2
3
Эх сурвалжийг харах

年审 提前判断分办单位是否配置审批人

baichengfei 5 жил өмнө
parent
commit
049b201654

+ 61 - 50
src/dashoo.cn/backend/api/controllers/oilsupplier/annualaudit.go

@@ -105,16 +105,16 @@ func (this *AnnualAuditController) GetEntityList() {
 	svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
 	var registerUser register.OilCorporateInfo
 	sql := " UserName='" + this.User.Username + "'"
-	svc.GetEntity(&registerUser,sql)
+	svc.GetEntity(&registerUser, sql)
 	//企业用户必须加创建人条件
 	if this.User.IsCompanyUser == 1 {
-		where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='"+registerUser.CommercialNo+"')"
+		where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
 	} else {
 		//超级管理员和有查看所有数据权限的用户不加条件
 		svcPerm := permission.GetPermissionService(utils.DBE)
 		isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.annual.AllRecord")
 		if !svcPerm.IsAdmin(this.User.Id) && !isauth {
-			where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='"+registerUser.CommercialNo+"')"
+			where = where + " and (b.CreateUserId = '" + this.User.Id + "' or a.CommercialNo='" + registerUser.CommercialNo + "')"
 		}
 	}
 	var list []annualaudit.OilAnnualAudit
@@ -231,7 +231,7 @@ func (this *AnnualAuditController) GetSupplierList() {
 	//		where = where + " and a.CreateUserId = '" + this.User.Id + "'"
 	//	}
 	//}
-	where = where + " and b.SupplierTypeCode='" + code + "' and b.Status='" + suppliercert.STORE_STATUS+"'"
+	where = where + " and b.SupplierTypeCode='" + code + "' and b.Status='" + suppliercert.STORE_STATUS + "'"
 	supplierlist = svc.GetSupplierList(""+OilSupplierName, where)
 	var datainfo DataInfo
 	datainfo.Items = supplierlist
@@ -313,15 +313,15 @@ func (this *AnnualAuditController) GetSupplier() {
 	where := "1=1 "
 	if SuppTypeCode != "" {
 		where = " WHERE b.Id is NOT NULL AND a.SupplierTypeCode = '" + SuppTypeCode + "' and (a.InFlag='1' or a.InFlag='2')"
-	}else {
+	} else {
 		where = " WHERE b.Id is NOT NULL AND (a.InFlag='1' or a.InFlag='2')"
 	}
 	var registerUser register.OilCorporateInfo
 	sql := " UserName='" + this.User.Username + "'"
-	svc.GetEntity(&registerUser,sql)
+	svc.GetEntity(&registerUser, sql)
 	//企业用户必须加创建人条件
 	if this.User.IsCompanyUser == 1 {
-		where = where + " and (b.CreateUserId = '" + this.User.Id + "' or b.CommercialNo='"+registerUser.CommercialNo+"')"
+		where = where + " and (b.CreateUserId = '" + this.User.Id + "' or b.CommercialNo='" + registerUser.CommercialNo + "')"
 		//if this.User.IsCompanyUser == 1 {
 		//	where = where + " and b.CreateUserId = '" + this.User.Id + "'"
 	}
@@ -334,6 +334,7 @@ func (this *AnnualAuditController) GetSupplier() {
 	this.Data["json"] = &model
 	this.ServeJSON()
 }
+
 // @Title 获取公司信息(信息变更专用)
 // @Description 根据创建用户Id和增项类别号获取公司信息
 // @Success 200 {object}
@@ -344,15 +345,15 @@ func (this *AnnualAuditController) GetSupplierForChange() {
 	where := "1=1 "
 	if SuppTypeCode != "" {
 		where = " WHERE b.Id is NOT NULL AND a.SupplierTypeCode = '" + SuppTypeCode + "' and (a.InFlag='1' or a.InFlag='2' or a.Status='6' or a.Status='7')"
-	}else {
+	} else {
 		where = " WHERE b.Id is NOT NULL AND (a.InFlag='1' or a.InFlag='2' or a.Status='6' or a.Status='7')"
 	}
 	var registerUser register.OilCorporateInfo
 	sql := " UserName='" + this.User.Username + "'"
-	svc.GetEntity(&registerUser,sql)
+	svc.GetEntity(&registerUser, sql)
 	//企业用户必须加创建人条件
 	if this.User.IsCompanyUser == 1 {
-		where = where + " and (b.CreateUserId = '" + this.User.Id + "' or b.CommercialNo='"+registerUser.CommercialNo+"')"
+		where = where + " and (b.CreateUserId = '" + this.User.Id + "' or b.CommercialNo='" + registerUser.CommercialNo + "')"
 		//if this.User.IsCompanyUser == 1 {
 		//	where = where + " and b.CreateUserId = '" + this.User.Id + "'"
 	}
@@ -376,7 +377,7 @@ func (this *AnnualAuditController) AddEntityDirect() {
 	var jsonBlob = this.Ctx.Input.RequestBody
 	svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
 	json.Unmarshal(jsonBlob, &model)
-	supWhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName+ "' and b.Status = '8' "
+	supWhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName + "' and b.Status = '8' "
 	supSvc := supplier.GetOilSupplierService(utils.DBE)
 	var list []supplier.OilSupplierView
 	supSvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 1, "a.Id", true, &list, supWhere)
@@ -544,7 +545,7 @@ func (this *AnnualAuditController) UpdateSuppEntity() {
 	}
 	err := svc.UpdateEntityBytbl(OilSupplierName, id, &model, updateCols)
 	if err == nil {
-		svc.DBE.Exec("update OilSupplierCert set Instyle="+instyle+" where SupplierId="+id+" and SupplierTypeCode="+typeCode+"")
+		svc.DBE.Exec("update OilSupplierCert set Instyle=" + instyle + " where SupplierId=" + id + " and SupplierTypeCode=" + typeCode + "")
 		errinfo.Message = "修改成功!"
 		errinfo.Code = 0
 		this.Data["json"] = &errinfo
@@ -556,6 +557,7 @@ func (this *AnnualAuditController) UpdateSuppEntity() {
 		this.ServeJSON()
 	}
 }
+
 // @Title 添加
 // @Description 新增年审
 // @Success	200	{object} controllers.Request
@@ -577,7 +579,7 @@ func (this *AnnualAuditController) AddEntity() {
 		this.ServeJSON()
 		return
 	}
-	supWhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName+ "' and b.Status = '8' "
+	supWhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName + "' and b.Status = '8' "
 	supSvc := supplier.GetOilSupplierService(utils.DBE)
 	var list []supplier.OilSupplierView
 	total := supSvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 1, "a.Id", true, &list, supWhere)
@@ -736,10 +738,10 @@ func (this *AnnualAuditController) AddAuditEntity() {
 	} else {
 		auditmodel.Status = suppliercert.FIRST_TRIAL_STATUS
 	}
-	auditmodel.FenbanAudit,_ = strconv.Atoi(firstAudit)
-	auditmodel.FirstAudit,_ = strconv.Atoi(firstAudit)
-	auditmodel.SecondAudit,_ = strconv.Atoi(secondAudit)
-	auditmodel.ThirdAudit,_ = strconv.Atoi(thirdAudit)
+	auditmodel.FenbanAudit, _ = strconv.Atoi(firstAudit)
+	auditmodel.FirstAudit, _ = strconv.Atoi(firstAudit)
+	auditmodel.SecondAudit, _ = strconv.Atoi(secondAudit)
+	auditmodel.ThirdAudit, _ = strconv.Atoi(thirdAudit)
 
 	cols := []string{
 		"Id",
@@ -822,6 +824,16 @@ func (this *AnnualAuditController) CompanyAuditEntity() {
 		panic("工作流已经启动,请刷新重试!")
 	}
 
+	supplierCertSrv := suppliercert.GetOilSupplierCertService(utils.DBE)
+	var supplierCertEntity suppliercert.OilSupplierCert
+	supplierCertSrv.GetEntityById(annualEntity.CerId, &supplierCertEntity)
+	stepCode := workflow.GetWorkFlowStepCode(supplierCertEntity.SupplierTypeCode) // TODO 年审的准入方式
+	auditSettingService := auditsetting.GetOilAuditSettingService(utils.DBE)
+	approverIds := auditSettingService.GetApproverIdsByStepCodeAndUnitId(stepCode, unitId)
+	if approverIds == "" {
+		panic("该分办单位未配置审批人")
+	}
+
 	svcActiviti := workflow.GetActivitiService(utils.DBE)
 	//启动工作流
 	businessKey := annualEntity.BusinessKey
@@ -854,7 +866,7 @@ func (this *AnnualAuditController) CompanyAuditEntity() {
 	ActiComplete.ProcessKey = workflow.OIL_AUDIT_APPLY
 	ActiComplete.BusinessKey = businessKey
 	ActiComplete.UserId = this.User.Id
-	ActiComplete.Result =  "1" //提交给二级单位分办
+	ActiComplete.Result = "1" //提交给二级单位分办
 	ActiComplete.Remarks = AuditRemark
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 
@@ -1106,7 +1118,7 @@ func (this *AnnualAuditController) UpdateIsStorage() {
 	ActiComplete.ProcessKey = workflow.OIL_AUDIT_APPLY
 	ActiComplete.BusinessKey = annualEntity.BusinessKey
 	ActiComplete.UserId = this.User.Id //审批人员
-	ActiComplete.Result = "1" //前台审批[同意、不同意]
+	ActiComplete.Result = "1"          //前台审批[同意、不同意]
 	ActiComplete.Remarks = AuditRemark
 	ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 	receiveVal := svcActiviti.TaskComplete(ActiComplete)
@@ -1216,9 +1228,9 @@ func (this *AnnualAuditController) AnnualAudit() {
 		step = 2
 		backstatus = suppliercert.NO_FEN_TRIAL_STATUS
 		if dataother.SuccessStatus == 1 {
-			list.FirstAudit,_ = strconv.Atoi(firstAudit)
-			list.SecondAudit,_ = strconv.Atoi(secondAudit)
-			list.ThirdAudit,_ = strconv.Atoi(thirdAudit)
+			list.FirstAudit, _ = strconv.Atoi(firstAudit)
+			list.SecondAudit, _ = strconv.Atoi(secondAudit)
+			list.ThirdAudit, _ = strconv.Atoi(thirdAudit)
 			cols := []string{
 				"FirstAudit",
 				"SecondAudit",
@@ -1306,7 +1318,7 @@ func (this *AnnualAuditController) AnnualAudit() {
 				paysvc := paymentinfo.GetPaymentService(utils.DBE)
 				var Amount float64
 				asvc := oilcostmanage.GetOilCostManageService(utils.DBE)
-				Amount = asvc.GetAmount("ANNUAL",list.SupplierTypeName)
+				Amount = asvc.GetAmount("ANNUAL", list.SupplierTypeName)
 				var payinfo paymentinfo.OilPaymentInfo
 				payinfo.SupplierId = list.SupplierId
 				payinfo.SrcId = list.Id
@@ -1316,24 +1328,24 @@ func (this *AnnualAuditController) AnnualAudit() {
 				payinfo.PayType = "2"
 				payinfo.IsPay = "0"
 				payinfo.IsInvoice = "0"
-				payinfo.Amount = strconv.FormatFloat(Amount,'E',-1,64)
+				payinfo.Amount = strconv.FormatFloat(Amount, 'E', -1, 64)
 				payinfo.CreateUserId = list.CreateUserId
 				payinfo.CreateBy = list.CreateBy
 				payinfo.CreateOn = time.Now()
 				paysvc.InsertEntity(&payinfo)
 				//发短信
 				toMobile := supplierEntity.Mobile
-				bFlag:=""
-				if list.SupplierTypeName == "01"{
-					bFlag="物资类"
-				}else if list.SupplierTypeName == "02"{
-					bFlag="基建类"
-				}else{
-					bFlag="服务类"
+				bFlag := ""
+				if list.SupplierTypeName == "01" {
+					bFlag = "物资类"
+				} else if list.SupplierTypeName == "02" {
+					bFlag = "基建类"
+				} else {
+					bFlag = "服务类"
 				}
-				msg:= "您的"+ bFlag + "年审审核通过,请及时确认信息并交费!"
+				msg := "您的" + bFlag + "年审审核通过,请及时确认信息并交费!"
 				msgService := msg2.GetMsgService(utils.DBE)
-				msgService.HandleMsg(toMobile,msg,"4-1",list.CreateBy,supplierEntity.ContactName,strconv.Itoa(list.CreateUserId), this.User.Username)
+				msgService.HandleMsg(toMobile, msg, "4-1", list.CreateBy, supplierEntity.ContactName, strconv.Itoa(list.CreateUserId), this.User.Username)
 			} else {
 				auditmodel.Status = suppliercert.ALL_PASE_STATUS
 			}
@@ -1352,10 +1364,10 @@ func (this *AnnualAuditController) AnnualAudit() {
 			}
 
 			var infoitems []infochange.OilAnnualChangeItem
-			where := "SupplierId = " + utils.ToStr(supplierEntity.Id) +" and InfoId = " +utils.ToStr(list.Id)
+			where := "SupplierId = " + utils.ToStr(supplierEntity.Id) + " and InfoId = " + utils.ToStr(list.Id)
 			svc.GetEntities(&infoitems, where)
 			this.updatesupplier(OilSupplierName, supplierEntity.Id, infoitems)
-		}else {
+		} else {
 			auditmodel.ApplyTime = oldaplydate
 		}
 		auditmodel.Step = step
@@ -1400,17 +1412,17 @@ func (this *AnnualAuditController) AnnualAudit() {
 			_, err := svc.UpdateEntityByIdCols(dataother.AnnualId, list, cols)
 
 			toMobile := supplierEntity.Mobile
-			bFlag:=""
-			if list.SupplierTypeName == "01"{
-				bFlag="物资类"
-			}else if list.SupplierTypeName == "02"{
-				bFlag="基建类"
-			}else{
-				bFlag="服务类"
+			bFlag := ""
+			if list.SupplierTypeName == "01" {
+				bFlag = "物资类"
+			} else if list.SupplierTypeName == "02" {
+				bFlag = "基建类"
+			} else {
+				bFlag = "服务类"
 			}
-			msg:= "您的"+ bFlag + "年审审核未通过,请及时查看!"
+			msg := "您的" + bFlag + "年审审核未通过,请及时查看!"
 			msgService := msg2.GetMsgService(utils.DBE)
-			msgService.HandleMsg(toMobile,msg,"4-1",list.CreateBy,supplierEntity.ContactName,strconv.Itoa(list.CreateUserId), this.User.Username)
+			msgService.HandleMsg(toMobile, msg, "4-1", list.CreateBy, supplierEntity.ContactName, strconv.Itoa(list.CreateUserId), this.User.Username)
 			if err == nil {
 				errinfo.Message = "提交成功!"
 				errinfo.Code = 0
@@ -1448,7 +1460,7 @@ func (this *AnnualAuditController) GetChangeEntity() {
 	models[0] = model
 
 	var infoitems []infochange.OilAnnualChangeItem
-	where := " SupplierId = " + Id +" and InfoId ="+InfoId
+	where := " SupplierId = " + Id + " and InfoId =" + InfoId
 	where = where + " and ChangeStatus = 0"
 	svc.GetEntitysByWhere(OilAnnualChangeItemName, where, &infoitems)
 	tmpModel := &model
@@ -1471,7 +1483,7 @@ func (this *AnnualAuditController) GetChangeEntity() {
 				floatchangeinfo, _ := strconv.ParseFloat(info.ChangeInfo, 64)
 				elem.FieldByName(info.SelectItem).SetFloat(floatchangeinfo)
 			} else if elem.FieldByName(info.SelectItem).Type().String() == "time.Time" {
-				t,_ := time.Parse("2006-01-02", info.ChangeInfo)
+				t, _ := time.Parse("2006-01-02", info.ChangeInfo)
 				elem.FieldByName(info.SelectItem).Set(reflect.ValueOf(t))
 			} else {
 				elem.FieldByName(info.SelectItem).SetString(info.ChangeInfo)
@@ -1805,7 +1817,6 @@ func (this *AnnualAuditController) DeleteAddFile() {
 	where1 := "Id=" + Id
 	err = svc.DeleteEntityBytbl(OilSupplierFileName, where1)
 
-
 	if err == nil {
 		errinfo.Message = "删除成功"
 		errinfo.Code = 0
@@ -1929,7 +1940,7 @@ func (this *AnnualAuditController) UpdatePayStatus() {
 	}
 
 	if len(paymentInfoEntities) == 1 {
-		for _, item := range  paymentInfoEntities {
+		for _, item := range paymentInfoEntities {
 			if item.IsPay == "1" {
 				errinfo.Message = "已确认交费!请耐心等待"
 				errinfo.Code = -1
@@ -1945,10 +1956,10 @@ func (this *AnnualAuditController) UpdatePayStatus() {
 		}
 	}
 
-	sql :="UPDATE OilPaymentInfo SET IsPay ='1' where SrcId=" + annualId
+	sql := "UPDATE OilPaymentInfo SET IsPay ='1' where SrcId=" + annualId
 	annualAuditSrv.DBE.Exec(sql)
 	errinfo.Message = "确认交费成功!"
 	errinfo.Code = 0
 	this.Data["json"] = &errinfo
 	this.ServeJSON()
-}
+}