应用集成平台服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

818 lines
27 KiB

1 year ago
package taskflow
import (
"appPlatform/api/version1/customerform"
"appPlatform/api/version1/taskplatform/taskmanagement"
"appPlatform/models/customerForm"
"appPlatform/models/modelAppPlatform"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2024-06-06 16:37:39
@ 功能: 获取App任务(任务流版本)
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainAppTaskList(c *gin.Context) {
var requestData AppTaskSearch
c.ShouldBindJSON(&requestData)
if requestData.Id == "" {
publicmethod.Result(100, requestData, c)
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 10
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&customerForm.RunFlowTask{}).Select("`id`").Where("appKey = ?", requestData.Id)
switch requestData.Class {
case 2: //待办事宜
gormDb = gormDb.Where("`status` = 3 AND FIND_IN_SET(?,`next_executor`)", userCont.Key)
case 3: //已办事宜
gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`participants`) AND NOT FIND_IN_SET(?,`next_executor`) AND `creater` <> ?", userCont.Key, userCont.Key, userCont.Key)
case 4: //草稿箱
gormDb = gormDb.Where("`status` = 1 AND `creater` = ?", userCont.Key)
case 5: //抄送我的
gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`makeCopy`)", userCont.Key)
default: //我的请求
gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", userCont.Key)
}
if requestData.Title != "" {
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%")
}
if requestData.State != 0 {
gormDb = gormDb.Where("`status` = ?", requestData.State)
}
//获取总数
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
var idAry []int64
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
err := gormDb.Order("`update_time` desc").Find(&idAry).Error
var userList []SendAppTaskFlowInfo
if err != nil || len(idAry) < 1 {
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c)
return
}
overall.CONSTANT_DB_CustomerForm.Model(&customerForm.RunFlowTask{}).Where("`id` IN ?", idAry).Order("`start_time` desc").Find(&userList)
for i := 0; i < len(userList); i++ {
userList[i].FormVersionId = strconv.FormatInt(userList[i].VersionId, 10)
userList[i].IdStr = strconv.FormatInt(userList[i].Id, 10)
userList[i].RunFlowIdStr = strconv.FormatInt(userList[i].Id, 10)
1 year ago
userList[i].FlowKeys = strconv.FormatInt(userList[i].FlowKey, 10)
userList[i].CreaterInfo = GainSmaillUserInfo[int64](userList[i].Creater)
userList[i].MastersKeyStr = strconv.FormatInt(userList[i].MastersKey, 10)
userList[i].AppKeyStr = strconv.FormatInt(userList[i].AppKey, 10)
userList[i].TableKeyStr = strconv.FormatInt(userList[i].TableKey, 10)
1 year ago
if userList[i].NextExecutor != "" {
nextAry := strings.Split(userList[i].NextExecutor, ",")
for _, v := range nextAry {
userList[i].CurrentNodeUser = append(userList[i].CurrentNodeUser, GainSmaillUserInfo[string](v))
}
}
userList[i].StartDate = publicmethod.UnixTimeToDay(userList[i].StartTime, 27)
if userList[i].NextStep != 0 {
nodeCont, idTrue := GainCurreNode(userList[i].FlowCont, userList[i].CurrentStep, userList[i].NextStep, userList[i].Status)
if idTrue {
userList[i].CurrentNodeName = nodeCont.NodeName
}
}
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)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-07 11:06:14
@ 功能: 获取App任务包含非流程表单
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GainAppAllTaskList(c *gin.Context) {
var requestData AppAllTaskSearch
c.ShouldBindJSON(&requestData)
if requestData.Id == "" {
publicmethod.Result(100, requestData, c)
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 10
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&customerForm.TaskRecord{}).Select("`id`").Where("appKey = ?", requestData.Id)
switch requestData.Class {
case 2: //草稿箱
gormDb = gormDb.Where("`status` = 1 AND `creater` = ?", userCont.Key)
default: //我的请求
gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", userCont.Key)
}
if requestData.Title != "" {
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%")
}
//获取总数
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
var idAry []int64
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
err := gormDb.Order("`id` desc").Find(&idAry).Error
var userList []SendTaskInfo
if err != nil || len(idAry) < 1 {
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c)
return
}
overall.CONSTANT_DB_CustomerForm.Model(&customerForm.TaskRecord{}).Where("`id` IN ?", idAry).Order("`id` desc").Find(&userList)
for i := 0; i < len(userList); i++ {
1 year ago
userList[i].States = userList[i].Status
1 year ago
userList[i].IdStr = strconv.FormatInt(userList[i].Id, 10)
userList[i].CreaterTimeStr = publicmethod.UnixTimeToDay(userList[i].CreaterTime, 27)
userList[i].RunFlowIdStr = strconv.FormatInt(userList[i].RunFlowId, 10)
userList[i].VersionIdStr = strconv.FormatInt(userList[i].VersionId, 10)
userList[i].MastersKeyStr = strconv.FormatInt(userList[i].MastersKey, 10)
userList[i].FlowKeyStr = strconv.FormatInt(userList[i].FlowKey, 10)
userList[i].FlowRunSingStr = strconv.FormatInt(userList[i].FlowRunSing, 10)
userList[i].TableKeyStr = strconv.FormatInt(userList[i].TableKey, 10)
userList[i].AppKeyStr = strconv.FormatInt(userList[i].AppKey, 10)
userList[i].CreaterInfo = GainSmaillUserInfo[int64](userList[i].Creater)
if userList[i].Types == 1 && userList[i].Status == 3 && userList[i].RunFlowId != 0 {
var runFlowInfo customerForm.RunWorkflow
runFlowInfo.GetCont(map[string]interface{}{"`id`": userList[i].RunFlowId}, "`current_step`", "`next_step`", "`creater`")
if runFlowInfo.NextStep != 0 && runFlowInfo.CurrentStep == 1 {
if runFlowInfo.Creater == userCont.Key {
userList[i].IsRetract = true
}
}
}
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(userList)), userList, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-07 13:27:30
@ 功能: 启动流程
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) RunAppWorkFlow(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 customerForm.TaskRecord
err = taskInfo.GetCont(map[string]interface{}{"`id`": requestData.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context) //当前操作人
creetTime := time.Now().Unix() //当前时间
//获取任务
var runFlowInfo customerForm.RunWorkflow
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": taskInfo.MastersKey})
if err != nil { //不存在,则新建工作流
//获取流程详情
var flowVersionInfo modelAppPlatform.WorkFlowVersion
flowVersionInfo.GetCont(map[string]interface{}{"`id`": taskInfo.FlowRunSing}, "`content`")
uuid := publicmethod.GetUUid(1)
runUuId := publicmethod.GetUUid(6)
//执行工作流内容
var workFlowInfo customerForm.RunWorkflow
workFlowInfo.Id = uuid
workFlowInfo.FlowKey, _ = strconv.ParseInt(requestData.Id, 10, 64) //统一识别符(任务标识符)
workFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本
workFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容
workFlowInfo.Creater = userCont.Key //流程发起人
workFlowInfo.Status = 3 //状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除
workFlowInfo.StartTime = creetTime //开始时间
workFlowInfo.UpdateTime = creetTime //更新时间
workFlowInfo.RunKey = runUuId //当前执行识别符
// startCreaterKey := strconv.FormatInt(userCont.Key, 10) //当前操作人
//执行流程
// var executeWorkflow RunWorkFlow
// executeWorkflow.Step = 0 //执行第几部
// executeWorkflow.FlowList = requestData.FlowList
// executeWorkflow.Participant = append(executeWorkflow.Participant, startCreaterKey)
// executeWorkflow.TotalSteps = len(requestData.FlowList) //流程总长度
// executeWorkflow.Uuid = uuid //流程唯一识别符
// executeWorkflow.RunUid = runUuId //执行Uid
} else {
//存在,则发起工作流
}
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-07 16:05:33
@ 功能: 编辑任务内容
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) EditTaskAppInfo(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
}
//Step1:判断任务是处在什么状态
var taskInfo customerForm.TaskRecord
err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": requestData.Id}, "`version_id`", "`mastesformjson`", "`status`", "`types`", `flow_key`, "`masters_key`")
if err != nil {
publicmethod.Result(1, err, c, "流程不存在!不可进行下一步")
return
}
if !publicmethod.IsInTrue[int](taskInfo.Status, []int{1, 2, 4}) {
publicmethod.Result(1, err, c, "流程既不是草稿,也未发表、归档!不可进行下一步")
return
}
//Step2:展开表单
var formJsonCont customerform.CustomerFormMaster
json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont)
//Step3:获取流程使用得表单数据表
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()
masterDataInfo := GainCurrendLogData(taskInfo.MastersKey, customerFormInfo, formUnitCont, masterUnitList)
var logDataInfo FormDataLog
logDataInfo.FlowKey = taskInfo.MastersKey
logDataInfo.GainFlowFoemLog()
fmt.Printf("主表的数据返回值--->%v\n--->%v\n", masterDataInfo, logDataInfo.NewData)
if len(logDataInfo.NewData) > 0 {
logTime := logDataInfo.NewData["logTime"]
newDataInfo := publicmethod.MapOut[string]()
for i, v := range masterDataInfo {
fmt.Printf("logDataInfo.masterDataInfo---->%v:%v--------->%T\n", i, v, v)
for j, jv := range logDataInfo.NewData {
if i == j {
if i == "masters_key" {
if mastKey, ok := jv.(uint64); ok {
newDataInfo[i] = strconv.FormatUint(mastKey, 10)
}
} else if i == "creater" {
if createrKey, ok := jv.(int64); ok {
newDataInfo[i] = strconv.FormatInt(createrKey, 10)
}
} else {
newDataInfo[i] = jv
}
}
if j == "explicate" {
newDataInfo["explicate"] = jv
}
}
}
logDataInfo.NewData = masterDataInfo
logDataInfo.NewData["logTime"] = logTime
masterDataInfo = newDataInfo
} else {
isWrite := true
for i, v := range masterDataInfo {
fmt.Printf("logDataInfo.masterDataInfo--1-->%v:%v--------->%T\n", i, v, v)
if i == "masters_key" {
if mastKey, ok := v.(uint64); ok {
masterDataInfo[i] = strconv.FormatUint(mastKey, 10)
}
}
if i == "creater" {
if createrKey, ok := v.(int64); ok {
masterDataInfo[i] = strconv.FormatInt(createrKey, 10)
}
}
if i == "explicate" {
isWrite = false
}
}
if isWrite {
masterDataInfo["explicate"] = ""
}
}
masterDataInfo["flowKey"] = strconv.FormatInt(taskInfo.FlowKey, 10)
sendData := publicmethod.MapOut[string]()
sendData["masterDataInfo"] = masterDataInfo
publicmethod.Result(0, sendData, c)
return
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)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-10 11:27:13
@ 功能: 再次保存草稿箱内容
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) SaveDraftAgain(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
}
taskId := ""
if taskIdVal, ok := mapData["masters_key"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
} else {
if akValStr, ok := taskIdVal.(string); ok {
taskId = akValStr
}
}
var formCont modelAppPlatform.CustomerFormView
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["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
}
sendInfo := publicmethod.MapOut[string]()
7 months ago
masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 2)
1 year ago
if len(masrWriteMap) > 0 {
oldMasterData, _ := taskmanagement.MasterTableHandle(formCont.TableKey, userCont.Key, cureeTime, masrWriteMap)
sendInfo["oldMasterData"] = oldMasterData
}
//判断是否有子表
if len(sunFieldAry) > 0 {
//有子表
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
for _, v := range formUnitCont.SunFormInfo {
sunTypeAry[v.TableName] = v.UbitInfo
}
7 months ago
sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
1 year ago
sendInfo["sunTableData"] = sunTableData
if len(sunTableData) > 0 {
sonList, _ := taskmanagement.SonTableHandle(taskId, userCont.Key, cureeTime, sunFieldAry)
sendInfo["sonList"] = sonList
}
}
sendInfo["taskId"] = taskId
sendInfo["mapData"] = mapData
sendInfo["masterField"] = masterField
sendInfo["sunFieldAry"] = sunFieldAry
sendInfo["masterUnitList"] = masterUnitList
sendInfo["cureeTime"] = cureeTime
sendInfo["masrWriteMap"] = masrWriteMap
publicmethod.Result(0, sendInfo, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2024-06-13 11:20:04
@ 功能: 重新提交有流程就发动流程无流程就正常发表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) AfreshAppSubmit(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
}
taskId := ""
if taskIdVal, ok := mapData["masters_key"]; !ok {
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
return
} else {
if akValStr, ok := taskIdVal.(string); ok {
taskId = akValStr
}
}
var flowListAry []RunFlow
if flowAry, ok := mapData["flowList"]; ok {
if akFlowValStr, ok := flowAry.(string); ok {
json.Unmarshal([]byte(akFlowValStr), &flowListAry)
}
}
var formCont modelAppPlatform.CustomerFormView
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["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
}
sendInfo := publicmethod.MapOut[string]()
7 months ago
masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 2)
1 year ago
if len(masrWriteMap) > 0 {
oldMasterData, _ := taskmanagement.MasterTableHandle(formCont.TableKey, userCont.Key, cureeTime, masrWriteMap)
sendInfo["oldMasterData"] = oldMasterData
}
//判断是否有子表
if len(sunFieldAry) > 0 {
//有子表
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
for _, v := range formUnitCont.SunFormInfo {
sunTypeAry[v.TableName] = v.UbitInfo
}
7 months ago
sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
1 year ago
sendInfo["sunTableData"] = sunTableData
if len(sunTableData) > 0 {
sonList, _ := taskmanagement.SonTableHandle(taskId, userCont.Key, cureeTime, sunFieldAry)
sendInfo["sonList"] = sonList
}
}
//开启流程的
if formCont.FlowIsOpen == 1 {
var runFlowInfo customerForm.RunWorkflow
err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": taskId}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`")
saveTask := publicmethod.MapOut[string]() //修改任务
if err != nil {
uuid := publicmethod.GetUUid(1)
runUuId := publicmethod.GetUUid(6)
var taskInfo customerForm.TaskRecord
taskInfo.GetCont(map[string]interface{}{"`masters_key`": taskId}, "`flow_key`", "`flow_run_sing`")
//获取流程详情
var flowVersionInfo modelAppPlatform.WorkFlowVersion
flowVersionInfo.GetCont(map[string]interface{}{"`id`": taskInfo.FlowRunSing}, "`content`")
//执行工作流内容
var workFlowInfo customerForm.RunWorkflow
workFlowInfo.Id = uuid
workFlowInfo.FlowKey = taskInfo.FlowKey //统一识别符(任务标识符)
workFlowInfo.Version = strconv.FormatInt(taskInfo.FlowRunSing, 10) //工作流版本
workFlowInfo.VersionCont = flowVersionInfo.Content //当前工作流内容
workFlowInfo.Creater = userCont.Key //流程发起人
workFlowInfo.Status = 3 //状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除
workFlowInfo.StartTime = cureeTime //开始时间
workFlowInfo.UpdateTime = cureeTime //更新时间
workFlowInfo.RunKey = runUuId //当前执行识别符
startCreaterKey := strconv.FormatInt(userCont.Key, 10) //当前操作人
//执行流程
var executeWorkflow RunWorkFlow
executeWorkflow.Step = 0 //执行第几部
executeWorkflow.FlowList = flowListAry
executeWorkflow.Participant = append(executeWorkflow.Participant, startCreaterKey)
executeWorkflow.TotalSteps = len(flowListAry) //流程总长度
executeWorkflow.Uuid = uuid //流程唯一识别符
executeWorkflow.RunUid = runUuId //执行Uid
executeWorkflow.GainRunNode(startCreaterKey, 2, "发起审批")
flowJsonCont, _ := json.Marshal(executeWorkflow.FlowList) //将步进流转化成json流
workFlowInfo.FlowCont = string(flowJsonCont) //流程执行体
workFlowInfo.CurrentStep = executeWorkflow.Step
workFlowInfo.NextStep = executeWorkflow.NextStep
//参与人去重
var parUser []string
for _, v := range executeWorkflow.Participant {
if !publicmethod.IsInTrue[string](v, parUser) {
parUser = append(parUser, v)
}
}
workFlowInfo.Participants = strings.Join(parUser, ",")
nextRunUser := executeWorkflow.NextRunNodeUser(1)
workFlowInfo.NextExecutor = strings.Join(nextRunUser, ",")
if executeWorkflow.NextStep <= 0 {
workFlowInfo.Status = 4
}
err = workFlowInfo.WriteCont() //写入执行工作流
if err != nil {
var taskInfo customerForm.TaskRecord
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 1})
publicmethod.Result(10001, err, c, "流程写入失败!请重新发起")
return
}
if executeWorkflow.NextStep <= 0 {
var taskCont customerForm.TaskRecord
taskCont.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 4})
} else {
var taskCont customerForm.TaskRecord
taskCont.EiteCont(map[string]interface{}{"`masters_key`": taskId}, map[string]interface{}{"`status`": 3})
}
// saveTask["`flow_key`"] = 2
} else {
var flowList []taskmanagement.RunFlow
err = json.Unmarshal([]byte(runFlowInfo.FlowCont), &flowList)
if err != nil {
publicmethod.Result(107, err, c)
return
}
startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人
runUuId := publicmethod.GetUUid(6)
//执行流程
var runFlow taskmanagement.RunWorkFlow
runFlow.Step = 0 //执行第几部
runFlow.FlowList = flowList
runFlow.Participant = append(runFlow.Participant, startUs)
runFlow.TotalSteps = len(flowList) //流程总长度
runFlow.Uuid = runFlowInfo.Id
runFlow.RunUid = runUuId
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`"] = runUuId
//参与人去重
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()
err = runFlowInfo.EiteCont(map[string]interface{}{"`id`": runFlowInfo.Id}, SaveFlowCont)
if err != nil {
publicmethod.Result(106, err, c)
return
}
}
saveTask["`status`"] = 3
saveTask["`edit_time`"] = time.Now().Unix()
var taskInfo customerForm.TaskRecord
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, saveTask)
} else { //未开启流程的表单
saveTask := publicmethod.MapOut[string]() //修改任务
saveTask["`status`"] = 2
saveTask["`edit_time`"] = time.Now().Unix()
var taskInfo customerForm.TaskRecord
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": taskId}, saveTask)
}
// sendInfo["taskId"] = taskId
// sendInfo["mapData"] = mapData
// sendInfo["masterField"] = masterField
// sendInfo["sunFieldAry"] = sunFieldAry
// sendInfo["masterUnitList"] = masterUnitList
// sendInfo["cureeTime"] = cureeTime
// sendInfo["masrWriteMap"] = masrWriteMap
publicmethod.Result(0, sendInfo, c)
}