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.
2817 lines
80 KiB
2817 lines
80 KiB
package taskmanagement
|
|
|
|
import (
|
|
"appPlatform/api/version1/customerform"
|
|
datacenter "appPlatform/api/version1/dataCenter"
|
|
"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"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 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
|
|
|
|
if formJsonCont.Form.DataSource == "yes" {
|
|
var sqlDb datacenter.DataBastType
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
if err != nil {
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
if err != nil {
|
|
publicmethod.Result(0, sqlDb, c)
|
|
return
|
|
}
|
|
}
|
|
|
|
sendData["tableData"] = GainOnlyOneCustomerFormLogYuan(sqlDborm, requestData.Id, formJsonCont.Form.DataSourceConfig.TableKey, formVersionInfo.TableStructure, tableUnitList)
|
|
|
|
} else {
|
|
|
|
sendData["tableData"] = GainOnlyOneCustomerFormLog(requestData.Id, formVersionInfo.TableKey, formVersionInfo.TableStructure, tableUnitList)
|
|
}
|
|
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-01-03 16:31:43
|
|
@ 功能:
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func GainOnlyOneCustomerFormLogYuan(sqlDb *gorm.DB, id, masterTableName, sunTableJson string, tableUnitList customerform.TableFormUnit) map[string]interface{} {
|
|
sendData := publicmethod.MapOut[string]()
|
|
if masterTableName == "" || id == "" || id == "0" {
|
|
return sendData
|
|
}
|
|
|
|
err := sqlDb.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, sendData)
|
|
}
|
|
}
|
|
|
|
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, tv)
|
|
}
|
|
}
|
|
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-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, sendData)
|
|
}
|
|
}
|
|
|
|
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, tv)
|
|
}
|
|
}
|
|
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, tableFormInfo interface{}) interface{} {
|
|
for _, uv := range unitCont {
|
|
if uv.Key == key {
|
|
acValInt, _ := strconv.Atoi(uv.ActiveValue)
|
|
// InavalInt, _ := strconv.Atoi(uv.InactiveValue)
|
|
fmt.Printf("switch---->%v-->%T---->%v\n", uv.Class, val, val)
|
|
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
|
|
case "datePicker":
|
|
if tableMap, isOk := tableFormInfo.(map[string]interface{}); isOk {
|
|
endKey := fmt.Sprintf("%v_end", key)
|
|
fmt.Printf("%v----->switch-->%T---->%v\n", endKey, tableMap[endKey], tableMap[endKey])
|
|
|
|
if tableMap[endKey] != nil {
|
|
return []interface{}{val, tableMap[endKey]}
|
|
} else {
|
|
return val
|
|
}
|
|
}
|
|
case "select":
|
|
|
|
if auxIsTeuw, isOk := uv.Auxiliary.(bool); isOk {
|
|
tj, _ := json.Marshal(tableFormInfo)
|
|
fmt.Printf("select---->%v---->%v-->%T---->%v---->%v\n", key, auxIsTeuw, val, val, string(tj))
|
|
if auxIsTeuw {
|
|
var ary []interface{}
|
|
if valStr, isTrue := val.(string); isTrue {
|
|
json.Unmarshal([]byte(valStr), &ary)
|
|
return ary
|
|
} else {
|
|
return val
|
|
}
|
|
} else {
|
|
fmt.Printf("select:%T--1-->%v\n", tableFormInfo, tableFormInfo)
|
|
valInt, _ := publicmethod.StringToInt64(val)
|
|
return valInt
|
|
}
|
|
|
|
} else {
|
|
valInt, _ := publicmethod.StringToInt64(val)
|
|
return valInt
|
|
}
|
|
fmt.Printf("%v----->switch-->%T---->%v\n", key, uv, uv)
|
|
case "timePicker":
|
|
// timeVal, _ := publicmethod.StringToInt64(val)
|
|
// val = publicmethod.UnixTimeToDay(timeVal/1000, 5)
|
|
case "expand-user":
|
|
// valStr := publicmethod.TypeToInterface(val)
|
|
// var peopleAry []string
|
|
// json.Unmarshal([]byte(valStr), &peopleAry)
|
|
// val = strings.Join(peopleAry, ",")
|
|
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 && len(taskList) < 1 {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
fmt.Printf("\n\n\n删除的账号---------------->%v\n\n\n", taskList)
|
|
|
|
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, 5, tableVersion.TableKey, tableVersion.TableStructure)
|
|
}
|
|
}
|
|
overall.CONSTANT_DB_CustomerForm.Table(requestData.TableKey).Where("`masters_key` IN ?", requestData.Id).Updates(map[string]interface{}{"`states`": 5})
|
|
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)
|
|
masterField[k] = valAry
|
|
} else {
|
|
masterField[k] = ""
|
|
}
|
|
default:
|
|
masterField[k] = v
|
|
}
|
|
} else {
|
|
sunFieldAry[k] = v
|
|
}
|
|
}
|
|
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont)
|
|
|
|
var tableUnitList customerform.TableFormUnit
|
|
tableUnitList.AnalysisTableFormUnitAttribute("", formJsonCont.List)
|
|
// hjksdf := publicmethod.MapOut[string]()
|
|
// hjksdf["tableUnitList"] = tableUnitList
|
|
|
|
// publicmethod.Result(106, hjksdf, c)
|
|
// return
|
|
//获取当前操作人信息
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
cureeTime := time.Now().Unix()
|
|
var masterOldData map[string]interface{}
|
|
if formJsonCont.Form.DataSource == "yes" {
|
|
var sqlDb datacenter.DataBastType
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
if err != nil {
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
if err != nil {
|
|
publicmethod.Result(0, sqlDb, c)
|
|
return
|
|
}
|
|
}
|
|
masterOldData, err = MasterTableHandleYuanNew(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey, userCont.Key, cureeTime, masterField, tableUnitList.MasterInfo)
|
|
} else {
|
|
masterOldData, err = MasterTableHandleNew(tableVersion.TableKey, userCont.Key, cureeTime, masterField, tableUnitList.MasterInfo)
|
|
}
|
|
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
// publicmethod.Result(106, masterOldData, 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
|
|
sendInfo["runFlowId"] = strconv.FormatInt(taskInfo.RunFlowId, 10)
|
|
publicmethod.Result(0, sendInfo, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-01-03 16:52:28
|
|
@ 功能: 主表处理数据(新版)有源
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func MasterTableHandleYuanNew(sqlDb *gorm.DB, tableName string, creater, cureeTime int64, newsData map[string]interface{}, MasterInfo []customerform.UnitAttribute) (map[string]interface{}, error) {
|
|
var oldData map[string]interface{}
|
|
if len(newsData) > 0 {
|
|
var id interface{}
|
|
editData := publicmethod.MapOut[string]()
|
|
for i, v := range newsData {
|
|
|
|
if i == "id" {
|
|
// if idStr, ok := v.(string); ok {
|
|
// id = idStr
|
|
// } else {
|
|
// id = idStr
|
|
// }
|
|
id = v
|
|
}
|
|
if !publicmethod.RemoveReservedWord(i) {
|
|
// fmt.Printf("i:%v---->t:%T---->v:%v\n", i, v, v)
|
|
|
|
for _, mv := range MasterInfo {
|
|
if i == mv.Key {
|
|
fmt.Printf("mv:%v---->t:%v---->---->v:%v\n", i, mv.Class, mv.Auxiliary)
|
|
switch mv.Class {
|
|
case "datePicker":
|
|
auxVal := publicmethod.TypeToInterface(mv.Auxiliary)
|
|
if !publicmethod.RemoveReservedWordTime(auxVal) {
|
|
editData[i] = v
|
|
} else {
|
|
if valAry, isAry := v.([]interface{}); isAry {
|
|
if len(valAry) > 0 {
|
|
editData[i] = valAry[0]
|
|
endKey := fmt.Sprintf("%v_end", i)
|
|
editData[endKey] = valAry[len(valAry)-1]
|
|
}
|
|
}
|
|
}
|
|
case "checkbox":
|
|
valStrJson, _ := json.Marshal(v)
|
|
editData[i] = string(valStrJson)
|
|
case "select":
|
|
if auxVal, isAc := mv.Auxiliary.(bool); isAc {
|
|
if auxVal {
|
|
valStrJson, _ := json.Marshal(v)
|
|
editData[i] = string(valStrJson)
|
|
} else {
|
|
editData[i] = v
|
|
}
|
|
} else {
|
|
editData[i] = v
|
|
}
|
|
|
|
default:
|
|
if valAry, isAry := v.([]interface{}); isAry {
|
|
|
|
if len(valAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valAry)
|
|
editData[i] = string(valStrJson)
|
|
} else {
|
|
editData[i] = ""
|
|
}
|
|
} else {
|
|
editData[i] = v
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
err := sqlDb.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 = sqlDb.Table(tableName).Where("`id` = ?", id).Updates(&editData).Error
|
|
|
|
return oldData, err
|
|
}
|
|
return oldData, nil
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-08-07 11:49:21
|
|
@ 功能: 主表处理数据(新版)
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func MasterTableHandleNew(tableName string, creater, cureeTime int64, newsData map[string]interface{}, MasterInfo []customerform.UnitAttribute) (map[string]interface{}, error) {
|
|
var oldData map[string]interface{}
|
|
if len(newsData) > 0 {
|
|
var id interface{}
|
|
editData := publicmethod.MapOut[string]()
|
|
for i, v := range newsData {
|
|
|
|
if i == "id" {
|
|
// if idStr, ok := v.(string); ok {
|
|
// id = idStr
|
|
// } else {
|
|
// id = idStr
|
|
// }
|
|
id = v
|
|
}
|
|
if !publicmethod.RemoveReservedWord(i) {
|
|
// fmt.Printf("i:%v---->t:%T---->v:%v\n", i, v, v)
|
|
|
|
for _, mv := range MasterInfo {
|
|
if i == mv.Key {
|
|
fmt.Printf("mv:%v---->t:%v---->---->v:%v\n", i, mv.Class, mv.Auxiliary)
|
|
switch mv.Class {
|
|
case "datePicker":
|
|
auxVal := publicmethod.TypeToInterface(mv.Auxiliary)
|
|
if !publicmethod.RemoveReservedWordTime(auxVal) {
|
|
editData[i] = v
|
|
} else {
|
|
if valAry, isAry := v.([]interface{}); isAry {
|
|
if len(valAry) > 0 {
|
|
editData[i] = valAry[0]
|
|
endKey := fmt.Sprintf("%v_end", i)
|
|
editData[endKey] = valAry[len(valAry)-1]
|
|
}
|
|
}
|
|
}
|
|
case "checkbox":
|
|
valStrJson, _ := json.Marshal(v)
|
|
editData[i] = string(valStrJson)
|
|
case "select":
|
|
if auxVal, isAc := mv.Auxiliary.(bool); isAc {
|
|
if auxVal {
|
|
valStrJson, _ := json.Marshal(v)
|
|
editData[i] = string(valStrJson)
|
|
} else {
|
|
editData[i] = v
|
|
}
|
|
} else {
|
|
editData[i] = v
|
|
}
|
|
|
|
default:
|
|
if valAry, isAry := v.([]interface{}); isAry {
|
|
|
|
if len(valAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valAry)
|
|
editData[i] = string(valStrJson)
|
|
} else {
|
|
editData[i] = ""
|
|
}
|
|
} else {
|
|
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 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 {
|
|
var id interface{}
|
|
editData := publicmethod.MapOut[string]()
|
|
for i, v := range newsData {
|
|
|
|
if i == "id" {
|
|
// if idStr, ok := v.(string); ok {
|
|
// id = idStr
|
|
// } else {
|
|
// id = idStr
|
|
// }
|
|
id = v
|
|
}
|
|
if !publicmethod.RemoveReservedWord(i) {
|
|
fmt.Printf("i:%v---->t:%T---->v:%v\n", i, v, v)
|
|
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)
|
|
return
|
|
}
|
|
sendData := publicmethod.MapOut[string]()
|
|
|
|
var taskInfo customerForm.TaskRecord
|
|
taskInfo.GetCont(map[string]interface{}{"`masters_key": requestData.Id})
|
|
//展开表单
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(taskInfo.MastesFormJson), &formJsonCont)
|
|
|
|
var tableUnitList customerform.TableFormUnit
|
|
tableUnitList.AnalysisTableFormUnitAttribute("", formJsonCont.List)
|
|
|
|
// sendData["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)
|
|
}
|
|
logCont["explicate"] = v.Explicate
|
|
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 SimTask
|
|
err := c.ShouldBindJSON(&requestData)
|
|
// if err != nil {
|
|
// publicmethod.Result(100, err, c)
|
|
// return
|
|
// }
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
if requestData.IsRun == 0 {
|
|
requestData.IsRun = 1
|
|
}
|
|
if requestData.UserKey == "" {
|
|
requestData.IsRun = 1
|
|
}
|
|
//获取当前启用的表单版本
|
|
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) //获取当前操作人
|
|
|
|
userCont := GainRunPeople(requestData.IsRun, requestData.UserKey, c)
|
|
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)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-05-08 08:01:24
|
|
@ 功能: 获取执行人信息
|
|
*/
|
|
func GainRunPeople(isRun int, userKey string, c *gin.Context) (userCont modelshr.ManCont) {
|
|
if isRun == 1 {
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
userCont.GetLoginCont(context) //获取当前操作人
|
|
} else {
|
|
if userKey != "" {
|
|
userCont.GetCont(map[string]interface{}{"`key`": userKey})
|
|
} else {
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
userCont.GetLoginCont(context) //获取当前操作人
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 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:再次审批
|
|
nodeInfo.HelpTips = v.HelpTips
|
|
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) {
|
|
|
|
fmt.Printf("\n\n\n节点处理---->%v\n\n\n", n)
|
|
|
|
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
|
|
nodeInfo.HelpTips = n.HelpTips
|
|
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]) //将工号写入数组
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fmt.Printf("获取到的人员-->\n\n\n%v\n\n\n", userNumber)
|
|
if len(userNumber) > 0 {
|
|
nodeInfo.Operator = GainUserCode(userNumber)
|
|
}
|
|
case 9: //权限矩阵
|
|
fmt.Printf("权限矩阵-->\n\n\n%v\n\n\n", n.Matrix)
|
|
if n.Attribute == 1 {
|
|
nodeInfo.Operator = GainMatrixUserList(creater.AdminOrg, n.Matrix)
|
|
} else {
|
|
nodeInfo.Operator = GainMatrixUserList(orgId, n.Matrix)
|
|
}
|
|
case 10: //指定部门负责人
|
|
fmt.Printf("指定部门负责人-->\n\n\n%v\n\n\n", n.OrgList)
|
|
if len(n.OrgList) > 0 {
|
|
nodeInfo.Operator = GainOrgManager(n.OrgList)
|
|
}
|
|
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)
|
|
|
|
switch n.Settype {
|
|
case 2: //主管
|
|
var levelUserList ContinuousMultiLevelSupervisor
|
|
levelUserList.MaxLevel = n.DirectorLevel
|
|
levelUserList.Continuity = false
|
|
if n.Attribute == 1 {
|
|
//申请人
|
|
nodeInfo.Operator = append(nodeInfo.Operator, levelUserList.ObtainRelevantLevelLeaders(creater.AdminOrg)...)
|
|
} else {
|
|
//执行部门
|
|
nodeInfo.Operator = append(nodeInfo.Operator, levelUserList.ObtainRelevantLevelLeaders(orgId)...)
|
|
}
|
|
case 3: //行政岗位
|
|
if n.Attribute == 1 {
|
|
nodeInfo.Operator = append(nodeInfo.Operator, GainOrgPostUserList(creater.AdminOrg, n.NodeUserList)...)
|
|
} else {
|
|
nodeInfo.Operator = append(nodeInfo.Operator, GainOrgPostUserList(orgId, 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 = append(nodeInfo.Operator, levelUserList.ObtainRelevantLevelLeaders(creater.AdminOrg)...)
|
|
} else {
|
|
//执行部门
|
|
nodeInfo.Operator = append(nodeInfo.Operator, levelUserList.ObtainRelevantLevelLeaders(orgId)...)
|
|
}
|
|
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]) //将工号写入数组
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fmt.Printf("获取到的人员-->\n\n\n%v\n\n\n", userNumber)
|
|
if len(userNumber) > 0 {
|
|
nodeInfo.Operator = append(nodeInfo.Operator, GainUserCode(userNumber)...)
|
|
}
|
|
case 9: //权限矩阵
|
|
fmt.Printf("权限矩阵-->\n\n\n%v\n\n\n", n.Matrix)
|
|
if n.Attribute == 1 {
|
|
nodeInfo.Operator = append(nodeInfo.Operator, GainMatrixUserList(creater.AdminOrg, n.Matrix)...)
|
|
} else {
|
|
nodeInfo.Operator = append(nodeInfo.Operator, GainMatrixUserList(orgId, n.Matrix)...)
|
|
}
|
|
case 10: //指定部门负责人
|
|
fmt.Printf("指定部门负责人-->\n\n\n%v\n\n\n", n.OrgList)
|
|
if len(n.OrgList) > 0 {
|
|
nodeInfo.Operator = append(nodeInfo.Operator, GainOrgManager(n.OrgList)...)
|
|
}
|
|
default:
|
|
}
|
|
|
|
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 {
|
|
fmt.Printf("获取行政组织----111-------》%v\n", v.Options)
|
|
syncSeting.Add(1)
|
|
go userAry.GainOrgPostPeople(allOrgId, v.Options)
|
|
}
|
|
}
|
|
syncSeting.Wait()
|
|
fmt.Printf("获取行政组织-----------》%v\n", approvers)
|
|
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(" `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
|
|
if len(matrix.List) > 0 {
|
|
var outcomeidAry []int64
|
|
for _, v := range matrix.List {
|
|
if !publicmethod.IsInTrue[int64](v.OutcomeId, outcomeidAry) {
|
|
outcomeidAry = append(outcomeidAry, v.OutcomeId)
|
|
}
|
|
}
|
|
if len(outcomeidAry) > 0 {
|
|
err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`hand_id`").Where("`types` = 2 AND `mc_id` = ? AND `mh_id` IN ? AND `number` = ?", matrix.MatrixId, outcomeidAry, keyVal).Find(&userKeys).Error
|
|
} else {
|
|
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
|
|
}
|
|
} else {
|
|
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) {
|
|
if orgId != 0 {
|
|
|
|
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 节点处理人
|
|
#examineMode 1、依次审批;2、会签;3、或签
|
|
|
|
@ 返回值
|
|
|
|
#userAry 人员列表信息
|
|
|
|
@ 方法原型
|
|
|
|
#func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList)
|
|
*/
|
|
func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) {
|
|
|
|
if len(userList) > 0 {
|
|
var userIdAry []int64
|
|
var oneIdAry []int64
|
|
var roleUserIdAry []int64
|
|
var orgUserIdAry []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)
|
|
oneIdAry = append(oneIdAry, 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...)
|
|
roleUserIdAry = append(roleUserIdAry, 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...)
|
|
orgUserIdAry = append(orgUserIdAry, usIdList...)
|
|
}
|
|
}
|
|
|
|
default:
|
|
}
|
|
}
|
|
fmt.Printf("\n\n\n员工----------->%v------->%v\n\n\n", oneIdAry, userList)
|
|
if len(oneIdAry) > 0 {
|
|
var userOneContMap []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 ?", oneIdAry).Find(&userOneContMap)
|
|
if len(userOneContMap) > 0 {
|
|
for _, v := range oneIdAry {
|
|
for _, uv := range userOneContMap {
|
|
if v == uv.Key {
|
|
userAry = append(userAry, TransformPublicUs(uv))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(roleUserIdAry) > 0 {
|
|
var userRoleContMap []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 ?", roleUserIdAry).Find(&userRoleContMap)
|
|
for _, v := range userRoleContMap {
|
|
userAry = append(userAry, TransformPublicUs(v))
|
|
}
|
|
}
|
|
if len(orgUserIdAry) > 0 {
|
|
var userOrgContMap []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 ?", orgUserIdAry).Find(&userOrgContMap)
|
|
for _, v := range userOrgContMap {
|
|
userAry = append(userAry, TransformPublicUs(v))
|
|
}
|
|
}
|
|
fmt.Printf("\n\n\n员工----1------->%v------->%v\n\n\n", oneIdAry, userAry)
|
|
}
|
|
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
|
|
}
|
|
|
|
if requestData.IsRun == 0 {
|
|
requestData.IsRun = 1
|
|
}
|
|
if requestData.UserKey == "" {
|
|
requestData.IsRun = 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) //获取当前操作人
|
|
|
|
userCont := GainRunPeople(requestData.IsRun, requestData.UserKey, c)
|
|
|
|
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)
|
|
// fmt.Printf("sendInfo.FlowList --->%v\n", sendInfo.FlowList)
|
|
// 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 {
|
|
// // fmt.Printf("获取当前操作人:%v================>%v\n", v.Operator, ov.Operator)
|
|
// 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{}{"`id`": 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.Id, userCont.Key, 1, flowList[stepVal].NodeKey, "撤回申请", "")
|
|
} else {
|
|
FlowRunLog(runFlowInfo.Id, userCont.Key, 1, "", "撤回申请", "")
|
|
}
|
|
|
|
var runEditFlowInfo customerForm.RunWorkflow
|
|
err = runEditFlowInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveFlowInfo)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
var taskInfo customerForm.TaskRecord
|
|
taskInfo.EiteCont(map[string]interface{}{"`runFlowId`": runFlowInfo.Id}, saveTaskInfo)
|
|
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-08-09 10:54:20
|
|
@ 功能: 获取行政组织负责人
|
|
@ 参数
|
|
|
|
#
|
|
|
|
person_in_charge
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func GainOrgManager(orgId []int64) (UserList []OperatorList) {
|
|
// fmt.Printf("\n\n\n指定部门负责人!---------->%v\n\n\n", orgId)
|
|
var keyList []int64
|
|
// 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("`admin_org` IN ? AND `person_in_charge` = ? AND `emp_type` BETWEEN ? AND ?", orgId, 1, 1, 10).Find(&userInfoAry)
|
|
// if len(userInfoAry) > 0 {
|
|
// for _, uv := range userInfoAry {
|
|
// if !publicmethod.IsInTrue[int64](uv.Key, keyList) {
|
|
// UserList = append(UserList, TransformPublicUs(uv))
|
|
// keyList = append(keyList, uv.Key)
|
|
// }
|
|
|
|
// }
|
|
// }
|
|
for _, v := range orgId {
|
|
var userInfoAryes []modelshr.ManCont
|
|
overall.CONSTANT_DB_HrInside.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("FIND_IN_SET(?,`responsible_department`) AND `person_in_charge` = ? AND `emp_type` BETWEEN ? AND ?", v, 1, 1, 10).Find(&userInfoAryes)
|
|
if len(userInfoAryes) > 0 {
|
|
for _, uvs := range userInfoAryes {
|
|
if !publicmethod.IsInTrue[int64](uvs.Key, keyList) {
|
|
UserList = append(UserList, TransformPublicUs(uvs))
|
|
keyList = append(keyList, uvs.Key)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|