Ver Fonte

完善年度评价接口

Yikoo há 5 anos atrás
pai
commit
fd5b552d9a

+ 3 - 0
src/dashoo.cn/backend/api/business/oilcontract/contractEvaluationItems/contractEvaluationItems.go

@@ -15,6 +15,7 @@ type OilContractEvaluationItems struct {
 	Content         string    `json:"Content" xorm:"comment('评价内容') VARCHAR(1000) 'Content'"`
 	NormalScore     string    `json:"NormalScore" xorm:"comment('标准分值') DECIMAL(11,2) 'NormalScore'"`
 	Score           string    `json:"Score" xorm:"comment('实得分数') DECIMAL(11,2) 'Score'"`
+	Value           int       `json:"Value" xorm:"not null default 0 comment('布尔专用') INT(11) 'Value'"`
 	LevelCode       int       `json:"LevelCode" xorm:"not null default 0 comment('级别') INT(11) 'LevelCode'"`
 	Remark          string    `json:"Remark" xorm:"comment('备注') VARCHAR(500) 'Remark'"`
 	ModifiedOn      time.Time `json:"ModifiedOn" xorm:"DATETIME 'ModifiedOn'"`
@@ -24,11 +25,13 @@ type OilContractEvaluationItems struct {
 type EvaluationItems struct {
 	Id             int       `json:"Id"`
 	Type           int       `json:"Type"`
+	ItemId         int       `json:"ItemId"`
 	ParentId       int       `json:"ParentId"`
 	SequenceNo     string    `json:"SequenceNo"`
 	Content        string    `json:"Content"`
 	NormalScore    string    `json:"NormalScore"`
 	Score          string    `json:"Score"`
+	Value          int       `json:"Value"`
 	LevelCode      int       `json:"LevelCode"`
 	Remark         string    `json:"Remark"`
 	IsDelete       int       `json:"IsDelete"`

+ 3 - 0
src/dashoo.cn/backend/api/business/oilcontract/contractReview/contractReview.go

@@ -91,7 +91,9 @@ type OilContractReviewVo struct {
 }
 type OilContractEvaluationItemsVo struct{
 	Id             int       `json:"Id" xorm:"not null pk autoincr comment('ID') INT(11) 'Id'"`
+	ItemId         int       `json:"ItemId" xorm:"not null default 0 comment('节点ID') INT(11) 'ItemId'"`
 	Type           int       `json:"Type" xorm:"default 1 comment('项类型 1分值 2布尔') INT(11) 'Type'"`
+	Category       int      `json:"Category" xorm:"default 0 comment('项类型 1分值 2布尔') INT(11) 'Category'"`
 	ContractId     int       `json:"ContractId" xorm:"default 0 comment('合同表ID') INT(11) 'ContractId'"`
 	ContractWorkId int       `json:"ContractId" xorm:"default 0 comment('ReviewWork表ID') INT(11) 'ContractWorkId'"`
 	ParentId       int       `json:"ParentId" xorm:"not null default 0 comment('上级节点ID') INT(11) 'ParentId'"`
@@ -99,6 +101,7 @@ type OilContractEvaluationItemsVo struct{
 	Content        string    `json:"content" xorm:"comment('评价内容') VARCHAR(1000) 'content'"`
 	NormalScore    string    `json:"NormalScore" xorm:"comment('标准分值') DECIMAL(11,2) 'NormalScore'"`
 	Score          string    `json:"Score" xorm:"comment('实得分数') DECIMAL(11,2) 'Score'"`
+	Value          int       `json:"Value" xorm:"not null default 0 comment('布尔专用') INT(11) 'Value'"`
 	LevelCode      int       `json:"LevelCode" xorm:"not null default 0 comment('级别') INT(11) 'LevelCode'"`
 	Remark         string    `json:"Remark" xorm:"comment('备注') VARCHAR(500) 'Remark'"`
 }

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

@@ -29,6 +29,8 @@ type OilContractSumScore struct {
 	ModifiedOn       time.Time `json:"ModifiedOn" xorm:"DATETIME 'ModifiedOn'"`
 	ModifiedUserId   int       `json:"ModifiedUserId" xorm:"INT(11) 'ModifiedUserId'"`
 	ModifiedBy       string    `json:"ModifiedBy" xorm:"VARCHAR(50) 'ModifiedBy'"`
+	UnitId            int       `json:"UnitId" xorm:"INT(11) 'UnitId'"`
+	Unit              string    `json:"Unit" xorm:"VARCHAR(50) 'Unit'"`
 }
 type OilContractSumScoreVo struct {
 	Id               int       `json:"Id" xorm:"not null pk autoincr comment('ID') INT(11) 'Id'"`
@@ -54,6 +56,19 @@ type OilContractSumScoreVo struct {
 	Content5    	 string    `json:"Content5" xorm:"default '0' comment('评价内容') VARCHAR(50) 'Content5'"`
 	NormalSumScore5  float64   `json:"NormalSumScore5" xorm:"default 0.00 comment('标准分值') DECIMAL(11,2) 'NormalSumScore5'"`
 	SumScore5        float64   `json:"SumScore5" xorm:"default 0.00 comment('实际分值') DECIMAL(11,2) 'SumScore5'"`
+
+	Content6    	 string    `json:"Content6" xorm:"default '0' comment('评价内容') VARCHAR(50) 'Content6'"`
+	NormalSumScore6  float64   `json:"NormalSumScore6" xorm:"default 0.00 comment('标准分值') DECIMAL(11,2) 'NormalSumScore6'"`
+	SumScore6        float64   `json:"SumScore6" xorm:"default 0.00 comment('实际分值') DECIMAL(11,2) 'SumScore6'"`
+
+	Content7    	 string    `json:"Content7" xorm:"default '0' comment('评价内容') VARCHAR(50) 'Content7'"`
+	NormalSumScore7  float64   `json:"NormalSumScore7" xorm:"default 0.00 comment('标准分值') DECIMAL(11,2) 'NormalSumScore7'"`
+	SumScore7        float64   `json:"SumScore7" xorm:"default 0.00 comment('实际分值') DECIMAL(11,2) 'SumScore7'"`
+
+	Content8    	 string    `json:"Content8" xorm:"default '0' comment('评价内容') VARCHAR(50) 'Content8'"`
+	NormalSumScore8  float64   `json:"NormalSumScore8" xorm:"default 0.00 comment('标准分值') DECIMAL(11,2) 'NormalSumScore8'"`
+	SumScore8        float64   `json:"SumScore8" xorm:"default 0.00 comment('实际分值') DECIMAL(11,2) 'SumScore8'"`
+
 	Status           string    `json:"Status" xorm:"not null default '0' comment('状态标识( 0 初始 - 1待二级初审 - 2待二级复审 - 3-专业科室接收 4 待专业科室审核 - 5 待集中评审 - 6 待交费 - 7 待入库 - 8 完成 - 9审核未通过)') VARCHAR(10) 'Status'"`
 	Note			 string    `json:"Note" xorm:"comment('备注') VARCHAR(255) 'Note'"`
 	ConclusionReason string    `json:"ConclusionReason" xorm:"comment('不合格原因') VARCHAR(255) 'ConclusionReason'"`
@@ -74,6 +89,16 @@ type OilContractSumScoreVo struct {
 	ModifiedOn       time.Time `json:"ModifiedOn" xorm:"DATETIME 'ModifiedOn'"`
 	ModifiedUserId   int       `json:"ModifiedUserId" xorm:"INT(11) 'ModifiedUserId'"`
 	ModifiedBy       string    `json:"ModifiedBy" xorm:"VARCHAR(50) 'ModifiedBy'"`
+
+
+	B1       int       `json:"B1" xorm:"default 0 comment('B1') INT(11) 'B1'"`
+	B2       int       `json:"B2" xorm:"default 0 comment('B2') INT(11) 'B2'"`
+	B3       int       `json:"B3" xorm:"default 0 comment('B3') INT(11) 'B3'"`
+	B4       int       `json:"B4" xorm:"default 0 comment('B4') INT(11) 'B4'"`
+	B5       int       `json:"B5" xorm:"default 0 comment('B5') INT(11) 'B5'"`
+	B6       int       `json:"B6" xorm:"default 0 comment('B6') INT(11) 'B6'"`
+	B7       int       `json:"B7" xorm:"default 0 comment('B7') INT(11) 'B7'"`
+	B8       int       `json:"B8" xorm:"default 0 comment('B8') INT(11) 'B8'"`
 }
 type OilContractComputeSumScoreVo struct {
 	SupplierId    int       `json:"SupplierId"`
@@ -90,5 +115,14 @@ type OilContractComputeSumScoreVo struct {
 	Score7    	  string    `json:"Score7"`
 	Score8  	  string    `json:"Score8"`
 	Score9        string    `json:"Score9"`
+
+	B1    	  string    `json:"B1"`
+	B2  	  string    `json:"B2"`
+	B3        string    `json:"B3"`
+	B4    	  string    `json:"B4"`
+	B5  	  string    `json:"B5"`
+	B6        string    `json:"B6"`
+	B7    	  string    `json:"B7"`
+	B8  	  string    `json:"B8"`
 	Evaluate 	  string    `json:"Evaluate"`
 }

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

@@ -18,6 +18,40 @@ 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) {
+	var resultsSlice []map[string][]byte
+	//获取总记录数
+	sqlCount := ` select count(*) from ` + controllers.OilContractSumScoreName + ` score `
+	sqlCount += ` left join ` + controllers.OilContractSumScoreItemsName + ` items on items.SumScoreId = score.id `
+	sqlCount += ` where ` + where
+
+	var sql string
+	sql =  `select * `
+	sql += ` from ` + controllers.OilContractSumScoreName + ` score `
+	sql += ` left join ` + controllers.OilContractSumScoreItemsName + ` items on items.SumScoreId = score.id `
+	sql += ` where ` + where
+
+	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) GetPagingComputeEntitiesWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
 	var resultsSlice []map[string][]byte
 	//获取总记录数
@@ -31,15 +65,25 @@ func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(page
 
 	var sql string
 	sql =  `select YEAR(NOW()) as Year,contract.ContractClass,contract.SupplierId,contract.SupplierName,count(review.id) as count,ROUND(sum(items.Score)/count(review.id),2) as Score, `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('1') then items.Score else 0 end)/count(review.id),2) Score1,  `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('2') then items.Score else 0 end)/count(review.id),2) Score2,  `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('3') then items.Score else 0 end)/count(review.id),2) Score3,  `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('4') then items.Score else 0 end)/count(review.id),2) Score4,  `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('5') then items.Score else 0 end)/count(review.id),2) Score5,  `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('6') then items.Score else 0 end)/count(review.id),2) Score6,  `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('7') then items.Score else 0 end)/count(review.id),2) Score7,  `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('8') then items.Score else 0 end)/count(review.id),2) Score8,  `
