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.
1957 lines
63 KiB
1957 lines
63 KiB
package taskmanagement
|
|
|
|
import (
|
|
"appPlatform/api/version1/customerform"
|
|
datacenter "appPlatform/api/version1/dataCenter"
|
|
"appPlatform/api/version1/workWechat"
|
|
"appPlatform/middleware/grocerystore"
|
|
"appPlatform/models/customerForm"
|
|
"appPlatform/models/modelAppPlatform"
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"regexp"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-09-27 14:21:08
|
|
@ 功能: 用户端自定义表单新增记录
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) AddFormAddData(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
|
|
}
|
|
if _, ok := mapData["formId"]; !ok {
|
|
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
|
|
return
|
|
}
|
|
sendData := publicmethod.MapOut[string]()
|
|
var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单
|
|
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["formId"]})
|
|
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", "id"}) {
|
|
masterField[k] = v
|
|
}
|
|
} else {
|
|
sunFieldAry[k] = v
|
|
}
|
|
}
|
|
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context)
|
|
uuid := publicmethod.GetUUid(1)
|
|
cureeTime := time.Now().Unix()
|
|
|
|
master, sunTable, jsonerr := GainFormStruct(formCont.MastesFormJson)
|
|
if jsonerr != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
// master, _, _ := GainFormStruct(formCont.MastesFormJson)
|
|
masterWriteVal := MakeTableVal(uuid, userCont.Key, cureeTime, masterField, master)
|
|
|
|
//任务列表
|
|
var taskCont modelAppPlatform.Task
|
|
taskCont.MastersKey = uuid
|
|
taskCont.Title = fmt.Sprintf("%v-%v(%v)-%v", formCont.Name, userCont.Name, userCont.Number, publicmethod.UnixTimeToDay(cureeTime, 14)) //标题"`
|
|
taskCont.Creater = userCont.Key //创建人"`
|
|
taskCont.CreaterTime = cureeTime //创建时间"`
|
|
taskCont.EditTime = cureeTime //编辑时间"`
|
|
taskCont.Types = 1 //类型(1:普通表单;2:流程表单)"`
|
|
taskCont.VersionId = formCont.Id //来源于哪个表单"`
|
|
taskCont.Status = 2
|
|
//判断是否
|
|
if len(sunFieldAry) > 0 {
|
|
//有子表
|
|
err = WriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masterWriteVal, sunFieldAry, sunTable)
|
|
} else {
|
|
//无子表
|
|
err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Create(masterWriteVal).Error
|
|
}
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
overall.CONSTANT_DB_AppPlatform.Create(&taskCont)
|
|
// sendData["err"] = err
|
|
// sendData["data"] = data
|
|
// sendData["mapData"] = mapData
|
|
// sendData["formCont"] = formCont
|
|
sendData["master"] = master
|
|
sendData["sunTable"] = sunTable
|
|
// sendData["jsonerr"] = jsonerr
|
|
// sendData["jsondfg"] = jsondfg
|
|
// sendData["formJsonCont"] = formJsonCont
|
|
|
|
sendData["master_len"] = len(master)
|
|
sendData["sunTable_len"] = len(sunTable)
|
|
// sendData["masterWriteVal"] = masterWriteVal
|
|
// sendData["sunFormName"] = sunFormName
|
|
// sendData["sunFieldAry"] = sunFieldAry
|
|
sendData["masterField"] = masterField
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-09-28 09:37:49
|
|
@ 功能: 主表与子表数据写入
|
|
@ 参数
|
|
|
|
#uuid 唯一标识
|
|
#creater 创建人
|
|
#createrTime 创建时间
|
|
#masterTableName 主表标识
|
|
#masterDataCont 主表数据
|
|
#sunDataList 字表数据列表
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func WriteSunDatabase(uuid, creater, userOrg, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (err error) {
|
|
if len(masterDataCont) > 0 {
|
|
if len(sunDataList) > 0 {
|
|
sunMasterMap := publicmethod.MapOut[string]()
|
|
//子表存在时,执行主表和子表数据写入
|
|
for k, v := range sunDataList {
|
|
// 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 := MakeFormMapData(uuid, creater, userOrg, createrTime, sdf, sunTableType, 2) //转换数据表值
|
|
if len(masterWriteVal) > 0 {
|
|
sunCont = append(sunCont, masterWriteVal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(sunCont) > 0 {
|
|
sunMasterMap[k] = sunCont
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(sunMasterMap) > 0 {
|
|
gormDb := overall.CONSTANT_DB_CustomerForm.Begin()
|
|
masterErr := gormDb.Table(masterTableName).Create(masterDataCont).Error
|
|
sunCreateIsOk := true
|
|
for k, v := range sunMasterMap {
|
|
sunErr := gormDb.Table(k).Create(v).Error
|
|
if sunErr != nil {
|
|
sunCreateIsOk = false
|
|
break
|
|
}
|
|
}
|
|
if masterErr == nil && sunCreateIsOk {
|
|
err = gormDb.Commit().Error
|
|
publicmethod.WriteLog("write", "写入自定义表单", err, masterDataCont, sunDataList)
|
|
} else {
|
|
gormDb.Rollback()
|
|
err = errors.New("表单数据提交失败!请重新提交")
|
|
publicmethod.WriteLog("e", "写入自定义表单", masterTableName, err)
|
|
}
|
|
} else {
|
|
gormDb := overall.CONSTANT_DB_CustomerForm
|
|
masterErr := gormDb.Table(masterTableName).Create(masterDataCont).Error
|
|
if masterErr != nil {
|
|
publicmethod.WriteLog("write", "写入自定义表单", masterTableName, masterErr)
|
|
}
|
|
}
|
|
} else {
|
|
//子表不存在时,写入主表数据
|
|
err = overall.CONSTANT_DB_CustomerForm.Table(masterTableName).Create(masterDataCont).Error
|
|
publicmethod.WriteLog("write", "写入自定义表单", masterTableName, err)
|
|
}
|
|
} else {
|
|
err = errors.New("表单数据提交失败!请重新提交")
|
|
publicmethod.WriteLog("e", "写入自定义表单", masterTableName, err)
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-09-27 16:01:48
|
|
@ 功能: 组装数据表值
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func MakeTableVal(uuid, userKey, cureeTime int64, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct) map[string]interface{} {
|
|
keyAndVal := make(map[string]interface{})
|
|
keyAndVal["masters_key"] = uuid
|
|
keyAndVal["creater"] = userKey
|
|
keyAndVal["creater_time"] = cureeTime
|
|
keyAndVal["edit_time"] = cureeTime
|
|
for k, v := range fieldVal {
|
|
if v != "" {
|
|
if val, isOk := subUnit[k]; isOk {
|
|
fielfInfoClass := customerform.AnalysisTable(val)
|
|
// fmt.Printf("k--->%v\nv--->%T\nfielfInfoClass------>%v\n\n\n", k, v, fielfInfoClass)
|
|
switch fielfInfoClass.Types {
|
|
case "int", "bigint":
|
|
//值类型是数组,并且需要分开存储
|
|
switch fielfInfoClass.ControlType {
|
|
case "year", "month", "date", "datetime":
|
|
if strVal, ok := v.(string); ok {
|
|
localTime, _ := time.ParseInLocation(time.RFC3339, strVal, time.Local)
|
|
keyAndVal[k] = localTime.Unix()
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "array":
|
|
if fielfInfoClass.Signed {
|
|
kEnd := fmt.Sprintf("%v_end", k)
|
|
if strVal, ok := v.([]interface{}); ok {
|
|
if len(strVal) >= 2 {
|
|
if starTimeStr, tOk := strVal[0].(string); tOk {
|
|
starTime, _ := time.ParseInLocation(time.RFC3339, starTimeStr, time.Local)
|
|
keyAndVal[k] = starTime.Unix()
|
|
} else {
|
|
keyAndVal[k] = strVal[0]
|
|
}
|
|
if endTimeStr, tOk := strVal[len(strVal)-1].(string); tOk {
|
|
endTime, _ := time.ParseInLocation(time.RFC3339, endTimeStr, time.Local)
|
|
keyAndVal[kEnd] = endTime.Unix()
|
|
} else {
|
|
keyAndVal[kEnd] = strVal[len(strVal)-1]
|
|
}
|
|
}
|
|
}
|
|
|
|
} else {
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.ParseInt(strVal, 10, 64)
|
|
keyAndVal[k] = floatVal
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
}
|
|
case "bigint":
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.ParseInt(strVal, 10, 64)
|
|
keyAndVal[k] = floatVal
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "int":
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.Atoi(strVal)
|
|
keyAndVal[k] = floatVal
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "booble":
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.Atoi(strVal)
|
|
keyAndVal[k] = floatVal
|
|
} else if strVal, ok := v.(bool); ok {
|
|
if strVal {
|
|
keyAndVal[k] = fielfInfoClass.DefaultValue
|
|
} else {
|
|
keyAndVal[k] = fielfInfoClass.DefaultValuees
|
|
}
|
|
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
default:
|
|
}
|
|
case "booble":
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.Atoi(strVal)
|
|
keyAndVal[k] = floatVal
|
|
} else if strVal, ok := v.(bool); ok {
|
|
if strVal {
|
|
keyAndVal[k] = fielfInfoClass.DefaultValue
|
|
} else {
|
|
keyAndVal[k] = fielfInfoClass.DefaultValuees
|
|
}
|
|
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "float":
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.ParseFloat(strVal, 64)
|
|
keyAndVal[k] = floatVal
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "decimal":
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.ParseFloat(strVal, 64)
|
|
keyAndVal[k] = floatVal
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "mediumtext", "longtext":
|
|
if valAry, ok := v.([]interface{}); ok {
|
|
if len(valAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else {
|
|
if fielfInfoClass.ControlType == "array" {
|
|
if valStr, ok := v.(string); ok {
|
|
valStrAry := strings.Split(valStr, ",")
|
|
if len(valStrAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valStrAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
}
|
|
default:
|
|
if fielfInfoClass.Types != "" {
|
|
if valAry, ok := v.([]interface{}); ok {
|
|
if len(valAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else {
|
|
if fielfInfoClass.ControlType == "array" {
|
|
if valStr, ok := v.(string); ok {
|
|
valStrAry := strings.Split(valStr, ",")
|
|
if len(valStrAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valStrAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// } else {
|
|
// keyAndVal[k] = v
|
|
// }
|
|
|
|
}
|
|
return keyAndVal
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-09-27 14:30:57
|
|
@ 功能: 获取组件结构体
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func GainFormStruct(formTabelJson string) (master map[string]customerform.MasterStruct, sunTable map[string]map[string]customerform.MasterStruct, err error) {
|
|
//将表格组件json数据转化成结构体
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(formTabelJson), &formJsonCont)
|
|
// fmt.Printf("将表格组件json数据转化成结构体---->%v---->%v\n", err, formTabelJson)
|
|
// if err != nil {
|
|
// return
|
|
// }
|
|
masterAry := make(map[string]customerform.MasterStruct)
|
|
sunTableAry := make(map[string]map[string]customerform.MasterStruct)
|
|
for _, v := range formJsonCont.List {
|
|
switch v.Type {
|
|
case "grid", "tabs":
|
|
if len(v.Columns) > 0 {
|
|
for _, cv := range v.Columns {
|
|
for _, cvl := range cv.List {
|
|
masterAry[cvl.Name] = cvl
|
|
}
|
|
}
|
|
}
|
|
case "card", "div":
|
|
if len(v.List) > 0 {
|
|
for _, cvl := range v.List {
|
|
masterAry[cvl.Name] = cvl
|
|
}
|
|
}
|
|
case "table", "flex":
|
|
if len(v.List) > 0 {
|
|
sunTableGd := make(map[string]customerform.MasterStruct)
|
|
for _, vl := range v.List {
|
|
sunTableGd[vl.Name] = vl
|
|
}
|
|
sunTableAry[v.Name] = sunTableGd
|
|
}
|
|
default:
|
|
// fmt.Printf("获取组件结构体-->%v-->%v\n", v.Name, v)
|
|
if v.Name != "" {
|
|
masterAry[v.Name] = v
|
|
}
|
|
|
|
}
|
|
}
|
|
master = masterAry
|
|
sunTable = sunTableAry
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-10-07 13:18:35
|
|
@ 功能: 用户端自定义表单新增记录(新版)
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) AddFormAddNewData(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
|
|
}
|
|
|
|
if _, ok := mapData["formId"]; !ok {
|
|
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
|
|
return
|
|
}
|
|
var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单
|
|
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["formId"]})
|
|
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", "id"}) {
|
|
masterField[k] = v
|
|
}
|
|
} else {
|
|
sunFieldAry[k] = v
|
|
}
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
uuid := publicmethod.GetUUid(1) //统一识别符
|
|
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
|
|
}
|
|
|
|
masrWriteMap := MakeFormMapData(uuid, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 1)
|
|
masrWriteMap["flowIsOpen"] = formCont.FlowIsOpen
|
|
//任务列表
|
|
var taskCont modelAppPlatform.Task
|
|
taskCont.MastersKey = uuid
|
|
taskCont.Title = fmt.Sprintf("%v-%v(%v)-%v", formCont.Name, userCont.Name, userCont.Number, publicmethod.UnixTimeToDay(cureeTime, 14)) //标题"`
|
|
|
|
taskCont.Creater = userCont.Key //创建人"`
|
|
taskCont.CreaterTime = cureeTime //创建时间"`
|
|
taskCont.EditTime = cureeTime //编辑时间"`
|
|
taskCont.Types = formCont.Classify //类型(1:普通表单;2:流程表单)"`
|
|
taskCont.VersionId = formCont.Id //来源于哪个表单"`
|
|
taskCont.Status = 2
|
|
if formCont.Classify == 2 {
|
|
taskCont.Status = 3
|
|
taskCont.FlowKey = formCont.Flowkey
|
|
var flowInfo modelAppPlatform.FlowVersion
|
|
flowInfo.GetCont(map[string]interface{}{"`key`": formCont.Flowkey, "`state`": 1}, "`id`")
|
|
taskCont.FlowRunSing = flowInfo.Id
|
|
}
|
|
|
|
//判断是否
|
|
if len(sunFieldAry) > 0 {
|
|
//有子表
|
|
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
|
|
for _, v := range formUnitCont.SunFormInfo {
|
|
sunTypeAry[v.TableName] = v.UbitInfo
|
|
}
|
|
|
|
err = WriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
|
|
} else {
|
|
// //无子表
|
|
err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Create(masrWriteMap).Error
|
|
}
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
taskCont.MastesForm = formCont.MastesForm
|
|
taskCont.MastesFormJson = formCont.MastesFormJson
|
|
err = overall.CONSTANT_DB_AppPlatform.Create(&taskCont).Error
|
|
// for k, v := range masrWriteMap {
|
|
// fmt.Printf("%v----> %T\n", k, v)
|
|
// }
|
|
|
|
sendData := publicmethod.MapOut[string]()
|
|
sendData["uuid"] = strconv.FormatInt(uuid, 10)
|
|
sendData["cureeTime"] = cureeTime
|
|
sendData["formUnitCont"] = formUnitCont
|
|
sendData["masterField"] = masterField
|
|
sendData["sunFieldAry"] = sunFieldAry
|
|
sendData["sunFieldAry_len"] = len(sunFieldAry)
|
|
sendData["masrWriteMap"] = masrWriteMap
|
|
sendData["sunFormName"] = sunFormName
|
|
sendData["mapData"] = mapData
|
|
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-10-07 15:35:07
|
|
@ 功能: 组装数据表新增数据
|
|
@ 参数
|
|
|
|
#uuid 统一识别符
|
|
#userKey 当前操作人
|
|
#cureeTime 操作时间
|
|
#fieldVal 提交数据得键值对
|
|
#subUnit 组件信息
|
|
#calss 1:新增;2:编辑
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func MakeFormMapData(uuid, userKey, userOrg, cureeTime int64, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct, calss int) map[string]interface{} {
|
|
keyAndVal := make(map[string]interface{})
|
|
if calss == 1 {
|
|
keyAndVal["creater_time"] = cureeTime
|
|
}
|
|
keyAndVal["masters_key"] = uuid
|
|
keyAndVal["creater"] = userKey
|
|
keyAndVal["createrOrg"] = userOrg
|
|
keyAndVal["edit_time"] = cureeTime
|
|
for k, v := range fieldVal {
|
|
fmt.Printf("写入字段:%v->%v\n", k, v)
|
|
if k == "id" {
|
|
keyAndVal[k] = v
|
|
}
|
|
if v != "" {
|
|
if val, isOk := subUnit[k]; isOk {
|
|
fmt.Printf("写入字段--->:%v->%v\n", k, val)
|
|
fielfInfoClass := customerform.AnalysisFormUnitClass(val)
|
|
switch fielfInfoClass.FieldType {
|
|
case "int":
|
|
if strVal, ok := v.(string); ok {
|
|
keyAndVal[k], _ = strconv.Atoi(strVal)
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "bigint":
|
|
if fielfInfoClass.ValIsAry { //判断值是否为数组
|
|
endField := fmt.Sprintf("%v_end", k)
|
|
if strVal, ok := v.([]interface{}); ok {
|
|
if len(strVal) >= 2 {
|
|
if starTimeStr, tOk := strVal[0].(string); tOk {
|
|
keyAndVal[k], _ = strconv.ParseInt(starTimeStr, 10, 64)
|
|
} else {
|
|
keyAndVal[k] = strVal[0]
|
|
}
|
|
if endTimeStr, tOk := strVal[len(strVal)-1].(string); tOk {
|
|
keyAndVal[endField], _ = strconv.ParseInt(endTimeStr, 10, 64)
|
|
} else {
|
|
keyAndVal[endField] = strVal[len(strVal)-1]
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if strVal, ok := v.(string); ok {
|
|
fieldVal, _ := strconv.ParseInt(strVal, 10, 64)
|
|
keyAndVal[k] = fieldVal
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
}
|
|
case "float":
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.ParseFloat(strVal, 64)
|
|
keyAndVal[k] = floatVal
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "decimal":
|
|
if strVal, ok := v.(string); ok {
|
|
floatVal, _ := strconv.ParseFloat(strVal, 64)
|
|
keyAndVal[k] = floatVal
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
case "mediumtext", "longtext":
|
|
if valAry, ok := v.([]interface{}); ok {
|
|
if len(valAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else {
|
|
if fielfInfoClass.ValIsAry && fielfInfoClass.UnitName != "upload" {
|
|
if valStr, ok := v.(string); ok {
|
|
valStrAry := strings.Split(valStr, ",")
|
|
if len(valStrAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valStrAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else if valAry, ok := v.([]interface{}); ok {
|
|
if len(valAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
}
|
|
case "varchar":
|
|
if valAry, ok := v.([]interface{}); ok {
|
|
if len(valAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else {
|
|
if fielfInfoClass.ValIsAry {
|
|
if valStr, ok := v.(string); ok {
|
|
valStrAry := strings.Split(valStr, ",")
|
|
if len(valStrAry) > 0 {
|
|
valStrJson, _ := json.Marshal(valStrAry)
|
|
keyAndVal[k] = string(valStrJson)
|
|
} else {
|
|
keyAndVal[k] = ""
|
|
}
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
} else {
|
|
keyAndVal[k] = v
|
|
}
|
|
}
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return keyAndVal
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-03 09:40:31
|
|
@ 功能:用户端自定义表单新增记录(列表新版)
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) AddCustomerForm(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
|
|
}
|
|
status := 2
|
|
if _, ok := mapData["formId"]; !ok {
|
|
publicmethod.Result(1, err, c, "非法表单!不能提交数据!")
|
|
return
|
|
}
|
|
var appKey int64 = 0
|
|
if appKeyVal, ok := mapData["appKey"]; ok {
|
|
appKey, _ = publicmethod.StringToInt64(appKeyVal)
|
|
}
|
|
var tableKey int64 = 0
|
|
if tableVal, ok := mapData["versionId"]; ok {
|
|
tableKey, _ = publicmethod.StringToInt64(tableVal)
|
|
}
|
|
|
|
if val, ok := mapData["status"]; !ok {
|
|
if valInt, isTrue := val.(int); isTrue {
|
|
status = valInt
|
|
if valInt <= 0 {
|
|
status = 2
|
|
}
|
|
}
|
|
} else {
|
|
status = 2
|
|
}
|
|
var formCont modelAppPlatform.CustomerFormView //获取指定版本的表单
|
|
err = formCont.GetCont(map[string]interface{}{"`id`": mapData["formId"]})
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
if appKey == 0 {
|
|
appKey = formCont.Groupid
|
|
}
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var formJsonCont customerform.CustomerFormMaster
|
|
json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont)
|
|
|
|
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", "id"}) {
|
|
masterField[k] = v
|
|
}
|
|
} else {
|
|
sunFieldAry[k] = v
|
|
}
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
uuid := publicmethod.GetUUid(1) //统一识别符
|
|
cureeTime := time.Now().Unix() //写入时间
|
|
|
|
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
|
|
}
|
|
|
|
masrWriteMap := MakeFormMapData(uuid, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 1)
|
|
masrWriteMap["flowIsOpen"] = formCont.FlowIsOpen
|
|
//任务列表
|
|
var taskCont customerForm.TaskRecord
|
|
taskCont.MastersKey = uuid
|
|
taskCont.Title = fmt.Sprintf("%v-%v(%v)-%v", formCont.Name, userCont.Name, userCont.Number, publicmethod.UnixTimeToDay(cureeTime, 14)) //标题"`
|
|
taskCont.AppKey = appKey
|
|
taskCont.TableKey = tableKey
|
|
taskCont.Creater = userCont.Key //创建人"`
|
|
taskCont.CreaterTime = cureeTime //创建时间"`
|
|
taskCont.EditTime = cureeTime //编辑时间"`
|
|
taskCont.Types = formCont.FlowIsOpen //类型(1:流程表单;2:普通表单)"`
|
|
taskCont.VersionId = formCont.Id //来源于哪个表单"`
|
|
taskCont.Status = status
|
|
taskCont.CreaterOrg = userCont.AdminOrg
|
|
if formCont.FlowIsOpen == 1 {
|
|
taskCont.Status = 3
|
|
taskCont.FlowKey = formCont.Flowkey
|
|
var flowInfo modelAppPlatform.FlowVersion
|
|
flowInfo.GetCont(map[string]interface{}{"`key`": formCont.Flowkey, "`state`": 1}, "`id`")
|
|
taskCont.FlowRunSing = flowInfo.Id
|
|
}
|
|
taskCont.MastesForm = formCont.MastesForm
|
|
taskCont.MastesFormJson = formCont.MastesFormJson
|
|
err = overall.CONSTANT_DB_CustomerForm.Create(&taskCont).Error
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "任务创建失败!")
|
|
return
|
|
}
|
|
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
|
|
}
|
|
}
|
|
|
|
//判断是否
|
|
if len(sunFieldAry) > 0 {
|
|
//有子表
|
|
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
|
|
for _, v := range formUnitCont.SunFormInfo {
|
|
sunTypeAry[v.TableName] = v.UbitInfo
|
|
}
|
|
|
|
err = WriteSunDatabaseSoucer(sqlDborm, uuid, userCont.Key, userCont.AdminOrg, cureeTime, formJsonCont.Form.DataSourceConfig.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
|
|
|
|
} else {
|
|
// //无子表
|
|
err = sqlDborm.Table(formJsonCont.Form.DataSourceConfig.TableKey).Create(masrWriteMap).Error
|
|
publicmethod.WriteLog("write", "写入自定义表单", formJsonCont.Form.DataSourceConfig.TableKey, err)
|
|
}
|
|
|
|
} else {
|
|
|
|
//判断是否
|
|
if len(sunFieldAry) > 0 {
|
|
//有子表
|
|
sunTypeAry := make(map[string]map[string]customerform.MasterStruct)
|
|
for _, v := range formUnitCont.SunFormInfo {
|
|
sunTypeAry[v.TableName] = v.UbitInfo
|
|
}
|
|
|
|
err = WriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry)
|
|
|
|
} else {
|
|
// //无子表
|
|
err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Create(masrWriteMap).Error
|
|
publicmethod.WriteLog("write", "写入自定义表单", formCont.TableKey, err)
|
|
}
|
|
}
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
|
|
// for k, v := range masrWriteMap {
|
|
// fmt.Printf("%v----> %T\n", k, v)
|
|
// }
|
|
publicmethod.WriteLog("write", "写入任务", err, taskCont)
|
|
|
|
sendData := publicmethod.MapOut[string]()
|
|
sendData["uuid"] = strconv.FormatInt(uuid, 10)
|
|
sendData["cureeTime"] = cureeTime
|
|
sendData["formUnitCont"] = formUnitCont
|
|
sendData["masterField"] = masterField
|
|
sendData["masterUnitList"] = masterUnitList
|
|
sendData["sunFieldAry"] = sunFieldAry
|
|
sendData["sunFieldAry_len"] = len(sunFieldAry)
|
|
sendData["masrWriteMap"] = masrWriteMap
|
|
sendData["sunFormName"] = sunFormName
|
|
sendData["mapData"] = mapData
|
|
//判断是否要发送信息
|
|
if formCont.ListJson != "" {
|
|
var sendMsgInterface FormListInfo
|
|
json.Unmarshal([]byte(formCont.ListJson), &sendMsgInterface)
|
|
|
|
var sendMsgInfo SendMsgInfo
|
|
sendMsgInfo = sendMsgInterface.SendMsg
|
|
// msgid, _ := sendMsgInfo.SendMsg(userCont, taskCont.Title, uuid, cureeTime, masterField, masrWriteMap, masterUnitList)
|
|
msgid, _ := sendMsgInfo.NewSendMsg(userCont, uuid, cureeTime, taskCont.Title, masterField, masrWriteMap, masterUnitList)
|
|
fmt.Printf("发送返回信息------------->%v\n\n\n", msgid)
|
|
if msgid != "" {
|
|
//设定redis Key名称
|
|
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", uuid)
|
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
|
|
redisClient.SetRedisTime(86400)
|
|
redisClient.Set(redisKey, msgid)
|
|
}
|
|
// sendConfig := sendMsgInterface.SendMsg
|
|
// if sendConfig.Open {
|
|
// msgTitle := taskCont.Title
|
|
// if len(sendConfig.Title) > 0 {
|
|
|
|
// }
|
|
// sendData["msgTitle"] = msgTitle
|
|
// switch sendConfig.SendRange {
|
|
// }
|
|
// }
|
|
}
|
|
|
|
publicmethod.Result(0, sendData, c)
|
|
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-31 13:54:38
|
|
@ 功能: 获取单一字段的数据
|
|
*/
|
|
func (s *SendMsgInfo) GainOneField(fields string, msgTitle string, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct) string {
|
|
var sendData interface{}
|
|
if val, isOk := fieldVal[fields]; isOk {
|
|
sendData = val
|
|
}
|
|
unitCont := GainFieldType(fields, subUnit)
|
|
switch unitCont.Type {
|
|
case "input", "password", "lowcodeImage": //单行文本
|
|
msgTitle = publicmethod.TypeToInterface(sendData)
|
|
case "textarea", "tinymce": //多行文本,富文本
|
|
msgTitle = publicmethod.TypeToInterface(sendData)
|
|
case "radio", "select": //单选框组、下拉选择框
|
|
val := publicmethod.TypeToInterface(sendData)
|
|
if len(unitCont.Options) > 0 {
|
|
for _, uv := range unitCont.Options {
|
|
if uv.Value == val {
|
|
msgTitle = uv.Label
|
|
}
|
|
}
|
|
}
|
|
case "checkbox", "cascader", "treeSelect", "upload": //checkbox,级联选择器,树形控件,图片/文件: ,
|
|
if valMap, isOk := sendData.([]int); isOk {
|
|
if len(valMap) > 0 && len(unitCont.Options) > 0 {
|
|
var titalMap []string
|
|
for _, v := range valMap {
|
|
for _, uv := range unitCont.Options {
|
|
if uv.Value == strconv.Itoa(v) {
|
|
titalMap = append(titalMap, uv.Label)
|
|
}
|
|
}
|
|
}
|
|
msgTitle = fmt.Sprintf("\"%v\"", strings.Join(titalMap, "、"))
|
|
}
|
|
}
|
|
case "expand-user": //选择用户
|
|
val := publicmethod.TypeToInterface(sendData)
|
|
var userNumber []string
|
|
ruleSet := regexp.MustCompile(`\(([^)]+)\)`)
|
|
valMap := ruleSet.FindAllStringSubmatch(val, -1)
|
|
if len(valMap) > 0 {
|
|
for _, v := range valMap {
|
|
vLen := len(v)
|
|
if vLen > 0 {
|
|
if !publicmethod.IsInTrue(v[vLen-1], userNumber) {
|
|
userNumber = append(userNumber, fmt.Sprintf("%v(%v)", v[0], v[vLen-1]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
msgTitle = fmt.Sprintf("\"%v\"", strings.Join(userNumber, "、"))
|
|
case "datePicker": //日期选择器
|
|
if strVal, ok := sendData.([]interface{}); ok {
|
|
strValLen := len(strVal)
|
|
if strValLen > 1 {
|
|
startTimg, _ := publicmethod.StringToInt64(strVal[0])
|
|
endTime, _ := publicmethod.StringToInt64(strVal[strValLen-1])
|
|
msgTitle = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg/1000, 14), publicmethod.TypeToClass(endTime/1000, 14))
|
|
} else if strValLen == 1 {
|
|
startTimg, _ := publicmethod.StringToInt64(strVal[0])
|
|
msgTitle = publicmethod.TypeToClass(startTimg/1000, 14)
|
|
}
|
|
} else {
|
|
startTimg, _ := publicmethod.StringToInt64(sendData)
|
|
msgTitle = publicmethod.TypeToClass(startTimg, 14)
|
|
}
|
|
case "timePicker", "inputNumber": //时间选择器,计数器
|
|
if strVal, ok := sendData.([]interface{}); ok {
|
|
strValLen := len(strVal)
|
|
if strValLen > 1 {
|
|
startTimg, _ := publicmethod.StringToInt64(strVal[0])
|
|
endTime, _ := publicmethod.StringToInt64(strVal[strValLen-1])
|
|
msgTitle = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg/1000, 14), publicmethod.TypeToClass(endTime/1000, 14))
|
|
} else if strValLen == 1 {
|
|
startTimg, _ := publicmethod.StringToInt64(strVal[0])
|
|
msgTitle = publicmethod.TypeToClass(startTimg/1000, 14)
|
|
}
|
|
} else {
|
|
startTimg, _ := publicmethod.StringToInt64(sendData)
|
|
msgTitle = publicmethod.TypeToClass(startTimg, 14)
|
|
}
|
|
case "colorPicker": //取色器
|
|
msgTitle = publicmethod.TypeToInterface(sendData)
|
|
case "switch": //开关
|
|
startTimg, _ := publicmethod.StringToInt64(sendData)
|
|
if startTimg == 1 {
|
|
msgTitle = "是"
|
|
} else {
|
|
msgTitle = "否"
|
|
}
|
|
case "rate", "slider": //评分,滑块
|
|
msgTitle = publicmethod.TypeToInterface(sendData)
|
|
case "txt", "button", "title", "table", "grid", "tabs", "card", "flex", "divider", "div": //文本,按钮,标题,表格,格栅,标签,卡片布局,弹性布局,分割线,容器
|
|
msgTitle = publicmethod.TypeToInterface(sendData)
|
|
case "component": //自定义组件 (格式待定)
|
|
msgTitle = publicmethod.TypeToInterface(sendData)
|
|
default:
|
|
msgTitle = publicmethod.TypeToInterface(sendData)
|
|
}
|
|
return msgTitle
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-28 15:48:28
|
|
@ 功能: 获取发送标题
|
|
*/
|
|
func (s *SendMsgInfo) SendMsgInfo(fields []string, msgTitle string, fieldVal, masrWriteMap map[string]interface{}, subUnit map[string]customerform.MasterStruct, linkClass int) string {
|
|
|
|
linkStr := "\n"
|
|
if linkClass == 1 {
|
|
linkStr = " - "
|
|
}
|
|
|
|
fmt.Printf("\n\n应获取的字段--->%v--->%v--->%v\n\n", fields, linkClass, linkStr)
|
|
|
|
if len(fields) > 0 {
|
|
biaotiYUneirong := ""
|
|
for _, v := range fields {
|
|
var sendData interface{}
|
|
if val, isOk := fieldVal[v]; isOk {
|
|
sendData = val
|
|
} else if vals, isTrue := masrWriteMap[v]; isTrue {
|
|
sendData = vals
|
|
}
|
|
if sendData == nil {
|
|
sendData = ""
|
|
}
|
|
|
|
titleAry := strings.Split(v, "|#|")
|
|
if len(titleAry) >= 2 {
|
|
if biaotiYUneirong != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, titleAry[0])
|
|
} else {
|
|
biaotiYUneirong = titleAry[0]
|
|
}
|
|
} else {
|
|
|
|
unitCont := GainFieldType(v, subUnit)
|
|
fmt.Printf("\n\n应获取的字段--1----Label:%v----sendData:%T--------------->v:%v--->Type:%v--->sendData:%v\n\n", unitCont.Item.Label, sendData, v, unitCont.Type, sendData)
|
|
switch unitCont.Type {
|
|
case "input", "password", "lowcodeImage": //单行文本
|
|
if unitCont.Item.Label != "" {
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, sendData)
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
}
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, sendData)
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, sendData)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
case "textarea", "tinymce": //多行文本,富文本
|
|
if unitCont.Item.Label != "" {
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, sendData)
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, sendData)
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, sendData)
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, sendData)
|
|
}
|
|
}
|
|
case "radio", "select": //单选框组、下拉选择框
|
|
if unitCont.Item.Label != "" {
|
|
val := publicmethod.TypeToInterface(sendData)
|
|
if len(unitCont.Options) > 0 {
|
|
for _, uv := range unitCont.Options {
|
|
if uv.Value == val {
|
|
// biaotiYUneirong = uv.Label
|
|
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, uv.Label)
|
|
} else {
|
|
biaotiYUneirong = uv.Label
|
|
}
|
|
// biaotiYUneirong = uv.Label
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, uv.Label)
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, uv.Label)
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, uv.Label)
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
case "checkbox", "cascader", "treeSelect", "upload": //checkbox,级联选择器,树形控件,图片/文件: ,
|
|
if unitCont.Item.Label != "" {
|
|
if valMap, isOk := sendData.([]int); isOk {
|
|
if len(valMap) > 0 && len(unitCont.Options) > 0 {
|
|
var titalMap []string
|
|
for _, v := range valMap {
|
|
for _, uv := range unitCont.Options {
|
|
if uv.Value == strconv.Itoa(v) {
|
|
titalMap = append(titalMap, uv.Label)
|
|
}
|
|
}
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("\"%v\"", strings.Join(titalMap, "、"))
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, strings.Join(titalMap, "、"))
|
|
} else {
|
|
biaotiYUneirong = strings.Join(titalMap, "、")
|
|
}
|
|
// biaotiYUneirong = strings.Join(titalMap, "、")
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, strings.Join(titalMap, "、"))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, strings.Join(titalMap, "、"))
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, strings.Join(titalMap, "、"))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
case "expand-user": //选择用户
|
|
if unitCont.Item.Label != "" {
|
|
val := publicmethod.TypeToInterface(sendData)
|
|
var userNumber []string
|
|
ruleSet := regexp.MustCompile(`\(([^)]+)\)`)
|
|
valMap := ruleSet.FindAllStringSubmatch(val, -1)
|
|
if len(valMap) > 0 {
|
|
for _, v := range valMap {
|
|
vLen := len(v)
|
|
if vLen > 0 {
|
|
if !publicmethod.IsInTrue(v[vLen-1], userNumber) {
|
|
userNumber = append(userNumber, fmt.Sprintf("%v(%v)", v[0], v[vLen-1]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("\"%v\"", strings.Join(userNumber, "、"))
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, strings.Join(userNumber, "、"))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("\"%v\"", strings.Join(userNumber, "、"))
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("\"%v\"", strings.Join(userNumber, "、"))
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, strings.Join(userNumber, "、"))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, fmt.Sprintf("\"%v\"", strings.Join(userNumber, "、")))
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, fmt.Sprintf("\"%v\"", strings.Join(userNumber, "、")))
|
|
}
|
|
}
|
|
case "datePicker": //日期选择器
|
|
if unitCont.Item.Label != "" {
|
|
if strVal, ok := sendData.([]interface{}); ok {
|
|
strValLen := len(strVal)
|
|
if strValLen > 1 {
|
|
startTimg, _ := publicmethod.StringToInt64(strVal[0])
|
|
endTime, _ := publicmethod.StringToInt64(strVal[strValLen-1])
|
|
|
|
if publicmethod.GetIntLength(startTimg) == 13 {
|
|
startTimg = startTimg / 1000
|
|
}
|
|
if publicmethod.GetIntLength(endTime) == 13 {
|
|
endTime = endTime / 1000
|
|
}
|
|
|
|
// biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14))
|
|
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14)))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14))
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14))
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14)))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14)))
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14)))
|
|
}
|
|
} else if strValLen == 1 {
|
|
startTimg, _ := publicmethod.StringToInt64(strVal[0])
|
|
// biaotiYUneirong = publicmethod.TypeToClass(startTimg/1000, 14)
|
|
if publicmethod.GetIntLength(startTimg) == 13 {
|
|
startTimg = startTimg / 1000
|
|
}
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToClass(startTimg, 14))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, publicmethod.TypeToClass(startTimg, 14))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, publicmethod.TypeToClass(startTimg, 14))
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, publicmethod.TypeToClass(startTimg, 14))
|
|
}
|
|
}
|
|
} else {
|
|
startTimg, _ := publicmethod.StringToInt64(sendData)
|
|
if publicmethod.GetIntLength(startTimg) == 13 {
|
|
startTimg = startTimg / 1000
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToClass(startTimg, 14))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, publicmethod.TypeToClass(startTimg, 14))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, publicmethod.TypeToClass(startTimg, 14))
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, publicmethod.TypeToClass(startTimg, 14))
|
|
}
|
|
}
|
|
}
|
|
case "timePicker", "inputNumber": //时间选择器,计数器
|
|
if unitCont.Item.Label != "" {
|
|
if strVal, ok := sendData.([]interface{}); ok {
|
|
strValLen := len(strVal)
|
|
if strValLen > 1 {
|
|
startTimg, _ := publicmethod.StringToInt64(strVal[0])
|
|
endTime, _ := publicmethod.StringToInt64(strVal[strValLen-1])
|
|
if publicmethod.GetIntLength(startTimg) == 13 {
|
|
startTimg = startTimg / 1000
|
|
}
|
|
if publicmethod.GetIntLength(endTime) == 13 {
|
|
endTime = endTime / 1000
|
|
}
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14)))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14))
|
|
}
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14)))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14)))
|
|
}
|
|
}
|
|
|
|
// biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg, 14), publicmethod.TypeToClass(endTime, 14))
|
|
} else if strValLen == 1 {
|
|
startTimg, _ := publicmethod.StringToInt64(strVal[0])
|
|
if publicmethod.GetIntLength(startTimg) == 13 {
|
|
startTimg = startTimg / 1000
|
|
}
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToClass(startTimg, 14))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
}
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, publicmethod.TypeToClass(startTimg, 14))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, publicmethod.TypeToClass(startTimg, 14))
|
|
}
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
}
|
|
} else {
|
|
startTimg, _ := publicmethod.StringToInt64(sendData)
|
|
if publicmethod.GetIntLength(startTimg) == 13 {
|
|
startTimg = startTimg / 1000
|
|
}
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToClass(startTimg, 14))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
}
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, publicmethod.TypeToClass(startTimg, 14))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, publicmethod.TypeToClass(startTimg, 14))
|
|
}
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14)
|
|
}
|
|
}
|
|
case "colorPicker": //取色器
|
|
if unitCont.Item.Label != "" {
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToInterface(sendData))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
}
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, publicmethod.TypeToInterface(sendData))
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, publicmethod.TypeToInterface(sendData))
|
|
}
|
|
}
|
|
|
|
// if biaotiYUneirong == "" {
|
|
// biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
// } else {
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, sendData)
|
|
// }
|
|
}
|
|
case "switch": //开关
|
|
if unitCont.Item.Label != "" {
|
|
startTimg, _ := publicmethod.StringToInt64(sendData)
|
|
kaiGuan := "否"
|
|
if startTimg == 1 {
|
|
kaiGuan = "是"
|
|
} else {
|
|
kaiGuan = "否"
|
|
}
|
|
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, kaiGuan)
|
|
} else {
|
|
biaotiYUneirong = kaiGuan
|
|
}
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, kaiGuan)
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, kaiGuan)
|
|
}
|
|
}
|
|
}
|
|
case "rate", "slider": //评分,滑块
|
|
if unitCont.Item.Label != "" {
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToInterface(sendData))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, sendData)
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, sendData)
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, sendData)
|
|
}
|
|
}
|
|
case "txt", "button", "title", "table", "grid", "tabs", "card", "flex", "divider", "div": //文本,按钮,标题,表格,格栅,标签,卡片布局,弹性布局,分割线,容器
|
|
if unitCont.Item.Label != "" {
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToInterface(sendData))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, sendData)
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, sendData)
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, sendData)
|
|
}
|
|
}
|
|
case "component": //自定义组件 (格式待定)
|
|
if unitCont.Item.Label != "" {
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToInterface(sendData))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, sendData)
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, sendData)
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, sendData)
|
|
}
|
|
}
|
|
default:
|
|
if unitCont.Item.Label != "" {
|
|
if biaotiYUneirong == "" {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v:%v", unitCont.Item.Label, publicmethod.TypeToInterface(sendData))
|
|
} else {
|
|
biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
}
|
|
// biaotiYUneirong = publicmethod.TypeToInterface(sendData)
|
|
} else {
|
|
if unitCont.Item.Label != "" {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v:%v", biaotiYUneirong, linkStr, unitCont.Item.Label, sendData)
|
|
} else {
|
|
biaotiYUneirong = fmt.Sprintf("%v%v%v", biaotiYUneirong, linkStr, sendData)
|
|
}
|
|
// biaotiYUneirong = fmt.Sprintf("%v\n%v", biaotiYUneirong, sendData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fmt.Printf("\n\n应获取的字段-3-->%v\n\n", biaotiYUneirong)
|
|
return biaotiYUneirong
|
|
}
|
|
return msgTitle
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-28 15:52:29
|
|
@ 功能: 获取字段类型
|
|
*/
|
|
func GainFieldType(fields string, subUnit map[string]customerform.MasterStruct) (unitInfo customerform.MasterStruct) {
|
|
if fields != "" {
|
|
if val, isOk := subUnit[fields]; isOk {
|
|
unitInfo = val
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-28 15:10:14
|
|
@ 功能: 处理自定义人员
|
|
*/
|
|
func (s *SendMsgInfo) CustomizeSendMsg() (wechatMap []string) {
|
|
if len(s.SendRangeList) > 0 {
|
|
var Recipient []string
|
|
var orgAry []string
|
|
var userAry []string
|
|
for _, v := range s.SendRangeList {
|
|
if v.Types == "masterOrg" {
|
|
if !publicmethod.IsInTrue[string](v.Id, orgAry) {
|
|
orgAry = append(orgAry, v.Id)
|
|
}
|
|
} else {
|
|
if !publicmethod.IsInTrue[string](v.Id, userAry) {
|
|
userAry = append(userAry, v.Id)
|
|
}
|
|
}
|
|
}
|
|
if len(orgAry) > 0 {
|
|
for _, ov := range orgAry {
|
|
val, _ := publicmethod.StringToInt64(ov)
|
|
if val != 0 {
|
|
//获取该组织得所以下级
|
|
Recipient = append(Recipient, GainOrgManWechat(val)...)
|
|
}
|
|
}
|
|
}
|
|
if len(userAry) > 0 {
|
|
var orgManList []modelshr.PersonArchives
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND `id` IN ?", userAry).Find(&orgManList)
|
|
if len(orgManList) > 0 {
|
|
for _, v := range orgManList {
|
|
if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, Recipient) {
|
|
Recipient = append(Recipient, v.Wechat)
|
|
}
|
|
if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, Recipient) {
|
|
Recipient = append(Recipient, v.WorkWechat)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//人员去重
|
|
if len(Recipient) > 0 {
|
|
for _, v := range Recipient {
|
|
if !publicmethod.IsInTrue[string](v, wechatMap) {
|
|
wechatMap = append(wechatMap, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-28 13:20:44
|
|
@ 功能: 处理自定义表格字段发送乏味
|
|
*/
|
|
func (s *SendMsgInfo) TableFieldsSendMsg(fieldVal map[string]interface{}, userCont modelshr.ManCont) (wechatMap []string) {
|
|
if len(s.SendRangeList) > 0 {
|
|
var Recipient []string
|
|
for _, v := range s.SendRangeList {
|
|
for fi, fv := range fieldVal {
|
|
if v.Id == fi {
|
|
switch v.Types {
|
|
case "orgCentent": //选择组织
|
|
val, _ := publicmethod.StringToInt64(fv)
|
|
if val != 0 {
|
|
//获取该组织得所以下级
|
|
Recipient = append(Recipient, GainOrgManWechat(val)...)
|
|
}
|
|
case "founder": //创建人
|
|
if userCont.WorkWechat != "" {
|
|
Recipient = append(Recipient, userCont.WorkWechat)
|
|
} else {
|
|
Recipient = append(Recipient, userCont.Wechat)
|
|
}
|
|
case "owner": //拥有者
|
|
val := publicmethod.TypeToInterface(fv)
|
|
if val != "" {
|
|
if len(val) >= 10 {
|
|
var orgMan modelshr.PersonArchives
|
|
orgMan.GetCont(map[string]interface{}{"`key`": val}, "`wechat`", "`work_wechat`")
|
|
if orgMan.WorkWechat != "" {
|
|
Recipient = append(Recipient, orgMan.WorkWechat)
|
|
} else if orgMan.Wechat != "" {
|
|
Recipient = append(Recipient, orgMan.Wechat)
|
|
}
|
|
}
|
|
} else {
|
|
orgId, _ := strconv.ParseInt(val, 10, 64)
|
|
Recipient = append(Recipient, GainOrgManWechat(orgId)...)
|
|
}
|
|
case "deptOrg": //所属部门
|
|
val, _ := publicmethod.StringToInt64(fv)
|
|
if val != 0 {
|
|
//获取该组织得所以下级
|
|
Recipient = append(Recipient, GainOrgManWechat(val)...)
|
|
}
|
|
case "pickpost": //岗位选择
|
|
val := publicmethod.TypeToInterface(fv)
|
|
if val != "" {
|
|
postMap := strings.Split(val, "#@#")
|
|
if len(postMap) >= 2 {
|
|
Recipient = append(Recipient, RecipientPost(postMap)...)
|
|
}
|
|
}
|
|
case "pickrole": //角色选择
|
|
val := publicmethod.TypeToInterface(fv)
|
|
if val != "" {
|
|
Recipient = append(Recipient, RecipientRole(val)...)
|
|
}
|
|
case "expand-user": //选择用户
|
|
val := publicmethod.TypeToInterface(fv)
|
|
if val != "" {
|
|
Recipient = append(Recipient, RegexpToMap(val)...)
|
|
}
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(Recipient) > 0 {
|
|
for _, v := range Recipient {
|
|
if !publicmethod.IsInTrue[string](v, wechatMap) {
|
|
wechatMap = append(wechatMap, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-28 14:49:38
|
|
@ 功能: 通过角色获取接收人员
|
|
*/
|
|
func RecipientRole(val string) (wechatMap []string) {
|
|
if val != "" {
|
|
var orgManList []modelshr.PersonArchives
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND FIND_IN_SET(?,`role`)", val).Find(&orgManList)
|
|
if len(orgManList) > 0 {
|
|
for _, v := range orgManList {
|
|
if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, wechatMap) {
|
|
wechatMap = append(wechatMap, v.Wechat)
|
|
}
|
|
if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, wechatMap) {
|
|
wechatMap = append(wechatMap, v.WorkWechat)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-28 14:41:25
|
|
@ 功能: 根据岗位获取接收人
|
|
*/
|
|
func RecipientPost(val []string) (wechatMap []string) {
|
|
vLen := len(val)
|
|
if vLen > 0 {
|
|
var orgManList []modelshr.PersonArchives
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND `position` = ?", val[vLen-1]).Find(&orgManList)
|
|
if len(orgManList) > 0 {
|
|
for _, v := range orgManList {
|
|
if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, wechatMap) {
|
|
wechatMap = append(wechatMap, v.Wechat)
|
|
}
|
|
if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, wechatMap) {
|
|
wechatMap = append(wechatMap, v.WorkWechat)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-28 13:59:42
|
|
@ 功能: 通过正则表达式获取人员编号
|
|
*/
|
|
func RegexpToMap(val string) (wechatMap []string) {
|
|
if val != "" {
|
|
var userNumber []string
|
|
ruleSet := regexp.MustCompile(`\(([^)]+)\)`)
|
|
valMap := ruleSet.FindAllStringSubmatch(val, -1)
|
|
if len(valMap) > 0 {
|
|
for _, v := range valMap {
|
|
vLen := len(v)
|
|
if vLen > 0 {
|
|
if !publicmethod.IsInTrue(v[vLen-1], userNumber) {
|
|
userNumber = append(userNumber, v[vLen-1])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(userNumber) > 0 {
|
|
var orgManList []modelshr.PersonArchives
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND `number` IN ?", userNumber).Find(&orgManList)
|
|
if len(orgManList) > 0 {
|
|
for _, v := range orgManList {
|
|
if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, wechatMap) {
|
|
wechatMap = append(wechatMap, v.Wechat)
|
|
}
|
|
if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, wechatMap) {
|
|
wechatMap = append(wechatMap, v.WorkWechat)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-28 10:58:27
|
|
@ 功能: 根据行政组织获取所有下级人员
|
|
*/
|
|
func GainOrgManWechat(orgId int64) (wechatMap []string) {
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
sunOrg.GetOrgSun(orgId)
|
|
sunOrg.Id = append(sunOrg.Id, orgId)
|
|
var orgManList []modelshr.PersonArchives
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND `admin_org` IN ?", sunOrg.Id).Find(&orgManList)
|
|
if len(orgManList) > 0 {
|
|
for _, v := range orgManList {
|
|
if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, wechatMap) {
|
|
wechatMap = append(wechatMap, v.Wechat)
|
|
}
|
|
if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, wechatMap) {
|
|
wechatMap = append(wechatMap, v.WorkWechat)
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-01-03 16:22:20
|
|
@ 功能: 处理有源数据库数据
|
|
@ 参数
|
|
|
|
#sqlDb 数据库句柄
|
|
#uuid 唯一标识
|
|
#creater 创建人
|
|
#createrTime 创建时间
|
|
#masterTableName 主表标识
|
|
#masterDataCont 主表数据
|
|
#sunDataList 字表数据列表
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func WriteSunDatabaseSoucer(sqlDb *gorm.DB, uuid, creater, userOrg, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (err error) {
|
|
if len(masterDataCont) > 0 {
|
|
if len(sunDataList) > 0 {
|
|
sunMasterMap := publicmethod.MapOut[string]()
|
|
//子表存在时,执行主表和子表数据写入
|
|
for k, v := range sunDataList {
|
|
// 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 := MakeFormMapData(uuid, creater, userOrg, createrTime, sdf, sunTableType, 2) //转换数据表值
|
|
if len(masterWriteVal) > 0 {
|
|
sunCont = append(sunCont, masterWriteVal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(sunCont) > 0 {
|
|
sunMasterMap[k] = sunCont
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(sunMasterMap) > 0 {
|
|
gormDb := overall.CONSTANT_DB_CustomerForm
|
|
masterErr := sqlDb.Table(masterTableName).Create(masterDataCont).Error
|
|
sunCreateIsOk := true
|
|
for k, v := range sunMasterMap {
|
|
sunErr := gormDb.Table(k).Create(v).Error
|
|
if sunErr != nil {
|
|
sunCreateIsOk = false
|
|
break
|
|
}
|
|
}
|
|
if masterErr == nil && sunCreateIsOk {
|
|
|
|
publicmethod.WriteLog("write", "写入自定义表单", err, masterDataCont, sunDataList)
|
|
} else {
|
|
|
|
err = errors.New("表单数据提交失败!请重新提交")
|
|
publicmethod.WriteLog("e", "写入自定义表单", masterTableName, err)
|
|
}
|
|
} else {
|
|
|
|
masterErr := sqlDb.Table(masterTableName).Create(masterDataCont).Error
|
|
if masterErr != nil {
|
|
publicmethod.WriteLog("write", "写入自定义表单", masterTableName, masterErr)
|
|
}
|
|
}
|
|
} else {
|
|
//子表不存在时,写入主表数据
|
|
err = sqlDb.Table(masterTableName).Create(masterDataCont).Error
|
|
publicmethod.WriteLog("write", "写入自定义表单", masterTableName, err)
|
|
}
|
|
} else {
|
|
err = errors.New("表单数据提交失败!请重新提交")
|
|
publicmethod.WriteLog("e", "写入自定义表单", masterTableName, err)
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-01 13:11:07
|
|
@ 功能: 撤回发送的信息
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) RecalSendMsg(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil || requestData.Id == "" {
|
|
publicmethod.Result(10001, err, c)
|
|
return
|
|
}
|
|
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", requestData.Id)
|
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
|
|
isTrue, msgId := redisClient.Get(redisKey)
|
|
if !isTrue {
|
|
publicmethod.Result(1, err, c, "数据撤回失败!")
|
|
return
|
|
}
|
|
if workWechat.RecallWorkWechatMsg("stzl", msgId) {
|
|
redisClient.DelKey(redisKey)
|
|
publicmethod.Result(0, err, c)
|
|
} else {
|
|
publicmethod.Result(1, err, c, "数据撤回失败!")
|
|
}
|
|
}
|
|
|