Explorar el Código

'年度评价接口'

Yikoo hace 5 años
padre
commit
a782f88a91

+ 16 - 0
src/dashoo.cn/backend/api/business/oilcontract/contractSumScore/contractSumScore.go

@@ -36,3 +36,19 @@ type OilContractSumScore struct {
 	ModifiedUserId   int       `json:"ModifiedUserId" xorm:"INT(11) 'ModifiedUserId'"`
 	ModifiedBy       string    `json:"ModifiedBy" xorm:"VARCHAR(50) 'ModifiedBy'"`
 }
+
+type OilContractComputeSumScoreVo struct {
+	SupplierId    int       `json:"SupplierId"`
+	SupplierName  string    `json:"SupplierName"`
+	Score         string    `json:"Score"`
+	Score1    	  string    `json:"Score1"`
+	Score2  	  string    `json:"Score2"`
+	Score3        string    `json:"Score3"`
+	Score4    	  string    `json:"Score4"`
+	Score5  	  string    `json:"Score5"`
+	Score6        string    `json:"Score6"`
+	Score7    	  string    `json:"Score7"`
+	Score8  	  string    `json:"Score8"`
+	Score9        string    `json:"Score9"`
+	Evaluate 	  string    `json:"Evaluate"`
+}

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

@@ -1,8 +1,11 @@
 package contractSumScore
 
 import (
+	"dashoo.cn/backend/api/controllers"
 	. "dashoo.cn/backend/api/mydb"
+	"dashoo.cn/utils"
 	"github.com/go-xorm/xorm"
+	"strconv"
 )
 
 type OilContractSumScoreService struct {
@@ -14,3 +17,54 @@ func GetOilContractSumScoreService(xormEngine *xorm.Engine) *OilContractSumScore
 	s.DBE = xormEngine
 	return s
 }
+
+func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
+	var resultsSlice []map[string][]byte
+	//获取总记录数
+	sqlCount := ` select count(*) from ( `
+	sqlCount += ` select contract.SupplierId from ` + controllers.OilContractReviewName + ` review `
+	sqlCount += ` left join ` + controllers.OilContractName + ` contract on review.ContractId=contract.id `
+	sqlCount += ` left join ` + controllers.OilContractEvaluationItemsName + ` items on items.ContentReviewId=review.id and items.LevelCode=1 `
+	sqlCount += ` where ` + where
+	sqlCount += ` group by contract.SupplierId,contract.SupplierName `
+	sqlCount += ` ) t `
+
+	var sql string
+	sql =  `select contract.SupplierId,contract.SupplierName,sum(items.Score) as Score, `
+	sql += ` sum(case when items.SequenceNo in  ('1') then items.Score else 0 end) Score1,  `
+	sql += ` sum(case when items.SequenceNo in  ('2') then items.Score else 0 end) Score2,  `
+	sql += ` sum(case when items.SequenceNo in  ('3') then items.Score else 0 end) Score3,  `
+	sql += ` sum(case when items.SequenceNo in  ('4') then items.Score else 0 end) Score4,  `
+	sql += ` sum(case when items.SequenceNo in  ('5') then items.Score else 0 end) Score5,  `
+	sql += ` sum(case when items.SequenceNo in  ('6') then items.Score else 0 end) Score6,  `
+	sql += ` sum(case when items.SequenceNo in  ('7') then items.Score else 0 end) Score7,  `
+	sql += ` sum(case when items.SequenceNo in  ('8') then items.Score else 0 end) Score8,  `
+	sql += ` sum(case when items.SequenceNo in  ('9') then items.Score else 0 end) Score9,  `
+	sql += ` case when sum(items.Score) <60 then '不合格' when sum(items.Score) <80 then '合格' else '优秀' 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 `
+	sql += ` where ` + where
+	sql += ` group by contract.SupplierId,contract.SupplierName `
+
+	if asc {
+		sql += ` order by ` + orderby + ` ASC `
+	} else {
+		sql += ` order by ` + orderby + ` DESC `
+	}
+	if (pageIndex != 0 && itemsPerPage !=0) {
+		sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
+	}
+
+	s.DBE.SQL(sql).Find(entitiesPtr)
+	resultsSlice, _ = s.DBE.Query(sqlCount)
+	if len(resultsSlice) > 0 {
+		results := resultsSlice[0]
+		for _, value := range results {
+			total, _ = strconv.ParseInt(string(value), 10, 64)
+			break
+		}
+	}
+	return total
+}
+

+ 36 - 0
src/dashoo.cn/backend/api/controllers/oilcontract/contractSumScore.go

@@ -181,6 +181,42 @@ func (this *OilContractSumScoreController) GetEntityList() {
 	this.ServeJSON()
 }
 
+// @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 "
+	orderby := "contract.SupplierId"
+	asc := false
+	Order := this.GetString("Order")
+	Prop := this.GetString("Prop")
+	if Order != "" && Prop != "" {
+		orderby = Prop
+		if Order == "asc" {
+			asc = true
+		}
+	}
+	SupplierName := this.GetString("SupplierName")
+
+	if SupplierName != "" {
+		where = where + " and contract.SupplierName like '%" + SupplierName + "%'"
+	}
+
+	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
+	var list []contractSumScore.OilContractComputeSumScoreVo
+	total := svc.GetPagingComputeEntitiesWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	datainfo.PageIndex = page.CurrentPage
+	datainfo.ItemsPerPage = page.Size
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
 // @Title 获取字典列表
 // @Description get user by token
 // @Success 200 {object} map[string]interface{}

+ 6 - 0
src/dashoo.cn/backend/api/routers/router.go

@@ -501,6 +501,12 @@ func init() {
 				&oilcontract.OilContractEvaluationOrderController{},
 			),
 		),
+		// 合同年度汇总分
+		beego.NSNamespace("/contract-score",
+			beego.NSInclude(
+				&oilcontract.OilContractSumScoreController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }