Forráskód Böngészése

年度汇总优化;修改合同评价优化

wd 2 éve
szülő
commit
a64688fe96

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

@@ -191,7 +191,7 @@ func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl2(pag
 	sql += ` ROUND(sum(case when items.SequenceNo in  ('3') AND items.Type =3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + `  then 1 else 0 end),2) ConditionScore3,  `
 	sql += ` ROUND(sum(case when items.SequenceNo in  ('4') AND items.Type =3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + `  then 1 else 0 end),2) ConditionScore4,  `
 	sql += ` ROUND(sum(case when items.SequenceNo in  ('5') AND items.Type =3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + `  then 1 else 0 end),2) ConditionScore5,  `
-	sql += ` ROUND(sum(case when items.ParentId = 0 AND items.Type = 3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type = 3` + where1 + `  then 1 else 0 end),2) ConditionScore,  `
+	sql += ` if(count(review.id) > 0, ROUND(sum(case when items.ParentId = 0 AND items.Type = 3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type = 3` + where1 + `  then 1 else 0 end),2), c.BasicConditionScore) ConditionScore,  `
 
 	if scoreType == "2" {
 		where1 += " AND items.Category = 0 "
@@ -229,6 +229,94 @@ func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl2(pag
 
 	s.DBE.SQL(sql).Find(entitiesPtr)
 }
+func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl3(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string, having string, scoreType string, reviewWhere string, supplierWhere string) (total int64) {
+	// 优秀、合格分数值从配置中取
+	var paramEntityList []baseparameter.Base_Parameter
+	paramsSvc := baseparameter.GetBaseparameterService(utils.DBE)
+	paramEntityList = paramsSvc.GetBaseparameterbyid("GFGL_CONTRACT", "paramset")
+	good := "80"
+	pass := "60"
+	for _, i := range paramEntityList {
+		if i.Parametercode == "yearEvaGood" {
+			good = i.Parametercontent
+		}
+		if i.Parametercode == "yearEvaPass" {
+			pass = i.Parametercontent
+		}
+	}
+	where1 := ""
+
+	//获取总记录数
+	sqlCount := ` select count(*) from ( `
+	sqlCount += ` select contract.SupplierId `
+	sqlCount += ` FROM OilSupplier s `
+	sqlCount += ` LEFT JOIN OilSupplierCert c ON s.id = c.SupplierId `
+	sqlCount += ` left join ` + controllers.OilContractName + ` contract on s.id=contract.SupplierId ` + where
+	sqlCount += ` left join ` + controllers.OilContractReviewName + ` review on review.ContractId=contract.id ` + reviewWhere
+	sqlCount += ` left join ` + controllers.OilContractEvaluationItemsName + ` items on items.ContentReviewId=review.id and items.LevelCode=1 ` + where1
+	sqlCount += ` where 1=1 and c.InFlag != '3' and c.status = '8' ` + supplierWhere
+	sqlCount += ` group by s.id, contract.SupplierId,contract.SupplierName `
+	sqlCount += ` having ` + having
+	sqlCount += ` ) t `
+
+	var resultsSlice []map[string][]byte
+
+	var sql string
+
+	sql = `select YEAR(NOW()) as Year,contract.ContractClass,s.Id as SupplierId,s.SupplierName,count(review.id) as count, `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + ` then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + `  then 1 else 0 end),2) ConditionScore1,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('2') AND items.Type =3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + `  then 1 else 0 end),2) ConditionScore2,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('3') AND items.Type =3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + `  then 1 else 0 end),2) ConditionScore3,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('4') AND items.Type =3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + `  then 1 else 0 end),2) ConditionScore4,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('5') AND items.Type =3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =3` + where1 + `  then 1 else 0 end),2) ConditionScore5,  `
+	sql += ` if(count(review.id) > 0, ROUND(sum(case when items.ParentId = 0 AND items.Type = 3` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type = 3` + where1 + `  then 1 else 0 end),2), c.BasicConditionScore) ConditionScore,  `
+
+	if scoreType == "2" {
+		where1 += " AND items.Category = 0 "
+	} else if scoreType == "3" {
+		where1 += " AND (items.Category = 1 or items.Category = 2) "
+	}
+
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + ` then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score1,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('2') AND items.Type =1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score2,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('3') AND items.Type =1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score3,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('4') AND items.Type =1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score4,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('5') AND items.Type =1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score5,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('6') AND items.Type =1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score6,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('7') AND items.Type =1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score7,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('8') AND items.Type =1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score8,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('9') AND items.Type =1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type =1` + where1 + `  then 1 else 0 end),2) Score9,  `
+	sql += ` ROUND(sum(case when items.ParentId = 0 AND items.Type = 1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type = 1` + where1 + `  then 1 else 0 end) * 0.75,2) Score,  `
+	sql += ` case when ROUND(sum(case when items.ParentId = 0 AND items.Type = 1` + where1 + `  then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type = 1` + where1 + `  then 1 else 0 end) * 0.75,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) * 0.75,2) < ` + good + ` then 2 else 1 end as Evaluate, `
+	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) * 0.75,2) + ROUND(sum(case when items.ParentId = 0 AND items.Type = 3 then items.Score else 0 end)/sum(case when items.SequenceNo in  ('1') AND items.Type = 3  then 1 else 0 end),2)) CountScore `
+	sql += ` FROM OilSupplier s `
+	sql += ` LEFT JOIN OilSupplierCert c ON s.id = c.SupplierId `
+	sql += ` left join ` + controllers.OilContractName + ` contract on s.id=contract.SupplierId ` + where
+	sql += ` left join ` + controllers.OilContractReviewName + ` review on review.ContractId=contract.id ` + reviewWhere
+	sql += ` left join ` + controllers.OilContractEvaluationItemsName + ` items on items.ContentReviewId=review.id and items.LevelCode=1 ` + where1
+	sql += ` where 1=1 and c.InFlag != '3' and c.status = '8' ` + supplierWhere
+	sql += ` group by s.id, contract.SupplierId,contract.SupplierName `
+	sql += ` having ` + having
+	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
+}
 func (s *OilContractSumScoreService) GetComputeEntity(entitiesPtr interface{}, where string) {
 	// 优秀、合格分数值从配置中取
 	var paramEntityList []baseparameter.Base_Parameter

+ 1 - 0
src/dashoo.cn/backend/api/business/oilsupplier/suppliercert/oilsuppliercert.go

@@ -72,6 +72,7 @@ type OilSupplierCert struct {
 	ModifiedUserId    int       `xorm:"INT(10)"`
 	ModifiedBy        string    `xorm:"VARCHAR(50)"`
 	GfId              int       `xorm:"INT(11)"`
+	BasicConditionScore              int       `xorm:"default 0 comment('基本条件评价') INT(10)"`
 }
 
 type Del_OilSupplierCert struct {

+ 40 - 38
src/dashoo.cn/backend/api/controllers/oilcontract/contractReview.go

@@ -804,48 +804,42 @@ func (this *OilContractReviewController) UpdateEntity() {
 		panic("操作失败!评价细项信息不完整")
 	}
 
-	cols := []string{"Score", "Value", "Remark", "ModifiedOn", "ModifiedBy", "ModifiedUserId"}
+	//cols := []string{"Score", "Value", "Remark", "ModifiedOn", "ModifiedBy", "ModifiedUserId"}
 	if modeVO.IsBusiness == 0 {
 		//where := "ContentReviewId=" + id + " AND Category = 0 "
 		// 清除掉之前的
 		//itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where)
 
+		score := "Score = CASE ItemId "
+		value := "Value = CASE ItemId "
+		remark := "Remark = CASE ItemId "
+		modifiedOn := "ModifiedOn = CASE ItemId "
+		modifiedBy := "ModifiedBy = CASE ItemId "
+		modifiedUserId := "ModifiedUserId = CASE ItemId "
+		userId, _ := utils.StrTo(this.User.Id).Int()
 		// 新增配置项
 		for _, v := range modeVO.Items {
 			if v.Id == 0 {
 				panic("操作失败!请求信息Id不完整")
 			}
-			var temp contractEvaluationItems.OilContractEvaluationItems
-			temp.Score = v.Score
-			temp.Value = v.Value
-			temp.Remark = v.Remark
-			temp.ModifiedOn = time.Now()
-			temp.ModifiedBy = this.User.Realname
-			temp.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-			err := itemSvc.UpdateEntityBywheretbl(OilContractEvaluationItemsName, &temp, cols, "Category = 0 and ContentReviewId = "+id+" and ItemId = "+strconv.Itoa(v.Id))
-			if err != nil {
-				panic("修改失败!" + utils.AlertProcess(err.Error()))
-			}
+			score += " WHEN " + strconv.Itoa(v.Id) + " THEN " + v.Score
+			value += " WHEN " + strconv.Itoa(v.Id) + " THEN " + strconv.Itoa(v.Value)
+			remark += " WHEN " + strconv.Itoa(v.Id) + " THEN '" + v.Remark + "'"
+			modifiedOn += " WHEN " + strconv.Itoa(v.Id) + " THEN '" + time.Now().Format("2006-01-02 15:04:05") + "'"
+			modifiedBy += " WHEN " + strconv.Itoa(v.Id) + " THEN '" + this.User.Realname + "'"
+			modifiedUserId += " WHEN " + strconv.Itoa(v.Id) + " THEN " + strconv.Itoa(userId)
+		}
+		setWhere := score + " END, " + value + " END, " + remark + " END, " + modifiedOn + " END, " + modifiedBy + " END, " + modifiedUserId + " END "
+		setWhere1 := score + " END, " + value + " END, " + remark + " END "
+		err := itemSvc.UpdateBatch(setWhere, "Category = 0 and ContentReviewId = " + id)
+		err1 := itemSvc.UpdateBatch(setWhere1, "Category = 1 and ContentReviewId = " + id)
+		if err != nil || err1 != nil {
+			panic("修改失败!" + utils.AlertProcess(err.Error()))
 		}
 
 		//where2 := "ContentReviewId=" + id + " AND Category = 1 "
 		// 清除掉之前的
 		//itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where2)
-
-		// 新增配置项
-		for _, v := range modeVO.Items {
-			if v.Id == 0 {
-				panic("操作失败!请求信息Id不完整")
-			}
-			var temp2 contractEvaluationItems.OilContractEvaluationItems
-			temp2.Score = v.Score
-			temp2.Value = v.Value
-			temp2.Remark = v.Remark
-			err := itemSvc.UpdateEntityBywheretbl(OilContractEvaluationItemsName, &temp2, cols, "Category = 1 and ContentReviewId = "+id+" and ItemId = "+strconv.Itoa(v.Id))
-			if err != nil {
-				panic("修改失败!" + utils.AlertProcess(err.Error()))
-			}
-		}
 	}
 
 	if modeVO.IsBusiness == 1 {
@@ -853,21 +847,29 @@ func (this *OilContractReviewController) UpdateEntity() {
 		// 清除掉之前的
 		//itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName, where3)
 		// 新增配置项
+		score := "Score = CASE ItemId "
+		value := "Value = CASE ItemId "
+		remark := "Remark = CASE ItemId "
+		modifiedOn := "ModifiedOn = CASE ItemId "
+		modifiedBy := "ModifiedBy = CASE ItemId "
+		modifiedUserId := "ModifiedUserId = CASE ItemId "
+		userId, _ := utils.StrTo(this.User.Id).Int()
+		// 新增配置项
 		for _, v := range modeVO.Items {
 			if v.Id == 0 {
 				panic("操作失败!请求信息Id不完整")
 			}
-			var temp3 contractEvaluationItems.OilContractEvaluationItems
-			temp3.Score = v.Score
-			temp3.Value = v.Value
-			temp3.Remark = v.Remark
-			temp3.ModifiedOn = time.Now()
-			temp3.ModifiedBy = this.User.Realname
-			temp3.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-			err := itemSvc.UpdateEntityBywheretbl(OilContractEvaluationItemsName, &temp3, cols, "Category = 2 and ContentReviewId = "+id+" and ItemId = "+strconv.Itoa(v.Id))
-			if err != nil {
-				panic("修改失败!" + utils.AlertProcess(err.Error()))
-			}
+			score += " WHEN " + strconv.Itoa(v.Id) + " THEN " + v.Score
+			value += " WHEN " + strconv.Itoa(v.Id) + " THEN " + strconv.Itoa(v.Value)
+			remark += " WHEN " + strconv.Itoa(v.Id) + " THEN '" + v.Remark + "'"
+			modifiedOn += " WHEN " + strconv.Itoa(v.Id) + " THEN '" + time.Now().Format("2006-01-02 15:04:05") + "'"
+			modifiedBy += " WHEN " + strconv.Itoa(v.Id) + " THEN '" + this.User.Realname + "'"
+			modifiedUserId += " WHEN " + strconv.Itoa(v.Id) + " THEN " + strconv.Itoa(userId)
+		}
+		setWhere := score + " END, " + value + " END, " + remark + " END, " + modifiedOn + " END, " + modifiedBy + " END, " + modifiedUserId + " END "
+		err := itemSvc.UpdateBatch(setWhere, "Category = 2 and ContentReviewId = " + id)
+		if err != nil {
+			panic("修改失败!" + utils.AlertProcess(err.Error()))
 		}
 	}
 }

+ 143 - 16
src/dashoo.cn/backend/api/controllers/oilcontract/contractSumScore.go

@@ -5,6 +5,7 @@ import (
 	"dashoo.cn/backend/api/business/oilcontract/contractSumScoreItems"
 	"dashoo.cn/backend/api/business/oilcontract/evaluationItems"
 	"dashoo.cn/backend/api/business/oilsupplier/supplier"
+	"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
 	baseparameter "dashoo.cn/business/parameter"
 	"dashoo.cn/business2/permission"
 	"fmt"
@@ -144,7 +145,10 @@ func (this *OilContractSumScoreController) GetComputeEntityList() {
 	//获取分页信息
 	page := this.GetPageInfoForm()
 	where := " 1=1 "
+	where3 := ""
 	having := " 1=1 "
+	reviewWhere := " "
+	supplierWhere := " "
 	orderby := "contract.SupplierId"
 	asc := false
 	Order := this.GetString("Order")
@@ -164,12 +168,19 @@ func (this *OilContractSumScoreController) GetComputeEntityList() {
 
 	if SupplierName != "" {
 		where = where + " and contract.SupplierName like '%" + SupplierName + "%'"
+		supplierWhere = supplierWhere + " and s.SupplierName like '%" + SupplierName + "%'"
 	}
 	if ScoreType == "2" {
 		where = where + " and review.IsBusiness=0 "
+		reviewWhere = reviewWhere + " and review.IsBusiness=0 "
 	}
+
+	// 审核通过的参与核算
+	reviewWhere = reviewWhere + " and review.Status='8' "
 	if ContractClass != "" {
+		where3 = where3 + " and contract.ContractClass = '" + ContractClass + "'"
 		where = where + " and contract.ContractClass = '" + ContractClass + "'"
+		supplierWhere = supplierWhere + " and c.SupplierTypeCode = '" + ContractClass + "'"
 	}
 
 	// 优秀、合格分数值从配置中取
@@ -204,6 +215,7 @@ func (this *OilContractSumScoreController) GetComputeEntityList() {
 	month := "01"
 	day := "01"
 	where = where + " and review.CreateOn>='" + year + "-" + month + "-" + day + "' and review.CreateOn <= '" + year + "-12-31 23:59:59' "
+	reviewWhere = reviewWhere + " and review.CreateOn>='" + year + "-" + month + "-" + day + "' and review.CreateOn <= '" + year + "-12-31 23:59:59' "
 
 	//if CreateOn != "" {
 	//	dates := strings.Split(CreateOn, ",")
@@ -219,22 +231,12 @@ func (this *OilContractSumScoreController) GetComputeEntityList() {
 
 	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
 	var list []contractSumScore.OilContractComputeSumScoreVo
-	total := svc.GetPagingComputeEntitiesWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where, having, ScoreType)
-
-	//if ContractClass == "02" {
-	//	for index, item := range list {
-	//		where1 := where + " and contract.SupplierId = " + strconv.Itoa(item.SupplierId)
-	//		var list1 []contractSumScore.OilContractSumScoreResult
-	//		svc.GetSumListEntitiesWithOrderBytbl(&list1, where1)
-	//		if len(list1) > 0 {
-	//			for _, value := range list1 {
-	//				if value.Result2 == "0" {
-	//					list[index].Result = "0"
-	//				}
-	//			}
-	//		}
-	//	}
-	//}
+	var total int64
+	if ContractClass == "02" {
+		total = svc.GetPagingComputeEntitiesWithOrderBytbl3(page.CurrentPage, page.Size, orderby, asc, &list, where3, having, ScoreType, reviewWhere, supplierWhere)
+	} else {
+		total = svc.GetPagingComputeEntitiesWithOrderBytbl(page.CurrentPage, page.Size, orderby, asc, &list, where, having, ScoreType)
+	}
 	var datainfo DataInfo
 	datainfo.Items = list
 	datainfo.CurrentItemCount = total
@@ -1111,6 +1113,131 @@ func (this *OilContractSumScoreController) ExcelExport() {
 	}
 }
 
+// 定时任务
+func (this *OilContractSumScoreController) SaveBasicConditionScore() {
+	var certList []suppliercert.OilSupplierCert
+	certSvc := suppliercert.GetOilSupplierCertService(utils.DBE)
+	certSvc.GetEntitysByWhere(OilSupplierCertName, "InFlag = '1' or InFlag = '2'", &certList)
+	for _, item := range certList {
+		item.BasicConditionScore = this.GetBasicConditionScore(item.SupplierId, item.SupplierTypeCode)
+		certSvc.UpdateEntityBytbl(OilSupplierCertName, item.Id, &item, []string{"BasicConditionScore"})
+	}
+}
+
+func (this *OilContractSumScoreController) GetBasicConditionScore(supplierId int, contractClass string) (normalScore int) {
+	supplierSvc := supplier.GetOilSupplierService(utils.DBE)
+	var supplierModel supplier.OilSupplier
+	contractSvc := contract.GetOilContractService(utils.DBE)
+	supplierSvc.GetEntityByIdBytbl(OilSupplierName, supplierId, &supplierModel)
+	regCapital := supplierModel.RegCapital * 10000 // 注册资金
+	operType := supplierModel.OperType // 类型
+	legalPerson := supplierModel.LegalPerson // 法人
+
+	var certModel suppliercert.OilSupplierCert
+	certSvc := suppliercert.GetOilSupplierCertService(utils.DBE)
+	certSql := "SupplierId = " + strconv.Itoa(supplierId) + " and SupplierTypeCode = " + contractClass + " and InFlag = '1' and ApplyTime > now()"
+	certSvc.GetEntityByWhere(OilSupplierCertName, certSql, &certModel)
+
+	var fileList []supplierfile.OilSupplierFile
+	// 过期的file
+	fileSql := "SupplierId = " + strconv.Itoa(supplierId) + " and EffectDate < now()"
+	certSvc.GetEntitysByWhere(OilSupplierFileName, fileSql, &fileList)
+
+	normalScore = 0
+	if contractClass == "01" {
+		// 供方是否具有独立法人资格,《市场管理信息系统》中供方名称与营业执照是否一致,保持一致且持续有效得5分,否则为0分。
+		fileTotal := contractSvc.GetFileCountByName("营业执照", supplierId, "01")
+		if fileTotal > 0 && legalPerson != "" {
+			normalScore += 5
+		}
+
+		// 制造商5分,代理商3分,贸易商1分。
+		if operType == "制造商" {
+			normalScore += 5
+		} else if operType == "代理商" {
+			normalScore += 3
+		} else if operType == "贸易商" {
+			normalScore += 1
+		}
+
+		// 注册资金在1亿元及以上得5分,小于1亿元且大于5000万元得4分,5000万元及以下且大于1000万元得3分,1000万元及以下且大于500万元得2分,500万元及以下得1分
+		if regCapital >= 100000000 {
+			normalScore += 5
+		} else if regCapital < 100000000 && regCapital > 50000000 {
+			normalScore += 4
+		} else if regCapital <= 50000000 && regCapital > 10000000 {
+			normalScore += 3
+		} else if regCapital <= 10000000 && regCapital > 5000000 {
+			normalScore += 2
+		} else if regCapital <= 5000000 {
+			normalScore += 1
+		}
+
+		// 如期办理大港油田公司供方年审、及时更新相关资质信息,系统准入状态有效的得5分,否则为0分。
+		if certModel.Id > 0 && len(fileList) == 0 {
+			normalScore += 5
+		}
+
+		// 具备质量管理体系认证证书且持续有效得5分,认证证书过期或无认证证书得0分
+		fileTotal1 := contractSvc.GetFileCountByName("质量管理体系认证证书", supplierId, "01")
+		if fileTotal1 > 0 {
+			normalScore += 5
+		}
+
+	} else if contractClass == "02" || contractClass == "03" {
+		// 供方名称与营业执照保持一致且持续有效得5分,否则为0分。
+		fileTotal := contractSvc.GetFileCountByName("营业执照", supplierId, contractClass)
+		if fileTotal > 0 && legalPerson != "" {
+			normalScore += 5
+		}
+
+		// 注册资金在1亿元及以上得5分,小于1亿元且大于5000万元得4分,5000万元及以下且大于1000万元得3分,1000万元及以下且大于500万元得2分,500万元及以下得1分
+		if regCapital >= 100000000 {
+			normalScore += 5
+		} else if regCapital < 100000000 && regCapital > 50000000 {
+			normalScore += 4
+		} else if regCapital <= 50000000 && regCapital > 10000000 {
+			normalScore += 3
+		} else if regCapital <= 10000000 && regCapital > 5000000 {
+			normalScore += 2
+		} else if regCapital <= 5000000 {
+			normalScore += 1
+		}
+
+		// 如期办理大港油田公司供方年审、及时更新相关资质信息,系统准入状态有效的得5分,否则为0分。
+		if certModel.Id > 0 && len(fileList) == 0 {
+			normalScore += 5
+		}
+
+		// 质量、环境、职业健康安全管理体系认证通过且持续有效得5分,其中一个证书失效扣1分,两个证书失效扣2分,三个证书全部失效及无以上三个证书供方得0分
+		fileTotal1 := contractSvc.GetFileCountByName("环境管理体系认证证书", supplierId, contractClass)
+		fileTotal2 := contractSvc.GetFileCountByName("质量管理体系认证证书", supplierId, contractClass)
+		fileTotal3 := contractSvc.GetFileCountByName("职业健康安全管理体系认证证书", supplierId, contractClass)
+		if fileTotal1 == 0 && fileTotal2 == 0 && fileTotal3 == 0 {
+			normalScore += 0
+		} else {
+			score := 5
+			if fileTotal1 < 0 {
+				score-=1
+			}
+			if fileTotal2 < 0 {
+				score-=1
+			}
+			if fileTotal3 < 0 {
+				score-=1
+			}
+			normalScore += score
+		}
+
+		// 按要求办理大港油田公司安全资质审查得5分,否则为0分。
+		fileTotal4 := contractSvc.GetFileCountByName("安全资质审查", supplierId, contractClass)
+		if fileTotal4 > 0 {
+				normalScore += 5
+			}
+		}
+	return normalScore
+}
+
 // @Title 添加
 // @Description 专业科室保存评价
 // @Param 	body body contractSumScore.OilContractSumScore

+ 9 - 0
src/dashoo.cn/backend/api/controllers/toolbox/toolbox.go

@@ -2,6 +2,7 @@ package toolbox
 
 import (
 	"dashoo.cn/backend/api/controllers/invoice"
+	"dashoo.cn/backend/api/controllers/oilcontract"
 	"dashoo.cn/backend/api/controllers/oilsupplier"
 	"github.com/astaxie/beego/toolbox"
 )
@@ -14,6 +15,7 @@ func TimingTask() {
 	c := new(oilsupplier.OilSupplierCertController)
 	invoice := new(invoice.OilInvoiceController)
 	todo := new(oilsupplier.TodoListController)
+	score := new(oilcontract.OilContractSumScoreController)
 	//supplier := new(oilsupplier.OilSupplierController)
 
 	//tkInFlag := toolbox.NewTask("myTaskInFlag", "0 0 1 * * *", func() error {
@@ -102,6 +104,13 @@ func TimingTask() {
 	})
 	toolbox.AddTask("myTaskNumberReset", tkNumberReset)
 
+	// 每天 1点 获取公司的基本条件评价 0 0 1 * * ?
+	basicConditionScore := toolbox.NewTask("myTaskBasicConditionScore", "0 0 1 * * ?", func() error {
+		score.SaveBasicConditionScore()
+		return nil
+	})
+	toolbox.AddTask("myTaskBasicConditionScore", basicConditionScore)
+
 	toolbox.StartTask()
 
 	//toolbox.StopTask()

+ 1 - 1
src/dashoo.cn/frontend_web/src/pages/oilcontract/contract-basis-year/index.vue

@@ -59,7 +59,7 @@
       <el-table id="rebateSetTable" highlight-current-row stripe size="mini" :data="entityList" border height="calc(100vh - 243px)" style="width: 100%" @sort-change="orderby" v-loading="tableLoading">
         <el-table-column label="操作" header-align="center" width="100" align="center" fixed="right">
           <template slot-scope="scope">
-              <el-button type="text" title="查看" size="small" icon="el-icon-edit" @click="onNavigateScore(scope.row)">查看</el-button>
+              <el-button type="text" title="查看" size="small" icon="el-icon-edit" :disabled="scope.row.Score === ''" @click="onNavigateScore(scope.row)">查看</el-button>
           </template>
         </el-table-column>
         <el-table-column align="center" width="70" label="序号">