|
|
@@ -1,6 +1,7 @@
|
|
|
package oilsupplier
|
|
|
|
|
|
import (
|
|
|
+ "dashoo.cn/backend/api/business/audithistory"
|
|
|
"dashoo.cn/backend/api/business/auditsetting"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/infochange"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/suppliercert"
|
|
|
@@ -413,6 +414,14 @@ func (this *InfoChangeController) GetEntityList() {
|
|
|
//找出待办任务
|
|
|
actisvc := workflow.GetActivitiService(utils.DBE)
|
|
|
certIdList := actisvc.GetMyTasks(workflow.OIL_INFO_CHANGE, this.User.Id)
|
|
|
+ appendIdarr := strings.Split(certIdList, ",")
|
|
|
+ for i, item := range appendIdarr {
|
|
|
+ idx := strings.Index(item,"-")
|
|
|
+ if (idx >= 0 ) {
|
|
|
+ appendIdarr[i] = strings.Split(item, "-")[0]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ certIdList = strings.Join(appendIdarr, ",")
|
|
|
where += " and Id in (" + certIdList + ")"
|
|
|
|
|
|
svc := infochange.GetInfoChangeService(utils.DBE)
|
|
|
@@ -610,6 +619,36 @@ func (this *InfoChangeController) GetAuditer() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
|
|
|
+// @Title 添加
|
|
|
+// @Description 新增年审
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /addinfomain [post]
|
|
|
+func (this *InfoChangeController) AddInfoMain() {
|
|
|
+ SupplierId := this.GetString("SupplierId")
|
|
|
+ Remark := this.GetString("Remark")
|
|
|
+ var infochmain infochange.OilInfoChange
|
|
|
+ var errinfo ErrorDataInfo
|
|
|
+ infochmain.SupplierId ,_ = strconv.Atoi(SupplierId)
|
|
|
+ infochmain.Remark = Remark
|
|
|
+ infochmain.CreateOn = time.Now()
|
|
|
+ infochmain.CreateBy = this.User.Realname
|
|
|
+ infochmain.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ svc := infochange.GetInfoChangeService(utils.DBE)
|
|
|
+ _, err := svc.InsertEntityBytbl(OilInfoChangeName, &infochmain)
|
|
|
+ if err == nil{
|
|
|
+ errinfo.Message = "添加成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ errinfo.Item = infochmain.Id
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }else {
|
|
|
+ errinfo.Message = "添加失败!"
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// @Title 提交审批
|
|
|
// @Description 提交审批
|
|
|
// @Success 200 {object} controllers.Request
|
|
|
@@ -618,13 +657,15 @@ func (this *InfoChangeController) AuditEntity() {
|
|
|
suppId := this.Ctx.Input.Param(":id")
|
|
|
firstAudit := this.GetString("auditer")
|
|
|
Remark := this.GetString("Remark")
|
|
|
-
|
|
|
+ InfoId := this.GetString("MInfoId")
|
|
|
//取出审批列表
|
|
|
svc := infochange.GetInfoChangeService(utils.DBE)
|
|
|
var infoitems []infochange.OilInfoChangeItem
|
|
|
where := " SupplierId = " + suppId
|
|
|
svc.GetEntities(&infoitems, where)
|
|
|
var infochangeentity infochange.OilInfoChange
|
|
|
+ infwhere := " Id = " + InfoId
|
|
|
+ svc.GetEntity(&infochangeentity, infwhere)
|
|
|
var infomodel infochange.OilInfoChangeItem
|
|
|
var errinfo ErrorDataInfo
|
|
|
defer func() { //finally处理失败的异常
|
|
|
@@ -646,26 +687,27 @@ func (this *InfoChangeController) AuditEntity() {
|
|
|
items = fmt.Sprintf("%s %s %s %s", items, infoitems[i].SelectItem, ","+infoitems[i].BeChangeInfo, ","+infoitems[i].ChangeInfo+";")
|
|
|
}
|
|
|
items = strings.Trim(items, ";")
|
|
|
- infoid, _ := svc.Insertentityinfo(OilInfoChangeName, items)
|
|
|
- var infoupda infochange.OilInfoChange
|
|
|
- infoupda.SupplierId,_ = strconv.Atoi(suppId)
|
|
|
- svc.UpdateEntityBytbl(OilInfoChangeName, infoid, &infoupda, []string{"SupplierId"})
|
|
|
+ infowhere := " Id = " + InfoId
|
|
|
+ svc.Updateentityinfo(OilInfoChangeName, items, infowhere)
|
|
|
+ //修改从表infoid
|
|
|
for i := 0; i < len(infoitems); i++ {
|
|
|
- infomodel.InfoId, _ = strconv.Atoi(strconv.FormatInt(infoid, 10))
|
|
|
+ infomodel.InfoId, _ = strconv.Atoi(InfoId)
|
|
|
err := svc.UpdateEntityBytbl(OilInfoChangeItemName, infoitems[i].Id, &infomodel, []string{"InfoId"})
|
|
|
fmt.Println(err)
|
|
|
}
|
|
|
|
|
|
svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
processInstanceId := ""
|
|
|
+ businessKey := ""
|
|
|
if infochangeentity.WorkFlowId == "0" || len(infochangeentity.WorkFlowId) <= 0 {
|
|
|
//启动工作流
|
|
|
- processInstanceId = svcActiviti.StartProcess(workflow.OIL_INFO_CHANGE, utils.ToStr(infoid), this.User.Id)
|
|
|
+ businessKey = InfoId + "-" + strconv.Itoa(infochangeentity.AuditIndex)
|
|
|
+ processInstanceId = svcActiviti.StartProcess(workflow.OIL_INFO_CHANGE, businessKey, this.User.Id)
|
|
|
}
|
|
|
|
|
|
var ActiComplete workflow.ActiCompleteVM
|
|
|
ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
|
|
|
- ActiComplete.BusinessKey = utils.ToStr(infoid)
|
|
|
+ ActiComplete.BusinessKey = businessKey
|
|
|
ActiComplete.UserNames = firstAudit
|
|
|
ActiComplete.UserId = this.User.Id
|
|
|
ActiComplete.Result = "1"
|
|
|
@@ -686,9 +728,10 @@ func (this *InfoChangeController) AuditEntity() {
|
|
|
return
|
|
|
}
|
|
|
//记下workflowID(首次提交时才会记录,中间状态请忽略) 及审批状态
|
|
|
-
|
|
|
infochangeentity.WorkFlowId = processInstanceId
|
|
|
infochangeentity.Status = suppliercert.FIRST_TRIAL_STATUS //二级单位初审
|
|
|
+ infochangeentity.AuditIndex = infochangeentity.AuditIndex + 1
|
|
|
+ infochangeentity.BusinessKey = ActiComplete.BusinessKey
|
|
|
infochangeentity.CreateOn = time.Now()
|
|
|
infochangeentity.CreateBy = this.User.Realname
|
|
|
infochangeentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
@@ -698,11 +741,13 @@ func (this *InfoChangeController) AuditEntity() {
|
|
|
"Status",
|
|
|
"Step",
|
|
|
"FirstAudit",
|
|
|
+ "AuditIndex",
|
|
|
+ "BusinessKey",
|
|
|
"CreateOn",
|
|
|
"CreateBy",
|
|
|
"CreateUserId",
|
|
|
}
|
|
|
- svc.UpdateEntityByIdCols(infoid, infochangeentity, cols)
|
|
|
+ svc.UpdateEntityByIdCols(InfoId, infochangeentity, cols)
|
|
|
}
|
|
|
|
|
|
// @Title 审批
|
|
|
@@ -750,7 +795,7 @@ func (this *InfoChangeController) InfoAudit() {
|
|
|
svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
var ActiComplete workflow.ActiCompleteVM
|
|
|
ActiComplete.ProcessKey = workflow.OIL_INFO_CHANGE
|
|
|
- ActiComplete.BusinessKey = utils.ToStr(infoid)
|
|
|
+ ActiComplete.BusinessKey = infomodel.BusinessKey
|
|
|
ActiComplete.UserNames = userIds
|
|
|
ActiComplete.UserId = this.User.Id
|
|
|
ActiComplete.Remarks = dataother.AuditorRemark
|
|
|
@@ -771,6 +816,12 @@ func (this *InfoChangeController) InfoAudit() {
|
|
|
"Step",
|
|
|
}
|
|
|
_, err := svc.UpdateEntityByIdCols(infoid, infochanentity, cols)
|
|
|
+ if infochanentity.Status == "3" {
|
|
|
+ var infochangeitemmodel infochange.OilInfoChangeItem
|
|
|
+ infochangeitemmodel.ChangeStatus = 1
|
|
|
+ itemswhere := "InfoId = " + utils.ToStr(infoid)
|
|
|
+ svc.UpdateEntityBywheretbl(OilInfoChangeItemName, &infochangeitemmodel, []string{"ChangeStatus"}, itemswhere)
|
|
|
+ }
|
|
|
if err == nil{
|
|
|
//原信息表更新
|
|
|
if infomodel.Status == "2" {
|
|
|
@@ -802,6 +853,30 @@ func (this *InfoChangeController) InfoAudit() {
|
|
|
infochanentity.Status = "-3" //企业法规处审批
|
|
|
}
|
|
|
receiveVal := svcActiviti.TaskComplete(ActiComplete)
|
|
|
+ if infochanentity.Status == "-2" {
|
|
|
+ // 审批历史
|
|
|
+ var audithistoryentity audithistory.Base_AuditHistory
|
|
|
+ audithistoryentity.EntityId = infoid
|
|
|
+ audithistoryentity.WorkflowId = infomodel.WorkFlowId
|
|
|
+ audithistoryentity.Process = ActiComplete.ProcessKey
|
|
|
+ audithistoryentity.BusinessKey = ActiComplete.BusinessKey
|
|
|
+ audithistoryentity.Type = "04"
|
|
|
+ audithistoryentity.BackStep = infomodel.Status
|
|
|
+ audithistoryentity.Index = infomodel.AuditIndex
|
|
|
+ audithistoryentity.CreateOn = time.Now()
|
|
|
+ audithistoryentity.CreateBy = this.User.Realname
|
|
|
+ audithistoryentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
+ certSrv.InsertEntity(audithistoryentity)
|
|
|
+ var updateinfo infochange.OilInfoChange
|
|
|
+ updateinfo.Step = 1
|
|
|
+ updateinfo.WorkFlowId = ""
|
|
|
+ cols := []string{
|
|
|
+ "Id",
|
|
|
+ "WorkFlowId",
|
|
|
+ "Step",
|
|
|
+ }
|
|
|
+ svc.UpdateEntityByIdCols(infoid, updateinfo, cols)
|
|
|
+ }
|
|
|
if receiveVal == "true" {
|
|
|
infochanentity.Step = step
|
|
|
cols := []string{
|