You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
981 lines
28 KiB
981 lines
28 KiB
package taskflow
|
|
|
|
import (
|
|
"appPlatform/api/version1/customerform"
|
|
"appPlatform/api/version1/taskplatform/taskmanagement"
|
|
"appPlatform/models/modelAppPlatform"
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/models/reviseform"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"encoding/json"
|
|
"fmt"
|
|
"sort"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-12-01 11:40:12
|
|
@ 功能: 获取要修改的数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GainEditFormFlowInfo(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(1, err, c, "未知表单参数!请核对1后重新提交!")
|
|
return
|
|
}
|
|
//第一步判断流程是否已经归档
|
|
var flowInfo modelAppPlatform.RunFlow
|
|
err = flowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}, "`flow_key`", "`status`", "`runKey`")
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "流程未归档不可执行修改审批")
|
|
return
|
|
}
|
|
//获取当前流程记录使用得哪个表单及表单组件列表
|
|
var taskInfo modelAppPlatform.Task
|
|
err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": flowInfo.FlowKey}, "`version_id`", "`mastesformjson`")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
//展开表单
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont)
|
|
//获取流程使用得表单数据表
|
|
var customerFormInfo modelAppPlatform.CustomerFormVersion
|
|
err = customerFormInfo.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId}, "`tablekey`", "`table_structure`", "`dict`")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
var formUnitCont customerform.FormUnitInfo
|
|
formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, formJsonCont.List, true)
|
|
masterUnitList := make(map[string]customerform.MasterStruct)
|
|
for _, v := range formUnitCont.MasterInfo {
|
|
|
|
masterUnitList[v.Name] = v
|
|
}
|
|
mastKeyName, sunKeyName := formUnitCont.GainMasterAndSunFormUnitNameKey()
|
|
// fmt.Printf("formUnitCont.MasterInfo---->%v---->%v\n", mastKeyName, sunKeyName)
|
|
masterDataInfo := GainCurrendLogData(flowInfo.FlowKey, customerFormInfo, formUnitCont, masterUnitList)
|
|
|
|
var logDataInfo FormDataLog
|
|
logDataInfo.FlowKey = flowInfo.FlowKey
|
|
logDataInfo.GainFlowFoemLog()
|
|
// fmt.Printf("logDataInfo.NewData---->%v\n", logDataInfo.NewData)
|
|
if len(logDataInfo.NewData) > 0 {
|
|
|
|
logTime := logDataInfo.NewData["logTime"]
|
|
newDataInfo := publicmethod.MapOut[string]()
|
|
for i, _ := range masterDataInfo {
|
|
// fmt.Printf("logDataInfo.masterDataInfo---->%v:%v\n", i, v)
|
|
for j, jv := range logDataInfo.NewData {
|
|
if i == j {
|
|
newDataInfo[i] = jv
|
|
}
|
|
if j == "explicate" {
|
|
newDataInfo["explicate"] = jv
|
|
}
|
|
}
|
|
}
|
|
// newDataInfo["logTime"] = logDataInfo.NewData["logTime"]
|
|
logDataInfo.NewData = masterDataInfo
|
|
logDataInfo.NewData["logTime"] = logTime
|
|
masterDataInfo = newDataInfo
|
|
fmt.Printf("新表数据---> %v\n", newDataInfo)
|
|
} else {
|
|
isWrite := true
|
|
for i, _ := range masterDataInfo {
|
|
if i == "explicate" {
|
|
isWrite = false
|
|
}
|
|
}
|
|
if isWrite {
|
|
masterDataInfo["explicate"] = ""
|
|
}
|
|
}
|
|
masterDataInfo["flowKey"] = strconv.FormatInt(flowInfo.FlowKey, 10)
|
|
sendData := publicmethod.MapOut[string]()
|
|
sendData["masterDataInfo"] = masterDataInfo
|
|
|
|
sendNewData := publicmethod.MapOut[string]()
|
|
sendSunNewData := publicmethod.MapOut[string]()
|
|
for i, v := range logDataInfo.NewData {
|
|
if val, isOk := v.([]map[string]interface{}); !isOk {
|
|
for mi, mv := range mastKeyName {
|
|
if mi == i {
|
|
sendNewData[mv] = v
|
|
}
|
|
}
|
|
} else {
|
|
// fmt.Printf("获取数据类型:---4-->%v----->%v\n", val, sunKeyName[i])
|
|
var newSunData []map[string]interface{}
|
|
for _, sv := range val {
|
|
sunOld := publicmethod.MapOut[string]()
|
|
for smi, smv := range sv {
|
|
for sui, suv := range sunKeyName[i] {
|
|
if sui == smi {
|
|
sunOld[suv] = smv
|
|
}
|
|
if smi == "id" {
|
|
sunOld[suv] = smv
|
|
}
|
|
}
|
|
}
|
|
newSunData = append(newSunData, sunOld)
|
|
fmt.Printf("获取数据类型:---4-->%v----->%v\n", sv, newSunData)
|
|
}
|
|
sendSunNewData[i] = newSunData
|
|
}
|
|
|
|
}
|
|
for i, v := range sendSunNewData {
|
|
sendNewData[i] = v
|
|
}
|
|
if len(sendNewData) > 0 {
|
|
sendNewData["logTime"] = logDataInfo.NewData["logTime"]
|
|
}
|
|
|
|
// fmt.Printf("获取数据类型:----->%v\n", sendNewData)
|
|
sendData["newData"] = sendNewData
|
|
sendData["oldData"] = EditLogCont(logDataInfo.OldData, mastKeyName, sunKeyName)
|
|
sendData["newDataLen"] = len(sendNewData)
|
|
sendData["logistrue"] = false
|
|
if len(sendNewData) > 0 || len(logDataInfo.OldData) > 0 {
|
|
sendData["logistrue"] = true
|
|
}
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-12-02 14:42:15
|
|
@ 功能: 修改历史记录处理
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func EditLogCont(oldData []map[string]interface{}, mastKeyName map[string]string, sunKeyName map[string]map[string]string) []map[string]interface{} {
|
|
var oldAry []map[string]interface{}
|
|
|
|
for _, v := range oldData {
|
|
sendNewData := publicmethod.MapOut[string]()
|
|
for fi, fv := range v {
|
|
// fmt.Printf("方法原型===>%v:%T>>>%v\n", fi, fv, fv)
|
|
if val, isOk := fv.([]interface{}); !isOk { //主表字段
|
|
for mi, mv := range mastKeyName {
|
|
if mi == fi {
|
|
sendNewData[mv] = fv
|
|
}
|
|
}
|
|
if fi == "explicate" {
|
|
sendNewData["修改说明"] = fv
|
|
// oldDataCont["logTime"] = publicmethod.UnixTimeToDay(v.AddTime, 12)
|
|
// fmt.Printf("修改说明:---4-->%v----->%v\n", fi, fv)
|
|
|
|
}
|
|
if fi == "logTime" {
|
|
sendNewData["logTime"] = fv
|
|
}
|
|
} else { //子表字段
|
|
var newSunData []map[string]interface{}
|
|
for _, sv := range val {
|
|
if ktv, ok := sv.(map[string]interface{}); ok {
|
|
sunOld := publicmethod.MapOut[string]()
|
|
for smi, smv := range ktv {
|
|
for sui, suv := range sunKeyName[fi] {
|
|
if sui == smi {
|
|
sunOld[suv] = smv
|
|
}
|
|
}
|
|
}
|
|
newSunData = append(newSunData, sunOld)
|
|
}
|
|
|
|
// fmt.Printf("获取数据类型:---4-->%T----->%v\n", sv, sv)
|
|
}
|
|
sendNewData[fi] = newSunData
|
|
}
|
|
|
|
}
|
|
|
|
// sendNewData["修改说明"] = v["explicate"]
|
|
oldAry = append(oldAry, sendNewData)
|
|
|
|
}
|
|
return oldAry
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-12-01 13:37:39
|
|
@ 功能: 获取数据表单数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func GainCurrendLogData(flowKey int64, customerFormInfo modelAppPlatform.CustomerFormVersion, formUnitCont customerform.FormUnitInfo, masterUnitList map[string]customerform.MasterStruct) map[string]interface{} {
|
|
//获取自定义创建表单数据
|
|
masterFormCont := publicmethod.MapOut[string]()
|
|
err := overall.CONSTANT_DB_CustomerForm.Table(customerFormInfo.TableKey).Where("`masters_key` = ?", flowKey).Take(&masterFormCont).Error
|
|
if err != nil {
|
|
return masterFormCont
|
|
}
|
|
masterFormCont = taskmanagement.CustomerFormCallBackVal(masterFormCont, masterUnitList)
|
|
if customerFormInfo.TableStructure != "" {
|
|
sunFormTable := publicmethod.MapOut[string]()
|
|
err = json.Unmarshal([]byte(customerFormInfo.TableStructure), &sunFormTable)
|
|
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
|
|
for _, v := range formUnitCont.SunFormInfo {
|
|
sunTypeAry[v.TableName] = v.UbitInfo
|
|
}
|
|
if err == nil {
|
|
for _, v := range sunFormTable {
|
|
var sunContList []map[string]interface{}
|
|
if tableName, isOk := v.(string); isOk {
|
|
overall.CONSTANT_DB_CustomerForm.Table(tableName).Where("`masters_key` = ?", flowKey).Find(&sunContList)
|
|
var sunContListZhuanBian []map[string]interface{}
|
|
if len(sunContList) > 0 {
|
|
for _, sclv := range sunContList {
|
|
if sunTableType, sunIsOk := sunTypeAry[tableName]; sunIsOk {
|
|
masterFormCont := taskmanagement.CustomerFormCallBackVal(sclv, sunTableType)
|
|
sunContListZhuanBian = append(sunContListZhuanBian, masterFormCont)
|
|
} else {
|
|
sunContListZhuanBian = append(sunContListZhuanBian, sclv)
|
|
}
|
|
}
|
|
}
|
|
fmt.Printf("自定义表单结果值!tableName:%v---->%T---->%v\n", tableName, sunContListZhuanBian, sunContListZhuanBian)
|
|
masterFormCont[tableName] = sunContListZhuanBian
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return masterFormCont
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-12-01 13:19:43
|
|
@ 功能: 获取自定义表单历史记录
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (f *FormDataLog) GainFlowFoemLog() {
|
|
var logDataList []reviseform.EditFormDataLog
|
|
err := overall.CONSTANT_DB_ReviseFormData.Where("`flow_key` = ?", f.FlowKey).Order("`addTime` desc").Find(&logDataList).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
if len(logDataList) > 0 {
|
|
for _, v := range logDataList {
|
|
if v.State == 1 {
|
|
if v.DataCont != "" {
|
|
json.Unmarshal([]byte(v.DataCont), &f.NewData)
|
|
f.NewData["explicate"] = v.Explicate
|
|
f.NewData["logTime"] = publicmethod.UnixTimeToDay(v.AddTime, 12)
|
|
}
|
|
if v.SunDataCont != "" {
|
|
sunDataList := publicmethod.MapOut[string]()
|
|
json.Unmarshal([]byte(v.SunDataCont), &sunDataList)
|
|
|
|
for si, sv := range sunDataList {
|
|
f.NewData[si] = sv
|
|
}
|
|
}
|
|
} else {
|
|
var oldDataCont map[string]interface{}
|
|
if v.DataCont != "" {
|
|
json.Unmarshal([]byte(v.DataCont), &oldDataCont)
|
|
|
|
if v.SunDataCont != "" {
|
|
sunDataList := publicmethod.MapOut[string]()
|
|
json.Unmarshal([]byte(v.SunDataCont), &sunDataList)
|
|
// fmt.Printf("v.SunDataCont====>%v====>%v\n", v.DataCont, sunDataList)
|
|
for si, sv := range sunDataList {
|
|
// fmt.Printf("v.SunDataCont====>%v====>%v\n", si, sv)
|
|
oldDataCont[si] = sv
|
|
}
|
|
}
|
|
oldDataCont["explicate"] = v.Explicate
|
|
oldDataCont["logTime"] = publicmethod.UnixTimeToDay(v.AddTime, 12)
|
|
f.OldData = append(f.OldData, oldDataCont)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-12-01 11:07:06
|
|
@ 功能: 申请修改数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) EditFormLogData(c *gin.Context) {
|
|
data, err := c.GetRawData() //接收表单提交得数据
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
|
|
mapData := publicmethod.MapOut[string]() //初始化MAP
|
|
err = json.Unmarshal(data, &mapData) //将json字符串转换成Map
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
fmt.Printf("接收表单提交得数据-->%v\n", mapData)
|
|
if _, ok := mapData["flowKey"]; !ok {
|
|
publicmethod.Result(1, err, c, "非法表单!1不能提交数据!")
|
|
return
|
|
}
|
|
//第一步判断流程是否已经归档
|
|
var flowInfo modelAppPlatform.RunFlow
|
|
err = flowInfo.GetCont(map[string]interface{}{"`flow_key`": mapData["flowKey"]}, "`flow_key`", "`status`", "`runKey`", "`id`", "`flow_cont`", "`current_step`", `next_step`, `participants`)
|
|
if err != nil || flowInfo.Status != 4 {
|
|
publicmethod.Result(1, err, c, "流程未归档不可执行修改审批")
|
|
return
|
|
}
|
|
//获取当前流程记录使用得哪个表单及表单组件列表
|
|
var taskInfo modelAppPlatform.Task
|
|
err = taskInfo.GetCont(map[string]interface{}{"`masters_key`": flowInfo.FlowKey}, "`version_id`", "`mastesformjson`")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
//获取指定版本表单内容
|
|
var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单
|
|
err = formCont.GetCont(map[string]interface{}{"`id`": taskInfo.VersionId})
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
var sunFormName []string //子表名称集合
|
|
if formCont.TableStructure != "" { //拆解获取子表名称
|
|
var sunFormStruct map[string]string
|
|
err = json.Unmarshal([]byte(formCont.TableStructure), &sunFormStruct)
|
|
if err == nil {
|
|
for _, v := range sunFormStruct {
|
|
if !publicmethod.IsInTrue[string](v, sunFormName) {
|
|
sunFormName = append(sunFormName, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
masterField := publicmethod.MapOut[string]() //主表数据
|
|
sunFieldAry := publicmethod.MapOut[string]() //子表数据
|
|
for k, v := range mapData {
|
|
if !publicmethod.IsInTrue[string](k, sunFormName) {
|
|
if !publicmethod.IsInTrue[string](k, []string{"formId"}) {
|
|
masterField[k] = v
|
|
}
|
|
} else {
|
|
sunFieldAry[k] = v
|
|
}
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
cureeTime := time.Now().Unix()
|
|
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串
|
|
|
|
var formUnitCont customerform.FormUnitInfo
|
|
formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件
|
|
//主表组件
|
|
masterUnitList := make(map[string]customerform.MasterStruct)
|
|
for _, v := range formUnitCont.MasterInfo {
|
|
masterUnitList[v.Name] = v
|
|
}
|
|
uuid := publicmethod.GetUUid(6)
|
|
//自定义表单修改数据历史记录
|
|
startUs := strconv.FormatInt(userCont.Key, 10) //当前操作人
|
|
var editFormDataLogInfo reviseform.EditFormDataLog
|
|
editFormDataLogInfo.SourceForm = taskInfo.VersionId //int64 来源表单"`
|
|
editFormDataLogInfo.FlowKey = flowInfo.FlowKey //int64 流程标识符"`
|
|
editFormDataLogInfo.RunKey = uuid //int64 当前执行识别符"`
|
|
editFormDataLogInfo.AddTime = cureeTime //int64 创建时间"`
|
|
editFormDataLogInfo.State = 1 //int 状态(1、新数据;2:已批准的老数据)"`
|
|
// editFormDataLogInfo.DataCont = //string 数据值"`
|
|
if expval, isOk := mapData["explicate"].(string); isOk {
|
|
editFormDataLogInfo.Explicate = expval //string 说明"`
|
|
}
|
|
|
|
// editFormDataLogInfo.SunDataCont = //string 子表数值"`
|
|
|
|
saveData := publicmethod.MapOut[string]()
|
|
|
|
//组装数据表新增数据
|
|
masrWriteMap := taskmanagement.MakeFormMapData(flowInfo.FlowKey, userCont.Key, cureeTime, masterField, masterUnitList, 2)
|
|
masterTableJson, _ := json.Marshal(masrWriteMap)
|
|
editFormDataLogInfo.DataCont = string(masterTableJson)
|
|
//判断是否有子表
|
|
if len(sunFieldAry) > 0 {
|
|
//有子表
|
|
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
|
|
for _, v := range formUnitCont.SunFormInfo {
|
|
sunTypeAry[v.TableName] = v.UbitInfo
|
|
}
|
|
sunTableData := EditSunDatabase(flowInfo.FlowKey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
|
|
fmt.Printf("判断是否有子表得数据-->%v\n", sunTableData)
|
|
saveData["sunTypeAry"] = sunTableData
|
|
sunTableJson, _ := json.Marshal(sunTableData)
|
|
editFormDataLogInfo.SunDataCont = string(sunTableJson)
|
|
}
|
|
saveData["masrWriteMap"] = masrWriteMap
|
|
editFormDataLogInfo.EiteCont(map[string]interface{}{"`flow_key`": flowInfo.FlowKey, "`state`": 1}, map[string]interface{}{"`state`": 2})
|
|
fmt.Printf("写入数据-->%v\n", editFormDataLogInfo)
|
|
err = overall.CONSTANT_DB_ReviseFormData.Model(&reviseform.EditFormDataLog{}).Create(&editFormDataLogInfo).Error
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
var flowList []RunFlow
|
|
err = json.Unmarshal([]byte(flowInfo.FlowCont), &flowList)
|
|
//执行流程
|
|
var runFlow RunWorkFlow
|
|
runFlow.Step = 0 //执行第几部
|
|
runFlow.FlowList = flowList
|
|
runFlow.Participant = append(runFlow.Participant, startUs)
|
|
runFlow.TotalSteps = len(flowList) //流程总长度
|
|
runFlow.Uuid = flowInfo.Id
|
|
runFlow.RunUid = uuid
|
|
runFlow.GainRunNode(startUs, 2, "申请修改数据")
|
|
|
|
flowJsonCont, _ := json.Marshal(runFlow.FlowList) //将步进流转化成json流
|
|
SaveFlowCont := publicmethod.MapOut[string]()
|
|
SaveFlowCont["`flow_cont`"] = string(flowJsonCont)
|
|
SaveFlowCont["`current_step`"] = runFlow.Step
|
|
SaveFlowCont["`next_step`"] = runFlow.NextStep
|
|
SaveFlowCont["`runKey`"] = uuid
|
|
//参与人去重
|
|
var parUser []string
|
|
for _, v := range runFlow.Participant {
|
|
if !publicmethod.IsInTrue[string](v, parUser) {
|
|
parUser = append(parUser, v)
|
|
}
|
|
}
|
|
SaveFlowCont["`participants`"] = strings.Join(parUser, ",")
|
|
nextRunUser := runFlow.NextRunNodeUser(1)
|
|
SaveFlowCont["`next_executor`"] = strings.Join(nextRunUser, ",")
|
|
SaveFlowCont["`status`"] = 3
|
|
if runFlow.NextStep <= 0 {
|
|
SaveFlowCont["`status`"] = 4
|
|
}
|
|
SaveFlowCont["`update_time`"] = time.Now().Unix()
|
|
|
|
flowInfo.EiteCont(map[string]interface{}{"`flow_key`": flowInfo.FlowKey}, SaveFlowCont)
|
|
taskInfo.EiteCont(map[string]interface{}{"`masters_key`": flowInfo.FlowKey}, map[string]interface{}{"`status`": 3})
|
|
publicmethod.Result(0, saveData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-12-02 09:24:33
|
|
@ 功能: 处理指标字段值
|
|
@ 参数
|
|
|
|
#uuid 唯一标识
|
|
#creater 创建人
|
|
#createrTime 创建时间
|
|
#masterTableName 主表标识
|
|
#masterDataCont 主表数据
|
|
#sunDataList 字表数据列表
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func EditSunDatabase(uuid, creater, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (sunTableData map[string]interface{}) {
|
|
if len(masterDataCont) > 0 {
|
|
if len(sunDataList) > 0 {
|
|
sunMasterMap := publicmethod.MapOut[string]()
|
|
//子表存在时,执行主表和子表数据写入
|
|
for k, v := range sunDataList {
|
|
// fmt.Printf("处理指标字段值--->%v--->%v\n", k, v)
|
|
// if k == "table1693811044212" {
|
|
s, ok := v.([]interface{}) //获取值类型
|
|
if !ok {
|
|
// err = errors.New("表单数据错误!请验证后重新提交!")
|
|
return
|
|
} else {
|
|
//判断是否有数据
|
|
if len(s) > 0 {
|
|
var sunCont []map[string]interface{}
|
|
for _, sv := range s { //拆分子表
|
|
if sdf, isOk := sv.(map[string]interface{}); isOk {
|
|
if sunTableType, sunIsOk := sunTable[k]; sunIsOk {
|
|
masterWriteVal := taskmanagement.MakeFormMapData(uuid, creater, createrTime, sdf, sunTableType, 2) //转换数据表值
|
|
// fmt.Printf("处理指标字段值-1-->%v--->%v\n", sunTableType, masterWriteVal)
|
|
if len(masterWriteVal) > 0 {
|
|
sunCont = append(sunCont, masterWriteVal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(sunCont) > 0 {
|
|
sunMasterMap[k] = sunCont
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sunTableData = sunMasterMap
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 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)
|
|
}
|
|
|