From 882921cf096323427fc52327443f835238b051da Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Thu, 10 Jul 2025 14:42:10 +0800 Subject: [PATCH] 1 --- api/shiyan/数据结构收集/图标.ts | 89 +++ api/version1/customChart/formTable.go | 439 +++++++++++ api/version1/customChart/type.go | 205 +++++ api/version1/customerform/formTable.go | 249 +++++- api/version1/customerform/listField.go | 17 +- api/version1/customerform/tableList.go | 365 +++++++++ api/version1/customerform/type.go | 19 + api/version1/entry.go | 2 + .../taskmanagement/formcontrol.go | 719 ++++++++++-------- .../taskplatform/taskmanagement/ruanTask.go | 5 +- .../taskmanagement/sendWorkWatchMsg.go | 558 ++++++++++++++ .../taskplatform/taskmanagement/types.go | 10 +- api/version1/workWechat/sendMsg.go | 2 +- apirouter/entry.go | 2 + apirouter/v1/customChartRouter/chartRouter.go | 23 + apirouter/v1/customChartRouter/entry.go | 3 + apirouter/v1/customerformrouter/router.go | 4 +- initialization/route/initRoute.go | 5 + models/modelAppPlatform/customer_form.go | 1 + models/modelAppPlatform/customer_form_view.go | 1 + overall/publicmethod/tableUnit.go | 6 + overall/publicmethod/technique.go | 35 +- 22 files changed, 2425 insertions(+), 334 deletions(-) create mode 100644 api/shiyan/数据结构收集/图标.ts create mode 100644 api/version1/customChart/formTable.go create mode 100644 api/version1/customChart/type.go create mode 100644 api/version1/customerform/tableList.go create mode 100644 api/version1/taskplatform/taskmanagement/sendWorkWatchMsg.go create mode 100644 apirouter/v1/customChartRouter/chartRouter.go create mode 100644 apirouter/v1/customChartRouter/entry.go create mode 100644 overall/publicmethod/tableUnit.go diff --git a/api/shiyan/数据结构收集/图标.ts b/api/shiyan/数据结构收集/图标.ts new file mode 100644 index 0000000..185c461 --- /dev/null +++ b/api/shiyan/数据结构收集/图标.ts @@ -0,0 +1,89 @@ +let tuBiao = { + tableKey:"", + state: true, + unitList:[ + { + uuid:"", + type:"cyl", + title:"柱状图", + y:[ + { + lable:"订单ID", + showLable:"订单ID", + field:"uuid", + sort:1, + attribute:1 //当字段为时间类型时. 1:ymdhms;2:year;3:month;4:day;5:hour;6:minute;7:second; + } + ], + x:[ + { + lable:"销售额", + showLable:"销售额", + field:"xiaoshoue", + sort:1, + method:1, //当字段聚合方式. 1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值 + format:1 //当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数; + } + ], + filter:[ //过滤器 + { + type:1, //字段类型 1: 数值;2:文本;3:时间 + lable:"商品", //名称 + field:"", //字段 + conditions:"", //条件 + }, + { + type:2, //字段类型 1: 数值;2:文本;3:时间 + lable:"成本", //名称 + field:"", //字段 + method:1, //聚合方式 1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小; + modality:1, //条件形式。 1:单条件;2:或条件;3:且条件 + modalityList:[ //条件列表 + { + equation:1, //表达式。1:等于;2:不等于;3:大于;4:小于;5:大于等于;6:小于等于;7:为空;8:不为空 + value:"" + } + ] + }, + { + type:3, //字段类型 1: 数值;2:文本;3:时间 + lable:"商品", //名称 + field:"", //字段 + conditions:"", //条件 + startTime:1, //开始时间 + endTime:1 //结束时间 + } + ], + timelength:1, + search:{ + state:false, + config:{ + searchBut:false, + resetBut:false + }, + factor:[ + { + type:1, //纬度字段 + lable:"订单ID", + field:"uuid", + isTime:false, + valur:1, + startTime:0, + endTime:0, + coor:"Y" + }, + { + type:2, //度量 + lable:"销售du'l", + field:"uuid", + isTime:false, + valur:1, + startTime:0, + endTime:0, + coor:"X" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/api/version1/customChart/formTable.go b/api/version1/customChart/formTable.go new file mode 100644 index 0000000..2705752 --- /dev/null +++ b/api/version1/customChart/formTable.go @@ -0,0 +1,439 @@ +package customchart + +import ( + "appPlatform/api/version1/customerform" + datacenter "appPlatform/api/version1/dataCenter" + "appPlatform/models/modelAppPlatform" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "sort" + "strings" + "time" + + "github.com/gin-gonic/gin" + "gorm.io/gorm" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-06-27 08:56:40 +@ 功能: 获取维度及度量字段 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) DimMeaFormTable(c *gin.Context) { + var requestData publicmethod.PublicId + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(200, err, c, "数据参数错误!") + return + } + var custTable modelAppPlatform.CustomerFormView + err = overall.CONSTANT_DB_AppPlatform.Model(&custTable).Select("`mastesformjson`,`table_structure`,`cfid`,`name`,`groupid`,`listjson`,`signCode`").Where("`status` = 1 AND `classify` <> 3 AND `tablekey` = ?", requestData.Id).First(&custTable).Error + if err != nil { + publicmethod.Result(200, err, c, "未找到表单!") + return + } + var formJsonCont customerform.CustomerFormMaster + json.Unmarshal([]byte(custTable.MastesFormJson), &formJsonCont) + var DimList []ChartFieldInfo + var MeaList []ChartFieldInfo + isCreaterTimg := true + var formUnitCont customerform.FormUnitInfo + formUnitCont.GainMasterAndSunFormUnit(requestData.Id, formJsonCont.List, true) + for _, v := range formUnitCont.MasterInfo { + if v.Name == "creater_time" { + isCreaterTimg = false + } + if publicmethod.IsInTrue[string](v.Type, publicmethod.Dimension) { + var dimInfo ChartFieldInfo + dimInfo.Title = v.Item.Label + if publicmethod.IsInTrue[string](v.Type, publicmethod.TimeUint) { + dimInfo.Type = 3 + } else { + dimInfo.Type = 1 + } + dimInfo.Field = v.Name + dimInfo.Options = v.Options + DimList = append(DimList, dimInfo) + } + if publicmethod.IsInTrue[string](v.Type, publicmethod.Quantization) { + var meaInfo ChartFieldInfo + meaInfo.Title = v.Item.Label + if publicmethod.IsInTrue[string](v.Type, publicmethod.TimeUint) { + meaInfo.Type = 3 + } else { + meaInfo.Type = 2 + } + meaInfo.Field = v.Name + meaInfo.Options = v.Options + MeaList = append(MeaList, meaInfo) + } + } + // for _, v := range formJsonCont.List { + // if v.Name == "creater_time" { + // isCreaterTimg = false + // } + // if publicmethod.IsInTrue[string](v.Type, publicmethod.Dimension) { + // var dimInfo ChartFieldInfo + // dimInfo.Title = v.Item.Label + // if publicmethod.IsInTrue[string](v.Type, publicmethod.TimeUint) { + // dimInfo.Type = 2 + // } else { + // dimInfo.Type = 1 + // } + // dimInfo.Field = v.Name + // DimList = append(DimList, dimInfo) + // } + // if publicmethod.IsInTrue[string](v.Type, publicmethod.Quantization) { + // var meaInfo ChartFieldInfo + // meaInfo.Title = v.Item.Label + // if publicmethod.IsInTrue[string](v.Type, publicmethod.TimeUint) { + // meaInfo.Type = 2 + // } else { + // meaInfo.Type = 1 + // } + // meaInfo.Field = v.Name + // MeaList = append(MeaList, meaInfo) + // } + // } + if isCreaterTimg { + var dimInfoOther ChartFieldInfo + dimInfoOther.Title = "创建时间" + dimInfoOther.Type = 3 + dimInfoOther.Field = "creater_time" + DimList = append(DimList, dimInfoOther) + } + sort.Slice(DimList, func(i, j int) bool { + return DimList[i].Type < DimList[j].Type + }) + sort.Slice(MeaList, func(i, j int) bool { + return MeaList[i].Type < MeaList[j].Type + }) + sendMap := publicmethod.MapOut[string]() + sendMap["dimList"] = DimList + sendMap["meaList"] = MeaList + sendMap["formUnitCont"] = formUnitCont + publicmethod.Result(0, sendMap, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 08:31:10 +@ 功能: 将图表信息写入数据库 +*/ +func (a *ApiMethod) CountChartValue(c *gin.Context) { + var requestData SaveChartSetup + c.ShouldBindJSON(&requestData) + if requestData.TableKey == "" { + publicmethod.Result(1, requestData, c, "未知数据源表!") + return + } + var custForm modelAppPlatform.CustomerForm + err := custForm.GetCont(map[string]interface{}{"`tablename`": requestData.TableKey}, "chartView", "`signCode`") + if err != nil { + publicmethod.Result(1, requestData, c, "未知数据源表!不可添加!") + return + } + chartJson, err := json.Marshal(requestData.ChartList) + if err != nil { + publicmethod.Result(1, requestData, c, "图表数据不正确!不可写入!") + return + } + saveData := publicmethod.MapOut[string]() + saveData["`chartView`"] = string(chartJson) + saveData["`edit_time`"] = time.Now().Unix() + var saveMode modelAppPlatform.CustomerForm + err = saveMode.EiteCont(map[string]interface{}{"`signCode`": custForm.SignCode}, saveData) + if err != nil { + publicmethod.Result(1, requestData, c, "图表数据不正确!不可写入!") + return + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 10:57:22 +@ 功能: 获取图表设定信息 +*/ +func (a *ApiMethod) GetChartCont(c *gin.Context) { + var requestData publicmethod.CommonId[string] + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(200, err, c, "数据参数错误!") + return + } + if requestData.Id == "" { + publicmethod.Result(1, requestData, c, "未知数据源表!2") + return + } + var custForm modelAppPlatform.CustomerForm + err = custForm.GetCont(map[string]interface{}{"`tablename`": requestData.Id}, "chartView") + if err != nil { + publicmethod.Result(1, requestData, c, "未知数据源表!") + return + } + var chartList []ChartInfo + err = json.Unmarshal([]byte(custForm.ChartView), &chartList) + if err != nil { + publicmethod.Result(200, chartList, c, "当前没有视图表 ") + return + } + publicmethod.Result(0, chartList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 11:33:26 +@ 功能: 根据条件解析图标结果 +*/ +func (a *ApiMethod) AnalyzeChartData(c *gin.Context) { + var requestData OneChartViews + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(200, err, c, "数据参数错误!") + return + } + if requestData.TableKey == "" { + publicmethod.Result(1, requestData, c, "未知数据源表!") + return + } + if requestData.ChartId == "" { + publicmethod.Result(1, requestData, c, "未知数据表!") + return + } + var custForm modelAppPlatform.CustomerFormView + err = custForm.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": requestData.TableKey}, "`tablekey`", "`mastesformjson`", "`chartView`") + if err != nil { + publicmethod.Result(1, requestData, c, "未知数据源表!2") + return + } + var formJsonCont customerform.CustomerFormMaster + json.Unmarshal([]byte(custForm.MastesFormJson), &formJsonCont) + + var chartList []ChartInfo + err = json.Unmarshal([]byte(custForm.ChartView), &chartList) + if err != nil { + publicmethod.Result(200, chartList, c, "当前没有视图表 ") + return + } + isRun := true + var sendChartDat interface{} + for _, v := range chartList { + if v.Uuid == requestData.ChartId { + isRun = false + switch v.Type { + case "pie": //饼 + case "line": //折线 + case "target": //指标 + case "barRace": //排行榜 + case "radar": //雷达 + default: //默认返回柱状图 + sendChartDat = v.AnalyzeBarChart(custForm.TableKey, formJsonCont) + } + } + } + if isRun { + publicmethod.Result(200, sendChartDat, c, "没有此表的数据! ") + return + } + publicmethod.Result(0, sendChartDat, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 14:24:28 +@ 功能: 解析柱状图 +*/ +func (c *ChartInfo) AnalyzeBarChart(tableName string, formJsonCont customerform.CustomerFormMaster) interface{} { + var formList []map[string]interface{} + var gormDb *gorm.DB + 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 { + return nil + } + } + gormDb = sqlDborm.Table(tableName) + } else { + gormDb = overall.CONSTANT_DB_CustomerForm.Table(tableName) + } + //判断是否有过滤条件 + if len(c.Filter) > 0 { + for _, v := range c.Filter { + gormDb = v.MakeGormSql(gormDb) + } + } + currTime := time.Now().Unix() + //时间约束 + switch c.TimeLength { + case 2: //近一周 + gormDb = gormDb.Where("`creater_time` BETWEEN ? AND ?", currTime-604800, currTime) + case 3: //近一月 + gormDb = gormDb.Where("`creater_time` BETWEEN ? AND ?", currTime-2628000, currTime) + case 4: //近三月 + gormDb = gormDb.Where("`creater_time` BETWEEN ? AND ?", currTime-7884000, currTime) + case 5: //近半年 + gormDb = gormDb.Where("`creater_time` BETWEEN ? AND ?", currTime-15768000, currTime) + case 6: //近一年 + gormDb = gormDb.Where("`creater_time` BETWEEN ? AND ?", currTime-31536000, currTime) + default: //近一天 + gormDb = gormDb.Where("`creater_time` BETWEEN ? AND ?", currTime-86400, currTime) + } + err := gormDb.Find(&formList).Error + if err != nil && len(formList) < 1 { + return nil + } + return nil +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 15:37:29 +@ 功能: 根据过滤,组装查询条件 +*/ +func (f *FilterInfo) MakeGormSql(gormDb *gorm.DB) *gorm.DB { + switch f.Type { + case 2: + // switch f.Method { + // case 2: + // sqlSelectStr := fmt.Sprintf("AVG(`%v`)", f.Field) + // gormDb = gormDb.Select(sqlSelectStr) + // case 3: + // sqlSelectStr := fmt.Sprintf("COUNT(`%v`)", f.Field) + // gormDb = gormDb.Select(sqlSelectStr) + // case 4: + // sqlSelectStr := fmt.Sprintf("COUNT(DISTINCT `%v`)", f.Field) + // gormDb = gormDb.Select(sqlSelectStr) + // case 5: + // sqlSelectStr := fmt.Sprintf("MAX(`%v`)", f.Field) + // gormDb = gormDb.Select(sqlSelectStr) + // case 6: + // sqlSelectStr := fmt.Sprintf("MIN(`%v`)", f.Field) + // gormDb = gormDb.Select(sqlSelectStr) + // default: + // sqlSelectStr := fmt.Sprintf("SUM(`%v`)", f.Field) + // gormDb = gormDb.Select(sqlSelectStr) + // } + gormDb = f.CalculationConditions(gormDb) + case 3: + star, _ := publicmethod.StringToInt64(f.StartTime) + endTime, _ := publicmethod.StringToInt64(f.EndTime) + if star != 0 && endTime != 0 { + sqlStr := fmt.Sprintf("%v BETWEEN %v AND %v", f.Field, star, endTime) + gormDb = gormDb.Where(sqlStr) + } else if star != 0 && endTime == 0 { + sqlStr := fmt.Sprintf("%v > %v ", f.Field, star) + gormDb = gormDb.Where(sqlStr) + } else if star == 0 && endTime != 0 { + sqlStr := fmt.Sprintf("%v < %v ", f.Field, endTime) + gormDb = gormDb.Where(sqlStr) + } + default: + if f.Conditions != "" { + sqlStr := fmt.Sprintf("%v LIKE %v%v%v", f.Field, "'%", f.Conditions, "%'") + gormDb = gormDb.Where(sqlStr) + } + } + return gormDb +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 16:01:30 +@ 功能: 数值计算条件 + + #gormDb 数据库实例 + #Modality 条件形式。 1:单条件;2:或条件;3:且条件 + #ModalityList 条件列表 +*/ +func (f *FilterInfo) CalculationConditions(gormDb *gorm.DB) *gorm.DB { + if len(f.ModalityList) > 0 { + switch f.Modality { + case 2: + var sqlList []string + for _, v := range f.ModalityList { + sqlList = append(sqlList, Dengshi(v.Equation, f.Field, v.Value)) + } + if len(sqlList) > 0 { + sqlStr := strings.Join(sqlList, " OR ") + gormDb = gormDb.Where(sqlStr) + } + + case 3: + var sqlList []string + for _, v := range f.ModalityList { + sqlList = append(sqlList, Dengshi(v.Equation, f.Field, v.Value)) + } + if len(sqlList) > 0 { + sqlStr := strings.Join(sqlList, " AND ") + gormDb = gormDb.Where(sqlStr) + } + default: + sqlStr := Dengshi(f.ModalityList[0].Equation, f.Field, f.ModalityList[0].Value) + if sqlStr != "" { + gormDb = gormDb.Where(sqlStr) + } + + } + } + return gormDb +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 16:09:27 +@ 功能: 等式演化 +*/ +func Dengshi(t int, field, val string) (sqlStr string) { + + switch t { + case 2: + sqlStr = fmt.Sprintf("%v <> %v", field, val) + case 3: + sqlStr = fmt.Sprintf("%v > %v", field, val) + case 4: + sqlStr = fmt.Sprintf("%v < %v", field, val) + case 5: + sqlStr = fmt.Sprintf("%v >= %v", field, val) + case 6: + sqlStr = fmt.Sprintf("%v <= %v", field, val) + case 7: + sqlStr = fmt.Sprintf("%v IS NULL", field) + case 8: + sqlStr = fmt.Sprintf("%v IS NOT NULL", field) + default: + sqlStr = fmt.Sprintf("%v = %v", field, val) + + } + return +} diff --git a/api/version1/customChart/type.go b/api/version1/customChart/type.go new file mode 100644 index 0000000..4aba1d9 --- /dev/null +++ b/api/version1/customChart/type.go @@ -0,0 +1,205 @@ +package customchart + +import ( + "appPlatform/api/version1/customerform" + "appPlatform/overall/publicmethod" + + "github.com/gin-gonic/gin" +) + +type ApiMethod struct{} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-06-27 08:55:24 +@ 功能: +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["msg"] = "自定义图表入口" + publicmethod.Result(0, outputCont, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-06-27 10:25:46 +@ 功能: 字段图表格式 +*/ +type ChartFieldInfo struct { + Title string `json:"title"` + Type int `json:"type"` //1:普通类;2:时间类 + Field string `json:"field"` + Options []customerform.OptionsStruct `json:"options"` +} +type OptionsInfo struct { + Label string `json:"label"` + Value string `json:"value"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 09:42:46 +@ 功能: 保存图标设定 +*/ +type SaveChartSetup struct { + TableKey string `json:"tableKey"` + ChartList []ChartInfo `json:"chartList"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 09:50:33 +@ 功能: 提交设定的结构体 +*/ +type ChartInfo struct { + Uuid string `json:"uuid"` + Icon string `json:"icon"` + Type string `json:"type"` + Title string `json:"title"` + WidthBox int `json:"widthBox"` + YAxis []YAxisInfo `json:"y"` + XAxis []XAxisInfo `json:"x"` + Filter []FilterInfo `json:"filter"` + TimeLength int `json:"timelength"` + Search interface{} `json:"search"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 14:01:37 +@ 功能: 获取 +*/ +type GetChartInfo struct { + Uuid string `json:"uuid"` + Icon string `json:"icon"` + Type string `json:"type"` + Title string `json:"title"` + WidthBox int `json:"widthBox"` + YAxis []YAxisInfo `json:"y"` + XAxis []XAxisInfo `json:"x"` + Filter []FilterInfo `json:"filter"` + TimeLength int `json:"timelength"` + Search []SearchInfo `json:"search"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 09:56:41 +@ 功能: 图表y轴结构体 +*/ +type YAxisInfo struct { + ChartFieldInfo + OldTitle string `json:"oldTitle"` + TimeType string `json:"timeType"` + Sort int `json:"sort"` + Method int `json:"method"` + Format int `json:"format"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 09:56:41 +@ 功能: 图表X轴结构体 +*/ +type XAxisInfo struct { + ChartFieldInfo + OldTitle string `json:"oldTitle"` + TimeType string `json:"timeType"` + Sort int `json:"sort"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 10:14:46 +@ 功能: 图表过滤 +*/ +type FilterInfo struct { + Label string `json:"label"` + Type int `json:"type"` //1:普通类;2:时间类 + Field string `json:"field"` + Options []customerform.OptionsStruct `json:"options"` + OldTitle string `json:"oldTitle"` + TimeType string `json:"timeType"` + Sort int `json:"sort"` + Conditions string `json:"conditions"` + Method int `json:"method"` + Modality int `json:"modality"` + ModalityList []modalityInfo `json:"modalityList"` + StartTime interface{} `json:"startTime"` + EndTime interface{} `json:"endTime"` + Meadim int `json:"meadim"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 10:19:57 +@ 功能: 等式条件 +*/ +type modalityInfo struct { + Equation int `json:"equation"` + Value string `json:"value"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 10:26:57 +@ 功能: 搜索结构体 +*/ +type SearchInfo struct { + State bool `json:"state"` + SearchBut []string `json:"searchBut"` + Factor []FactorInfo `json:"factor"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 10:28:58 +@ 功能: 搜索条件 +*/ +type FactorInfo struct { + Label string `json:"lable"` + Type int `json:"type"` //1:普通类;2:时间类 + Field string `json:"field"` + Options []customerform.OptionsStruct `json:"options"` + OldTitle string `json:"oldTitle"` + TimeType string `json:"timeType"` + Sort int `json:"sort"` + IsTime bool `json:"isTime"` + Value string `json:"value"` + StartTime string `json:"startTime"` + EndTime string `json:"endTime"` + Coor string `json:"coor"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-07-08 13:18:25 +@ 功能: 单一图表设定 +*/ +type OneChartViews struct { + TableKey string `json:"tableKey"` + ChartId string `json:"chartId"` +} diff --git a/api/version1/customerform/formTable.go b/api/version1/customerform/formTable.go index 055898e..6c4a4ff 100644 --- a/api/version1/customerform/formTable.go +++ b/api/version1/customerform/formTable.go @@ -391,13 +391,13 @@ func (f *FormTableSql) TableSubUnitAnalysis(tablename string, subUnitAry []Maste // } } - if publicmethod.IsInTrue[string](wordClass.WordName, oldTable) { + if !publicmethod.IsInTrue[string](wordClass.WordName, oldTable) { alreadyExists = append(alreadyExists, wordClass.WordName) } } for _, v := range fieldList { - if publicmethod.IsInTrue[string](v.Field, oldTable) { + if !publicmethod.IsInTrue[string](v.Field, oldTable) { alreadyExists = append(alreadyExists, v.Field) } } @@ -1917,14 +1917,26 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa var myInfo modelshr.PersonArchives myInfo.GetCont(map[string]interface{}{"`key`": mvInt}, "`name`") sendInfo[mi] = myInfo.Name + sendInfo["createrKey"] = mv } case "creater_time": timeInt, _ := publicmethod.StringToInt64(mv) - sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + + if publicmethod.GetIntLength(timeInt) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt/1000, 27) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + } + sendInfo["createrTimeVal"] = mv case "edit_time": timeInt, _ := publicmethod.StringToInt64(mv) - sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + if publicmethod.GetIntLength(timeInt) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt/1000, 27) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + } + sendInfo["editTimeVal"] = mv case "states": mvInt, _ := publicmethod.StringToInt64(mv) switch mvInt { @@ -1998,50 +2010,88 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa switch lv.Auxiliary { case "year": - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 16) + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 16) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 16) + } + case "month": - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 15) + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 15) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 15) + } case "datetime": - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 11) + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 11) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 11) + } case "week": - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 41) + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 41) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 41) + } case "datetimerange": - beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 11) - sendInfo[mi] = beginTime + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 11) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 11) + } + // sendInfo[mi] = beginTime // endKey := fmt.Sprintf("%v_end", mi) // if v[endKey] != nil { // endTimeVal, _ := publicmethod.StringToInt64(v[endKey]) // sendInfo[mi] = fmt.Sprintf("%v - %v", beginTime, publicmethod.UnixTimeToDay(int64(endTimeVal)/1000, 11)) // } case "daterange": - beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) - sendInfo[mi] = beginTime + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 14) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 14) + } + // sendInfo[mi] = beginTime // endKey := fmt.Sprintf("%v_end", mi) // if v[endKey] != nil { // endTimeVal, _ := publicmethod.StringToInt64(v[endKey]) // sendInfo[mi] = fmt.Sprintf("%v - %v", beginTime, publicmethod.UnixTimeToDay(int64(endTimeVal)/1000, 14)) // } case "monthrange": - beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 15) - sendInfo[mi] = beginTime + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 15) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 15) + } + // sendInfo[mi] = beginTime // endKey := fmt.Sprintf("%v_end", mi) // if v[endKey] != nil { // endTimeVal, _ := publicmethod.StringToInt64(v[endKey]) // sendInfo[mi] = fmt.Sprintf("%v - %v", beginTime, publicmethod.UnixTimeToDay(int64(endTimeVal)/1000, 15)) // } default: - beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) - sendInfo[mi] = beginTime + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 14) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 14) + } + // sendInfo[mi] = beginTime // endKey := fmt.Sprintf("%v_end", mi) // if v[endKey] != nil { // endTimeVal, _ := publicmethod.StringToInt64(v[endKey]) // sendInfo[mi] = fmt.Sprintf("%v - %v", beginTime, publicmethod.UnixTimeToDay(int64(endTimeVal)/1000, 14)) // } } + fmt.Printf("\n\n\n\n时间--------->%v--------->%v--------->%v\n\n\n\n", publicmethod.GetIntLength(timeVal), timeVal, beginTime) case "timePicker": timeVal, _ := publicmethod.StringToInt64(mv) if timeVal != 0 { - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 5) + if publicmethod.GetIntLength(timeVal) == 13 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 5) + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 5) + } } else { sendInfo[mi] = "" } @@ -2575,6 +2625,171 @@ func (a *ApiMethod) GainListTableField(c *gin.Context) { publicmethod.Result(0, sendTableList, c) } +/* +* +@ 作者: 秦东 +@ 时间: 2024-07-06 13:42:03 +@ 功能: 列表展示需要字段(带标题组件) +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainListTableFieldTitle(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(103, err, c, "未知表单!无法获取字段!") + return + } + var customerFormMaster modelAppPlatform.CustomerFormView + err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`name`") + if err != nil { + publicmethod.Result(100, err, c, "未知表单!无法获取字段!") + return + } + var masterTable []Result + var formJsonCont CustomerFormMaster + json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &formJsonCont) + 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 + } + } + masterTable, err = GainFormAllFieldList(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey) + + } else { + masterTable, err = GainFormTableField(customerFormMaster.TableKey) + + } + + // masterTable, err := GainFormTableField(customerFormMaster.TableKey) + if err != nil { + publicmethod.Result(101, err, c, "未知表单!无法获取字段!") + return + } + sendTableList := publicmethod.MapOut[string]() + // sendTableList["masterTableName"] = customerFormMaster.Name + // sendTableList["masterTable"] = masterTable + if customerFormMaster.TableStructure != "" { //判断是否有主体子表单 + var sunTable map[string]interface{} + err = json.Unmarshal([]byte(customerFormMaster.TableStructure), &sunTable) + if err == nil { + sunTableMap := publicmethod.MapOut[string]() + for _, v := range sunTable { //遍历子表单名称 + if vStr, ok := v.(string); ok { + sunTableMap[vStr], err = GainFormTableField(vStr) + + } + } + // sendTableList["sunTable"] = sunTableMap + } + } + + var unitCont map[string]interface{} + json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &unitCont) + + var formFieldAry FormJsonFieldInfo + if list, ok := unitCont["list"]; ok { + + if listAry, ok := list.([]interface{}); ok { + formFieldAry.AnalyzingFormJson("", listAry) + } + } + + var allKeyWords []ViewListMode + var mapKeyWords []ViewListMode + var cardKeyWords []ViewListMode + var timeKeyWords []ViewListMode + sendTableList["isMap"] = false + sendTableList["isCard"] = false + for _, v := range masterTable { + var keyWords ViewListMode + keyWords.Label = v.Comment + if v.Field == "id" { + keyWords.Label = "Id" + } + keyWords.Value = v.Field + allKeyWords = append(allKeyWords, keyWords) + if v.Field == "creater_time" || v.Field == "edit_time" { + timeKeyWords = append(timeKeyWords, keyWords) + } + } + for _, fv := range formFieldAry.MasterInfo { + if publicmethod.IsInTrue(fv.FieldClass, []string{"datePicker", "timePicker"}) { + var keyWordsTime ViewListMode + keyWordsTime.Label = fv.Label + keyWordsTime.Value = fv.Id + timeKeyWords = append(timeKeyWords, keyWordsTime) + } + if publicmethod.IsInTrue(fv.FieldClass, []string{"baidumap"}) { + var keyWordsMap ViewListMode + keyWordsMap.Label = fv.Label + keyWordsMap.Value = fv.Id + mapKeyWords = append(mapKeyWords, keyWordsMap) + sendTableList["isMap"] = true + } + if publicmethod.IsInTrue(fv.FieldClass, []string{"lowcodeImage"}) { + var keyWordsMap ViewListMode + keyWordsMap.Label = fv.Label + keyWordsMap.Value = fv.Id + cardKeyWords = append(cardKeyWords, keyWordsMap) + sendTableList["isCard"] = true + } + } + allKeyWords = append(allKeyWords, JudgeUnitTitle(formJsonCont.List)...) + sendTableList["allKeyWords"] = allKeyWords + sendTableList["mapKeyWords"] = mapKeyWords + sendTableList["timeKeyWords"] = timeKeyWords + sendTableList["cardKeyWords"] = cardKeyWords + + publicmethod.Result(0, sendTableList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-05-31 15:09:44 +@ 功能: 标题组件解析 +*/ +func JudgeUnitTitle(List []MasterStruct) (keyValAry []ViewListMode) { + fmt.Printf("标题组件解析------------》%v\n\n\n\n\n", List) + for _, v := range List { + if v.Type == "title" { + if v.Control.ModelValue != "" { + // title := publicmethod.TypeToClass(v.Control.ModelValue, 10) + var keyVal ViewListMode + keyVal.Label = publicmethod.TypeToClass(v.Control.ModelValue, 10) + keyVal.Value = fmt.Sprintf("%v|#|%v", v.Control.ModelValue, "title") + keyValAry = append(keyValAry, keyVal) + } + } + } + return +} + /* * @ 作者: 秦东 diff --git a/api/version1/customerform/listField.go b/api/version1/customerform/listField.go index 88e650d..be4618e 100644 --- a/api/version1/customerform/listField.go +++ b/api/version1/customerform/listField.go @@ -26,13 +26,16 @@ type ViewInfo struct { Form FormInfo `json:"form"` } type FormInfo struct { - StartTime string `json:"startTime"` - EndTime string `json:"endTime"` - DayType int `json:"dayType"` - SortWord string `json:"sortWord"` - Sort int `json:"sort"` - MapWord string `json:"mapWord"` - Title []string `json:"title"` + StartTime string `json:"startTime"` + EndTime string `json:"endTime"` + DayType int `json:"dayType"` + SortWord string `json:"sortWord"` + Sort int `json:"sort"` + MapWord string `json:"mapWord"` + Title []string `json:"title"` + TitleWork string `json:"titleWork"` + ImgWork string `json:"imgWork"` + Describe interface{} `json:"describe"` } type FormApiInfor struct { Type string `json:"type"` diff --git a/api/version1/customerform/tableList.go b/api/version1/customerform/tableList.go new file mode 100644 index 0000000..ce566e6 --- /dev/null +++ b/api/version1/customerform/tableList.go @@ -0,0 +1,365 @@ +package customerform + +import ( + datacenter "appPlatform/api/version1/dataCenter" + "appPlatform/middleware/grocerystore" + "appPlatform/models/customerForm" + "appPlatform/models/modelAppPlatform" + "appPlatform/models/modelshr" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "strconv" + "strings" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-05-31 15:32:53 +@ 功能: 根据设定得字段显示数据列表内容 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) TableCusterField(c *gin.Context) { + var requestData FormPageListAttr + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.FormId == "" { + publicmethod.Result(1, err, c, "未知表单!无法获取字段!") + return + } + if requestData.Page == 0 { + requestData.Page = 1 + } + if requestData.PageSize == 0 { + requestData.Page = 20 + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + + //获取表单数据 + var formInfo modelAppPlatform.CustomerFormView + err = formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`", "`groupid`", "`cfid`") + if err != nil { + publicmethod.Result(1, err, c, "未知表单!无法获取字段!") + return + } + + //解析表单列表数据结构 + var formJsonCont CustomerFormMaster + json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) + //解析表格组件数据 + var sunMap map[string]string + json.Unmarshal([]byte(formInfo.TableStructure), &sunMap) + var total int64 + //判断当前数据源来源于什么地方 + var formList []map[string]interface{} + if formJsonCont.Form.DataSource == "yes" { //采用外部数据源 + //Step 1 打开数据源 + 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 + } + } + //Step 2 使用数据源处理数据 + gormDb := sqlDborm.Table(formJsonCont.Form.DataSourceConfig.TableKey) //确定使用哪个库 + gormDb = gormDb.Where("`states` BETWEEN ? AND ?", 1, 2) //基础查询条件 + gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) //处理查询条件 + //Step 3 权限处理 + var powerSearch publicmethod.GainUserPower + powerSearch.SystemName = "appsystem" //系统名称 + powerSearch.RoleId = userCont.Role //角色列表 + powerSearch.OrgId = userCont.AdminOrg //行政组织 + powerSearch.PostId = userCont.Position //岗位 + powerSearch.AppKey = formInfo.Groupid //归属哪个App + powerSearch.TableId = formInfo.CfId //归属哪个表格 + gormDb = powerSearch.MakeSearchSql(gormDb, userCont, formJsonCont.Form.DataSource) + //Step 4 获取一共有多少条数据 + + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + //Step 5 获取每页具体数据 + gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) + err = gormDb.Order("`id` DESC").Find(&formList).Error + if err != nil && len(formList) < 1 { + publicmethod.Result(0, err, c) + return + } + } else { //采用系统数据源 + tableName := fmt.Sprintf("`%v` as f", formInfo.TableKey) + gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus,t.runFlowId") + gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key") + gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2) //基础查询条件 + gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) //处理查询条件 + //Step 2 权限处理 + var powerSearch publicmethod.GainUserPower + powerSearch.SystemName = "appsystem" //系统名称 + powerSearch.RoleId = userCont.Role //角色列表 + powerSearch.OrgId = userCont.AdminOrg //行政组织 + powerSearch.PostId = userCont.Position //岗位 + powerSearch.AppKey = formInfo.Groupid //归属哪个App + powerSearch.TableId = formInfo.CfId //归属哪个表格 + gormDb = powerSearch.MakeSearchSql(gormDb, userCont, formJsonCont.Form.DataSource) + //Step 3 获取一共有多少条数据 + + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + //Step 4 翻页配置 + gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) + err = gormDb.Order("f.`id` DESC").Find(&formList).Error + fmt.Printf("err----%v------->%v\n\n\n", formJsonCont.Form.DataSource, err) + if err != nil && len(formList) < 1 { + publicmethod.Result(0, err, c) + return + } + } + var sendList []KaPianField + var listFieldsMap ListPageFields + if formInfo.ListJson != "" { + err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) + if err == nil { + formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont) + } + for _, v := range formList { + var sendInfo KaPianField + sendInfo.TableKey = formInfo.TableKey + sendInfo.IsRetract = false + if id, ok := v["id"]; ok { + sendInfo.Id = publicmethod.TypeToClass(id, 10) + } + if timeAdd, ok := v["creater_time"]; ok { + sendInfo.CreaterTime = publicmethod.TypeToInterface(timeAdd) + } + + var createrVal int64 + if createrName, ok := v["createrKey"]; ok { + createrVal, _ = publicmethod.StringToInt64(createrName) + var myInfo modelshr.PersonArchives + myInfo.GetCont(map[string]interface{}{"`key`": createrName}, "`name`", "`number`") + sendInfo.Creater = fmt.Sprintf("%v(NO. %v)", myInfo.Name, myInfo.Number) + if createrVal == userCont.Key { + sendInfo.IsMyMsg = true + } + } + + if mastrKeyVal, ok := v["masters_key"]; ok { + masterKeyVal := publicmethod.TypeToInterface(mastrKeyVal) + sendInfo.Title = masterKeyVal + sendInfo.MastersKey = masterKeyVal //唯一标识符 + // if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok { + // sendInfo.MastersKey = strconv.FormatUint(mastrKeyUint64, 10) //唯一标识符 + // } + redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", masterKeyVal) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3) + + sendInfo.RetractTrue, _ = redisClient.Get(redisKey) + + if createrVal, ok := v["creater"]; ok { + createrValInt, _ := publicmethod.StringToInt64(createrVal) + + if userCont.Key != createrValInt { + sendInfo.RetractTrue = false + } + } + } + if flowIsOpen, ok := v["flowIsOpens"]; ok { + sendInfo.FlowIsOpens = flowIsOpen //是否为流程表单 + } + if taskStatus, ok := v["taskStatus"]; ok { + sendInfo.TaskStatus = taskStatus //是否为流程表单 + } + + if mastrKey, ok := v["runFlowId"]; ok { + mastrKeyInt, _ := publicmethod.StringToInt64(mastrKey) + if mastrKeyInt != 0 { + var runFlowInfo customerForm.RunWorkflow + runFlowInfo.GetCont(map[string]interface{}{"`id`": mastrKey}, "`id`", "`current_step`", "`next_step`") + sendInfo.RunFlowInfo = strconv.FormatInt(runFlowInfo.Id, 10) + if stateVal, ok := v["taskStatus"]; ok { + if stauval, ok := stateVal.(string); ok { + if stauval == "3" && runFlowInfo.NextStep != 0 { + + if runFlowInfo.CurrentStep == 1 { + + if createrVal == userCont.Key { + sendInfo.IsRetract = true + } + + } + } + } + } + } + } + + sendInfo.Img = HaveImgInfo(v, listFieldsMap.View, formJsonCont.List, 1) //项目图片 + sendInfo.TitleWork = HaveImgInfo(v, listFieldsMap.View, formJsonCont.List, 2) //项目图片标题 + sendInfo.Title = HaveImgInfo(v, listFieldsMap.View, formJsonCont.List, 3) //项目标题 + sendInfo.Describe = strings.Split(HaveImgInfo(v, listFieldsMap.View, formJsonCont.List, 4), "|#|") //项目描述 + + sendList = append(sendList, sendInfo) + } + } + publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-06-03 09:46:52 +@ 功能: 组装返回值 +*/ +func HaveImgInfo(val map[string]interface{}, view map[string]ViewInfo, unitList []MasterStruct, types int) string { + switch types { + case 1: + if viewCard, ok := view["card"]; ok { + if viewCard.Form.ImgWork != "" { + if imgSrc, ok := val[viewCard.Form.ImgWork]; ok { + return publicmethod.TypeToInterface(imgSrc) + } + } + // if imgSrc,ok := val[viewCard.Form] + } + case 2: + if viewCard, ok := view["card"]; ok { + if viewCard.Form.TitleWork != "" { + titleAry := strings.Split(viewCard.Form.TitleWork, "|#|") + if len(titleAry) >= 2 { + return titleAry[0] + } else { + if imgSrcTitle, ok := val[viewCard.Form.TitleWork]; ok { + return publicmethod.TypeToInterface(imgSrcTitle) + } + } + } + } + case 3: + titleStr := "" + if viewCard, ok := view["card"]; ok { + if len(viewCard.Form.Title) > 0 { + for _, v := range viewCard.Form.Title { + vAry := strings.Split(v, "|#|") + if len(vAry) >= 2 { + if vAry[0] != "" { + if titleStr != "" { + titleStr = fmt.Sprintf("%v - %v", titleStr, vAry[0]) + } else { + titleStr = vAry[0] + } + } + } else { + if vInfo, ok := val[v]; ok { + vInfoStr := publicmethod.TypeToInterface(vInfo) + if vInfoStr != "" { + if titleStr != "" { + titleStr = fmt.Sprintf("%v - %v", titleStr, vInfoStr) + } else { + titleStr = vInfoStr + } + } + + } + } + } + } + } + return titleStr + case 4: + if viewCard, ok := view["card"]; ok { + fmt.Printf("\n\n\n\n描述类型----->%T------------1------------->%v\n\n\n\n", viewCard.Form.Describe, viewCard.Form.Describe) + switch descVal := viewCard.Form.Describe.(type) { + case []interface{}: + var descAry []string + for _, v := range descVal { + vInfoStr := publicmethod.TypeToInterface(v) + descInfo := strings.Split(vInfoStr, "|#|") + if len(descInfo) >= 2 { + descAry = append(descAry, descInfo[0]) + } else { + if descTitle, ok := val[vInfoStr]; ok { + descInfoVal := "" + for _, uv := range unitList { + if uv.Name != "" && uv.Name == vInfoStr { + descInfoVal = fmt.Sprintf("%v:%v ", uv.Item.Label, publicmethod.TypeToInterface(descTitle)) + } + } + if descInfoVal == "" { + descInfoVal = publicmethod.TypeToInterface(descTitle) + } + if descInfoVal != "" { + descAry = append(descAry, descInfoVal) + } + + } + } + } + return strings.Join(descAry, "|#|") + default: + vInfoStr := publicmethod.TypeToInterface(descVal) + if vInfoStr != "" { + descInfo := strings.Split(vInfoStr, "|#|") + if len(descInfo) >= 2 { + return descInfo[0] + } else { + if descTitle, ok := val[vInfoStr]; ok { + descInfoVal := "" + for _, uv := range unitList { + if uv.Name != "" && uv.Name == vInfoStr { + descInfoVal = fmt.Sprintf("%v:%v ", uv.Item.Label, publicmethod.TypeToInterface(descTitle)) + } + } + if descInfoVal == "" { + descInfoVal = publicmethod.TypeToInterface(descTitle) + } + return descInfoVal + } + } + } + } + + } + default: + strVal := "" + for _, v := range val { + if strVal == "" { + fmt.Printf("%v", v) + } else { + fmt.Printf("%v - %v", strVal, v) + } + + } + return strVal + } + return "" +} diff --git a/api/version1/customerform/type.go b/api/version1/customerform/type.go index 4024e04..f13032f 100644 --- a/api/version1/customerform/type.go +++ b/api/version1/customerform/type.go @@ -590,3 +590,22 @@ type SunTableInfo struct { FieldKey string `json:"fieldKey"` //标识 Fields interface{} `json:"fields"` //字段 } + +// 输出web卡片指定字段数据 +type KaPianField struct { + publicmethod.PublicId //项目ID + Img string `json:"img"` //项目图片 + TitleWork string `json:"titleWork"` //项目图片标题 + Title string `json:"title"` //项目标题 + Describe interface{} `json:"describe"` //项目描述 + TaskStatus interface{} `json:"taskStatus"` //项目状态 + FlowIsOpens interface{} `json:"flowIsOpens"` //是否为流程表单 + IsRetract bool `json:"isRetract"` //是否可以撤回已发送的流程 + MastersKey string `json:"masters_key"` //唯一标识符 + RetractTrue bool `json:"retract_true"` //是否可以撤回已发送的企业微信消息 + RunFlowInfo string `json:"runFlowInfo"` //正在执行得流程 + IsMyMsg bool `json:"isMyMsg"` //这是我的消息 + Creater string `json:"creater"` //创建人 + CreaterTime string `json:"creater_time"` //创建时间 + TableKey string `json:"tableKey"` //表单 +} diff --git a/api/version1/entry.go b/api/version1/entry.go index 768fdc7..73f47e6 100644 --- a/api/version1/entry.go +++ b/api/version1/entry.go @@ -1,6 +1,7 @@ package version1 import ( + customchart "appPlatform/api/version1/customChart" "appPlatform/api/version1/customerApp" "appPlatform/api/version1/customerform" datacenter "appPlatform/api/version1/dataCenter" @@ -38,6 +39,7 @@ type ApiEntry struct { CustomerAppApi customerApp.ApiMethod //自定App WebSocketApi webstocetmsg.ApiMethod //webSocket通讯相关 WorkFlowApi workflowRun.ApiMethod //工作流相关 + ChartApi customchart.ApiMethod } var AppApiEntry = new(ApiEntry) diff --git a/api/version1/taskplatform/taskmanagement/formcontrol.go b/api/version1/taskplatform/taskmanagement/formcontrol.go index 6111c31..cbfa731 100644 --- a/api/version1/taskplatform/taskmanagement/formcontrol.go +++ b/api/version1/taskplatform/taskmanagement/formcontrol.go @@ -900,7 +900,13 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { 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 @@ -956,9 +962,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { publicmethod.Result(104, err, c) return } - taskCont.MastesForm = formCont.MastesForm - taskCont.MastesFormJson = formCont.MastesFormJson - err = overall.CONSTANT_DB_CustomerForm.Create(&taskCont).Error + // for k, v := range masrWriteMap { // fmt.Printf("%v----> %T\n", k, v) // } @@ -982,7 +986,8 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { var sendMsgInfo SendMsgInfo sendMsgInfo = sendMsgInterface.SendMsg - msgid, _ := sendMsgInfo.SendMsg(userCont, taskCont.Title, uuid, cureeTime, masterField, masrWriteMap, masterUnitList) + // 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名称 @@ -1007,223 +1012,6 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { } -/* -* -@ 作者: 秦东 -@ 时间: 2025-03-28 09:17:29 -@ 功能: 发送企业微信消息 -@ 参数 - - #sendConfig //发送消息配置信息 - #msgTitle //消息标题 - #cureeTime //创建时间 - #fieldVal //提交得数据已表字段 - #subUnit //表单组件属性 - -@ 返回值 - - #msgid 消息id,用于撤回应用消息 - #err 信息 - -@ 方法原型 - - # -*/ -func (s *SendMsgInfo) SendMsg(userCont modelshr.ManCont, msgTitle string, uuid, cureeTime int64, fieldVal, masrWriteMap map[string]interface{}, subUnit map[string]customerform.MasterStruct) (msgid string, err error) { - - if s.Open { //开启发送信息 - var sendMsg workWechat.SendMessage - sendUserCount := 0 - var sendUserAll []string - isSend := true - //Step 1: 获取消息的发送范围 - switch s.SendRange { - case 1: //全集团 - sendMsg.Touser = "@all" - case 2: //本公司 - var myCompany modelshr.AdministrativeOrganization - myCompany.GetCont(map[string]interface{}{"id": userCont.Company}, "`wechat_organization_id`") - if myCompany.WechatOrganizationId != 0 { - sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10) - } else { - if userCont.Company != 0 { - //获取该组织得所以下级 - sendUserAll = GainOrgManWechat(userCont.Company) - sendUserCount = len(sendUserAll) - - if sendUserCount <= 1000 && sendUserCount > 0 { - sendMsg.Touser = strings.Join(sendUserAll, "|") - } else { - if sendUserCount == 0 { - isSend = false - } - } - // sendMsg.Touser = - } else { - if userCont.WorkWechat != "" { - sendMsg.Touser = userCont.WorkWechat - } else if userCont.Wechat != "" { - sendMsg.Touser = userCont.Wechat - } else { - sendMsg.Touser = "@all" - } - } - } - case 3: //本部门 - if userCont.MainDeparment != 0 { - var myCompany modelshr.AdministrativeOrganization - myCompany.GetCont(map[string]interface{}{"id": userCont.MainDeparment}, "`wechat_organization_id`") - if myCompany.WechatOrganizationId != 0 { - sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10) - } else { - //获取该组织得所以下级 - sendUserAll = GainOrgManWechat(userCont.MainDeparment) - sendUserCount = len(sendUserAll) - if sendUserCount <= 1000 && sendUserCount > 0 { - sendMsg.Touser = strings.Join(sendUserAll, "|") - } else { - if sendUserCount == 0 { - isSend = false - } - } - } - } else { - if userCont.Wechat == "" && userCont.WorkWechat == "" { - isSend = false - } else { - if userCont.WorkWechat != "" { - sendMsg.Touser = userCont.WorkWechat - } else { - sendMsg.Touser = userCont.Wechat - } - } - } - case 4: //本行政组织 - if userCont.AdminOrg != 0 { - var myCompany modelshr.AdministrativeOrganization - myCompany.GetCont(map[string]interface{}{"id": userCont.AdminOrg}, "`wechat_organization_id`") - if myCompany.WechatOrganizationId != 0 { - sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10) - } else { - //获取该组织得所以下级 - sendUserAll = GainOrgManWechat(userCont.AdminOrg) - sendUserCount = len(sendUserAll) - if sendUserCount <= 1000 && sendUserCount > 0 { - sendMsg.Touser = strings.Join(sendUserAll, "|") - } else { - if sendUserCount == 0 { - isSend = false - } - } - } - } else { - if userCont.Wechat == "" && userCont.WorkWechat == "" { - isSend = false - } else { - if userCont.WorkWechat != "" { - sendMsg.Touser = userCont.WorkWechat - } else { - sendMsg.Touser = userCont.Wechat - } - } - } - case 5: //表格中指定 - sendUserAll = s.TableFieldsSendMsg(fieldVal, userCont) - sendUserCount = len(sendUserAll) - if sendUserCount <= 1000 && sendUserCount > 0 { - sendMsg.Touser = strings.Join(sendUserAll, "|") - } else { - if sendUserCount == 0 { - isSend = false - } - } - case 6: //自定义 - sendUserAll = s.CustomizeSendMsg() - sendUserCount = len(sendUserAll) - if sendUserCount <= 1000 && sendUserCount > 0 { - sendMsg.Touser = strings.Join(sendUserAll, "|") - } else { - if sendUserCount == 0 { - isSend = false - } - } - default: - isSend = false - } - if isSend { - switch s.Types { - case "textcard": - sendMsg.Msgtype = "textcard" - sendMsg.Textcard.Title = s.SendMsgInfo(s.Title, msgTitle, fieldVal, masrWriteMap, subUnit) - sendMsg.Textcard.Description = fmt.Sprintf("
%v
%v
请尽快阅读此信息
", publicmethod.UnixTimeToDay(time.Now().Unix(), 11), s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, subUnit)) - sendMsg.Textcard.Url = fmt.Sprintf("%v/#/work_wechat?masters_key=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, uuid) - sendMsg.Textcard.Btntxt = "前往查看" - case "news": - sendMsg.Msgtype = "news" - //图文内容 - var imgMsgInfo workWechat.ArticlesList - imgMsgInfo.Title = s.SendMsgInfo(s.Title, msgTitle, fieldVal, masrWriteMap, subUnit) - imgMsgInfo.Description = s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, subUnit) - imgMsgInfo.Url = fmt.Sprintf("%v/#/work_wechat?masters_key=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, uuid) - imgMsgInfo.PicUrl = s.GainOneField(s.Icon, msgTitle, fieldVal, subUnit) - sendMsg.NewsMsg.Articles = append(sendMsg.NewsMsg.Articles, imgMsgInfo) - // sendMsg.NewsMsg.Articles = s.SendMsgInfo(s.Title, msgTitle, fieldVal, subUnit) - default: - sendMsg.Msgtype = "text" - sendMsg.TextMsg.Content = s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, subUnit) - } - - sendInitInfouser, _ := json.Marshal(sendUserAll) - fmt.Printf("\n\n这是查看接收人信息-----》%v\n\n", string(sendInitInfouser)) - sendInitInfo, _ := json.Marshal(sendMsg) - fmt.Printf("\n\n这是查看输入信息-----》%v\n\n", string(sendInitInfo)) - - //判断当前人数是否曹组 - if sendUserCount >= 1000 { - fmt.Printf("\n\n--1---》%v\n\n", string(sendInitInfouser)) - var msgidAry []string - var msgToUser []string - for i, v := range sendUserAll { - if (i+1)%1000 == 0 { - if len(msgToUser) > 0 { - sendMsg.Touser = strings.Join(msgToUser, "|") - msgidSte, errStr := sendMsg.SendMsg("stzl", 1) - msgToUser = []string{} - msgidAry = append(msgidAry, msgidSte) - if errStr != nil { - err = errStr - } - } - - } else { - msgToUser = append(msgToUser, v) - } - } - if len(msgToUser) > 0 { - sendMsg.Touser = strings.Join(msgToUser, "|") - msgidSte, errStr := sendMsg.SendMsg("stzl", 1) - fmt.Printf("\n\n--3---》%v\n\n", string(sendInitInfouser)) - msgToUser = []string{} - msgidAry = append(msgidAry, msgidSte) - if errStr != nil { - err = errStr - } - } - if len(msgidAry) > 0 { - msgid = strings.Join(msgidAry, ",") - } - } else { - fmt.Printf("\n\n--2---》%v\n\n", string(sendInitInfouser)) - msgid, err = sendMsg.SendMsg("stzl", 1) - } - } - - } else { - err = nil - } - return -} - /* * @ 作者: 秦东 @@ -1337,8 +1125,15 @@ func (s *SendMsgInfo) GainOneField(fields string, msgTitle string, fieldVal map[ @ 时间: 2025-03-28 15:48:28 @ 功能: 获取发送标题 */ -func (s *SendMsgInfo) SendMsgInfo(fields []string, msgTitle string, fieldVal, masrWriteMap map[string]interface{}, subUnit map[string]customerform.MasterStruct) string { - fmt.Printf("\n\n应获取的字段--->%v\n\n", fields) +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 { @@ -1348,99 +1143,415 @@ func (s *SendMsgInfo) SendMsgInfo(fields []string, msgTitle string, fieldVal, ma } else if vals, isTrue := masrWriteMap[v]; isTrue { sendData = vals } - unitCont := GainFieldType(v, subUnit) - fmt.Printf("\n\n应获取的字段--1->%v--->%v\n\n", unitCont.Type, sendData) - switch unitCont.Type { - case "input", "password", "lowcodeImage": //单行文本 - biaotiYUneirong = publicmethod.TypeToInterface(sendData) - case "textarea", "tinymce": //多行文本,富文本 - biaotiYUneirong = publicmethod.TypeToInterface(sendData) - case "radio", "select": //单选框组、下拉选择框 - val := publicmethod.TypeToInterface(sendData) - if len(unitCont.Options) > 0 { - for _, uv := range unitCont.Options { - if uv.Value == val { - biaotiYUneirong = uv.Label + 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 "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 { + + 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 == strconv.Itoa(v) { - titalMap = append(titalMap, uv.Label) + 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) + } + } } } - biaotiYUneirong = 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])) + 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, "、")) + } } } } - } - biaotiYUneirong = 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]) - biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg/1000, 14), publicmethod.TypeToClass(endTime/1000, 14)) - } else if strValLen == 1 { - startTimg, _ := publicmethod.StringToInt64(strVal[0]) - biaotiYUneirong = publicmethod.TypeToClass(startTimg/1000, 14) + 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, "、"))) + } } - } else { - startTimg, _ := publicmethod.StringToInt64(sendData) - biaotiYUneirong = 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]) - biaotiYUneirong = fmt.Sprintf("%v 至 %v", publicmethod.TypeToClass(startTimg/1000, 14), publicmethod.TypeToClass(endTime/1000, 14)) - } else if strValLen == 1 { - startTimg, _ := publicmethod.StringToInt64(strVal[0]) - biaotiYUneirong = publicmethod.TypeToClass(startTimg/1000, 14) + 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) + } } - } else { - startTimg, _ := publicmethod.StringToInt64(sendData) - biaotiYUneirong = publicmethod.TypeToClass(startTimg, 14) - } - case "colorPicker": //取色器 - biaotiYUneirong = publicmethod.TypeToInterface(sendData) - case "switch": //开关 - startTimg, _ := publicmethod.StringToInt64(sendData) - if startTimg == 1 { - biaotiYUneirong = "是" - } else { - biaotiYUneirong = "否" } - case "rate", "slider": //评分,滑块 - biaotiYUneirong = publicmethod.TypeToInterface(sendData) - case "txt", "button", "title", "table", "grid", "tabs", "card", "flex", "divider", "div": //文本,按钮,标题,表格,格栅,标签,卡片布局,弹性布局,分割线,容器 - biaotiYUneirong = publicmethod.TypeToInterface(sendData) - case "component": //自定义组件 (格式待定) - biaotiYUneirong = publicmethod.TypeToInterface(sendData) - default: - biaotiYUneirong = publicmethod.TypeToInterface(sendData) } } fmt.Printf("\n\n应获取的字段-3-->%v\n\n", biaotiYUneirong) diff --git a/api/version1/taskplatform/taskmanagement/ruanTask.go b/api/version1/taskplatform/taskmanagement/ruanTask.go index 2956f5d..1c343f7 100644 --- a/api/version1/taskplatform/taskmanagement/ruanTask.go +++ b/api/version1/taskplatform/taskmanagement/ruanTask.go @@ -501,10 +501,12 @@ func (a *ApiMethod) SoftDeletion(c *gin.Context) { } var taskList []customerForm.TaskRecord err = overall.CONSTANT_DB_CustomerForm.Where("`masters_key` IN ?", requestData.Id).Find(&taskList).Error - if err != nil { + 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`") @@ -512,6 +514,7 @@ func (a *ApiMethod) SoftDeletion(c *gin.Context) { 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) } diff --git a/api/version1/taskplatform/taskmanagement/sendWorkWatchMsg.go b/api/version1/taskplatform/taskmanagement/sendWorkWatchMsg.go new file mode 100644 index 0000000..080bf75 --- /dev/null +++ b/api/version1/taskplatform/taskmanagement/sendWorkWatchMsg.go @@ -0,0 +1,558 @@ +package taskmanagement + +import ( + "appPlatform/api/version1/customerform" + "appPlatform/api/version1/workWechat" + "appPlatform/models/modelshr" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "strconv" + "strings" + "time" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-28 09:17:29 +@ 功能: 发送企业微信消息 +@ 参数 + + #sendConfig //发送消息配置信息 + #msgTitle //消息标题 + #cureeTime //创建时间 + #fieldVal //提交得数据已表字段 + #subUnit //表单组件属性 + +@ 返回值 + + #msgid 消息id,用于撤回应用消息 + #err 信息 + +@ 方法原型 + + # +*/ +func (s *SendMsgInfo) SendMsg(userCont modelshr.ManCont, msgTitle string, uuid, cureeTime int64, fieldVal, masrWriteMap map[string]interface{}, subUnit map[string]customerform.MasterStruct) (msgid string, err error) { + + if s.Open { //开启发送信息 + var sendMsg workWechat.SendMessage + sendUserCount := 0 + var sendUserAll []string + isSend := true + //Step 1: 获取消息的发送范围 + switch s.SendRange { + case 1: //全集团 + sendMsg.Touser = "@all" + case 2: //本公司 + var myCompany modelshr.AdministrativeOrganization + myCompany.GetCont(map[string]interface{}{"id": userCont.Company}, "`wechat_organization_id`") + if myCompany.WechatOrganizationId != 0 { + sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10) + } else { + if userCont.Company != 0 { + //获取该组织得所以下级 + sendUserAll = GainOrgManWechat(userCont.Company) + sendUserCount = len(sendUserAll) + + if sendUserCount <= 1000 && sendUserCount > 0 { + sendMsg.Touser = strings.Join(sendUserAll, "|") + } else { + if sendUserCount == 0 { + isSend = false + } + } + // sendMsg.Touser = + } else { + if userCont.WorkWechat != "" { + sendMsg.Touser = userCont.WorkWechat + } else if userCont.Wechat != "" { + sendMsg.Touser = userCont.Wechat + } else { + sendMsg.Touser = "@all" + } + } + } + case 3: //本部门 + if userCont.MainDeparment != 0 { + var myCompany modelshr.AdministrativeOrganization + myCompany.GetCont(map[string]interface{}{"id": userCont.MainDeparment}, "`wechat_organization_id`") + if myCompany.WechatOrganizationId != 0 { + sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10) + } else { + //获取该组织得所以下级 + sendUserAll = GainOrgManWechat(userCont.MainDeparment) + sendUserCount = len(sendUserAll) + if sendUserCount <= 1000 && sendUserCount > 0 { + sendMsg.Touser = strings.Join(sendUserAll, "|") + } else { + if sendUserCount == 0 { + isSend = false + } + } + } + } else { + if userCont.Wechat == "" && userCont.WorkWechat == "" { + isSend = false + } else { + if userCont.WorkWechat != "" { + sendMsg.Touser = userCont.WorkWechat + } else { + sendMsg.Touser = userCont.Wechat + } + } + } + case 4: //本行政组织 + if userCont.AdminOrg != 0 { + var myCompany modelshr.AdministrativeOrganization + myCompany.GetCont(map[string]interface{}{"id": userCont.AdminOrg}, "`wechat_organization_id`") + if myCompany.WechatOrganizationId != 0 { + sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10) + } else { + //获取该组织得所以下级 + sendUserAll = GainOrgManWechat(userCont.AdminOrg) + sendUserCount = len(sendUserAll) + if sendUserCount <= 1000 && sendUserCount > 0 { + sendMsg.Touser = strings.Join(sendUserAll, "|") + } else { + if sendUserCount == 0 { + isSend = false + } + } + } + } else { + if userCont.Wechat == "" && userCont.WorkWechat == "" { + isSend = false + } else { + if userCont.WorkWechat != "" { + sendMsg.Touser = userCont.WorkWechat + } else { + sendMsg.Touser = userCont.Wechat + } + } + } + case 5: //表格中指定 + sendUserAll = s.TableFieldsSendMsg(fieldVal, userCont) + sendUserCount = len(sendUserAll) + if sendUserCount <= 1000 && sendUserCount > 0 { + sendMsg.Touser = strings.Join(sendUserAll, "|") + } else { + if sendUserCount == 0 { + isSend = false + } + } + case 6: //自定义 + sendUserAll = s.CustomizeSendMsg() + sendUserCount = len(sendUserAll) + if sendUserCount <= 1000 && sendUserCount > 0 { + sendMsg.Touser = strings.Join(sendUserAll, "|") + } else { + if sendUserCount == 0 { + isSend = false + } + } + default: + isSend = false + } + if isSend { + switch s.Types { + case "textcard": + sendMsg.Msgtype = "textcard" + sendMsg.Textcard.Title = s.SendMsgInfo(s.Title, msgTitle, fieldVal, masrWriteMap, subUnit, 1) + sendMsg.Textcard.Description = fmt.Sprintf("
%v
%v
请尽快阅读此信息
", publicmethod.UnixTimeToDay(time.Now().Unix(), 11), s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, subUnit, 2)) + sendMsg.Textcard.Url = fmt.Sprintf("%v/#/work_wechat?masters_key=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, uuid) + sendMsg.Textcard.Btntxt = "前往查看" + case "news": + sendMsg.Msgtype = "news" + //图文内容 + var imgMsgInfo workWechat.ArticlesList + imgMsgInfo.Title = s.SendMsgInfo(s.Title, msgTitle, fieldVal, masrWriteMap, subUnit, 1) + imgMsgInfo.Description = s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, subUnit, 2) + imgMsgInfo.Url = fmt.Sprintf("%v/#/work_wechat?masters_key=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, uuid) + imgMsgInfo.PicUrl = s.GainOneField(s.Icon, msgTitle, fieldVal, subUnit) + sendMsg.NewsMsg.Articles = append(sendMsg.NewsMsg.Articles, imgMsgInfo) + // sendMsg.NewsMsg.Articles = s.SendMsgInfo(s.Title, msgTitle, fieldVal, subUnit) + default: + sendMsg.Msgtype = "text" + sendMsg.TextMsg.Content = s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, subUnit, 2) + } + + sendInitInfouser, _ := json.Marshal(sendUserAll) + fmt.Printf("\n\n这是查看接收人信息-----》%v\n\n", string(sendInitInfouser)) + sendInitInfo, _ := json.Marshal(sendMsg) + fmt.Printf("\n\n这是查看输入信息-----》%v\n\n", string(sendInitInfo)) + + //判断当前人数是否曹组 + if sendUserCount >= 1000 { + fmt.Printf("\n\n--1---》%v\n\n", string(sendInitInfouser)) + var msgidAry []string + var msgToUser []string + for i, v := range sendUserAll { + if (i+1)%1000 == 0 { + if len(msgToUser) > 0 { + sendMsg.Touser = strings.Join(msgToUser, "|") + msgidSte, errStr := sendMsg.SendMsg("stzl", 1) + msgToUser = []string{} + msgidAry = append(msgidAry, msgidSte) + if errStr != nil { + err = errStr + } + } + + } else { + msgToUser = append(msgToUser, v) + } + } + if len(msgToUser) > 0 { + sendMsg.Touser = strings.Join(msgToUser, "|") + msgidSte, errStr := sendMsg.SendMsg("stzl", 1) + fmt.Printf("\n\n--3---》%v\n\n%v\n\n", string(sendInitInfouser), errStr) + msgToUser = []string{} + msgidAry = append(msgidAry, msgidSte) + if errStr != nil { + err = errStr + } + } + if len(msgidAry) > 0 { + msgid = strings.Join(msgidAry, ",") + } + } else { + + msgid, err = sendMsg.SendMsg("stzl", 1) + fmt.Printf("\n\n--2---》%v\n\n%v\n\n", string(sendInitInfouser), err) + } + } + + } else { + err = nil + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-06-06 13:21:24 +@ 功能: +@ 参数 + + #userCont 当前操作人 + #uuid 任务唯一识别符 + #cureeTime 创建时间 + #msgTitle 默认消息标题 + #fieldVal 数据表字段及对应值 + #masrWriteMap 主表对应数据 + #tableUnit 表单组件 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (s *SendMsgInfo) NewSendMsg(userCont modelshr.ManCont, uuid, cureeTime int64, msgTitle string, fieldVal, masrWriteMap map[string]interface{}, tableUnit map[string]customerform.MasterStruct) (msgid string, err error) { + //Step1:判断是否发起消息推送 + if s.Open { //开启消息推送 + var sendMsg workWechat.SendMessage //消息通用结构体 + isSend := true + var sendTyleList SendMsgNumber //判断是否具备发送消息 + //Step2:获取消息发送范围 + switch s.SendRange { + case 1: //全集团 + sendTyleList.Class = 1 + sendTyleList.SendList = []string{"@all"} + // sendMsg.Touser = "@all" + case 2: //本公司 + sendTyleList.Class = 2 + var myCompany modelshr.AdministrativeOrganization //获取当前执行人的行政组织对应的企业微信ID + myCompany.GetCont(map[string]interface{}{"id": userCont.Company}, "`wechat_organization_id`") + if myCompany.WechatOrganizationId != 0 { //当企业行政组织微信ID存在时进行行政组织发送 + // sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10) + + sendTyleList.SendList = []string{strconv.FormatInt(myCompany.WechatOrganizationId, 10)} + } else { + if userCont.Company != 0 { //当前执行人存在公司ID时执行 + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSonAllId(userCont.Company) + sunOrg.Id = append(sunOrg.Id, userCont.Company) + var allOrgWorkId []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`wechat_organization_id`").Where("`id` IN ?", sunOrg.Id).Find(&allOrgWorkId) + if len(allOrgWorkId) > 0 { + var watchId []string + for _, v := range allOrgWorkId { + if v != 0 { + watchIdStr := strconv.FormatInt(v, 10) + if !publicmethod.IsInTrue[string](watchIdStr, watchId) { + watchId = append(watchId, watchIdStr) + } + } + } + if len(watchId) > 0 { + var guoDu []string + for i := 1; i < len(watchId); i++ { + if i%100 == 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + guoDu = append(guoDu, watchId[i-1]) + } else { + guoDu = append(guoDu, watchId[i-1]) + } + } + if len(guoDu) > 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + } + // sendMsg.Toparty = strings.Join(watchId, "|") + } else { + isSend = false + } + } else { + isSend = false + } + } else { //不存在时 + isSend = false + } + } + case 3: //本部门 + sendTyleList.Class = 3 + if userCont.MainDeparment != 0 { + var myCompany modelshr.AdministrativeOrganization + myCompany.GetCont(map[string]interface{}{"id": userCont.MainDeparment}, "`wechat_organization_id`") + if myCompany.WechatOrganizationId != 0 { //当企业行政组织微信ID存在时进行行政组织发送 + // sendMsg.Toparty = strconv.FormatInt(myCompany.WechatOrganizationId, 10) + + sendTyleList.SendList = []string{strconv.FormatInt(myCompany.WechatOrganizationId, 10)} + } else { + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSonAllId(userCont.MainDeparment) + sunOrg.Id = append(sunOrg.Id, userCont.MainDeparment) + var allOrgWorkId []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`wechat_organization_id`").Where("`id` IN ?", sunOrg.Id).Find(&allOrgWorkId) + if len(allOrgWorkId) > 0 { + var watchId []string + for _, v := range allOrgWorkId { + if v != 0 { + watchIdStr := strconv.FormatInt(v, 10) + if !publicmethod.IsInTrue[string](watchIdStr, watchId) { + watchId = append(watchId, watchIdStr) + } + } + } + if len(watchId) > 0 { + var guoDu []string + for i := 1; i < len(watchId); i++ { + if i%100 == 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + guoDu = append(guoDu, watchId[i-1]) + } else { + guoDu = append(guoDu, watchId[i-1]) + } + } + if len(guoDu) > 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + } + // sendMsg.Toparty = strings.Join(watchId, "|") + } else { + isSend = false + } + } else { + isSend = false + } + } + } else { + isSend = false + } + case 4: //本行政组织 + sendTyleList.Class = 4 + if userCont.AdminOrg != 0 { + var myCompany modelshr.AdministrativeOrganization + myCompany.GetCont(map[string]interface{}{"id": userCont.AdminOrg}, "`wechat_organization_id`") + if myCompany.WechatOrganizationId != 0 { + sendTyleList.SendList = []string{strconv.FormatInt(myCompany.WechatOrganizationId, 10)} + } else { + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSonAllId(userCont.AdminOrg) + sunOrg.Id = append(sunOrg.Id, userCont.AdminOrg) + var allOrgWorkId []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`wechat_organization_id`").Where("`id` IN ?", sunOrg.Id).Find(&allOrgWorkId) + if len(allOrgWorkId) > 0 { + var watchId []string + for _, v := range allOrgWorkId { + if v != 0 { + watchIdStr := strconv.FormatInt(v, 10) + if !publicmethod.IsInTrue[string](watchIdStr, watchId) { + watchId = append(watchId, watchIdStr) + } + } + } + if len(watchId) > 0 { + var guoDu []string + for i := 1; i < len(watchId); i++ { + if i%100 == 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + guoDu = append(guoDu, watchId[i-1]) + } else { + guoDu = append(guoDu, watchId[i-1]) + } + } + if len(guoDu) > 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + } + // sendMsg.Toparty = strings.Join(watchId, "|") + } else { + isSend = false + } + } else { + isSend = false + } + } + } else { + isSend = false + } + case 5: //表格中指定 + sendTyleList.Class = 5 + sendUserAll := s.TableFieldsSendMsg(fieldVal, userCont) + sendUserCount := len(sendUserAll) + if sendUserCount > 0 { + var guoDu []string + for i := 1; i < sendUserCount; i++ { + if i%100 == 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + guoDu = append(guoDu, sendUserAll[i-1]) + } else { + guoDu = append(guoDu, sendUserAll[i-1]) + } + } + if len(guoDu) > 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + } + } else { + isSend = false + } + case 6: //自定义 + sendTyleList.Class = 6 + sendUserAll := s.CustomizeSendMsg() + sendUserCount := len(sendUserAll) + if sendUserCount > 0 { + var guoDu []string + for i := 1; i < sendUserCount; i++ { + if i%100 == 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + guoDu = append(guoDu, sendUserAll[i-1]) + } else { + guoDu = append(guoDu, sendUserAll[i-1]) + } + } + if len(guoDu) > 0 { + sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) + guoDu = []string{} + } + } else { + isSend = false + } + default: + isSend = false + } + //Step3:判断是否具备发送消息条件 + if isSend { + //Step4:组装发射内容 + switch s.Types { + case "textcard": + sendMsg.Msgtype = "textcard" + sendMsg.Textcard.Title = s.SendMsgInfo(s.Title, msgTitle, fieldVal, masrWriteMap, tableUnit, 1) + sendMsg.Textcard.Description = fmt.Sprintf("
%v
%v
请尽快阅读此信息
", publicmethod.UnixTimeToDay(time.Now().Unix(), 11), s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, tableUnit, 2)) + sendMsg.Textcard.Url = fmt.Sprintf("%v/#/work_wechat?masters_key=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, uuid) + sendMsg.Textcard.Btntxt = "前往查看" + case "news": + sendMsg.Msgtype = "news" + //图文内容 + var imgMsgInfo workWechat.ArticlesList + imgMsgInfo.Title = s.SendMsgInfo(s.Title, msgTitle, fieldVal, masrWriteMap, tableUnit, 1) + imgMsgInfo.Description = s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, tableUnit, 2) + imgMsgInfo.Url = fmt.Sprintf("%v/#/work_wechat?masters_key=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, uuid) + imgMsgInfo.PicUrl = s.GainOneField(s.Icon, msgTitle, fieldVal, tableUnit) + sendMsg.NewsMsg.Articles = append(sendMsg.NewsMsg.Articles, imgMsgInfo) + default: + sendMsg.Msgtype = "text" + sendMsg.TextMsg.Content = s.SendMsgInfo(s.Content, msgTitle, fieldVal, masrWriteMap, tableUnit, 2) + } + //Step5:组装发射人员或行政组织 + var msgidAry []string + switch sendTyleList.Class { + case 1: + for _, v := range sendTyleList.SendList { + sendMsg.Touser = v + msgidSte, errStr := sendMsg.SendMsg("stzl", 1) + msgidAry = append(msgidAry, msgidSte) + if errStr != nil { + err = errStr + } + } + case 2: + for _, v := range sendTyleList.SendList { + sendMsg.Toparty = v + msgidSte, errStr := sendMsg.SendMsg("stzl", 1) + msgidAry = append(msgidAry, msgidSte) + if errStr != nil { + err = errStr + } + } + case 3: + for _, v := range sendTyleList.SendList { + sendMsg.Toparty = v + msgidSte, errStr := sendMsg.SendMsg("stzl", 1) + msgidAry = append(msgidAry, msgidSte) + if errStr != nil { + err = errStr + } + } + case 4: + for _, v := range sendTyleList.SendList { + sendMsg.Toparty = v + msgidSte, errStr := sendMsg.SendMsg("stzl", 1) + msgidAry = append(msgidAry, msgidSte) + if errStr != nil { + err = errStr + } + } + case 5: + for _, v := range sendTyleList.SendList { + sendMsg.Touser = v + msgidSte, errStr := sendMsg.SendMsg("stzl", 1) + msgidAry = append(msgidAry, msgidSte) + if errStr != nil { + err = errStr + } + } + case 6: + for _, v := range sendTyleList.SendList { + sendMsg.Touser = v + msgidSte, errStr := sendMsg.SendMsg("stzl", 1) + msgidAry = append(msgidAry, msgidSte) + if errStr != nil { + err = errStr + } + } + default: + } + if len(msgidAry) > 0 { + msgid = strings.Join(msgidAry, ",") + } + } + + } else { //不开启推送消息 + err = nil + } + return +} diff --git a/api/version1/taskplatform/taskmanagement/types.go b/api/version1/taskplatform/taskmanagement/types.go index 7183927..cce4eb9 100644 --- a/api/version1/taskplatform/taskmanagement/types.go +++ b/api/version1/taskplatform/taskmanagement/types.go @@ -84,8 +84,9 @@ type CallBackFormStruct struct { // 批量删除数据 type BatchDeleteClass struct { - Id []string `json:"id"` - IsTrue int `json:"isTrue"` + Id []string `json:"id"` + TableKey string `json:"tableKey"` //表单 + IsTrue int `json:"isTrue"` } type NodelPeopleInfo struct { FactorId string `json:"factorid"` @@ -255,3 +256,8 @@ type SimTask struct { IsRun int `json:"isRun"` //1:正式;2:模拟 UserKey string `json:"userKey"` //模拟操作人 } + +type SendMsgNumber struct { + Class int + SendList []string +} diff --git a/api/version1/workWechat/sendMsg.go b/api/version1/workWechat/sendMsg.go index 85f4b40..06bfe87 100644 --- a/api/version1/workWechat/sendMsg.go +++ b/api/version1/workWechat/sendMsg.go @@ -282,7 +282,7 @@ func (s *SendMessage) SendMsg(systemApp string, class int) (msgid string, err er // mapAry.Send["template_card"] = templateCard msgid, err = mapAry.SendMsg(systemApp, class) - fmt.Printf("\n\n通用发送消息-----》%v\n\n", msgid, err) + fmt.Printf("\n\n通用发送消息-----》%v-----》%v\n\n", msgid, err) return } diff --git a/apirouter/entry.go b/apirouter/entry.go index a58e0c2..978a95d 100644 --- a/apirouter/entry.go +++ b/apirouter/entry.go @@ -4,6 +4,7 @@ import ( "appPlatform/apirouter/apishiyan" "appPlatform/apirouter/authenticationroute" "appPlatform/apirouter/personalityAssessment" + "appPlatform/apirouter/v1/customChartRouter" "appPlatform/apirouter/v1/customerformrouter" datacenterrouter "appPlatform/apirouter/v1/dataCenterRouter" dictrouters "appPlatform/apirouter/v1/dict_routers" @@ -39,6 +40,7 @@ type RouterGroup struct { DataCenterRouter datacenterrouter.ApiRouter WebSocketRouters websocketrouter.ApiRouter CharacterTestRongXin personalityAssessment.ApiRouter + ChartRouter customChartRouter.ApiRouter } var RouterGroupEntry = new(RouterGroup) diff --git a/apirouter/v1/customChartRouter/chartRouter.go b/apirouter/v1/customChartRouter/chartRouter.go new file mode 100644 index 0000000..ec76387 --- /dev/null +++ b/apirouter/v1/customChartRouter/chartRouter.go @@ -0,0 +1,23 @@ +package customChartRouter + +import ( + "appPlatform/api/version1" + + "github.com/gin-gonic/gin" +) + +// 权限矩阵PC端 +func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { + apiRouter := router.Group("chart") + //var methodBinding = version1.AppApiEntry.CustomerFormApi + dataApi := version1.AppApiEntry.ChartApi + { + apiRouter.GET("", dataApi.Index) //入口 + apiRouter.POST("", dataApi.Index) //入口 + + apiRouter.POST("dimMeaFormTable", dataApi.DimMeaFormTable) //获取维度及度量字段 + apiRouter.POST("countChartValue", dataApi.CountChartValue) //将图表信息写入数据库 + apiRouter.POST("getChartCont", dataApi.GetChartCont) //获取图表设定信息 + apiRouter.POST("analyzeChartData", dataApi.AnalyzeChartData) //根据条件解析图标结果 + } +} diff --git a/apirouter/v1/customChartRouter/entry.go b/apirouter/v1/customChartRouter/entry.go new file mode 100644 index 0000000..b1f366f --- /dev/null +++ b/apirouter/v1/customChartRouter/entry.go @@ -0,0 +1,3 @@ +package customChartRouter + +type ApiRouter struct{} diff --git a/apirouter/v1/customerformrouter/router.go b/apirouter/v1/customerformrouter/router.go index 02ec146..93f5fba 100644 --- a/apirouter/v1/customerformrouter/router.go +++ b/apirouter/v1/customerformrouter/router.go @@ -51,8 +51,10 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("gainFormListCont", methodBinding.GainFormListCont) //获取表单列表数据 apiRouter.POST("gainFormPageListCont", methodBinding.GainFormPageListContNew) //获取表单列表翻页数据 + apiRouter.POST("tableCusterField", methodBinding.TableCusterField) //获取表单列表翻页数据(指定字段卡片) - apiRouter.POST("gainListTableField", methodBinding.GainListTableField) //列表展示需要字段 + apiRouter.POST("gainListTableField", methodBinding.GainListTableField) //列表展示需要字段 + apiRouter.POST("gainListTableFieldTitle", methodBinding.GainListTableFieldTitle) //列表展示需要字段 apiRouter.POST("multiViewPage", methodBinding.MultiViewPAge) //多视图数据处理 diff --git a/initialization/route/initRoute.go b/initialization/route/initRoute.go index a84e9c7..147fc36 100644 --- a/initialization/route/initRoute.go +++ b/initialization/route/initRoute.go @@ -108,6 +108,11 @@ func InitialRouter() *gin.Engine { { workFlowRouterApi.RouterGroupFlow(VerifyIdentity) } + //图表 + chartInitRouterApi := apirouter.RouterGroupEntry.ChartRouter + { + chartInitRouterApi.RouterGroup(VerifyIdentity) + } } //验证身份接口 无需鉴权Url(主要web端使用) VerifyIdentityWeb := router.Group("") diff --git a/models/modelAppPlatform/customer_form.go b/models/modelAppPlatform/customer_form.go index 7540ae0..d8a3507 100644 --- a/models/modelAppPlatform/customer_form.go +++ b/models/modelAppPlatform/customer_form.go @@ -31,6 +31,7 @@ type CustomerForm struct { AppOrgMan string `json:"appOrgMan" gorm:"column:appOrgMan;type:mediumtext;default:'';comment:应用管理行政组织"` AgentId string `json:"agentId" gorm:"column:agentId;type:varchar(255);default:'';comment:企业微信应用识别码"` AppSecret string `json:"appSecret" gorm:"column:appSecret;type:text;default:'';comment:验证符号"` + ChartView string `json:"chartView" gorm:"column:chartView;type:longtext;default:'';comment:图表视图"` } func (CustomerForm *CustomerForm) TableName() string { diff --git a/models/modelAppPlatform/customer_form_view.go b/models/modelAppPlatform/customer_form_view.go index 0684028..7517a33 100644 --- a/models/modelAppPlatform/customer_form_view.go +++ b/models/modelAppPlatform/customer_form_view.go @@ -40,6 +40,7 @@ type CustomerFormView struct { AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;default:'';comment:授权职务"` SignCode int64 `json:"signCode" gorm:"column:signCode;type:bigint(20) unsigned NOT NULL DEFAULT '0';comment:唯一标识"` Describe string `json:"describe" gorm:"column:describe;type:longtext;default:'';comment:描述"` + ChartView string `json:"chartView" gorm:"column:chartView;type:longtext;default:'';comment:图表视图"` } func (CustomerFormView *CustomerFormView) TableName() string { diff --git a/overall/publicmethod/tableUnit.go b/overall/publicmethod/tableUnit.go new file mode 100644 index 0000000..ec8298c --- /dev/null +++ b/overall/publicmethod/tableUnit.go @@ -0,0 +1,6 @@ +package publicmethod + +//自定义表单量化类型 +var Dimension = []string{"input", "textarea", "datePicker", "timePicker", "organization", "tinymce", "colorPicker", "treeSelect", "serialNumber", "expand-user", "orgCentent", "founder", "founderTime", "editTime", "owner", "deptOrg", "pickpost", "pickrole"} //维度字段 +var Quantization = []string{"digitpage", "radio", "checkbox", "select", "cascader", "switch", "inputNumber", "slider", "rate"} //可量化字段 +var TimeUint = []string{"founderTime", "editTime", "timePicker"} diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 480da4a..2875518 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -2678,7 +2678,7 @@ func TypeToClass(val interface{}, timeClass int) (str string) { if valErr == nil { str = UnixTimeToDay(valInt, timeClass) } else { - str = "" + str = typeVal } } else { str = "" @@ -3016,3 +3016,36 @@ func GetLastMonthStartEnd(dayTime string) (int64, int64) { lastMonthEnd := time.Date(lastMonthEndDay.Year(), lastMonthEndDay.Month(), lastMonthEndDay.Day(), 23, 59, 59, 0, now.Location()).Unix() return lastMonthStart, lastMonthEnd } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-06-03 09:13:15 +@ 功能: 计算整数长度 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GetIntLength(n int64) int { + if n == 0 { + return 1 + } + count := 0 + // 处理负数的情况 + if n < 0 { + n = -n + } + for n > 0 { + count++ + n /= 10 + } + return count +}