You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
819 lines
23 KiB
819 lines
23 KiB
package customerform
|
|
|
|
import (
|
|
"appPlatform/models/customerForm"
|
|
"appPlatform/models/modelAppPlatform"
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-07-08 15:41:37
|
|
@ 功能: 多视图数据处理
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) MultiViewPAge(c *gin.Context) {
|
|
var requestData ViewListSearch
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.FormId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知表单!无法获取字段!2")
|
|
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`")
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
return
|
|
}
|
|
var formList []map[string]interface{}
|
|
sendListInfo := publicmethod.MapOut[string]()
|
|
var sendTimeList []interface{}
|
|
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.`creater` = ? ", userCont.Key)
|
|
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2)
|
|
gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb)
|
|
var total int64
|
|
totalErr := gormDb.Count(&total).Error
|
|
if totalErr != nil {
|
|
total = 0
|
|
}
|
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
|
|
switch requestData.ViewClass.Class {
|
|
case "date":
|
|
gormDb = gormDb.Order("`id` DESC")
|
|
case "time":
|
|
if requestData.ViewClass.SortWord != "" {
|
|
if requestData.ViewClass.Sort == 1 {
|
|
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord))
|
|
} else {
|
|
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord))
|
|
}
|
|
} else {
|
|
if requestData.ViewClass.Sort == 1 {
|
|
gormDb = gormDb.Order("`id` DESC")
|
|
} else {
|
|
gormDb = gormDb.Order("`id` ASC")
|
|
}
|
|
}
|
|
case "gantt":
|
|
if requestData.ViewClass.SortWord != "" {
|
|
if requestData.ViewClass.Sort == 1 {
|
|
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord))
|
|
} else {
|
|
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord))
|
|
}
|
|
} else {
|
|
if requestData.ViewClass.Sort == 1 {
|
|
gormDb = gormDb.Order("`id` DESC")
|
|
} else {
|
|
gormDb = gormDb.Order("`id` ASC")
|
|
}
|
|
}
|
|
case "map":
|
|
if requestData.ViewClass.SortWord != "" {
|
|
if requestData.ViewClass.Sort == 1 {
|
|
gormDb = gormDb.Order(fmt.Sprintf("`%v` DESC", requestData.ViewClass.SortWord))
|
|
} else {
|
|
gormDb = gormDb.Order(fmt.Sprintf("`%v` ASC", requestData.ViewClass.SortWord))
|
|
}
|
|
} else {
|
|
if requestData.ViewClass.Sort == 1 {
|
|
gormDb = gormDb.Order("`id` DESC")
|
|
} else {
|
|
gormDb = gormDb.Order("`id` ASC")
|
|
}
|
|
}
|
|
default:
|
|
gormDb = gormDb.Order("`id` DESC")
|
|
}
|
|
err = gormDb.Find(&formList).Error
|
|
if err != nil && len(formList) < 1 {
|
|
publicmethod.Result(0, err, c)
|
|
return
|
|
}
|
|
// pageMyTola := len()
|
|
// fmt.Printf("列表数据解析---1->%v\n", formInfo.ListJson)
|
|
|
|
//获取任务状态
|
|
for i, v := range formList {
|
|
formList[i]["isRetract"] = false
|
|
if mastrKey, ok := v["runFlowId"]; ok {
|
|
// fmt.Printf("masters_key----------->%v\n", v["masters_key"])
|
|
var runFlowInfo customerForm.RunWorkflow
|
|
runFlowInfo.GetCont(map[string]interface{}{"`id`": mastrKey}, "`id`", "`current_step`", "`next_step`")
|
|
formList[i]["runFlowInfo"] = strconv.FormatInt(runFlowInfo.Id, 10)
|
|
formList[i]["runFlowId"] = strconv.FormatInt(runFlowInfo.Id, 10)
|
|
// fmt.Printf("runFlowInfo----------->%v--------->%v\n", runFlowInfo, v["taskStatus"])
|
|
if stateVal, ok := v["taskStatus"]; ok {
|
|
// fmt.Printf("NextStep----------->%T----------->%v--------->%v--------->%v\n", stateVal, stateVal, runFlowInfo.NextStep, runFlowInfo.CurrentStep)
|
|
if stauval, ok := stateVal.(string); ok {
|
|
if stauval == "3" && runFlowInfo.NextStep != 0 {
|
|
|
|
if runFlowInfo.CurrentStep == 1 {
|
|
if createrName, ok := formList[i]["creater"].(string); ok {
|
|
if createrName == userCont.Name {
|
|
formList[i]["isRetract"] = true
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
if mastrKeyVal, ok := v["masters_key"]; ok {
|
|
// fmt.Printf("mastrKeyVal----------->%T----------->%v\n", mastrKeyVal, mastrKeyVal)
|
|
if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok {
|
|
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10)
|
|
}
|
|
}
|
|
}
|
|
|
|
if requestData.OlaData != "" {
|
|
var oldDataAry interface{}
|
|
err = json.Unmarshal([]byte(requestData.OlaData), &oldDataAry)
|
|
if err == nil {
|
|
if oldVal, ok := oldDataAry.([]interface{}); ok {
|
|
var oldList []map[string]interface{}
|
|
for _, v := range oldVal {
|
|
if mv, mvOk := v.(map[string]interface{}); mvOk {
|
|
if mvla, isOk := mv["class_type$unit"]; isOk {
|
|
timeInt, _ := publicmethod.StringToInt64(mvla)
|
|
if timeInt != 1 {
|
|
oldInfo := publicmethod.MapOut[string]()
|
|
for key, val := range mv {
|
|
if key != "class_type$unit" {
|
|
oldInfo[key] = val
|
|
}
|
|
if key == "creater_time" {
|
|
// creTime, _ := publicmethod.StringToInt64(mvla)
|
|
// oldInfo[key] =
|
|
if sVal, isTrue := val.(string); isTrue {
|
|
var creTimeAll publicmethod.DateTimeTotimes
|
|
creTimeAll.BaisStrToTime(sVal)
|
|
creTime, _ := publicmethod.StringToInt64(creTimeAll.AllTime)
|
|
oldInfo[key] = creTime
|
|
}
|
|
// fmt.Printf("formList----> %T----> %v\n", val, val)
|
|
}
|
|
if key == "edit_time" {
|
|
if sVal, isTrue := val.(string); isTrue {
|
|
var creTimeAll publicmethod.DateTimeTotimes
|
|
creTimeAll.BaisStrToTime(sVal)
|
|
creTime, _ := publicmethod.StringToInt64(creTimeAll.AllTime)
|
|
oldInfo[key] = creTime
|
|
}
|
|
}
|
|
}
|
|
oldList = append(oldList, oldInfo)
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
// fmt.Printf("mvla----> %T----> %v\n", oldList, oldList)
|
|
if len(oldList) > 0 {
|
|
oldList = append(oldList, formList...)
|
|
formList = oldList
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// fmt.Printf("formList----> %v----> %v\n", len(formList), formList)
|
|
if formInfo.ListJson != "" {
|
|
var listFieldsMap ListPageFields
|
|
err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap)
|
|
// fmt.Printf("列表数据解析---->%v\n", err)
|
|
if err == nil {
|
|
lik, formListAry, dayAry := listFieldsMap.TimeViewWordHandle(formList, requestData.ViewClass)
|
|
// timeAry := publicmethod.MapOut[string]()
|
|
sendListInfo["listInfo"] = formListAry
|
|
sendListInfo["dayList"] = dayAry
|
|
sendListInfo["lik"] = lik
|
|
for _, lv := range lik {
|
|
if len(lv.List) > 0 {
|
|
for _, lvlv := range lv.List {
|
|
sendTimeList = append(sendTimeList, lvlv)
|
|
}
|
|
// sendTimeList = append(sendTimeList, lv)
|
|
}
|
|
}
|
|
|
|
// formList = appenlikd(formList, timeAry)
|
|
}
|
|
}
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), sendTimeList, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-07-09 08:57:05
|
|
@ 功能: 时间轴视图数据输出
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (l *ListPageFields) TimeViewWordHandle(listData []map[string]interface{}, viewCalss ViewKeyType) ([]TimeFenGe, []map[string]interface{}, []string) {
|
|
|
|
// fmt.Printf("TimeViewWordHandle:%v------------>%v\n", len(listData), listData)
|
|
|
|
var sendList []map[string]interface{}
|
|
var dayAry []string
|
|
var lik []TimeFenGe
|
|
switch viewCalss.Class {
|
|
case "date":
|
|
|
|
case "time":
|
|
_, _, listTime := l.GainStartOrEndTime(listData, viewCalss)
|
|
lik = listTime
|
|
// startTime := int64(0)
|
|
// endTime := int64(0)
|
|
// sendInfo := publicmethod.MapOut[string]()
|
|
// for _, lv := range listData {
|
|
|
|
// for mi, mv := range lv {
|
|
// if mi == viewCalss.SortWord {
|
|
// mvInt, _ := publicmethod.StringToInt64(mv)
|
|
// if startTime == 0 && endTime == 0 {
|
|
// startTime = mvInt
|
|
// endTime = mvInt
|
|
// } else {
|
|
// if startTime <= mvInt {
|
|
// startTime = mvInt
|
|
// }
|
|
// if endTime >= mvInt {
|
|
// endTime = mvInt
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// jsondd, _ := json.Marshal(listTime)
|
|
// fmt.Printf("猎头结果:%v================%v================%v\n", len(listTime), string(jsondd), listTime)
|
|
for _, v := range listTime {
|
|
if len(v.List) > 0 {
|
|
info := publicmethod.MapOut[string]()
|
|
info[v.DateTime] = v.List
|
|
sendList = append(sendList, info)
|
|
dayAry = append(dayAry, v.DateTime)
|
|
// for _, lv := range v.List {
|
|
// sendList = append(sendList, lv)
|
|
// }
|
|
}
|
|
}
|
|
// sendList = listTime
|
|
case "gantt":
|
|
|
|
case "map":
|
|
|
|
default:
|
|
sendList = l.DevelopSpecificationsSend(listData)
|
|
}
|
|
// fmt.Printf("获取起止时间--->%v---->%v\n", len(lik), lik)
|
|
return lik, sendList, dayAry
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-07-09 10:14:44
|
|
@ 功能: 获取起止时间
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (l *ListPageFields) GainStartOrEndTime(listData []map[string]interface{}, viewCalss ViewKeyType) (startTime, endTime int64, sendTime []TimeFenGe) {
|
|
for _, lv := range listData {
|
|
for mi, mv := range lv {
|
|
if mi == viewCalss.SortWord {
|
|
mvInt, _ := publicmethod.StringToInt64(mv)
|
|
if startTime == 0 && endTime == 0 {
|
|
startTime = mvInt
|
|
endTime = mvInt
|
|
} else {
|
|
if startTime <= mvInt {
|
|
startTime = mvInt
|
|
}
|
|
if endTime >= mvInt {
|
|
endTime = mvInt
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
tianShu, _ := publicmethod.DayBetweenDate(publicmethod.UnixTimeToDay(startTime, 14), publicmethod.UnixTimeToDay(endTime, 14))
|
|
fmt.Printf("天数: %v\n", tianShu)
|
|
if viewCalss.Sort == 1 {
|
|
beginTime := publicmethod.TimeUnixToTime(startTime, "s")
|
|
for i := 0; i <= tianShu; i++ {
|
|
yesterday := beginTime.AddDate(0, 0, -i)
|
|
var timeInfo TimeFenGe
|
|
riqi := publicmethod.UnixTimeToDay(yesterday.Unix(), 14)
|
|
timeInfo.DateTime = riqi
|
|
timeInfo.WeekDay, _ = publicmethod.GetWeekday(riqi)
|
|
timeInfo.Day = publicmethod.UnixTimeToDay(yesterday.Unix(), 18)
|
|
timeInfo.Stor = i
|
|
timeInfo.TimeUnix = yesterday.Unix()
|
|
begin, end := publicmethod.TimeUnixDayStartAndEnd(yesterday.Unix())
|
|
timeInfo.StartAndEnd.Start = begin
|
|
timeInfo.StartAndEnd.End = end
|
|
listAry := l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData)
|
|
if len(listAry) > 0 {
|
|
gd := make(map[string]interface{})
|
|
gd["dateTime"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 40)
|
|
gd["weekDay"], _ = publicmethod.GetWeekday(riqi)
|
|
gd["day"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 18)
|
|
gd["class_type$unit"] = 1
|
|
timeInfo.List = append(timeInfo.List, gd)
|
|
timeInfo.List = append(timeInfo.List, listAry...)
|
|
} else {
|
|
timeInfo.List = l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData)
|
|
}
|
|
|
|
// DaBaoShuJu(riqi, viewCalss.SortWord, begin, end, listData)
|
|
sendTime = append(sendTime, timeInfo)
|
|
}
|
|
} else {
|
|
beginTime := publicmethod.TimeUnixToTime(endTime, "s")
|
|
for i := 0; i <= tianShu; i++ {
|
|
yesterday := beginTime.AddDate(0, 0, -i)
|
|
var timeInfo TimeFenGe
|
|
riqi := publicmethod.UnixTimeToDay(yesterday.Unix(), 14)
|
|
timeInfo.DateTime = riqi
|
|
timeInfo.WeekDay, _ = publicmethod.GetWeekday(riqi)
|
|
timeInfo.Day = publicmethod.UnixTimeToDay(yesterday.Unix(), 18)
|
|
timeInfo.Stor = i
|
|
timeInfo.TimeUnix = yesterday.Unix()
|
|
begin, end := publicmethod.TimeUnixDayStartAndEnd(yesterday.Unix())
|
|
timeInfo.StartAndEnd.Start = begin
|
|
timeInfo.StartAndEnd.End = end
|
|
listAry := l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData)
|
|
if len(listAry) > 0 {
|
|
gd := make(map[string]interface{})
|
|
gd["dateTime"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 40)
|
|
gd["weekDay"], _ = publicmethod.GetWeekday(riqi)
|
|
gd["day"] = publicmethod.UnixTimeToDay(yesterday.Unix(), 18)
|
|
gd["class_type$unit"] = 1
|
|
timeInfo.List = append(timeInfo.List, gd)
|
|
timeInfo.List = append(timeInfo.List, listAry...)
|
|
} else {
|
|
timeInfo.List = l.DaBaoShuJu(viewCalss.SortWord, begin, end, listData)
|
|
}
|
|
|
|
// DaBaoShuJu(riqi, viewCalss.SortWord, begin, end, listData)
|
|
sendTime = append(sendTime, timeInfo)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-07-09 11:39:52
|
|
@ 功能: 打包数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (l *ListPageFields) DaBaoShuJu(sortWord string, startTime, endTime int64, listData []map[string]interface{}) (sendData []interface{}) {
|
|
// fmt.Printf("打包--->%v\n", sortWord)
|
|
sc := make([]interface{}, 0)
|
|
for _, v := range listData {
|
|
if mv, ok := v[sortWord]; ok {
|
|
// fmt.Printf("打包--1->%v->%T\n", mv, mv)
|
|
idInt, _ := publicmethod.StringToInt64(mv)
|
|
// fmt.Printf("打包--1->%v->%T->%v->%T\n", mv, mv, idInt, idInt)
|
|
if idInt >= startTime && idInt <= endTime {
|
|
v[sortWord] = publicmethod.UnixTimeToDay(idInt, 11)
|
|
v["class_type$unit"] = 2
|
|
for mi, mv := range v {
|
|
switch mi {
|
|
case "creater":
|
|
if sortWord != "creater" {
|
|
var myInfo modelshr.PersonArchives
|
|
myInfo.GetCont(map[string]interface{}{"`key`": mv}, "`name`")
|
|
v[mi] = myInfo.Name
|
|
}
|
|
|
|
case "creater_time":
|
|
if sortWord != "creater_time" {
|
|
timeInt, _ := publicmethod.StringToInt64(mv)
|
|
v[mi] = publicmethod.UnixTimeToDay(timeInt, 11)
|
|
}
|
|
case "edit_time":
|
|
if sortWord != "edit_time" {
|
|
timeInt, _ := publicmethod.StringToInt64(mv)
|
|
v[mi] = publicmethod.UnixTimeToDay(timeInt, 11)
|
|
}
|
|
default:
|
|
_, v[mi] = l.BaseTableAttrViewField(mi, mv)
|
|
// sendInfo[mi] = publicmethod.TypeToInterface(mv)
|
|
}
|
|
|
|
}
|
|
sc = append(sc, v)
|
|
// sendData = append(sendData, sc)
|
|
}
|
|
}
|
|
}
|
|
if len(sc) > 0 {
|
|
// sendVal := publicmethod.MapOut[string]()
|
|
// sendVal[riqi] = sc
|
|
sendData = sc
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-02 08:14:10
|
|
@ 功能: 按照制定列表字段输出(视图)
|
|
*/
|
|
func (l *ListPageFields) DevelopSpecificViewSend(listData []map[string]interface{}) []map[string]interface{} {
|
|
var sendList []map[string]interface{}
|
|
for _, v := range listData {
|
|
sendInfo := publicmethod.MapOut[string]()
|
|
for mi, mv := range v {
|
|
fmt.Printf("%v = %v\n", mi, mv)
|
|
// switch mi {
|
|
// case "creater":
|
|
// var myInfo modelshr.PersonArchives
|
|
// myInfo.GetCont(map[string]interface{}{"`key`": mv}, "`name`")
|
|
// sendInfo["创建人"] = myInfo.Name
|
|
// case "creater_time":
|
|
// timeInt, _ := publicmethod.StringToInt64(mv)
|
|
// sendInfo["创建时间"] = publicmethod.UnixTimeToDay(timeInt, 27)
|
|
// case "edit_time":
|
|
// timeInt, _ := publicmethod.StringToInt64(mv)
|
|
// sendInfo["编辑时间"] = publicmethod.UnixTimeToDay(timeInt, 27)
|
|
// case "id":
|
|
// if idInt, ok := mv.(int64); ok {
|
|
// sendInfo["Id"] = strconv.FormatInt(idInt, 10)
|
|
// }
|
|
// idInt, _ := publicmethod.StringToInt64(mv)
|
|
// sendInfo["Id"] = idInt
|
|
// default:
|
|
// // sendInfo[mi] = l.BaseTableAttrField(mi, mv)
|
|
// key, val := l.BaseTableAttrViewField(mi, mv)
|
|
// if key != "" {
|
|
// sendInfo[key] = val
|
|
// }
|
|
|
|
// // sendInfo[mi] = publicmethod.TypeToInterface(mv)
|
|
// }
|
|
key, val := l.BaseTableAttrViewField(mi, mv)
|
|
if key != "" {
|
|
sendInfo[key] = val
|
|
}
|
|
}
|
|
// fmt.Printf("================================\n")
|
|
sendList = append(sendList, sendInfo)
|
|
}
|
|
return sendList
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-02 11:42:20
|
|
@ 功能: 根据字段显示格式处理数据(字段)
|
|
*/
|
|
func (l *ListPageFields) BaseTableAttrViewField(key string, val interface{}) (string, interface{}) {
|
|
// fmt.Printf("根据字段显示格式处理数据(字段):%v==1==>%v\n", key, len(l.TableData.Columns))
|
|
if len(l.TableData.Columns) < 0 {
|
|
return "", val
|
|
}
|
|
keyStr := ""
|
|
for _, v := range l.TableData.Columns {
|
|
// fmt.Printf("根据字段显示格式处理数据(字段):%v====>%v\n", key, v.Id)
|
|
if v.Id == key {
|
|
// fmt.Printf("根据字段显示格式处理数据(字段):%v\n", v.Label)
|
|
switch v.FieldClass {
|
|
case "checkbox":
|
|
if val != nil {
|
|
var checkboxStrAry []interface{}
|
|
var checkboxAry []string
|
|
if valStr, ok := val.(string); ok {
|
|
err := json.Unmarshal([]byte(valStr), &checkboxStrAry)
|
|
if err == nil {
|
|
for _, v := range checkboxStrAry {
|
|
checkboxAry = append(checkboxAry, publicmethod.TypeToInterface(v))
|
|
}
|
|
}
|
|
}
|
|
|
|
if len(checkboxAry) > 0 {
|
|
var jieGuo []string
|
|
for _, ov := range v.Options {
|
|
if publicmethod.IsInTrue[string](ov.Value, checkboxAry) {
|
|
jieGuo = append(jieGuo, ov.Label)
|
|
}
|
|
}
|
|
val = strings.Join(jieGuo, ",")
|
|
}
|
|
}
|
|
case "orgCentent":
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
orgCont.GetCont(map[string]interface{}{"`id`": val}, "name")
|
|
return v.Label, orgCont.Name
|
|
case "baidumap":
|
|
var mapAry []string
|
|
if valStr, ok := val.(string); ok {
|
|
mapAry = strings.Split(valStr, "|*@*|")
|
|
}
|
|
if len(mapAry) > 0 {
|
|
return v.Label, mapAry[0]
|
|
}
|
|
default:
|
|
return v.Label, publicmethod.TypeToInterface(val)
|
|
}
|
|
}
|
|
}
|
|
return keyStr, val
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-07-16 14:02:42
|
|
@ 功能: 根据日期获取数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GainCalendarList(c *gin.Context) {
|
|
var requestData CalendarSearch
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
if len(requestData.TimeAry) < 1 && len(requestData.TimeMonthAry) < 1 {
|
|
publicmethod.Result(1, requestData, c, "未知日期!无法获取字段!2")
|
|
return
|
|
}
|
|
if requestData.Search.FormId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知表单!无法获取字段!")
|
|
return
|
|
}
|
|
if requestData.Search.Page == 0 {
|
|
requestData.Search.Page = 1
|
|
}
|
|
if requestData.Search.PageSize == 0 {
|
|
requestData.Search.Page = 20
|
|
}
|
|
|
|
var listField []SearchButtonInfo
|
|
json.Unmarshal([]byte(requestData.Search.SearchData), &listField)
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
|
|
var formInfo modelAppPlatform.CustomerFormView
|
|
err := formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.Search.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`")
|
|
if err != nil {
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
return
|
|
}
|
|
var listFieldsMap ListPageFields
|
|
json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap)
|
|
|
|
if requestData.Types != 1 {
|
|
var listSynv CalendarList
|
|
for _, v := range requestData.TimeAry {
|
|
syncSeting.Add(1)
|
|
go listSynv.GetDayCont(v, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson)
|
|
}
|
|
syncSeting.Wait()
|
|
sendListArt := TimeHaveAry(requestData.TimeAry, listSynv.List)
|
|
if len(sendListArt) == 1 {
|
|
var onInfo TimeAryInfo
|
|
for _, v := range sendListArt {
|
|
onInfo = v
|
|
}
|
|
publicmethod.Result(0, onInfo, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, sendListArt, c)
|
|
} else {
|
|
var sendMonthList []interface{}
|
|
for _, v := range requestData.TimeMonthAry {
|
|
var listSynv CalendarList
|
|
for _, tv := range v {
|
|
syncSeting.Add(1)
|
|
go listSynv.GetDayCont(tv, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson)
|
|
}
|
|
syncSeting.Wait()
|
|
// sendListArt := TimeHaveAry(v, listSynv.List)
|
|
// fmt.Printf("每段结构---->%v\n=================================\n", sendListArt)
|
|
sendMonthList = append(sendMonthList, TimeHaveAry(v, listSynv.List))
|
|
}
|
|
|
|
publicmethod.Result(0, sendMonthList, c)
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-07-17 08:55:56
|
|
@ 功能: 结果与日期合并
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func TimeHaveAry(dateList []TimeAryInfo, listDate []map[string]interface{}) []TimeAryInfo {
|
|
for ti, tv := range dateList {
|
|
fmt.Printf("测试类型--->%v=============>%v\n", ti, tv)
|
|
for _, v := range listDate {
|
|
for mi, mv := range v {
|
|
if tv.Date == mi {
|
|
dateList[ti].List = mv
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return dateList
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-07-16 14:09:26
|
|
@ 功能: 按天获取数据
|
|
@ 参数
|
|
|
|
#day 日历单个日期参数
|
|
#tableName 要操作得数据表
|
|
#userCont 当前操作人
|
|
#Search 搜索条件
|
|
#listField 自定义表单查询条件
|
|
#viewCondition 视图设定
|
|
#listJson 字段处理
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (c *CalendarList) GetDayCont(day TimeAryInfo, tableName string, userCont modelshr.ManCont, Search FormPageListAttr, listField []SearchButtonInfo, viewCondition map[string]ViewInfo, listJson string) {
|
|
defer syncSeting.Done()
|
|
|
|
tableName = fmt.Sprintf("`%v` as f", tableName)
|
|
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.`creater` = ? ", userCont.Key)
|
|
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2)
|
|
gormDb = AnalysisSerachTermSqlIng(listField, gormDb)
|
|
|
|
if class, isOk := viewCondition["date"]; isOk {
|
|
if class.Status {
|
|
startTime, endTime := publicmethod.OenDayStartOrEndTime(day.Date, 1)
|
|
if class.Form.StartTime != "" && class.Form.EndTime != "" {
|
|
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v OR f.`%v` BETWEEN %v AND %v", class.Form.StartTime, startTime, endTime, class.Form.EndTime, startTime, endTime)
|
|
gormDb = gormDb.Where(whySql)
|
|
} else if class.Form.StartTime != "" && class.Form.EndTime == "" {
|
|
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v", class.Form.StartTime, startTime, endTime)
|
|
gormDb = gormDb.Where(whySql)
|
|
} else if class.Form.StartTime == "" && class.Form.EndTime != "" {
|
|
whySql := fmt.Sprintf("f.`%v` BETWEEN %v AND %v", class.Form.EndTime, startTime, endTime)
|
|
gormDb = gormDb.Where(whySql)
|
|
}
|
|
}
|
|
}
|
|
var formList []map[string]interface{}
|
|
err := gormDb.Order("`id` DESC").Find(&formList).Error
|
|
if listJson != "" {
|
|
var listFieldsMap ListPageFields
|
|
err = json.Unmarshal([]byte(listJson), &listFieldsMap)
|
|
if err == nil {
|
|
formList = listFieldsMap.DevelopSpecificationsSend(formList)
|
|
}
|
|
|
|
}
|
|
if err == nil {
|
|
inDate := publicmethod.MapOut[string]()
|
|
inDate[day.Date] = formList
|
|
c.List = append(c.List, inDate)
|
|
// c.List = append(c.List, inDate)
|
|
// c.List = make(map[string]interface{})
|
|
// c.List[day.Date] = formList
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-07-16 15:53:51
|
|
@ 功能: 自定义表单查询条件
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func AnalysisSerachTermSqlIng(why []SearchButtonInfo, gormDb *gorm.DB) *gorm.DB {
|
|
if len(why) < 1 {
|
|
return gormDb
|
|
}
|
|
for _, v := range why {
|
|
if v.Values != nil && v.Values != "" {
|
|
switch v.Pattern {
|
|
case "int":
|
|
likeSql := fmt.Sprintf("f.`%v` = %v", v.Field, v.Values)
|
|
gormDb = gormDb.Where(likeSql)
|
|
case "bigint":
|
|
likeSql := fmt.Sprintf("f.`%v` = %v", v.Field, v.Values)
|
|
gormDb = gormDb.Where(likeSql)
|
|
default:
|
|
likeSql := fmt.Sprintf("f.%v LIKE %v%v%v", v.Field, "'%", v.Values, "%'")
|
|
gormDb = gormDb.Where(likeSql)
|
|
}
|
|
}
|
|
}
|
|
return gormDb
|
|
}
|
|
|