diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a330349 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "idf.pythonInstallPath": "f:\\esp32\\toolsides\\tools\\idf-python\\3.11.2\\python.exe" +} \ No newline at end of file diff --git a/api/personalityTest/rongXinPage/downLoad.go b/api/personalityTest/rongXinPage/downLoad.go index e6184c6..697ae88 100644 --- a/api/personalityTest/rongXinPage/downLoad.go +++ b/api/personalityTest/rongXinPage/downLoad.go @@ -469,3 +469,74 @@ func jisuanOrg(company, deparment, org int64) string { } return "" } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-02-27 11:02:37 +@ 功能: 下载人员班组 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) DownLoadTearms(c *gin.Context) { + adminorg := c.Query("org") + if adminorg == "" || adminorg == "0" { + c.String(c.Writer.Status(), "没有获取到正确的行政组织") + return + } + adminorgInt, _ := strconv.ParseInt(adminorg, 10, 64) + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSun(adminorgInt) + sunOrg.Id = append(sunOrg.Id, adminorgInt) + var peopleList []modelshr.PersonArchives + overall.CONSTANT_DB_HrInside.Model(&modelshr.PersonArchives{}).Select("`number`,`name`,`admin_org`,`teamid` ").Where("`admin_org` IN ? AND `emp_type` BETWEEN 1 AND 10", sunOrg.Id).Find(&peopleList) + if len(peopleList) < 1 { + c.String(c.Writer.Status(), "没有查询到信息") + return + } + var orgInfo modelshr.AdministrativeOrganization + orgInfo.GetCont(map[string]interface{}{"`id`": adminorg}, "`name`") + var builder strings.Builder + builder.WriteString("\xEF\xBB\xBF") //写入UTF-8 BOM 防止乱码 + writer := csv.NewWriter(&builder) + tableTitle := fmt.Sprintf("%v班组信息列表", orgInfo.Name) + writer.Write([]string{tableTitle}) + writer.Write([]string{"序号", "工号", "姓名", "班组"}) + for i, v := range peopleList { + var scvBody []string + xuHao := strconv.Itoa(i + 1) + scvBody = append(scvBody, xuHao) + scvBody = append(scvBody, v.Number) + scvBody = append(scvBody, v.Name) + if v.TeamId != 0 { + var teamsInfo modelshr.TeamGroup + teamsInfo.GetCont(map[string]interface{}{"`id`": v.TeamId}, "`name`") + if teamsInfo.Name == "" { + scvBody = append(scvBody, "未知") + } else { + scvBody = append(scvBody, teamsInfo.Name) + } + + } else { + scvBody = append(scvBody, "未知") + } + writer.Write(scvBody) + } + writer.Flush() + fileName := fmt.Sprintf("%v_班组信息列表_%v.csv", orgInfo.Name, publicmethod.GetUUid(1)) + c.Writer.Header().Add("Content-type", "application/octet-stream") + c.Header("Content-Type", "application/vnd.ms-excel;charset=utf8") + c.Header("Content-Disposition", "attachment; filename="+url.PathEscape(fileName)) + // c.Header("Content-Disposition", "attachment; filename=团队角色盘点.csv") + c.Header("Content-Transfer-Encoding", "binary") + c.Writer.Write([]byte(builder.String())) +} diff --git a/api/version1/customerApp/appControll.go b/api/version1/customerApp/appControll.go index 6a716db..aa4f7cb 100644 --- a/api/version1/customerApp/appControll.go +++ b/api/version1/customerApp/appControll.go @@ -229,6 +229,7 @@ func AppTreeMenus(parentId int64, menuList []modelAppPlatform.Appmenus) (menusTr menuCont.Sort = v.Sort // 排序"` menuCont.State = v.State menuCont.IsMain = v.IsMain + menuCont.Icon = gainMenuIcon(v.Id) menuCont.Children = AppTreeMenus(v.Id, menuList) menusTree = append(menusTree, menuCont) } @@ -236,6 +237,20 @@ func AppTreeMenus(parentId int64, menuList []modelAppPlatform.Appmenus) (menusTr return } +/* +* +@ 作者: 秦东 +@ 时间: 2025-02-26 11:22:18 +@ 功能: 获取上传的图片 +*/ +func gainMenuIcon(id int64) (img string) { + fmt.Printf("获取上传的图片--->%v\n\n\n", id) + var custForm modelAppPlatform.CustomerForm + custForm.GetCont(map[string]interface{}{"`signCode`": id}, "`icon`") + img = custForm.Icon + return +} + /* * @ 作者: 秦东 @@ -317,6 +332,7 @@ func GainAppMenuTree(key int64) (menusTree []AppMenuTree) { if err != nil { return } + sort.Slice(menuList, func(i, j int) bool { return menuList[i].EditTime < menuList[j].EditTime }) @@ -1596,6 +1612,7 @@ func (a *ApiMethod) PreviewAppFormVersion(c *gin.Context) { if err == nil { for _, v := range sunTable { sonFieldAry, sunErr := customerform.ReadDatabaseForm(v) + appFormSersion.TableStructureMap = append(appFormSersion.TableStructureMap, v) if sunErr == nil { for _, v := range sonFieldAry { if !publicmethod.IsInTrue[string](v.Field, appFormSersion.FormField) { @@ -2196,3 +2213,236 @@ func (a *ApiMethod) EditAppMenusIcon(c *gin.Context) { publicmethod.Result(0, err, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-18 09:05:47 +@ 功能: 获取分组App菜单 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainAppGroupMenus(c *gin.Context) { + var appGroupList []modelAppPlatform.CustomerFormGroup + overall.CONSTANT_DB_AppPlatform.Where("`state` = 1").Order("`sort` DESC").Order("`id` ASC").Find(&appGroupList) + + var appList GroupAppList + var sendList []interface{} + if len(appGroupList) > 0 { + + for _, v := range appGroupList { + syncSeting.Add(1) + go appList.GroupAppList(v.Id) + } + syncSeting.Wait() + if len(appList.List) > 0 { + for _, v := range appList.List { + syncSeting.Add(1) + appKey, _ := strconv.ParseInt(v.Id, 10, 64) + var appMenu AppMenuTree + appMenu.Id = v.Id //id"` + appMenu.Label = v.Name //label"` + appMenu.Types = 3 //type"` + appMenu.Svg = "" //svg" ` + appMenu.PcIsShow = 1 //pcIsShow"` + appMenu.WapIsShow = 1 //wapIsShow"` + appMenu.Parent = v.GroupId //parent"` + appMenu.Appkey = v.GroupId //appkey"` + appMenu.IsLock = 2 //isLock"` + appMenu.Sort = 1 //sort"` + appMenu.State = 1 //state"` + appMenu.IsMain = 1 //isMain"` + appMenu.Icon = "" //icon"` + appMenu.Children = GainAppTree(appKey) //children"` + sendList = append(sendList, appMenu) + } + syncSeting.Wait() + } + + } + // syncSeting.Add(1) + // sendInfo["menuTree"] = GainAppMenuTree(appCont.SignCode) + syncSeting.Wait() + publicmethod.Result(0, sendList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-18 13:38:30 +@ 功能: 获取分组下得App列表 +*/ +func (g *GroupAppList) GroupAppList(id int64) { + defer syncSeting.Done() + if id == 0 { + return + } else { + var formList []modelAppPlatform.CustomerForm + overall.CONSTANT_DB_AppPlatform.Where("`states` = 1 AND `classify` = 3 AND `groupid` = ?", id).Find(&formList) + if len(formList) > 0 { + for _, v := range formList { + var formApp TransferMenu + formApp.Id = strconv.FormatInt(v.SignCode, 10) + formApp.Name = v.Name + formApp.GroupId = strconv.FormatInt(id, 10) + g.List = append(g.List, formApp) + } + } + } + +} + +func GainAppTree(key int64) (menusTree []AppMenuTree) { + defer syncSeting.Done() + if key == 0 { + return + } + var menuList []modelAppPlatform.Appmenus + err := overall.CONSTANT_DB_AppPlatform.Where("`state` = 1 AND `isLock` = 2 AND `appkey` = ?", key).Find(&menuList).Error + if err != nil { + return + } + + sort.Slice(menuList, func(i, j int) bool { + return menuList[i].EditTime < menuList[j].EditTime + }) + sort.Slice(menuList, func(i, j int) bool { + return menuList[i].Sort < menuList[j].Sort + }) + menusTree = AppTreeMenus(key, menuList) + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-19 07:56:31 +@ 功能: 移动栏目 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) MoveAppMenus(c *gin.Context) { + var requestData MoveAppMenusId + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.MenuId == "" || requestData.OldMenuId == "" { + publicmethod.Result(102, err, c) + return + } + var newAppkey int64 + var oldAppkey int64 + //Step 1:获取愿菜单基本信息 + var oldAppMenus modelAppPlatform.Appmenus + err = oldAppMenus.GetCont(map[string]interface{}{"`id`": requestData.OldMenuId}) + if err != nil { + publicmethod.Result(1, err, c, "数据错误!请重新操作!") + return + } + oldAppkey = oldAppMenus.Appkey + //Step 2:获取旧菜单是否有子菜单 + var sunAppId AppSunMenus + sunAppId.HaveMenuSun(oldAppMenus.Id) + + var newFormInfo modelAppPlatform.CustomerForm + err = newFormInfo.GetCont(map[string]interface{}{"`signCode`": requestData.MenuId}) + //修改主应用表 + var mastMenuEdit modelAppPlatform.CustomerForm + editMenuInfo := publicmethod.MapOut[string]() + editMenuInfo["groupid"] = newFormInfo.Groupid + editMenuInfo["edit_time"] = time.Now().Unix() + err = mastMenuEdit.EiteCont(map[string]interface{}{"`signCode`": requestData.OldMenuId}, editMenuInfo) + if err != nil { + publicmethod.Result(1, err, c, "数据错误!请重新操作!") + return + } + sunEditMenu := publicmethod.MapOut[string]() + + //修改主菜单信息 + var mastAppMenuEdit modelAppPlatform.Appmenus + editAppMenuInfo := publicmethod.MapOut[string]() + editAppMenuInfo["edit_time"] = time.Now().Unix() + editAppMenuInfo["parent"] = requestData.MenuId + if newFormInfo.Classify != 3 { + var newParentMenu modelAppPlatform.Appmenus + newParentMenu.GetCont(map[string]interface{}{"`id`": requestData.MenuId}) + editAppMenuInfo["appkey"] = newParentMenu.Appkey + sunEditMenu["appkey"] = newParentMenu.Appkey + newAppkey = newParentMenu.Appkey + } else { + editAppMenuInfo["appkey"] = newFormInfo.SignCode + sunEditMenu["appkey"] = newFormInfo.SignCode + newAppkey = newFormInfo.SignCode + } + err = mastAppMenuEdit.EiteCont(map[string]interface{}{"`id`": requestData.OldMenuId}, editAppMenuInfo) + if err != nil { + publicmethod.Result(1, err, c, "数据错误!请重新操作!") + return + } + if len(sunAppId.Key) > 0 { + overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Where("`signCode` IN ?", sunAppId.Key).Updates(editMenuInfo) + overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Appmenus{}).Where("`id` IN ?", sunAppId.Key).Updates(sunEditMenu) + } + + //目标App菜单重组 + var newAppMenuJson []AppMenuTree + syncSeting.Add(1) + newAppMenuJson = GainAppMenuTree(newAppkey) + syncSeting.Wait() + menuTreeJson, _ := json.Marshal(newAppMenuJson) + sunEditMenuJson := publicmethod.MapOut[string]() + sunEditMenuJson["listjson"] = string(menuTreeJson) + var newMoveFormInfo modelAppPlatform.CustomerForm + newMoveFormInfo.EiteCont(map[string]interface{}{"`signCode`": newAppkey}, sunEditMenuJson) + if newAppkey != oldAppkey { + var oldAppMenuJson []AppMenuTree + syncSeting.Add(1) + oldAppMenuJson = GainAppMenuTree(oldAppkey) + syncSeting.Wait() + menuTreeJsonOld, _ := json.Marshal(oldAppMenuJson) + sunoldEditMenuJson := publicmethod.MapOut[string]() + sunoldEditMenuJson["listjson"] = string(menuTreeJsonOld) + var newMoveFormInfo modelAppPlatform.CustomerForm + newMoveFormInfo.EiteCont(map[string]interface{}{"`signCode`": oldAppkey}, sunoldEditMenuJson) + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-19 08:19:48 +@ 功能: 递归获取子级菜单目录 +*/ +func (a *AppSunMenus) HaveMenuSun(prentId int64) { + if prentId != 0 { + var appMenus []modelAppPlatform.Appmenus + overall.CONSTANT_DB_AppPlatform.Where("`parent` = ?", prentId).Find(&appMenus) + if len(appMenus) > 0 { + for _, v := range appMenus { + a.Key = append(a.Key, v.Id) + a.HaveMenuSun(v.Id) + } + } + } +} diff --git a/api/version1/customerApp/runAppControll.go b/api/version1/customerApp/runAppControll.go index f7e791b..e33aab1 100644 --- a/api/version1/customerApp/runAppControll.go +++ b/api/version1/customerApp/runAppControll.go @@ -412,13 +412,14 @@ func (s *StatisTaskCount) GetTotalPAge(appk string, types int) { switch types { case 1: //待办事宜 gormDb = gormDb.Where("`status` = 3 AND FIND_IN_SET(?,`next_executor`)", s.userCont.Key) + case 2: //已办事宜 gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`participants`) AND NOT FIND_IN_SET(?,`next_executor`) AND `creater` <> ?", s.userCont.Key, s.userCont.Key, s.userCont.Key) case 5: //草稿箱 gormDb = gormDb.Where("`status` = 1 AND `creater` = ?", s.userCont.Key) gormDbEs = gormDbEs.Where("`status` = 1 AND `creater` = ?", s.userCont.Key) case 3: //抄送我的 - // gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`makeCopy`)", s.userCont.Key) + gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`makeCopy`)", s.userCont.Key) default: //我的请求 // gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", s.userCont.Key) gormDbEs = gormDbEs.Where("`status` IN (1,2,3,4) AND `creater` = ?", s.userCont.Key) diff --git a/api/version1/customerApp/type.go b/api/version1/customerApp/type.go index 56931a1..c0dbc7f 100644 --- a/api/version1/customerApp/type.go +++ b/api/version1/customerApp/type.go @@ -58,6 +58,7 @@ type AppMenuTree struct { Sort int64 `json:"sort"` State int `json:"state"` IsMain int `json:"isMain"` + Icon string `json:"icon"` Children []AppMenuTree `json:"children"` } @@ -124,10 +125,11 @@ type EditAppFormPageInfo struct { } type LookCustomerFormInfo struct { modelAppPlatform.CustomerFormView - States int `json:"states" gorm:"-"` - GroupKey string `json:"groupKey" gorm:"-"` - PermitList [][]int64 `json:"permit_list" gorm:"-"` - FormField []string `json:"formField" gorm:"-"` + States int `json:"states" gorm:"-"` + GroupKey string `json:"groupKey" gorm:"-"` + PermitList [][]int64 `json:"permit_list" gorm:"-"` + FormField []string `json:"formField" gorm:"-"` + TableStructureMap []string `json:"tableStructureMap" gorm:"-"` } // app基础设置参数 @@ -300,3 +302,24 @@ type TableFormDnsConfig struct { AppId string `json:"appid"` TableInfo } +type GroupAppList struct { + List []TransferMenu +} + +// 转移菜单目录 +type TransferMenu struct { + publicmethod.CommonId[string] + publicmethod.PublicName + GroupId string `json:"groupId"` +} + +// 转移App菜单目录 +type MoveAppMenusId struct { + MenuId string `json:"menuid"` + OldMenuId string `json:"oldmenuid"` +} + +// 获取菜单子级 +type AppSunMenus struct { + Key []int64 `json:"key"` +} diff --git a/api/version1/customerform/calendarData.go b/api/version1/customerform/calendarData.go new file mode 100644 index 0000000..cabb6bb --- /dev/null +++ b/api/version1/customerform/calendarData.go @@ -0,0 +1,178 @@ +package customerform + +import ( + "appPlatform/models/modelAppPlatform" + "appPlatform/models/modelshr" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-07 14:05:56 +@ 功能: 日历数据处理 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) CalendarDataList(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 + } + //Step1:获取搜索栏目的内容 + var listField []SearchButtonInfo + json.Unmarshal([]byte(requestData.Search.SearchData), &listField) + //Step2:获取当前操作人 + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) + //Step3:获取当前信息表单咨询 + 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 + } + //Step 4: 拆分出列表信息 + var listFieldsMap ListPageFields + json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) + //Step 5: 拆分出主表单信息 + var formJsonCont CustomerFormMaster + json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) + //Step 6:判断当前是否为正月展示 + if requestData.Types != 1 { + //非正月 + var listSynv CalendarList + for _, v := range requestData.TimeAry { + syncSeting.Add(1) + go listSynv.HaveEveryDayData(v, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson, formJsonCont) + } + 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.HaveEveryDayData(tv, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson, formJsonCont) + } + syncSeting.Wait() + sendMonthList = append(sendMonthList, TimeHaveAry(v, listSynv.List)) + } + publicmethod.Result(0, sendMonthList, c) + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-07 14:27:24 +@ 功能: 获取指定日期的数据 +@ 参数 + + #day 日历单个日期参数 + #tableName 要操作得数据表 + #userCont 当前操作人 + #Search 搜索条件 + #listField 自定义表单查询条件 + #viewCondition 视图设定 + #listJson 字段处理 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (c *CalendarList) HaveEveryDayData(day TimeAryInfo, tableName string, userCont modelshr.ManCont, Search FormPageListAttr, listField []SearchButtonInfo, viewCondition map[string]ViewInfo, listJson string, formJsonCont CustomerFormMaster) { + 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) //将查询条件转换成 + startTime, endTime := publicmethod.OenDayStartOrEndTime(day.Date, 1) + if class, isOk := viewCondition["date"]; isOk { //解析视图设定参数 + if class.Status { //当前参数启用 + 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) + fmt.Printf("语句1===》%v\n", 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) + fmt.Printf("语句2===》%v\n", 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) + fmt.Printf("语句3===》%v\n", whySql) + } else { + whySql := fmt.Sprintf("f.`creater_time` BETWEEN %v AND %v", startTime, endTime) + fmt.Printf("语句4===》%v\n", whySql) + gormDb = gormDb.Where(whySql) + } + } else { + whySql := fmt.Sprintf("f.`creater_time` BETWEEN %v AND %v", startTime, endTime) + gormDb = gormDb.Where(whySql) + } + } else { + whySql := fmt.Sprintf("f.`creater_time` BETWEEN %v AND %v", 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, formJsonCont) + } + + } + if err == nil { + inDate := publicmethod.MapOut[string]() + inDate[day.Date] = formList + c.List = append(c.List, inDate) + } +} diff --git a/api/version1/customerform/form.go b/api/version1/customerform/form.go index dbdf001..6b53c14 100644 --- a/api/version1/customerform/form.go +++ b/api/version1/customerform/form.go @@ -452,6 +452,7 @@ func (a *ApiMethod) LookCustomerForm(c *gin.Context) { if err == nil { for _, v := range sunTable { sonFieldAry, sunErr := ReadDatabaseForm(v) + sendCont.TableStructureMap = append(sendCont.TableStructureMap, v) if sunErr == nil { for _, v := range sonFieldAry { if !publicmethod.IsInTrue[string](v.Field, sendCont.FormField) { diff --git a/api/version1/customerform/formTable.go b/api/version1/customerform/formTable.go index aab4fa1..e2ad103 100644 --- a/api/version1/customerform/formTable.go +++ b/api/version1/customerform/formTable.go @@ -5,6 +5,7 @@ import ( "appPlatform/models/customerForm" "appPlatform/models/modelAppPlatform" "appPlatform/models/modelshr" + "appPlatform/models/modelssystempermission" "appPlatform/overall" "appPlatform/overall/publicmethod" "encoding/json" @@ -862,28 +863,56 @@ func (a *ApiMethod) GainFormTableField(c *gin.Context) { err = json.Unmarshal([]byte(customerFormMaster.TableStructure), &sunTable) if err == nil { sunTableMap := publicmethod.MapOut[string]() + sunTableNameMap := publicmethod.MapOut[string]() + var sunFormList []SunTableInfo for _, v := range sunTable { //遍历子表单名称 if vStr, ok := v.(string); ok { + var sunFormInfo SunTableInfo + sunFormInfo.FieldKey = vStr + sunFormInfo.Name = gainSunTableName(vStr, formJsonCont) sunField := GainSunFormTableField(vStr, formFieldAry.SunFormInfo) if len(sunField) > 0 { sunTableForm, formErr := GainFormTableField(vStr) if formErr == nil { - sunTableMap[vStr] = TableFieldCompare(sunTableForm, sunField) + fields := TableFieldCompare(sunTableForm, sunField) + sunTableMap[vStr] = fields + sunFormInfo.Fields = fields } else { - sunTableMap[vStr], _ = GainFormTableField(vStr) //获取表单字段 + fields, _ := GainFormTableField(vStr) + sunTableMap[vStr] = TableFieldCompare(fields, sunField) //获取表单字段 + sunFormInfo.Fields = TableFieldCompare(fields, sunField) } } else { - sunTableMap[vStr], _ = GainFormTableField(vStr) //获取表单字段 + sunTableForm, _ := GainFormTableField(vStr) + fields := TableFieldCompare(sunTableForm, sunField) + sunTableMap[vStr] = fields //获取表单字段 + sunFormInfo.Fields = fields } - + sunTableNameMap[vStr] = gainSunTableName(vStr, formJsonCont) + sunFormList = append(sunFormList, sunFormInfo) } } sendTableList["sunTable"] = sunTableMap + sendTableList["sunTableName"] = sunTableNameMap + sendTableList["sunFormList"] = sunFormList } } publicmethod.Result(0, sendTableList, c) } +// 获取子表单名称 +func gainSunTableName(tableKey string, formJsonCont CustomerFormMaster) (sunTableName string) { + if len(formJsonCont.List) > 0 { + for _, v := range formJsonCont.List { + if v.Type == "table" && v.Name == tableKey { + sunTableName = v.Item.Label + return + } + } + } + return +} + /* * @ 作者: 秦东 @@ -1352,6 +1381,10 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { var formJsonCont CustomerFormMaster json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) + + var sunMap map[string]string + json.Unmarshal([]byte(formInfo.TableStructure), &sunMap) + if formJsonCont.Form.DataSource == "yes" { var sqlDb datacenter.DataBastType sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType @@ -1384,15 +1417,16 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { publicmethod.Result(0, err, c) return } + var listFieldsMap ListPageFields // sqlDborm.Table(formJsonCont.Form.DataSourceConfig.TableKey).Find(&formList) // fmt.Printf("%T----------->%v----------->%v\n", formList, err, formList) if formInfo.ListJson != "" { - var listFieldsMap ListPageFields + err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) // fmt.Printf("%T----------->%v----------->%v\n", listFieldsMap, err, listFieldsMap) if err == nil { // fmt.Printf("%T----------->%v\n", listFieldsMap, listFieldsMap) - formList = listFieldsMap.DevelopSpecificationsSend(formList) + formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont) // formList = DevelopSpecificationsSend(formList, listFieldsMap) } @@ -1401,8 +1435,9 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { //获取任务状态 for i, v := range formList { formList[i]["isRetract"] = false + var masterKey int64 if mastrKeyVal, isOk := v["masters_key"]; isOk { - + masterKey, _ = publicmethod.StringToInt64(mastrKeyVal) if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok { formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10) } @@ -1455,6 +1490,9 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { // formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10) // } // } + for _, sv := range sunMap { + formList[i][sv] = gainMasterSunList(sv, masterKey, formJsonCont, sqlDborm) + } } // publicmethod.Result(100, formList, c) @@ -1492,13 +1530,14 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { // // formList[i]["flowIsOpen"] = formInfo.FlowIsOpen // formList[i]["flowkey"] = strconv.FormatInt(formInfo.Flowkey, 10) // } + var listFieldsMap ListPageFields if formInfo.ListJson != "" { - var listFieldsMap ListPageFields + err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) // fmt.Printf("%T----------->%v----------->%v\n", listFieldsMap, err, listFieldsMap) if err == nil { // fmt.Printf("%T----------->%v\n", listFieldsMap, listFieldsMap) - formList = listFieldsMap.DevelopSpecificationsSend(formList) + formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont) // formList = DevelopSpecificationsSend(formList, listFieldsMap) } @@ -1535,12 +1574,19 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { } } + var masterKey int64 if mastrKeyVal, ok := v["masters_key"]; ok { + masterKey, _ = publicmethod.StringToInt64(mastrKeyVal) // fmt.Printf("mastrKeyVal----------->%T----------->%v\n", mastrKeyVal, mastrKeyVal) if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok { + formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10) } } + fmt.Printf("mastrKeyVal----------->%T----------->%v\n", v["table_structure"], v["table_structure"]) + for _, sv := range sunMap { + formList[i][sv] = gainMasterSunList(sv, masterKey, formJsonCont, overall.CONSTANT_DB_CustomerForm) + } } // publicmethod.Result(100, formList, c) @@ -1548,13 +1594,286 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { } } +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-14 08:59:27 +@ 功能: 获取每条数据得子数据列表 +*/ +func gainMasterSunList(tableName string, masterKey int64, formJsonCont CustomerFormMaster, gormDbConfig *gorm.DB) (list []map[string]interface{}) { + // fmt.Printf(" 获取每条数据得子数据列表------->%v\n------->%v\n------->%v\n", tableName, masterKey, gormDbConfig) + gormDbConfig.Table(tableName).Where("`masters_key` = ? and `states` = 1", masterKey).Find(&list) + if len(list) > 0 { + var listFieldsMap ListPageFields + var sunTable MasterStruct + for _, v := range formJsonCont.List { + if v.Type == "table" && v.Name == tableName { + sunTable = v + } + } + list = listFieldsMap.SunTableForm(list, masterKey, sunTable) + } + + // fmt.Printf(" 获取每条数据得子数据列表------->%v\n------->%v\n------->%v\n", err, err, err) + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-14 11:20:00 +@ 功能: 数值结果类型转换 +*/ +func (l *ListPageFields) SunTableForm(listData []map[string]interface{}, masterKey int64, sunTable MasterStruct) []map[string]interface{} { + var sendList []map[string]interface{} + for _, v := range listData { + sendInfo := publicmethod.MapOut[string]() + for mi, mv := range v { + switch mi { + case "creater": + mvInt, _ := publicmethod.StringToInt64(mv) + if mvInt != 0 { + var myInfo modelshr.PersonArchives + myInfo.GetCont(map[string]interface{}{"`key`": mvInt}, "`name`") + sendInfo[mi] = myInfo.Name + } + + case "creater_time": + timeInt, _ := publicmethod.StringToInt64(mv) + sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + case "edit_time": + timeInt, _ := publicmethod.StringToInt64(mv) + sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + default: + sendInfo[mi] = l.BaseSunTableAttrField(mi, mv, sunTable) + // sendInfo[mi] = publicmethod.TypeToInterface(mv) + } + for _, lv := range l.TableData.Columns { + if lv.FieldClass != "-" && lv.FieldClass != "_lableTitle" && lv.FieldClass != "__control" { + if lv.Id == mi { + switch lv.FieldClass { + case "radio": + for _, ov := range lv.Options { + + radioId := publicmethod.TypeToInterface(mv) + if radioId == ov.Value { + sendInfo[mi] = ov.Label + } + } + case "datePicker": + var beginTime string + timeVal, _ := publicmethod.StringToInt64(mv) + + switch lv.Auxiliary { + case "year": + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 16) + case "month": + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 15) + case "datetime": + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 11) + case "week": + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 41) + case "datetimerange": + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 11) + sendInfo[mi] = beginTime + case "daterange": + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) + sendInfo[mi] = beginTime + case "monthrange": + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 15) + sendInfo[mi] = beginTime + default: + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) + sendInfo[mi] = beginTime + } + case "timePicker": + timeVal, _ := publicmethod.StringToInt64(mv) + if timeVal != 0 { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 5) + } else { + sendInfo[mi] = "" + } + case "deptOrg": + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": mv}, "`name`") + sendInfo[mi] = orgCont.Name + case "owner": + var userInfo modelshr.PersonArchives + userInfo.GetCont(map[string]interface{}{"`key`": mv}, "`name`", "`number`") + sendInfo[mi] = fmt.Sprintf("%v(%v)", userInfo.Name, userInfo.Number) + case "expand-user": + var userAry []string + jsonStr := publicmethod.TypeToInterface(mv) + json.Unmarshal([]byte(jsonStr), &userAry) + sendInfo[mi] = strings.Join(userAry, " , ") + case "select": + var sendInfp []string + if mv != nil { + fmt.Printf("Step1:\n") + valStr := publicmethod.TypeToInterface(mv) + var valAry []int64 + json.Unmarshal([]byte(valStr), &valAry) + if len(valAry) > 0 { + for _, vv := range valAry { + for _, v := range lv.Options { + vvStr := strconv.FormatInt(vv, 10) + if v.Value == vvStr { + fmt.Printf("Step2:\n") + sendInfp = append(sendInfp, v.Label) + } + } + } + + } else { + fmt.Printf("Step3:\n") + for _, v := range lv.Options { + if v.Value == valStr { + fmt.Printf("Step4:\n") + sendInfp = append(sendInfp, v.Label) + } + } + } + sendInfo[mi] = strings.Join(sendInfp, " , ") + + } + default: + } + } + } + } + } + sendList = append(sendList, sendInfo) + } + return sendList +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-14 11:23:55 +@ 功能: 根据字段显示格式处理数据 +*/ +func (l *ListPageFields) BaseSunTableAttrField(key string, val interface{}, sunTable MasterStruct) interface{} { + if len(l.TableData.Columns) < 0 { + return val + } + for _, v := range l.TableData.Columns { + if v.Id == key { + fmt.Printf("组件类型---->\n\n%v\n\n", v.FieldClass) + 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 { + intVal, _ := publicmethod.StringToInt64(ov.Value) + intValStr := strconv.FormatInt(intVal, 10) + if publicmethod.IsInTrue[string](intValStr, 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 orgCont.Name + case "baidumap": + var mapAry []string + if valStr, ok := val.(string); ok { + mapAry = strings.Split(valStr, "|*@*|") + } + if len(mapAry) > 0 { + return mapAry[0] + } + case "treeSelect": + // jsonStr, _ := json.Marshal(v) + // fmt.Printf("树形菜单结构----》\n%v\n", string(jsonStr)) + // formJsonCont.GetUnitVal(v.Id) + hjakshdk := GetSunUnitVal(v.Id, val, sunTable) + // fmt.Printf("树形菜单结构----》\n%v\n", hjakshdk) + return hjakshdk + case "pickrole": + return 112 + case "pickpost": + return 250 + case "select": + var sendInfp []string + if val != nil { + + valStr := publicmethod.TypeToInterface(val) + var valAry []int64 + json.Unmarshal([]byte(valStr), &valAry) + if len(valAry) > 0 { + for _, vv := range valAry { + for _, v := range v.Options { + vvStr := strconv.FormatInt(vv, 10) + if v.Value == vvStr { + + sendInfp = append(sendInfp, v.Label) + } + } + } + + } else { + + for _, v := range v.Options { + if v.Value == valStr { + + sendInfp = append(sendInfp, v.Label) + } + } + } + selectVal := strings.Join(sendInfp, " , ") + + return selectVal + } + + default: + return publicmethod.TypeToInterface(val) + } + } + } + return publicmethod.TypeToInterface(val) +} + +func GetSunUnitVal(key string, val interface{}, formJsonCont MasterStruct) (rutVal string) { + + if len(formJsonCont.List) > 0 { + for _, v := range formJsonCont.List { + if v.Name == key { + if datList, isOk := v.Control.Data.([]interface{}); isOk { + + rutVal = diGuiShu(val, datList) + // fmt.Printf("已经是结果了:%v\n", rutVal) + } + + } + } + } + return + +} + /* * @ 作者: 秦东 @ 时间: 2024-04-02 08:14:10 @ 功能: 按照制定列表字段输出 */ -func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interface{}) []map[string]interface{} { +func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interface{}, formJsonCont CustomerFormMaster) []map[string]interface{} { var sendList []map[string]interface{} for _, v := range listData { sendInfo := publicmethod.MapOut[string]() @@ -1575,14 +1894,38 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa case "edit_time": timeInt, _ := publicmethod.StringToInt64(mv) sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + case "states": + mvInt, _ := publicmethod.StringToInt64(mv) + switch mvInt { + case 1: + sendInfo[mi] = "启用" + case 2: + sendInfo[mi] = "禁用" + case 3: + sendInfo[mi] = "删除" + default: + sendInfo[mi] = "未知" + } + case "flowIsOpen": + mvInt, _ := publicmethod.StringToInt64(mv) + switch mvInt { + case 1: + sendInfo[mi] = "开启" + case 2: + sendInfo[mi] = "关闭" + case 3: + sendInfo[mi] = "删除" + default: + sendInfo[mi] = "未知" + } default: - sendInfo[mi] = l.BaseTableAttrField(mi, mv) + sendInfo[mi] = l.BaseTableAttrField(mi, mv, formJsonCont) // sendInfo[mi] = publicmethod.TypeToInterface(mv) } for _, lv := range l.TableData.Columns { if lv.FieldClass != "-" && lv.FieldClass != "_lableTitle" && lv.FieldClass != "__control" { if lv.Id == mi { - + // fmt.Printf("%T = %v\n", lv.FieldClass, lv.FieldClass) switch lv.FieldClass { case "radio": for _, ov := range lv.Options { @@ -1729,10 +2072,14 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa @ 时间: 2024-04-02 11:42:20 @ 功能: 根据字段显示格式处理数据 */ -func (l *ListPageFields) BaseTableAttrField(key string, val interface{}) interface{} { +func (l *ListPageFields) BaseTableAttrField(key string, val interface{}, formJsonCont CustomerFormMaster) interface{} { if len(l.TableData.Columns) < 0 { return val } + + // jsonStrl, _ := json.Marshal(formJsonCont) + // fmt.Printf("树形菜单结构--1--》\n\n\n\n%v\n\n\n\n", string(jsonStrl)) + for _, v := range l.TableData.Columns { if v.Id == key { switch v.FieldClass { @@ -1773,6 +2120,13 @@ func (l *ListPageFields) BaseTableAttrField(key string, val interface{}) interfa if len(mapAry) > 0 { return mapAry[0] } + case "treeSelect": + // jsonStr, _ := json.Marshal(v) + // fmt.Printf("树形菜单结构----》\n%v\n", string(jsonStr)) + // formJsonCont.GetUnitVal(v.Id) + hjakshdk := GetUnitVal(v.Id, val, formJsonCont) + // fmt.Printf("树形菜单结构----》\n%v\n", hjakshdk) + return hjakshdk case "select": var sendInfp []string if val != nil { @@ -1804,7 +2158,34 @@ func (l *ListPageFields) BaseTableAttrField(key string, val interface{}) interfa return selectVal } + case "pickrole": + valInt := publicmethod.TypeToInterface(val) + if valInt != "" && valInt != "0" { + var roleMode modelssystempermission.SystemRole + roleMode.GetCont(map[string]interface{}{"`id`": val}) + return roleMode.Name + } else { + return val + } + case "pickpost": + valString := publicmethod.TypeToInterface(val) + if valString != "" { + mapAry := strings.Split(valString, "#@#") + if len(mapAry) >= 2 { + var orgInfo modelshr.AdministrativeOrganization + orgInfo.GetCont(map[string]interface{}{"`id`": mapAry[0]}, "`name`") + var postInfo modelshr.Position + postInfo.GetCont(map[string]interface{}{"`id`": mapAry[len(mapAry)-1]}, "`name`") + return fmt.Sprintf("%v - %v", orgInfo.Name, postInfo.Name) + } else if len(mapAry) == 1 { + var orgInfo modelshr.AdministrativeOrganization + orgInfo.GetCont(map[string]interface{}{"`id`": mapAry[0]}, "`name`") + return orgInfo.Name + } + } else { + return val + } default: return publicmethod.TypeToInterface(val) } @@ -1813,6 +2194,62 @@ func (l *ListPageFields) BaseTableAttrField(key string, val interface{}) interfa return publicmethod.TypeToInterface(val) } +func GetUnitVal(key string, val interface{}, formJsonCont CustomerFormMaster) (rutVal string) { + + if len(formJsonCont.List) > 0 { + for _, v := range formJsonCont.List { + if v.Name == key { + if datList, isOk := v.Control.Data.([]interface{}); isOk { + + rutVal = diGuiShu(val, datList) + // fmt.Printf("已经是结果了:%v\n", rutVal) + } + + } + } + } + return + +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-02-28 15:43:27 +@ 功能: 递归查值 +*/ +func diGuiShu(key interface{}, val []interface{}) string { + jieguo := "" + + for _, v := range val { + + if mapVal, isOk := v.(map[string]interface{}); isOk { + // fmt.Printf("结果是---111-->%v---111-->%v---111-->%v\n", mapVal["value"], key, publicmethod.TypeToInterface(mapVal["value"]) == publicmethod.TypeToInterface(key)) + publicmethod.TypeToInterface(mapVal["value"]) + if publicmethod.TypeToInterface(mapVal["value"]) == publicmethod.TypeToInterface(key) { + // fmt.Printf("结果是---label-->%v\n", publicmethod.TypeToInterface(mapVal["label"])) + jieguo = publicmethod.TypeToInterface(mapVal["label"]) + // return jieguo + } else { + if childVal, isok := mapVal["children"]; isok { + // fmt.Printf("\n\n组件清苦--->>%T------>%v\n\n", childVal, childVal) + if vhiList, ok := childVal.([]interface{}); ok { + jieguo = diGuiShu(key, vhiList) + + } + } + } + } + if jieguo != "" { + return jieguo + } + } + + // fmt.Printf("结果是-1--label--1>%v\n", jieguo) + return jieguo + +} + /* * @ 作者: 秦东 @@ -2150,10 +2587,10 @@ func (a *ApiMethod) GainTableVersionField(c *gin.Context) { if len(formFieldAry.MasterInfo) > 0 { sendTableList["masterTable"] = TableFieldCompareForm(masterTable, formFieldAry.MasterInfo) } else { - sendTableList["masterTablesss"] = masterTable + sendTableList["masterTable"] = masterTable } } else { - sendTableList["masterTablesss"] = masterTable + sendTableList["masterTable"] = masterTable } if version.TableStructure != "" { var sunTable map[string]interface{} diff --git a/api/version1/customerform/formTableView.go b/api/version1/customerform/formTableView.go index bbf8cd0..2c9b794 100644 --- a/api/version1/customerform/formTableView.go +++ b/api/version1/customerform/formTableView.go @@ -215,9 +215,13 @@ func (a *ApiMethod) MultiViewPAge(c *gin.Context) { if formInfo.ListJson != "" { var listFieldsMap ListPageFields err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) + var formJsonCont CustomerFormMaster + if formInfo.MastesFormJson != "" { + json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) + } // fmt.Printf("列表数据解析---->%v\n", err) if err == nil { - lik, formListAry, dayAry := listFieldsMap.TimeViewWordHandle(formList, requestData.ViewClass) + lik, formListAry, dayAry := listFieldsMap.TimeViewWordHandle(formList, requestData.ViewClass, formJsonCont) // timeAry := publicmethod.MapOut[string]() sendListInfo["listInfo"] = formListAry sendListInfo["dayList"] = dayAry @@ -254,7 +258,7 @@ func (a *ApiMethod) MultiViewPAge(c *gin.Context) { # */ -func (l *ListPageFields) TimeViewWordHandle(listData []map[string]interface{}, viewCalss ViewKeyType) ([]TimeFenGe, []map[string]interface{}, []string) { +func (l *ListPageFields) TimeViewWordHandle(listData []map[string]interface{}, viewCalss ViewKeyType, formJsonCont CustomerFormMaster) ([]TimeFenGe, []map[string]interface{}, []string) { // fmt.Printf("TimeViewWordHandle:%v------------>%v\n", len(listData), listData) @@ -309,7 +313,7 @@ func (l *ListPageFields) TimeViewWordHandle(listData []map[string]interface{}, v case "map": default: - sendList = l.DevelopSpecificationsSend(listData) + sendList = l.DevelopSpecificationsSend(listData, formJsonCont) } // fmt.Printf("获取起止时间--->%v---->%v\n", len(lik), lik) return lik, sendList, dayAry @@ -743,12 +747,15 @@ func (a *ApiMethod) GainCalendarList(c *gin.Context) { } var listFieldsMap ListPageFields json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) - + var formJsonCont CustomerFormMaster + if formInfo.MastesFormJson != "" { + json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) + } 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) + go listSynv.GetDayCont(v, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson, formJsonCont) } syncSeting.Wait() sendListArt := TimeHaveAry(requestData.TimeAry, listSynv.List) @@ -767,7 +774,7 @@ func (a *ApiMethod) GainCalendarList(c *gin.Context) { var listSynv CalendarList for _, tv := range v { syncSeting.Add(1) - go listSynv.GetDayCont(tv, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson) + go listSynv.GetDayCont(tv, formInfo.TableKey, userCont, requestData.Search, listField, listFieldsMap.View, formInfo.ListJson, formJsonCont) } syncSeting.Wait() // sendListArt := TimeHaveAry(v, listSynv.List) @@ -835,7 +842,7 @@ func TimeHaveAry(dateList []TimeAryInfo, listDate []map[string]interface{}) []Ti # */ -func (c *CalendarList) GetDayCont(day TimeAryInfo, tableName string, userCont modelshr.ManCont, Search FormPageListAttr, listField []SearchButtonInfo, viewCondition map[string]ViewInfo, listJson string) { +func (c *CalendarList) GetDayCont(day TimeAryInfo, tableName string, userCont modelshr.ManCont, Search FormPageListAttr, listField []SearchButtonInfo, viewCondition map[string]ViewInfo, listJson string, formJsonCont CustomerFormMaster) { defer syncSeting.Done() tableName = fmt.Sprintf("`%v` as f", tableName) @@ -886,7 +893,7 @@ func (c *CalendarList) GetDayCont(day TimeAryInfo, tableName string, userCont mo var listFieldsMap ListPageFields err = json.Unmarshal([]byte(listJson), &listFieldsMap) if err == nil { - formList = listFieldsMap.DevelopSpecificationsSend(formList) + formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont) } } @@ -993,6 +1000,10 @@ func (a *ApiMethod) GainFormPageMapCont(c *gin.Context) { if formInfo.ListJson != "" { json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) } + var formJsonCont CustomerFormMaster + if formInfo.MastesFormJson != "" { + json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) + } // why, err := AnalysisSerachTerm(requestData.SearchData) // fmt.Printf("why---->%v\n", why) var formList []map[string]interface{} @@ -1048,7 +1059,7 @@ func (a *ApiMethod) GainFormPageMapCont(c *gin.Context) { // fmt.Printf("%T----------->%v----------->%v\n", listFieldsMaps, err, listFieldsMaps) if err == nil { // fmt.Printf("%T----------->%v\n", listFieldsMaps, listFieldsMaps) - formList = listFieldsMaps.DevelopSpecificationsSend(formList) + formList = listFieldsMaps.DevelopSpecificationsSend(formList, formJsonCont) // formList = DevelopSpecificationsSend(formList, listFieldsMap) } diff --git a/api/version1/customerform/type.go b/api/version1/customerform/type.go index 0c05cfa..f3c205c 100644 --- a/api/version1/customerform/type.go +++ b/api/version1/customerform/type.go @@ -117,7 +117,7 @@ type ControlStruct struct { Max int `json:"max"` // ColorFormat string `json:"colorFormat"` // FormAt string `json:"format"` // - Data []string `json:"data"` // + Data interface{} `json:"data"` // RenderAfterExpand bool `json:"renderAfterExpand"` // Multiple bool `json:"multiple"` // Action string `json:"action"` // @@ -282,10 +282,11 @@ type EditCustomerFormStatus struct { // 输出查看详情信息 type LookCustomerFormInfo struct { modelAppPlatform.CustomerFormView - States int `json:"states"` - GroupKey string `json:"groupKey"` - PermitList [][]int64 `json:"permit_list"` - FormField []string `json:"formField"` + States int `json:"states"` + GroupKey string `json:"groupKey"` + PermitList [][]int64 `json:"permit_list"` + FormField []string `json:"formField"` + TableStructureMap []string `json:"tableStructureMap"` } // 接收自定义表单设置数据 @@ -581,3 +582,10 @@ type TimeAryInfo struct { type CalendarList struct { List []map[string]interface{} } + +// 子表列表 +type SunTableInfo struct { + publicmethod.PublicName //名称 + FieldKey string `json:"fieldKey"` //标识 + Fields interface{} `json:"fields"` //字段 +} diff --git a/api/version1/publicapi/api.go b/api/version1/publicapi/api.go index 4e325c1..b6079cd 100644 --- a/api/version1/publicapi/api.go +++ b/api/version1/publicapi/api.go @@ -385,8 +385,8 @@ func (a *ApiMethod) GainNumber(c *gin.Context) { */ func (g *GainRulsNumner) GainUniqueNumber(uuid string) string { var uuidAry []string - // fmt.Printf("获取唯一编号%v\n", g) - // fmt.Printf("uuidAry---->%v\n", uuid) + fmt.Printf("获取唯一编号%v\n", g) + fmt.Printf("uuidAry---->%v\n", uuid) if len(g.CustomRules) > 0 { for _, v := range g.CustomRules { switch v.Types { @@ -469,8 +469,10 @@ func (g *GainRulsNumner) GainUniqueNumber(uuid string) string { redisClient.Rpush(redisKey, uuid) return uuid } + } else { + g.GainUniqueNumber(uuid) } - g.GainUniqueNumber(uuid) + // } return uuid diff --git a/api/version1/taskplatform/taskflow/types.go b/api/version1/taskplatform/taskflow/types.go index d2f3340..d7a833c 100644 --- a/api/version1/taskplatform/taskflow/types.go +++ b/api/version1/taskplatform/taskflow/types.go @@ -364,3 +364,21 @@ type SendTaskInfo struct { RunFlowIdStr string `json:"runFlowIdStr" gorm:"-"` States int `json:"statesing" gorm:"-"` } + +// 发送范围表单字段选择 +type SendRangField struct { + Lable string `json:"lable"` //名称 + Fields string `json:"fields"` //字段 + Types string `json:"types"` //字段类型 + MultipleChoice bool `json:"multipleChoice"` //值多选 +} + +type SendWorkMsgRangField struct { + Id string `json:"id"` //ID + Number string `json:"number"` //编号 + Name string `json:"name"` //名称 + Icon string `json:"icon"` //头像 + IsPick bool `json:"isPick"` //是否选中 + Types string `json:"types"` //类型 + MultipleChoice bool `json:"multipleChoice"` //值多选 +} diff --git a/api/version1/taskplatform/taskflow/workflow.go b/api/version1/taskplatform/taskflow/workflow.go index 6584f58..240d08c 100644 --- a/api/version1/taskplatform/taskflow/workflow.go +++ b/api/version1/taskplatform/taskflow/workflow.go @@ -151,6 +151,7 @@ func (a *ApiMethod) GainNodeFactor(c *gin.Context) { } } for _, v := range masterUnit { + fmt.Printf("组件类型---->%v\n", v.Type) var sendCont SendFormNodeFactor if requestData.Types == 1 && publicmethod.IsInTrue[string](v.Type, []string{"expand-user"}) { sendCont.Id = v.Name @@ -838,3 +839,122 @@ func (a *ApiMethod) SetFlowFormKeyPower(c *gin.Context) { } publicmethod.Result(0, requestData, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-25 16:26:37 +@ 功能: 获取行政组织几人员相关控件信息 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainOrgOfPeopleNodeFactor(c *gin.Context) { + var requestData publicmethod.CommonId[string] + err := c.ShouldBindJSON(&requestData) + if err != nil || requestData.Id == "" { + publicmethod.Result(100, err, c) + return + } + var customerFormCont modelAppPlatform.CustomerForm + err = customerFormCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`tablename`") + if err != nil { + publicmethod.Result(106, err, c) + return + } + var customerFormVersionCont modelAppPlatform.CustomerFormVersion + err = customerFormVersionCont.GetCont(map[string]interface{}{"`tablekey`": customerFormCont.TableNames, "`status`": 1}, "`mastesformjson`") + if err != nil { + publicmethod.Result(106, err, c) + return + } + var sendList []SendRangField + var sendMapList []SendWorkMsgRangField + if customerFormVersionCont.MastesFormJson != "" { + var formJsonCont customerform.CustomerFormMaster + json.Unmarshal([]byte(customerFormVersionCont.MastesFormJson), &formJsonCont) + var unitList CustomerFormUnit + unitList.GetFormUnit(formJsonCont.Form.Name, formJsonCont.List, true) + + sendData := publicmethod.MapOut[string]() + // master, sunTable, jsonerr := taskmanagement.GainFormStruct(customerFormVersionCont.MastesFormJson) + // if jsonerr != nil { + // publicmethod.Result(104, err, c) + // return + // } + if len(unitList.MasterInfo) > 0 { + var masterUnit []customerform.MasterStruct + for _, v := range unitList.MasterInfo { + if v.IsMaster { + masterUnit = v.Info + } + } + for _, v := range masterUnit { + isWrite := true + jsonVal, _ := json.Marshal(v) + fmt.Printf("组件类型---->%v\n", string(jsonVal)) + var sendCont SendRangField + sendCont.Lable = v.Item.Label + sendCont.Fields = v.Name + sendCont.Types = v.Type + + var sendMapCont SendWorkMsgRangField + sendMapCont.Id = v.Name + sendMapCont.Name = v.Item.Label + sendMapCont.Types = v.Type + switch v.Type { + case "pickrole": //角色选择 + sendMapCont.MultipleChoice = false + sendCont.MultipleChoice = false + isWrite = true + case "pickpost": //岗位选择 + sendMapCont.MultipleChoice = false + sendCont.MultipleChoice = false + isWrite = true + case "deptOrg": //所属部门 + sendMapCont.MultipleChoice = false + sendCont.MultipleChoice = false + isWrite = true + case "owner": //拥有者 + sendMapCont.MultipleChoice = false + sendCont.MultipleChoice = false + isWrite = true + case "founder": //创建人 + sendMapCont.MultipleChoice = false + sendCont.MultipleChoice = false + isWrite = true + case "orgCentent": //角色选择组织选择 + sendMapCont.MultipleChoice = false + sendCont.MultipleChoice = false + isWrite = true + case "expand-user": //角色选择组织选择 + sendMapCont.MultipleChoice = true + sendCont.MultipleChoice = true + isWrite = true + default: + isWrite = false + } + if isWrite { + sendList = append(sendList, sendCont) + sendMapList = append(sendMapList, sendMapCont) + } + + } + } + // sendData["master"] = master + // sendData["sunTable"] = sunTable + sendData["sendList"] = sendList + sendData["unitList"] = unitList + sendData["sendMapList"] = sendMapList + publicmethod.Result(0, sendMapList, c) + } + // publicmethod.Result(0, sendList, c) +} diff --git a/api/version1/taskplatform/taskmanagement/formcontrol.go b/api/version1/taskplatform/taskmanagement/formcontrol.go index 1b15ab9..0ae2d9e 100644 --- a/api/version1/taskplatform/taskmanagement/formcontrol.go +++ b/api/version1/taskplatform/taskmanagement/formcontrol.go @@ -3,6 +3,7 @@ package taskmanagement import ( "appPlatform/api/version1/customerform" datacenter "appPlatform/api/version1/dataCenter" + "appPlatform/api/version1/workWechat" "appPlatform/models/customerForm" "appPlatform/models/modelAppPlatform" "appPlatform/models/modelshr" @@ -11,6 +12,7 @@ import ( "encoding/json" "errors" "fmt" + "regexp" "strconv" "strings" "time" @@ -653,13 +655,13 @@ func MakeFormMapData(uuid, userKey, cureeTime int64, fieldVal map[string]interfa keyAndVal["creater"] = userKey keyAndVal["edit_time"] = cureeTime for k, v := range fieldVal { - // fmt.Printf("写入字段:%v->%v\n", k, v) + fmt.Printf("写入字段:%v->%v\n", k, v) if k == "id" { keyAndVal[k] = v } if v != "" { if val, isOk := subUnit[k]; isOk { - // fmt.Printf("写入字段:%v->%v\n", k, val) + fmt.Printf("写入字段--->:%v->%v\n", k, val) fielfInfoClass := customerform.AnalysisFormUnitClass(val) switch fielfInfoClass.FieldType { case "int": @@ -961,16 +963,367 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { sendData["cureeTime"] = cureeTime sendData["formUnitCont"] = formUnitCont sendData["masterField"] = masterField + sendData["masterUnitList"] = masterUnitList sendData["sunFieldAry"] = sunFieldAry sendData["sunFieldAry_len"] = len(sunFieldAry) sendData["masrWriteMap"] = masrWriteMap sendData["sunFormName"] = sunFormName sendData["mapData"] = mapData + //判断是否要发送信息 + if formCont.ListJson != "" { + var sendMsgInterface FormListInfo + json.Unmarshal([]byte(formCont.ListJson), &sendMsgInterface) + + var sendMsgInfo SendMsgInfo + sendMsgInfo.SendMsg(sendMsgInterface.SendMsg, userCont, taskCont.Title, cureeTime, masterField, masterUnitList) + + // sendConfig := sendMsgInterface.SendMsg + // if sendConfig.Open { + // msgTitle := taskCont.Title + // if len(sendConfig.Title) > 0 { + + // } + // sendData["msgTitle"] = msgTitle + // switch sendConfig.SendRange { + // } + // } + } publicmethod.Result(0, sendData, c) } +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-28 09:17:29 +@ 功能: 发送企业微信消息 +@ 参数 + + #sendConfig //发送消息配置信息 + #msgTitle //消息标题 + #cureeTime //创建时间 + #fieldVal //提交得数据已表字段 + #subUnit //表单组件属性 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (s *SendMsgInfo) SendMsg(sendConfig SendMsgInfo, userCont modelshr.ManCont, msgTitle string, cureeTime int64, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct) bool { + if sendConfig.Open { //开启发送信息 + var sendMsg workWechat.SendMessage + sendUserCount := 0 + var sendUserAll []string + isSend := true + //Step 1: 获取消息的发送范围 + switch sendConfig.SendRange { + case 1: //全集团 + sendMsg.Touser = "@all" + case 2: //本公司 + var myCompany modelshr.AdministrativeOrganization + myCompany.GetCont(map[string]interface{}{"id": userCont.Company}, "`schoole`") + if myCompany.Schoole != 0 { + sendMsg.Toparty = strconv.FormatInt(myCompany.Schoole, 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}, "`schoole`") + if myCompany.Schoole != 0 { + sendMsg.Toparty = strconv.FormatInt(myCompany.Schoole, 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}, "`schoole`") + if myCompany.Schoole != 0 { + sendMsg.Toparty = strconv.FormatInt(myCompany.Schoole, 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: //自定义 + + default: + } + if isSend { + } + } + return false +} + +/* +@ 作者: 秦东 +@ 时间: 2025-03-28 13:20:44 +@ 功能: 处理自定义表格字段发送乏味 +*/ +func (s *SendMsgInfo) TableFieldsSendMsg(fieldVal map[string]interface{}, userCont modelshr.ManCont) (wechatMap []string) { + if len(s.SendRangeList) > 0 { + var Recipient []string + for _, v := range s.SendRangeList { + for fi, fv := range fieldVal { + if v.Id == fi { + switch v.Types { + case "orgCentent": //选择组织 + val, _ := publicmethod.StringToInt64(fv) + if val != 0 { + //获取该组织得所以下级 + Recipient = append(Recipient, GainOrgManWechat(val)...) + } + case "founder": //创建人 + if userCont.WorkWechat != "" { + Recipient = append(Recipient, userCont.WorkWechat) + } else { + Recipient = append(Recipient, userCont.Wechat) + } + case "owner": //拥有者 + val := publicmethod.TypeToInterface(fv) + if val != "" { + if len(val) >= 10 { + var orgMan modelshr.PersonArchives + orgMan.GetCont(map[string]interface{}{"`key`": val}, "`wechat`", "`work_wechat`") + if orgMan.WorkWechat != "" { + Recipient = append(Recipient, orgMan.WorkWechat) + } else if orgMan.Wechat != "" { + Recipient = append(Recipient, orgMan.Wechat) + } + } + } else { + orgId, _ := strconv.ParseInt(val, 10, 64) + Recipient = append(Recipient, GainOrgManWechat(orgId)...) + } + case "deptOrg": //所属部门 + val, _ := publicmethod.StringToInt64(fv) + if val != 0 { + //获取该组织得所以下级 + Recipient = append(Recipient, GainOrgManWechat(val)...) + } + case "pickpost": //岗位选择 + val := publicmethod.TypeToInterface(fv) + if val != "" { + postMap := strings.Split(val, "#@#") + if len(postMap) >= 2 { + Recipient = append(Recipient, RecipientPost(postMap)...) + } + } + case "pickrole": //角色选择 + val := publicmethod.TypeToInterface(fv) + if val != "" { + Recipient = append(Recipient, RecipientRole(val)...) + } + case "expand-user": //选择用户 + val := publicmethod.TypeToInterface(fv) + if val != "" { + Recipient = append(Recipient, RegexpToMap(val)...) + } + default: + } + } + } + } + if len(Recipient) > 0 { + for _, v := range Recipient { + if !publicmethod.IsInTrue[string](v, wechatMap) { + wechatMap = append(wechatMap, v) + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-28 14:49:38 +@ 功能: 通过角色获取接收人员 +*/ +func RecipientRole(val string) (wechatMap []string) { + if val != "" { + var orgManList []modelshr.PersonArchives + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND FIND_IN_SET(?,`role`)", val).Find(&orgManList) + if len(orgManList) > 0 { + for _, v := range orgManList { + if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, wechatMap) { + wechatMap = append(wechatMap, v.Wechat) + } + if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, wechatMap) { + wechatMap = append(wechatMap, v.WorkWechat) + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-28 14:41:25 +@ 功能: 根据岗位获取接收人 +*/ +func RecipientPost(val []string) (wechatMap []string) { + vLen := len(val) + if vLen > 0 { + var orgManList []modelshr.PersonArchives + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND `position` = ?", val[vLen-1]).Find(&orgManList) + if len(orgManList) > 0 { + for _, v := range orgManList { + if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, wechatMap) { + wechatMap = append(wechatMap, v.Wechat) + } + if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, wechatMap) { + wechatMap = append(wechatMap, v.WorkWechat) + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-28 13:59:42 +@ 功能: 通过正则表达式获取人员编号 +*/ +func RegexpToMap(val string) (wechatMap []string) { + if val != "" { + var userNumber []string + ruleSet := regexp.MustCompile(`\(([^)]+)\)`) + valMap := ruleSet.FindAllStringSubmatch(val, -1) + if len(valMap) > 0 { + for _, v := range valMap { + vLen := len(v) + if vLen > 0 { + if !publicmethod.IsInTrue(v[vLen-1], userNumber) { + userNumber = append(userNumber, v[vLen-1]) + } + } + } + } + if len(userNumber) > 0 { + var orgManList []modelshr.PersonArchives + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND `admin_org` IN ?", userNumber).Find(&orgManList) + if len(orgManList) > 0 { + for _, v := range orgManList { + if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, wechatMap) { + wechatMap = append(wechatMap, v.Wechat) + } + if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, wechatMap) { + wechatMap = append(wechatMap, v.WorkWechat) + } + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-28 10:58:27 +@ 功能: 根据行政组织获取所有下级人员 +*/ +func GainOrgManWechat(orgId int64) (wechatMap []string) { + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSun(orgId) + sunOrg.Id = append(sunOrg.Id, orgId) + var orgManList []modelshr.PersonArchives + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`wechat`,`work_wechat`").Where("`emp_type` BETWEEN 1 AND 10").Where("`state` = 1 AND `admin_org` IN ?", sunOrg.Id).Find(&orgManList) + if len(orgManList) > 0 { + for _, v := range orgManList { + if v.Wechat != "" && !publicmethod.IsInTrue[string](v.Wechat, wechatMap) { + wechatMap = append(wechatMap, v.Wechat) + } + if v.WorkWechat != "" && !publicmethod.IsInTrue[string](v.WorkWechat, wechatMap) { + wechatMap = append(wechatMap, v.WorkWechat) + } + } + } + return +} + /* * @ 作者: 秦东 diff --git a/api/version1/taskplatform/taskmanagement/types.go b/api/version1/taskplatform/taskmanagement/types.go index 63e790b..d536632 100644 --- a/api/version1/taskplatform/taskmanagement/types.go +++ b/api/version1/taskplatform/taskmanagement/types.go @@ -158,3 +158,90 @@ type UserSmallInfo struct { Icon string `json:"icon"` WeChat string `json:"weChat"` } + +// 解析表单列表结构体 +type FormListInfo struct { + TableData TableDataInfo `json:"tableData"` //列表表格元素 + SearchData []SearchDataInfo `json:"searchData"` //搜索元素 + Loading bool `json:"loading"` + AttrObj interface{} `json:"attrObj"` + Config interface{} `json:"config"` + TagList interface{} `json:"tagList"` + FormId string `json:"formId"` + FormList []interface{} `json:"formList"` + Name string `json:"name"` + TreeData interface{} `json:"treeData"` + PreviewVisible bool `json:"previewVisible"` + TabsName string `json:"tabsName"` + FormFieldList []interface{} `json:"formList"` + FormApi interface{} `json:"formApi"` + Dict interface{} `json:"dict"` + RefreshTable bool `json:"refreshTable"` + ViewPage ViewPageInfo `json:"view"` + SendMsg SendMsgInfo `json:"sendMsg"` //发送企业微信消息配置 +} + +// 发送企业微信消息 +type SendMsgInfo struct { + Open bool `json:"open"` //是否开启发送 + Types string `json:"type"` //发送消息类型 + Title []string `json:"title"` //发送信息标题(对应表单字段) + Content []string `json:"content"` //发送信息描述(对应表单字段) + Icon string `json:"icon"` //发送信息封面(对应表单字段) + SendRange int `json:"sendRange"` //发送范围(1:全集团;2:本公司;3:本部门;4:本行政组织;5:表格中指定;6:自定义) + SendRangeList []sendRangeListInfo `json:"sendRangeList"` //发送范围辅助信息 +} + +type sendRangeListInfo struct { + Icon string `json:"icon"` + Id string `json:"id"` + IsPick bool `json:"isPick"` + MultipleChoice bool `json:"multipleChoice"` + Name string `json:"name"` + Number string `json:"number"` + Types string `json:"types"` +} + +// 视图展示方式 +type ViewPageInfo struct { + Card ViewPageCont `json:"card"` + Date ViewPageCont `json:"date"` + Gantt ViewPageCont `json:"gantt"` + List ViewPageCont `json:"carlistd"` + Map ViewPageCont `json:"card"` + Time ViewPageCont `json:"time"` +} + +type ViewPageCont struct { + Form interface{} `json:"form"` + IsClick bool `json:"isClick"` + Status bool `json:"status"` +} + +// 搜索元素 +type SearchDataInfo struct { + Id string `json:"id"` + Label string `json:"label"` + Field string `json:"field"` + Types string `json:"type"` + Attribute string `json:"attribute"` + Pattern string `json:"pattern"` + FieldClass string `json:"fieldClass"` + Auxiliary string `json:"auxiliary"` + ActiveValue string `json:"activeValue"` + InactiveValue string `json:"inactiveValue"` + Config interface{} `json:"config"` + Control interface{} `json:"control"` + Options interface{} `json:"options"` + IsSearch bool `json:"isSearch"` + IsMsater bool `json:"isMsater"` + SunFormKey string `json:"sunFormKey"` +} + +// 表单内容 +type TableDataInfo struct { + Columns []interface{} `json:"columns"` //列表表格元素 + Config interface{} `json:"config"` //列表表格配置 + ControlBtn []interface{} `json:"controlBtn"` //列表表格操作按钮 + operateBtn []interface{} `json:"operateBtn"` //列表表格操作按钮 +} diff --git a/api/version1/user/type.go b/api/version1/user/type.go index c82b497..09387aa 100644 --- a/api/version1/user/type.go +++ b/api/version1/user/type.go @@ -82,3 +82,42 @@ type EditTemplateCont struct { publicmethod.PublicId UpLoadTemSave } + +type PostJieguo struct { + List []SendPostUnit +} + +// 输出岗位组件树 +type SendPostUnit struct { + Id string `json:"id"` + Value string `json:"value"` + Label string `json:"label"` + IsOrg bool `json:"is_org"` + Superior string `json:"superior"` + OrgId string `json:"org_id"` + Children []SendPostUnit `json:"children"` +} + +// 行政组织和人 +type OrgAndPeopleInfo struct { + Id string `json:"id"` //ID + Number string `json:"number"` //编号 + Name string `json:"name"` //名称 + Icon string `json:"icon"` //头像 + IsPick bool `json:"isPick"` //是否选中 + Types string `json:"types"` //类型 + MultipleChoice bool `json:"multipleChoice"` //值多选 +} + +// 输出数据 +type SendOrgAndPeople struct { + OrgList []OrgAndPeopleInfo `json:"orgList"` //行政组织 + PeopleList []OrgAndPeopleInfo `json:"peopleList"` //人员 + Breadcrumb []OrgAndPeopleInfo `json:"breadcrumb"` //面包屑 +} + +// 输出简化 +type SendOrgAndManInfo struct { + OrgManList []OrgAndPeopleInfo `json:"orgManList"` //行政组织Joi + Breadcrumb []OrgAndPeopleInfo `json:"breadcrumb"` //面包屑 +} diff --git a/api/version1/user/userCont.go b/api/version1/user/userCont.go index 86e0426..0c067c0 100644 --- a/api/version1/user/userCont.go +++ b/api/version1/user/userCont.go @@ -845,3 +845,290 @@ func (a *ApiMethod) GainTempleateOrgList(c *gin.Context) { } publicmethod.Result(0, orgList, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-19 14:01:00 +@ 功能: 获取角色列表 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainRoleList(c *gin.Context) { + var roleMode modelssystempermission.SystemRole + roleList, _ := roleMode.ContMap(map[string]interface{}{"state": 1}) + publicmethod.Result(0, roleList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-19 15:08:47 +@ 功能: 获取岗位 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainPickPost(c *gin.Context) { + var requestData publicmethod.PublicId + c.ShouldBindJSON(&requestData) + var orgList []modelshr.AdministrativeOrganization + + gormDb := overall.CONSTANT_DB_HR.Where("`state` = 1") + if requestData.Id != "" { + adminorgInt, _ := strconv.ParseInt(requestData.Id, 10, 64) + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSun(adminorgInt) + sunOrg.Id = append(sunOrg.Id, adminorgInt) + gormDb = gormDb.Where("`id` IN ?", sunOrg.Id) + } + gormDb.Find(&orgList) + var orgPostList PostJieguo + if len(orgList) > 0 { + + for _, v := range orgList { + if v.Id == 102 { + syncSeting.Add(1) + go orgPostList.OrgPostMap(v) + } + + } + syncSeting.Wait() + } + + // publicmethod.Result(0, orgPostList.List, c) + orgPostMap := OrgPostTree(requestData.Id, orgPostList.List) + publicmethod.Result(0, orgPostMap, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-19 15:34:32 +@ 功能: 获取每个行政组织的岗位 +*/ +func (p *PostJieguo) OrgPostMap(org modelshr.AdministrativeOrganization) { + defer syncSeting.Done() + var inFor SendPostUnit + inFor.Id = strconv.FormatInt(org.Id, 10) + inFor.Value = org.Number + inFor.Label = org.Name + inFor.IsOrg = true + inFor.Superior = strconv.FormatInt(org.Superior, 10) + // inFor.Children = GainOrgPost(org.Id) + p.List = append(p.List, inFor) + p.List = append(p.List, GainOrgPost(org.Id)...) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-19 15:39:30 +@ 功能: +*/ +func GainOrgPost(org int64) (postMap []SendPostUnit) { + var postList []modelshr.Position + overall.CONSTANT_DB_HR.Where("`state` = 1 AND `department` = ?", org).Find(&postList) + // var postAry []SendPostUnit + if len(postList) > 0 { + for _, v := range postList { + var inFor SendPostUnit + inFor.Id = strconv.FormatInt(v.Id, 10) + inFor.Value = v.Number + inFor.Label = v.Name + inFor.IsOrg = false + inFor.OrgId = strconv.FormatInt(v.Department, 10) + inFor.Superior = strconv.FormatInt(v.Department, 10) + postMap = append(postMap, inFor) + } + } + // postMap = OrgPostTree("0", postAry) + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-19 16:03:39 +@ 功能: 生成树 +*/ +func OrgPostTree(parentId string, postMap []SendPostUnit) (menusTree []SendPostUnit) { + fmt.Printf("上一级OrgId:%v\n", parentId) + if len(postMap) > 0 { + for _, v := range postMap { + // if v.IsOrg { + if v.Superior == parentId { + var inFor SendPostUnit + inFor.Id = v.Id + inFor.Value = v.Value + inFor.Label = v.Label + inFor.IsOrg = v.IsOrg + inFor.OrgId = v.OrgId + inFor.Superior = v.Superior + inFor.Children = OrgPostTree(v.Id, postMap) + menusTree = append(menusTree, inFor) + } + // } else { + // if v.OrgId == parentId { + // var inFor SendPostUnit + // inFor.Id = v.Id + // inFor.Value = v.Value + // inFor.Label = v.Label + // inFor.IsOrg = v.IsOrg + // inFor.OrgId = v.OrgId + // inFor.Superior = v.Superior + // inFor.Children = OrgPostTree(v.OrgId, postMap) + // menusTree = append(menusTree, inFor) + // } + // } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-26 16:13:07 +@ 功能: 获取行政组织几人员关系 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GainOegAndPeople(c *gin.Context) { + var requestData publicmethod.PublicId + err := c.ShouldBindJSON(&requestData) + if err != nil || requestData.Id == "0" || requestData.Id == "" { + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + requestData.Id = strconv.FormatInt(userCont.Company, 10) + } + orgId, _ := strconv.ParseInt(requestData.Id, 10, 64) + var sendInfo SendOrgAndPeople + //行政组织 + syncSeting.Add(1) + go sendInfo.GainOrgList(requestData.Id) + //获取该组织下得人员 + syncSeting.Add(1) + go sendInfo.GainPeopleList(requestData.Id) + //面包屑 + syncSeting.Add(1) + go sendInfo.GainBreadcrumb(orgId) + syncSeting.Wait() + var sendMap SendOrgAndManInfo + sendMap.OrgManList = append(sendMap.OrgManList, sendInfo.OrgList...) + sendMap.OrgManList = append(sendMap.OrgManList, sendInfo.PeopleList...) + sendMap.Breadcrumb = sendInfo.Breadcrumb + publicmethod.Result(0, sendMap, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-27 08:09:27 +@ 功能: 获取选择项面包屑 +*/ +func (s *SendOrgAndPeople) GainBreadcrumb(orgId int64) { + defer syncSeting.Done() + var fatherOrg publicmethod.GetOrgAllParent + fatherOrg.GetOrgAllFatherId(orgId, 4) + orgIdLen := len(fatherOrg.Id) + if orgIdLen > 0 { + s.Breadcrumb = s.Breadcrumb[:0] + for i := orgIdLen - 1; i >= 0; i-- { + if fatherOrg.Id[i] != 0 { + var orgInfo modelshr.AdministrativeOrganization + orgInfo.GetCont(map[string]interface{}{"`id`": fatherOrg.Id[i]}, "`id`", "`number`", "`name`") + var orgInfoBrea OrgAndPeopleInfo + orgInfoBrea.Id = strconv.FormatInt(orgInfo.Id, 10) + orgInfoBrea.Number = orgInfo.Number + orgInfoBrea.Name = orgInfo.Name + if orgInfo.Id > 0 { + s.Breadcrumb = append(s.Breadcrumb, orgInfoBrea) + } + } + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-26 16:23:23 +@ 功能: 获取人员信息 +*/ +func (s *SendOrgAndPeople) GainPeopleList(orgId string) { + defer syncSeting.Done() + if orgId == "0" || orgId == "" { + orgId = "313" + } + var orgList []modelshr.PersonArchives + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`number`,`name`,`icon`,`icon_photo`").Where("`state` = 1 AND `emp_type` BETWEEN 1 AND 10 AND `admin_org` = ?", orgId).Find(&orgList) + if len(orgList) > 0 { + s.PeopleList = s.PeopleList[:0] + for _, v := range orgList { + var orgInfo OrgAndPeopleInfo + orgInfo.Id = strconv.FormatInt(v.Id, 10) + orgInfo.Number = v.Number + orgInfo.Name = v.Name + orgInfo.Icon = v.IconPhoto + if v.Icon != "" { + orgInfo.Icon = v.Icon + } + orgInfo.Types = "people" + s.PeopleList = append(s.PeopleList, orgInfo) + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-03-26 16:23:23 +@ 功能: 获取行政组织 +*/ +func (s *SendOrgAndPeople) GainOrgList(orgId string) { + defer syncSeting.Done() + if orgId == "0" || orgId == "" { + orgId = "313" + } + var orgList []modelshr.AdministrativeOrganization + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`number`,`name`").Where("`state` = 1 AND `superior` = ?", orgId).Find(&orgList) + if len(orgList) > 0 { + s.OrgList = s.OrgList[:0] + for _, v := range orgList { + var orgInfo OrgAndPeopleInfo + orgInfo.Id = strconv.FormatInt(v.Id, 10) + orgInfo.Number = v.Number + orgInfo.Name = v.Name + orgInfo.Types = "masterOrg" + s.OrgList = append(s.OrgList, orgInfo) + } + } +} diff --git a/api/version1/workWechat/wechat.go b/api/version1/workWechat/wechat.go index f81ab69..7b4d5c5 100644 --- a/api/version1/workWechat/wechat.go +++ b/api/version1/workWechat/wechat.go @@ -568,6 +568,6 @@ func (a *ApiMethod) WechatCallBackPage(c *gin.Context) { default: callBackLoginUrl = fmt.Sprintf("%v/#/work_wechat?%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, urlParameter) } - + fmt.Printf("\n\n返回路径:%v\n\n", callBackLoginUrl) c.Redirect(http.StatusMovedPermanently, callBackLoginUrl) } diff --git a/apirouter/personalityAssessment/rongxin.go b/apirouter/personalityAssessment/rongxin.go index e6316fc..4cca57b 100644 --- a/apirouter/personalityAssessment/rongxin.go +++ b/apirouter/personalityAssessment/rongxin.go @@ -27,5 +27,6 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter.POST("downLoadNineTestPage", methodBinding.DownLoadNineTestPage) //下载九型人格测试结果 apiRouter.GET("downLoadNineTestPage", methodBinding.DownLoadNineTestPage) //下载九型人格测试结果 apiRouter.GET("statisticsPersonality", methodBinding.StatisticsPersonality) //下载人格测试状态 + apiRouter.GET("downLoadTearms", methodBinding.DownLoadTearms) //下载人员班组 } } diff --git a/apirouter/v1/customerformrouter/router.go b/apirouter/v1/customerformrouter/router.go index 6ef7579..af803aa 100644 --- a/apirouter/v1/customerformrouter/router.go +++ b/apirouter/v1/customerformrouter/router.go @@ -56,7 +56,8 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("multiViewPage", methodBinding.MultiViewPAge) //多视图数据处理 - apiRouter.POST("gainCalendarList", methodBinding.GainCalendarList) //日历视图数据处理 + // apiRouter.POST("gainCalendarList", methodBinding.GainCalendarList) //日历视图数据处理 + apiRouter.POST("gainCalendarList", methodBinding.CalendarDataList) //日历视图数据处理 apiRouter.POST("setOftenApp", methodBinding.SetOftenApp) //编辑常用自定义App @@ -106,5 +107,9 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { appApiRouter.POST("gaveAllApp", methodAppHand.GaveAllApp) //获取所有自定义App appApiRouter.POST("ginTeamRule", methodAppHand.GinTeamRule) //获取已经设定好的参数 appApiRouter.POST("setupRulerForm", methodAppHand.SetupRulerForm) //设定取值 + + appApiRouter.POST("gainAppGroupMenus", methodAppHand.GainAppGroupMenus) //获取分组App菜单 + + appApiRouter.POST("moveAppMenus", methodAppHand.MoveAppMenus) //移动栏目 } } diff --git a/apirouter/v1/taskrouter/taskrouter.go b/apirouter/v1/taskrouter/taskrouter.go index 38bd591..e20aa87 100644 --- a/apirouter/v1/taskrouter/taskrouter.go +++ b/apirouter/v1/taskrouter/taskrouter.go @@ -100,5 +100,7 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { taskFlowApi.POST("afreshAppSubmit", taskFlowRouter.AfreshAppSubmit) // 重新提交(有流程就发动流程,无流程就正常发表) + taskFlowApi.POST("gainOrgOfPeopleNodeFactor", taskFlowRouter.GainOrgOfPeopleNodeFactor) //获取行政组织几人员相关控件信息 + } } diff --git a/apirouter/v1/userRouters/pc.go b/apirouter/v1/userRouters/pc.go index ee69a1c..841a743 100644 --- a/apirouter/v1/userRouters/pc.go +++ b/apirouter/v1/userRouters/pc.go @@ -24,5 +24,9 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("gainUserTemplateInfo", methodBinding.GainUserTemplateInfo) //获取员工模版信息 apiRouter.POST("editUserTemplateInfo", methodBinding.EditUserTemplateInfo) //编辑模版内容 apiRouter.POST("gainTempleateOrgList", methodBinding.GainTempleateOrgList) //获取现有模版归属那个组织 + apiRouter.POST("gainRoleList", methodBinding.GainRoleList) //获取角色列表 + apiRouter.POST("gainPickPost", methodBinding.GainPickPost) //获取岗位 + + apiRouter.POST("gainOegAndPeople", methodBinding.GainOegAndPeople) //获取行政组织几人员关系 } }