-	sql += ` ROUND(sum(case when items.SequenceNo in  ('9') then items.Score else 0 end)/count(review.id),2) Score9,  `
+
+	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, `
+	sql += ` sum(case when items.SequenceNo in  ('4') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end )  B4, `
+	sql += ` sum(case when items.SequenceNo in  ('5') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end )  B5, `
+	sql += ` sum(case when items.SequenceNo in  ('6') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end )  B6, `
+	sql += ` sum(case when items.SequenceNo in  ('7') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end )  B7, `
+	sql += ` sum(case when items.SequenceNo in  ('8') AND items.Type = 2 AND items.Value > 0 then 1 else 0 end )  B8, `
+
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('1') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score1,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('2') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score2,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('3') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score3,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('4') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score4,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('5') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score5,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('6') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score6,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('7') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score7,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('8') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score8,  `
+	sql += ` ROUND(sum(case when items.SequenceNo in  ('9') AND items.Type =1 then items.Score else 0 end)/count(review.id),2) Score9,  `
 	sql += ` case when sum(items.Score)/count(review.id) <60 then 3 when sum(items.Score)/count(review.id) <80 then 2 else 1 end as Evaluate `
 	sql += ` from ` + controllers.OilContractReviewName + ` review `
 	sql += ` left join ` + controllers.OilContractName + ` contract on review.ContractId=contract.id `

