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("