diff --git a/api/version1/customerform/formTable.go b/api/version1/customerform/formTable.go index d37d925..814834c 100644 --- a/api/version1/customerform/formTable.go +++ b/api/version1/customerform/formTable.go @@ -518,3 +518,43 @@ func (f *FormUnitInfo) GainMasterAndSunFormUnit(tablename string, subUnitAry []M } } } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-02 11:07:48 +@ 功能: 组件名与关键字对照 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (f *FormUnitInfo) GainMasterAndSunFormUnitNameKey() (mastNameKey map[string]string, suanNameKey map[string]map[string]string) { + mastNameKeyInfo := make(map[string]string) + for _, v := range f.MasterInfo { + mastNameKeyInfo[v.Name] = v.Item.Label + } + mastNameKey = mastNameKeyInfo + + sunTypeAry := make(map[string]map[string]string) + for _, v := range f.SunFormInfo { + sunUnitNameKey := make(map[string]string) + for _, uv := range v.UbitInfo { + + sunUnitNameKey[uv.Name] = uv.Item.Label + } + sunTypeAry[v.TableName] = sunUnitNameKey + // sunTypeAry[v.TableName] = v.UbitInfo + // fmt.Printf("自定义表单结果值!tableName:%v---->%T---->%v\n", v.TableName, v.UbitInfo, v.UbitInfo) + } + suanNameKey = sunTypeAry + // fmt.Printf("自定义表单结果值!tableName:%v---->%T\n", sunTypeAry, sunTypeAry) + return +} diff --git a/api/version1/taskplatform/taskflow/editformflow.go b/api/version1/taskplatform/taskflow/editformflow.go new file mode 100644 index 0000000..f4fea33 --- /dev/null +++ b/api/version1/taskplatform/taskflow/editformflow.go @@ -0,0 +1,593 @@ +package taskflow + +import ( + "appPlatform/api/version1/customerform" + "appPlatform/api/version1/taskplatform/taskmanagement" + "appPlatform/models/modelAppPlatform" + "appPlatform/models/modelshr" + "appPlatform/models/reviseform" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-01 11:40:12 +@ 功能: 获取要修改的数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainEditFormFlowInfo(c *gin.Context) { + var requestData publicmethod.PublicId + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(1, err, c, "未知表单参数!请核对1后重新提交!") + return + } + //第一步判断流程是否已经归档 + var flowInfo modelAppPlatform.RunFlow + err = flowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}, "`flow_key`", "`status`", "`runKey`") + if err != nil { + publicmethod.Result(1, err, c, "流程未归档不可执行修改审批") + return + } + //获取当前流程记录使用得哪个表单及表单组件列表 + var taskInfo modelAppPlatform.Task + err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": flowInfo.FlowKey}, "`version_id`", "`mastesformjson`") + if err != nil { + publicmethod.Result(107, err, c) + return + } + //展开表单 + var formJsonCont customerform.CustomerFormMaster + json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont) + //获取流程使用得表单数据表 + var customerFormInfo modelAppPlatform.CustomerFormVersion + err = customerFormInfo.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}, "`tablekey`", "`table_structure`", "`dict`") + if err != nil { + publicmethod.Result(107, err, c) + return + } + var formUnitCont customerform.FormUnitInfo + formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, formJsonCont.List, true) + masterUnitList := make(map[string]customerform.MasterStruct) + for _, v := range formUnitCont.MasterInfo { + + masterUnitList[v.Name] = v + } + mastKeyName, sunKeyName := formUnitCont.GainMasterAndSunFormUnitNameKey() + // fmt.Printf("formUnitCont.MasterInfo---->%v---->%v\n", mastKeyName, sunKeyName) + masterDataInfo := GainCurrendLogData(flowInfo.FlowKey, customerFormInfo, formUnitCont, masterUnitList) + + var logDataInfo FormDataLog + logDataInfo.FlowKey = flowInfo.FlowKey + logDataInfo.GainFlowFoemLog() + // fmt.Printf("logDataInfo.NewData---->%v\n", logDataInfo.NewData) + if len(logDataInfo.NewData) > 0 { + + logTime := logDataInfo.NewData["logTime"] + newDataInfo := publicmethod.MapOut[string]() + for i, _ := range masterDataInfo { + // fmt.Printf("logDataInfo.masterDataInfo---->%v:%v\n", i, v) + for j, jv := range logDataInfo.NewData { + if i == j { + newDataInfo[i] = jv + } + if j == "explicate" { + newDataInfo["explicate"] = jv + } + } + } + // newDataInfo["logTime"] = logDataInfo.NewData["logTime"] + logDataInfo.NewData = masterDataInfo + logDataInfo.NewData["logTime"] = logTime + masterDataInfo = newDataInfo + fmt.Printf("新表数据---> %v\n", newDataInfo) + } else { + isWrite := true + for i, _ := range masterDataInfo { + if i == "explicate" { + isWrite = false + } + } + if isWrite { + masterDataInfo["explicate"] = "" + } + } + masterDataInfo["flowKey"] = strconv.FormatInt(flowInfo.FlowKey, 10) + sendData := publicmethod.MapOut[string]() + sendData["masterDataInfo"] = masterDataInfo + + sendNewData := publicmethod.MapOut[string]() + sendSunNewData := publicmethod.MapOut[string]() + for i, v := range logDataInfo.NewData { + if val, isOk := v.([]map[string]interface{}); !isOk { + for mi, mv := range mastKeyName { + if mi == i { + sendNewData[mv] = v + } + } + } else { + // fmt.Printf("获取数据类型:---4-->%v----->%v\n", val, sunKeyName[i]) + var newSunData []map[string]interface{} + for _, sv := range val { + sunOld := publicmethod.MapOut[string]() + for smi, smv := range sv { + for sui, suv := range sunKeyName[i] { + if sui == smi { + sunOld[suv] = smv + } + if smi == "id" { + sunOld[suv] = smv + } + } + } + newSunData = append(newSunData, sunOld) + fmt.Printf("获取数据类型:---4-->%v----->%v\n", sv, newSunData) + } + sendSunNewData[i] = newSunData + } + + } + for i, v := range sendSunNewData { + sendNewData[i] = v + } + if len(sendNewData) > 0 { + sendNewData["logTime"] = logDataInfo.NewData["logTime"] + } + + // fmt.Printf("获取数据类型:----->%v\n", sendNewData) + sendData["newData"] = sendNewData + sendData["oldData"] = EditLogCont(logDataInfo.OldData, mastKeyName, sunKeyName) + sendData["newDataLen"] = len(sendNewData) + sendData["logistrue"] = false + if len(sendNewData) > 0 || len(logDataInfo.OldData) > 0 { + sendData["logistrue"] = true + } + publicmethod.Result(0, sendData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-02 14:42:15 +@ 功能: 修改历史记录处理 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func EditLogCont(oldData []map[string]interface{}, mastKeyName map[string]string, sunKeyName map[string]map[string]string) []map[string]interface{} { + var oldAry []map[string]interface{} + + for _, v := range oldData { + sendNewData := publicmethod.MapOut[string]() + for fi, fv := range v { + // fmt.Printf("方法原型===>%v:%T>>>%v\n", fi, fv, fv) + if val, isOk := fv.([]interface{}); !isOk { //主表字段 + for mi, mv := range mastKeyName { + if mi == fi { + sendNewData[mv] = fv + } + } + if fi == "explicate" { + sendNewData["修改说明"] = fv + // oldDataCont["logTime"] = publicmethod.UnixTimeToDay(v.AddTime, 12) + // fmt.Printf("修改说明:---4-->%v----->%v\n", fi, fv) + + } + if fi == "logTime" { + sendNewData["logTime"] = fv + } + } else { //子表字段 + var newSunData []map[string]interface{} + for _, sv := range val { + if ktv, ok := sv.(map[string]interface{}); ok { + sunOld := publicmethod.MapOut[string]() + for smi, smv := range ktv { + for sui, suv := range sunKeyName[fi] { + if sui == smi { + sunOld[suv] = smv + } + } + } + newSunData = append(newSunData, sunOld) + } + + // fmt.Printf("获取数据类型:---4-->%T----->%v\n", sv, sv) + } + sendNewData[fi] = newSunData + } + + } + + // sendNewData["修改说明"] = v["explicate"] + oldAry = append(oldAry, sendNewData) + + } + return oldAry +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-01 13:37:39 +@ 功能: 获取数据表单数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainCurrendLogData(flowKey int64, customerFormInfo modelAppPlatform.CustomerFormVersion, formUnitCont customerform.FormUnitInfo, masterUnitList map[string]customerform.MasterStruct) map[string]interface{} { + //获取自定义创建表单数据 + masterFormCont := publicmethod.MapOut[string]() + err := overall.CONSTANT_DB_CustomerForm.Table(customerFormInfo.TableKey).Where("`masters_key` = ?", flowKey).Take(&masterFormCont).Error + if err != nil { + return masterFormCont + } + masterFormCont = taskmanagement.CustomerFormCallBackVal(masterFormCont, masterUnitList) + if customerFormInfo.TableStructure != "" { + sunFormTable := publicmethod.MapOut[string]() + err = json.Unmarshal([]byte(customerFormInfo.TableStructure), &sunFormTable) + sunTypeAry := make(map[string]map[string]customerform.MasterStruct) + for _, v := range formUnitCont.SunFormInfo { + sunTypeAry[v.TableName] = v.UbitInfo + } + if err == nil { + for _, v := range sunFormTable { + var sunContList []map[string]interface{} + if tableName, isOk := v.(string); isOk { + overall.CONSTANT_DB_CustomerForm.Table(tableName).Where("`masters_key` = ?", flowKey).Find(&sunContList) + var sunContListZhuanBian []map[string]interface{} + if len(sunContList) > 0 { + for _, sclv := range sunContList { + if sunTableType, sunIsOk := sunTypeAry[tableName]; sunIsOk { + masterFormCont := taskmanagement.CustomerFormCallBackVal(sclv, sunTableType) + sunContListZhuanBian = append(sunContListZhuanBian, masterFormCont) + } else { + sunContListZhuanBian = append(sunContListZhuanBian, sclv) + } + } + } + fmt.Printf("自定义表单结果值!tableName:%v---->%T---->%v\n", tableName, sunContListZhuanBian, sunContListZhuanBian) + masterFormCont[tableName] = sunContListZhuanBian + } + } + } + } + return masterFormCont +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-01 13:19:43 +@ 功能: 获取自定义表单历史记录 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (f *FormDataLog) GainFlowFoemLog() { + var logDataList []reviseform.EditFormDataLog + err := overall.CONSTANT_DB_ReviseFormData.Where("`flow_key` = ?", f.FlowKey).Order("`addTime` desc").Find(&logDataList).Error + if err != nil { + return + } + if len(logDataList) > 0 { + for _, v := range logDataList { + if v.State == 1 { + if v.DataCont != "" { + json.Unmarshal([]byte(v.DataCont), &f.NewData) + f.NewData["explicate"] = v.Explicate + f.NewData["logTime"] = publicmethod.UnixTimeToDay(v.AddTime, 12) + } + if v.SunDataCont != "" { + sunDataList := publicmethod.MapOut[string]() + json.Unmarshal([]byte(v.SunDataCont), &sunDataList) + + for si, sv := range sunDataList { + f.NewData[si] = sv + } + } + } else { + var oldDataCont map[string]interface{} + if v.DataCont != "" { + json.Unmarshal([]byte(v.DataCont), &oldDataCont) + + if v.SunDataCont != "" { + sunDataList := publicmethod.MapOut[string]() + json.Unmarshal([]byte(v.SunDataCont), &sunDataList) + // fmt.Printf("v.SunDataCont====>%v====>%v\n", v.DataCont, sunDataList) + for si, sv := range sunDataList { + // fmt.Printf("v.SunDataCont====>%v====>%v\n", si, sv) + oldDataCont[si] = sv + } + } + oldDataCont["explicate"] = v.Explicate + oldDataCont["logTime"] = publicmethod.UnixTimeToDay(v.AddTime, 12) + f.OldData = append(f.OldData, oldDataCont) + } + } + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-01 11:07:06 +@ 功能: 申请修改数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) EditFormLogData(c *gin.Context) { + data, err := c.GetRawData() //接收表单提交得数据 + if err != nil { + publicmethod.Result(100, err, c) + return + } + + mapData := publicmethod.MapOut[string]() //初始化MAP + err = json.Unmarshal(data, &mapData) //将json字符串转换成Map + if err != nil { + publicmethod.Result(100, err, c) + return + } + fmt.Printf("接收表单提交得数据-->%v\n", mapData) + if _, ok := mapData["flowKey"]; !ok { + publicmethod.Result(1, err, c, "非法表单!1不能提交数据!") + return + } + //第一步判断流程是否已经归档 + var flowInfo modelAppPlatform.RunFlow + err = flowInfo.GetCont(map[string]interface{}{"`flow_key`": mapData["flowKey"]}, "`flow_key`", "`status`", "`runKey`", "`id`", "`flow_cont`", "`current_step`", `next_step`, `participants`) + if err != nil || flowInfo.Status != 4 { + publicmethod.Result(1, err, c, "流程未归档不可执行修改审批") + return + } + //获取当前流程记录使用得哪个表单及表单组件列表 + var taskInfo modelAppPlatform.Task + err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": flowInfo.FlowKey}, "`version_id`", "`mastesformjson`") + if err != nil { + publicmethod.Result(107, err, c) + return + } + //获取指定版本表单内容 + var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单 + err = formCont.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}) + if err != nil { + publicmethod.Result(107, err, c) + return + } + var sunFormName []string //子表名称集合 + if formCont.TableStructure != "" { //拆解获取子表名称 + var sunFormStruct map[string]string + err = json.Unmarshal([]byte(formCont.TableStructure), &sunFormStruct) + if err == nil { + for _, v := range sunFormStruct { + if !publicmethod.IsInTrue[string](v, sunFormName) { + sunFormName = append(sunFormName, v) + } + } + } + } + masterField := publicmethod.MapOut[string]() //主表数据 + sunFieldAry := publicmethod.MapOut[string]() //子表数据 + for k, v := range mapData { + if !publicmethod.IsInTrue[string](k, sunFormName) { + if !publicmethod.IsInTrue[string](k, []string{"formId"}) { + masterField[k] = v + } + } else { + sunFieldAry[k] = v + } + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + cureeTime := time.Now().Unix() + + var formJsonCont customerform.CustomerFormMaster + json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串 + + var formUnitCont customerform.FormUnitInfo + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件 + //主表组件 + masterUnitList := make(map[string]customerform.MasterStruct) + for _, v := range formUnitCont.MasterInfo { + masterUnitList[v.Name] = v + } + uuid := publicmethod.GetUUid(6) + //自定义表单修改数据历史记录 + startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人 + var editFormDataLogInfo reviseform.EditFormDataLog + editFormDataLogInfo.SourceForm = taskInfo.VersionId //int64 来源表单"` + editFormDataLogInfo.FlowKey = flowInfo.FlowKey //int64 流程标识符"` + editFormDataLogInfo.RunKey = uuid //int64 当前执行识别符"` + editFormDataLogInfo.AddTime = cureeTime //int64 创建时间"` + editFormDataLogInfo.State = 1 //int 状态(1、新数据;2:已批准的老数据)"` + // editFormDataLogInfo.DataCont = //string 数据值"` + if expval, isOk := mapData["explicate"].(string); isOk { + editFormDataLogInfo.Explicate = expval //string 说明"` + } + + // editFormDataLogInfo.SunDataCont = //string 子表数值"` + + saveData := publicmethod.MapOut[string]() + + //组装数据表新增数据 + masrWriteMap := taskmanagement.MakeFormMapData(flowInfo.FlowKey, userCont.Key, cureeTime, masterField, masterUnitList, 2) + masterTableJson, _ := json.Marshal(masrWriteMap) + editFormDataLogInfo.DataCont = string(masterTableJson) + //判断是否有子表 + if len(sunFieldAry) > 0 { + //有子表 + sunTypeAry := make(map[string]map[string]customerform.MasterStruct) + for _, v := range formUnitCont.SunFormInfo { + sunTypeAry[v.TableName] = v.UbitInfo + } + sunTableData := EditSunDatabase(flowInfo.FlowKey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + fmt.Printf("判断是否有子表得数据-->%v\n", sunTableData) + saveData["sunTypeAry"] = sunTableData + sunTableJson, _ := json.Marshal(sunTableData) + editFormDataLogInfo.SunDataCont = string(sunTableJson) + } + saveData["masrWriteMap"] = masrWriteMap + editFormDataLogInfo.EiteCont(map[string]interface{}{"`flow_key`": flowInfo.FlowKey, "`state`": 1}, map[string]interface{}{"`state`": 2}) + fmt.Printf("写入数据-->%v\n", editFormDataLogInfo) + err = overall.CONSTANT_DB_ReviseFormData.Model(&reviseform.EditFormDataLog{}).Create(&editFormDataLogInfo).Error + if err != nil { + publicmethod.Result(106, err, c) + return + } + var flowList []RunFlow + err = json.Unmarshal([]byte(flowInfo.FlowCont), &flowList) + //执行流程 + var runFlow RunWorkFlow + runFlow.Step = 0 //执行第几部 + runFlow.FlowList = flowList + runFlow.Participant = append(runFlow.Participant, startUs) + runFlow.TotalSteps = len(flowList) //流程总长度 + runFlow.Uuid = flowInfo.Id + runFlow.RunUid = uuid + runFlow.GainRunNode(startUs, 2, "申请修改数据") + + flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流 + SaveFlowCont := publicmethod.MapOut[string]() + SaveFlowCont["`flow_cont`"] = string(flowJsonCont) + SaveFlowCont["`current_step`"] = runFlow.Step + SaveFlowCont["`next_step`"] = runFlow.NextStep + SaveFlowCont["`runKey`"] = uuid + //参与人去重 + var parUser []string + for _, v := range runFlow.Participant { + if !publicmethod.IsInTrue[string](v, parUser) { + parUser = append(parUser, v) + } + } + SaveFlowCont["`participants`"] = strings.Join(parUser, ",") + nextRunUser := runFlow.NextRunNodeUser(1) + SaveFlowCont["`next_executor`"] = strings.Join(nextRunUser, ",") + SaveFlowCont["`status`"] = 3 + if runFlow.NextStep <= 0 { + SaveFlowCont["`status`"] = 4 + } + SaveFlowCont["`update_time`"] = time.Now().Unix() + + flowInfo.EiteCont(map[string]interface{}{"`flow_key`": flowInfo.FlowKey}, SaveFlowCont) + taskInfo.EiteCont(map[string]interface{}{"`masters_key`": flowInfo.FlowKey}, map[string]interface{}{"`status`": 3}) + publicmethod.Result(0, saveData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-02 09:24:33 +@ 功能: 处理指标字段值 +@ 参数 + + #uuid 唯一标识 + #creater 创建人 + #createrTime 创建时间 + #masterTableName 主表标识 + #masterDataCont 主表数据 + #sunDataList 字表数据列表 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func EditSunDatabase(uuid, creater, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (sunTableData map[string]interface{}) { + if len(masterDataCont) > 0 { + if len(sunDataList) > 0 { + sunMasterMap := publicmethod.MapOut[string]() + //子表存在时,执行主表和子表数据写入 + for k, v := range sunDataList { + // fmt.Printf("处理指标字段值--->%v--->%v\n", k, v) + // if k == "table1693811044212" { + s, ok := v.([]interface{}) //获取值类型 + if !ok { + // err = errors.New("表单数据错误!请验证后重新提交!") + return + } else { + //判断是否有数据 + if len(s) > 0 { + var sunCont []map[string]interface{} + for _, sv := range s { //拆分子表 + if sdf, isOk := sv.(map[string]interface{}); isOk { + if sunTableType, sunIsOk := sunTable[k]; sunIsOk { + masterWriteVal := taskmanagement.MakeFormMapData(uuid, creater, createrTime, sdf, sunTableType, 2) //转换数据表值 + // fmt.Printf("处理指标字段值-1-->%v--->%v\n", sunTableType, masterWriteVal) + if len(masterWriteVal) > 0 { + sunCont = append(sunCont, masterWriteVal) + } + } + } + } + if len(sunCont) > 0 { + sunMasterMap[k] = sunCont + } + } + } + } + sunTableData = sunMasterMap + } + } + return +} diff --git a/api/version1/taskplatform/taskflow/taskFlow.go b/api/version1/taskplatform/taskflow/taskFlow.go index 60965ab..961c681 100644 --- a/api/version1/taskplatform/taskflow/taskFlow.go +++ b/api/version1/taskplatform/taskflow/taskFlow.go @@ -3,6 +3,7 @@ package taskflow import ( "appPlatform/models/modelAppPlatform" "appPlatform/models/modelshr" + "appPlatform/models/reviseform" "appPlatform/overall" "appPlatform/overall/publicmethod" "encoding/json" @@ -102,6 +103,11 @@ func (a *ApiMethod) TaskFlowList(c *gin.Context) { if userList[i].MastesForm == "" || userList[i].MastesFormJson == "" { userList[i].MastesForm, userList[i].MastesFormJson = GainTaskFormData(userList[i].FlowKey) } + if userList[i].Status == 3 && userList[i].NextStep != 0 { + if userList[i].CurrentStep == 1 { + userList[i].IsRetract = true + } + } } publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c) } @@ -279,6 +285,9 @@ func (a *ApiMethod) GainRunTaskFlow(c *gin.Context) { } //判断是否需要回写流程记录 flowAry, operational := CheckMakeCopy(runFlowInfo.FlowKey, runFlowInfo.RunKey, runFlowInfo.Status, runFlowInfo.CurrentStep, flowList, userCont) + if runFlowInfo.Status != 3 { + operational = false + } sendMap := publicmethod.MapOut[string]() sendMap["flowList"] = flowAry sendMap["operational"] = operational @@ -314,7 +323,7 @@ func CheckMakeCopy(uuid, runKey int64, state int, currepStep int, flowList []Run if endStep >= len(flowList) { endStep = len(flowList) } - fmt.Printf("currepStep:%v---->endStep:%v\n", currepStep, endStep) + // fmt.Printf("currepStep:%v---->endStep:%v\n", currepStep, endStep) operational = false isWrite := false userKey := strconv.FormatInt(userCont.Key, 10) @@ -337,7 +346,7 @@ func CheckMakeCopy(uuid, runKey int64, state int, currepStep int, flowList []Run } } } - fmt.Printf("currepStep:%v---->endStep:%v\n", flowList[i].ExamineMode, operational) + // fmt.Printf("currepStep:%v---->endStep:%v\n", flowList[i].ExamineMode, operational) } if flowList[i].Types != 0 { if flowList[i].Step <= endStep { @@ -371,7 +380,7 @@ func CheckMakeCopy(uuid, runKey int64, state int, currepStep int, flowList []Run if timeStep <= 0 { timeStep = 1 } - fmt.Printf("operational--->%v\n", operational) + // fmt.Printf("operational--->%v\n", operational) if operational { for k := 0; k < len(flowList); k++ { if flowList[k].Step <= endStep { @@ -631,6 +640,7 @@ func (a *ApiMethod) SubmitApprovalResults(c *gin.Context) { } else { saveFlowInfo["`status`"] = 4 saveTaskInfo["`status`"] = 4 + JudgeEditFlow(flowInfo.FlowKey) } } else { saveFlowInfo["`runKey`"] = publicmethod.GetUUid(6) @@ -655,6 +665,144 @@ func (a *ApiMethod) SubmitApprovalResults(c *gin.Context) { publicmethod.Result(0, err, c) } +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-02 13:49:17 +@ 功能: 判断是不是修改流程 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func JudgeEditFlow(flowKey int64) { + var logDataInfo reviseform.EditFormDataLog + + err := logDataInfo.GetCont(map[string]interface{}{"`flow_key`": flowKey, "`state`": 1}) + if err == nil { + oldCont := publicmethod.MapOut[string]() + //处理主表数据 + if logDataInfo.DataCont != "" { + mastInfo := publicmethod.MapOut[string]() + json.Unmarshal([]byte(logDataInfo.DataCont), &mastInfo) + var oldMastInfoKey []string + for i, _ := range mastInfo { + if !publicmethod.IsInTrue[string](i, oldMastInfoKey) { + oldMastInfoKey = append(oldMastInfoKey, i) + } + } + //获取主表 + var taskInfo modelAppPlatform.Task + err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": flowKey}, "`version_id`") + if err == nil { + var cusFormVersion modelAppPlatform.CustomerFormView + err = cusFormVersion.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}, "`tablekey`") + if err == nil { + oldDataMast := publicmethod.MapOut[string]() + //获取原始数据 + err = overall.CONSTANT_DB_CustomerForm.Table(cusFormVersion.TableKey).Where("`masters_key` = ?", flowKey).Find(&oldDataMast).Error + if err == nil { + for ol, ov := range oldDataMast { + for _, olv := range oldMastInfoKey { + if ol == olv { + oldCont[ol] = ov + } + } + } + } + overall.CONSTANT_DB_CustomerForm.Table(cusFormVersion.TableKey).Where("`masters_key` = ?", flowKey).Updates(mastInfo) + // fmt.Printf("主表更新:%v----->%v------%v\n", cusFormVersion.TableKey, mastInfo, oldCont) + } + } + } + sunOldData := publicmethod.MapOut[string]() + // var sunOldData map[string]interface{} + //处理子表数据 + if logDataInfo.SunDataCont != "" { + sunTableInfo := publicmethod.MapOut[string]() + json.Unmarshal([]byte(logDataInfo.SunDataCont), &sunTableInfo) + + // fmt.Printf("子表数据:%v\n", sunTableInfo) + + for i, v := range sunTableInfo { + + var newSunDataAyr []map[string]interface{} //子表新数据 + if val, isOk := v.([]interface{}); isOk { //判断子表数据是不是数组 + for _, sv := range val { //循环输出数组数据 + if sval, isTrues := sv.(map[string]interface{}); isTrues { //判断值是不是视图 + oldSunKey := publicmethod.MapOut[string]() + for svi, svv := range sval { //解析视图值 + oldSunKey[svi] = svv + } + newSunDataAyr = append(newSunDataAyr, oldSunKey) + } + } + } + + // fmt.Printf("子表---2---》:%T========》%v\n", newSunDataAyr, newSunDataAyr) + + var oldDataSun []map[string]interface{} //子表老数据 + // //获取原始数据 + overall.CONSTANT_DB_CustomerForm.Table(i).Where("`masters_key` = ?", flowKey).Find(&oldDataSun) + // fmt.Printf("获取子表AAA数据:%v----->%v------%v\n", i, v, oldDataSun) + // fmt.Printf("子表更新:%v----->%v------%v\n", i, i, newSunDataAyr) + sunOldData[i] = oldDataSun + //一下步骤是获取老数据表中的数据 + var oldSunTableIdMAp []int64 + for _, oldv := range oldDataSun { + + if sunId, iskk := oldv["id"]; iskk { + // fmt.Printf("子表---9---》:%T========》%v\n", sunId, sunId) + if idInt, isKv := sunId.(uint64); isKv { + oldSunTableIdMAp = append(oldSunTableIdMAp, int64(idInt)) + } + } + } + //一下是区分修改还新增或删除 + var nooPerate []int64 + if len(newSunDataAyr) > 0 { + for _, nv := range newSunDataAyr { + if sunId, iskk := nv["id"]; iskk { + if idInt, isKv := sunId.(uint64); isKv { + if !publicmethod.IsInTrue[int64](int64(idInt), oldSunTableIdMAp) { + nooPerate = append(nooPerate, int64(idInt)) + } + } + overall.CONSTANT_DB_CustomerForm.Table(i).Where("`id` = ?", sunId).Updates(nv) + } else { + overall.CONSTANT_DB_CustomerForm.Table(i).Create(&nv) + } + + } + } + if len(nooPerate) > 0 { + delSql := fmt.Sprintf("DELETE FROM %v WHERE `id` IN %v", i, nooPerate) + overall.CONSTANT_DB_CustomerForm.Exec(delSql) + } + // overall.CONSTANT_DB_CustomerForm.Table(i).Where("`masters_key` = ?", flowKey).Updates(v) + } + } + saveDataLog := publicmethod.MapOut[string]() + mastJsonCont, _ := json.Marshal(oldCont) + saveDataLog["dataCont"] = string(mastJsonCont) + sunJsonCont, _ := json.Marshal(sunOldData) + // fmt.Printf("子表会写更新:%v\n", string(sunJsonCont)) + saveDataLog["sunDataCont"] = string(sunJsonCont) + saveDataLog["`state`"] = 2 + saveDataLog["`editTime`"] = time.Now().Unix() + var logFlow reviseform.EditFormDataLog + logFlow.EiteCont(map[string]interface{}{"`flow_key`": flowKey, "`state`": 1}, saveDataLog) + } + +} + /* * @ 作者: 秦东 @@ -683,10 +831,10 @@ func (r *RunWorkFlow) FlowStepRun(userKey int64, AgreeToRefuse int, Suggest stri for i := 0; i < r.TotalSteps; i++ { if r.FlowList[i].Step == r.Step { - fmt.Printf("节点审批人--11->%v------>%v------>%v\n", r.FlowList[i].Step, r.Step, userKeyStr) + // fmt.Printf("节点审批人--11->%v------>%v------>%v\n", r.FlowList[i].Step, r.Step, userKeyStr) //判断操作人是有操作权限或是否已经操作过 r.IsRun, r.Msg = JudgeOperUser(userKey, r.RunUid, r.FlowList[i].Operator) - fmt.Printf("节点审批人--12->%v------>%v------>%v\n", r.IsRun, r.Msg, userKeyStr) + // fmt.Printf("节点审批人--12->%v------>%v------>%v\n", r.IsRun, r.Msg, userKeyStr) if r.IsRun { return } else { @@ -700,13 +848,13 @@ func (r *RunWorkFlow) FlowStepRun(userKey int64, AgreeToRefuse int, Suggest stri return } else { //同意操作 currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i]) - fmt.Printf("节点审批人--0->%v------>%v->%v------>%v\n", r.Step, r.NextStep, currentStep, nextStep) + // fmt.Printf("节点审批人--0->%v------>%v->%v------>%v\n", r.Step, r.NextStep, currentStep, nextStep) r.FlowList[i].Status = 2 operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 2, r.FlowList[i].Operator, Suggest) r.FlowList[i].Operator = operatorAry r.Participant = append(r.Participant, nodeUser...) - fmt.Printf("节点审批人--2->%v------>%v\n", r.Step, r.NextStep) + // // fmt.Printf("节点审批人--2->%v------>%v\n", r.Step, r.NextStep) switch r.FlowList[i].Types { case 0: r.Step = currentStep @@ -715,13 +863,13 @@ func (r *RunWorkFlow) FlowStepRun(userKey int64, AgreeToRefuse int, Suggest stri if JudgeRunNode(currentStep, r.FlowList) { r.FlowStepRun(userKey, AgreeToRefuse, Suggest) } - fmt.Printf("节点审批人--3->%v------>%v\n", r.Step, r.NextStep) + // fmt.Printf("节点审批人--3->%v------>%v\n", r.Step, r.NextStep) return case 1: r.Step = currentStep r.NextStep = nextStep FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") - fmt.Printf("节点审批人--4->%v------>%v\n", r.Step, r.NextStep) + // fmt.Printf("节点审批人--4->%v------>%v\n", r.Step, r.NextStep) return case 2: r.Step = currentStep @@ -736,12 +884,12 @@ func (r *RunWorkFlow) FlowStepRun(userKey int64, AgreeToRefuse int, Suggest stri r.FlowStepRun(userKey, AgreeToRefuse, Suggest) } return - fmt.Printf("节点审批人--5->%v------>%v\n", r.Step, r.NextStep) + // fmt.Printf("节点审批人--5->%v------>%v\n", r.Step, r.NextStep) case 3: r.Step = currentStep r.NextStep = nextStep FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") - fmt.Printf("节点审批人--6->%v------>%v\n", r.Step, r.NextStep) + // fmt.Printf("节点审批人--6->%v------>%v\n", r.Step, r.NextStep) return default: } @@ -935,3 +1083,74 @@ func (a *ApiMethod) AfreshRunFlow(c *gin.Context) { taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTask) publicmethod.Result(0, err, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-12-01 09:20:42 +@ 功能: 撤回申请 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) RetractRunFlow(c *gin.Context) { + var requestData publicmethod.PublicId + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(100, err, c) + return + } + where := publicmethod.MapOut[string]() + where["`flow_key`"] = requestData.Id + var runFlowInfo modelAppPlatform.RunFlow + err = runFlowInfo.GetCont(where, "`id`", "`next_executor`", "`current_step`", `next_step`, `participants`) + if err != nil { + publicmethod.Result(107, err, c) + return + } + curTime := time.Now().Unix() + saveFlowInfo := publicmethod.MapOut[string]() + saveTaskInfo := publicmethod.MapOut[string]() + saveFlowInfo["`status`"] = 1 + saveTaskInfo["`status`"] = 1 + saveFlowInfo["`update_time`"] = curTime + saveTaskInfo["`edit_time`"] = curTime + saveFlowInfo["`runKey`"] = publicmethod.GetUUid(6) + saveFlowInfo["`current_step`"] = 1 + saveFlowInfo["`next_step`"] = 0 + saveFlowInfo["`next_executor`"] = "" + if runFlowInfo.NextExecutor != "" && runFlowInfo.Participants != "" { + canYuRen := strings.Split(runFlowInfo.Participants, ",") + nextMan := strings.Split(runFlowInfo.NextExecutor, ",") + var nextCanYuRen []string + for _, v := range canYuRen { + if !publicmethod.IsInTrue[string](v, nextMan) { + nextCanYuRen = append(nextCanYuRen, v) + } + } + if len(nextCanYuRen) > 0 { + saveFlowInfo["`participants`"] = strings.Join(nextCanYuRen, ",") + } + } + var runEditFlowInfo modelAppPlatform.RunFlow + err = runEditFlowInfo.EiteCont(where, saveFlowInfo) + if err != nil { + publicmethod.Result(106, err, c) + return + } + var taskInfo modelAppPlatform.Task + taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTaskInfo) + publicmethod.Result(0, err, c) +} diff --git a/api/version1/taskplatform/taskflow/types.go b/api/version1/taskplatform/taskflow/types.go index c6dabb9..b934f1f 100644 --- a/api/version1/taskplatform/taskflow/types.go +++ b/api/version1/taskplatform/taskflow/types.go @@ -240,6 +240,7 @@ type SendTaskFlowInfo struct { CurrentNodeUser []UserSmallInfo `json:"currentNodeUser" gorm:"-"` //节点操作人 IdStr string `json:"idStr" gorm:"-"` // FormVersionId string `json:"formVersionId" gorm:"-"` + IsRetract bool `json:"isRetract" gorm:"-"` //是否可以撤回 } // 人员剪短信息 @@ -259,3 +260,10 @@ type SubmitAppResults struct { Suggest string `json:"suggest"` //审批意见 FlowList []RunFlow `json:"flowlist"` //执行流程 } + +// 获取自定义表单历史记录 +type FormDataLog struct { + FlowKey int64 + NewData map[string]interface{} + OldData []map[string]interface{} +} diff --git a/api/version1/taskplatform/taskflow/workFlowRun.go b/api/version1/taskplatform/taskflow/workFlowRun.go index c426da8..57a4202 100644 --- a/api/version1/taskplatform/taskflow/workFlowRun.go +++ b/api/version1/taskplatform/taskflow/workFlowRun.go @@ -84,7 +84,7 @@ func (a *ApiMethod) StartRunFlow(c *gin.Context) { runFlow.Uuid = uuid runFlow.RunUid = runUuId if requestData.State == 3 { - runFlow.GainRunNode(startUs, 2, "发起工作流") + runFlow.GainRunNode(startUs, 2, "发起审批") } else { runFlow.GainRunNode(startUs, 1, "") } @@ -470,3 +470,104 @@ func FindOperator(userKey string, runUid int64, AgreeToRefuse int, operator []Op return } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-30 08:01:37 +@ 功能: 已有表单数据,只发布流程 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) OnlyPublishFlow(c *gin.Context) { + var requestData StartFlow + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(100, err, c, "未知进程!不可执行") + return + } + if len(requestData.FlowList) < 1 { + publicmethod.Result(100, err, c, "未知进程!不可执行") + return + } + if requestData.State == 0 { + requestData.State = 3 + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + creetTime := time.Now().Unix() //当前时间 + var runInfo modelAppPlatform.RunFlow + err = runInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}, "`flow_cont`", "`current_step`", "`runKey`", "`participants`") + if err != nil { + publicmethod.Result(107, err, c) + return + } + if len(requestData.FlowList) < 1 && runInfo.FlowCont != "" { + json.Unmarshal([]byte(runInfo.FlowCont), &requestData.FlowList) + } + startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人 + //执行流程 + var runFlow RunWorkFlow + runFlow.Step = 0 //执行第几部 + runFlow.FlowList = requestData.FlowList + runFlow.Participant = append(runFlow.Participant, startUs) + runFlow.TotalSteps = len(requestData.FlowList) //流程总长度 + runFlow.Uuid = runInfo.FlowKey + runFlow.RunUid = runInfo.RunKey + if requestData.State == 3 { + runFlow.GainRunNode(startUs, 2, "发起审批") + } else { + runFlow.GainRunNode(startUs, 1, "") + } + flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流 + saveTask := publicmethod.MapOut[string]() + saveFlow := publicmethod.MapOut[string]() + saveFlow["`flow_cont`"] = flowJsonCont + saveFlow["`current_step`"] = runFlow.Step + saveFlow["`next_step`"] = runFlow.NextStep + //参与人去重 + var parUser []string + for _, v := range runFlow.Participant { + if !publicmethod.IsInTrue[string](v, parUser) { + parUser = append(parUser, v) + } + } + saveFlow["`participants`"] = strings.Join(parUser, ",") + nextRunUser := runFlow.NextRunNodeUser(1) + saveFlow["`next_executor`"] = strings.Join(nextRunUser, ",") + saveFlow["`status`"] = requestData.State + saveTask["status"] = requestData.State + if runFlow.NextStep <= 0 { + saveFlow["`status`"] = 4 + saveTask["status"] = 4 + } + if requestData.State == 2 { + saveTask["status"] = 1 + } + saveFlow["`update_time`"] = creetTime + saveTask["edit_time"] = creetTime + + var saveRunInfo modelAppPlatform.RunFlow + err = saveRunInfo.EiteCont(map[string]interface{}{"`flow_key`": requestData.Id}, saveFlow) + if err != nil { + publicmethod.Result(106, err, c) + return + } + var saveTaskInfo modelAppPlatform.Task + saveTaskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTask) + publicmethod.Result(0, err, c) +} diff --git a/api/version1/taskplatform/taskmanagement/appform.go b/api/version1/taskplatform/taskmanagement/appform.go index 05bbeb8..cd46685 100644 --- a/api/version1/taskplatform/taskmanagement/appform.go +++ b/api/version1/taskplatform/taskmanagement/appform.go @@ -1151,11 +1151,11 @@ func (a *ApiMethod) NewCustomerFormEditData(c *gin.Context) { } if _, ok := mapData["formKey"]; !ok { - publicmethod.Result(1, err, c, "非法表单!1不能提交数据!") + publicmethod.Result(1, err, c, "非法表单!不能提交数据!") return } if _, ok := mapData["formId"]; !ok { - publicmethod.Result(1, err, c, "非法表单!2不能提交数据!") + publicmethod.Result(1, err, c, "非法表单!不能提交数据!") return } var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单 diff --git a/api/version1/taskplatform/taskmanagement/formcontrol.go b/api/version1/taskplatform/taskmanagement/formcontrol.go index f40151b..80ac61c 100644 --- a/api/version1/taskplatform/taskmanagement/formcontrol.go +++ b/api/version1/taskplatform/taskmanagement/formcontrol.go @@ -641,6 +641,9 @@ func MakeFormMapData(uuid, userKey, cureeTime int64, fieldVal map[string]interfa keyAndVal["edit_time"] = cureeTime for k, v := range fieldVal { // fmt.Printf("写入字段:%v->%v\n", k, v) + if k == "id" { + keyAndVal[k] = v + } if v != "" { if val, isOk := subUnit[k]; isOk { // fmt.Printf("写入字段:%v->%v\n", k, val) diff --git a/apirouter/v1/taskrouter/taskrouter.go b/apirouter/v1/taskrouter/taskrouter.go index 0e28bed..fec87a1 100644 --- a/apirouter/v1/taskrouter/taskrouter.go +++ b/apirouter/v1/taskrouter/taskrouter.go @@ -51,5 +51,10 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { taskFlowApi.POST("submitApprovalResults", taskFlowRouter.SubmitApprovalResults) //提交审批结果 taskFlowApi.POST("delRunFlow", taskFlowRouter.DelRunFlow) //删除工作流任务 taskFlowApi.POST("afreshRunFlow", taskFlowRouter.AfreshRunFlow) //重新发起流程 + taskFlowApi.POST("onlyPublishFlow", taskFlowRouter.OnlyPublishFlow) //已有表单数据,只发布流程 + taskFlowApi.POST("retractRunFlow", taskFlowRouter.RetractRunFlow) //撤回申请 + + taskFlowApi.POST("gainEditFormFlowInfo", taskFlowRouter.GainEditFormFlowInfo) //获取要修改的数据 + taskFlowApi.POST("editFormLogData", taskFlowRouter.EditFormLogData) //申请修改数据 } } diff --git a/config/configDatabase/database.go b/config/configDatabase/database.go index 35f7642..5f57432 100644 --- a/config/configDatabase/database.go +++ b/config/configDatabase/database.go @@ -32,6 +32,7 @@ type MysqlSetUp struct { TidbrMaster MasterMysqlSetUp `mapstructure:"tidbrmaster" json:"tidbrmaster" yaml:"tidbrmaster"` //仓储系统数据库 CustomerForm MasterMysqlSetUp `mapstructure:"customerFormDatabase" json:"customerFormDatabase" yaml:"customerFormDatabase"` //自定义表单数据库 FlowLogDatabase MasterMysqlSetUp `mapstructure:"flowLogDatabase" json:"flowLogDatabase" yaml:"flowLogDatabase"` //工作流记录 + ReviseFormData MasterMysqlSetUp `mapstructure:"reviseFormData" json:"reviseFormData" yaml:"reviseFormData"` //工作流记录 } type MasterMysqlSetUp struct { diff --git a/initialization/databaseinit/mysql.go b/initialization/databaseinit/mysql.go index 893625b..811b0fb 100644 --- a/initialization/databaseinit/mysql.go +++ b/initialization/databaseinit/mysql.go @@ -143,15 +143,21 @@ func LoadDatabase() { fmt.Printf("%v:数据库开启成功!私有云服务器\n", sqlConfig.TidbrMaster.Name) } overall.CONSTANT_DB_CustomerForm = sqlConfig.CustomerForm.OpenSql() - if overall.CONSTANT_DB_Tidb == nil { + if overall.CONSTANT_DB_CustomerForm == nil { fmt.Printf("%v:数据库开启失败!服务器\n", sqlConfig.CustomerForm.Name) } else { fmt.Printf("%v:数据库开启成功!服务器\n", sqlConfig.CustomerForm.Name) } overall.CONSTANT_DB_WorkFlowLog = sqlConfig.FlowLogDatabase.OpenSql() - if overall.CONSTANT_DB_Tidb == nil { + if overall.CONSTANT_DB_WorkFlowLog == nil { fmt.Printf("%v:数据库开启失败!服务器\n", sqlConfig.FlowLogDatabase.Name) } else { fmt.Printf("%v:数据库开启成功!服务器\n", sqlConfig.FlowLogDatabase.Name) } + overall.CONSTANT_DB_ReviseFormData = sqlConfig.ReviseFormData.OpenSql() + if overall.CONSTANT_DB_ReviseFormData == nil { + fmt.Printf("%v:数据库开启失败!服务器\n", sqlConfig.ReviseFormData.Name) + } else { + fmt.Printf("%v:数据库开启成功!服务器\n", sqlConfig.ReviseFormData.Name) + } } diff --git a/models/flowlog/work_flow_log.go b/models/flowlog/work_flow_log.go index 8b66400..db68403 100644 --- a/models/flowlog/work_flow_log.go +++ b/models/flowlog/work_flow_log.go @@ -24,7 +24,7 @@ func (WorkFlowLog *WorkFlowLog) TableName() string { // 写入内容 func (cont *WorkFlowLog) WriteCont() (err error) { - err = overall.CONSTANT_DB_WorkFlowLog.Create(&cont).Error + err = overall.CONSTANT_DB_WorkFlowLog.Create(cont).Error return } diff --git a/models/reviseform/edit_form_data_log.go b/models/reviseform/edit_form_data_log.go new file mode 100644 index 0000000..1c0141b --- /dev/null +++ b/models/reviseform/edit_form_data_log.go @@ -0,0 +1,65 @@ +package reviseform + +import ( + "appPlatform/overall" + "strings" +) + +// 字典类型 +type EditFormDataLog struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + SourceForm int64 `json:"source_form" gorm:"column:source_form;type:bigint(20) unsigned;default:0;not null;comment:来源表单"` + FlowKey int64 `json:"flow_key" gorm:"column:flow_key;type:bigint(20) unsigned;default:0;not null;comment:流程标识符"` + RunKey int64 `json:"runKey" gorm:"column:runKey;type:bigint(20) unsigned;default:0;not null;comment:当前执行识别符"` + AddTime int64 `json:"addTime" gorm:"column:addTime;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1、新数据;2:已批准的老数据)"` + DataCont string `json:"dataCont" gorm:"column:dataCont;type:longtext;default:'';comment:数据值"` + Explicate string `json:"explicate" gorm:"column:explicate;type:longtext;default:'';comment:说明"` + SunDataCont string `json:"sunDataCont" gorm:"column:sunDataCont;type:longtext;default:'';comment:子表数值"` + EditTime int64 `json:"editTime" gorm:"column:editTime;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` +} + +func (EditFormDataLog *EditFormDataLog) TableName() string { + return "edit_form_data_log" +} + +// 编辑内容 +func (cont *EditFormDataLog) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_ReviseFormData.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *EditFormDataLog) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_ReviseFormData.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *EditFormDataLog) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_ReviseFormData.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *EditFormDataLog) ContMap(whereMap interface{}, field ...string) (countAry []EditFormDataLog, err error) { + gormDb := overall.CONSTANT_DB_ReviseFormData.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *EditFormDataLog) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_ReviseFormData.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/appConfig.go b/overall/appConfig.go index 80e5441..c9338e1 100644 --- a/overall/appConfig.go +++ b/overall/appConfig.go @@ -42,8 +42,9 @@ var ( CONSTANT_DB_System_Permission *gorm.DB //系统权限配置数据库 CONSTANT_DB_Storage *gorm.DB //仓储系统数据库 - CONSTANT_DB_CustomerForm *gorm.DB //自定义表单数据库 - CONSTANT_DB_WorkFlowLog *gorm.DB //工作流历史记录 + CONSTANT_DB_CustomerForm *gorm.DB //自定义表单数据库 + CONSTANT_DB_WorkFlowLog *gorm.DB //工作流历史记录 + CONSTANT_DB_ReviseFormData *gorm.DB //工作流历史记录 CONSTANT_DB_Server *gorm.DB //线上数据库 CONSTANT_DB_Tidb *gorm.DB //私有云数据库