|
|
@@ -3,6 +3,7 @@ package contractSumScore
|
|
|
import (
|
|
|
"dashoo.cn/backend/api/controllers"
|
|
|
. "dashoo.cn/backend/api/mydb"
|
|
|
+ baseparameter "dashoo.cn/business/parameter"
|
|
|
"dashoo.cn/utils"
|
|
|
"github.com/go-xorm/xorm"
|
|
|
"strconv"
|
|
|
@@ -18,7 +19,7 @@ func GetOilContractSumScoreService(xormEngine *xorm.Engine) *OilContractSumScore
|
|
|
return s
|
|
|
}
|
|
|
|
|
|
-func (s *OilContractSumScoreService)GetMyPagingEntitiesWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
|
|
|
+func (s *OilContractSumScoreService) GetMyPagingEntitiesWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
|
|
|
var resultsSlice []map[string][]byte
|
|
|
//获取总记录数
|
|
|
sqlCount := ` select count(*) from ` + controllers.OilContractSumScoreName + ` score `
|
|
|
@@ -26,7 +27,7 @@ func (s *OilContractSumScoreService)GetMyPagingEntitiesWithOrderBytbl(pageIndex,
|
|
|
sqlCount += ` where ` + where
|
|
|
|
|
|
var sql string
|
|
|
- sql = `select * `
|
|
|
+ sql = `select * `
|
|
|
sql += ` from ` + controllers.OilContractSumScoreName + ` score `
|
|
|
sql += ` left join ` + controllers.OilContractSumScoreItemsName + ` items on items.SumScoreId = score.id `
|
|
|
sql += ` where ` + where
|
|
|
@@ -36,7 +37,7 @@ func (s *OilContractSumScoreService)GetMyPagingEntitiesWithOrderBytbl(pageIndex,
|
|
|
} else {
|
|
|
sql += ` order by ` + orderby + ` DESC `
|
|
|
}
|
|
|
- if (pageIndex != 0 && itemsPerPage !=0) {
|
|
|
+ if pageIndex != 0 && itemsPerPage != 0 {
|
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
}
|
|
|
|
|
|
@@ -51,9 +52,9 @@ func (s *OilContractSumScoreService)GetMyPagingEntitiesWithOrderBytbl(pageIndex,
|
|
|
}
|
|
|
return total
|
|
|
}
|
|
|
-func (s *OilContractSumScoreService)GetMyEntitiesWithOrderBytbl( orderby string, asc bool, entitiesPtr interface{}, where string) () {
|
|
|
+func (s *OilContractSumScoreService) GetMyEntitiesWithOrderBytbl(orderby string, asc bool, entitiesPtr interface{}, where string) {
|
|
|
var sql string
|
|
|
- sql = `select * `
|
|
|
+ sql = `select * `
|
|
|
sql += ` from ` + controllers.OilContractSumScoreName + ` score `
|
|
|
sql += ` left join ` + controllers.OilContractSumScoreItemsName + ` items on items.SumScoreId = score.id `
|
|
|
sql += ` where ` + where
|
|
|
@@ -64,7 +65,22 @@ func (s *OilContractSumScoreService)GetMyEntitiesWithOrderBytbl( orderby string,
|
|
|
}
|
|
|
s.DBE.SQL(sql).Find(entitiesPtr)
|
|
|
}
|
|
|
-func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string,having string) (total int64) {
|
|
|
+func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string, having string) (total int64) {
|
|
|
+ // 优秀、合格分数值从配置中取
|
|
|
+ var paramEntityList []baseparameter.Base_Parameter
|
|
|
+ paramsSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
+ paramEntityList = paramsSvc.GetBaseparameterbyid("GFGL1", "paramset")
|
|
|
+ good := "80"
|
|
|
+ pass := "60"
|
|
|
+ for _, i := range paramEntityList {
|
|
|
+ if i.Parametercode == "yearEvaGood" {
|
|
|
+ good = i.Parametercontent
|
|
|
+ }
|
|
|
+ if i.Parametercode == "yearEvaPass" {
|
|
|
+ pass = i.Parametercontent
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var resultsSlice []map[string][]byte
|
|
|
//获取总记录数
|
|
|
sqlCount := ` select count(*) from ( `
|
|
|
@@ -76,7 +92,7 @@ func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(page
|
|
|
sqlCount += ` ) t `
|
|
|
|
|
|
var sql string
|
|
|
- sql = `select YEAR(NOW()) as Year,contract.ContractClass,contract.SupplierId,contract.SupplierName,count(review.id) as count, `
|
|
|
+ sql = `select YEAR(NOW()) as Year,contract.ContractClass,contract.SupplierId,contract.SupplierName,count(review.id) as count, `
|
|
|
|
|
|
sql += ` sum(case when items.SequenceNo in ('1') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end ) B1, `
|
|
|
sql += ` sum(case when items.SequenceNo in ('2') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end ) B2, `
|
|
|
@@ -97,7 +113,7 @@ func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(page
|
|
|
sql += ` ROUND(sum(case when items.SequenceNo in ('8') AND items.Type =1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type =1 then 1 else 0 end),2) Score8, `
|
|
|
sql += ` ROUND(sum(case when items.SequenceNo in ('9') AND items.Type =1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type =1 then 1 else 0 end),2) Score9, `
|
|
|
sql += ` ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) Score, `
|
|
|
- sql += ` case when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) <60 then 3 when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) <80 then 2 else 1 end as Evaluate `
|
|
|
+ sql += ` case when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) < ` + pass + ` then 3 when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) < ` + good + ` then 2 else 1 end as Evaluate `
|
|
|
sql += ` from ` + controllers.OilContractReviewName + ` review `
|
|
|
sql += ` left join ` + controllers.OilContractName + ` contract on review.ContractId=contract.id `
|
|
|
sql += ` left join ` + controllers.OilContractEvaluationItemsName + ` items on items.ContentReviewId=review.id and items.LevelCode=1 `
|
|
|
@@ -109,7 +125,7 @@ func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(page
|
|
|
} else {
|
|
|
sql += ` order by ` + orderby + ` DESC `
|
|
|
}
|
|
|
- if (pageIndex != 0 && itemsPerPage !=0) {
|
|
|
+ if pageIndex != 0 && itemsPerPage != 0 {
|
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
}
|
|
|
|
|
|
@@ -125,8 +141,23 @@ func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(page
|
|
|
return total
|
|
|
}
|
|
|
func (s *OilContractSumScoreService) GetComputeEntity(entitiesPtr interface{}, where string) {
|
|
|
+ // 优秀、合格分数值从配置中取
|
|
|
+ var paramEntityList []baseparameter.Base_Parameter
|
|
|
+ paramsSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
+ paramEntityList = paramsSvc.GetBaseparameterbyid("GFGL1", "paramset")
|
|
|
+ good := "80"
|
|
|
+ pass := "60"
|
|
|
+ for _, i := range paramEntityList {
|
|
|
+ if i.Parametercode == "yearEvaGood" {
|
|
|
+ good = i.Parametercontent
|
|
|
+ }
|
|
|
+ if i.Parametercode == "yearEvaPass" {
|
|
|
+ pass = i.Parametercontent
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var sql string
|
|
|
- sql = `select YEAR(NOW()) as Year,contract.ContractClass,contract.SupplierId,contract.SupplierName,count(review.id) as count, `
|
|
|
+ sql = `select YEAR(NOW()) as Year,contract.ContractClass,contract.SupplierId,contract.SupplierName,count(review.id) as count, `
|
|
|
|
|
|
sql += ` sum(case when items.SequenceNo in ('1') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end ) B1, `
|
|
|
sql += ` sum(case when items.SequenceNo in ('2') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end ) B2, `
|
|
|
@@ -147,7 +178,7 @@ func (s *OilContractSumScoreService) GetComputeEntity(entitiesPtr interface{}, w
|
|
|
sql += ` ROUND(sum(case when items.SequenceNo in ('8') AND items.Type =1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type =1 then 1 else 0 end),2) Score8, `
|
|
|
sql += ` ROUND(sum(case when items.SequenceNo in ('9') AND items.Type =1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type =1 then 1 else 0 end),2) Score9, `
|
|
|
sql += ` ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) Score, `
|
|
|
- sql += ` case when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) <60 then 3 when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) <80 then 2 else 1 end as Evaluate `
|
|
|
+ sql += ` case when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) < ` + pass + ` then 3 when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) < ` + good + ` then 2 else 1 end as Evaluate `
|
|
|
sql += ` from ` + controllers.OilContractReviewName + ` review `
|
|
|
sql += ` left join ` + controllers.OilContractName + ` contract on review.ContractId=contract.id `
|
|
|
sql += ` left join ` + controllers.OilContractEvaluationItemsName + ` items on items.ContentReviewId=review.id and items.LevelCode=1 `
|
|
|
@@ -158,7 +189,7 @@ func (s *OilContractSumScoreService) GetComputeEntity(entitiesPtr interface{}, w
|
|
|
}
|
|
|
func (s *OilContractSumScoreService) GetComputeEntity1(entitiesPtr interface{}, where string) {
|
|
|
var sql string
|
|
|
- sql = `select group_concat(DISTINCT items.Remark) as Content1`
|
|
|
+ sql = `select group_concat(DISTINCT items.Remark) as Content1`
|
|
|
sql += ` from ` + controllers.OilContractEvaluationItemsName + ` items `
|
|
|
sql += ` left join ` + controllers.OilContractReviewName + ` review on items.ContentReviewId=review.id and items.LevelCode=2 `
|
|
|
sql += ` left join ` + controllers.OilContractName + ` contract on review.ContractId=contract.id `
|
|
|
@@ -170,7 +201,7 @@ func (s *OilContractSumScoreService) GetComputeEntity1(entitiesPtr interface{},
|
|
|
func (s *OilContractSumScoreService) GetSumListEntitiesWithOrderBytbl(entitiesPtr interface{}, where string) {
|
|
|
|
|
|
var sql string
|
|
|
- sql = `select contract.Id,contract.SupplierId,contract.SupplierName,contract.Amount, `
|
|
|
+ sql = `select contract.Id,contract.SupplierId,contract.SupplierName,contract.Amount, `
|
|
|
sql += ` ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) Result1, `
|
|
|
sql += ` sum(case when items.Type = 2 AND items.Value = 1 then 1 else 0 end) Result2 `
|
|
|
sql += ` from ` + controllers.OilContractReviewName + ` review `
|
|
|
@@ -181,11 +212,26 @@ func (s *OilContractSumScoreService) GetSumListEntitiesWithOrderBytbl(entitiesPt
|
|
|
|
|
|
s.DBE.SQL(sql).Find(entitiesPtr)
|
|
|
}
|
|
|
-func (s *OilContractSumScoreService) GetComputeEntityBytbl(where string) OilContractComputeSumScoreVo{
|
|
|
+func (s *OilContractSumScoreService) GetComputeEntityBytbl(where string) OilContractComputeSumScoreVo {
|
|
|
+ // 优秀、合格分数值从配置中取
|
|
|
+ var paramEntityList []baseparameter.Base_Parameter
|
|
|
+ paramsSvc := baseparameter.GetBaseparameterService(utils.DBE)
|
|
|
+ paramEntityList = paramsSvc.GetBaseparameterbyid("GFGL1", "paramset")
|
|
|
+ good := "80"
|
|
|
+ pass := "60"
|
|
|
+ for _, i := range paramEntityList {
|
|
|
+ if i.Parametercode == "yearEvaGood" {
|
|
|
+ good = i.Parametercontent
|
|
|
+ }
|
|
|
+ if i.Parametercode == "yearEvaPass" {
|
|
|
+ pass = i.Parametercontent
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var model OilContractComputeSumScoreVo
|
|
|
// contract.ContractClass,
|
|
|
var sql string
|
|
|
- sql = `select YEAR(NOW()) as Year,contract.SupplierId,contract.SupplierName,count(review.id) as count, `
|
|
|
+ sql = `select YEAR(NOW()) as Year,contract.SupplierId,contract.SupplierName,count(review.id) as count, `
|
|
|
sql += ` sum(case when items.SequenceNo in ('1') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end ) B1, `
|
|
|
sql += ` sum(case when items.SequenceNo in ('2') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end ) B2, `
|
|
|
sql += ` sum(case when items.SequenceNo in ('3') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end ) B3, `
|
|
|
@@ -204,7 +250,7 @@ func (s *OilContractSumScoreService) GetComputeEntityBytbl(where string) OilCont
|
|
|
sql += ` ROUND(sum(case when items.SequenceNo in ('8') AND items.Type =1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type =1 then 1 else 0 end),2) Score8, `
|
|
|
sql += ` ROUND(sum(case when items.SequenceNo in ('9') AND items.Type =1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type =1 then 1 else 0 end),2) Score9, `
|
|
|
sql += ` ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) Score, `
|
|
|
- sql += ` case when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) <60 then 3 when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) <80 then 2 else 1 end as Evaluate `
|
|
|
+ sql += ` case when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) < ` + pass + ` then 3 when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1 then items.Score else 0 end)/sum(case when items.SequenceNo in ('1') AND items.Type = 1 then 1 else 0 end),2) < ` + good + ` then 2 else 1 end as Evaluate `
|
|
|
sql += ` from ` + controllers.OilContractReviewName + ` review `
|
|
|
sql += ` left join ` + controllers.OilContractName + ` contract on review.ContractId=contract.id `
|
|
|
sql += ` left join ` + controllers.OilContractEvaluationItemsName + ` items on items.ContentReviewId=review.id and items.LevelCode=1 `
|
|
|
@@ -215,7 +261,7 @@ func (s *OilContractSumScoreService) GetComputeEntityBytbl(where string) OilCont
|
|
|
return model
|
|
|
}
|
|
|
|
|
|
-func (s *OilContractSumScoreService)GetCount(where string) (total int64) {
|
|
|
+func (s *OilContractSumScoreService) GetCount(where string) (total int64) {
|
|
|
var resultsSlice []map[string][]byte
|
|
|
//获取总记录数
|
|
|
sqlCount := ` select count(*) from OilContract`
|
|
|
@@ -232,11 +278,10 @@ func (s *OilContractSumScoreService)GetCount(where string) (total int64) {
|
|
|
return total
|
|
|
}
|
|
|
|
|
|
-func (s *OilContractSumScoreService)GetSum(entitiesPtr interface{},where string){
|
|
|
+func (s *OilContractSumScoreService) GetSum(entitiesPtr interface{}, where string) {
|
|
|
|
|
|
sql := ` select sum(Amount) as Amount from OilContract`
|
|
|
sql += ` where ` + where
|
|
|
|
|
|
s.DBE.SQL(sql).Get(entitiesPtr)
|
|
|
}
|
|
|
-
|