diff --git a/api/shiyan/maptostruct/shiyan.go b/api/shiyan/maptostruct/shiyan.go index 0eedd63..f413d53 100644 --- a/api/shiyan/maptostruct/shiyan.go +++ b/api/shiyan/maptostruct/shiyan.go @@ -574,3 +574,28 @@ func (a *ApiMethod) GetAllOrgSun(c *gin.Context) { sunOrg.GetOrgSun(requestData.Id) publicmethod.Result(0, sunOrg.Id, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-18 15:20:02 +@ 功能: 获取数据中台的数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainDateCenter(c *gin.Context) { + url := "http://172.20.5.86/prod-api/database/app/datasource/page?pageNum=1&pageSize=10&databaseName=&dataType=" + jisguo := publicmethod.CurlGet(url) + var sendDara map[string]interface{} + json.Unmarshal(jisguo, &sendDara) + publicmethod.Result(0, sendDara, c) +} diff --git a/api/version1/customerform/analysis_table.go b/api/version1/customerform/analysis_table.go index 8455380..955b77b 100644 --- a/api/version1/customerform/analysis_table.go +++ b/api/version1/customerform/analysis_table.go @@ -501,3 +501,72 @@ func SubUnitConvertSql(tablename string, subUnit MasterStruct) (sql string, sqlA } return } + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 14:35:39 +@ 功能: 解析自定义表单所有组件属性 +*/ +func (t *TableFormUnit) AnalysisTableFormUnitAttribute(tablename string, subUnitAry []MasterStruct) { + if len(subUnitAry) > 0 { + var unitContAry []UnitAttribute + for _, v := range subUnitAry { + wordClass := AnalysisFormUnitClass(v) + switch wordClass.UnitName { + case "flex", "table": + if len(v.List) > 0 { + t.AnalysisTableFormUnitAttribute(v.Name, v.List) + } + case "grid", "tabs": + if len(v.Columns) > 0 { + for _, mv := range v.Columns { + t.AnalysisTableFormUnitAttribute(tablename, mv.List) + } + } + case "card", "div": + if len(v.List) > 0 { + t.AnalysisTableFormUnitAttribute(tablename, v.List) + } + default: + var unitCont UnitAttribute + unitCont.Name = v.Item.Label //组件名称 + unitCont.Key = v.Name //主键识别符 + unitCont.Class = v.Type //组件分类 + unitCont.ActiveValue = v.Control.ActiveValue //开关的开值 + unitCont.InactiveValue = v.Control.InactiveValue //开关的关值 + for _, v := range v.Options { + var optVal OptionsList + optVal.Label = v.Label + optVal.Value = v.Value + unitCont.Options = append(unitCont.Options, optVal) //附件判断值 + } + + unitContAry = append(unitContAry, unitCont) + // fmt.Printf("tablename:%v------>%v------>%v\n", tablename, v.Name, unitContAry) + } + } + if tablename != "" { + if len(t.SunFormInfo) > 0 { + isNew := true + for i, v := range t.SunFormInfo { + if _, ok := v[tablename]; ok { + isNew = false + t.SunFormInfo[i][tablename] = unitContAry + } + } + if isNew { + sonMapAry := make(map[string][]UnitAttribute) + sonMapAry[tablename] = unitContAry + t.SunFormInfo = append(t.SunFormInfo, sonMapAry) + } + } else { + sonMapAry := make(map[string][]UnitAttribute) + sonMapAry[tablename] = unitContAry + t.SunFormInfo = append(t.SunFormInfo, sonMapAry) + } + } else { + t.MasterInfo = append(t.MasterInfo, unitContAry...) + } + } +} diff --git a/api/version1/customerform/formTable.go b/api/version1/customerform/formTable.go index 86fe23a..a11e463 100644 --- a/api/version1/customerform/formTable.go +++ b/api/version1/customerform/formTable.go @@ -1,6 +1,7 @@ package customerform import ( + "appPlatform/models/customerForm" "appPlatform/models/modelAppPlatform" "appPlatform/models/modelshr" "appPlatform/overall" @@ -1160,11 +1161,14 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { // why, err := AnalysisSerachTerm(requestData.SearchData) // fmt.Printf("why---->%v\n", why) var formList []map[string]interface{} - gormDb := overall.CONSTANT_DB_CustomerForm.Table(formInfo.TableKey) - // gormDb := overall.CONSTANT_DB_CustomerForm.Table(formInfo.TableKey).Where("`states` BETWEEN ? AND ?", 1, 2) + // gormDb := overall.CONSTANT_DB_CustomerForm.Table(formInfo.TableKey) + tableName := fmt.Sprintf("`%v` as f", formInfo.TableKey) + gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus") // if err == nil { // gormDb = gormDb.Where(why) // } + gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key") + gormDb = gormDb.Where("`states` BETWEEN ? AND ?", 1, 2) gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) var total int64 totalErr := gormDb.Count(&total).Error @@ -1185,13 +1189,44 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { if formInfo.ListJson != "" { var listFieldsMap ListPageFields err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) - fmt.Printf("%T----------->%v----------->%v\n", listFieldsMap, err, listFieldsMap) + // fmt.Printf("%T----------->%v----------->%v\n", listFieldsMap, err, listFieldsMap) if err == nil { // fmt.Printf("%T----------->%v\n", listFieldsMap, listFieldsMap) formList = listFieldsMap.DevelopSpecificationsSend(formList) // formList = DevelopSpecificationsSend(formList, listFieldsMap) } + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + //获取任务状态 + for i, v := range formList { + formList[i]["isRetract"] = false + if mastrKey, ok := v["masters_key"]; ok { + // fmt.Printf("masters_key----------->%v\n", v["masters_key"]) + var runFlowInfo customerForm.RunWorkflow + runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": mastrKey}, "`current_step`", "`next_step`") + // fmt.Printf("runFlowInfo----------->%v--------->%v\n", runFlowInfo, v["taskStatus"]) + if stateVal, ok := v["taskStatus"]; ok { + // fmt.Printf("NextStep----------->%T----------->%v--------->%v--------->%v\n", stateVal, stateVal, runFlowInfo.NextStep, runFlowInfo.CurrentStep) + if stauval, ok := stateVal.(string); ok { + if stauval == "3" && runFlowInfo.NextStep != 0 { + // fmt.Printf("IsRetract----------->%T----------->%v----------->%v\n", formList[i]["creater"], formList[i]["creater"], userCont.Name) + if runFlowInfo.CurrentStep == 1 { + if createrName, ok := formList[i]["creater"].(string); ok { + if createrName == userCont.Name { + formList[i]["isRetract"] = true + } + } + + } + } + } + + } + } + } // publicmethod.Result(100, formList, c) @@ -1209,7 +1244,7 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa for _, v := range listData { sendInfo := publicmethod.MapOut[string]() for mi, mv := range v { - fmt.Printf("%v = %v\n", mi, mv) + // fmt.Printf("%v = %v\n", mi, mv) switch mi { case "creater": var myInfo modelshr.PersonArchives @@ -1226,7 +1261,7 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa // sendInfo[mi] = publicmethod.TypeToInterface(mv) } } - fmt.Printf("================================\n") + // fmt.Printf("================================\n") sendList = append(sendList, sendInfo) } return sendList diff --git a/api/version1/customerform/listField.go b/api/version1/customerform/listField.go index 80658e9..2df5df1 100644 --- a/api/version1/customerform/listField.go +++ b/api/version1/customerform/listField.go @@ -48,3 +48,26 @@ type controlBtnInfo struct { Size string `json:"size"` Icon string `json:"icon"` } + +// 自定义表单组件基本属性 +type UnitAttribute struct { + Name string `json:"name"` //组件名称 + Key string `json:"key"` //主键识别符 + Class string `json:"class"` //组件分类 + ActiveValue string `json:"activeValue"` //开关的开值 + InactiveValue string `json:"inactiveValue"` //开关的关值 + Options []OptionsList `json:"options"` //附件判断值 +} +type OptionsList struct { + Label string `json:"label"` //名称 + Value string `json:"value"` //判定值 +} + +type TableFormUnit struct { + MasterInfo []UnitAttribute `json:"masterInfo"` //主表组件列表 + SunFormInfo []map[string][]UnitAttribute `json:"sunFormInfo"` //子表 +} + +type SunFormInfoStruct struct { + SunFormInfo []map[string][]UnitAttribute `json:"sunFormInfo"` //子表 +} diff --git a/api/version1/dataCenter/hander.go b/api/version1/dataCenter/hander.go new file mode 100644 index 0000000..4b4284f --- /dev/null +++ b/api/version1/dataCenter/hander.go @@ -0,0 +1,202 @@ +package datacenter + +import ( + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "net/url" + "strings" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-18 15:37:05 +@ 功能: 通用地址 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GaindataCenter(c *gin.Context) { + var requestData DataInfo + c.ShouldBindJSON(&requestData) + if requestData.Url == "" { + publicmethod.Result(1, requestData, c, "未知访问地址") + return + } + // publicmethod.Result(1, requestData, c, "未知访问地址") + // return + if requestData.Where != "" { + if requestData.Method == "GET" { + var whereAry []string + whyOne := strings.Split(requestData.Where, "&") + if len(whyOne) > 0 { + for _, v := range whyOne { + whyTwo := strings.Split(v, "=") + if len(whyTwo) == 2 { + whereAry = append(whereAry, fmt.Sprintf("%v=%v", whyTwo[0], url.QueryEscape(whyTwo[1]))) + } else { + whereAry = append(whereAry, v) + } + } + } + getUrl := requestData.Url + if len(whereAry) > 0 { + getUrl = fmt.Sprintf("%v?%v", requestData.Url, strings.Join(whereAry, "&")) + } + + // getUrl = url.QueryEscape(getUrl) + // fmt.Printf("%T--------->%v\n", getUrl, getUrl) + getData := publicmethod.CurlGet(getUrl) + var sendMap map[string]interface{} + json.Unmarshal(getData, &sendMap) + // fmt.Printf("%T--------->%v--------->%v\n", sendMap, sendMap, getUrl) + // publicmethod.Result(0, sendMap, c) + shenData := publicmethod.MapOut[string]() + if code, ok := sendMap["code"]; ok { + + if codeIn, ok := code.(float64); ok { + if codeIn == 200 { + shenData["code"] = 0 + } else { + shenData["code"] = codeIn + } + } + + } + if msg, ok := sendMap["msg"]; ok { + shenData["msg"] = msg + } + if data, ok := sendMap["data"]; ok { + shenData["data"] = data + } + publicmethod.ResultInterface(sendMap, c) + return + } else { + getData := publicmethod.CurlPostJosn(requestData.Url, []byte(requestData.Where)) + var sendMap map[string]interface{} + json.Unmarshal(getData, &sendMap) + publicmethod.ResultInterface(sendMap, c) + return + } + } else { + if requestData.Method == "GET" { + getUrl := fmt.Sprintf("%v", requestData.Url) + getData := publicmethod.CurlGet(getUrl) + var sendMap map[string]interface{} + json.Unmarshal(getData, &sendMap) + // publicmethod.Result(0, sendMap, c) + shenData := publicmethod.MapOut[string]() + if code, ok := sendMap["code"]; ok { + if codeIn, ok := code.(float64); ok { + if codeIn == 200 { + shenData["code"] = 0 + } else { + shenData["code"] = codeIn + } + } + + } + if msg, ok := sendMap["msg"]; ok { + shenData["msg"] = msg + } + if data, ok := sendMap["data"]; ok { + shenData["data"] = data + } + publicmethod.ResultInterface(sendMap, c) + return + } else { + getData := publicmethod.CurlPostJosn(requestData.Url, []byte("")) + var sendMap map[string]interface{} + json.Unmarshal(getData, &sendMap) + shenData := publicmethod.MapOut[string]() + if code, ok := sendMap["code"]; ok { + if codeIn, ok := code.(float64); ok { + if codeIn == 200 { + shenData["code"] = 0 + } else { + shenData["code"] = codeIn + } + } + + } + if msg, ok := sendMap["msg"]; ok { + shenData["msg"] = msg + } + publicmethod.ResultInterface(sendMap, c) + return + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-19 14:05:46 +@ 功能: 数据中台POST提交数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) PostSaveData(c *gin.Context) { + var requestData DataInfoPost + c.ShouldBindJSON(&requestData) + if requestData.Url == "" { + publicmethod.Result(1, requestData, c, "未知访问地址") + return + } + dataJson, err := json.Marshal(requestData.DataInfo) + shenData := publicmethod.MapOut[string]() + if err != nil { + shenData["code"] = 10001 + shenData["msg"] = err + publicmethod.ResultInterface(shenData, c) + return + } + callBackBtye := publicmethod.CurlPostJosn(requestData.Url, dataJson) + var sendMap map[string]interface{} + err = json.Unmarshal(callBackBtye, &sendMap) + if err != nil { + shenData["code"] = 10001 + shenData["msg"] = err + publicmethod.ResultInterface(shenData, c) + return + } + if code, ok := sendMap["code"]; ok { + + if codeIn, ok := code.(float64); ok { + if codeIn == 200 { + shenData["code"] = 0 + } else { + shenData["code"] = codeIn + } + + } + + } + if msg, ok := sendMap["msg"]; ok { + shenData["msg"] = msg + } + if data, ok := sendMap["data"]; ok { + shenData["data"] = data + } + publicmethod.ResultInterface(shenData, c) +} diff --git a/api/version1/dataCenter/type.go b/api/version1/dataCenter/type.go new file mode 100644 index 0000000..65fd4d3 --- /dev/null +++ b/api/version1/dataCenter/type.go @@ -0,0 +1,49 @@ +package datacenter + +import ( + "appPlatform/overall/publicmethod" + "sync" + + "github.com/gin-gonic/gin" +) + +// 协程设置 +var syncSeting = sync.WaitGroup{} + +type ApiMethod struct{} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-18 15:28:20 +@ 功能: 数据中台入口 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["index"] = "数据中台入口" + publicmethod.Result(0, outputCont, c) +} + +// 接收参数 +type DataInfo struct { + Url string `json:"url"` + Method string `json:"methodType"` + Where string `json:"where"` +} + +// 接收POST请求 +type DataInfoPost struct { + Url string `json:"url"` + DataInfo interface{} `json:"dataInfo"` +} diff --git a/api/version1/entry.go b/api/version1/entry.go index 03170b3..e1f5f71 100644 --- a/api/version1/entry.go +++ b/api/version1/entry.go @@ -2,6 +2,7 @@ package version1 import ( "appPlatform/api/version1/customerform" + datacenter "appPlatform/api/version1/dataCenter" "appPlatform/api/version1/datamanagement/redisController" "appPlatform/api/version1/dict" "appPlatform/api/version1/grantpowers" @@ -30,6 +31,7 @@ type ApiEntry struct { RedisManagApi redisController.ApiMethod MathsApi matsformula.ApiMethod WechatApi workWechat.ApiMethod //微信相关项目 + DataCenterApi datacenter.ApiMethod //数据中台 } var AppApiEntry = new(ApiEntry) diff --git a/api/version1/taskplatform/taskflow/editformflow.go b/api/version1/taskplatform/taskflow/editformflow.go index f4fea33..b1bfefd 100644 --- a/api/version1/taskplatform/taskflow/editformflow.go +++ b/api/version1/taskplatform/taskflow/editformflow.go @@ -10,6 +10,7 @@ import ( "appPlatform/overall/publicmethod" "encoding/json" "fmt" + "sort" "strconv" "strings" "time" @@ -591,3 +592,390 @@ func EditSunDatabase(uuid, creater, createrTime int64, masterTableName string, m } return } + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-13 09:49:27 +@ 功能: 获取流程可见范围 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainFlowLookSee(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 custView modelAppPlatform.CustomerFormView + err = custView.GetCont(map[string]interface{}{"`id`": requestData.Id}) + if err != nil { + publicmethod.Result(1, err, c, "未知表单参数!请核对1后重新提交!") + return + } + var powList []LookPowerCont + if custView.FlowIsOpen == 1 && custView.Flowkey != 0 { + flowLookPower := GainWorkflowLookView(custView.Flowkey) + if len(flowLookPower) > 0 { + powList = append(powList, flowLookPower...) + } + } + if custView.AuthorizedOrg != "" { + orgIdAry := strings.Split(custView.AuthorizedOrg, ",") + if len(orgIdAry) > 0 { + var orgList []modelshr.AdministrativeOrganization + err = overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`").Where("`state` = 1 AND `id` IN ?", orgIdAry).Find(&orgList).Error + if err == nil && len(orgList) > 0 { + for _, v := range orgList { + var lookCont LookPowerCont + lookCont.Types = 3 //1:人员;2:角色;3:行政组织;4:职务 + lookCont.TargetId = strconv.FormatInt(v.Id, 10) //相关内容识别符 + lookCont.Name = v.Name //相关内容名称 + lookCont.Icon = "" //头像 + lookCont.IconToBase64 = "" //头像Base64 + powList = append(powList, lookCont) + } + } + } + } + if custView.AuthorizedPersonnel != "" { + userKeyAry := strings.Split(custView.AuthorizedPersonnel, ",") + if len(userKeyAry) > 0 { + var userList []modelshr.PersonArchives + err = overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`name`,`icon`,`icon_photo`").Where("`emp_type` IN ? AND `id` IN ?", overall.EmployeeStatusIng, userKeyAry).Find(&userList).Error + if err == nil && len(userList) > 0 { + for _, v := range userList { + var lookCont LookPowerCont + lookCont.Types = 1 //1:人员;2:角色;3:行政组织;4:职务 + lookCont.TargetId = strconv.FormatInt(v.Id, 10) //相关内容识别符 + lookCont.Name = v.Name //相关内容名称 + lookCont.Icon = v.Icon //头像 + lookCont.IconToBase64 = v.IconPhoto //头像Base64 + powList = append(powList, lookCont) + } + } + } + } + //数据去重 + var isKey []string + var sendData []LookPowerCont + for _, v := range powList { + if !publicmethod.IsInTrue(v.TargetId, isKey) { + isKey = append(isKey, v.TargetId) + sendData = append(sendData, v) + } + } + sort.Slice(sendData, func(i, j int) bool { + return sendData[i].Types > sendData[j].Types + }) + publicmethod.Result(0, sendData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-13 15:08:04 +@ 功能: 获取流程可见范围 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainWorkflowLookView(flowKey int64) (lookPower []LookPowerCont) { + if flowKey == 0 { + return + } + var flowInfo modelAppPlatform.FlowVersion + err := flowInfo.GetCont(map[string]interface{}{"`key`": flowKey, "`state`": 1}, "`content`") + if err == nil && flowInfo.Content != "" { + var flowConter map[string]interface{} + err = json.Unmarshal([]byte(flowInfo.Content), &flowConter) + if err == nil { + if flowPermission, ok := flowConter["flowPermission"]; ok { + if powList, ok := flowPermission.([]interface{}); ok { + + for _, v := range powList { + var lookPowCont LookPowerCont + if val, ok := v.(map[string]interface{}); ok { + if iconVal, ok := val["icon"].(string); ok { + lookPowCont.Icon = iconVal + } + if iconBaseVal, ok := val["iconToBase64"].(string); ok { + lookPowCont.IconToBase64 = iconBaseVal + } + if nameVal, ok := val["name"].(string); ok { + lookPowCont.Name = nameVal + } + if targetIdVal, ok := val["targetId"].(string); ok { + lookPowCont.TargetId = targetIdVal + } + if targetIdVal, ok := val["type"].(float64); ok { + lookPowCont.Types = targetIdVal + } + } + if lookPowCont.Types != 0 { + lookPower = append(lookPower, lookPowCont) + } + } + } + } + } + } + + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-15 14:34:47 +@ 功能: 编辑可见范围 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) EditLookPowerView(c *gin.Context) { + var requestData LookPowerEdit + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(1, err, c, "未知表单参数!请核对1后重新提交!") + return + } + var custView modelAppPlatform.CustomerFormView + err = custView.GetCont(map[string]interface{}{"`id`": requestData.Id}) + if err != nil { + publicmethod.Result(1, err, c, "未知表单参数!请核对1后重新提交!") + return + } + + // var powList []LookPowerCont + if custView.FlowIsOpen == 1 && custView.Flowkey != 0 { + EditFlowLookView(custView.Flowkey, requestData.ListData) + } + var roleList []string + var peopleList []string + var orgList []string + var postList []string + if len(requestData.ListData) > 0 { + for _, v := range requestData.ListData { + switch v.Types { + case 1: + peopleList = append(peopleList, v.TargetId) + case 2: + roleList = append(roleList, v.TargetId) + case 3: + orgList = append(orgList, v.TargetId) + case 4: + postList = append(postList, v.TargetId) + default: + } + } + } + saveDara := publicmethod.MapOut[string]() + if len(peopleList) > 0 { + saveDara["authorizedPersonnel"] = strings.Join(peopleList, ",") + } else { + saveDara["authorizedPersonnel"] = "" + } + if len(roleList) > 0 { + saveDara["authorizationRoles"] = strings.Join(roleList, ",") + } else { + saveDara["authorizationRoles"] = "" + } + if len(orgList) > 0 { + saveDara["authorizedOrg"] = strings.Join(orgList, ",") + } else { + saveDara["authorizedOrg"] = "" + } + if len(postList) > 0 { + saveDara["authorizedPosition"] = strings.Join(postList, ",") + } else { + saveDara["authorizedPosition"] = "" + } + if len(saveDara) > 0 { + saveDara["edit_time"] = time.Now().Unix() + } + err = custView.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveDara) + if err != nil { + publicmethod.Result(106, err, c) + return + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-15 14:58:23 +@ 功能: +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func EditFlowLookView(flowKey int64, ListData []LookPowerCont) { + if flowKey == 0 { + return + } + var flowInfo modelAppPlatform.FlowVersion + err := flowInfo.GetCont(map[string]interface{}{"`key`": flowKey, "`state`": 1}, "`content`", "`id`") + if err == nil && flowInfo.Content != "" { + var flowConter map[string]interface{} + err = json.Unmarshal([]byte(flowInfo.Content), &flowConter) + if err == nil { + if _, ok := flowConter["flowPermission"]; ok { + flowConter["flowPermission"] = ListData + } + } + jsonView, errk := json.Marshal(flowConter) + fmt.Printf("errk==>%v\n jsonView==>%v\n", errk, string(jsonView)) + saveCont := publicmethod.MapOut[string]() + saveCont["`content`"] = string(jsonView) + saveCont["`time`"] = time.Now().Unix() + var saveFlowVersion modelAppPlatform.WorkFlowVersion + saveFlowVersion.EiteCont(map[string]interface{}{"`id`": flowInfo.Id}, saveCont) + } + +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-16 15:58:05 +@ 功能: 编辑消息提醒 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) SetUpMsg(c *gin.Context) { + var requestData SetMsgInfo + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(1, err, c, "未知表单参数!请核对1后重新提交!") + return + } + var msgRuleInfo modelAppPlatform.MsgRule + err = msgRuleInfo.GetCont(map[string]interface{}{"`formKey`": requestData.Id}) + + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + formKeyInt, _ := strconv.ParseInt(requestData.Id, 10, 64) + timeVal := time.Now().Unix() + var editMsgRuleInfo modelAppPlatform.MsgRule + if err != nil { //不存在,就写入 + editMsgRuleInfo.FlowKey = formKeyInt + editMsgRuleInfo.RuleCont = requestData.SetCont + editMsgRuleInfo.Creater = userCont.Key + editMsgRuleInfo.StartTime = timeVal + editMsgRuleInfo.UpdateTime = timeVal + err = editMsgRuleInfo.WriteCont() + } else { + saveData := publicmethod.MapOut[string]() + saveData["ruleCont"] = requestData.SetCont + saveData["creater"] = userCont.Key + saveData["edit_time"] = timeVal + err = editMsgRuleInfo.EiteCont(map[string]interface{}{"`id`": msgRuleInfo.Id}, saveData) + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-16 16:51:11 +@ 功能: 获取消息设置 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainSetUpMsg(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 msgRuleInfo modelAppPlatform.MsgRule + err = msgRuleInfo.GetCont(map[string]interface{}{"`formKey`": requestData.Id}) + if err != nil { + publicmethod.Result(10001, err, c) + return + } + sendMap := publicmethod.MapOut[string]() + sendMap["id"] = strconv.FormatInt(msgRuleInfo.Id, 10) + sendMap["formKey"] = strconv.FormatInt(msgRuleInfo.FlowKey, 10) + if msgRuleInfo.RuleCont != "" { + var ruleContMap map[string]interface{} + json.Unmarshal([]byte(msgRuleInfo.RuleCont), &ruleContMap) + sendMap["ruleCont"] = ruleContMap + } else { + sendMap["ruleCont"] = "" + } + sendMap["timeVal"] = publicmethod.UnixTimeToDay(msgRuleInfo.StartTime, 27) + publicmethod.Result(0, sendMap, c) +} diff --git a/api/version1/taskplatform/taskflow/flowType.go b/api/version1/taskplatform/taskflow/flowType.go index 5959e4f..ed45935 100644 --- a/api/version1/taskplatform/taskflow/flowType.go +++ b/api/version1/taskplatform/taskflow/flowType.go @@ -217,3 +217,22 @@ type SearchUserCont struct { Name string `json:"name"` Department int64 `json:"department"` } + +type LookPowerCont struct { + Types float64 `json:"type"` //1:人员;2:角色;3:行政组织;4:职务 + TargetId string `json:"targetId"` //相关内容识别符 + publicmethod.PublicName //相关内容名称 + Icon string `json:"icon"` //头像 + IconToBase64 string `json:"iconToBase64"` //头像Base64 +} + +type LookPowerEdit struct { + publicmethod.PublicId + ListData []LookPowerCont `json:"listData"` // +} + +//设置消息提醒 +type SetMsgInfo struct { + publicmethod.PublicId + SetCont string `json:"setCont"` //提示主体 +} diff --git a/api/version1/taskplatform/taskmanagement/appform.go b/api/version1/taskplatform/taskmanagement/appform.go index ebcf784..35effe5 100644 --- a/api/version1/taskplatform/taskmanagement/appform.go +++ b/api/version1/taskplatform/taskmanagement/appform.go @@ -207,38 +207,42 @@ func (a *ApiMethod) GianTaskVersionCont(c *gin.Context) { publicmethod.Result(107, err, c) return } - var versionCont modelAppPlatform.CustomerFormView - err = versionCont.GetCont(map[string]interface{}{"`id`": requestData.Id}) + // var versionCont modelAppPlatform.CustomerFormView + // err = versionCont.GetCont(map[string]interface{}{"`id`": requestData.Id}) + var sendInfo CallBackFormStruct + err = overall.CONSTANT_DB_AppPlatform.Where("`id` = ?", requestData.Id).Find(&sendInfo).Error + if err != nil { publicmethod.Result(107, err, c) return } - var sendInfo CallBackFormStruct - sendInfo.Id = versionCont.Id - sendInfo.TableKey = versionCont.TableKey //表单标识符"` - sendInfo.Version = versionCont.Version //版本号"` - sendInfo.Status = versionCont.Status //显示状态(1:启用;2:禁用,3:删除)"` - sendInfo.MastesForm = versionCont.MastesForm //表单结构"` - sendInfo.MastesFormJson = versionCont.MastesFormJson //表单结构json"` - sendInfo.Creater = versionCont.Creater //创建人"` - sendInfo.CreaterTime = versionCont.CreaterTime //创建时间"` - sendInfo.EditTime = versionCont.EditTime //编辑时间"` - sendInfo.TableStructure = versionCont.TableStructure //字表结构"` - sendInfo.Dict = versionCont.Dict //字表结构"` - sendInfo.CfId = versionCont.CfId // - sendInfo.Name = versionCont.Name //表单名称"` - sendInfo.Classify = versionCont.Classify //分类1:表单;2:流程表单"` - sendInfo.Permit = versionCont.Permit //授权范围"` - sendInfo.PermitStr = versionCont.PermitStr //授权范围"` - sendInfo.Flowkey = versionCont.Flowkey //关联工作流"` - sendInfo.UserPermit = versionCont.UserPermit //可见人员"` - sendInfo.PostPermit = versionCont.PostPermit //可见角色"` - sendInfo.PowerStr = versionCont.PowerStr //权限结构"` - sendInfo.Groupid = versionCont.Groupid //分组Id"` - sendInfo.Icon = versionCont.Icon //图标"` - sendInfo.FlowIsOpen = versionCont.FlowIsOpen //是否开启工作流(1:启用;2:禁用)"` - sendInfo.FlowkeyStr = strconv.FormatInt(versionCont.Flowkey, 10) - sendInfo.CreaterStr = strconv.FormatInt(versionCont.Creater, 10) + // var sendInfo CallBackFormStruct + // sendInfo.Id = versionCont.Id + // sendInfo.TableKey = versionCont.TableKey //表单标识符"` + // sendInfo.Version = versionCont.Version //版本号"` + // sendInfo.Status = versionCont.Status //显示状态(1:启用;2:禁用,3:删除)"` + // sendInfo.MastesForm = versionCont.MastesForm //表单结构"` + // sendInfo.MastesFormJson = versionCont.MastesFormJson //表单结构json"` + // sendInfo.Creater = versionCont.Creater //创建人"` + // sendInfo.CreaterTime = versionCont.CreaterTime //创建时间"` + // sendInfo.EditTime = versionCont.EditTime //编辑时间"` + // sendInfo.TableStructure = versionCont.TableStructure //字表结构"` + // sendInfo.Dict = versionCont.Dict //字表结构"` + // sendInfo.CfId = versionCont.CfId // + // sendInfo.Name = versionCont.Name //表单名称"` + // sendInfo.Classify = versionCont.Classify //分类1:表单;2:流程表单"` + // sendInfo.Permit = versionCont.Permit //授权范围"` + // sendInfo.PermitStr = versionCont.PermitStr //授权范围"` + // sendInfo.Flowkey = versionCont.Flowkey //关联工作流"` + // sendInfo.UserPermit = versionCont.UserPermit //可见人员"` + // sendInfo.PostPermit = versionCont.PostPermit //可见角色"` + // sendInfo.PowerStr = versionCont.PowerStr //权限结构"` + // sendInfo.Groupid = versionCont.Groupid //分组Id"` + // sendInfo.Icon = versionCont.Icon //图标"` + // sendInfo.FlowIsOpen = versionCont.FlowIsOpen //是否开启工作流(1:启用;2:禁用)"` + sendInfo.FlowkeyStr = strconv.FormatInt(sendInfo.Flowkey, 10) + sendInfo.CreaterStr = strconv.FormatInt(sendInfo.Creater, 10) + sendInfo.IdStr = strconv.FormatInt(sendInfo.Id, 10) publicmethod.Result(0, sendInfo, c) } diff --git a/api/version1/taskplatform/taskmanagement/flowNode.go b/api/version1/taskplatform/taskmanagement/flowNode.go new file mode 100644 index 0000000..f282bf9 --- /dev/null +++ b/api/version1/taskplatform/taskmanagement/flowNode.go @@ -0,0 +1,186 @@ +package taskmanagement + +import "appPlatform/overall/publicmethod" + +/** +@ 作者: 秦东 +@ 时间: 2024-04-09 10:56:48 +@ 功能: 工作流结构主体 +*/ +type FlowMainBody struct { + TableId string `json:"tableId"` //工作流识别吗 + WorkFlowDef WorkFlowDefInfo `json:"workFlowDef"` //工作流主体属性 + DirectorMaxLevel int `json:"directorMaxLevel"` //审批主管最大层级 + FlowPermission []FlowPermissionInfo `json:"flowPermission"` //流程发起人 + NodeConfig NodePublicInfo `json:"nodeConfig"` //节点信息内容 +} + +//工作流主体属性 +type WorkFlowDefInfo struct { + FormKey string `json:"formKey"` //关联操作ID + publicmethod.PublicName //姓名 +} + +//流程节点 +type NodePublicInfo struct { + NodePublicInfoES + Settype int `json:"settype"` // 审批人设置 1:指定成员; 2:主管;3:行政岗位; 4:发起人自选; 5:发起人自己;6:连续多级主管;7:指定前置审批为本节点设置审批人;8:表单字段;9:权限矩阵 + SelectMode int `json:"selectMode"` //审批人数 1选一个人 2选多个人 + SelectRange int `json:"selectRange"` //选择范围 1.全公司 2指定成员 3指定角色 + DirectorLevel int `json:"directorLevel"` //审批终点 最高层主管数 + ExamineMode int `json:"examineMode"` //多人审批时采用的审批方式 1:依次审批; 2:会签;3:非会签 + NoHanderAction int `json:"noHanderAction"` //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员 + ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` //审批终点 第n层主管 + SendBackNode string `json:"sendBackNode"` //退回哪个节点 + CustomNode string `json:"customNode"` //指定前置审批为本节点设置审批人 + + ConditionNodes []NodePublicInfoES `json:"conditionNodes"` //判断条件,当节点是路由时有效 + Executionaddress string `json:"executionaddress"` //第三方执行地址 + + ChildNode *NodePublicInfo `json:"childNode"` //子节点 + Matrix MatrixInfo `json:"matrix"` // +} + +type NodePublicInfoES struct { + NodeNumber string `json:"nodeNumber"` //节点识别符 + NodeName string `json:"nodeName"` //节点名称 + Types int `json:"type"` //0:发起人;1:审批;2:抄送;3:执行人;4:条件;5:路由 + FromNode string `json:"fromNode"` //来源节点 + GotoNode []string `json:"gotoNode"` //流向节点 + PriorityLevel int `json:"priorityLevel"` // 条件优先级 + Attribute int `json:"attribute"` //属性 1:申请人为基线;2:目标人为基线 + Errors bool `json:"error"` //当前审批是否通过校验 + CcSelfSelectFlag int `json:"ccSelfSelectFlag"` //允许发起人自选抄送人(0:不允许;1:允许) + NodeUserList []NodeUserListInfo `json:"nodeUserList"` //操作人 + ConditionList []ConditionListInfo `json:"conditionList"` //判断条件主体 + ChildNode *NodePublicInfo `json:"childNode"` //子节点 +} + +//节点执行人 +type NodeUserListInfo struct { + FlowPermissionInfo + publicmethod.CommonId[string] + publicmethod.PublicName + Options []OptionsInfo `json:"options"` //可选项(用于关联表单使用) + IsCheckbox bool `json:"isCheckbox"` //结果值多选 +} + +//人员;角色;行政组织;职务通用结构体 +type FlowPermissionInfo struct { + Types int `json:"type"` //1:人员;2:角色;3:行政组织;4:职务 + TargetId string `json:"targetId"` //相关内容识别符 + publicmethod.PublicName //相关内容名称 + Icon string `json:"icon"` //头像 + IconToBase64 string `json:"iconToBase64"` //头像Base64 +} + +//矩阵信息 +type MatrixInfo struct { + MatrixId int64 `json:"matrixid"` + FactorId int64 `json:"factorid"` + OutcomeId int64 `json:"outcomeid"` + MatrixName string `json:"matrixName"` + FactorName string `json:"factorName"` + OutcomeName string `json:"outcomeName"` +} + +//判断条件主体 +type ConditionListInfo struct { + publicmethod.CommonId[int] //条件顺序 + publicmethod.PublicName //条件名称 + Factorid string `json:"factorid"` //条件识别字段 + Types int `json:"type"` //条件类型:1:人员、行政组织、角色;2:自定义字段;3:关联表单字段; + Isok bool `json:"isok"` //页面渲染使用 + IsCheckbox bool `json:"isCheckbox"` //结果值多选 + Options []OptionsInfo `json:"options"` //可选项(用于关联表单使用) + Oneanswer string `json:"oneanswer"` //可选项锚定值(用于关联表单使用) + Answers []string `json:"answers"` //可选项锚定值(用于关联表单使用) + CustomFields []CustomFieldsInfo `json:"customFields"` //自定义字段条件主体 + NodeUserList []FlowPermissionInfo `json:"nodeUserList"` //人员、行政组织、角色为条件主体 +} + +//可选项(用于关联表单使用) +type OptionsInfo struct { + Label string `json:"label"` //名称 + Value string `json:"value"` //值 +} + +//自定义字段条件主体 +type CustomFieldsInfo struct { + Wordfield string `json:"wordfield"` //判断字段 + OptType string `json:"optType"` //判定方法(1:小于;2:大于;3:小于等于;4:等于;5:大于等于;6:介于两数之间;7:包含;8:不包含) + LeftVal string `json:"leftval"` //左侧值 + LeftOptType string `json:"leftoptType"` //OptType值为6时;左侧判定方法 + RightOptType string `json:"rightoptType"` //OptType值为6时;右侧判定方法 + RightVal string `json:"rightval"` //OptType值为6时;右侧值 +} + +//输出工作流相关操作 +type SendFlowInfo struct { + Step int `json:"Step"` //当前执行第几步 + NodeKey string `json:"nodeKey"` //当前节点标识 + NextStep int `json:"nextStep"` //下一步执行第几步 + FlowList []RunFlow `json:"flowList"` //流程主体 +} + +/** +@ 作者: 秦东 +@ 时间: 2023-11-01 09:12:18 +@ 功能: 流程执行体 +*/ +type RunFlow struct { + Step int `json:"step"` //步骤 + Types int `json:"type"` //0:发起节点;1:审批节点;2:抄送;3:执行节点 + NodeKey string `json:"nodeKey"` //节点识别符 + NodeName string `json:"nodeName"` //节点名称 + Status int `json:"status"` //1:未到达;2:已审批;3:已驳回;4:再次审批 + FromNode string `json:"fromnode"` //来至哪个节点 + ArriveNode string `json:"arrivenode"` //到哪个节点 + GoBackNode string `json:"gobacknode"` //驳回返回节点 + ExamineMode int `json:"examinemode"` //多人审批时采用的审批方式。0:无操作 1依次审批 2会签 3:非会签 + NoHanderAction int `json:"nohanderaction"` //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员 + CustomNode string `json:"customNode"` //由哪个节点指定本节点审批人 + JudgeList bool `json:"judgelist"` //是否可自己选中操作人 + Operator []OperatorList `json:"operator"` //操作人 + PendPers []OperatorList `json:"pendpers"` //操作人ssss + RunType int `json:"runtype"` //运行时选择 0:禁闭;1:发起人自选,2:发起人自己,3:有选中得节点指定,4:抄送节点 + RunScope int `json:"runscope"` //运行时选择范围 0:不可选,1:本公司;2:本部门;当RunType = 4时:1:自选;非1:不可自选 + // Operational bool `json:"operational"` //是否可提交审批意见 +} + +//操作人 +type OperatorList struct { + Id string `json:"id"` //操作人ID + Types int `json:"type"` //1:人员;2:角色;3:行政组织 + Name string `json:"name"` //操作人姓名 + Number string `json:"number"` //操作人工号 + Icon string `json:"icon"` //操作人头像 + IconBase64 string `json:"iconbase64"` //操作人头像 + Wechat string `json:"wechat"` //微信Openid + DepartmentId int64 `json:"departmentid"` //分厂Id + DepartmentName string `json:"departmentname"` //分厂名称 + PostId int64 `json:"postid"` //职务Id + PostName string `json:"postname"` //职务名称 + Tema int64 `json:"tema"` //班组Id + TemaName string `json:"temaname"` //班组名称 + LogList []LogList `json:"log"` //操作记录 + NoEdit bool `json:"noedit"` //不可删除 + Tel string `json:"tel"` //电话 + CompanyName string `json:"companyName"` //公司 +} + +// 节点操作人操作记录 +type LogList struct { + State int `json:"state"` //状态 1、未操作;2、通过;3、驳回;4、已查看 + TimeVal string `json:"time"` + Cause string `json:"cause"` //审批意见 + Enclosure []EnclosureFormat `json:"enclosure"` //附件 + UID string `json:"uid"` //当前执行识别符 +} + +// 附件格式 +type EnclosureFormat struct { + FileName string `json:"filename"` //附件名称 + FilePath string `json:"filepath"` //附件地址 + Type int `json:"type"` //附件类型 +} diff --git a/api/version1/taskplatform/taskmanagement/flowType.go b/api/version1/taskplatform/taskmanagement/flowType.go new file mode 100644 index 0000000..7c345e0 --- /dev/null +++ b/api/version1/taskplatform/taskmanagement/flowType.go @@ -0,0 +1,30 @@ +package taskmanagement + +import "appPlatform/overall/publicmethod" + +// 启动流程 +type StartWorkFlow struct { + publicmethod.PublicId + FlowList []RunFlow `json:"flowList"` //流程主体 + State int `json:"state"` //状态状态:1、草稿;2:驳回;3:审批中;4:归档;5:删除 +} + +// 流程执行 +type RunWorkFlow struct { + Step int //执行哪一步 + NextStep int //下一步 + TotalSteps int //总步数 + FlowList []RunFlow //流程 + Participant []string //参与人 + NewFlowList []RunFlow //流程 + Uuid int64 // + RunUid int64 //执行Uid + IsRun bool //是否结束执行 + Msg string //执行说明 +} +type SubmitAppResults struct { + publicmethod.PublicId + AgreeOrRefuse int `json:"agreeOrRefuse"` //1:同意;2:驳回 + Suggest string `json:"suggest"` //审批意见 + FlowList []RunFlow `json:"flowlist"` //执行流程 +} diff --git a/api/version1/taskplatform/taskmanagement/formcontrol.go b/api/version1/taskplatform/taskmanagement/formcontrol.go index 914eb05..3b49914 100644 --- a/api/version1/taskplatform/taskmanagement/formcontrol.go +++ b/api/version1/taskplatform/taskmanagement/formcontrol.go @@ -210,6 +210,12 @@ func WriteSunDatabase(uuid, creater, createrTime int64, masterTableName string, err = errors.New("表单数据提交失败!请重新提交") publicmethod.WriteLog("e", "写入自定义表单", masterTableName, err) } + } else { + gormDb := overall.CONSTANT_DB_CustomerForm + masterErr := gormDb.Table(masterTableName).Create(masterDataCont).Error + if masterErr != nil { + publicmethod.WriteLog("write", "写入自定义表单", masterTableName, masterErr) + } } } else { //子表不存在时,写入主表数据 @@ -768,7 +774,7 @@ func MakeFormMapData(uuid, userKey, cureeTime int64, fieldVal map[string]interfa * @ 作者: 秦东 @ 时间: 2024-04-03 09:40:31 -@ 功能: +@ 功能:用户端自定义表单新增记录(列表新版) @ 参数 # @@ -857,7 +863,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { taskCont.Types = formCont.FlowIsOpen //类型(1:流程表单;2:普通表单)"` taskCont.VersionId = formCont.Id //来源于哪个表单"` taskCont.Status = 2 - if formCont.FlowIsOpen == 2 { + if formCont.FlowIsOpen == 1 { taskCont.Status = 3 taskCont.FlowKey = formCont.Flowkey var flowInfo modelAppPlatform.FlowVersion diff --git a/api/version1/taskplatform/taskmanagement/ruanTask.go b/api/version1/taskplatform/taskmanagement/ruanTask.go new file mode 100644 index 0000000..1400638 --- /dev/null +++ b/api/version1/taskplatform/taskmanagement/ruanTask.go @@ -0,0 +1,2169 @@ +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" + "errors" + "fmt" + "regexp" + "sort" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-03 14:39:53 +@ 功能: 获取任务表单内容 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainTaskFormInfo(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{}{"`masters_key`": requestData.Id}, "`version_id`", "`mastesform`", " `mastesformjson`") + if err != nil { + publicmethod.Result(1, err, c, "未知表单!不可查询") + return + } + 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["structure"] = formVersionInfo + sendData["tableData"] = GainOnlyOneCustomerFormLog(requestData.Id, formVersionInfo.TableKey, formVersionInfo.TableStructure, tableUnitList) + publicmethod.Result(0, sendData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-03 15:33:55 +@ 功能: 获取单一自定义表单详情数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainOnlyOneCustomerFormLog(id, masterTableName, sunTableJson string, tableUnitList customerform.TableFormUnit) map[string]interface{} { + sendData := publicmethod.MapOut[string]() + if masterTableName == "" || id == "" || id == "0" { + return sendData + } + + err := overall.CONSTANT_DB_CustomerForm.Table(masterTableName).Where("`masters_key` = ?", id).Find(&sendData).Error + if err != nil { + return sendData + } + + for i, v := range sendData { + switch i { + case "id": + sendData[i] = publicmethod.TypeToInterface(v) + case "masters_key": + sendData[i] = publicmethod.TypeToInterface(v) + case "creater": + sendData[i] = publicmethod.TypeToInterface(v) + case "creater_time": + sendData[i] = publicmethod.TypeToInterface(v) + case "edit_time": + sendData[i] = publicmethod.TypeToInterface(v) + case "flow_id": + sendData[i] = publicmethod.TypeToInterface(v) + default: + // sendData[i] = v + sendData[i] = ChuLiMasterTableData(i, v, tableUnitList.MasterInfo) + } + } + + if sunTableJson != "" { + sunSqlMap := make(map[string]string) + err = json.Unmarshal([]byte(sunTableJson), &sunSqlMap) + if err == nil { + if len(sunSqlMap) > 0 { + for _, v := range sunSqlMap { + var sunTableData []map[string]interface{} + overall.CONSTANT_DB_CustomerForm.Table(v).Where("`masters_key` = ?", id).Find(&sunTableData) + var sunTableFormInfor []map[string]interface{} + for _, tv := range sunTableData { + sunFormContent := publicmethod.MapOut[string]() + for si, sv := range tv { + switch si { + case "id": + sunFormContent[si] = publicmethod.TypeToInterface(sv) + case "masters_key": + sunFormContent[si] = publicmethod.TypeToInterface(sv) + case "creater": + sunFormContent[si] = publicmethod.TypeToInterface(sv) + case "creater_time": + sunFormContent[si] = publicmethod.TypeToInterface(sv) + case "edit_time": + sunFormContent[si] = publicmethod.TypeToInterface(sv) + case "flow_id": + sunFormContent[si] = publicmethod.TypeToInterface(sv) + default: + if len(tableUnitList.SunFormInfo) > 0 { + isWrite := true + for _, tv := range tableUnitList.SunFormInfo { + if sonUnitCont, ok := tv[v]; ok { + isWrite = false + sunFormContent[si] = ChuLiMasterTableData(si, sv, sonUnitCont) + } + } + if isWrite { + sunFormContent[si] = sv + } + } else { + sunFormContent[si] = sv + } + + } + + } + sunTableFormInfor = append(sunTableFormInfor, sunFormContent) + } + fmt.Printf("sunTableFormInfor----->%v----->%T----->%v\n", v, sunTableFormInfor, sunTableFormInfor) + if len(sunTableFormInfor) > 0 { + sendData[v] = sunTableFormInfor + } else { + sendData[v] = []string{} + } + + } + } + } + } + return sendData +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-08 09:35:44 +@ 功能: 处理主表值 +*/ +func ChuLiMasterTableData(key string, val interface{}, unitCont []customerform.UnitAttribute) interface{} { + for _, uv := range unitCont { + if uv.Key == key { + acValInt, _ := strconv.Atoi(uv.ActiveValue) + // InavalInt, _ := strconv.Atoi(uv.InactiveValue) + switch uv.Class { + case "switch": + // fmt.Printf("switch-->%T---->%v\n", val, val) + switch vData := val.(type) { + case int: + if vData == acValInt { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case int8: + if vData == int8(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case int16: + if vData == int16(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case int32: + if vData == int32(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case int64: + if vData == int64(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case uint: + if int(vData) == acValInt { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case uint8: + if int64(vData) == int64(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case uint16: + if int64(vData) == int64(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case uint32: + if int64(vData) == int64(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case uint64: + if int64(vData) == int64(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case float64: + if vData == float64(acValInt) { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + case string: + if vData == uv.ActiveValue { + return uv.ActiveValue + } else { + return uv.InactiveValue + } + default: + return uv.InactiveValue + } + case "checkbox": + var cbVal []int + if vStr, ok := val.(string); ok { + json.Unmarshal([]byte(vStr), &cbVal) + } + return cbVal + default: + return val + } + } + } + return val +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-05 08:29:09 +@ 功能: 删除任务数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) SoftDeletion(c *gin.Context) { + var requestData BatchDeleteClass + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if len(requestData.Id) < 1 { + publicmethod.Result(100, err, c) + return + } + if requestData.IsTrue == 0 { + requestData.IsTrue = 3 + } + var taskList []customerForm.TaskRecord + err = overall.CONSTANT_DB_CustomerForm.Where("`masters_key` IN ?", requestData.Id).Find(&taskList).Error + if err != nil { + publicmethod.Result(107, err, c) + return + } + for _, v := range taskList { + var tableVersion modelAppPlatform.CustomerFormView + err = tableVersion.GetCont(map[string]interface{}{"`id`": v.VersionId}, "`tablekey`", "`table_structure`") + if err == nil { + EditTablePageInfo(v.MastersKey, requestData.IsTrue, 3, tableVersion.TableKey, tableVersion.TableStructure) + } + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-05 09:15:21 +@ 功能: 删除相关数据 +@ 参数 + + #masterKey 唯一识别符 + #isTrue 是否强制执行 + #state 状态 + #tableKey 自定义主表单 + #sunTableStr 自定义子表单 +*/ +func EditTablePageInfo(masterKey int64, isTrue, state int, tableKey, sunTableStr string) { + publicmethod.WriteLog("write", "处理自定义表单数据状态", isTrue, state, masterKey, tableKey, sunTableStr) + if isTrue != 3 { //软删除 + var taskInfo customerForm.TaskRecord + taskInfo.EiteCont(map[string]interface{}{"`masters_key`": masterKey}, map[string]interface{}{"`status`": state}) + var taskRunInfo customerForm.TaskRunRecord + taskRunInfo.EiteCont(map[string]interface{}{"`flow_key`": masterKey}, map[string]interface{}{"`status`": state}) + + var reviseForm reviseform.EditFormDataLog + reviseForm.EiteCont(map[string]interface{}{"`flow_key`": masterKey}, map[string]interface{}{"`state`": state}) + + overall.CONSTANT_DB_CustomerForm.Table(tableKey).Where("`masters_key` = ?", masterKey).Updates(map[string]interface{}{"`states`": state}) + if sunTableStr != "" { + var sunTable map[string]string + err := json.Unmarshal([]byte(sunTableStr), &sunTable) + if err == nil && len(sunTable) > 0 { + for _, v := range sunTable { + overall.CONSTANT_DB_CustomerForm.Table(v).Where("`masters_key` = ?", masterKey).Updates(map[string]interface{}{"`states`": state}) + } + } + } + } else { //强制删除 + var taskInfo customerForm.TaskRecord + taskInfo.DelCont(map[string]interface{}{"`masters_key`": masterKey}) + var taskRunInfo customerForm.TaskRunRecord + taskRunInfo.DelCont(map[string]interface{}{"`flow_key`": masterKey}) + var reviseForm reviseform.EditFormDataLog + reviseForm.DelCont(map[string]interface{}{"`flow_key`": masterKey}) + sqlStr := fmt.Sprintf("DELETE FROM `%v` WHERE `masters_key` = %v", tableKey, masterKey) + overall.CONSTANT_DB_CustomerForm.Exec(sqlStr) + if sunTableStr != "" { + var sunTable map[string]string + err := json.Unmarshal([]byte(sunTableStr), &sunTable) + if err == nil && len(sunTable) > 0 { + for _, v := range sunTable { + sunSqlStr := fmt.Sprintf("DELETE FROM `%v` WHERE `masters_key` = %v", v, masterKey) + overall.CONSTANT_DB_CustomerForm.Exec(sunSqlStr) + } + } + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-06 15:49:35 +@ 功能: 编辑任务 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) EditCustomerTable(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 + } + masterKey := "" + if masterVal, ok := mapData["masters_key"]; !ok { + publicmethod.Result(1, err, c, "非法表单!不能提交数据!") + return + } else { + if masterValStr, ok := masterVal.(string); ok { + masterKey = masterValStr + } + } + var taskInfo customerForm.TaskRecord + err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": mapData["masters_key"]}) + if err != nil { + publicmethod.Result(1, err, c, "未知任务!不可修改!") + return + } + if taskInfo.Types == 1 { + switch taskInfo.Status { + case 3: + publicmethod.Result(1, err, c, "任务审批中不可执行修改审批") + return + default: + } + } + //获取指定版本表单内容 + var tableVersion modelAppPlatform.CustomerFormVersion + err = tableVersion.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}) + if err != nil { + publicmethod.Result(107, err, c) + return + } + // var formJsonCont customerform.CustomerFormMaster + // json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont) + // var tableUnitList customerform.TableFormUnit + // tableUnitList.AnalysisTableFormUnitAttribute("", formJsonCont.List) + + var sunFormName []string + if tableVersion.TableStructure != "" { //拆解获取子表名称 + var sunFormStruct map[string]string + err = json.Unmarshal([]byte(tableVersion.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) { + switch valAry := v.(type) { + case []interface{}: + if len(valAry) > 0 { + valStrJson, _ := json.Marshal(valAry) + masterField[k] = string(valStrJson) + } else { + masterField[k] = "" + } + default: + masterField[k] = v + } + } else { + sunFieldAry[k] = v + } + } + //获取当前操作人信息 + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + cureeTime := time.Now().Unix() + + masterOldData, err := MasterTableHandle(tableVersion.TableKey, userCont.Key, cureeTime, masterField) + if err != nil { + publicmethod.Result(106, err, c) + return + } + + //自定义表单修改数据历史记录 + var tableEditLog reviseform.EditFormDataLog + masterKeyInt, _ := strconv.ParseInt(masterKey, 10, 64) + tableEditLog.MastersKey = masterKeyInt + tableEditLog.SourceForm = taskInfo.VersionId //来源表单版本 + if len(sunFormName) > 0 { + sonList, err := SonTableHandle(masterKey, userCont.Key, cureeTime, sunFieldAry) + // fmt.Printf("sonList--->%v\n", sonList) + if err == nil { + sunTableList, _ := json.Marshal(sonList) + tableEditLog.SunDataCont = string(sunTableList) //子表数值 + } + } + //是否为流程表单 + if taskInfo.Types == 1 { + var flowInfo customerForm.RunWorkflow + err = flowInfo.GetCont(map[string]interface{}{"`flow_key`": mapData["masters_key"]}) + tableEditLog.FlowKey = flowInfo.FlowKey //流程标识符"` + tableEditLog.RunKey = flowInfo.RunKey //当前执行识别符"` + } + masterTableOldJson, _ := json.Marshal(masterOldData) + tableEditLog.DataCont = string(masterTableOldJson) //主表数据值 + tableEditLog.AddTime = cureeTime //创建时间"` + tableEditLog.State = 1 //状态(1、新数据;2:已批准的老数据)"` + if expval, isOk := mapData["explicate"].(string); isOk { + tableEditLog.Explicate = expval //string 说明"` + } + tableEditLog.EditTime = cureeTime //创建时间"` + tableEditLog.Executor = userCont.Key //:执行人"` + err = overall.CONSTANT_DB_ReviseFormData.Model(&reviseform.EditFormDataLog{}).Create(&tableEditLog).Error + sendInfo := publicmethod.MapOut[string]() + sendInfo["masterField"] = masterField + sendInfo["sunFieldAry"] = sunFieldAry + sendInfo["cureeTime"] = cureeTime + sendInfo["masterKey"] = masterKey + sendInfo["MasterTableHandle"] = masterOldData + sendInfo["err"] = err + publicmethod.Result(0, sendInfo, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 09:15:12 +@ 功能: 编辑处理子表数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func SonTableHandle(masterKey string, creater, cureeTime int64, sunTableMap map[string]interface{}) (map[string]interface{}, error) { + + // fmt.Printf("masterKey--->%v--->%v\n", masterKey, sunTableMap) + + sunTableList := publicmethod.MapOut[string]() + if masterKey == "" { + return sunTableList, errors.New("没有子表数据") + } + if len(sunTableMap) < 1 { + return sunTableList, errors.New("没有子表数据") + } + for i, v := range sunTableMap { + fmt.Printf("sunTableMap--->%v--->%T--->%v\n", i, v, v) + if vMap, ok := v.([]interface{}); ok { + sunTableList[i] = SonTableSaveData(i, masterKey, creater, cureeTime, vMap) + } + } + return sunTableList, nil +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 09:46:30 +@ 功能: 子表数据处理 +@ 参数 + + #sunTableName 子表名称 + #masterKey 数据标识 + #creater 当前操作人 + #cureeTime 执行时间 + #sunDataMap 子表新值 + +@ 返回值 + + #interface 旧值 +*/ +func SonTableSaveData(sunTableName, masterKey string, creater, cureeTime int64, sunDataMap []interface{}) interface{} { + var sunOldTableInfo interface{} + var ddd []map[string]interface{} + overall.CONSTANT_DB_CustomerForm.Table(sunTableName).Where("`masters_key` = ?", masterKey).Find(&ddd) + sunOldTableInfo = ddd + // fmt.Printf("sunOldTableInfo--->%v\n", sunOldTableInfo) + sqlStr := fmt.Sprintf("DELETE FROM `%v` WHERE `masters_key` = %v", sunTableName, masterKey) + err := overall.CONSTANT_DB_CustomerForm.Exec(sqlStr).Error + // fmt.Printf("err--->%T--->%v\n", err, err) + if err == nil { + for _, v := range sunDataMap { + // fmt.Printf("sunOldTableInfo--->%T--->%v\n", v, v) + saveData := publicmethod.MapOut[string]() + if vMap, ok := v.(map[string]interface{}); ok { + for mi, mv := range vMap { + if !publicmethod.RemoveReservedWord(mi) { + if mi == "creater" { + saveData[mi] = creater + } else { + saveData[mi] = mv + } + + } + } + saveData["`masters_key`"] = masterKey + saveData["`edit_time`"] = cureeTime + saveData["`creater_time`"] = cureeTime + saveData["`states`"] = 1 + overall.CONSTANT_DB_CustomerForm.Table(sunTableName).Create(&saveData) + } + } + } + return sunOldTableInfo +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 08:49:19 +@ 功能: 主表数据处理 +@ 参数 + + #tableName 主表名称 + #creater 当前操作人 + #cureeTime 执行时间 + #newsData 新值 + +@ 返回值 + + #map[string]interface{} 旧值 + #error 编辑情况 +*/ +func MasterTableHandle(tableName string, creater, cureeTime int64, newsData map[string]interface{}) (map[string]interface{}, error) { + var oldData map[string]interface{} + if len(newsData) > 0 { + id := "" + editData := publicmethod.MapOut[string]() + for i, v := range newsData { + if i == "id" { + if idStr, ok := v.(string); ok { + id = idStr + } + } + if !publicmethod.RemoveReservedWord(i) { + editData[i] = v + } + } + + err := overall.CONSTANT_DB_CustomerForm.Table(tableName).Where("`id` = ?", id).Find(&oldData).Error + if err != nil { + return oldData, err + } + editData["`edit_time`"] = cureeTime + editData["`creater`"] = creater + editData["`states`"] = 1 + err = overall.CONSTANT_DB_CustomerForm.Table(tableName).Where("`id` = ?", id).Updates(&editData).Error + + return oldData, err + } + return oldData, nil +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 11:04:39 +@ 功能:获取修改记录 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainEditDataLog(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) + } + 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["formUnitCont"] = tableUnitList + + // sendData["tableEditLog"] = tableEditLog + var logAry []map[string]interface{} + for _, v := range tableEditLog { + logCont := publicmethod.MapOut[string]() + if v.DataCont != "" { + mastAry, creater, time, err := AnalysisMsaterLog(v.DataCont, tableUnitList.MasterInfo) + if err == nil { + logCont["masterdata"] = mastAry + logCont["creater"] = creater.Name + logCont["time"] = time + } + } + if v.SunDataCont != "" { + logCont["sunList"], _ = AnalysisSonLog(v.SunDataCont, tableUnitList.SunFormInfo) + } + logAry = append(logAry, logCont) + } + sendData["logAry"] = logAry + publicmethod.Result(0, sendData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 13:48:58 +@ 功能: 解析子表记录 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func AnalysisSonLog(sonDataStr string, sonNameKey []map[string][]customerform.UnitAttribute) (sendData map[string]interface{}, err error) { + var sonMap map[string][]map[string]interface{} + err = json.Unmarshal([]byte(sonDataStr), &sonMap) + // fmt.Printf("sonMap-1-->%T---------->%v---------->%v\n", sonMap, sonMap, sonMap) + sonTableData := publicmethod.MapOut[string]() + for _, v := range sonNameKey { + for si, sv := range v { + // fmt.Printf("sonMap-2-->%T---------->%v---------->%v\n", sv, si, sv) + if sonCont, ok := sonMap[si]; ok { + fmt.Printf("sonMap-5-->%T---------->%v---------->%v\n", sonCont, si, sonCont) + // for mi, mv := range sv { + // fmt.Printf("sonMap-4-->%T---------->%v---------->%v\n", mv, mi, sonCont) + // } + sonTableData[si] = SunTableDataHandel(sonCont, sv) + } + } + + // for _, sv := range sonNameKey { + // fmt.Printf("sonMap--->%T---------->%v---------->%v\n", sv, sv, v) + // if sonKey, ok := sv[i]; ok { + // fmt.Printf("sonMap--->%T---------->%v---------->%v\n", sonKey, sonKey, v) + // } + // } + // if sonKey, ok := sonNameKey[i]; ok { + + // sonTableData[i] = SunTableDataHandel(v, sonKey) + // fmt.Printf("sonMap--->%T---------->%v---------->%v\n", sonTableData, sonTableData, i) + // } + } + sendData = sonTableData + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 14:02:25 +@ 功能: 子表单数据处理 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func SunTableDataHandel(sonMapAry []map[string]interface{}, nameKey []customerform.UnitAttribute) (sendAry []interface{}) { + + for _, v := range sonMapAry { + infoData := publicmethod.MapOut[string]() + for i, v := range v { + for _, uv := range nameKey { + if uv.Key == i { + switch uv.Class { + case "switch": + switch vData := v.(type) { + case float64: + vstr := strconv.FormatFloat(vData, 'f', -1, 64) + if vstr == uv.ActiveValue { + infoData[uv.Name] = uv.ActiveValue + } else { + infoData[uv.Name] = uv.InactiveValue + } + case string: + if vData == uv.ActiveValue { + infoData[uv.Name] = uv.ActiveValue + } else { + infoData[uv.Name] = uv.InactiveValue + } + default: + infoData[uv.Name] = uv.InactiveValue + } + + case "checkbox": + var cbVal []int + if vStr, ok := v.(string); ok { + json.Unmarshal([]byte(vStr), &cbVal) + } + infoData[uv.Name] = cbVal + default: + infoData[uv.Name] = v + } + } + } + } + sendAry = append(sendAry, infoData) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 13:02:07 +@ 功能: 解析主表记录 +@ 参数 + + #dataStr 主表数据值 + #nameKey 主表字段对照 + +@ 返回值 + + #sendData 主表返回值 + #createrInfo 操作人 + #createrTime 操作事件 + #err 状态 + +@ 方法原型 + + # +*/ +func AnalysisMsaterLog(dataStr string, nameKey []customerform.UnitAttribute) (sendData map[string]interface{}, 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 + } + sendConter := make(map[string]interface{}) + for i, v := range dataInfo { + if i == "creater" { + createrInfo.GetCont(map[string]interface{}{"`key`": v}) + } + if i == "edit_time" { + + if timeV, ok := v.(float64); ok { + timeStr := strconv.FormatFloat(timeV, 'f', -1, 64) + timeInt, _ := strconv.ParseInt(timeStr, 10, 64) + createrTime = publicmethod.UnixTimeToDay(timeInt, 27) + } + } + + for _, uv := range nameKey { + + if i == uv.Key { + fmt.Printf("edit_time--->%T--->%v--->%v--->%v--->%v--->%T\n", uv.ActiveValue, i, uv.Key, uv, v, v) + switch uv.Class { + case "switch": + switch vData := v.(type) { + case float64: + vstr := strconv.FormatFloat(vData, 'f', -1, 64) + if vstr == uv.ActiveValue { + // sendConter[uv.Name] = uv.ActiveValue + sendConter[uv.Name] = true + } else { + // sendConter[uv.Name] = uv.InactiveValue + sendConter[uv.Name] = false + } + case string: + if vData == uv.ActiveValue { + sendConter[uv.Name] = true + } else { + sendConter[uv.Name] = false + } + default: + // sendConter[uv.Name] = uv.InactiveValue + sendConter[uv.Name] = false + } + + case "checkbox": + var cbVal []int + if vStr, ok := v.(string); ok { + json.Unmarshal([]byte(vStr), &cbVal) + } + var valAry []string + for _, ov := range uv.Options { + intVal, _ := strconv.Atoi(ov.Value) + if publicmethod.IsInTrue[int](intVal, cbVal) { + if !publicmethod.IsInTrue[string](ov.Label, valAry) { + valAry = append(valAry, ov.Label) + } + } + } + sendConter[uv.Name] = strings.Join(valAry, ",") + default: + sendConter[uv.Name] = v + } + } + } + + } + sendData = sendConter + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 10:29:35 +@ 功能: 添加任务是回显表单数据,若有流程回显流程 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) EchoTableFormPage(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(107, err, c) + return + } + //获取当前启用的表单版本 + var tableFormPage CallBackFormStruct + err = overall.CONSTANT_DB_AppPlatform.Where("`id` = ?", requestData.Id).Find(&tableFormPage).Error + if err != nil { + publicmethod.Result(107, err, c) + return + } + tableFormPage.FlowkeyStr = strconv.FormatInt(tableFormPage.Flowkey, 10) + tableFormPage.CreaterStr = strconv.FormatInt(tableFormPage.Creater, 10) + tableFormPage.IdStr = strconv.FormatInt(tableFormPage.Id, 10) + sendPage := make(map[string]interface{}) + sendPage["tableFormPage"] = tableFormPage + if tableFormPage.FlowIsOpen == 1 { //当为流程表单时。返回流程数据 + var flowPage modelAppPlatform.FlowVersion //获取当前启用的流程信息 + err = flowPage.GetCont(map[string]interface{}{"`key`": tableFormPage.Flowkey, "`state`": 1}) + var flowCont FlowMainBody + var sendInfo SendFlowInfo + if err != nil && flowPage.Content == "" { + sendPage["flowPage"] = sendInfo + } else { + err = json.Unmarshal([]byte(flowPage.Content), &flowCont) //解析流程列表 + if err != nil { + sendPage["flowPage"] = sendInfo + } else { + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //获取当前操作人 + var judgeWhy []ConditionListInfo + var ddd []NodelPeopleInfo + workFlowInfo := flowCont.NodeConfig.CircularParsing(1, userCont, userCont.AdminOrg, judgeWhy, ddd) + // fmt.Printf("workFlowInfo--->%v\n", workFlowInfo) + sendInfo.Step = 1 + sendInfo.NodeKey, sendInfo.NextStep, sendInfo.FlowList = ReformFlow(1, workFlowInfo) + sendPage["flowPage"] = sendInfo + } + } + } else { + sendPage["flowPage"] = "" + } + publicmethod.Result(0, sendPage, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 14:17:31 +@ 功能: 重整工作流步进值 +@ 参数 + + #step 当前在执行第几步 + #nodeList 工作流主体 + +@ 返回值 + + #nodeKey 当前执行节点标识 + #nodeMap 工作流主体 + +@ 方法原型 + + # +*/ +func ReformFlow(step int, nodeList []RunFlow) (nodeKey string, nextStep int, nodeMap []RunFlow) { + sort.Slice(nodeList, func(i, j int) bool { + return nodeList[i].Step < nodeList[j].Step + }) + nodeNum := make(map[int]string) + for i, v := range nodeList { + nodeNum[i] = v.NodeKey + } + for i, v := range nodeList { + if v.Step == step { + nodeKey = v.NodeKey + } + lastStep := step + 1 + if lastStep == v.Step { + nextStep = lastStep + } + var nodeInfo RunFlow + nodeInfo.Step = v.Step //步骤 + nodeInfo.Types = v.Types //0:发起节点;1:审批节点;2:抄送;3:执行节点 + nodeInfo.NodeKey = v.NodeKey //节点识别符 + nodeInfo.NodeName = v.NodeName //节点名称 + nodeInfo.Status = v.Status //1:未到达;2:已审批;3:已驳回;4:再次审批 + if i-1 >= 0 { + nodeInfo.FromNode = nodeNum[i-1] + } + if val, isOk := nodeNum[i+1]; isOk { + nodeInfo.ArriveNode = val //到哪个节点 + } else { + nodeInfo.ArriveNode = "endflow" //到哪个节点 + } + nodeInfo.GoBackNode = v.GoBackNode //驳回返回节点 + nodeInfo.ExamineMode = v.ExamineMode //多人审批时采用的审批方式。0:无操作 1依次审批 2会签 3:非会签 + nodeInfo.NoHanderAction = v.NoHanderAction //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员 + nodeInfo.CustomNode = v.CustomNode //由哪个节点指定本节点审批人 + nodeInfo.JudgeList = v.JudgeList //是否可自己选中操作人 + + var operAry []OperatorList + for _, op := range v.Operator { + var operInfo OperatorList + operInfo.Id = op.Id //操作人ID + operInfo.Types = op.Types //1:人员;2:角色;3:行政组织 + operInfo.Name = op.Name //操作人姓名 + operInfo.Number = op.Number //操作人工号 + operInfo.Icon = op.Icon //操作人头像 + operInfo.IconBase64 = op.IconBase64 //操作人头像 + operInfo.Wechat = op.Wechat //微信Openid + operInfo.DepartmentId = op.DepartmentId //分厂Id + operInfo.DepartmentName = op.DepartmentName //分厂名称 + operInfo.PostId = op.PostId //职务Id + operInfo.PostName = op.PostName //职务名称 + operInfo.Tema = op.Tema //班组Id + operInfo.TemaName = op.TemaName //班组名称 + operInfo.LogList = op.LogList //操作记录 + operInfo.NoEdit = true //不可删除 + operInfo.Tel = op.Tel // + operInfo.CompanyName = op.CompanyName + operAry = append(operAry, operInfo) + } + nodeInfo.Operator = operAry //操作人 + nodeInfo.RunType = v.RunType //运行时选择 0:禁闭;1:发起人自选,2:发起人自己,3:有选中得节点指定,4:抄送节点 + nodeInfo.RunScope = v.RunScope //运行时选择范围 0:不可选,1:本公司;2:本部门;当RunType = 4时:1:自选;非1:不可自选 + nodeInfo.PendPers = v.PendPers // + nodeMap = append(nodeMap, nodeInfo) + } + // nodeMap = nodeList + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 11:20:58 +@ 功能: 无线循环解析节点 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, orgId int64, condition []ConditionListInfo, nodelPeople []NodelPeopleInfo) (nodeList []RunFlow) { + var nodeInfo RunFlow + + nodeInfo.Step = step + nodeInfo.Types = n.Types //0:发起人;1:审批;2:抄送;3:执行人;4:条件;5:路由 当前节点类型 + nodeInfo.NodeKey = n.NodeNumber + nodeInfo.NodeName = n.NodeName + nodeInfo.Status = 1 + nodeInfo.FromNode = n.FromNode + + if n.SendBackNode == "" { + nodeInfo.GoBackNode = "beginnode" + } else { + nodeInfo.GoBackNode = n.SendBackNode + } + nodeInfo.ExamineMode = n.ExamineMode + nodeInfo.NoHanderAction = n.NoHanderAction + //判断节点类型 0:发起人;1:审批;2:抄送;3:执行人;4:条件;5:路由 + switch n.Types { + case 1, 3: + // 审批人设置 1:指定成员; 2:主管;3:行政岗位; 4:发起人自选; 5:发起人自己;6:连续多级主管;7:指定前置审批为本节点设置审批人;8:表单字段;9:权限矩阵 + switch n.Settype { + case 1: //指定成员 + nodeInfo.Operator = OperatorHandle(n.NodeUserList) + case 2: //主管 + var levelUserList ContinuousMultiLevelSupervisor + levelUserList.MaxLevel = n.DirectorLevel + levelUserList.Continuity = false + if n.Attribute == 1 { + //申请人 + nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(creater.AdminOrg) + } else { + //执行部门 + nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(orgId) + } + case 3: //行政岗位 + if n.Attribute == 1 { + nodeInfo.Operator = GainOrgPostUserList(creater.AdminOrg, n.NodeUserList) + } else { + nodeInfo.Operator = GainOrgPostUserList(orgId, n.NodeUserList) + } + case 4: //发起人自选 + nodeInfo.RunType = 1 + nodeInfo.RunScope = n.SelectRange + if n.SelectRange != 1 { + // fmt.Printf("发起人自选--->%v\n--->%v\n", n.SelectRange, OperatorHandle(n.NodeUserList)) + nodeInfo.PendPers = OperatorHandle(n.NodeUserList) + + } + case 5: //发起人自己 + var myCont modelshr.ManCont + myCont.GetCont(map[string]interface{}{"`id`": creater.Id}, "`key`", "`name`", "`number`", "`icon`", "`icon_photo`", "`wechat`", "`work_wechat`", "`admin_org`", "`position`", "`teamid`", "`mobilephone`,`company`") + nodeInfo.Operator = append(nodeInfo.Operator, TransformPublicUs(myCont)) + case 6: //连续多级主管 + var levelUserList ContinuousMultiLevelSupervisor + levelUserList.MaxLevel = n.ExamineEndDirectorLevel + levelUserList.Continuity = true + if n.Attribute == 1 { + //申请人 + nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(creater.AdminOrg) + } else { + //执行部门 + nodeInfo.Operator = levelUserList.ObtainRelevantLevelLeaders(orgId) + } + case 7: //指定前置审批为本节点设置审批人 + nodeInfo.RunType = 3 + nodeInfo.CustomNode = n.CustomNode + case 8: //表单字段 + reg1 := regexp.MustCompile(`\(([^)]+)\)`) //解析()内的数据 + var userNumber []string //工号切片 + for _, v := range n.NodeUserList { //判断本节点需要什么样的表格字段 + for _, e := range nodelPeople { //循环找出提交得表格字段 + if v.Id == e.FactorId { //判断提交得字段是否为当前节点操作字段 + userAry := reg1.FindAllStringSubmatch(e.UserList, -1) //按照正则规则提取数据 + for _, u := range userAry { + vLen := len(u) + if vLen > 0 { + if !publicmethod.IsInTrue[string](u[vLen-1], userNumber) { + userNumber = append(userNumber, u[vLen-1]) //将工号写入数组 + } + } + } + } + } + } + if len(userNumber) > 0 { + nodeInfo.Operator = GainUserCode(userNumber) + } + case 9: //权限矩阵 + if n.Attribute == 1 { + nodeInfo.Operator = GainMatrixUserList(creater.AdminOrg, n.Matrix) + } else { + nodeInfo.Operator = GainMatrixUserList(orgId, n.Matrix) + } + default: + } + // jsonCont, _ := json.Marshal(nodeInfo) + // fmt.Printf("第%v步------>%v\n", step, string(jsonCont)) + nodeList = append(nodeList, nodeInfo) + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition, nodelPeople)...) + } + case 2: + //抄送 + nodeInfo.RunType = 4 + nodeInfo.RunScope = n.CcSelfSelectFlag + nodeInfo.Operator = OperatorHandle(n.NodeUserList) + nodeList = append(nodeList, nodeInfo) + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition, nodelPeople)...) + } + case 4: + case 5: + if len(n.ConditionNodes) > 0 { //判断条件,当节点是路由时有效 + //根据维度序号排序,确定条件执行的优先级 + sort.Slice(n.ConditionNodes, func(i, j int) bool { + return n.ConditionNodes[i].PriorityLevel < n.ConditionNodes[j].PriorityLevel + }) + lastStrp := step + for _, pv := range n.ConditionNodes { //循环解析相关条件 + routerNodes := pv.ResolveRouting(step, creater, orgId, condition, nodelPeople) + if len(routerNodes) > 0 { + lastStrp = lastStrp + len(routerNodes) + nodeList = append(nodeList, routerNodes...) + break + } + } + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(lastStrp, creater, orgId, condition, nodelPeople)...) + } + } else { //无条件时判断有没有下一个节点 + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition, nodelPeople)...) + } + } + default: + nodeInfo.RunType = 0 + //发起人 + var originator OperatorList + originator.Id = strconv.FormatInt(creater.Key, 10) //操作人ID + originator.Types = 1 //1:人员;2:角色;3:行政组织 + originator.Name = creater.Name //操作人姓名 + originator.Number = creater.Number //操作人工号 + originator.Icon = creater.Icon //操作人头像 + originator.IconBase64 = creater.IconPhpto //操作人头像 + originator.Wechat = creater.Wechat //微信Openid + if creater.WorkWechat != "" { + originator.Wechat = creater.WorkWechat //企业微信Openid + } + + _, companyId, _, _, _ := publicmethod.GetOrgStructurees(creater.AdminOrg) + originator.DepartmentId = companyId //分厂Id + if companyId != 0 { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`") + originator.DepartmentName = orgCont.Name //分厂名称 + } + //获取岗位 + if creater.Position != 0 { + var postCont modelshr.Position + postCont.GetCont(map[string]interface{}{"`id`": creater.Position}, "`name`") + originator.PostId = creater.Position //职务Id + originator.PostName = postCont.Name //职务名称 + } + if creater.TeamId != 0 { + var teamCont modelshr.TeamGroup + teamCont.GetCont(map[string]interface{}{"`id`": creater.TeamId}, "`name`") + originator.Tema = creater.TeamId //班组Id + originator.TemaName = teamCont.Name //班组名称 + } + var logCont LogList + logCont.State = 1 //状态 1、未操作;2、通过;3、驳回 + logCont.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1) + // originator.LogList = append(originator.LogList, logCont) //操作记录 + nodeInfo.Operator = append(nodeInfo.Operator, originator) + nodeList = append(nodeList, nodeInfo) + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(step+1, creater, orgId, condition, nodelPeople)...) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:51:49 +@ 功能: 岗位操作人解析 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainOrgPostUserList(orgId int64, approvers []NodeUserListInfo) (UserList []OperatorList) { + if len(approvers) > 0 { + _, companyId, _, _, _ := publicmethod.GetOrgStructurees(orgId) + allOrgId := publicmethod.HaveAllOrgRelation(companyId) //获取全部归属行政单位 + + var userAry MultiLeveUserList + for _, v := range approvers { //逐行分析职务 + if v.Types == 4 { + syncSeting.Add(1) + go userAry.GainOrgPostPeople(allOrgId, v.Options) + } + } + syncSeting.Wait() + UserList = userAry.UserList + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:52:07 +@ 功能: 获取职务相关人员 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (m *MultiLeveUserList) GainOrgPostPeople(orgId []int64, options []OptionsInfo) { + if len(options) > 0 { //判断职务编号 + var postId []int + for i := 0; i < len(options); i++ { + piVal, _ := strconv.Atoi(options[i].Value) + if !publicmethod.IsInTrue[int](piVal, postId) { + postId = append(postId, piVal) + } + } + if len(postId) > 0 { + var userInfoAry []modelshr.ManCont + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`person_in_charge` = 1 AND `admin_org` IN ? AND position IN ? AND `emp_type` BETWEEN ? AND ?", orgId, postId, 1, 10).Find(&userInfoAry) + if len(userInfoAry) > 0 { + for _, uv := range userInfoAry { + m.UserList = append(m.UserList, TransformPublicUs(uv)) + } + } + } + } + defer syncSeting.Done() +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:51:24 +@ 功能: 矩阵拆分 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainMatrixUserList(orgId int64, matrix MatrixInfo) (UserList []OperatorList) { + allOrgId := publicmethod.HaveAllOrgRelation(orgId) //获取全部归属行政单位 + // fmt.Printf("全部行政组织:%v---->%v\n", orgId, allOrgId) + var keyVal int64 + err := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`number`").Where("`types` = 1 AND `mc_id` = ? AND `mh_id` = ? AND `hand_id` IN ?", matrix.MatrixId, matrix.FactorId, allOrgId).First(&keyVal).Error + if err != nil { + return + } + var userKeys []int64 + err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`hand_id`").Where("`types` = 2 AND `mc_id` = ? AND `mh_id` = ? AND `number` = ?", matrix.MatrixId, matrix.OutcomeId, keyVal).Find(&userKeys).Error + if err != nil || len(userKeys) < 1 { + return + } + var userInfoAry []modelshr.ManCont + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`key` IN ? AND `emp_type` BETWEEN ? AND ?", userKeys, 1, 10).Find(&userInfoAry) + if len(userInfoAry) > 0 { + for _, uv := range userInfoAry { + UserList = append(UserList, TransformPublicUs(uv)) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:51:00 +@ 功能: 根据工号获取人员信息 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainUserCode(userNumber []string) (userAry []OperatorList) { + var userInfoAry []modelshr.ManCont + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`number` IN ? AND `emp_type` BETWEEN ? AND ?", userNumber, 1, 10).Find(&userInfoAry) + if len(userInfoAry) > 0 { + for _, uv := range userInfoAry { + userAry = append(userAry, TransformPublicUs(uv)) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:49:42 +@ 功能: 获取单级或多级主管审批人 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (c *ContinuousMultiLevelSupervisor) ObtainRelevantLevelLeaders(orgId int64) (UserList []OperatorList) { + if c.MaxLevel == 0 { + c.MaxLevel = 1 + } + c.ObtainRelevantLevelLeadersUser(1, orgId) + if len(c.UserList) > 0 { + if c.Continuity { //连续层级主管 + sort.Slice(c.UserList, func(i, j int) bool { + return c.UserList[i].Level < c.UserList[j].Level + }) + for _, v := range c.UserList { + UserList = append(UserList, v.UserList...) + } + } else { //单一层级 + for i := c.MaxLevel; i > 0; i-- { + UserList = GainOneLevel(i, c.UserList) + if len(UserList) > 0 { + return + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 11:50:01 +@ 功能: +@ 参数 + + #level 层级 + #UserList 操作人信息 + +@ 返回值 + + #UserAry 操作人列表 + +@ 方法原型 + + # +*/ +func GainOneLevel(level int, UserList []MultiLeveUserList) (UserAry []OperatorList) { + for _, v := range UserList { + if v.Level == level { + UserAry = v.UserList + return + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:50:14 +@ 功能: 循环获取主管层级负责人 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (c *ContinuousMultiLevelSupervisor) ObtainRelevantLevelLeadersUser(level int, orgId int64) { + var orgInfo modelshr.AdministrativeOrganization + err := orgInfo.GetCont(map[string]interface{}{"`id`": orgId}, "`superior`") + if err == nil { + var userList []modelshr.ManCont + err = overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`person_in_charge` = 1 AND `admin_org` = ? AND `emp_type` BETWEEN ? AND ?", orgId, 1, 10).Find(&userList).Error + + if err == nil { + var userAry MultiLeveUserList + userAry.Level = level + for _, v := range userList { + userAry.UserList = append(userAry.UserList, TransformPublicUs(v)) + } + c.UserList = append(c.UserList, userAry) + } + nextLevel := level + 1 + if nextLevel <= c.MaxLevel { + c.ObtainRelevantLevelLeadersUser(nextLevel, orgInfo.Superior) + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:40:59 +@ 功能: 解析条件 +@ 参数 + + #step 步进值 + #creater 当前操作人 + #orgId 执行行政组织 + #condition 判定条件值 + +@ 返回值 + + #nodeList 操作节点 + +@ 方法原型 + + # +*/ +func (n *NodePublicInfoES) ResolveRouting(step int, creater modelshr.ManCont, orgId int64, condition []ConditionListInfo, nodelPeople []NodelPeopleInfo) (nodeList []RunFlow) { + if len(n.ConditionList) > 0 { + termAry := 0 + for _, v := range n.ConditionList { + switch v.Types { //条件类型:1:人员、行政组织、角色;2:自定义字段;3:关联表单字段; + case 1: + if JudgingTermPeoOrgRoles(v.NodeUserList, creater) { //判断申请人是否在可允许范围之内 + termAry++ + } + case 2: + if JudgingCustomConditions(v.CustomFields, condition) { + termAry++ + } + case 3: + if ProcessMultipleSelectionResults(v, condition) { //判断表单 + termAry++ + } + default: + } + } + if termAry == len(n.ConditionList) { + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(step, creater, orgId, condition, nodelPeople)...) + } + } + } else { + if n.ChildNode != nil { + nodeList = append(nodeList, n.ChildNode.CircularParsing(step, creater, orgId, condition, nodelPeople)...) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:46:09 +@ 功能: 处理选择条件 +@ 参数 + + #judging 选择条件 + #presetVal 提交的判断提交 + +@ 返回值 + + #isTrue true:条件符合,验证通过;false:不通过 + +@ 方法原型 + + # +*/ +func ProcessMultipleSelectionResults(judging ConditionListInfo, presetVal []ConditionListInfo) (isTrue bool) { + isTrue = false + if len(presetVal) < 1 { + return + } + for _, v := range presetVal { + if v.Types == 3 && judging.Factorid == v.Factorid { + if judging.IsCheckbox { + //多选 + if len(v.Answers) <= len(judging.Answers) { //判断答案个数是否小于等于设定条件值个数 + isTrue = true + for i := 0; i < len(v.Answers); i++ { + if !publicmethod.IsInTrue[string](v.Answers[i], judging.Answers) { + isTrue = false + } + } + } + } else { //单选 + if v.Oneanswer == judging.Oneanswer { + isTrue = true + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:45:18 +@ 功能: 处理自定义条件 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func JudgingCustomConditions(customFields []CustomFieldsInfo, presetVal []ConditionListInfo) (isTrue bool) { + isTrue = false + if len(presetVal) < 1 { + return + } + var subCustomFields []CustomFieldsInfo + for _, v := range presetVal { + if v.Types == 2 && len(v.CustomFields) > 0 { + subCustomFields = append(subCustomFields, v.CustomFields...) + } + } + if len(subCustomFields) < 1 { + return + } + isOk := 0 + for _, s := range subCustomFields { //提交的条件结果 + for _, c := range customFields { //预设定条件 + if s.Wordfield == c.Wordfield { + + switch c.OptType { + case "1": //小于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal < cLeftVal { + isOk++ + } + } + } + case "2": //大于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal > cLeftVal { + isOk++ + } + } + } + case "3": //小于等于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal <= cLeftVal { + isOk++ + } + } + } + case "4": //等于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal == cLeftVal { + isOk++ + } + } + } + case "5": //大于等于 + sLeftVal, sErr := strconv.ParseFloat(s.LeftVal, 64) + if sErr == nil { + cLeftVal, cErr := strconv.ParseFloat(c.LeftVal, 64) + if cErr == nil { + if sLeftVal >= cLeftVal { + isOk++ + } + } + } + case "6": //介于两个数之间 + leftIsOk := false + rightIsOk := false + sLeftVal, sLErr := strconv.ParseFloat(s.LeftVal, 64) + sRightVal, sRErr := strconv.ParseFloat(s.RightVal, 64) + if sLErr == nil && sRErr == nil { + cLeftVal, cLErr := strconv.ParseFloat(c.LeftVal, 64) + cRightVal, cRErr := strconv.ParseFloat(c.RightVal, 64) + if cLErr == nil && cRErr == nil { + + if c.LeftOptType == "1" { + if sLeftVal > cLeftVal { + leftIsOk = true + } + } else { + if sLeftVal >= cLeftVal { + leftIsOk = true + } + } + if c.RightOptType == "1" { + if sRightVal < cRightVal { + rightIsOk = true + } + } else { + if sRightVal <= cRightVal { + rightIsOk = true + } + } + } + } + if leftIsOk && rightIsOk { + isOk++ + } + case "7": //包含 + setUpValAry := strings.Split(c.LeftVal, ",") + // fmt.Printf("处理自定义条件-abc->%v-->%v-->%v-->%v\n", s.Wordfield, c.Wordfield, setUpValAry, publicmethod.IsInTrue[string](s.LeftVal, setUpValAry)) + if publicmethod.IsInTrue[string](s.LeftVal, setUpValAry) { + isOk++ + } + case "8": //不包含 + setUpValAry := strings.Split(c.LeftVal, ",") + if !publicmethod.IsInTrue[string](s.LeftVal, setUpValAry) { + isOk++ + } + default: + } + } + } + } + // fmt.Printf("处理自定义条件-->%v-->%v\n", isOk, len(customFields)) + if isOk == len(customFields) { + isTrue = true + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:43:38 +@ 功能: 判断路由条件(人员、行政组织、角色)是否满足 +@ 参数 + + #term 预设可操作此节点的人 + #creater 流程发起人 + +@ 返回值 + + #isTrue true:条件符合,验证通过;false:不通过 + +@ 方法原型 + + # +*/ +func JudgingTermPeoOrgRoles(term []FlowPermissionInfo, creater modelshr.ManCont) (isTrue bool) { + isTrue = false + usList := CondToNodeUser(term) + operatorList := OperatorHandle(usList) //获取所有可操作的人 + var usKey []string + for i := 0; i < len(operatorList); i++ { //提取可操作人的唯一识别符 + if !publicmethod.IsInTrue[string](operatorList[i].Id, usKey) { + usKey = append(usKey, operatorList[i].Id) + } + } + creKey := strconv.FormatInt(creater.Key, 10) + if publicmethod.IsInTrue[string](creKey, usKey) { //判断当前操作人是否在可执行人当中 + isTrue = true + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-17 08:12:29 +@ 功能: 转变人员信息 +@ 参数 + + #condition 判断条件中的人员信息 + +@ 返回值 + + #usAry 转变后的人员列表 + +@ 方法原型 + + # +*/ +func CondToNodeUser(condition []FlowPermissionInfo) (usAry []NodeUserListInfo) { + if len(condition) < 1 { + return + } + for _, v := range condition { + var usCont NodeUserListInfo + usCont.Types = v.Types // 1:人员;2:角色;3:行政组织;4:职务 + usCont.TargetId = v.TargetId // /相关内容识别符 + usCont.Name = v.Name //相关内容名称 + usCont.Icon = v.Icon //头像 + usCont.IconToBase64 = v.IconToBase64 //头像Base64 + usAry = append(usAry, usCont) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 13:22:24 +@ 功能: 处理操作人 +@ 参数 + + #userList 节点处理人 + +@ 返回值 + + #userAry 人员列表信息 + +@ 方法原型 + + #func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) +*/ +func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) { + if len(userList) > 0 { + var userIdAry []int64 + for _, v := range userList { + switch v.Types { //1:人员;2:角色;3:行政组织 + case 1: + myKey, myErr := strconv.ParseInt(v.TargetId, 10, 64) + if myErr == nil { + userIdAry = append(userIdAry, myKey) + } + case 2: //角色 + var usIdList []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("FIND_IN_SET(?,`role`) AND `emp_type` BETWEEN ? AND ?", v.TargetId, 1, 10).Find(&usIdList) + if len(usIdList) > 0 { + userIdAry = append(userIdAry, usIdList...) + } + case 3: //行政组织 + myKey, myErr := strconv.ParseInt(v.TargetId, 10, 64) + if myErr == nil { + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSonAllId(myKey) + sunOrg.Id = append(sunOrg.Id, myKey) + var usIdList []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("`admin_org` IN ? AND `emp_type` BETWEEN ? AND ?", sunOrg.Id, 1, 10).Find(&usIdList) + if len(usIdList) > 0 { + userIdAry = append(userIdAry, usIdList...) + } + } + + default: + } + } + var userContMap []modelshr.ManCont + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`key` IN ?", userIdAry).Find(&userContMap) + for _, v := range userContMap { + userAry = append(userAry, TransformPublicUs(v)) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-11-15 11:37:00 +@ 功能: 装通用执行人数据 +@ 参数 + + #v 人员信息 + +@ 返回值 + + #userCont 统一操作人信息 + +@ 方法原型 + + # +*/ +func TransformPublicUs(v modelshr.ManCont) (userCont OperatorList) { + userCont.Id = strconv.FormatInt(v.Key, 10) + userCont.Types = 1 //1:人员;2:角色;3:行政组织 + userCont.Name = v.Name //操作人姓名 + userCont.Number = v.Number //操作人工号 + userCont.Icon = v.Icon //操作人头像 + userCont.IconBase64 = v.IconPhpto //操作人头像 + userCont.Wechat = v.Wechat //微信Openid、 + userCont.Tel = v.Mobilephone + if v.WorkWechat != "" { + userCont.Wechat = v.WorkWechat //微信Openid + } + if v.Company != 0 { + var orgGroupCont modelshr.AdministrativeOrganization + orgGroupCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") + userCont.CompanyName = orgGroupCont.Name //公司名称 + } + _, companyId, _, _, _ := publicmethod.GetOrgStructurees(v.AdminOrg) + userCont.DepartmentId = companyId //分厂Id + if companyId != 0 { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`") + userCont.DepartmentName = orgCont.Name //分厂名称 + } + //获取岗位 + if v.Position != 0 { + var postCont modelshr.Position + postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`") + userCont.PostId = v.Position //职务Id + userCont.PostName = postCont.Name //职务名称 + } + if v.TeamId != 0 { + var teamCont modelshr.TeamGroup + teamCont.GetCont(map[string]interface{}{"`id`": v.TeamId}, "`name`") + userCont.Tema = v.TeamId //班组Id + userCont.TemaName = teamCont.Name //班组名称 + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 15:27:46 +@ 功能: 根据表单数据实时更新流程 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) RealTimeUpdateFlow(c *gin.Context) { + var requestData CreatFlowView + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(10001, err, c) + return + } + if requestData.Step == 0 { + requestData.Step = 1 + } + var flowPage modelAppPlatform.FlowVersion + err = flowPage.GetCont(map[string]interface{}{"`key`": requestData.Id, "`state`": 1}) + if err != nil && flowPage.Content == "" { + publicmethod.Result(107, err, c) + return + } + var flowCont FlowMainBody + var sendInfo SendFlowInfo + err = json.Unmarshal([]byte(flowPage.Content), &flowCont) //解析流程列表 + if err != nil && flowPage.Content == "" { + publicmethod.Result(107, err, c) + return + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //获取当前操作人 + + workFlowInfo := flowCont.NodeConfig.CircularParsing(1, userCont, userCont.AdminOrg, requestData.ConditionList, requestData.NodelPeople) + // fmt.Printf("workFlowInfo--->%v\n", workFlowInfo) + sendInfo.Step = requestData.Step + sendInfo.NodeKey, sendInfo.NextStep, sendInfo.FlowList = ReformFlow(requestData.Step, workFlowInfo) + + if len(sendInfo.FlowList) > 0 && len(requestData.OldFlow) > 0 { + for i, v := range sendInfo.FlowList { + for _, ov := range requestData.OldFlow { + if v.NodeKey == ov.NodeKey { + if len(v.Operator) < 1 && len(ov.Operator) > 0 { + sendInfo.FlowList[i].Operator = ov.Operator + } else if len(v.Operator) > 0 && len(ov.Operator) > 0 { + sendInfo.FlowList[i].Operator = SlicingAndDeduplication(v.Operator, ov.Operator) + } + } + } + } + } + publicmethod.Result(0, sendInfo, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 15:47:35 +@ 功能: 切片去重 +*/ +func SlicingAndDeduplication(new, old []OperatorList) (mapAry []OperatorList) { + var isInAry []string + if len(new) > 0 { + for _, v := range new { + if !publicmethod.IsInTrue[string](v.Id, isInAry) { + isInAry = append(isInAry, v.Id) + mapAry = append(mapAry, v) + } + } + } + if len(old) > 0 { + for _, v := range old { + if !publicmethod.IsInTrue[string](v.Id, isInAry) { + isInAry = append(isInAry, v.Id) + mapAry = append(mapAry, v) + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-11 10:00:57 +@ 功能: 撤回已申请的工作流 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) RetractRunWorkFlow(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 runFlowInfo customerForm.RunWorkflow + err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`") + 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, ",") + } + } + + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //获取当前操作人 + + var flowList []RunFlow + json.Unmarshal([]byte(runFlowInfo.FlowCont), &flowList) + userKey := strconv.FormatInt(userCont.Key, 10) + if len(flowList) > 0 { + stepVal := runFlowInfo.CurrentStep - 1 + if stepVal < 0 { + stepVal = 0 + } + operatorAry, _ := FindOperator(userKey, runFlowInfo.RunKey, 3, flowList[stepVal].Operator, "主动测回") + flowList[stepVal].Operator = operatorAry + fmt.Printf("operatorAry------------>%v\n", operatorAry) + saveFlowInfo["`flow_cont`"], _ = json.Marshal(flowList) + + FlowRunLog(runFlowInfo.FlowKey, userCont.Key, 1, flowList[stepVal].NodeKey, "撤回申请", "") + } else { + FlowRunLog(runFlowInfo.FlowKey, userCont.Key, 1, "", "撤回申请", "") + } + + var runEditFlowInfo customerForm.RunWorkflow + err = runEditFlowInfo.EiteCont(map[string]interface{}{"`flow_key`": requestData.Id}, saveFlowInfo) + if err != nil { + publicmethod.Result(106, err, c) + return + } + var taskInfo customerForm.TaskRecord + taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTaskInfo) + + publicmethod.Result(0, err, c) +} diff --git a/api/version1/taskplatform/taskmanagement/runWorkFlow.go b/api/version1/taskplatform/taskmanagement/runWorkFlow.go new file mode 100644 index 0000000..19564ab --- /dev/null +++ b/api/version1/taskplatform/taskmanagement/runWorkFlow.go @@ -0,0 +1,1551 @@ +package taskmanagement + +import ( + "appPlatform/models/customerForm" + "appPlatform/models/flowlog" + "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" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 08:26:53 +@ 功能: 发起流程 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) StartRunWorkFlow(c *gin.Context) { + var requestData StartWorkFlow + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(10001, err, c, "未知进程!不可执行") + return + } + if requestData.Id == "" { + var taskInfo customerForm.TaskRecord + taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 1}) + publicmethod.Result(10001, err, c, "未知进程!不可执行") + return + } + if len(requestData.FlowList) < 1 { + var taskInfo customerForm.TaskRecord + taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": 1}) + publicmethod.Result(10001, 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 taskInfo customerForm.TaskRecord + taskInfo.GetCont(map[string]interface{}{"`masters_key`": requestData.Id}, "`flow_key`", "`flow_run_sing`") + //获取流程详情 + 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 = requestData.State //状态: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 + if requestData.State == 3 { + executeWorkflow.GainRunNode(startCreaterKey, 2, "发起审批") + } else { + executeWorkflow.GainRunNode(startCreaterKey, 1, "") + } + flowJsonCont, _ := json.Marshal(executeWorkflow.FlowList) //将步进流转化成json流 + workFlowInfo.FlowCont = string(flowJsonCont) //流程执行体 + if requestData.State == 3 { + 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`": requestData.Id}, 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`": requestData.Id}, map[string]interface{}{"`status`": 4}) + } else { + var taskCont customerForm.TaskRecord + taskCont.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, map[string]interface{}{"`status`": requestData.State}) + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 09:50:37 +@ 功能: 获取下一步执行人 +@ 参数 + + #isTrue 1:本节点审批完毕;非1:本节点还有未操作的人 + +@ 返回值 + + #userAry 下一步执行人 + +@ 方法原型 + + # +*/ +func (r *RunWorkFlow) NextRunNodeUser(isTrue int) (userAry []string) { + if r.NextStep <= 0 { + return + } + if isTrue == 1 { + curStep := r.Step + 1 + if curStep > r.TotalSteps { + curStep = r.TotalSteps + } + for _, v := range r.FlowList { + if v.Step == curStep { + for _, op := range v.Operator { + if !publicmethod.IsInTrue[string](op.Id, userAry) { + userAry = append(userAry, op.Id) + } + } + } + } + } else { + if r.Step == 1 { + return + } + for _, v := range r.FlowList { + if v.Step == r.Step { + for _, op := range v.Operator { + if !publicmethod.IsInTrue[string](op.Id, userAry) { + userAry = append(userAry, op.Id) + } + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 09:03:40 +@ 功能: 执行工作流 +@ 参数 + + #userKey //当前执行人 + #AgreeToRefuse 同意或者驳回 + #runCont //执行意见 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (r *RunWorkFlow) GainRunNode(userKey string, AgreeToRefuse int, runCont string) { + userkInt, _ := strconv.ParseInt(userKey, 10, 64) //将字符型转换成64位整型 + curStep := 1 + if r.Step != 0 { + curStep = r.Step + } + for i := 0; i < r.TotalSteps; i++ { + if r.FlowList[i].Step == curStep { //获取正在执行得节点 + currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i]) //获取当前步进值和下一步步进值 + operatorAry, nodeUser := FindOperator(userKey, r.RunUid, AgreeToRefuse, r.FlowList[i].Operator, runCont) + r.FlowList[i].Operator = operatorAry + r.FlowList[i].Status = AgreeToRefuse + r.Participant = append(r.Participant, nodeUser...) + switch r.FlowList[i].Types { //0:发起节点;1:审批节点;2:抄送;3:执行节点 + case 0: + r.Step = currentStep + r.NextStep = nextStep + FlowRunLog(r.Uuid, userkInt, AgreeToRefuse, r.FlowList[i].NodeKey, runCont, "") + if JudgeRunNode(currentStep, r.FlowList) { + r.GainRunNode(userKey, AgreeToRefuse, runCont) + } + return + case 1: + r.Step = currentStep + r.NextStep = nextStep + return + case 2: + r.Step = currentStep + r.NextStep = nextStep + for _, op := range r.FlowList[i].Operator { + userkIntId, _ := strconv.ParseInt(op.Id, 10, 64) + title := fmt.Sprintf("向%v发送抄送数据", op.Name) + FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "") + } + if r.NextStep > 0 { + r.GainRunNode(userKey, AgreeToRefuse, runCont) + } + return + case 3: + r.Step = currentStep + r.NextStep = nextStep + return + default: + } + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 09:41:46 +@ 功能: 判断当前节点是否要继续执行 +@ 参数 + + #step 当前步进值 + #FlowList 流程内容 + +@ 返回值 + + #isRun 是否继续执行 + +@ 方法原型 + + # +*/ +func JudgeRunNode(step int, FlowList []RunFlow) (isRun bool) { + isRun = false + for _, v := range FlowList { + if v.Step == step { + if v.Types == 2 { + isRun = true + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 09:37:01 +@ 功能: 流程执行记录 +@ 参数 + + #uuid 流程uuid + #userKey 操作人 + #AgreeToRefuse 同意或者驳回 + #nodeKey 操作得节点 + #idea 意见 + #annex 附件 + +@ 返回值 + + # + +@ 方法原型 + + #func FlowRunLog(uuid, userKey int64, AgreeToRefuse int, nodeKey, idea, annex string) +*/ +func FlowRunLog(uuid, userKey int64, AgreeToRefuse int, nodeKey, idea, annex string) { + creetTime := time.Now().Unix() + var flowRunLog flowlog.WorkFlowLog + flowRunLog.FlowId = uuid //执行的流程"` + flowRunLog.Creater = userKey //操作人"` + flowRunLog.Status = AgreeToRefuse //状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"` + flowRunLog.Content = idea //审批意见"` + flowRunLog.Annex = annex //附件"` + flowRunLog.Time = creetTime //创建时间"` + flowRunLog.EditTime = creetTime //ault编辑时间"` + flowRunLog.NodeKey = nodeKey //操作得节点 + flowRunLog.WriteCont() +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 09:28:28 +@ 功能: 操作人操作记录处理 +@ 参数 + + #userKey 操作人 + #runUid 执行Uid + #AgreeToRefuse 同意或者驳回 + #operator 当前节点操作人 + #suggest 审批意见 + +@ 返回值 + + #OperatorAry 操作人信息 + #nodeUser 操作人唯一识别符 + +@ 方法原型 + + # +*/ +func FindOperator(userKey string, runUid int64, AgreeToRefuse int, operator []OperatorList, suggest string) (OperatorAry []OperatorList, nodeUser []string) { + var logInfo LogList + logInfo.State = AgreeToRefuse //状态 1、未操作;2、通过;3、驳回 + logInfo.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1) + logInfo.UID = strconv.FormatInt(runUid, 10) + logInfo.Cause = suggest + isNewAdd := true + for _, v := range operator { + nodeUser = append(nodeUser, v.Id) + if v.Id == userKey && AgreeToRefuse != 1 { + v.LogList = append(v.LogList, logInfo) + isNewAdd = false + } + OperatorAry = append(OperatorAry, v) + } + if isNewAdd { + var myInfo modelshr.ManCont + myInfo.GetCont(map[string]interface{}{"`key`": userKey}) + nodeMan := TransformPublicUs(myInfo) + nodeMan.LogList = append(nodeMan.LogList, logInfo) + OperatorAry = append(OperatorAry, nodeMan) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 09:15:45 +@ 功能: 计算工作流执行得步伐 +@ 参数 + + #runId 执行工作流唯一识别符 + #step 当前执行得步进值 + #totalSteps 总步数 + #nodeInfo 节点内容 + +@ 返回值 + + #currentStep 当前步进值 + #nextStep 下一步步进值 + +@ 方法原型 + + #func PaceStep(runId int64, step, totalSteps int, nodeInfo RunFlow) (currentStep, nextStep int) +*/ +func PaceStep(runId int64, step, totalSteps int, nodeInfo RunFlow) (currentStep, nextStep int) { + if nodeInfo.ExamineMode == 0 { //多人审批时采用的审批方式。0:无操作 1依次审批 2会签 3:非会签 + + } + switch nodeInfo.ExamineMode { + case 0: + if step >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + + currentStep = step + 1 + if currentStep >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + nextStep = currentStep + 1 + if nextStep >= totalSteps { + nextStep = totalSteps + } + case 3: + if step >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + currentStep = step + if currentStep >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + nextStep = currentStep + 1 + if nextStep >= totalSteps { + nextStep = totalSteps + } + default: + runIdStr := strconv.FormatInt(runId, 10) + allUser := len(nodeInfo.Operator) + jiBuQi := 1 + for _, v := range nodeInfo.Operator { + for _, m := range v.LogList { + if m.UID == runIdStr { + jiBuQi++ + } + } + } + if allUser <= jiBuQi { //全部审批完毕 + if step >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + currentStep = step + 1 + if currentStep >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + nextStep = currentStep + 1 + if nextStep >= totalSteps { + nextStep = totalSteps + } + } else { + currentStep = step - 1 + if currentStep <= 0 { + currentStep = 1 + } + if currentStep >= totalSteps { + currentStep = totalSteps + nextStep = 0 + return + } + nextStep = currentStep + 1 + if nextStep >= totalSteps { + nextStep = totalSteps + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 10:28:37 +@ 功能: 从草稿箱发起审批 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) DraftsInitiateApproval(c *gin.Context) { + var requestData StartWorkFlow + 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 customerForm.RunWorkflow + 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 customerForm.RunWorkflow + err = saveRunInfo.EiteCont(map[string]interface{}{"`flow_key`": requestData.Id}, saveFlow) + if err != nil { + publicmethod.Result(106, err, c) + return + } + var saveTaskInfo customerForm.TaskRecord + saveTaskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTask) + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 12:58:51 +@ 功能: 获取正在执行得任务流程 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainRunTaskWorkflow(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 runFlowInfo customerForm.RunWorkflow + err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}) + if err != nil || runFlowInfo.FlowCont == "" { + publicmethod.Result(107, err, c) + return + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + var flowList []RunFlow + err = json.Unmarshal([]byte(runFlowInfo.FlowCont), &flowList) + if err != nil { + publicmethod.Result(107, err, c) + return + } + //判断是否需要回写流程记录 + 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 + sendMap["current_step"] = runFlowInfo.CurrentStep + publicmethod.Result(0, sendMap, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 13:01:12 +@ 功能: 检查当前人抄送是否查看 +@ 参数 + + #uuid 流程唯一识别符 + #endStep 当前步进值 + #flowList 流程列表 + #userCont 人员信息 + +@ 返回值 + + #flowMap 流程 + #operational 是否可操作 + +@ 方法原型 + + # +*/ +func CheckMakeCopy(uuid, runKey int64, state int, currepStep int, flowList []RunFlow, userCont modelshr.ManCont) (flowMap []RunFlow, operational bool) { + if len(flowList) < 1 { + return + } + endStep := currepStep + 1 + if endStep >= len(flowList) { + endStep = len(flowList) + } + operational = false + isWrite := false + userKey := strconv.FormatInt(userCont.Key, 10) + var cureeNode RunFlow + for i := 0; i < len(flowList); i++ { //梳理抄送节点 + if flowList[i].Step == endStep { + + cureeNode = flowList[i] + switch flowList[i].ExamineMode { + case 1: + operational = ApprovalInSequence(flowList[i].Operator, userCont) + case 2: + operational = NotSignJointly(runKey, state, flowList[i].Operator, userCont) + case 3: + operational = NotSignJointly(runKey, state, flowList[i].Operator, userCont) + default: + for m := 0; m < len(flowList[i].Operator); m++ { + if flowList[i].Operator[m].Id == userKey { + operational = true + } + } + } + // fmt.Printf("currepStep:%v---->endStep:%v\n", flowList[i].ExamineMode, operational) + } + if flowList[i].Types != 0 { + if flowList[i].Step <= endStep { + if flowList[i].Types == 2 { + flowList[i].RunType = 0 + flowList[i].RunScope = 0 + for j := 0; j < len(flowList[i].Operator); j++ { + if flowList[i].Operator[j].Id == userKey { + if len(flowList[i].Operator[j].LogList) < 1 { + var logCont LogList + logCont.State = 4 //状态 1、未操作;2、通过;3、驳回 + logCont.TimeVal = publicmethod.UnixTimeToDay(time.Now().Unix(), 1) + flowList[i].Operator[j].LogList = append(flowList[i].Operator[j].LogList, logCont) //操作记录 + isWrite = true + FlowRunLog(uuid, userCont.Key, 6, flowList[i].NodeKey, "查看抄送内容", "") + } + } + } + + } + } + } + } + if isWrite { + flowJson, _ := json.Marshal(flowList) + var runFlowInfo modelAppPlatform.RunFlow + runFlowInfo.EiteCont(map[string]interface{}{"`flow_key`": uuid}, map[string]interface{}{"`flow_cont`": string(flowJson)}) + } + // fmt.Printf("cureeNode.CustomNode =====> %v\n", cureeNode.NodeKey) + timeStep := endStep - 1 + if timeStep <= 0 { + timeStep = 1 + } + // fmt.Printf("operational--->%v\n", operational) + if operational { + for k := 0; k < len(flowList); k++ { + if flowList[k].Step <= endStep { + flowList[k].RunType = 0 + flowList[k].RunScope = 0 + + } + + if flowList[k].Step >= endStep { + + if flowList[k].CustomNode == cureeNode.NodeKey { + if flowList[k].RunScope == 0 { + flowList[k].RunScope = 1 + } + // fmt.Printf("cureeNode.CustomNode =====> %v =====> %v =====> %v =====> %v\n", flowList[k].Step, endStep, flowList[k].CustomNode == cureeNode.NodeKey, flowList[timeStep].Operator) + + for j := 0; j < len(flowList[timeStep].Operator); j++ { + + if flowList[timeStep].Operator[j].Id == userKey { + flowList[k].JudgeList = true + } + } + + } + } + } + } else { + for k := 0; k < len(flowList); k++ { + flowList[k].JudgeList = false + } + } + flowMap = flowList + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 13:04:49 +@ 功能: 处理非会签情况 +@ 参数 + + #Operator 节点操作人 + #userCont 当前操作人 + +@ 返回值 + + #bool //是否可以操作 + +@ 方法原型 + + # +*/ +func NotSignJointly(runKey int64, state int, Operator []OperatorList, userCont modelshr.ManCont) bool { + if len(Operator) < 1 { + return false + } + if state != 3 { + return false + } + userKey := strconv.FormatInt(userCont.Key, 10) + runKeyStr := strconv.FormatInt(runKey, 10) + for _, v := range Operator { + if v.Id == userKey { + for _, lv := range v.LogList { + if lv.UID == runKeyStr { + return false + } + } + return true + } + } + + return false +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-10 13:03:20 +@ 功能: 依次审批 +@ 参数 + + #Operator 操作人 + #userCont 当前执行人 + +@ 返回值 + + #bool //是否可以操作 + +@ 方法原型 + + # +*/ +func ApprovalInSequence(Operator []OperatorList, userCont modelshr.ManCont) bool { + allAry := len(Operator) + + if allAry < 1 { + return false + } + + userKey := strconv.FormatInt(userCont.Key, 10) + if allAry == 1 { + for _, v := range Operator { + if v.Id == userKey { + return true + } + } + } + minVal := 0 + for _, v := range Operator { + if minVal <= len(v.LogList) { + minVal = len(v.LogList) + } + } + // fmt.Printf("依次审批--a-->%v---->%v---->%v\n", minVal, len(Operator), allAry) + if minVal == 0 { + for i, v := range Operator { + // fmt.Printf("依次审批---->%v---->%v\n", i, v.Name) + if v.Id == userKey { + if i == 0 { + return true + } + } + } + return false + } + + endTrue := true + if allAry >= 2 { + for i := 0; i < allAry-2; i++ { + if len(Operator[i].LogList) <= minVal && len(Operator[i].LogList) <= len(Operator[i+1].LogList) { + if Operator[i].Id == userKey { + endTrue = false + return true + } + } + } + } + + if endTrue { + if Operator[allAry-1].Id == userKey { + return true + } + } + return false +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-11 11:05:04 +@ 功能: 重新发起流程 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) AfreshRunWorkflow(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 runFlowInfo customerForm.RunWorkflow + err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}, "`id`", "`next_executor`", "`current_step`", "`next_step`", "`participants`", "`flow_key`", "`flow_cont`", "`runKey`") + if err != nil { + publicmethod.Result(107, err, c) + return + } + var flowList []RunFlow + err = json.Unmarshal([]byte(runFlowInfo.FlowCont), &flowList) + if err != nil { + publicmethod.Result(107, err, c) + return + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人 + runUuId := publicmethod.GetUUid(6) + //执行流程 + var runFlow 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 + } + var taskInfo customerForm.TaskRecord + saveTask := publicmethod.MapOut[string]() + saveTask["`status`"] = 3 + saveTask["`edit_time`"] = time.Now().Unix() + taskInfo.EiteCont(map[string]interface{}{"`masters_key`": requestData.Id}, saveTask) + publicmethod.Result(0, runFlowInfo, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-11 11:42:29 +@ 功能: 申请修改数据 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) ApplyForTableFormData(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 + } + masterKey := "" + if masterVal, ok := mapData["masters_key"]; !ok { + publicmethod.Result(1, err, c, "非法表单!不能提交数据!") + return + } else { + if masterValStr, ok := masterVal.(string); ok { + masterKey = masterValStr + } + } + var taskInfo customerForm.TaskRecord + err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": mapData["masters_key"]}) + if err != nil { + publicmethod.Result(1, err, c, "未知任务!不可修改!") + return + } + if taskInfo.Types == 1 { + switch taskInfo.Status { + case 3: + publicmethod.Result(1, err, c, "任务审批中不可执行修改审批") + return + default: + } + } + //获取指定版本表单内容 + var tableVersion modelAppPlatform.CustomerFormVersion + err = tableVersion.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}) + if err != nil { + publicmethod.Result(107, err, c) + return + } + // var formJsonCont customerform.CustomerFormMaster + // json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont) + // var tableUnitList customerform.TableFormUnit + // tableUnitList.AnalysisTableFormUnitAttribute("", formJsonCont.List) + + var sunFormName []string + if tableVersion.TableStructure != "" { //拆解获取子表名称 + var sunFormStruct map[string]string + err = json.Unmarshal([]byte(tableVersion.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) { + switch valAry := v.(type) { + case []interface{}: + if len(valAry) > 0 { + valStrJson, _ := json.Marshal(valAry) + masterField[k] = string(valStrJson) + } else { + masterField[k] = "" + } + default: + masterField[k] = v + } + } else { + sunFieldAry[k] = v + } + } + //获取当前操作人信息 + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + cureeTime := time.Now().Unix() + + masterOldData, err := MasterTableHandle(tableVersion.TableKey, userCont.Key, cureeTime, masterField) + if err != nil { + publicmethod.Result(106, err, c) + return + } + + //自定义表单修改数据历史记录 + var tableEditLog reviseform.EditFormDataLog + masterKeyInt, _ := strconv.ParseInt(masterKey, 10, 64) + tableEditLog.MastersKey = masterKeyInt + tableEditLog.SourceForm = taskInfo.VersionId //来源表单版本 + if len(sunFormName) > 0 { + sonList, err := SonTableHandle(masterKey, userCont.Key, cureeTime, sunFieldAry) + // fmt.Printf("sonList--->%v\n", sonList) + if err == nil { + sunTableList, _ := json.Marshal(sonList) + tableEditLog.SunDataCont = string(sunTableList) //子表数值 + } + } + runUuId := publicmethod.GetUUid(6) + //启动流程 + var flowInfo customerForm.RunWorkflow + flowInfo.GetCont(map[string]interface{}{"`flow_key`": mapData["masters_key"]}) + //是否为流程表单 + if taskInfo.Types == 1 { + tableEditLog.FlowKey = flowInfo.FlowKey //流程标识符"` + tableEditLog.RunKey = runUuId //当前执行识别符"` + } + masterTableOldJson, _ := json.Marshal(masterOldData) + tableEditLog.DataCont = string(masterTableOldJson) //主表数据值 + tableEditLog.AddTime = cureeTime //创建时间"` + tableEditLog.State = 1 //状态(1、新数据;2:已批准的老数据)"` + if expval, isOk := mapData["explicate"].(string); isOk { + tableEditLog.Explicate = expval //string 说明"` + } + tableEditLog.EditTime = cureeTime //创建时间"` + tableEditLog.Executor = userCont.Key //:执行人"` + err = overall.CONSTANT_DB_ReviseFormData.Model(&reviseform.EditFormDataLog{}).Create(&tableEditLog).Error + + if err == nil { + startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人 + var flowList []RunFlow + 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 = 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() + flowInfo.EiteCont(map[string]interface{}{"`flow_key`": flowInfo.FlowKey}, SaveFlowCont) + taskInfo.EiteCont(map[string]interface{}{"`masters_key`": flowInfo.FlowKey}, map[string]interface{}{"`status`": 3}) + } + sendInfo := publicmethod.MapOut[string]() + sendInfo["masterField"] = masterField + sendInfo["sunFieldAry"] = sunFieldAry + sendInfo["cureeTime"] = cureeTime + sendInfo["masterKey"] = masterKey + sendInfo["MasterTableHandle"] = masterOldData + sendInfo["err"] = err + publicmethod.Result(0, sendInfo, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-11 13:33:39 +@ 功能: 审批处理 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) AuthorizeWorkflow(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["`flow_key`"] = 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 runFlow RunWorkFlow + runFlow.Step = flowInfo.CurrentStep + 1 //执行第几部 + runFlow.NextStep = 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.FlowStepRun(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, ",") + //下一步执行人 + 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("`masters_key` = ?", 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-04-11 13:48:40 +@ 功能: 判断是不是修改流程 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +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 customerForm.TaskRecord + 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) + } + } + } + sunOldData := publicmethod.MapOut[string]() + //处理子表数据 + if logDataInfo.SunDataCont != "" { + sunTableInfo := publicmethod.MapOut[string]() + json.Unmarshal([]byte(logDataInfo.SunDataCont), &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) + } + } + } + var oldDataSun []map[string]interface{} //子表老数据 + overall.CONSTANT_DB_CustomerForm.Table(i).Where("`masters_key` = ?", flowKey).Find(&oldDataSun) + sunOldData[i] = oldDataSun + var oldSunTableIdMAp []int64 + for _, oldv := range oldDataSun { + + if sunId, iskk := oldv["id"]; iskk { + 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) + } + } + } + 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) + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-11 13:38:58 +@ 功能: 流程处理 +@ 参数 + + #userKey 当前处理人 + #AgreeToRefuse 1:同意,2:驳回 + #Suggest 审批意见 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (r *RunWorkFlow) FlowStepRun(userKey int64, AgreeToRefuse int, Suggest string) { + if len(r.FlowList) < 1 { + return + } + userKeyStr := strconv.FormatInt(userKey, 10) + for i := 0; i < r.TotalSteps; i++ { + if r.FlowList[i].Step == r.Step { + //判断操作人是有操作权限或是否已经操作过 + 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) + return + } else { //同意操作 + currentStep, nextStep := PaceStep(r.RunUid, r.Step, r.TotalSteps, r.FlowList[i]) + 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: + r.Step = currentStep + r.NextStep = nextStep + FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, "发起流程", "") + if JudgeRunNode(currentStep, r.FlowList) { + r.FlowStepRun(userKey, AgreeToRefuse, Suggest) + } + return + case 1: + r.Step = currentStep + r.NextStep = nextStep + FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") + case 2: + r.Step = currentStep + r.NextStep = nextStep + // fmt.Printf("执行曹总--0->%v->%v\n", r.Step, r.NextStep) + for _, op := range r.FlowList[i].Operator { + userkIntId, _ := strconv.ParseInt(op.Id, 10, 64) + title := fmt.Sprintf("向%v发送抄送数据", op.Name) + FlowRunLog(r.Uuid, userkIntId, AgreeToRefuse, r.FlowList[i].NodeKey, title, "") + } + if r.NextStep > 0 { + r.FlowStepRun(userKey, AgreeToRefuse, Suggest) + } + return + case 3: + r.Step = currentStep + r.NextStep = nextStep + FlowRunLog(r.Uuid, userKey, 2, r.FlowList[i].NodeKey, Suggest, "") + default: + } + } + } + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-11 13:43:32 +@ 功能: 查询驳回到哪个点 +@ 参数 + + #nodeKey 返回的节点 + +@ 返回值 + + #isNew 是否重新发起 + +@ 方法原型 + + # +*/ +func (r *RunWorkFlow) RejectNode(nodeKey string) (isNew bool) { + if nodeKey == "beginnode" { + r.Step = 1 + if r.TotalSteps >= 2 { + r.NextStep = 2 + isNew = false + } else { + r.NextStep = 0 + isNew = true + } + return + } + for _, v := range r.FlowList { + if nodeKey == v.NodeKey { + r.Step = v.Step + nextStep := v.Step + 1 + if nextStep <= r.TotalSteps { + r.NextStep = nextStep + isNew = false + } else { + r.NextStep = 0 + isNew = true + } + return + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-11 13:40:35 +@ 功能: 判断操作人是否已经操作过,并写入操作记录 +@ 参数 + + #userKey 当前操作人 + #runId 执行码 + #Operator 操作人 + +@ 返回值 + + #isTrue + +@ 方法原型 + + #func JudgeOperUser(userKey, runId int64, Operator []OperatorList) (bool, string) {} +*/ +func JudgeOperUser(userKey, runId int64, Operator []OperatorList) (bool, string) { + if len(Operator) < 1 { + return true, "您不是此节点操作人!请不要提交!" + } + caoZuoQuanXian := true + for _, v := range Operator { + if v.Id == strconv.FormatInt(userKey, 10) { + caoZuoQuanXian = false + if len(v.LogList) > 0 { + for _, m := range v.LogList { + if m.UID == strconv.FormatInt(runId, 10) { + return true, "您已经操作过此节点!请不要重复提交!" + } + } + } + } + } + if caoZuoQuanXian { + return true, "您不是此节点操作人!请不要提交!" + } + return false, "" +} diff --git a/api/version1/taskplatform/taskmanagement/types.go b/api/version1/taskplatform/taskmanagement/types.go index 810f5ab..f97e380 100644 --- a/api/version1/taskplatform/taskmanagement/types.go +++ b/api/version1/taskplatform/taskmanagement/types.go @@ -78,4 +78,34 @@ type CallBackFormStruct struct { modelAppPlatform.CustomerFormView FlowkeyStr string `json:"flowkeystr" gorm:"-"` CreaterStr string `json:"createrstr" gorm:"-"` + IdStr string `json:"idStr" gorm:"-"` +} + +// 批量删除数据 +type BatchDeleteClass struct { + Id []string `json:"id"` + IsTrue int `json:"isTrue"` +} +type NodelPeopleInfo struct { + FactorId string `json:"factorid"` + UserList string `json:"userList"` +} + +// 主管层级 +type ContinuousMultiLevelSupervisor struct { + MaxLevel int //最大级别 + Continuity bool //是否连续主管 + UserList []MultiLeveUserList //每级人员列表 +} +type MultiLeveUserList struct { + Level int //第几级 + UserList []OperatorList //操作人 +} + +type CreatFlowView struct { + publicmethod.PublicId + ConditionList []ConditionListInfo `json:"conditionList"` //判断条件主体 + NodelPeople []NodelPeopleInfo `json:"nodelPeople"` //节点操作人 + Step int `json:"step"` //当前执行第几步 + OldFlow []RunFlow `json:"oldFlow"` //已生成的流程 } diff --git a/apirouter/apishiyan/maptostruct.go b/apirouter/apishiyan/maptostruct.go index 863e7ec..482c130 100644 --- a/apirouter/apishiyan/maptostruct.go +++ b/apirouter/apishiyan/maptostruct.go @@ -36,7 +36,8 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter.POST("createFlowChart", methodBinding.CreateFlowChart) //实验流程图生成 - apiRouter.POST("getAllOrgSun", methodBinding.GetAllOrgSun) //获取行政组织所有子类 + apiRouter.POST("getAllOrgSun", methodBinding.GetAllOrgSun) //获取行政组织所有子类 + apiRouter.POST("gainDateCenter", methodBinding.GainDateCenter) //获取行政组织所有子类 } } diff --git a/apirouter/entry.go b/apirouter/entry.go index e77c5f1..1664fae 100644 --- a/apirouter/entry.go +++ b/apirouter/entry.go @@ -4,6 +4,7 @@ import ( "appPlatform/apirouter/apishiyan" "appPlatform/apirouter/authenticationroute" "appPlatform/apirouter/v1/customerformrouter" + datacenterrouter "appPlatform/apirouter/v1/dataCenterRouter" dictrouters "appPlatform/apirouter/v1/dict_routers" "appPlatform/apirouter/v1/grantsystempower" "appPlatform/apirouter/v1/mathsrouter" @@ -33,6 +34,7 @@ type RouterGroup struct { RedisClassApiRouter redisRouter.ApiRouter MathsRouter mathsrouter.ApiRouter WorkWechatRouter workwechatrouter.ApiRouter + DataCenterRouter datacenterrouter.ApiRouter } var RouterGroupEntry = new(RouterGroup) diff --git a/apirouter/v1/dataCenterRouter/router.go b/apirouter/v1/dataCenterRouter/router.go new file mode 100644 index 0000000..467db26 --- /dev/null +++ b/apirouter/v1/dataCenterRouter/router.go @@ -0,0 +1,21 @@ +package datacenterrouter + +import ( + "appPlatform/api/version1" + + "github.com/gin-gonic/gin" +) + +// 权限矩阵PC端 +func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { + apiRouter := router.Group("dataCenter") + //var methodBinding = version1.AppApiEntry.CustomerFormApi + dataApi := version1.AppApiEntry.DataCenterApi + { + apiRouter.GET("", dataApi.Index) //入口 + apiRouter.POST("", dataApi.Index) //入口 + + apiRouter.POST("gaindataCenter", dataApi.GaindataCenter) //通用地址 + apiRouter.POST("postSaveData", dataApi.PostSaveData) //数据中台POST提交数据 + } +} diff --git a/apirouter/v1/dataCenterRouter/type.go b/apirouter/v1/dataCenterRouter/type.go new file mode 100644 index 0000000..ca23942 --- /dev/null +++ b/apirouter/v1/dataCenterRouter/type.go @@ -0,0 +1,4 @@ +package datacenterrouter + +//公共路由 +type ApiRouter struct{} diff --git a/apirouter/v1/taskrouter/taskrouter.go b/apirouter/v1/taskrouter/taskrouter.go index 440725d..9629a58 100644 --- a/apirouter/v1/taskrouter/taskrouter.go +++ b/apirouter/v1/taskrouter/taskrouter.go @@ -26,6 +26,22 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("add_form_data", taskManagementRouter.AddFormAddData) //用户端自定义表单新增记录 apiRouter.POST("add_form_newdata", taskManagementRouter.AddFormAddNewData) //用户端自定义表单新增记录(新版) apiRouter.POST("add_customer_form", taskManagementRouter.AddCustomerForm) //用户端自定义表单新增记录(列表新版) + + apiRouter.POST("gainTaskFormInfo", taskManagementRouter.GainTaskFormInfo) //获取任务表单内容 + + apiRouter.POST("softDeletion", taskManagementRouter.SoftDeletion) //删除任务数据 + apiRouter.POST("editCustomerTable", taskManagementRouter.EditCustomerTable) //编辑任务 + apiRouter.POST("gainEditDataLog", taskManagementRouter.GainEditDataLog) //获取修改记录 + apiRouter.POST("echoTableFormPage", taskManagementRouter.EchoTableFormPage) //添加任务是回显表单数据,若有流程回显流程 + apiRouter.POST("realTimeUpdateFlow", taskManagementRouter.RealTimeUpdateFlow) //根据表单数据实时更新流程 + + apiRouter.POST("startRunWorkFlow", taskManagementRouter.StartRunWorkFlow) //发起流程 + apiRouter.POST("draftsInitiateApproval", taskManagementRouter.DraftsInitiateApproval) //根据表单数据实时更新流程 + apiRouter.POST("gainRunTaskWorkflow", taskManagementRouter.GainRunTaskWorkflow) //获取正在执行得任务流程 + apiRouter.POST("retractRunWorkFlow", taskManagementRouter.RetractRunWorkFlow) //撤回已申请的工作流 + apiRouter.POST("afreshRunWorkflow", taskManagementRouter.AfreshRunWorkflow) //重新发起流程 + apiRouter.POST("applyForTableFormData", taskManagementRouter.ApplyForTableFormData) //申请修改数据 + apiRouter.POST("authorizeWorkflow", taskManagementRouter.AuthorizeWorkflow) //审批处理 } taskFlowApi := router.Group("task_flow") @@ -63,5 +79,9 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { taskFlowApi.POST("gainEditFormFlowInfo", taskFlowRouter.GainEditFormFlowInfo) //获取要修改的数据 taskFlowApi.POST("editFormLogData", taskFlowRouter.EditFormLogData) //申请修改数据 + taskFlowApi.POST("gainFlowLookSee", taskFlowRouter.GainFlowLookSee) //获取流程可见范围 + taskFlowApi.POST("editLookPowerView", taskFlowRouter.EditLookPowerView) //编辑可见范围 + taskFlowApi.POST("setUpMsg", taskFlowRouter.SetUpMsg) //编辑消息提醒 + taskFlowApi.POST("gainSetUpMsg", taskFlowRouter.GainSetUpMsg) //获取消息设置 } } diff --git a/go.mod b/go.mod index 4c32d5d..0fde37a 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20231212025023-e0a8e9370425 github.com/fsnotify/fsnotify v1.7.0 github.com/gin-gonic/gin v1.9.1 - github.com/go-redis/redis/v8 v8.11.5 github.com/mitchellh/mapstructure v1.5.0 github.com/mozillazg/go-pinyin v0.20.0 github.com/redis/go-redis/v9 v9.3.0 diff --git a/go.sum b/go.sum index 8e679da..a1b9800 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,6 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= -github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= @@ -72,9 +70,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mozillazg/go-pinyin v0.20.0 h1:BtR3DsxpApHfKReaPO1fCqF4pThRwH9uwvXzm+GnMFQ= github.com/mozillazg/go-pinyin v0.20.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -134,8 +129,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/initialization/route/initRoute.go b/initialization/route/initRoute.go index 0114a91..27c4c3c 100644 --- a/initialization/route/initRoute.go +++ b/initialization/route/initRoute.go @@ -46,6 +46,9 @@ func InitialRouter() *gin.Engine { { wechatApiRouter.RouterGroupPc(appLoadRouterGroup) } + //数据中台 + dataCenterInit := apirouter.RouterGroupEntry.DataCenterRouter + dataCenterInit.RouterGroupPc(appLoadRouterGroup) } //验证身份接口 鉴权Url(主要应用端使用) diff --git a/models/customerForm/runWorkflow.go b/models/customerForm/runWorkflow.go new file mode 100644 index 0000000..377f8a5 --- /dev/null +++ b/models/customerForm/runWorkflow.go @@ -0,0 +1,76 @@ +package customerForm + +import ( + "appPlatform/overall" + "strings" +) + +// 工作流执行主体 +// 字典类型 +type RunWorkflow struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + FlowKey int64 `json:"flowKey" gorm:"column:flow_key;type:bigint(20) unsigned;default:0;not null;comment:工作流主体"` + Version string `json:"version" gorm:"column:version;type:varchar(255);default:'';comment:使用得版本"` + Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态:1、草稿;2:驳回;3:通过;4:归档;5:删除"` + FlowCont string `json:"flowcont" gorm:"column:flow_cont;type:longtext;comment:流程执行体"` + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:流程发起人"` + CurrentStep int `json:"currentStep" gorm:"column:current_step;type:int(4) unsigned;default:1;not null;comment:当前节点"` + NextStep int `json:"nextStep" gorm:"column:next_step;type:int(4) unsigned;default:0;not null;comment:下一个节点。0:代表没有下一个节点。流程结束"` + NextExecutor string `json:"nextExecutor" gorm:"column:next_executor;type:mediumtext;default:'';comment:下一步执行人"` + Participants string `json:"participants" gorm:"column:participants;type:longtext;comment:参与人"` + StartTime int64 `json:"startTime" gorm:"column:start_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + UpdateTime int64 `json:"update_time" gorm:"column:update_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + VersionCont string `json:"versionCont" gorm:"column:version_cont;type:longtext;comment:版本流程内容"` + RunKey int64 `json:"runKey" gorm:"column:runKey;type:bigint(20) unsigned;default:0;not null;comment:当前执行识别符"` +} + +func (RunWorkflow *RunWorkflow) TableName() string { + return "runWorkflow" +} + +// 写入内容 +func (cont *RunWorkflow) WriteCont() (err error) { + err = overall.CONSTANT_DB_CustomerForm.Create(&cont).Error + return +} + +// 编辑内容 +func (cont *RunWorkflow) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *RunWorkflow) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_CustomerForm.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 *RunWorkflow) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *RunWorkflow) ContMap(whereMap interface{}, field ...string) (countAry []RunWorkflow, err error) { + gormDb := overall.CONSTANT_DB_CustomerForm.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *RunWorkflow) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_CustomerForm.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/customerForm/taskrecord.go b/models/customerForm/taskrecord.go index 3b877c4..0129aba 100644 --- a/models/customerForm/taskrecord.go +++ b/models/customerForm/taskrecord.go @@ -7,19 +7,25 @@ import ( // 自定义表单任务表 type TaskRecord struct { - Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` - Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"` - Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` - CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` - EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` - Types int `json:"types" gorm:"column:types;type:int(1) unsigned;default:1;not null;comment:类型(1:普通表单;2:流程表单)"` - VersionId int64 `json:"version_id" gorm:"column:version_id;type:bigint(20) unsigned;default:0;not null;comment:来源于哪个表单"` - Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态(1:草稿,2:发表;3:审批中;4:归档;5:删除)"` - MastersKey int64 `json:"masters_key" gorm:"column:masters_key;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:主表标识"` - FlowRunSing int64 `json:"flowRunSing" gorm:"column:flow_run_sing;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` - MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` - MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` + Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"` + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` + CreaterTime int64 `json:"creater_time" gorm:"column:creater_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + Types int `json:"types" gorm:"column:types;type:int(1) unsigned;default:1;not null;comment:类型(1:普通表单;2:流程表单)"` + VersionId int64 `json:"version_id" gorm:"column:version_id;type:bigint(20) unsigned;default:0;not null;comment:来源于哪个表单"` + Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:状态(1:草稿,2:发表;3:审批中;4:归档;5:删除)"` + MastersKey int64 `json:"masters_key" gorm:"column:masters_key;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:主表标识"` + FlowRunSing int64 `json:"flowRunSing" gorm:"column:flow_run_sing;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` + MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` + MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` + Visibility int `json:"visibility" gorm:"column:visibility;type:int(1) unsigned;default:1;not null;comment:1、所有人;2、自定义"` + AuthorizationRoles string `json:"authorizationRoles" gorm:"column:authorizationRoles;type:mediumtext;comment:授权角色"` + AuthorizedPersonnel string `json:"authorizedPersonnel" gorm:"column:authorizedPersonnel;type:mediumtext;comment:授权人员"` + AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;comment:授权行政组织"` + AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;comment:授权职务"` + Participant string `json:"participant" gorm:"column:participant;type:longtext;default:'';comment:表单结构json"` } func (TaskRecord *TaskRecord) TableName() string { diff --git a/models/modelAppPlatform/customer_form_version.go b/models/modelAppPlatform/customer_form_version.go index b98d492..d8ff0ae 100644 --- a/models/modelAppPlatform/customer_form_version.go +++ b/models/modelAppPlatform/customer_form_version.go @@ -7,18 +7,25 @@ import ( // 自定义表单版本列表 type CustomerFormVersion struct { - Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` - TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"` - Version int64 `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"` - Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"` - MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` - MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` - Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` - CreaterTime int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` - EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` - TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"` - Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"` - PowerStr string `json:"powerstr" gorm:"column:powerstr;type:longtext;default:'';comment:权限结构"` + Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` + TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"` + Version int64 `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"` + Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"` + MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` + MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` + CreaterTime int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + FlowKey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"` + TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"` + Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"` + PowerStr string `json:"powerstr" gorm:"column:powerstr;type:longtext;default:'';comment:权限结构"` + ListPage string `json:"listPage" gorm:"column:listPage;type:longtext;default:'';comment:列表结构"` + Visibility int `json:"visibility" gorm:"column:stavisibilitytus;type:int(1) unsigned;default:1;not null;comment:1、所有人,2、自定义"` + AuthorizationRoles string `json:"authorizationRoles" gorm:"column:authorizationRoles;type:mediumtext;default:'';comment:授权角色"` + AuthorizedPersonnel string `json:"authorizedPersonnel" gorm:"column:authorizedPersonnel;type:mediumtext;default:'';comment:授权人员"` + AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;default:'';comment:授权行政组织"` + AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;default:'';comment:授权职务"` } func (CustomerFormVersion *CustomerFormVersion) TableName() string { diff --git a/models/modelAppPlatform/customer_form_view.go b/models/modelAppPlatform/customer_form_view.go index b45fdea..65a8513 100644 --- a/models/modelAppPlatform/customer_form_view.go +++ b/models/modelAppPlatform/customer_form_view.go @@ -7,30 +7,36 @@ import ( // 自定义表单版本列表 type CustomerFormView struct { - Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` - TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"` - Version int `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"` - Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"` - MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` - MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` - Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` - CreaterTime int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` - EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` - TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"` - Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"` - CfId int64 `json:"cfid" gorm:"column:cfid;type:int(5) unsigned;not null;comment:Id"` - Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:表单名称"` - Classify int `json:"classify" gorm:"column:classify;type:int(1) unsigned;default:1;not null;comment:分类1:表单;2:流程表单"` - Permit string `json:"permit" gorm:"column:permit;type:mediumtext;default:'';comment:授权范围"` - PermitStr string `json:"permitstr" gorm:"column:permitstr;type:mediumtext;default:'';comment:授权范围"` - Flowkey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"` - UserPermit string `json:"userpermit" gorm:"column:userpermit;type:mediumtext;default:'';comment:可见人员"` - PostPermit string `json:"postpermit" gorm:"column:postpermit;type:mediumtext;default:'';comment:可见角色"` - PowerStr string `json:"powerstr" gorm:"column:powerstr;type:longtext;default:'';comment:权限结构"` - Groupid int64 `json:"groupid" gorm:"column:groupid;type:bigint(20) unsigned;default:0;not null;comment:分组Id"` - Icon string `json:"icon" gorm:"column:icon;type:varchar(255);default:'';comment:图标"` - FlowIsOpen int `json:"flowIsOpen" gorm:"column:flowIsOpen;type:int(1) unsigned;default:2;not null;comment:是否开启工作流(1:启用;2:禁用)"` - ListJson string `json:"listjson" gorm:"column:listjson;type:longtext;default:'';comment:列表结构体"` + Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` + TableKey string `json:"tablekey" gorm:"column:tablekey;type:varchar(255) unsigned;default:'';not null;comment:表单标识符"` + Version int `json:"version" gorm:"column:version;type:int(5) unsigned;default:1;not null;comment:版本号"` + Status int `json:"status" gorm:"column:status;type:int(1) unsigned;default:1;not null;comment:显示状态(1:启用;2:禁用,3:删除)"` + MastesForm string `json:"mastesform" gorm:"column:mastesform;type:longtext;default:'';comment:表单结构"` + MastesFormJson string `json:"mastesformjson" gorm:"column:mastesformjson;type:longtext;default:'';comment:表单结构json"` + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:创建人"` + CreaterTime int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + EditTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + TableStructure string `json:"table_structure" gorm:"column:table_structure;type:longtext;default:'';comment:字表结构"` + Dict string `json:"dict" gorm:"column:dict;type:mediumtext;default:'';comment:字表结构"` + CfId int64 `json:"cfid" gorm:"column:cfid;type:int(5) unsigned;not null;comment:Id"` + Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:表单名称"` + Classify int `json:"classify" gorm:"column:classify;type:int(1) unsigned;default:1;not null;comment:分类1:表单;2:流程表单"` + Permit string `json:"permit" gorm:"column:permit;type:mediumtext;default:'';comment:授权范围"` + PermitStr string `json:"permitstr" gorm:"column:permitstr;type:mediumtext;default:'';comment:授权范围"` + Flowkey int64 `json:"flowkey" gorm:"column:flowkey;type:bigint(20) unsigned;default:0;not null;comment:关联工作流"` + UserPermit string `json:"userpermit" gorm:"column:userpermit;type:mediumtext;default:'';comment:可见人员"` + PostPermit string `json:"postpermit" gorm:"column:postpermit;type:mediumtext;default:'';comment:可见角色"` + PowerStr string `json:"powerstr" gorm:"column:powerstr;type:longtext;default:'';comment:权限结构"` + Groupid int64 `json:"groupid" gorm:"column:groupid;type:bigint(20) unsigned;default:0;not null;comment:分组Id"` + Icon string `json:"icon" gorm:"column:icon;type:varchar(255);default:'';comment:图标"` + FlowIsOpen int `json:"flowIsOpen" gorm:"column:flowIsOpen;type:int(1) unsigned;default:2;not null;comment:是否开启工作流(1:启用;2:禁用)"` + ListJson string `json:"listjson" gorm:"column:listjson;type:longtext;default:'';comment:列表结构体"` + ListPage string `json:"listPage" gorm:"column:listPage;type:longtext;default:'';comment:列表结构"` + Visibility int `json:"visibility" gorm:"column:stavisibilitytus;type:int(1) unsigned;default:1;not null;comment:1、所有人,2、自定义"` + AuthorizationRoles string `json:"authorizationRoles" gorm:"column:authorizationRoles;type:mediumtext;default:'';comment:授权角色"` + AuthorizedPersonnel string `json:"authorizedPersonnel" gorm:"column:authorizedPersonnel;type:mediumtext;default:'';comment:授权人员"` + AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;default:'';comment:授权行政组织"` + AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;default:'';comment:授权职务"` } func (CustomerFormView *CustomerFormView) TableName() string { diff --git a/models/modelAppPlatform/msgrule.go b/models/modelAppPlatform/msgrule.go new file mode 100644 index 0000000..6421acb --- /dev/null +++ b/models/modelAppPlatform/msgrule.go @@ -0,0 +1,67 @@ +package modelAppPlatform + +import ( + "appPlatform/overall" + "strings" +) + +// 自定义表单消息推送规则 +type MsgRule struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + FlowKey int64 `json:"flowKey" gorm:"column:formKey;type:bigint(20) unsigned;default:0;not null;comment:工作流主体"` + Creater int64 `json:"creater" gorm:"column:creater;type:bigint(20) unsigned;default:0;not null;comment:流程发起人"` + RuleCont string `json:"ruleCont" gorm:"column:ruleCont;type:mediumtext;default:'';comment:规则字符串"` + StartTime int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + UpdateTime int64 `json:"editTime" gorm:"column:edit_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` +} + +func (MsgRule *MsgRule) TableName() string { + return "msgrule" +} + +// 写入内容 +func (cont *MsgRule) WriteCont() (err error) { + err = overall.CONSTANT_DB_AppPlatform.Create(&cont).Error + return +} + +// 编辑内容 +func (cont *MsgRule) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *MsgRule) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_AppPlatform.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 *MsgRule) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *MsgRule) ContMap(whereMap interface{}, field ...string) (countAry []MsgRule, err error) { + gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *MsgRule) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/reviseform/edit_form_data_log.go b/models/reviseform/edit_form_data_log.go index 1c0141b..6db2d02 100644 --- a/models/reviseform/edit_form_data_log.go +++ b/models/reviseform/edit_form_data_log.go @@ -17,6 +17,8 @@ type EditFormDataLog struct { 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:创建时间"` + Executor int64 `json:"executor" gorm:"column:executor;type:bigint(20) unsigned;default:0;not null;comment:执行人"` + MastersKey int64 `json:"masters_key" gorm:"column:masters_key;type:bigint(20) unsigned;default:0;not null;comment:主表标识"` } func (EditFormDataLog *EditFormDataLog) TableName() string { diff --git a/overall/publicmethod/formatOutput.go b/overall/publicmethod/formatOutput.go index 4628988..e1939e1 100644 --- a/overall/publicmethod/formatOutput.go +++ b/overall/publicmethod/formatOutput.go @@ -35,6 +35,11 @@ func Result(code int, data interface{}, c *gin.Context, msgAry ...string) { c.JSON(http.StatusOK, Reply{code, msg, data}) //输出json格式数据 } +// 格式化输出 +func ResultInterface(data interface{}, c *gin.Context) { + c.JSON(http.StatusOK, data) //输出json格式数据 +} + //列表输出标准格式 /* @total 总数 diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 8bbc7d3..cd88ae1 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -2753,3 +2753,14 @@ func TypeToInterface(val interface{}) string { return "" } } + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-07 08:26:39 +@ 功能: 去除字段保留字 +*/ +func RemoveReservedWord(val string) bool { + reservedWord := []string{"id", "masters_key", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen"} + return IsInTrue[string](val, reservedWord) +}