+ 19 - 0
src/dashoo.cn/backend/api/business/oilcontract/contractSumScoreItems/contractSumScoreItems.go

@@ -23,6 +23,15 @@ type OilContractSumScoreItems struct{
 	Content5    	 string    `json:"Content5" xorm:"default '0' comment('评价内容') VARCHAR(50) 'Content5'"`
 	NormalSumScore5  float64   `json:"NormalSumScore5" xorm:"default 0.00 comment('标准分值') DECIMAL(11,2) 'NormalSumScore5'"`
 	SumScore5        float64   `json:"SumScore5" xorm:"default 0.00 comment('实际分值') DECIMAL(11,2) 'SumScore5'"`
+	Content6    	 string    `json:"Content6" xorm:"default '0' comment('评价内容') VARCHAR(50) 'Content6'"`
+	NormalSumScore6  float64   `json:"NormalSumScore6" xorm:"default 0.00 comment('标准分值') DECIMAL(11,2) 'NormalSumScore6'"`
+	SumScore6        float64   `json:"SumScore6" xorm:"default 0.00 comment('实际分值') DECIMAL(11,2) 'SumScore6'"`
+	Content7    	 string    `json:"Content7" xorm:"default '0' comment('评价内容') VARCHAR(50) 'Content7'"`
+	NormalSumScore7  float64   `json:"NormalSumScore7" xorm:"default 0.00 comment('标准分值') DECIMAL(11,2) 'NormalSumScore7'"`
+	SumScore7        float64   `json:"SumScore7" xorm:"default 0.00 comment('实际分值') DECIMAL(11,2) 'SumScore7'"`
+	Content8    	 string    `json:"Content8" xorm:"default '0' comment('评价内容') VARCHAR(50) 'Content8'"`
+	NormalSumScore8  float64   `json:"NormalSumScore8" xorm:"default 0.00 comment('标准分值') DECIMAL(11,2) 'NormalSumScore8'"`
+	SumScore8        float64   `json:"SumScore8" xorm:"default 0.00 comment('实际分值') DECIMAL(11,2) 'SumScore8'"`
 	Note			 string    `json:"Note" xorm:"comment('备注') VARCHAR(255) 'Note'"`
 	CreateOn       	 time.Time `json:"CreateOn" xorm:"DATETIME 'CreateOn'"`
 	CreateUserId     int       `json:"CreateUserId" xorm:"INT(11) 'CreateUserId'"`
@@ -30,4 +39,14 @@ type OilContractSumScoreItems struct{
 	ModifiedOn       time.Time `json:"ModifiedOn" xorm:"DATETIME 'ModifiedOn'"`
 	ModifiedUserId   int       `json:"ModifiedUserId" xorm:"INT(11) 'ModifiedUserId'"`
 	ModifiedBy       string    `json:"ModifiedBy" xorm:"VARCHAR(50) 'ModifiedBy'"`
+
+	B1       int       `json:"B1" xorm:"default 0 comment('B1') INT(11) 'B1'"`
+	B2       int       `json:"B2" xorm:"default 0 comment('B2') INT(11) 'B2'"`
+	B3       int       `json:"B3" xorm:"default 0 comment('B3') INT(11) 'B3'"`
+	B4       int       `json:"B4" xorm:"default 0 comment('B4') INT(11) 'B4'"`
+	B5       int       `json:"B5" xorm:"default 0 comment('B5') INT(11) 'B5'"`
+	B6       int       `json:"B6" xorm:"default 0 comment('B6') INT(11) 'B6'"`
+	B7       int       `json:"B7" xorm:"default 0 comment('B7') INT(11) 'B7'"`
+	B8       int       `json:"B8" xorm:"default 0 comment('B8') INT(11) 'B8'"`
+
 }

+ 50 - 1
src/dashoo.cn/backend/api/controllers/oilcontract/contract.go

@@ -1,6 +1,7 @@
 package oilcontract
 
 import (
+	"dashoo.cn/backend/api/business/oilcontract/contractReview"
 	"encoding/json"
 	"strings"
 	"time"
@@ -257,6 +258,40 @@ func (this *OilContractController) GetDictList() {
 	this.ServeJSON()
 }
 
+// @Title 完成合同
+// @Description get user by token
+// @Success 200 {object} map[string]interface{}
+// @router /finish/:id [get]
+func (this *OilContractController) Finish(){
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model contract.OilContract
+	svc := contract.GetOilContractService(utils.DBE)
+	model.Status = 2
+	cols := []string{
+		"Status",
+	}
+	err := svc.UpdateEntityBytbl(OilContractName, id, &model, cols)
+	if err == nil {
+		errinfo.Message = "修改成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
 // @Title 获取实体
 // @Description 获取实体
 // @Success 200 {object} oilcontract.OilContract
@@ -431,11 +466,25 @@ func (this *OilContractController) DeleteEntity() {
 		this.ServeJSON()
 		return
 	}
+
+	// 有没有待审核的评价
+	itemsSvc := contractReview.GetOilContractReviewService(utils.DBE)
+	var review contractReview.OilContractReview
+	tempCount,_:=itemsSvc.GetCount(&review,"ContractId='" + Id +"' and status > 0 and status < 8 ")
+	if tempCount > 0 {
+		errinfo.Message = "该合同存在待审核评价!"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
 	var model contract.OilContract
 	var entityempty contract.OilContract
 	svc := contract.GetOilContractService(utils.DBE)
 	opdesc := "删除-" + Id
-	err := svc.DeleteOperationAndWriteLogBytbl(OilContractName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "钻井日报")
+	err := svc.DeleteOperationAndWriteLogBytbl(OilContractName, BaseOperationLogName, Id, &model, &entityempty,
+		utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "合同表")
 	if err == nil {
 		errinfo.Message = "删除成功"
 		errinfo.Code = 0

+ 7 - 0
src/dashoo.cn/backend/api/controllers/oilcontract/contractEvaluationItems.go

@@ -143,6 +143,10 @@ func (this *OilContractEvaluationItemsController) GetTreeList() {
 		firstTmp.NormalScore = value.NormalScore
 		firstTmp.Remark = value.Remark
 		firstTmp.LevelCode = value.LevelCode
+		firstTmp.Score = value.Score
+		firstTmp.Type = value.Type
+		firstTmp.Value = value.Value
+		firstTmp.ItemId = value.ItemId
 
 		var list1 []contractEvaluationItems.OilContractEvaluationItems
 		where1 := "ContentReviewId ='" + Id +"' AND ParentId = " + strconv.Itoa(value.ItemId)
@@ -157,6 +161,9 @@ func (this *OilContractEvaluationItemsController) GetTreeList() {
 			secTmp.NormalScore = v.NormalScore
 			secTmp.Remark = v.Remark
 			secTmp.LevelCode = v.LevelCode
+			secTmp.Type = v.Type
+			secTmp.Value = v.Value
+			secTmp.ItemId = v.ItemId
 			firstTmp.Son = append(firstTmp.Son, secTmp)
 		}
 		result = append(result, firstTmp)

+ 17 - 7
src/dashoo.cn/backend/api/controllers/oilcontract/contractReview.go

@@ -179,7 +179,7 @@ func (this *OilContractReviewController) AddEntity() {
 		fmt.Print(i)
 		var temp contractEvaluationItems.OilContractEvaluationItems
 		temp.ContentReviewId = reviewMode.Id
-		temp.Type     = v.Type
+		temp.Type     = v.Category
 		temp.Category = 0
 		temp.ItemId = v.Id
 		temp.ParentId = v.ParentId
@@ -187,6 +187,7 @@ func (this *OilContractReviewController) AddEntity() {
 		temp.Content = v.Content
 		temp.NormalScore = v.NormalScore
 		temp.Score = v.Score
+		temp.Value = v.Value
 		temp.LevelCode = v.LevelCode
 		temp.Remark = v.Remark
 		temp.Content = v.Content
@@ -246,6 +247,7 @@ func (this *OilContractReviewController) SaveEvaluationItemsBySec(){
 		temp.Content = v.Content
 		temp.NormalScore = v.NormalScore
 		temp.Score = v.Score
+		temp.Value = v.Value
 		temp.LevelCode = v.LevelCode
 		temp.Remark = v.Remark
 		temp.Content = v.Content
@@ -340,30 +342,32 @@ func (this *OilContractReviewController) UpdateEntity() {
 
 	where := "ContentReviewId=" + id
 	// 清除掉之前的
-	itemSvc.DeleteEntityBytbl(OilContractReviewName,where)
+	itemSvc.DeleteEntityBytbl(OilContractEvaluationItemsName,where)
 
 	var items []contractEvaluationItems.OilContractEvaluationItems
 	// 新增配置项
 	for i,v := range modeVO.Items{
 		fmt.Print(i)
 		var temp contractEvaluationItems.OilContractEvaluationItems
-		temp.ContentReviewId = reviewMode.Id
+		temp.ContentReviewId ,_ = strconv.Atoi(id)
 		temp.Type     = v.Type
+		temp.ItemId   = v.ItemId
 		temp.Category = 0
 		temp.ParentId = v.ParentId
 		temp.SequenceNo = v.SequenceNo
 		temp.Content = v.Content
 		temp.NormalScore = v.NormalScore
 		temp.Score = v.Score
+		temp.Value = v.Value
 		temp.LevelCode = v.LevelCode
 		temp.Remark = v.Remark
 		temp.Content = v.Content
 		items = append(items, temp)
 	}
-	itemSvc.DBE.Insert(items)
+	_, err2 := itemSvc.DBE.Insert(items)
 
 
-	if err == nil {
+	if err == nil && err2 == nil {
 		errinfo.Message = "修改成功!"
 		errinfo.Code = 0
 		this.Data["json"] = &errinfo
@@ -396,8 +400,14 @@ func (this *OilContractReviewController) DeleteEntity() {
 	svc := contractReview.GetOilContractReviewService(utils.DBE)
 
 	// 评分审核是否结束校验
-
-
+	svc.GetEntityByIdBytbl(OilContractReviewName, Id, &model)
+	if model.Status > "0" && model.Status < "8"  {
+		errinfo.Message = "该合同评价正在审核,不允许删除!"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
 
 	opdesc := "删除-" + Id
 	err := svc.DeleteOperationAndWriteLogBytbl(OilContractReviewName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")

+ 201 - 128
src/dashoo.cn/backend/api/controllers/oilcontract/contractSumScore.go

@@ -2,6 +2,8 @@ package oilcontract
 
 import (
 	"dashoo.cn/backend/api/business/oilcontract/contractSumScoreItems"
+	"dashoo.cn/business/permission"
+
 	//"dashoo.cn/backend/api/business/oilcontract/contractReview"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercert"
 	"dashoo.cn/backend/api/business/workflow"
@@ -31,7 +33,7 @@ func (this *OilContractSumScoreController) GetEntityList() {
 	//获取分页信息
 	page := this.GetPageInfoForm()
 	where := " 1=1 "
-	orderby := "Id"
+	orderby := "score.Id"
 	asc := false
 	Order := this.GetString("Order")
 	Prop := this.GetString("Prop")
@@ -42,160 +44,82 @@ func (this *OilContractSumScoreController) GetEntityList() {
 		}
 	}
 	Id := this.GetString("Id")
-	ContractId := this.GetString("ContractId")
+	SupplierId := this.GetString("SupplierId")
 	ContractClass := this.GetString("ContractClass")
-	SumScore := this.GetString("SumScore")
-	NormalSumScore1 := this.GetString("NormalSumScore1")
-	SumScore1 := this.GetString("SumScore1")
-	Content1 := this.GetString("Content1")
-	NormalSumScore2 := this.GetString("NormalSumScore2")
-	SumScore2 := this.GetString("SumScore2")
-	Content2 := this.GetString("Content2")
-	NormalSumScore3 := this.GetString("NormalSumScore3")
-	SumScore3 := this.GetString("SumScore3")
-	Content3 := this.GetString("Content3")
-	NormalSumScore4 := this.GetString("NormalSumScore4")
-	SumScore4 := this.GetString("SumScore4")
-	Content4 := this.GetString("Content4")
-	NormalSumScore5 := this.GetString("NormalSumScore5")
-	SumScore5 := this.GetString("SumScore5")
-	Content5 := this.GetString("Content5")
-	ConclusionReason := this.GetString("ConclusionReason")
-	Conclusion := this.GetString("Conclusion")
+	SupplierName := this.GetString("SupplierName")
+	Year := this.GetString("Year")
+	Status := this.GetString("Status")
 	CreateOn := this.GetString("CreateOn")
 	CreateUserId := this.GetString("CreateUserId")
 	CreateBy := this.GetString("CreateBy")
 	ModifiedOn := this.GetString("ModifiedOn")
 	ModifiedUserId := this.GetString("ModifiedUserId")
 	ModifiedBy := this.GetString("ModifiedBy")
-
 	if Id != "" {
-		where = where + " and Id like '%" + Id + "%'"
+		where = where + " and score.Id like '%" + Id + "%'"
 	}
-
-
-	if ContractId != "" {
-		where = where + " and ContractId like '%" + ContractId + "%'"
-	}
-
-
-	if ContractClass != "" {
-		where = where + " and ContractClass like '%" + ContractClass + "%'"
-	}
-
-	if SumScore != "" {
-		where = where + " and SumScore like '%" + SumScore + "%'"
-	}
-
-	if Content1 != "" {
-		where = where + " and Content1 like '%" + Content1 + "%'"
-	}
-
-	if NormalSumScore1 != "" {
-		where = where + " and NormalSumScore1 like '%" + NormalSumScore1 + "%'"
-	}
-
-	if SumScore1 != "" {
-		where = where + " and SumScore1 like '%" + SumScore1 + "%'"
-	}
-
-	if Content2 != "" {
-		where = where + " and Content2 like '%" + Content2 + "%'"
-	}
-
-	if NormalSumScore2 != "" {
-		where = where + " and NormalSumScore2 like '%" + NormalSumScore2 + "%'"
-	}
-
-	if SumScore2 != "" {
-		where = where + " and SumScore2 like '%" + SumScore2 + "%'"
-	}
-
-	if Content3 != "" {
-		where = where + " and Content3 like '%" + Content3 + "%'"
-	}
-
-	if NormalSumScore3 != "" {
-		where = where + " and NormalSumScore3 like '%" + NormalSumScore3 + "%'"
-	}
-
-	if SumScore3 != "" {
-		where = where + " and SumScore3 like '%" + SumScore3 + "%'"
-	}
-
-	if Content4 != "" {
-		where = where + " and Content4 like '%" + Content4 + "%'"
-	}
-
-	if NormalSumScore4 != "" {
-		where = where + " and NormalSumScore4 like '%" + NormalSumScore4 + "%'"
+	if SupplierId != "" {
+		where = where + " and score.SupplierId like '%" + SupplierId + "%'"
 	}
-
-	if SumScore4 != "" {
-		where = where + " and SumScore4 like '%" + SumScore4 + "%'"
-	}
-	if Content5 != "" {
-		where = where + " and Content5 like '%" + Content5 + "%'"
-	}
-
-	if NormalSumScore5 != "" {
-		where = where + " and NormalSumScore5 like '%" + NormalSumScore5 + "%'"
+	if SupplierName != "" {
+		where = where + " and score.SupplierName like '%" + SupplierName + "%'"
 	}
-
-	if SumScore5 != "" {
-		where = where + " and SumScore5 like '%" + SumScore5 + "%'"
+	if ContractClass != "" {
+		where = where + " and score.ContractClass like '%" + ContractClass + "%'"
 	}
-	if ConclusionReason != "" {
-		where = where + " and ConclusionReason like '%" + ConclusionReason + "%'"
+	if Year != "" {
+		where = where + " and score.Year like '%" + Year + "%'"
 	}
 
-
-	if Conclusion != "" {
-		where = where + " and Conclusion like '%" + Conclusion + "%'"
+	if Status != "" {
+		where = where + " and score.Status = '" + Status + "'"
 	}
-
 	//if CreateOn != "" {
 	//	where = where + " and CreateOn like '%" + CreateOn + "%'"
 	//}
 
-
 	if CreateUserId != "" {
-		where = where + " and CreateUserId like '%" + CreateUserId + "%'"
+		where = where + " and score.CreateUserId like '%" + CreateUserId + "%'"
 	}
 
-
 	if CreateBy != "" {
-		where = where + " and CreateBy like '%" + CreateBy + "%'"
+		where = where + " and score.CreateBy like '%" + CreateBy + "%'"
 	}
 
-
 	if ModifiedOn != "" {
-		where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
+		where = where + " and score.ModifiedOn like '%" + ModifiedOn + "%'"
 	}
 
-
 	if ModifiedUserId != "" {
-		where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
+		where = where + " and score.ModifiedUserId like '%" + ModifiedUserId + "%'"
 	}
 
-
 	if ModifiedBy != "" {
-		where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
+		where = where + " and score.ModifiedBy like '%" + ModifiedBy + "%'"
 	}
-
-
 	if CreateOn != "" {
 		dates := strings.Split(CreateOn, ",")
 		if len(dates) == 2 {
 			minDate := dates[0]
 			maxDate := dates[1]
-			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
+			where = where + " and score.CreateOn>='" + minDate + "' and score.CreateOn<='" + maxDate + "'"
 		}
 	}
 
+
+	//超级管理员和有查看所有数据权限的用户不加条件
+	svcPerm := permission.GetPermissionService(utils.DBE)
+	isauth  := svcPerm.IsAuthorized(this.User.Id, "oil_contract.SumStore.AllRecord")
+	if(!isauth){
+		// 权限过滤  自己创建的评价 ,同二级部门创建的评价 ,企管法规处能看
+		where = where + " and ( score.CreateUserId =  '" + this.User.Id + "' "
+		where = where + " or score.UnitId = '" +  strconv.Itoa(this.User.UnitId) + "' "
+		where = where + " )"
+	}
+
 	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
-	var list []contractSumScore.OilContractSumScore
-	total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
+	var list []contractSumScore.OilContractSumScoreVo
+	total := svc.GetMyPagingEntitiesWithOrderBytbl( page.CurrentPage, page.Size, orderby, asc, &list, where)
 	var datainfo DataInfo
 	datainfo.Items = list
 	datainfo.CurrentItemCount = total
@@ -288,16 +212,17 @@ func (this *OilContractSumScoreController) GetDictList() {
 // @Title 获取实体
 // @Description 获取实体
 // @Success 200 {object} contractSumScore.OilContractSumScore
-// @router /get/:id [get]
+// @router /get/:id/:category [get]
 func (this *OilContractSumScoreController) GetEntity() {
-	Id := this.Ctx.Input.Param(":id")
+	Id       := this.Ctx.Input.Param(":id")
+	Category := this.Ctx.Input.Param(":category")
 	var model contractSumScore.OilContractSumScore
 	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
 	svc.GetEntityByIdBytbl(OilContractSumScoreName, Id, &model)
 
 	var item contractSumScoreItems.OilContractSumScoreItems
 	itemSvc := contractSumScoreItems.GetOilContractSumScoreItemsService(utils.DBE)
-	where := " 1=1 AND SumScoreId= '" + utils.ToStr( model.Id) + "' AND Category = 0 "
+	where := " 1=1 AND SumScoreId= '" + utils.ToStr( model.Id) + "' AND Category =  '" + Category +  "'"
 	itemSvc.GetEntityByWhere(OilContractSumScoreItemsName,where,&item)
 
 	var result contractSumScore.OilContractSumScoreVo
@@ -307,6 +232,8 @@ func (this *OilContractSumScoreController) GetEntity() {
 	result.ContractClass= model.ContractClass
 	result.Year         = model.Year
 	result.Status       = model.Status
+	result.WorkflowId   = model.WorkflowId
+	result.Processkey   = model.Processkey
 	result.Category     = item.Category
 	result.SumScoreId   = item.SumScoreId
 	result.SumScore     = item.SumScore
@@ -327,6 +254,15 @@ func (this *OilContractSumScoreController) GetEntity() {
 	result.NormalSumScore5 = item.NormalSumScore5
 	result.Note = item.Note
 	result.Conclusion = item.Conclusion
+
+	result.B1 = item.B1
+	result.B2 = item.B2
+	result.B3 = item.B3
+	result.B4 = item.B4
+	result.B5 = item.B5
+	result.B6 = item.B6
+	result.B7 = item.B7
+	result.B8 = item.B8
 	this.Data["json"] = &result
 	this.ServeJSON()
 }
@@ -347,6 +283,8 @@ func (this *OilContractSumScoreController) AddEntity() {
 	entity.ContractClass= model.ContractClass
 	entity.Year         = model.Year
 	entity.Status     = "0"
+	entity.Unit       = this.User.Unit
+	entity.UnitId     = this.User.UnitId
 	entity.CreateOn   = time.Now()
 	entity.CreateBy   = this.User.Realname
 	entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
@@ -373,12 +311,30 @@ func (this *OilContractSumScoreController) AddEntity() {
 	item.Content5   = model.Content5
 	item.NormalSumScore5 = model.NormalSumScore5
 	item.SumScore5  = model.SumScore5
+	item.Content6   = model.Content6
+	item.NormalSumScore6 = model.NormalSumScore6
+	item.SumScore6  = model.SumScore6
+	item.Content7   = model.Content7
+	item.NormalSumScore7 = model.NormalSumScore7
+	item.SumScore7  = model.SumScore7
+	item.Content8   = model.Content8
+	item.NormalSumScore8 = model.NormalSumScore8
+	item.SumScore8  = model.SumScore8
 	item.Conclusion = model.Conclusion
 	item.Note       = model.Note
 	item.CreateOn   = time.Now()
 	item.CreateBy   = this.User.Realname
 	item.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
 
+	item.B1 = model.B1
+	item.B2 = model.B2
+	item.B3 = model.B3
+	item.B4 = model.B4
+	item.B5 = model.B5
+	item.B6 = model.B6
+	item.B7 = model.B7
+	item.B8 = model.B8
+
 	itemSvc := contractSumScoreItems.GetOilContractSumScoreItemsService(utils.DBE)
 	itemSvc.InsertEntityBytbl(OilContractSumScoreItemsName, &item)
 	var errinfo ErrorDataInfo
@@ -418,15 +374,10 @@ func (this *OilContractSumScoreController) UpdateEntity() {
 	var jsonBlob = this.Ctx.Input.RequestBody
 	json.Unmarshal(jsonBlob, &model)
 
-	var entity contractSumScore.OilContractSumScore
-	entity.SupplierId   = model.SupplierId
-	entity.SupplierName = model.SupplierName
-	entity.ContractClass= model.ContractClass
-	entity.Year         = model.Year
-	entity.Status     = "0"
-	entity.ModifiedOn   = time.Now()
-	entity.ModifiedBy   = this.User.Realname
-	entity.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	model.Status     = "0"
+	model.ModifiedOn   = time.Now()
+	model.ModifiedBy   = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
 	cols := []string{
 		"SupplierId",
 		"SupplierName",
@@ -441,9 +392,9 @@ func (this *OilContractSumScoreController) UpdateEntity() {
 
 	var item contractSumScoreItems.OilContractSumScoreItems
 	itemSvc := contractSumScoreItems.GetOilContractSumScoreItemsService(utils.DBE)
-	where := " 1=1 AND SumScoreId= '" + utils.ToStr( entity.Id) + "' AND Category = 0 "
+	where := " 1=1 AND SumScoreId= '" + utils.ToStr( model.Id) + "' AND Category = 0 "
 	itemSvc.GetEntityByWhere(OilContractSumScoreItemsName,where,&item)
-	item.Category   = 1                      // 二级单位创建
+	item.Category   = 0                       // 二级单位创建
 	item.SumScore   = model.SumScore
 	item.Content1   = model.Content1
 	item.NormalSumScore1 = model.NormalSumScore1
@@ -465,6 +416,15 @@ func (this *OilContractSumScoreController) UpdateEntity() {
 	item.ModifiedBy   = this.User.Realname
 	item.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
 
+	item.B1 = model.B1
+	item.B2 = model.B2
+	item.B3 = model.B3
+	item.B4 = model.B4
+	item.B5 = model.B5
+	item.B6 = model.B6
+	item.B7 = model.B7
+	item.B8 = model.B8
+
 	cols2 := []string{
 		"Category",
 		"SumScore",
@@ -473,22 +433,122 @@ func (this *OilContractSumScoreController) UpdateEntity() {
 		"Content3",
 		"Content4",
 		"Content5",
+		"Content6",
+		"Content7",
+		"Content8",
 		"NormalSumScore1",
 		"NormalSumScore2",
 		"NormalSumScore3",
 		"NormalSumScore4",
 		"NormalSumScore5",
+		"NormalSumScore6",
+		"NormalSumScore7",
+		"NormalSumScore8",
 		"SumScore1",
 		"SumScore2",
 		"SumScore3",
 		"SumScore4",
 		"SumScore5",
+		"SumScore6",
+		"SumScore7",
+		"SumScore8",
 		"Note",
 		"ModifiedOn",
 		"ModifiedBy",
 		"ModifiedUserId",
+		"B1",
+		"B2",
+		"B3",
+		"B4",
+		"B5",
+		"B6",
+		"B7",
+		"B8",
+	}
+	err2 := itemSvc.UpdateEntityBytbl(OilContractSumScoreItemsName,item.Id,&item,cols2)
+
+	if err == nil && err2 == nil {
+		errinfo.Message = "修改成功!"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+
+// @Title 添加
+// @Description 专业科室保存评价
+// @Param 	body body contractSumScore.OilContractSumScore
+// @Success	200	{object} controllers.Request
+// @router /save-sec-score/:id [post]
+func (this *OilContractSumScoreController) SaveScoreItemsBySec(){
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
 	}
-	itemSvc.UpdateEntityBytbl(OilContractSumScoreItemsName,item.Id,&item,cols2)
+	var model contractSumScore.OilContractSumScoreVo
+	itemSvc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
+	var jsonBlob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonBlob, &model)
+
+	where := "SumScoreId=" + id + " AND Category = 1 "
+	// 清除掉之前的
+	itemSvc.DeleteEntityBytbl(OilContractSumScoreItemsName,where)
+
+	var item contractSumScoreItems.OilContractSumScoreItems
+	item.SumScoreId,_ = strconv.Atoi(id)
+	item.Category   = 1                      // 二级单位创建
+	item.SumScore   = model.SumScore
+	item.Content1   = model.Content1
+	item.NormalSumScore1 = model.NormalSumScore1
+	item.SumScore1  = model.SumScore1
+	item.Content2   = model.Content2
+	item.NormalSumScore2 = model.NormalSumScore2
+	item.SumScore2  = model.SumScore2
+	item.Content3   = model.Content3
+	item.NormalSumScore3 = model.NormalSumScore3
+	item.SumScore3  = model.SumScore3
+	item.Content4   = model.Content4
+	item.NormalSumScore4 = model.NormalSumScore4
+	item.SumScore4  = model.SumScore4
+	item.Content5   = model.Content5
+	item.NormalSumScore5 = model.NormalSumScore5
+	item.SumScore5  = model.SumScore5
+	item.Content6   = model.Content6
+	item.NormalSumScore6 = model.NormalSumScore6
+	item.SumScore6  = model.SumScore6
+	item.Content7   = model.Content7
+	item.NormalSumScore7 = model.NormalSumScore7
+	item.SumScore7  = model.SumScore7
+	item.Content8   = model.Content8
+	item.NormalSumScore8 = model.NormalSumScore8
+	item.SumScore8  = model.SumScore8
+	item.Conclusion = model.Conclusion
+	item.Note       = model.Note
+	item.CreateOn   = time.Now()
+	item.CreateBy   = this.User.Realname
+	item.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+
+	item.B1 = model.B1
+	item.B2 = model.B2
+	item.B3 = model.B3
+	item.B4 = model.B4
+	item.B5 = model.B5
+	item.B6 = model.B6
+	item.B7 = model.B7
+	item.B8 = model.B8
+
+	_,err := itemSvc.InsertEntityBytbl(OilContractSumScoreItemsName, &item)
 
 	if err == nil {
 		errinfo.Message = "修改成功!"
@@ -503,6 +563,7 @@ func (this *OilContractSumScoreController) UpdateEntity() {
 	}
 }
 
+
 // @Title 删除单条信息
 // @Description
 // @Success 200 {object} ErrorInfo
@@ -521,6 +582,18 @@ func (this *OilContractSumScoreController) DeleteEntity() {
 	var model contractSumScore.OilContractSumScore
 	var entityempty contractSumScore.OilContractSumScore
 	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
+
+	// 审核中不能删除
+	svc.GetEntityByIdBytbl(OilContractSumScoreName, Id, &model)
+	if model.Status > "0" && model.Status < "8"  {
+		errinfo.Message = "该年度评价正在审核,不允许删除!"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+
 	opdesc := "删除-" + Id
 	err := svc.DeleteOperationAndWriteLogBytbl(this.User.AccCode+OilContractSumScoreName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
 	if err == nil {