22 changed files with 2425 additions and 334 deletions
@ -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" |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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"` |
||||
|
} |
||||
@ -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 "" |
||||
|
} |
||||
@ -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("<div class='gray'>%v</div> <div class='normal'>%v</div><div class='highlight'>请尽快阅读此信息</div>", 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("<div class='gray'>%v</div> <div class='normal'>%v</div><div class='highlight'>请尽快阅读此信息</div>", 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 |
||||
|
} |
||||
@ -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) //根据条件解析图标结果
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
package customChartRouter |
||||
|
|
||||
|
type ApiRouter struct{} |
||||
@ -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"} |
||||
Loading…
Reference in new issue