Parcourir la source

后端:申请快照,在提交审批申请时记录,开始记录。工作流异常提示文案及log。在工作流执行(主要是异常)前更新表信息(主要是状态,后面可以拆开先存人,工作流成功后再更新状态)保证工作流上信息显示准确,暂不考虑异常。

baichengfei il y a 5 ans
Parent
commit
e2518e722d

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

@@ -22,4 +22,5 @@ type OilSupplierLog struct {
 	AwardProject      string    `xorm:"TEXT"`         // 近三年省部级及以上获奖项目
 	Remark            string    `xorm:"TEXT"`         // 日志备注
 	CreateOn          time.Time `xorm:"DATETIME created"`
+	ModifiedOn        time.Time `xorm:"DATETIME created"`
 }

+ 54 - 14
src/dashoo.cn/backend/api/business/oilsupplier/supplierlog/supplierlogService.go

@@ -32,6 +32,26 @@ type SupplierlogService struct {
 	MyServiceBase
 }
 
+//type SupplierBaseInfo struct {
+//	BaseInfo	string	`json:"baseInfo"`	// OilSupplier
+//	ChangeItems	string	`json:"changeItems"`	//OilAppendChangeItem
+//}
+
+type SupplierAppendBaseInfo struct {
+	BaseInfo    supplier.OilSupplier
+	ChangeItems []suppliercertappendsub.OilAppendChangeItem
+}
+
+type SupplierAnnualBaseInfo struct {
+	BaseInfo    supplier.OilSupplier
+	ChangeItems []infochange.OilAnnualChangeItem
+}
+
+type SupplierInfoChangeBaseInfo struct {
+	BaseInfo    supplier.OilSupplier
+	ChangeItems []infochange.OilInfoChangeItem
+}
+
 func GetSupplierLogService(xormEngine *xorm.Engine) *SupplierlogService {
 	s := new(SupplierlogService)
 	s.DBE = xormEngine
@@ -61,7 +81,7 @@ func (s *SupplierlogService) SaveSupplierLogForAccess(supplierId int, supplierCe
 		// 现场考察报告列表
 		sceneFileSrv := supplierscenefile.GetSupplierScenefileService(utils.DBE)
 		var sceneFileList []supplierscenefile.OilSupplierSceneFile
-		sceneFileSrv.GetEntitysByWhere("OilSupplierFile", whereSupplier, &sceneFileList)
+		sceneFileSrv.GetEntitysByWhere("`OilSupplierSceneFile`", whereSupplier, &sceneFileList)
 		// 主要设备
 		majorEquipmentSrv := majorequip.GetMajorequipService(utils.DBE)
 		var majorEquipmentList []majorequip.OilEnterpriseMajorEquipment
@@ -85,7 +105,7 @@ func (s *SupplierlogService) SaveSupplierLogForAccess(supplierId int, supplierCe
 		// 准入范围
 		certSubSrv := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
 		var certSubList []suppliercertsub.OilSupplierCertSub
-		certSubSrv.GetEntitysByWhere("OilSupplierCertSub", whereSupplier+" and Type=1 and "+whereSupplierCert+" and TypeCode="+supplierCertEntity.SupplierTypeCode, &certSubList)
+		certSubSrv.GetEntitysByWhere("OilSupplierCertSub", whereSupplier+" and Type=1 and "+whereSupplierCert+" and SupplierTypeCode="+supplierCertEntity.SupplierTypeCode, &certSubList)
 
 		// json 化数据
 		supplierBaseInfo, _ := json.Marshal(supplierEntity)
@@ -152,16 +172,20 @@ func (s *SupplierlogService) SaveSupplierLogForAppend(supplierId int, supplierCe
 		appendWhere := " a.SupplierId = " + strconv.Itoa(supplierId)
 		appendWhere = appendWhere + " and a.SupplierTypeCode in ( '000', '" + appendCertEntity.AppendType + "')"
 		appendCertSubSrv := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
-		appendCertSubSrv.GetQualPagingEntities("OilSupplierFile", "OilAppendChangeDetail", 1, 100, "a.Id", true, &appendCertFileList, appendWhere, strconv.Itoa(supplierCertAppendId))
+		appendCertSubSrv.GetQualPagingEntities("OilSupplierFile", "OilAppendChangeDetail", 1, 1000, "a.Id", true, &appendCertFileList, appendWhere, strconv.Itoa(supplierCertAppendId))
 		// 准入范围 Type是3的就是本次新增的
 		certSubSrv := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
 		var certSubList []suppliercertsub.OilSupplierCertSub
-		certSubSrv.GetEntitysByWhere("OilSupplierCertSub", whereSupplier+" and "+whereSupplierCertAppend+" and Type IN ('1', '3') and SupplierTypeCode IN ('000', '"+appendCertEntity.AppendType+"')", &certSubList)
+		certSubSrv.GetEntitysByWhere("OilSupplierCertSub", whereSupplier+" and "+whereSupplierCertAppend+" and SupplierTypeCode IN ('000', '"+appendCertEntity.AppendType+"')", &certSubList)
 		// json 化数据 SupplierTypeCode
-		supplierBaseInfo, _ := json.Marshal(supplierEntity)
-		supplierBaseInfoChangeItem, _ := json.Marshal(changeInfoItems)
+		//supplierBaseInfo, _ := json.Marshal(supplierEntity)
+		//supplierBaseInfoChangeItem, _ := json.Marshal(changeInfoItems)
 		certFile, _ := json.Marshal(appendCertFileList)
 		certSub, _ := json.Marshal(certSubList)
+		var appendBaseInfo SupplierAppendBaseInfo
+		appendBaseInfo.BaseInfo = supplierEntity
+		appendBaseInfo.ChangeItems = changeInfoItems
+		baseInfo, _ := json.Marshal(appendBaseInfo)
 
 		// 插入日志信息
 		var model OilSupplierLog
@@ -170,7 +194,7 @@ func (s *SupplierlogService) SaveSupplierLogForAppend(supplierId int, supplierCe
 		model.NewSupplierName = supplierEntity.SupplierName
 		model.NewCommercialNo = supplierEntity.CommercialNo
 		model.OperType = 2
-		model.BaseInfo = string(supplierBaseInfo) + "&& " + string(supplierBaseInfoChangeItem)
+		model.BaseInfo = string(baseInfo)
 		model.CertFile = string(certFile)
 		model.CertSub = string(certSub)
 		model.CreateOn = time.Now()
@@ -208,7 +232,7 @@ func (s *SupplierlogService) SaveSupplierLogForAnnual(supplierId int, annualId i
 		annualWhere := " a.SupplierId = " + strconv.Itoa(supplierId)
 		annualWhere = annualWhere + " and a.SupplierTypeCode in ( '000', '" + annualEntity.SupplierTypeName + "')"
 		annualCertSubSrv := suppliercertappendsub.GetOilSupplierCertAppendSubService(utils.DBE)
-		annualCertSubSrv.GetQualPagingEntities("OilSupplierFile", "OilAnnualChangeDetail", 1, 100, "a.Id", true, &annualCertFileList, annualWhere, strconv.Itoa(annualId))
+		annualCertSubSrv.GetQualPagingEntities("OilSupplierFile", "OilAnnualChangeDetail", 1, 1000, "a.Id", true, &annualCertFileList, annualWhere, strconv.Itoa(annualId))
 
 		whereSupplierCert := "SupplierCertId=" + strconv.Itoa(annualEntity.CerId)
 		// 主要设备
@@ -227,15 +251,26 @@ func (s *SupplierlogService) SaveSupplierLogForAnnual(supplierId int, annualId i
 		winningProSrv := winning.GetWinningService(utils.DBE)
 		var winingProList []winning.OilWinningProject
 		winningProSrv.GetEntitysByWhere("OilWinningProject", whereSupplierCert, &winingProList)
+		// 准入范围
+		whereSupplier := "SupplierId=" + strconv.Itoa(annualEntity.SupplierId)
+		certSubSrv := suppliercertsub.GetOilSupplierCertSubService(utils.DBE)
+		var certSubList []suppliercertsub.OilSupplierCertSub
+		certSubSrv.GetEntitysByWhere("OilSupplierCertSub", whereSupplier+" and "+whereSupplierCert+" and SupplierTypeCode="+annualEntity.SupplierTypeName, &certSubList)
 
 		// json 化数据
-		supplierBaseInfo, _ := json.Marshal(supplierEntity)
-		supplierBaseInfoChangeItem, _ := json.Marshal(changeInfoItems)
+		//supplierBaseInfo, _ := json.Marshal(supplierEntity)
+		//supplierBaseInfoChangeItem, _ := json.Marshal(changeInfoItems)
 		majorEquipment, _ := json.Marshal(majorEquipmentList)
 		threeYearsPerformance, _ := json.Marshal(threeYearsPerformanceList)
 		patentTech, _ := json.Marshal(patentTechList)
 		winingPro, _ := json.Marshal(winingProList)
 		certFile, _ := json.Marshal(annualCertFileList)
+		certSub, _ := json.Marshal(certSubList)
+
+		var annualBaseInfo SupplierAnnualBaseInfo
+		annualBaseInfo.BaseInfo = supplierEntity
+		annualBaseInfo.ChangeItems = changeInfoItems
+		baseInfo, _ := json.Marshal(annualBaseInfo)
 
 		// 插入日志信息
 		var model OilSupplierLog
@@ -244,12 +279,13 @@ func (s *SupplierlogService) SaveSupplierLogForAnnual(supplierId int, annualId i
 		model.NewSupplierName = supplierEntity.SupplierName
 		model.NewCommercialNo = supplierEntity.CommercialNo
 		model.OperType = 3 // 年审
-		model.BaseInfo = string(supplierBaseInfo) + "&" + string(supplierBaseInfoChangeItem)
+		model.BaseInfo = string(baseInfo)
 		model.Equipment = string(majorEquipment)
 		model.Performance = string(threeYearsPerformance)
 		model.Patent = string(patentTech)
 		model.AwardProject = string(winingPro)
 		model.CertFile = string(certFile)
+		model.CertSub = string(certSub)
 		model.CreateOn = time.Now()
 		_, err := s.InsertEntity(&model)
 		if err != nil {
@@ -289,9 +325,13 @@ func (s *SupplierlogService) SaveSupplierLogForInfoChange(supplierId int, infoCh
 		allCertSubSrv.GetQualPagingEntities("OilSupplierFile", "OilQualChangeDetail", 1, 1000, "a.Id", true, &allCertFileList, changeWhere, strconv.Itoa(infoChangeId))
 
 		// json 化数据
-		supplierBaseInfo, _ := json.Marshal(supplierEntity)
-		supplierBaseInfoChangeItem, _ := json.Marshal(changeInfoItems)
+		//supplierBaseInfo, _ := json.Marshal(supplierEntity)
+		//supplierBaseInfoChangeItem, _ := json.Marshal(changeInfoItems)
 		certFile, _ := json.Marshal(allCertFileList)
+		var infoChangeBaseInfo SupplierInfoChangeBaseInfo
+		infoChangeBaseInfo.BaseInfo = supplierEntity
+		infoChangeBaseInfo.ChangeItems = changeInfoItems
+		baseInfo, _ := json.Marshal(infoChangeBaseInfo)
 
 		// 插入日志信息
 		var model OilSupplierLog
@@ -300,7 +340,7 @@ func (s *SupplierlogService) SaveSupplierLogForInfoChange(supplierId int, infoCh
 		model.NewSupplierName = supplierEntity.SupplierName
 		model.NewCommercialNo = supplierEntity.CommercialNo
 		model.OperType = 4
-		model.BaseInfo = string(supplierBaseInfo) + "&" + string(supplierBaseInfoChangeItem)
+		model.BaseInfo = string(baseInfo)
 		model.CertFile = string(certFile)
 		model.CreateOn = time.Now()
 		_, err := s.InsertEntity(&model)

+ 0 - 5
src/dashoo.cn/backend/api/controllers/oilsupplier/annualListener.go

@@ -327,11 +327,6 @@ func (this *OilAnnualListenerController) WorkflowEndAudit() {
 	certModel.InFlag = "1"
 	paymentInfoSvc.UpdateEntityByIdCols(strconv.Itoa(annualEntity.CerId), &certModel, []string{"ApplyTime", "InFlag"})
 
-	// 入库成功 记录快照
-	//supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
-	//sourceId, _ := strconv.Atoi(annualId)
-	//supplierLogService.SaveSupplierLogForAnnual(annualEntity.SupplierId, sourceId) // 年审
-
 	// 实际更新变更项
 	//log.Print("年审实际变更信息:", annualEntity)
 	//var qualDetail []annualaudit.OilAnnualChangeDetail

+ 24 - 8
src/dashoo.cn/backend/api/controllers/oilsupplier/annualaudit.go

@@ -9,6 +9,7 @@ import (
 	"dashoo.cn/backend/api/business/oilsupplier/qualchange"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercert"
 	"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
+	"dashoo.cn/backend/api/business/oilsupplier/supplierlog"
 	"dashoo.cn/backend/api/business/oilsupplier/tableheader"
 	"dashoo.cn/backend/api/business/organize"
 	"dashoo.cn/backend/api/business/paymentinfo"
@@ -232,7 +233,7 @@ func (this *AnnualAuditController) GetSupplierList() {
 	//	}
 	//}
 
-	if code != ""{
+	if code != "" {
 		where = where + " and b.SupplierTypeCode='" + code + "' "
 	}
 	where = where + " and b.Status='" + suppliercert.STORE_STATUS + "' "
@@ -878,8 +879,14 @@ func (this *AnnualAuditController) CompanyAuditEntity() {
 
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+annualEntity.BusinessKey+", 流程ID:"+annualEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
+
+	// 入库成功 记录快照
+	supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
+	sourceId, _ := strconv.Atoi(annualId)
+	supplierLogService.SaveSupplierLogForAnnual(annualEntity.SupplierId, sourceId) // 年审
 }
 
 // @Title 二级分办单位提交审批
@@ -963,8 +970,14 @@ func (this *AnnualAuditController) SeparateUnitSubmitAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+auditEntity.BusinessKey+", 流程ID:"+auditEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
+
+	// 入库成功 记录快照
+	supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
+	sourceId, _ := strconv.Atoi(annualId)
+	supplierLogService.SaveSupplierLogForAnnual(auditEntity.SupplierId, sourceId) // 年审
 }
 
 // @Title 二级单位分办 --审批
@@ -1017,12 +1030,13 @@ func (this *AnnualAuditController) SeparateAuditEntity() {
 	ActiComplete.BusinessKey = annualEntity.BusinessKey
 	ActiComplete.UserId = this.User.Id // 审批人员
 	// ActiComplete.UserNames = secondAudit // 初审人员
-	ActiComplete.Result = Result//分办完成后只向前走
+	ActiComplete.Result = Result //分办完成后只向前走
 	ActiComplete.Remarks = AuditRemark
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+annualEntity.BusinessKey+", 流程ID:"+annualEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 }
 
@@ -1066,7 +1080,8 @@ func (this *AnnualAuditController) CommonAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+annualEntity.BusinessKey+", 流程ID:"+annualEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 }
 
@@ -1132,12 +1147,13 @@ func (this *AnnualAuditController) UpdateIsStorage() {
 	ActiComplete.ProcessKey = workflow.OIL_AUDIT_APPLY
 	ActiComplete.BusinessKey = annualEntity.BusinessKey
 	ActiComplete.UserId = this.User.Id //审批人员
-	ActiComplete.Result = status         //前台审批[同意、不同意]
+	ActiComplete.Result = status       //前台审批[同意、不同意]
 	ActiComplete.Remarks = AuditRemark
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+annualEntity.BusinessKey+", 流程ID:"+annualEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 
 }

+ 0 - 5
src/dashoo.cn/backend/api/controllers/oilsupplier/infoChangeListener.go

@@ -254,11 +254,6 @@ func (this *OilInfoChangeListenerController) WorkflowEndAudit() {
 	infoChangeEntity.Status = suppliercert.STORE_STATUS //已入库
 	certAppendSrv.UpdateEntityByIdCols(infoId, infoChangeEntity, cols)
 
-	//  入库成功 实际更新前 记录快照
-	//supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
-	//sourceId, _ := strconv.Atoi(infoId)
-	//supplierLogService.SaveSupplierLogForInfoChange(infoChangeEntity.SupplierId, sourceId) // 信息变更
-
 	this.Data["json"] = 1
 	this.ServeJSON()
 }

+ 21 - 6
src/dashoo.cn/backend/api/controllers/oilsupplier/infochange.go

@@ -9,6 +9,7 @@ import (
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercert"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
 	"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
+	"dashoo.cn/backend/api/business/oilsupplier/supplierlog"
 	"dashoo.cn/backend/api/business/paymentinfo"
 	"dashoo.cn/backend/api/business/register"
 	"dashoo.cn/business2/parameter"
@@ -1638,8 +1639,14 @@ func (this *InfoChangeController) CompanyAuditEntity() {
 
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+infoChangeEntity.BusinessKey+", 流程ID:"+infoChangeEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
+
+	// 入库成功 实际更新前 记录快照
+	supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
+	sourceId, _ := strconv.Atoi(infoId)
+	supplierLogService.SaveSupplierLogForInfoChange(infoChangeEntity.SupplierId, sourceId) // 信息变更
 }
 
 // @Title 二级单位提交审批 --启动工作流
@@ -1726,8 +1733,14 @@ func (this *InfoChangeController) UnitAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+infoChangeEntity.BusinessKey+", 流程ID:"+infoChangeEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
+
+	// 入库成功 实际更新前 记录快照
+	supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
+	sourceId, _ := strconv.Atoi(infoId)
+	supplierLogService.SaveSupplierLogForInfoChange(infoChangeEntity.SupplierId, sourceId) // 信息变更
 }
 
 // @Title 二级单位分办 --审批
@@ -1784,7 +1797,8 @@ func (this *InfoChangeController) SeparateAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+infoChangeEntity.BusinessKey+", 流程ID:"+infoChangeEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 }
 
@@ -1828,7 +1842,8 @@ func (this *InfoChangeController) CommonAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+infoChangeEntity.BusinessKey+", 流程ID:"+infoChangeEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 
 	var infoChangeEntityAfterUpdate infochange.OilInfoChange
@@ -1839,10 +1854,10 @@ func (this *InfoChangeController) CommonAuditEntity() {
 		var oldName supplier.OilSupplierOldName
 		var info infochange.OilInfoChangeItem
 		svc := supplier.GetOilSupplierService(utils.DBE)
-		svc.GetEntityByWhere(OilInfoChangeItemName, "SelectItem = 'SupplierName' and InfoId = " + infoId, &info)
+		svc.GetEntityByWhere(OilInfoChangeItemName, "SelectItem = 'SupplierName' and InfoId = "+infoId, &info)
 		// 曾用名存到主表
 		oilSupplier.OldSupplierName = info.BeChangeInfo
-		svc.UpdateEntityBywheretbl(OilSupplierName, &oilSupplier, []string{"OldSupplierName"}, "Id = " + strconv.Itoa(infoChangeEntityAfterUpdate.SupplierId))
+		svc.UpdateEntityBywheretbl(OilSupplierName, &oilSupplier, []string{"OldSupplierName"}, "Id = "+strconv.Itoa(infoChangeEntityAfterUpdate.SupplierId))
 
 		oldName.OldName = info.BeChangeInfo
 		oldName.Name = info.ChangeInfo

+ 47 - 35
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercert.go

@@ -11,6 +11,7 @@ import (
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
 	"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
+	"dashoo.cn/backend/api/business/oilsupplier/supplierlog"
 	"dashoo.cn/backend/api/business/organize"
 	"dashoo.cn/backend/api/business/paymentinfo"
 	baseparameter "dashoo.cn/business2/parameter"
@@ -723,8 +724,14 @@ func (this *OilSupplierCertController) CompanyAuditEntity() {
 
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertEntity.BusinessKey+", 流程ID:"+supplierCertEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
+
+	// 入库成功 记录快照
+	supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
+	sourceId, _ := strconv.Atoi(certId)
+	supplierLogService.SaveSupplierLogForAccess(supplierCertEntity.SupplierId, sourceId) // 准入
 }
 
 // @Title 二级单位提交审批 --启动工作流
@@ -821,6 +828,11 @@ func (this *OilSupplierCertController) UnitAuditEntity() {
 	if receiveVal != "true" {
 		panic("提交失败,请刷新!")
 	}
+
+	// 入库成功 记录快照
+	supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
+	sourceId, _ := strconv.Atoi(certId)
+	supplierLogService.SaveSupplierLogForAccess(supplierCertEntity.SupplierId, sourceId) // 准入
 }
 
 // @Title 二级单位分办 --审批
@@ -928,7 +940,8 @@ func (this *OilSupplierCertController) CommonAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertEntity.BusinessKey+", 流程ID:"+supplierCertEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 }
 
@@ -963,6 +976,19 @@ func (this *OilSupplierCertController) BusinessOfficeSeparateAuditEntity() {
 	var supplierCertEntity suppliercert.OilSupplierCert
 	certSrv.GetEntityById(certId, &supplierCertEntity)
 
+	// 保证工作流上信息显示准确,暂不考虑异常
+	if Result == "1" {
+		cols := []string{
+			"Id",
+			"Status",
+			"ProfessionalAudit",
+		}
+		supplierCertId := strings.Split(supplierCertEntity.BusinessKey, "-")[0]
+		supplierCertEntity.Status = suppliercert.PROF_AUDIT_STATUS //专业处室接收
+		supplierCertEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
+		certSrv.UpdateEntityByIdCols(supplierCertId, supplierCertEntity, cols)
+	}
+
 	svcActiviti := workflow.GetActivitiService(utils.DBE)
 	var ActiComplete workflow.ActiCompleteVM
 	ActiComplete.ProcessKey = workflow.OIL_ENUSER_SUPPLIER_APPLY
@@ -974,18 +1000,8 @@ func (this *OilSupplierCertController) BusinessOfficeSeparateAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
-	}
-	if Result == "1" {
-		cols := []string{
-			"Id",
-			"Status",
-			"ProfessionalAudit",
-		}
-		supplierCertId := strings.Split(supplierCertEntity.BusinessKey, "-")[0]
-		supplierCertEntity.Status = suppliercert.PROF_AUDIT_STATUS //专业处室接收
-		supplierCertEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
-		certSrv.UpdateEntityByIdCols(supplierCertId, supplierCertEntity, cols)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertEntity.BusinessKey+", 流程ID:"+supplierCertEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 }
 
@@ -1028,7 +1044,8 @@ func (this *OilSupplierCertController) ConcentrateAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertEntity.BusinessKey+", 流程ID:"+supplierCertEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 	//cols := []string{
 	//	"Id",
@@ -1075,12 +1092,6 @@ func (this *OilSupplierCertController) UpdateIsStorage() {
 				where := " SupplierCertId = " + id
 				svc1.UpdateEntityBywheretbl(OilSupplierCertSubName, &model1, cols, where)
 				errinfo.Message = "入库成功"
-
-				// 入库成功 记录快照	// 也可以在监听器工作流结束环节记录
-				//supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
-				//sourceId, _ := strconv.Atoi(id)
-				//supplierId, _ := strconv.Atoi(SupplierId)
-				//supplierLogService.SaveSupplierLogForAccess(supplierId, sourceId) // 准入
 			} else {
 				errinfo.Message = "退回成功"
 			}
@@ -1157,7 +1168,8 @@ func (this *OilSupplierCertController) UpdateIsStorage() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertEntity.BusinessKey+", 流程ID:"+supplierCertEntity.WorkflowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 
 }
@@ -1549,15 +1561,15 @@ func (this *OilSupplierCertController) ChangeSupplierStatus() {
 				tmpCertItem.InFlag = "2"
 				if tmpCertItem.ApplyTime.Before(time.Now()) {
 					// 年审到期
-					tmpCertItem.Remark = strings.Trim("年审过期,资质过期," + tmpCertItem.Remark, ",")
+					tmpCertItem.Remark = strings.Trim("年审过期,资质过期,"+tmpCertItem.Remark, ",")
 				} else {
-					tmpCertItem.Remark = strings.Trim("资质过期," + tmpCertItem.Remark, ",")
+					tmpCertItem.Remark = strings.Trim("资质过期,"+tmpCertItem.Remark, ",")
 				}
 				svcsupp.UpdateEntityByIdCols(tmpCertItem.Id, &tmpCertItem, cols)
 
-			} else if tmpCertItem.InFlag == "2" && !strings.Contains(tmpCertItem.Remark, "资质过期")  {
+			} else if tmpCertItem.InFlag == "2" && !strings.Contains(tmpCertItem.Remark, "资质过期") {
 				tmpCertItem.InFlag = "2"
-				tmpCertItem.Remark = strings.Trim("资质过期," + tmpCertItem.Remark, ",")
+				tmpCertItem.Remark = strings.Trim("资质过期,"+tmpCertItem.Remark, ",")
 				svcsupp.UpdateEntityByIdCols(tmpCertItem.Id, &tmpCertItem, cols)
 			}
 		}
@@ -1573,15 +1585,15 @@ func (this *OilSupplierCertController) ChangeSupplierStatus() {
 
 	// 将过期时间的更正过来,SQL备份
 	/*
-	-- SELECT id, cert.SupplierId, Inflag, Remark FROM OilSupplierCert cert
-	UPDATE OilSupplierCert cert SET cert.InFlag='1', cert.Remark=''
-	WHERE cert.InFlag='2' AND cert.Remark = '资质过期'
-	AND NOT EXISTS (
-		SELECT Id, `NeedFileType`, a.EffectDate FROM `OilSupplierFile` a
-	WHERE a.EffectDate <= NOW()
-	AND a.SupplierTypeCode IN ('000', cert.SupplierTypeCode)
-	AND a.SupplierId = cert.SupplierId
-	) */
+		-- SELECT id, cert.SupplierId, Inflag, Remark FROM OilSupplierCert cert
+		UPDATE OilSupplierCert cert SET cert.InFlag='1', cert.Remark=''
+		WHERE cert.InFlag='2' AND cert.Remark = '资质过期'
+		AND NOT EXISTS (
+			SELECT Id, `NeedFileType`, a.EffectDate FROM `OilSupplierFile` a
+		WHERE a.EffectDate <= NOW()
+		AND a.SupplierTypeCode IN ('000', cert.SupplierTypeCode)
+		AND a.SupplierId = cert.SupplierId
+		) */
 
 }
 

+ 1 - 5
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercertAppendListener.go

@@ -347,11 +347,7 @@ func (this *OilSupplierCertAppendListenerController) WorkflowEndAudit() {
 	var appendSubModel suppliercertsub.OilSupplierCertSub
 	appendSubModel.Type = "3"
 	certAppendSrv.UpdateEntityBywheretbl(OilSupplierCertSubName, &appendSubModel, []string{"Type"}, appendWhere)
-	// TODO 实际更新前 记录申请快照
-	// 选择在准入项更新以后记录快照,防止第一次审批未通过后又改变了准入范围(待验证)。	// CertSubStatus字段 -1是什么状态
-	//supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
-	//sourceId, _ := strconv.Atoi(supplierCertAppendId)
-	//supplierLogService.SaveSupplierLogForAppend(supplierCertAppendEntity.SupplierId, sourceId) // 增项
+
 	//更新资质表
 	appendFileWhere := " SupplierId = " + utils.ToStr(supplierCertAppendEntity.SupplierId) + " and SupType = 2"
 	var appendSubFileModel supplierfile.OilSupplierFile

+ 39 - 20
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercertappend.go

@@ -10,6 +10,7 @@ import (
 	"dashoo.cn/backend/api/business/oilsupplier/supplier"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
 	"dashoo.cn/backend/api/business/oilsupplier/supplierfile"
+	"dashoo.cn/backend/api/business/oilsupplier/supplierlog"
 	"dashoo.cn/backend/api/business/oilsupplier/tableheader"
 	"dashoo.cn/backend/api/business/organize"
 	"dashoo.cn/backend/api/business/paymentinfo"
@@ -766,8 +767,14 @@ func (this *OilSupplierCertAppendController) CompanySubmitAuditEntity() {
 
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertAppendEntity.BusinessKey+", 流程ID:"+supplierCertAppendEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
+
+	// 记录申请快照 选择在准入项更新以后记录快照,防止第一次审批未通过后又改变了准入范围(待验证)。	// CertSubStatus字段 -1是什么状态
+	supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
+	sourceId, _ := strconv.Atoi(certAppendId)
+	supplierLogService.SaveSupplierLogForAppend(supplierCertAppendEntity.SupplierId, sourceId) // 增项
 }
 
 // @Title 二级分办单位提交审批----启动工作流
@@ -854,8 +861,13 @@ func (this *OilSupplierCertAppendController) SeparateUnitSubmitAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertAppendEntity.BusinessKey+", 流程ID:"+supplierCertAppendEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
+	// 记录申请快照 选择在准入项更新以后记录快照,防止第一次审批未通过后又改变了准入范围(待验证)。	// CertSubStatus字段 -1是什么状态
+	supplierLogService := supplierlog.GetSupplierLogService(utils.DBE)
+	sourceId, _ := strconv.Atoi(certAppendId)
+	supplierLogService.SaveSupplierLogForAppend(supplierCertAppendEntity.SupplierId, sourceId) // 增项
 }
 
 // @Title 二级单位分办 --审批
@@ -915,7 +927,8 @@ func (this *OilSupplierCertAppendController) AppendSeparateAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertAppendEntity.BusinessKey+", 流程ID:"+supplierCertAppendEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 }
 
@@ -959,7 +972,8 @@ func (this *OilSupplierCertAppendController) AppendCommonAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertAppendEntity.BusinessKey+", 流程ID:"+supplierCertAppendEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 }
 
@@ -994,19 +1008,7 @@ func (this *OilSupplierCertAppendController) AppendBusinessOfficeSeparateAuditEn
 	var supplierCertAppendEntity suppliercertappend.OilSupplierCertAppend
 	certSrv.GetEntityById(certAppendId, &supplierCertAppendEntity)
 
-	svcActiviti := workflow.GetActivitiService(utils.DBE)
-	var ActiComplete workflow.ActiCompleteVM
-	ActiComplete.ProcessKey = workflow.OIL_ENUSER_APPEND_APPLY
-	ActiComplete.BusinessKey = supplierCertAppendEntity.BusinessKey
-	ActiComplete.UserId = this.User.Id         //审批人员
-	ActiComplete.Result = Result                  //前台审批[同意、不同意]
-	ActiComplete.UserNames = ProfessionalAudit // 直接分配业务处室专业审批人
-	ActiComplete.Remarks = AuditRemark
-	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
-	receiveVal := svcActiviti.TaskComplete(ActiComplete)
-	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
-	}
+	// 保证工作流上信息显示准确,暂不考虑异常
 	if Result == "1" {
 		cols := []string{
 			"Id",
@@ -1018,6 +1020,21 @@ func (this *OilSupplierCertAppendController) AppendBusinessOfficeSeparateAuditEn
 		supplierCertAppendEntity.ProfessionalAudit, _ = strconv.Atoi(ProfessionalAudit)
 		certSrv.UpdateEntityByIdCols(supplierCertAppendId, supplierCertAppendEntity, cols)
 	}
+
+	svcActiviti := workflow.GetActivitiService(utils.DBE)
+	var ActiComplete workflow.ActiCompleteVM
+	ActiComplete.ProcessKey = workflow.OIL_ENUSER_APPEND_APPLY
+	ActiComplete.BusinessKey = supplierCertAppendEntity.BusinessKey
+	ActiComplete.UserId = this.User.Id         //审批人员
+	ActiComplete.Result = Result               //前台审批[同意、不同意]
+	ActiComplete.UserNames = ProfessionalAudit // 直接分配业务处室专业审批人
+	ActiComplete.Remarks = AuditRemark
+	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
+	receiveVal := svcActiviti.TaskComplete(ActiComplete)
+	if receiveVal != "true" {
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertAppendEntity.BusinessKey+", 流程ID:"+supplierCertAppendEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
+	}
 }
 
 // @Title 集中审批
@@ -1059,7 +1076,8 @@ func (this *OilSupplierCertAppendController) AppendConcentrateAuditEntity() {
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertAppendEntity.BusinessKey+", 流程ID:"+supplierCertAppendEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 	//cols := []string{
 	//	"Id",
@@ -1132,12 +1150,13 @@ func (this *OilSupplierCertAppendController) UpdateIsStorage() {
 	ActiComplete.ProcessKey = workflow.OIL_ENUSER_APPEND_APPLY
 	ActiComplete.BusinessKey = supplierCertAppendEntity.BusinessKey
 	ActiComplete.UserId = this.User.Id //审批人员
-	ActiComplete.Result = status         //前台审批[同意、不同意]
+	ActiComplete.Result = status       //前台审批[同意、不同意]
 	ActiComplete.Remarks = AuditRemark
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
 	if receiveVal != "true" {
-		panic("工作流异常,请联系管理员!" + receiveVal)
+		fmt.Println(time.Now().String()+" ---- 工作流异常, 业务ID:"+supplierCertAppendEntity.BusinessKey+", 流程ID:"+supplierCertAppendEntity.WorkFlowId, " 工作流传参: ", ActiComplete, receiveVal)
+		panic("任务已审批,请刷新!")
 	}
 
 }