package taskmanagement import ( "appPlatform/api/version1/customerform" "appPlatform/models/customerForm" "appPlatform/models/modelAppPlatform" "appPlatform/models/modelshr" "appPlatform/models/reviseform" "appPlatform/overall" "appPlatform/overall/publicmethod" "encoding/json" "fmt" "sort" "strconv" "strings" "time" "github.com/gin-gonic/gin" ) /* * @ 作者: 秦东 @ 时间: 2024-06-18 09:11:38 @ 功能: 执行工作流 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) RunTaskFlow(c *gin.Context) { var requestData SubmitAppResults err := c.ShouldBindJSON(&requestData) if err != nil { publicmethod.Result(100, err, c) return } if requestData.Id == "" { publicmethod.Result(100, err, c) return } if requestData.AgreeOrRefuse == 0 { requestData.AgreeOrRefuse = 2 } where := publicmethod.MapOut[string]() where["`id`"] = requestData.Id var flowInfo customerForm.RunWorkflow err = flowInfo.GetCont(where) if err != nil { publicmethod.Result(107, err, c) return } if flowInfo.NextStep == 0 || flowInfo.Status != 3 { publicmethod.Result(1, err, c, "此流程再不可审批状态!您的提交无效") return } if len(requestData.FlowList) < 1 { if flowInfo.FlowCont != "" { err = json.Unmarshal([]byte(flowInfo.FlowCont), &requestData.FlowList) if err != nil { publicmethod.Result(1, err, c, "流程异常!您的提交无效") return } } else { publicmethod.Result(1, err, c, "流程异常!您的提交无效") return } } context, _ := c.Get(overall.MyContJwt) var userCont modelshr.ManCont userCont.GetLoginCont(context) //当前操作人 var taskInfo customerForm.TaskRecord taskInfo.GetCont(map[string]interface{}{"`runFlowId`": requestData.Id}, "`title`", "`creater`", `masters_key`, "`version_id`", "`flow_key`", "`flow_run_sing`", "`tableKey`", "`appKey`", "`runFlowId`") //执行流程 var runFlow RunWorkFlow runFlow.Step = flowInfo.NextStep runFlow.TotalSteps = len(requestData.FlowList) //流程总长度 runFlow.Uuid = flowInfo.FlowKey runFlow.RunUid = flowInfo.RunKey runFlow.Participant = strings.Split(flowInfo.Participants, ",") runFlow.FlowList = requestData.FlowList runFlow.SendWecharMsg.AppKey = taskInfo.AppKey runFlow.SendWecharMsg.Creater = taskInfo.Creater runFlow.SendWecharMsg.MastersKey = taskInfo.MastersKey runFlow.SendWecharMsg.TableKey = taskInfo.TableKey runFlow.SendWecharMsg.RunFlowId = taskInfo.RunFlowId runFlow.RunNodeHandle(userCont.Key, requestData.AgreeOrRefuse, requestData.Suggest) if runFlow.IsRun { publicmethod.Result(1, err, c, runFlow.Msg) return } flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流 saveFlowInfo := publicmethod.MapOut[string]() saveTaskInfo := publicmethod.MapOut[string]() saveFlowInfo["`flow_cont`"] = flowJsonCont saveFlowInfo["`current_step`"] = runFlow.Step saveFlowInfo["`next_step`"] = runFlow.NextStep if flowInfo.Participants != "" { oldUser := strings.Split(flowInfo.Participants, ",") runFlow.Participant = append(runFlow.Participant, oldUser...) } //参与人去重 var parUser []string for _, v := range runFlow.Participant { if !publicmethod.IsInTrue[string](v, parUser) { parUser = append(parUser, v) } } saveFlowInfo["`participants`"] = strings.Join(parUser, ",") var tsakInfos customerForm.TaskRecord tsakInfos.GetCont(map[string]interface{}{"`runFlowId`": requestData.Id}, "`participant`") if len(parUser) > 0 { oldTaskUser := strings.Split(tsakInfos.Participant, ",") for _, v := range parUser { if !publicmethod.IsInTrue[string](v, oldTaskUser) { oldTaskUser = append(oldTaskUser, v) } } saveTaskInfo["`participant`"] = strings.Join(parUser, ",") } //抄送人 if flowInfo.MakeCopy != "" { oldCopyUser := strings.Split(flowInfo.MakeCopy, ",") runFlow.MakeCopy = append(runFlow.MakeCopy, oldCopyUser...) } var copyMan []string for _, v := range runFlow.MakeCopy { if !publicmethod.IsInTrue[string](v, copyMan) { copyMan = append(copyMan, v) } } saveFlowInfo["`makeCopy`"] = strings.Join(copyMan, ",") //下一步执行人 nextRunUser := runFlow.NextRunNodeUser(requestData.AgreeOrRefuse) saveFlowInfo["`next_executor`"] = strings.Join(nextRunUser, ",") saveFlowInfo["`update_time`"] = time.Now().Unix() if requestData.AgreeOrRefuse == 1 { if runFlow.NextStep != 0 { saveFlowInfo["`status`"] = 3 saveTaskInfo["`status`"] = 3 } else { saveFlowInfo["`status`"] = 4 saveTaskInfo["`status`"] = 4 JudgeEditFlow(flowInfo.FlowKey) } } else { saveFlowInfo["`runKey`"] = publicmethod.GetUUid(6) if runFlow.Step != 1 { saveFlowInfo["`status`"] = 3 } else { saveFlowInfo["`status`"] = 2 saveTaskInfo["`status`"] = 1 } } saveTaskInfo["`edit_time`"] = time.Now().Unix() gordb := overall.CONSTANT_DB_CustomerForm.Begin() flowErr := gordb.Model(&customerForm.RunWorkflow{}).Where(where).Updates(saveFlowInfo).Error taskErr := gordb.Model(&customerForm.TaskRecord{}).Where("`runFlowId` = ?", requestData.Id).Updates(saveTaskInfo).Error if flowErr != nil || taskErr != nil { gordb.Rollback() publicmethod.Result(100, err, c, "数据提交失败!请重新提交!") return } gordb.Commit() publicmethod.Result(0, err, c) } /* * @ 作者: 秦东 @ 时间: 2024-06-18 09:18:27 @ 功能: 执行节点处理 @ 参数 #userKey 当前处理人 #AgreeToRefuse 1:同意,2:驳回 #Suggest 审批意见 @ 返回值 # @ 方法原型 # */ func (r *RunWorkFlow) RunNodeHandle(userKey int64, AgreeToRefuse int, Suggest string) { //判断流程是否存在 if len(r.FlowList) < 1 { return } userKeyStr := strconv.FormatInt(userKey, 10) //当前操作人识别符转字符类型 fmt.Printf("执行节点处理--->%v------>%v\n", r.Step, r.NextStep) //遍历流程判断当前要执行的步骤 for i := 0; i < r.TotalSteps; i++ { if r.FlowList[i].Step == r.Step { //获取当前操作节点 //Step1:判断当前节点是不是抄送节点 if r.FlowList[i].Types == 2 { currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i]) for _, op := range r.FlowList[i].Operator { r.MakeCopy = append(r.MakeCopy, op.Id) userkIntId, _ := strconv.ParseInt(op.Id, 10, 64) title := fmt.Sprintf("向%v发送抄送数据", op.Name) FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "") // fmt.Printf("抄送人---->%v---->%v\n", userkIntId, title) } r.SendWecharMsgTopct(userKeyStr, r.Step) r.Step = currentStep r.NextStep = nextStep if nextStep > 0 { // if JudgeRunNode(nextStep, r.FlowList) { if r.ToNextNodeRunOrClose(userKeyStr, nextStep) { r.Step = nextStep r.RunNodeHandle(userKey, AgreeToRefuse, Suggest) } } } else { r.IsRun, r.Msg = JudgeOperUser(userKey, r.RunUid, r.FlowList[i].Operator) //判断操作人是有操作权限或是否已经操作过 if r.IsRun { return } else { if AgreeToRefuse != 1 { //驳回操作 r.FlowList[i].Status = 3 operatorAry, nodeUser := FindOperator(userKeyStr, r.RunUid, 3, r.FlowList[i].Operator, Suggest) r.FlowList[i].Operator = operatorAry r.Participant = append(r.Participant, nodeUser...) r.RejectNode(r.FlowList[i].GoBackNode) r.SendWecharMsgTextCard(r.Step, "驳回", Suggest) return } else { currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i]) // fmt.Printf("同意操作---->%v---->%v---->%v\n", currentStep, nextStep, r.FlowList[i].Types) 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...) switch r.FlowList[i].Types { case 0: if r.Step != currentStep { r.SendWecharMsgTopct(userKeyStr, currentStep) } r.Step = currentStep r.NextStep = nextStep FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, "发起流程", "") // if JudgeRunNode(nextStep, r.FlowList) { if r.ToNextNodeRunOrClose(userKeyStr, nextStep) { r.Step = nextStep r.FlowStepRun(userKey, AgreeToRefuse, Suggest) } return case 1: if r.Step != currentStep { r.SendWecharMsgTopct(userKeyStr, currentStep) } r.Step = currentStep r.NextStep = nextStep // fmt.Printf("判断是否继续执行---->%v\n", JudgeRunNode(nextStep, r.FlowList)) FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") if r.ToNextNodeRunOrClose(userKeyStr, nextStep) { // if JudgeRunNode(nextStep, r.FlowList) { r.Step = nextStep r.RunNodeHandle(userKey, AgreeToRefuse, Suggest) } return case 2: if currentStep+1 < r.TotalSteps { r.Step = currentStep + 1 if nextStep+1 <= r.TotalSteps { r.NextStep = nextStep + 1 } else { r.NextStep = 0 } } else { r.Step = r.TotalSteps r.NextStep = 0 } for _, op := range r.FlowList[i].Operator { r.MakeCopy = append(r.MakeCopy, op.Id) userkIntId, _ := strconv.ParseInt(op.Id, 10, 64) title := fmt.Sprintf("向%v发送抄送数据", op.Name) FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "") } r.SendWecharMsgTopct(userKeyStr, r.Step) return case 3: if r.Step != currentStep { r.SendWecharMsgTopct(userKeyStr, currentStep) } r.Step = currentStep r.NextStep = nextStep FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") if r.ToNextNodeRunOrClose(userKeyStr, nextStep) { // if JudgeRunNode(nextStep, r.FlowList) { r.Step = nextStep r.RunNodeHandle(userKey, AgreeToRefuse, Suggest) } return default: } } } } } } } /* * @ 作者: 秦东 @ 时间: 2024-08-06 14:23:36 @ 功能: 修改记录(新版) @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) GainEditDataNewLog(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 } var tableEditLog []reviseform.EditFormDataLog err = overall.CONSTANT_DB_ReviseFormData.Model(&reviseform.EditFormDataLog{}).Where("`masters_key` = ?", requestData.Id).Order("`id` DESC").Find(&tableEditLog).Error if err != nil { publicmethod.Result(107, err, c) return } sendData := publicmethod.MapOut[string]() var taskInfo customerForm.TaskRecord taskInfo.GetCont(map[string]interface{}{"`masters_key": requestData.Id}) //展开表单 var formJsonCont customerform.CustomerFormMaster json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont) var tableUnitList customerform.TableFormUnit tableUnitList.AnalysisTableFormUnitAttribute("", formJsonCont.List) sendData["tableUnitList"] = formJsonCont.List // publicmethod.Result(107, tableUnitList.MasterInfo, c) // return var sendList []EditTaskLog for _, v := range tableEditLog { // fmt.Println("====================================") var sendInfo EditTaskLog if v.DataCont != "" { mastAry, creater, timeStr, _ := AnalysisMsaterNewLog(v.DataCont, tableUnitList.MasterInfo) // if err != nil { sendInfo.Creater = creater.Name sendInfo.Time = timeStr sendInfo.Masterdata = append(sendInfo.Masterdata, mastAry...) // } } if v.SunDataCont != "" { sendInfo.SunData, _ = AnalysisSonNewLog(v.SunDataCont, tableUnitList.SunFormInfo) } sendList = append(sendList, sendInfo) // fmt.Println("====================================") } publicmethod.Result(0, sendList, c) } /* * @ 作者: 秦东 @ 时间: 2024-08-06 16:56:55 @ 功能: 解析子表新方法记录 @ 参数 # @ 返回值 # @ 方法原型 # */ func AnalysisSonNewLog(sonDataStr string, sonNameKey []map[string][]customerform.UnitAttribute) (SunData map[string][][]TaskLogInfo, err error) { var sonMap map[string][]map[string]interface{} err = json.Unmarshal([]byte(sonDataStr), &sonMap) sonTableData := make(map[string][][]TaskLogInfo) for _, v := range sonNameKey { for si, sv := range v { if sonCont, ok := sonMap[si]; ok { // fmt.Printf("sonMap-5-->%T---------->%v---------->%v---------->%v\n", sonCont, si, sonCont, sv) sonTableData[si] = sunContHandel(sonCont, sv) } } } SunData = sonTableData return } /* * @ 作者: 秦东 @ 时间: 2024-08-07 08:25:53 @ 功能: 处理子表单数据 @ 参数 # @ 返回值 # @ 方法原型 # */ func sunContHandel(sonMapAry []map[string]interface{}, nameKey []customerform.UnitAttribute) (infoList [][]TaskLogInfo) { var taskInfoList [][]TaskLogInfo for _, v := range sonMapAry { // fmt.Printf("sonMap-5-->%T---------->%v\n", v, v) var logAry []TaskLogInfo for i, val := range v { for _, uv := range nameKey { if uv.Key == i { var taskInfo TaskLogInfo taskInfo.Label = uv.Name taskInfo.Field = i taskInfo.Auxiliary = uv.Auxiliary // taskInfo.Value = vv taskInfo.Types = uv.Class taskInfo.Sort = uv.Sort switch i { case "creater": var createrInfo modelshr.ManCont createrInfo.GetCont(map[string]interface{}{"`key`": val}, "`name`", "`number`") taskInfo.Value = fmt.Sprintf("%v(%v)", createrInfo.Name, createrInfo.Number) case "edit_time": timeInt, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeInt, 27) case "creater_time": timeCreaInt, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeCreaInt, 27) case "states": statesVal, _ := publicmethod.StringToInt64(val) switch statesVal { case 3: taskInfo.Value = "删除" case 2: taskInfo.Value = "禁用" default: taskInfo.Value = "启用" } default: switch uv.Class { case "digitpage": digitpageInt := publicmethod.TypeToInterface(val) if len(digitpageInt) > 16 { taskInfo.Value = digitpageInt } else { taskInfo.Value, _ = publicmethod.StringToInt64(val) } case "radio": for _, v := range uv.Options { radioOptVal := publicmethod.TypeToInterface(val) if v.Value == radioOptVal { taskInfo.Value = v.Label } } case "checkbox": var valAry []interface{} checkboxVal := publicmethod.TypeToInterface(val) err := json.Unmarshal([]byte(checkboxVal), &valAry) if err == nil { var pickStr []string for _, v := range valAry { pickStr = append(pickStr, publicmethod.TypeToInterface(v)) } var valList []string for _, v := range uv.Options { if publicmethod.IsInTrue[string](v.Value, pickStr) { valList = append(valList, v.Label) } } taskInfo.Value = strings.Join(valList, ",") } case "select": if auxVal, isOk := uv.Auxiliary.(bool); isOk { if auxVal { var valAry []interface{} checkboxVal := publicmethod.TypeToInterface(val) err := json.Unmarshal([]byte(checkboxVal), &valAry) if err == nil { var pickStr []string for _, v := range valAry { pickStr = append(pickStr, publicmethod.TypeToInterface(v)) } var valList []string for _, v := range uv.Options { if publicmethod.IsInTrue[string](v.Value, pickStr) { valList = append(valList, v.Label) } } taskInfo.Value = strings.Join(valList, ",") } } else { for _, v := range uv.Options { selectVal := publicmethod.TypeToInterface(val) if v.Value == selectVal { taskInfo.Value = v.Label } } } } else { for _, v := range uv.Options { selectVal := publicmethod.TypeToInterface(val) if v.Value == selectVal { taskInfo.Value = v.Label } } } case "datePicker": switch uv.Auxiliary { case "year": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 16) case "month": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 15) case "datetime": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 11) case "week": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 41) case "datetimerange": timeVal, _ := publicmethod.StringToInt64(val) beginTime := publicmethod.UnixTimeToDay(timeVal/1000, 11) taskInfo.Value = beginTime endFile := fmt.Sprintf("%v_end", i) if valTime, isTimeOk := v[endFile]; isTimeOk { endTimeInt, _ := publicmethod.StringToInt64(valTime) endTimeStr := publicmethod.UnixTimeToDay(endTimeInt/1000, 11) taskInfo.Value = fmt.Sprintf("%v 至 %v", beginTime, endTimeStr) } case "daterange": timeVal, _ := publicmethod.StringToInt64(val) beginTime := publicmethod.UnixTimeToDay(timeVal/1000, 14) taskInfo.Value = beginTime endFile := fmt.Sprintf("%v_end", i) if valTime, isTimeOk := v[endFile]; isTimeOk { endTimeInt, _ := publicmethod.StringToInt64(valTime) endTimeStr := publicmethod.UnixTimeToDay(endTimeInt/1000, 14) taskInfo.Value = fmt.Sprintf("%v 至 %v", beginTime, endTimeStr) } case "monthrange": timeVal, _ := publicmethod.StringToInt64(val) beginTime := publicmethod.UnixTimeToDay(timeVal/1000, 15) taskInfo.Value = beginTime endFile := fmt.Sprintf("%v_end", i) if valTime, isTimeOk := v[endFile]; isTimeOk { endTimeInt, _ := publicmethod.StringToInt64(valTime) endTimeStr := publicmethod.UnixTimeToDay(endTimeInt/1000, 15) taskInfo.Value = fmt.Sprintf("%v 至 %v", beginTime, endTimeStr) } default: timeVal, _ := publicmethod.StringToInt64(val) beginTime := publicmethod.UnixTimeToDay(timeVal/1000, 14) taskInfo.Value = beginTime } case "timePicker": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 5) case "expand-user": // valStr := publicmethod.TypeToInterface(val) // fmt.Printf("用户类型:%T--->%v=====%v\n", val, val, valStr) // var peopleAry []string // json.Unmarshal([]byte(valStr), &peopleAry) // taskInfo.Value = strings.Join(peopleAry, ",") taskInfo.Value = val case "orgCentent": var orgCont modelshr.AdministrativeOrganization orgCont.GetCont(map[string]interface{}{"`id`": val}, "`name`") taskInfo.Value = orgCont.Name case "deptOrg": var orgCont modelshr.AdministrativeOrganization orgCont.GetCont(map[string]interface{}{"`id`": val}, "`name`") taskInfo.Value = orgCont.Name case "owner": var manInfo modelshr.ManCont manInfo.GetCont(map[string]interface{}{"`key`": val}, "`name`", "`number`") taskInfo.Value = fmt.Sprintf("%v(%v)", manInfo.Name, manInfo.Number) case "lowcodeImage": if val == nil { taskInfo.Value = uv.FilePath } else { taskInfo.Value = val } case "lowcodeCarsusel": if val == nil { taskInfo.Value = uv.CarsuselConfigArr } else { taskInfo.Value = val } case "videoUpAndPlay": if val == nil { taskInfo.Value = uv.VideoList } else { taskInfo.Value = val } default: taskInfo.Value = val } } logAry = append(logAry, taskInfo) } } } sort.Slice(logAry, func(i, j int) bool { return logAry[i].Sort < logAry[j].Sort }) taskInfoList = append(taskInfoList, logAry) } infoList = taskInfoList return } /* * @ 作者: 秦东 @ 时间: 2024-08-06 16:09:14 @ 功能: 修改记录主表数据解析 @ 参数 # @ 返回值 # @ 方法原型 # */ func AnalysisMsaterNewLog(dataStr string, nameKey []customerform.UnitAttribute) (taskInfoAry []TaskLogInfo, createrInfo modelshr.ManCont, createrTime string, err error) { if dataStr == "" || len(nameKey) < 1 { return } var dataInfo map[string]interface{} err = json.Unmarshal([]byte(dataStr), &dataInfo) if err != nil { return } for i, v := range dataInfo { // fmt.Printf("%v:%v\n", i, v) switch i { case "creater": createrInfo.GetCont(map[string]interface{}{"`key`": v}) case "edit_time": timeInt, _ := publicmethod.StringToInt64(v) createrTime = publicmethod.UnixTimeToDay(timeInt, 27) default: taskInfoAry = append(taskInfoAry, HistoryValueHand(i, v, nameKey, dataInfo)...) // for _, uv := range nameKey { // if i == uv.Key { // var taskInfo TaskLogInfo // taskInfo.Label = uv.Name // taskInfo.Field = i // taskInfo.Auxiliary = uv.Auxiliary // taskInfo.Types = uv.Class // taskInfo.Sort = uv.Sort // taskInfo.Value = v // taskInfoAry = append(taskInfoAry, taskInfo) // } // } } } sort.Slice(taskInfoAry, func(i, j int) bool { return taskInfoAry[i].Sort < taskInfoAry[j].Sort }) return } /* * @ 作者: 秦东 @ 时间: 2024-08-07 09:41:53 @ 功能: 历史记录值处理 */ func HistoryValueHand(field string, val interface{}, nameKey []customerform.UnitAttribute, dataInfo map[string]interface{}) (taskInfoAry []TaskLogInfo) { for _, uv := range nameKey { if field == uv.Key { var taskInfo TaskLogInfo taskInfo.Label = uv.Name taskInfo.Field = field taskInfo.Auxiliary = uv.Auxiliary taskInfo.Types = uv.Class taskInfo.Sort = uv.Sort fmt.Printf("key: %v, type: %T val:%v Class:%v\n", field, val, val, uv.Class) switch field { case "creater": var createrInfo modelshr.ManCont createrInfo.GetCont(map[string]interface{}{"`key`": val}, "`name`", "`number`") taskInfo.Value = fmt.Sprintf("%v(%v)", createrInfo.Name, createrInfo.Number) case "edit_time": timeInt, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeInt, 27) case "creater_time": timeCreaInt, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeCreaInt, 27) case "states": statesVal, _ := publicmethod.StringToInt64(val) switch statesVal { case 3: taskInfo.Value = "删除" case 2: taskInfo.Value = "禁用" default: taskInfo.Value = "启用" } default: switch uv.Class { case "digitpage": digitpageInt := publicmethod.TypeToInterface(val) if len(digitpageInt) > 16 { taskInfo.Value = digitpageInt } else { taskInfo.Value, _ = publicmethod.StringToInt64(val) } case "radio": for _, v := range uv.Options { radioOptVal := publicmethod.TypeToInterface(val) if v.Value == radioOptVal { taskInfo.Value = v.Label } } case "checkbox": var valAry []interface{} checkboxVal := publicmethod.TypeToInterface(val) err := json.Unmarshal([]byte(checkboxVal), &valAry) if err == nil { var pickStr []string for _, v := range valAry { pickStr = append(pickStr, publicmethod.TypeToInterface(v)) } var valList []string for _, v := range uv.Options { if publicmethod.IsInTrue[string](v.Value, pickStr) { valList = append(valList, v.Label) } } taskInfo.Value = strings.Join(valList, ",") } case "select": if auxVal, isOk := uv.Auxiliary.(bool); isOk { if auxVal { var valAry []interface{} checkboxVal := publicmethod.TypeToInterface(val) err := json.Unmarshal([]byte(checkboxVal), &valAry) if err == nil { var pickStr []string for _, v := range valAry { pickStr = append(pickStr, publicmethod.TypeToInterface(v)) } var valList []string for _, v := range uv.Options { if publicmethod.IsInTrue[string](v.Value, pickStr) { valList = append(valList, v.Label) } } taskInfo.Value = strings.Join(valList, ",") } } else { for _, v := range uv.Options { selectVal := publicmethod.TypeToInterface(val) if v.Value == selectVal { taskInfo.Value = v.Label } } } } else { for _, v := range uv.Options { selectVal := publicmethod.TypeToInterface(val) if v.Value == selectVal { taskInfo.Value = v.Label } } } case "datePicker": switch uv.Auxiliary { case "year": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 16) case "month": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 15) case "datetime": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 11) case "week": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 41) case "datetimerange": timeVal, _ := publicmethod.StringToInt64(val) beginTime := publicmethod.UnixTimeToDay(timeVal/1000, 11) taskInfo.Value = beginTime endFile := fmt.Sprintf("%v_end", field) if valTime, isTimeOk := dataInfo[endFile]; isTimeOk { endTimeInt, _ := publicmethod.StringToInt64(valTime) endTimeStr := publicmethod.UnixTimeToDay(endTimeInt/1000, 11) taskInfo.Value = fmt.Sprintf("%v 至 %v", beginTime, endTimeStr) } case "daterange": timeVal, _ := publicmethod.StringToInt64(val) beginTime := publicmethod.UnixTimeToDay(timeVal/1000, 14) taskInfo.Value = beginTime endFile := fmt.Sprintf("%v_end", field) if valTime, isTimeOk := dataInfo[endFile]; isTimeOk { endTimeInt, _ := publicmethod.StringToInt64(valTime) endTimeStr := publicmethod.UnixTimeToDay(endTimeInt/1000, 14) taskInfo.Value = fmt.Sprintf("%v 至 %v", beginTime, endTimeStr) } case "monthrange": timeVal, _ := publicmethod.StringToInt64(val) beginTime := publicmethod.UnixTimeToDay(timeVal/1000, 15) taskInfo.Value = beginTime endFile := fmt.Sprintf("%v_end", field) if valTime, isTimeOk := dataInfo[endFile]; isTimeOk { endTimeInt, _ := publicmethod.StringToInt64(valTime) endTimeStr := publicmethod.UnixTimeToDay(endTimeInt/1000, 15) taskInfo.Value = fmt.Sprintf("%v 至 %v", beginTime, endTimeStr) } default: timeVal, _ := publicmethod.StringToInt64(val) beginTime := publicmethod.UnixTimeToDay(timeVal/1000, 14) taskInfo.Value = beginTime // endKey := fmt.Sprintf("%v_end", field) // if v[endKey] != nil { // endTimeVal, _ := publicmethod.StringToInt64(v[endKey]) // sendInfo[mi] = fmt.Sprintf("%v - %v", beginTime, publicmethod.UnixTimeToDay(int64(endTimeVal)/1000, 14)) // } } case "timePicker": timeVal, _ := publicmethod.StringToInt64(val) taskInfo.Value = publicmethod.UnixTimeToDay(timeVal/1000, 5) fmt.Printf("格式---》%v---》%v\n", timeVal, taskInfo.Value) case "expand-user": valStr := publicmethod.TypeToInterface(val) var peopleAry []string json.Unmarshal([]byte(valStr), &peopleAry) taskInfo.Value = strings.Join(peopleAry, ",") case "orgCentent": var orgCont modelshr.AdministrativeOrganization orgCont.GetCont(map[string]interface{}{"`id`": val}, "`name`") taskInfo.Value = orgCont.Name case "deptOrg": var orgCont modelshr.AdministrativeOrganization orgCont.GetCont(map[string]interface{}{"`id`": val}, "`name`") taskInfo.Value = orgCont.Name case "owner": var manInfo modelshr.ManCont manInfo.GetCont(map[string]interface{}{"`key`": val}, "`name`", "`number`") taskInfo.Value = fmt.Sprintf("%v(%v)", manInfo.Name, manInfo.Number) case "lowcodeImage": if val == nil { taskInfo.Value = uv.FilePath } else { taskInfo.Value = val } case "lowcodeCarsusel": if val == nil { taskInfo.Value = uv.CarsuselConfigArr } else { taskInfo.Value = val } case "videoUpAndPlay": if val == nil { taskInfo.Value = uv.VideoList } else { taskInfo.Value = val } // fmt.Printf("videoUpAndPlay--->key: %v, type: %T val:%v\n", field, val, val) default: taskInfo.Value = val } } taskInfoAry = append(taskInfoAry, taskInfo) } } return } /* * @ 作者: 秦东 @ 时间: 2024-12-19 16:13:29 @ 功能: 获取web表单数据 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) GainWebTaskFlowInfo(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 } //获取任务 var taskInfo TaskInfoStruct err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": requestData.Id}) if err != nil { publicmethod.Result(107, err, c) return } taskInfo.MastersKeyStr = strconv.FormatInt(taskInfo.MastersKey, 10) taskInfo.FlowKeyStr = strconv.FormatInt(taskInfo.FlowKey, 10) taskInfo.TableKeyStr = strconv.FormatInt(taskInfo.TableKey, 10) taskInfo.AppKeyStr = strconv.FormatInt(taskInfo.AppKey, 10) taskInfo.RunFlowIdStr = strconv.FormatInt(taskInfo.Id, 10) taskInfo.RunFlowId = taskInfo.Id taskInfo.FormVersionId = strconv.FormatInt(taskInfo.VersionId, 10) taskInfo.IdStr = strconv.FormatInt(taskInfo.Id, 10) taskInfo.RunFlowIdStr = strconv.FormatInt(taskInfo.Id, 10) taskInfo.FlowKeys = strconv.FormatInt(taskInfo.FlowKey, 10) taskInfo.CreaterInfo = GainSmaillUserInfo[int64](taskInfo.Creater) taskInfo.MastersKeyStr = strconv.FormatInt(taskInfo.MastersKey, 10) taskInfo.AppKeyStr = strconv.FormatInt(taskInfo.AppKey, 10) taskInfo.TableKeyStr = strconv.FormatInt(taskInfo.TableKey, 10) if taskInfo.NextExecutor != "" { nextAry := strings.Split(taskInfo.NextExecutor, ",") for _, v := range nextAry { taskInfo.CurrentNodeUser = append(taskInfo.CurrentNodeUser, GainSmaillUserInfo[string](v)) } } taskInfo.StartDate = publicmethod.UnixTimeToDay(taskInfo.StartTime, 27) if taskInfo.NextStep != 0 { nodeCont, idTrue := GainCurreNode(taskInfo.FlowCont, taskInfo.CurrentStep, taskInfo.NextStep, taskInfo.Status) if idTrue { taskInfo.CurrentNodeName = nodeCont.NodeName } } if taskInfo.MastesForm == "" || taskInfo.MastesFormJson == "" { taskInfo.MastesForm, taskInfo.MastesFormJson = GainTaskFormData(taskInfo.FlowKey) } if taskInfo.Status == 3 && taskInfo.NextStep != 0 { if taskInfo.CurrentStep == 1 { taskInfo.IsRetract = true } } //获取表单数据 var formVersionInfo CallBackFormStruct err = formVersionInfo.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}) if err != nil { publicmethod.Result(107, err, c) return } formVersionInfo.FlowkeyStr = strconv.FormatInt(formVersionInfo.Flowkey, 10) formVersionInfo.CreaterStr = strconv.FormatInt(formVersionInfo.Creater, 10) formVersionInfo.MastesForm = taskInfo.MastesForm formVersionInfo.MastesFormJson = taskInfo.MastesFormJson //展开表单 var formJsonCont customerform.CustomerFormMaster json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont) var tableUnitList customerform.TableFormUnit tableUnitList.AnalysisTableFormUnitAttribute("", formJsonCont.List) sendData := publicmethod.MapOut[string]() sendData["taskInfo"] = taskInfo sendData["structure"] = formVersionInfo sendData["tableData"] = GainOnlyOneCustomerFormLog(requestData.Id, formVersionInfo.TableKey, formVersionInfo.TableStructure, tableUnitList) publicmethod.Result(0, sendData, c) } /* * @ 作者: 秦东 @ 时间: 2023-11-23 16:17:17 @ 功能: 获取简短人员信息 @ 参数 #userKey 操作人 @ 返回值 # @ 方法原型 # */ func GainSmaillUserInfo[T publicmethod.GenericityVariable](userKey T) (createrInfo UserSmallInfo) { var userInfo modelshr.ManCont err := userInfo.GetCont(map[string]interface{}{"`key`": userKey}, "`id`", "`key`", "`name`", "`number`", "`icon`", "`icon_photo`", "`wechat`", "`work_wechat`") if err != nil { return } createrInfo.Id = userInfo.Id createrInfo.Key = strconv.FormatInt(userInfo.Key, 10) createrInfo.Name = userInfo.Name createrInfo.Number = userInfo.Number createrInfo.Icon = userInfo.Icon if userInfo.IconPhpto != "" { createrInfo.Icon = userInfo.IconPhpto } createrInfo.WeChat = userInfo.Wechat if userInfo.WorkWechat != "" { createrInfo.WeChat = userInfo.WorkWechat } return } /* * @ 作者: 秦东 @ 时间: 2023-11-23 16:34:22 @ 功能: 获取当前节点 @ 参数 # @ 返回值 # @ 方法原型 # */ func GainCurreNode(flowStr string, step, nextStep, state int) (nodeInfo RunFlow, isOk bool) { if flowStr == "" { return } var flowAry []RunFlow err := json.Unmarshal([]byte(flowStr), &flowAry) if err != nil { return } if nextStep == 0 { step = len(flowAry) } else { switch state { case 1: step = 0 case 2: if step != 1 { step = step + 1 } case 3: step = step + 1 case 4: step = len(flowAry) default: step = step + 1 } } for _, v := range flowAry { if v.Step == step { nodeInfo = v isOk = true return } } return } /* * @ 作者: 秦东 @ 时间: 2023-11-24 11:36:32 @ 功能: 获取表单数据 @ 参数 # @ 返回值 # @ 方法原型 # */ func GainTaskFormData(taskId int64) (mastesform, mastesformjson string) { if taskId > 0 { var taskInfo modelAppPlatform.Task err := taskInfo.GetCont(map[string]interface{}{"`masters_key`": taskId}, "`version_id`") if err != nil { return } var formVerInfo modelAppPlatform.CustomerFormVersion err = formVerInfo.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}, "`mastesform`", "`mastesformjson`") if err != nil { return } mastesform = formVerInfo.MastesForm mastesformjson = formVerInfo.MastesFormJson taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`mastesform`": formVerInfo.MastesForm, "`mastesformjson`": formVerInfo.MastesFormJson}) } return }