Przeglądaj źródła

'年度汇总查询接口修改'

Yikoo 4 lat temu
rodzic
commit
c6752f1557

+ 4 - 4
src/dashoo.cn/backend/api/business/oilcontract/contractSumScore/contractSumScoreService.go

@@ -64,7 +64,7 @@ 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) (total int64) {
+func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string,having string) (total int64) {
 	var resultsSlice []map[string][]byte
 	//获取总记录数
 	sqlCount := ` select count(*) from ( `
@@ -103,7 +103,7 @@ func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(page
 	sql += ` left join ` + controllers.OilContractEvaluationItemsName + ` items on items.ContentReviewId=review.id and items.LevelCode=1 `
 	sql += ` where ` + where
 	sql += ` group by contract.SupplierId,contract.SupplierName `
-
+	sql += ` having ` + having
 	if asc {
 		sql += ` order by ` + orderby + ` ASC `
 	} else {
@@ -138,11 +138,11 @@ func (s *OilContractSumScoreService) GetSumListEntitiesWithOrderBytbl(entitiesPt
 
 	s.DBE.SQL(sql).Find(entitiesPtr)
 }
-
 func (s *OilContractSumScoreService) GetComputeEntityBytbl(where string) OilContractComputeSumScoreVo{
 	var model OilContractComputeSumScoreVo
+	// contract.ContractClass,
 	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.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, `

+ 13 - 7
src/dashoo.cn/backend/api/controllers/oilcontract/contractSumScore.go

@@ -133,13 +133,15 @@ func (this *OilContractSumScoreController) GetEntityList() {
 }
 
 // @Title 获取核算列表
+
 // @Description get user by token
 // @Success 200 {object} []contractSumScore.OilContractSumScore
 // @router /compute-list [get]
 func (this *OilContractSumScoreController) GetComputeEntityList() {
 	//获取分页信息
 	page := this.GetPageInfoForm()
-	where := " 1=1 "
+	where  := " 1=1 "
+	having := " 1=1 "
 	orderby := "contract.SupplierId"
 	asc := false
 	Order := this.GetString("Order")
@@ -162,14 +164,14 @@ func (this *OilContractSumScoreController) GetComputeEntityList() {
 		where = where + " and contract.ContractClass = '" + ContractClass + "'"
 	}
 
-	if Evaluate == "1" {
 
-	} else if Evaluate == "2" {
-
-	} else if Evaluate == "3" {
+	if Evaluate == "1" {  // 优秀
 
+	} else if Evaluate == "2" {  // 合格
+		having = "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"
+	} else if Evaluate == "3" {  // 不合格
+		having = "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"
 	}
-
 	// 今年的汇总
 	year := strconv.Itoa(time.Now().Year())
 	month := "01"
@@ -190,7 +192,7 @@ func (this *OilContractSumScoreController) GetComputeEntityList() {
 
 	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
 	var list []contractSumScore.OilContractComputeSumScoreVo
-	total := svc.GetPagingComputeEntitiesWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where)
+	total := svc.GetPagingComputeEntitiesWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where,having)
 	var datainfo DataInfo
 	datainfo.Items = list
 	datainfo.CurrentItemCount = total
@@ -205,8 +207,12 @@ func (this *OilContractSumScoreController) GetComputeEntityList() {
 // @router /compute-entity/:id [get]
 func (this *OilContractSumScoreController) GetComputeEntity(){
 	Id := this.Ctx.Input.Param(":id")
+	ContractClass := this.GetString("ContractClass", "01")
 	where := " contract.SupplierId = " + Id
 	where = where + " and review.Status='8' "
+	if ContractClass != "" {
+		where = where + " and contract.ContractClass = '" + ContractClass + "'"
+	}
 	// 今年的汇总
 	year := strconv.Itoa(time.Now().Year())
 	month := "01"