From b98b34ef06e4b24012166fc2b4ed29b7d1752c41 Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Fri, 28 Nov 2025 11:15:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 13 +- api/authentication/creatToke.go | 172 +++ api/authentication/setupRoule.go | 313 +++++ api/authentication/type.go | 71 ++ api/version1/customChartesing/analyData.go | 491 ++++++++ api/version1/customChartesing/bar.go | 416 ++++--- api/version1/customChartesing/barRace.go | 49 + api/version1/customChartesing/chartType.go | 7 +- api/version1/customChartesing/formTable.go | 205 +++- api/version1/customChartesing/newAnaly.go | 579 +++++++++ api/version1/customChartesing/radar.go | 51 + api/version1/customChartesing/target.go | 13 + api/version1/customChartesing/type.go | 91 +- api/version1/customerApp/appControll.go | 110 +- api/version1/customerApp/commont.go | 607 ++++++++++ api/version1/customerApp/companyduty.go | 1030 +++++++++++++++++ api/version1/customerApp/companyduty_test.go | 529 +++++++++ api/version1/customerApp/type.go | 384 ++++++ api/version1/customerform/calendarData.go | 30 +- api/version1/customerform/form.go | 8 + api/version1/customerform/formTable.go | 269 ++++- api/version1/customerform/formTableList.go | 75 ++ api/version1/customerform/formTableView.go | 33 +- api/version1/customerform/tableList.go | 6 +- api/version1/customerform/type.go | 5 +- api/version1/entry.go | 4 + api/version1/grantpowers/postpower.go | 114 +- api/version1/grantpowers/type.go | 37 + api/version1/humanResources/enter.go | 33 + api/version1/humanResources/org.go | 116 ++ api/version1/menus/menus.go | 15 +- api/version1/publicapi/updownpage.go | 133 +++ api/version1/setupRoule/authorization.go | 267 +++++ api/version1/setupRoule/entry.go | 150 +++ api/version1/setupRoule/orgPeople.go | 459 ++++++++ api/version1/setupRoule/power.go | 149 +++ .../taskplatform/taskflowing/analyFormJson.go | 302 +++++ .../taskplatform/taskflowing/appTaskFlow.go | 16 +- .../taskplatform/taskflowing/editformflow.go | 4 +- .../taskplatform/taskflowing/types.go | 53 +- .../taskplatform/taskmanagement/appControl.go | 2 +- .../taskplatform/taskmanagement/appform.go | 8 +- .../taskplatform/taskmanagement/flowNode.go | 3 + .../taskmanagement/formcontrol.go | 21 +- .../taskplatform/taskmanagement/ruanTask.go | 122 +- .../taskmanagement/sendWorkWatchMsg.go | 10 +- .../taskplatform/taskmanagement/types.go | 30 +- api/version1/user/setPower.go | 483 ++++++++ api/version1/user/type.go | 67 ++ api/version1/user/userCont.go | 7 +- api/version1/workWechat/sendMsg.go | 37 +- apirouter/appPower/entry.go | 3 + apirouter/appPower/powerRole.go | 32 + apirouter/authenticationroute/entry.go | 1 + .../authenticationroute/signcoderoute.go | 21 +- apirouter/entry.go | 5 + apirouter/hrRoute/enter.go | 3 + apirouter/hrRoute/hrrouter.go | 18 + apirouter/v1/customChartRouter/chartRouter.go | 10 +- apirouter/v1/customerformrouter/router.go | 22 +- apirouter/v1/grantsystempower/pc.go | 1 + apirouter/v1/public/router.go | 1 + apirouter/v1/taskrouter/taskrouter.go | 4 +- config/configDatabase/database.yaml | 36 +- go.mod | 2 + go.sum | 5 + initialization/route/initRoute.go | 14 +- models/customerForm/shiftChangeApplication.go | 78 ++ .../modelAppPlatform/customer_form_version.go | 1 + models/modelAppPlatform/customer_form_view.go | 1 + models/modelAppPlatform/mychart..go | 70 ++ models/modelshr/org_cont.go | 82 ++ models/modelssystempermission/auth_power.go | 63 + .../modelssystempermission/authpowerlist.go | 72 ++ models/modelssystempermission/power_info.go | 65 ++ models/modelssystempermission/system_role.go | 13 +- models/teamlog/companylog.go | 69 ++ overall/publicmethod/getUserPower.go | 112 +- overall/publicmethod/powerRedis.go | 53 + overall/publicmethod/tableUnit.go | 7 +- overall/publicmethod/technique.go | 296 ++++- overall/publicmethod/type.go | 60 + package.json | 6 + 83 files changed, 9089 insertions(+), 336 deletions(-) create mode 100644 api/authentication/creatToke.go create mode 100644 api/authentication/setupRoule.go create mode 100644 api/version1/customChartesing/newAnaly.go create mode 100644 api/version1/customerApp/commont.go create mode 100644 api/version1/customerApp/companyduty.go create mode 100644 api/version1/customerApp/companyduty_test.go create mode 100644 api/version1/humanResources/enter.go create mode 100644 api/version1/humanResources/org.go create mode 100644 api/version1/publicapi/updownpage.go create mode 100644 api/version1/setupRoule/authorization.go create mode 100644 api/version1/setupRoule/entry.go create mode 100644 api/version1/setupRoule/orgPeople.go create mode 100644 api/version1/setupRoule/power.go create mode 100644 api/version1/taskplatform/taskflowing/analyFormJson.go create mode 100644 api/version1/user/setPower.go create mode 100644 apirouter/appPower/entry.go create mode 100644 apirouter/appPower/powerRole.go create mode 100644 apirouter/hrRoute/enter.go create mode 100644 apirouter/hrRoute/hrrouter.go create mode 100644 models/customerForm/shiftChangeApplication.go create mode 100644 models/modelAppPlatform/mychart..go create mode 100644 models/modelshr/org_cont.go create mode 100644 models/modelssystempermission/auth_power.go create mode 100644 models/modelssystempermission/authpowerlist.go create mode 100644 models/modelssystempermission/power_info.go create mode 100644 models/teamlog/companylog.go create mode 100644 overall/publicmethod/powerRedis.go create mode 100644 package.json diff --git a/.vscode/settings.json b/.vscode/settings.json index a330349..7701711 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,14 @@ { - "idf.pythonInstallPath": "f:\\esp32\\toolsides\\tools\\idf-python\\3.11.2\\python.exe" + "idf.pythonInstallPath": "f:\\esp32\\toolsides\\tools\\idf-python\\3.11.2\\python.exe", + "editor.gotoLocation.alternativeDeclarationCommand": "editor.action.revealDefinition", + "editor.gotoLocation.alternativeDefinitionCommand": "editor.action.revealDefinition", + "editor.gotoLocation.alternativeTypeDefinitionCommand": "editor.action.revealDefinition", + "editor.selectionHighlight": false, + "files.autoSave": "onFocusChange", + "editor.suggest.snippetsPreventQuickSuggestions": false, + "editor.quickSuggestions": { + "other": "on", + "comments": "off", + "strings": "on" + } } \ No newline at end of file diff --git a/api/authentication/creatToke.go b/api/authentication/creatToke.go new file mode 100644 index 0000000..1f577e1 --- /dev/null +++ b/api/authentication/creatToke.go @@ -0,0 +1,172 @@ +package authentication + +import ( + "appPlatform/middleware/grocerystore" + "appPlatform/models/modelshr" + "appPlatform/models/modelsschool" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "fmt" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-13 15:30:06 +@ 功能: 获取身份 +*/ +func (a *ApiMethod) HaveMyCode(c *gin.Context) { + var requestData publicmethod.CommonId[string] + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(200, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(200, err, c, "未知行政组织!") + return + } + var userCont modelshr.ManCont + err = overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Where("`state` = 1 AND `emp_type` BETWEEN ? AND ? AND `number` = ?", 1, 10, requestData.Id).First(&userCont).Error + if err != nil { + publicmethod.Result(200, err, c) + return + } + userAgent := overall.CONSTANT_CONFIG.Appsetup.AppKey + //加密固定参数 + var md5JiaMi publicmethod.Md5Encryption + md5JiaMi.Md5EncryptionInit(userAgent) + md5Token := md5JiaMi.Md5EncryptionAlgorithm() + //加密工号 + var md5JiaMiNumber publicmethod.Md5Encryption + md5JiaMiNumber.Md5EncryptionInit(userCont.Number) + userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm() + + sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token + sha1Token := publicmethod.Sha1Encryption(sha1Str) + menuoper, jurisdiction := getRoleSeat(userCont.Role) + writeRedisData := map[string]interface{}{ + "userkey": userKeyCode, + "key": userCont.Key, + "usernumber": userCont.Number, + "userpwd": userCont.Password, + "usertoken": sha1Token, + "jurisdiction": jurisdiction, + "menuOper": menuoper, + "wand": 118, + } + //API Token数据 + redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKeyCode) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) + redisClient.SetRedisTime(10800) + redisClient.HashMsetAdd(redisFileKey, writeRedisData) + + saveData := publicmethod.MapOut[string]() + saveData["key"] = userKeyCode + saveData["token"] = sha1Token + + _, companyId, _, sunDepartId, _ := publicmethod.GetOrgStructurees(userCont.AdminOrg) + + var sunmaindeparment int64 + + if companyId != sunDepartId { + sunmaindeparment = sunDepartId + } + + //缓存写入个人信息 + redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userCont.Number) + myCont := publicmethod.MapOut[string]() + myCont["id"] = userCont.Id + myCont["number"] = userCont.Number //员工工号 + myCont["name"] = userCont.Name //姓名 + myCont["icon"] = userCont.Icon //头像 + myCont["hireclass"] = userCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;) + myCont["emptype"] = userCont.EmpType //用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职) + myCont["company"] = userCont.Company //入职公司 + // myCont["maindeparment"] = userCont.MainDeparment //主部门 + // myCont["sunmaindeparment"] = userCont.SunMainDeparment //二级主部门 + myCont["maindeparment"] = companyId //主部门 + myCont["sunmaindeparment"] = sunmaindeparment //二级主部门 + + myCont["deparment"] = userCont.Deparment //部门 + myCont["adminorg"] = userCont.AdminOrg //所属行政组织 + myCont["teamid"] = userCont.TeamId //班组 + myCont["position"] = userCont.Position //职位 + myCont["jobclass"] = userCont.JobClass //职务分类 + myCont["jobid"] = userCont.JobId //职务 + myCont["jobleve"] = userCont.JobLeve //职务等级 + myCont["wechat"] = userCont.Wechat //微信UserId + myCont["workwechat"] = userCont.WorkWechat //企业微信UserId + myCont["state"] = userCont.State //状态(1:启用;2:禁用;3:删除) + myCont["key"] = userCont.Key //key + myCont["isadmin"] = userCont.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管 + myCont["password"] = userCont.Password //密码 + myCont["role"] = userCont.Role //角色 + myCont["idcardno"] = userCont.Idcardno //身份证号 + myCont["passportno"] = userCont.Passportno //护照号码 + myCont["globalroaming"] = userCont.Globalroaming //国际区号 + myCont["mobilephone"] = userCont.Mobilephone //手机号码 + myCont["email"] = userCont.Email //电子邮件 + myCont["gender"] = userCont.Gender //性别(1:男性;2:女性;3:中性) + myCont["birthday"] = userCont.Birthday //birthday + myCont["myfolk"] = userCont.Myfolk //民族 + myCont["nativeplace"] = userCont.Nativeplace //籍贯 + myCont["idcardstartdate"] = userCont.Idcardstartdate //身份证有效期开始 + myCont["idcardenddate"] = userCont.Idcardenddate //身份证有效期结束 + myCont["idcardaddress"] = userCont.Idcardaddress //身份证地址 + myCont["idcardIssued"] = userCont.IdcardIssued //身份证签发机关 + myCont["health"] = userCont.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废) + myCont["maritalstatus"] = userCont.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异) + myCont["internaltelephone"] = userCont.Internaltelephone //内线电话 + myCont["currentresidence"] = userCont.Currentresidence //现居住地址 + myCont["constellationing"] = userCont.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座) + myCont["isdoubleworker"] = userCont.Isdoubleworker //是否双职工(1:是;2:否) + myCont["isveterans"] = userCont.Isveterans //是否为退役军人(1:是;2:否) + myCont["veteransnumber"] = userCont.Veteransnumber //退役证编号 + myCont["jobstartdate"] = userCont.Jobstartdate //参加工作日期 + myCont["entrydate"] = userCont.Entrydate //入职日期 + myCont["probationperiod"] = userCont.Probationperiod //试用期 + myCont["planformaldate"] = userCont.Planformaldate //预计转正日期 + myCont["political_outlook"] = userCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员) + + var companyCont modelshr.AdministrativeOrganization + companyCont.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`") + myCont["companyname"] = companyCont.Name + var departmentCont modelshr.AdministrativeOrganization + departmentCont.GetCont(map[string]interface{}{"`id`": userCont.MainDeparment}, "`name`") + myCont["maindeparmentname"] = departmentCont.Name + var postInfo modelshr.Position + postInfo.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`") + myCont["positionname"] = postInfo.Name + redisClient.HashMsetAdd(redisMyContKey, myCont) + + // saveData["usercont"] = myCont + + // var sendKpiCont WriteIderCont + // sendKpiCont.Openid = requestData.Id + // sendKpiCont.Key = userKeyCode + // sendKpiCont.Token = sha1Token + // sendKpiCont.UserInfo.Key = strconv.FormatInt(userCont.Key, 10) + // sendKpiCont.UserInfo.Number = userCont.Number + // sendKpiCont.UserInfo.Password = userCont.Password + // sendDate, _ := json.Marshal(sendKpiCont) + // publicmethod.CurlPostJosn("http://120.224.6.6:39168/shiyan/write_token", sendDate) + + publicmethod.Result(0, saveData, c) +} + +// 获取权限点位 +func getRoleSeat(roleId string) (menuStr, buttonStr string) { + var roleInfo modelsschool.SystemRole + err := roleInfo.GetCont(map[string]interface{}{"r_id": roleId}, "r_menu_oper", "r_jurisdiction") + if err != nil { + return + } + menuStr = roleInfo.MenuOper + buttonStr = roleInfo.Jurisdiction + // jsonStr, _ := json.Marshal(roleInfo) + // fmt.Printf("roleInfo-->%v-menuStr->%v\n-buttonStr->%v----jsonStr--->%v\n", roleId, menuStr, buttonStr, string(jsonStr)) + return +} diff --git a/api/authentication/setupRoule.go b/api/authentication/setupRoule.go new file mode 100644 index 0000000..e6e6fe5 --- /dev/null +++ b/api/authentication/setupRoule.go @@ -0,0 +1,313 @@ +package authentication + +import ( + "appPlatform/models/modelshr" + "appPlatform/models/modelssystempermission" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "fmt" + "sort" + "strconv" + "time" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-10-23 09:07:27 +@ 功能: 获取角色树 +*/ +func (a *RoleApiMethod) GiveRoleTree(c *gin.Context) { + var roleList []modelssystempermission.SystemRole + err := overall.CONSTANT_DB_System_Permission.Where("`state` IN (1,2)").Find(&roleList).Error + var sendRoleList []RolePower + if err != nil || len(roleList) < 1 { + publicmethod.Result(0, sendRoleList, c) + return + } + sort.Slice(roleList, func(i, j int) bool { + return roleList[i].Sort < roleList[j].Sort + }) + sendRoleList = InfiniteRoleTree(0, roleList) + publicmethod.Result(0, sendRoleList, c) +} + +// 递归无线角色菜单 +func InfiniteRoleTree(parentId int64, threeData []modelssystempermission.SystemRole) []RolePower { + var roleTree []RolePower + for _, v := range threeData { + if v.Superior == parentId { + var roleInfo RolePower + roleInfo.Id = strconv.FormatInt(v.Id, 10) + roleInfo.Label = v.Name + roleInfo.Types = strconv.Itoa(v.Types) + if v.State == 1 { + roleInfo.Status = true + } else { + roleInfo.Status = false + } + roleInfo.Superior = strconv.FormatInt(v.Superior, 10) + roleInfo.Sort = v.Sort + roleInfo.Children = InfiniteRoleTree(v.Id, threeData) + roleTree = append(roleTree, roleInfo) + } + } + return roleTree +} + +// 获取角色分组树 +func (a *RoleApiMethod) GiveRoleGroupTree(c *gin.Context) { + var roleList []modelssystempermission.SystemRole + err := overall.CONSTANT_DB_System_Permission.Where("`state` IN (1,2) AND `types` = 2").Find(&roleList).Error + var sendRoleList []RolePower + if err != nil || len(roleList) < 1 { + publicmethod.Result(0, sendRoleList, c) + return + } + sort.Slice(roleList, func(i, j int) bool { + return roleList[i].Sort < roleList[j].Sort + }) + sendRoleList = InfiniteRoleTree(0, roleList) + publicmethod.Result(0, sendRoleList, c) +} + +// 编辑角色组 +func (a *RoleApiMethod) EditRoleCont(c *gin.Context) { + var request EditInfoRole + err := c.ShouldBindJSON(&request) + if err != nil { + publicmethod.Result(1, err, c) + return + } + roleType := 2 + if request.Types == "" { + roleType = 2 + } else { + roleType, _ = strconv.Atoi(request.Types) + } + if request.Id == "" || request.Id == "0" { + err = AddRoleCont(request) + if err != nil { + publicmethod.Result(1, err, c) + return + } + publicmethod.Result(0, err, c) + } else { + var roleInfo modelssystempermission.SystemRole + err = roleInfo.GetCont(map[string]interface{}{"`id`": request.Id}) + if err != nil || roleInfo.Id == 0 { + err = AddRoleCont(request) + if err != nil { + publicmethod.Result(1, err, c) + return + } + publicmethod.Result(0, err, c) + } else { + saveData := publicmethod.MapOut[string]() + if request.Name != "" && request.Name != roleInfo.Name { + saveData["name"] = request.Name + } + if request.Sort != 0 && request.Sort != roleInfo.Sort { + saveData["sort"] = request.Sort + } + var roleSuper int64 + if request.Superior != "" { + roleSuper, _ = strconv.ParseInt(request.Superior, 10, 64) + } + if roleSuper != roleInfo.Superior { + saveData["superior"] = roleSuper + } + if roleType != roleInfo.Types { + saveData["types"] = roleType + } + if len(saveData) > 0 { + saveData["`time`"] = time.Now().Unix() + var saveRoleInfo modelssystempermission.SystemRole + err = saveRoleInfo.EiteCont(map[string]interface{}{"`id`": roleInfo.Id}, saveData) + if err != nil { + publicmethod.Result(1, err, c) + return + } + } + publicmethod.Result(0, err, c) + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-10-23 15:06:53 +@ 功能: 新增角色 +*/ +func AddRoleCont(saveData EditInfoRole) (err error) { + roleType := 2 + if saveData.Types == "" { + roleType = 2 + } else { + roleType, _ = strconv.Atoi(saveData.Types) + } + var saveRoleInfo modelssystempermission.SystemRole + saveRoleInfo.Name = saveData.Name //系统名称"` + saveRoleInfo.State = 1 //状态(1:启用;2:禁用;3:删除)"` + saveRoleInfo.Time = time.Now().Unix() //创建时间"` + saveRoleInfo.Sort = saveData.Sort //排序"` + saveRoleInfo.Types = roleType //类型"` + saveRoleInfo.Superior, _ = strconv.ParseInt(saveData.Superior, 10, 64) //上级"` + err = overall.CONSTANT_DB_System_Permission.Create(&saveRoleInfo).Error + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-10-23 16:52:54 +@ 功能: 修改角色状态 +*/ +func (a *RoleApiMethod) EditRoleStatus(c *gin.Context) { + var request EditRoleState + err := c.ShouldBindJSON(&request) + if err != nil { + publicmethod.Result(1, err, c) + return + } + if request.Id == "" { + publicmethod.Result(1, err, c, "未知角色!") + return + } + var roleInfo modelssystempermission.SystemRole + err = roleInfo.GetCont(map[string]interface{}{"`id`": request.Id}) + if err != nil || roleInfo.Id == 0 { + publicmethod.Result(1, err, c) + return + } + var allSunId GetAllSunId + allSunId.GaveMySunAll(roleInfo.Id) + allSunId.Id = append(allSunId.Id, roleInfo.Id) + if request.Status == 0 { + request.Status = 1 + } + + saveData := publicmethod.MapOut[string]() + saveData["`state`"] = request.Status + saveData["`time`"] = time.Now().Unix() + var saveRoleInfo modelssystempermission.SystemRole + // err = saveRoleInfo.EiteCont(map[string]interface{}{"`id`": request.Id}, saveData) + err = overall.CONSTANT_DB_System_Permission.Model(&saveRoleInfo).Where("`id` IN ?", allSunId.Id).Updates(saveData).Error + if err != nil { + publicmethod.Result(1, err, c) + return + } + publicmethod.Result(0, err, c) +} + +// 获取所有子集 +func (g *GetAllSunId) GaveMySunAll(parentId int64) { + var id []int64 + overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`id`").Where("`superior` = ?", parentId).Find(&id) + if len(id) > 0 { + for _, v := range id { + if v != 0 { + if !publicmethod.IsInTrue[int64](v, g.Id) { + g.Id = append(g.Id, v) + } + g.GaveMySunAll(v) + } + } + } +} + +// 获取行政组织加岗位树 +func (a *RoleApiMethod) GetOrgPostTree(c *gin.Context) { + var request publicmethod.PublicId + c.ShouldBindJSON(&request) + var orgId int64 + var sunOrgList publicmethod.GetOrgAllParent + if request.Id != "" { + orgId, _ = strconv.ParseInt(request.Id, 10, 64) + if orgId != 0 { + sunOrgList.GetOrgSun(orgId) + } + if len(sunOrgList.Id) > 0 { + sunOrgList.Id = append(sunOrgList.Id, orgId) + } + } else { + orgId = 0 + } + var list []modelshr.OrgCont + var postList []modelshr.Position + if len(sunOrgList.Id) > 0 { + overall.CONSTANT_DB_HR.Model(&modelshr.OrgCont{}).Where("`state` = 1 AND `id` IN ?", sunOrgList.Id).Find(&list) + overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Where("`state` = 1 AND `administrative_organization` IN ?", sunOrgList.Id).Find(&postList) + } else { + if orgId > 0 { + overall.CONSTANT_DB_HR.Model(&modelshr.OrgCont{}).Where("`state` = 1 AND `id` = ?", orgId).Find(&list) + overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Where("`state` = 1 and `administrative_organization` = ?", orgId).Find(&postList) + } else { + overall.CONSTANT_DB_HR.Model(&modelshr.OrgCont{}).Where("`state` = 1").Find(&list) + overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Where("`state` = 1").Find(&postList) + } + + } + + var allList []OrgPostPower + for _, v := range list { + var orgInfo OrgPostPower + orgInfo.Id = strconv.FormatInt(v.Id, 10) //string `json:"id"` + orgInfo.Label = v.Name //string `json:"label"` + orgInfo.Types = strconv.FormatInt(v.Level, 10) // string `json:"types"` + orgInfo.TypeName = v.TypeName + orgInfo.Status = false //bool `json:"status"` + orgInfo.Superior = strconv.FormatInt(v.Superior, 10) //string `json:"superior"` + orgInfo.Key = fmt.Sprintf("o_%v", v.Id) + orgInfo.Sort = v.Sort //int `json:"sort"` + allList = append(allList, orgInfo) + } + + for i, v := range postList { + var positInfo OrgPostPower + positInfo.Id = strconv.FormatInt(v.Id, 10) //string `json:"id"` + positInfo.Label = v.Name //string `json:"label"` + positInfo.Types = "9" + positInfo.TypeName = "岗位" // string `json:"types"` + positInfo.Status = true //bool `json:"status"` + positInfo.Superior = strconv.FormatInt(v.AdministrativeOrganization, 10) //string `json:"superior"` + positInfo.Key = fmt.Sprintf("p_%v", v.Id) + positInfo.Sort = i //int `json:"sort"` + allList = append(allList, positInfo) + } + + sort.Slice(allList, func(i, j int) bool { + return allList[i].Types < allList[j].Types + }) + // publicmethod.Result(0, allList, c) + orgIdStr := strconv.FormatInt(orgId, 10) + var orgPostTree []OrgPostisTree + orgPostTree = InfiniteOrgPostTree(orgIdStr, allList) + publicmethod.Result(0, orgPostTree, c) +} + +// 递归无线行政组织与岗位菜单 +func InfiniteOrgPostTree(parentId string, threeData []OrgPostPower) []OrgPostisTree { + var roleTree []OrgPostisTree + for _, v := range threeData { + if v.Superior == parentId { + var roleInfo OrgPostisTree + roleInfo.Id = v.Id //string `json:"id"` + roleInfo.Label = v.Label //string `json:"label"` + roleInfo.Types = v.Types // string `json:"types"` + roleInfo.TypeName = v.TypeName + roleInfo.Status = v.Status //bool `json:"status"` + roleInfo.Superior = v.Superior //string `json:"superior"` + roleInfo.Key = v.Key + roleInfo.Sort = v.Sort //int `json:"sort"` + if v.Types != "9" { + roleInfo.Children = InfiniteOrgPostTree(v.Id, threeData) + } + roleTree = append(roleTree, roleInfo) + } + } + return roleTree +} diff --git a/api/authentication/type.go b/api/authentication/type.go index 3353c89..313c196 100644 --- a/api/authentication/type.go +++ b/api/authentication/type.go @@ -7,6 +7,7 @@ import ( ) type ApiMethod struct{} +type RoleApiMethod struct{} // 身份验证 func (a *ApiMethod) Index(c *gin.Context) { @@ -15,8 +16,16 @@ func (a *ApiMethod) Index(c *gin.Context) { publicmethod.Result(0, outputCont, c) } +// 权限处理入口 +func (a *RoleApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["index"] = "权限处理入口" + publicmethod.Result(0, outputCont, c) +} + type ApiEntry struct { SingCodeApi ApiMethod + RoleApi RoleApiMethod } var AppApiEntry = new(ApiEntry) @@ -25,3 +34,65 @@ var AppApiEntry = new(ApiEntry) type SignCodeStr struct { Code string `json:"code"` } + +// 角色赋权输出结构体 +type RolePower struct { + Id string `json:"id"` + Label string `json:"label"` + Types string `json:"types"` + Status bool `json:"status"` + Superior string `json:"superior"` + Sort int `json:"sort"` + Children []RolePower `json:"children"` +} + +// 编辑角色 +type EditInfoRole struct { + Id string `json:"id"` + Name string `json:"name"` + Types string `json:"type"` + Superior string `json:"superior"` + Sort int `json:"sort"` +} + +// 修改状态 +type EditRoleState struct { + Id string `json:"id"` + Status int `json:"status"` +} + +// 获取全部子集 +type GetAllSunId struct { + Id []int64 +} + +// 数据清洗 +type OrgPostPower struct { + Id string `json:"id"` + Label string `json:"label"` + Types string `json:"types"` + TypeName string `json:"typeName"` + Status bool `json:"status"` + Superior string `json:"superior"` + Key string `json:"key"` + Sort int `json:"sort"` +} + +// 岗位树 +type OrgPostisTree struct { + OrgPostPower + Children []OrgPostisTree `json:"children"` +} + +// 输出角色树及人员 +type RoleTreeAndUser struct { + publicmethod.PublicId + publicmethod.PublicName + State int `json:"state"` + Sort int `json:"sort"` + Types int `json:"types"` + Superior int `json:"superior"` + Code string `json:"code"` + Icon string `json:"icon"` + Org string `json:"org"` +} diff --git a/api/version1/customChartesing/analyData.go b/api/version1/customChartesing/analyData.go index 97100ae..6c0c221 100644 --- a/api/version1/customChartesing/analyData.go +++ b/api/version1/customChartesing/analyData.go @@ -6,6 +6,7 @@ import ( "appPlatform/models/modelssystempermission" "appPlatform/overall" "appPlatform/overall/publicmethod" + "fmt" "strconv" ) @@ -14,12 +15,23 @@ func (c *ChartInfo) DataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, chart charData.XAxis.Types = "category" charData.YAxis.Types = "value" var timeList []string + var SunWdList []SunWd + var allMasterKey []string if yVal, isOk := val.([]map[string]interface{}); isOk { for _, mv := range yVal { if yVal, isOk := mv[x.Field]; isOk { pageTime := publicmethod.TypeToInterface(yVal) if !publicmethod.IsInTrue[string](pageTime, timeList) { timeList = append(timeList, pageTime) + + if mastKey, isok := mv["masters_key"]; isok { + mastKeyStr := publicmethod.TypeToInterface(mastKey) + var SunWdInfo SunWd + SunWdInfo.TitleVal = pageTime + SunWdInfo.MasterKey = mastKeyStr + allMasterKey = append(allMasterKey, mastKeyStr) + SunWdList = append(SunWdList, SunWdInfo) + } } } } @@ -35,6 +47,119 @@ func (c *ChartInfo) DataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, chart } } charData.AggregateCalculating(x.Field, y, val, timeList, chartType) + if len(SunWdList) > 0 { + charData.SunWuTimeAnaly(SunWdList, c.XSunAxis, c.YSunAxis, chartType, allMasterKey) + } + + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-30 15:00:46 +@ 功能: 计算子表图表数据 +*/ +func (b *BarDataInfo) SunWuTimeAnaly(sunWdList []SunWd, x, y []SunTableSetup, chartType string, allMasterKey []string) { + dlValMap := AllSunTableGroup(x, y, allMasterKey) + var timeList []string + for _, v := range sunWdList { //x轴分布 + if !publicmethod.IsInTrue[string](v.TitleVal, timeList) { + timeList = append(timeList, v.TitleVal) + } + + } + // for _, v := range sunWdList { //x轴分布 + for _, dv := range dlValMap { + for _, yv := range y { + var seriesInfo SeriesList + titleStr := fmt.Sprintf("%v:%v-%v", dv.Title, dv.Label, yv.Title) + seriesInfo.Name = titleStr + seriesInfo.Types = chartType + if !publicmethod.IsInTrue[string](titleStr, b.Legend.Data) { + b.Legend.Data = append(b.Legend.Data, titleStr) + } + + switch yv.Method { + case 2: + seriesInfo.AverageValuees(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 3: + seriesInfo.StatisticalQuantityes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 4: + seriesInfo.RemoveDuplicateCountss(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 5: + seriesInfo.maxDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 6: + seriesInfo.minDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + default: + seriesInfo.sumDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + } + + b.Series = append(b.Series, seriesInfo) + } + } + // } +} + +// 获取所有子表的度量 +func AllSunTableGroup(x, y []SunTableSetup, allMasterKey []string) (duLianCanshu []WeiDuInfos) { + for _, v := range x { + var listData []map[string]interface{} + overall.CONSTANT_DB_CustomerForm.Table(v.TableKey).Where("`states` = 1 AND `masters_key` IN ?", allMasterKey).Find(&listData) + if len(listData) > 0 { + if mapAry, isOk := v.Options.([]interface{}); isOk { + for _, mv := range mapAry { + if mvMap, isOk := mv.(map[string]interface{}); isOk { + if mvVal, isOk := mvMap["value"]; isOk { + mvValStr := publicmethod.TypeToInterface(mvVal) + var WeiDuConter WeiDuInfos + WeiDuConter.Field = v.Field + WeiDuConter.DataVal = mvValStr + WeiDuConter.Title = v.OldTitle + if labelVal, isOk := mvMap["label"]; isOk { + WeiDuConter.Label = publicmethod.TypeToInterface(labelVal) + } + for _, lv := range listData { + if lvVal, isOk := lv[v.Field]; isOk { + lvValStr := publicmethod.TypeToInterface(lvVal) + if lvValStr == mvValStr { + WeiDuConter.List = append(WeiDuConter.List, lv) + } + } + } + duLianCanshu = append(duLianCanshu, WeiDuConter) + } + } + } + } else { + var fenlei []string + for _, lv := range listData { + if lvVal, isOk := lv[v.Field]; isOk { + lvValStr := publicmethod.TypeToInterface(lvVal) + if !publicmethod.IsInTrue[string](lvValStr, fenlei) { + fenlei = append(fenlei, lvValStr) + } + } + } + for _, fv := range fenlei { + var WeiDuConter WeiDuInfos + WeiDuConter.Field = v.Field + WeiDuConter.DataVal = fv + WeiDuConter.Title = v.OldTitle + WeiDuConter.Label = fv + for _, lv := range listData { + if lvVal, isOk := lv[v.Field]; isOk { + lvValStr := publicmethod.TypeToInterface(lvVal) + if lvValStr == fv { + WeiDuConter.List = append(WeiDuConter.List, lv) + } + } + } + duLianCanshu = append(duLianCanshu, WeiDuConter) + } + } + } + } return } @@ -317,3 +442,369 @@ func (s *SeriesList) sumDataes(xField, yField string, xAry []string, val interfa s.Data = append(s.Data, jieguo) } } + +// 计算柱形子表数据 +// 计算数值 +// 1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值 +// 当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数; +/* +val 获取到的数值 +x 纬度 +y 量化 +chartType 图表类型 +types 时间类型 +types 时间类型 +*/ +func (b *BarDataInfo) SunDayCalculateValues(val interface{}, x, y []SunTableSetup, chartType string, types string, timeAry []string) { + // fmt.Printf("子表数据---->%v\n\n\n", val) + var dataMastKey []string + if valMapAry, isOk := val.([]map[string]interface{}); isOk { + for _, v := range valMapAry { + if mastKey, isok := v["masters_key"]; isok { + + key := publicmethod.TypeToInterface(mastKey) + if !publicmethod.IsInTrue[string](key, dataMastKey) { + dataMastKey = append(dataMastKey, key) + + } + } + + } + } + // fmt.Printf("子表数据--dataMastKey-->%v\n\n\n", dataMastKey) + if len(dataMastKey) > 0 { + var SunTabelName []string + var weiduDataMap []EveryOneSunTableData + for _, v := range x { + if !publicmethod.IsInTrue[string](v.TableKey, SunTabelName) { + SunTabelName = append(SunTabelName, v.TableKey) + weiduDataMap = append(weiduDataMap, SunTableDataList(v, dataMastKey)) + } + } + // jsonm, _ := json.Marshal(weiduDataMap) + // fmt.Printf("子表数据--dataMastKey-->%v\n-->%v\n\n", SunTabelName, string(jsonm)) + if len(weiduDataMap) > 0 { + for _, v := range weiduDataMap { + for _, lv := range v.List { + for _, yv := range y { + var seriesInfo SeriesList + titleStr := fmt.Sprintf("%v:%v-%v", lv.Title, lv.Label, yv.Title) + seriesInfo.Name = titleStr + seriesInfo.Types = chartType + if !publicmethod.IsInTrue[string](titleStr, b.Legend.Data) { + b.Legend.Data = append(b.Legend.Data, titleStr) + } + + fmt.Printf("子表数据--yv.Method-->%v\n\n\n", yv.Method) + + switch yv.Method { + case 2: + seriesInfo.SunSumDataAverage(lv.Field, yv.Field, types, lv.List, yv.Format, timeAry) + case 3: + seriesInfo.SunSumDataStatisticalQuantity(lv.Field, yv.Field, types, lv.List, yv.Format, timeAry) + case 4: + seriesInfo.SunSumDataRemoveDuplicate(lv.Field, yv.Field, types, lv.List, yv.Format, timeAry) + case 5: + seriesInfo.SunSumDataMax(lv.Field, yv.Field, types, lv.List, yv.Format, timeAry) + case 6: + seriesInfo.SunSumDataMin(lv.Field, yv.Field, types, lv.List, yv.Format, timeAry) + default: + seriesInfo.SunSumData(lv.Field, yv.Field, types, lv.List, yv.Format, timeAry) + } + b.Series = append(b.Series, seriesInfo) + // seriesInfo.DuLiangAnalySun(lv, yv, types, timeAry) + // fmt.Printf("seriesInfo----->%v\n\n\n", seriesInfo) + } + } + + } + } + } + +} +func (s *SeriesList) SunSumDataMin(xField, yField, types string, val interface{}, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthAry = append(monthAry, s.QuMinData(startTime, endTime.AllTime, val, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) + case "second": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuMinData(startTime, endTime, val, xField, yField, format)) + default: + } + } + s.Data = monthAry +} +func (s *SeriesList) SunSumDataMax(xField, yField, types string, val interface{}, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthAry = append(monthAry, s.QuMaxData(startTime, endTime.AllTime, val, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) + case "second": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuMaxData(startTime, endTime, val, xField, yField, format)) + default: + } + } + s.Data = monthAry +} +func (s *SeriesList) SunSumDataRemoveDuplicate(xField, yField, types string, val interface{}, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthAry = append(monthAry, s.QuChongData(startTime, endTime.AllTime, val, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) + case "second": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuChongData(startTime, endTime, val, xField, yField, format)) + default: + } + } + s.Data = monthAry +} +func (s *SeriesList) SunSumDataStatisticalQuantity(xField, yField, types string, val interface{}, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthAry = append(monthAry, s.QuJishuData(startTime, endTime.AllTime, val, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) + case "second": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuJishuData(startTime, endTime, val, xField, yField, format)) + default: + } + } + s.Data = monthAry +} +func (s *SeriesList) SunSumDataAverage(xField, yField, types string, val interface{}, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime.AllTime, val, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) + case "second": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuPingjunSumData(startTime, endTime, val, xField, yField, format)) + default: + } + } + s.Data = monthAry +} + +// func (s *SeriesList) SunSumData(mastreVal interface{}, xField, yField, types string, val interface{}, format int, timeAry []string) { +func (s *SeriesList) SunSumData(xField, yField, types string, val interface{}, format int, timeAry []string) { + // jsonVal, _ := json.Marshal(val) + // fmt.Printf("jisuan----->%v\n\n\n----->%v\n\n\n----->%v\n\n\n----->%v\n\n\n", xField, yField, types, string(jsonVal)) + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthAry = append(monthAry, s.QuSumData(startTime, endTime.AllTime, val, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) + // fmt.Printf("计算一天的数据:\n\n%v 到 %v 结果:%v\n\n", startTime, endTime, monthAry) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) + case "second": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) + default: + } + } + + s.Data = monthAry +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-29 16:51:03 +@ 功能: 获取不同子表得数据 +*/ +func SunTableDataList(table SunTableSetup, mastKey []string) (list EveryOneSunTableData) { + list.TableName = table.TableKey + if len(mastKey) > 0 { + var listData []map[string]interface{} + overall.CONSTANT_DB_CustomerForm.Table(table.TableKey).Where("`states` = 1 AND `masters_key` IN ?", mastKey).Find(&listData) + if len(listData) > 0 { + if mapAry, isOk := table.Options.([]interface{}); isOk { + for _, mv := range mapAry { + if mvMap, isOk := mv.(map[string]interface{}); isOk { + if mvVal, isOk := mvMap["value"]; isOk { + mvValStr := publicmethod.TypeToInterface(mvVal) + var WeiDuConter WeiDuInfos + WeiDuConter.Field = table.Field + WeiDuConter.DataVal = mvValStr + WeiDuConter.Title = table.OldTitle + if labelVal, isOk := mvMap["label"]; isOk { + WeiDuConter.Label = publicmethod.TypeToInterface(labelVal) + } + for _, lv := range listData { + if lvVal, isOk := lv[table.Field]; isOk { + lvValStr := publicmethod.TypeToInterface(lvVal) + if lvValStr == mvValStr { + WeiDuConter.List = append(WeiDuConter.List, lv) + } + } + } + list.List = append(list.List, WeiDuConter) + } + } + } + } else { + var fenlei []string + for _, v := range listData { + if lvVal, isOk := v[table.Field]; isOk { + lvValStr := publicmethod.TypeToInterface(lvVal) + if !publicmethod.IsInTrue[string](lvValStr, fenlei) { + fenlei = append(fenlei, lvValStr) + } + } + } + for _, v := range fenlei { + var WeiDuConter WeiDuInfos + WeiDuConter.Field = table.Field + WeiDuConter.DataVal = v + WeiDuConter.Title = table.OldTitle + WeiDuConter.Label = v + for _, lv := range listData { + if lvVal, isOk := lv[table.Field]; isOk { + lvValStr := publicmethod.TypeToInterface(lvVal) + if lvValStr == v { + WeiDuConter.List = append(WeiDuConter.List, lv) + } + } + } + list.List = append(list.List, WeiDuConter) + } + + } + } + + } + return +} diff --git a/api/version1/customChartesing/bar.go b/api/version1/customChartesing/bar.go index 8706080..8f8d38a 100644 --- a/api/version1/customChartesing/bar.go +++ b/api/version1/customChartesing/bar.go @@ -15,16 +15,60 @@ import ( @ 功能: 柱状图结果解析 */ func (c *ChartInfo) zhuChart(val interface{}, untis []customerform.MasterStruct, chartType string) (snedMap interface{}) { - + var jisguozhi BarDataInfo for _, v := range c.XAxis { - fmt.Printf("\n\nc.X ===1==> %v =====> %v\n\n", v.Type, v) + // fmt.Printf("\n\nc.X ===1==> %v =====> %v\n\n", v.Type, v) switch v.Type { case 3: - snedMap = c.TimeDataAnaly(v, c.YAxis, val, chartType) + jisguozhi = c.TimeDataAnaly(v, c.YAxis, val, chartType) default: - snedMap = c.DataAnaly(v, c.YAxis, val, chartType, untis) + jisguozhi = c.DataAnaly(v, c.YAxis, val, chartType, untis) + } + } + // var isColor []string + // for _, v := range jisguozhi.Series { + // for di, dv := range v.Data { + // var valSetColor ColorValue + // valSetColor.Value = dv + // for true { + // setColor := publicmethod.GenerateRandomHexColor() + // if !publicmethod.IsInTrue[string](setColor, isColor) { + // isColor = append(isColor, setColor) + // valSetColor.ItemStyle.Color = setColor + // break + // } + // } + // v.Data[di] = valSetColor + // } + // } + for j, v := range jisguozhi.Series { + lenVal := len(publicmethod.SunXuColor) + if j < lenVal { + jisguozhi.Series[j].ItemStyle.Color = publicmethod.SunXuColor[j] + } else { + var isColor []string + for true { + setColor := publicmethod.GenerateRandomHexColor() + if !publicmethod.IsInTrue[string](setColor, isColor) { + isColor = append(isColor, setColor) + jisguozhi.Series[j].ItemStyle.Color = setColor + break + } + } } + + // for true { + // setColor := publicmethod.GenerateRandomHexColor() + // if !publicmethod.IsInTrue[string](setColor, isColor) { + // isColor = append(isColor, setColor) + // jisguozhi.Series[j].ItemStyle.Color = setColor + // break + // } + // } + + fmt.Printf("颜色---》%v\n%v\n", v.Name, v.ItemStyle) } + snedMap = jisguozhi return } @@ -47,12 +91,18 @@ func (c *ChartInfo) TimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, c charData.XAxis.Data = []string{yearVal} } charData.CalculateNumericalValues(y, val, x.Field, chartType, "all", 12, charData.XAxis.Data) + // charData.SunDayCalculateValues(val, c.XSunAxis, c.YSunAxis, chartType, "all", charData.XAxis.Data) + charData.SunDayVal(x.Field, val, c.XSunAxis, c.YSunAxis, chartType, "all", charData.XAxis.Data) case "month": var timeList []string yearVal := publicmethod.UnixTimeToDay(tayTime, 16) tayTimeing := int(time.Now().Month()) for i := 1; i <= tayTimeing; i++ { - timeList = append(timeList, fmt.Sprintf("%v-%v", yearVal, i)) + if i > 9 { + timeList = append(timeList, fmt.Sprintf("%v-%v", yearVal, i)) + } else { + timeList = append(timeList, fmt.Sprintf("%v-0%v", yearVal, i)) + } } if len(searchTime) > 0 { charData.XAxis.Data = searchTime @@ -61,21 +111,31 @@ func (c *ChartInfo) TimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, c } charData.CalculateNumericalValues(y, val, x.Field, chartType, "month", tayTimeing, charData.XAxis.Data) + // charData.SunDayCalculateValues(val, c.XSunAxis, c.YSunAxis, chartType, "month", charData.XAxis.Data) + charData.SunDayVal(x.Field, val, c.XSunAxis, c.YSunAxis, chartType, "month", charData.XAxis.Data) case "day": tayTimeing := int(time.Now().Day()) yearVal := publicmethod.UnixTimeToDay(tayTime, 15) - fmt.Printf("时间字段-1-->%v\n\n", tayTimeing) + // fmt.Printf("时间字段-1-->%v\n\n", tayTimeing) var timeList []string for i := 1; i <= tayTimeing; i++ { - timeList = append(timeList, fmt.Sprintf("%v-%v", yearVal, i)) + if i > 9 { + timeList = append(timeList, fmt.Sprintf("%v-%v", yearVal, i)) + } else { + timeList = append(timeList, fmt.Sprintf("%v-0%v", yearVal, i)) + } + } - fmt.Printf("时间字段-1-->%v-->%v\n\n", len(searchTime), searchTime) + // fmt.Printf("时间字段-1-->%v-->%v\n\n", len(searchTime), searchTime) if len(searchTime) > 0 { charData.XAxis.Data = searchTime } else { charData.XAxis.Data = timeList } charData.NewCalculateNumericalValues(y, val, x.Field, chartType, "day", tayTimeing, charData.XAxis.Data) + // charData.SunDayCalculateValues(val, c.XSunAxis, c.YSunAxis, chartType, "day", charData.XAxis.Data) + + charData.SunDayVal(x.Field, val, c.XSunAxis, c.YSunAxis, chartType, "day", charData.XAxis.Data) case "hour": var timeList []string @@ -91,6 +151,8 @@ func (c *ChartInfo) TimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, c charData.XAxis.Data = timeList } charData.CalculateNumericalValues(y, val, x.Field, chartType, "hour", hourInt, charData.XAxis.Data) + // charData.SunDayCalculateValues(val, c.XSunAxis, c.YSunAxis, chartType, "hour", charData.XAxis.Data) + charData.SunDayVal(x.Field, val, c.XSunAxis, c.YSunAxis, chartType, "hour", charData.XAxis.Data) case "minute": var timeList []string yearVal := publicmethod.UnixTimeToDay(tayTime, 9) @@ -105,6 +167,8 @@ func (c *ChartInfo) TimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, c charData.XAxis.Data = timeList } charData.CalculateNumericalValues(y, val, x.Field, chartType, "minute", hourInt, charData.XAxis.Data) + // charData.SunDayCalculateValues(val, c.XSunAxis, c.YSunAxis, chartType, "minute", charData.XAxis.Data) + charData.SunDayVal(x.Field, val, c.XSunAxis, c.YSunAxis, chartType, "minute", charData.XAxis.Data) case "second": var timeList []string yearVal := publicmethod.UnixTimeToDay(tayTime, 10) @@ -119,6 +183,8 @@ func (c *ChartInfo) TimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, c charData.XAxis.Data = timeList } charData.CalculateNumericalValues(y, val, x.Field, chartType, "second", hourInt, charData.XAxis.Data) + // charData.SunDayCalculateValues(val, c.XSunAxis, c.YSunAxis, chartType, "second", charData.XAxis.Data) + charData.SunDayVal(x.Field, val, c.XSunAxis, c.YSunAxis, chartType, "second", charData.XAxis.Data) default: var timeList []string yearVal := publicmethod.UnixTimeToDay(tayTime, 15) @@ -132,11 +198,14 @@ func (c *ChartInfo) TimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, c charData.XAxis.Data = timeList } charData.CalculateNumericalValues(y, val, x.Field, chartType, "month", tayTime, charData.XAxis.Data) + // charData.SunDayCalculateValues(val, c.XSunAxis, c.YSunAxis, chartType, "month", charData.XAxis.Data) + charData.SunDayVal(x.Field, val, c.XSunAxis, c.YSunAxis, chartType, "month", charData.XAxis.Data) } // xAxis := c.JieXiSearchTime() // if len(xAxis) > 0 { // charData.XAxis.Data = xAxis // } + fmt.Printf("\n\n\n%T------12138/--------->%v\n\n\n", charData.Series, charData.Series) return } @@ -146,10 +215,13 @@ func (c *ChartInfo) TimeDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, c func (b *BarDataInfo) NewCalculateNumericalValues(y []YAxisInfo, val interface{}, xField, chartType string, types string, lenght int, timeAry []string) { for _, v := range y { + + fmt.Printf("计算数值类型-------->%v\n\n\n", v.Method) // if i == 0 { var seriesInfo SeriesList seriesInfo.Name = v.OldTitle seriesInfo.Types = chartType + switch v.Method { case 2: seriesInfo.NewAverageValue(xField, v.Field, types, val, v.Format, timeAry) @@ -242,10 +314,10 @@ func (s *SeriesList) QuPingjunSumData(startTime, endTime int64, val interface{}, begTime = startTime eldTime = startTime } - // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) - // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) + // // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) + // // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) if begTime <= pageTime && pageTime <= eldTime { - // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) + // // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) if yzVal, isOk := mv[yField]; isOk { minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) if err == nil { @@ -253,10 +325,20 @@ func (s *SeriesList) QuPingjunSumData(startTime, endTime int64, val interface{}, jibuqi++ } } - + fmt.Printf("时间数组度量技术:\n\n%v======258=======>%v=======>%v\n\n", publicmethod.UnixTimeToDay(begTime, 14), sumVal, jibuqi) } - // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) + } + // if yzVal, isOk := mv[yField]; isOk { + + // fmt.Printf("纬度知:\n\n%v======1=======>%v\n\n", yField, yzVal) + + // minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + // if err == nil { + // sumVal = sumVal + minVal + // jibuqi++ + // } + // } } // fmt.Printf("时间数组:\n\n%v======1=======>%v======1=======>%v======1=======>%v\n\n", publicmethod.UnixTimeToDay(startTime, 14), xField, yField, sumVal) // jieguo = publicmethod.DataChuli(sumVal, format) @@ -268,6 +350,7 @@ func (s *SeriesList) QuPingjunSumData(startTime, endTime int64, val interface{}, jieguo = publicmethod.DataChuli(sumVal, format) } } + // fmt.Printf("时间数组囧恩:\n\n%v======1=======>%v======1=======>%v======1=======>%v\n\n", publicmethod.UnixTimeToDay(startTime, 14), xField, yField, jieguo) // if yVal, isOk := val.([]map[string]interface{}); isOk { // var sumVal float64 // jibuqi := 0 @@ -350,62 +433,68 @@ func (s *SeriesList) NewStatisticalQuantity(xField, yField, types string, val in s.Data = monthAry } func (s *SeriesList) QuJishuData(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { - // if yVal, isOk := val.([]map[string]interface{}); isOk { - // var valAry []float64 - // for _, mv := range yVal { - // if yVal, isOk := mv[yField]; isOk { - // if xVal, isOk := mv[xField]; isOk { - // pageTime, _ := publicmethod.StringToInt64(xVal) - // if publicmethod.GetIntLength(pageTime) >= 13 { - // startTime = startTime * 1000 - // endTime = endTime * 1000 - // } - // if startTime <= pageTime && pageTime <= endTime { - // minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) - // if err == nil { - - // valAry = append(valAry, minVal) - - // } - // } - // } - - // } - - // } - // jieguo = len(valAry) - // } if yVal, isOk := val.([]map[string]interface{}); isOk { var valAry []float64 for _, mv := range yVal { - if xVal, isOk := mv[xField]; isOk { - pageTime, _ := publicmethod.StringToInt64(xVal) - var begTime int64 - var eldTime int64 - if publicmethod.GetIntLength(pageTime) >= 13 { - begTime = startTime * 1000 - eldTime = endTime * 1000 - } else { - begTime = startTime - eldTime = startTime - } - // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) - // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) - if begTime <= pageTime && pageTime <= eldTime { - // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) - if yzVal, isOk := mv[yField]; isOk { - minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if yVal, isOk := mv[yField]; isOk { + if xVal, isOk := mv[xField]; isOk { + pageTime, _ := publicmethod.StringToInt64(xVal) + if publicmethod.GetIntLength(pageTime) >= 13 { + startTime = startTime * 1000 + endTime = endTime * 1000 + } + if startTime <= pageTime && pageTime <= endTime { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yVal), 64) if err == nil { + valAry = append(valAry, minVal) + } } - } - // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) + } + } jieguo = len(valAry) } + // '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''if yVal, isOk := val.([]map[string]interface{}); isOk { + // var valAry []float64 + // for _, mv := range yVal { + // // if xVal, isOk := mv[xField]; isOk { + // // pageTime, _ := publicmethod.StringToInt64(xVal) + // // var begTime int64 + // // var eldTime int64 + // // if publicmethod.GetIntLength(pageTime) >= 13 { + // // begTime = startTime * 1000 + // // eldTime = endTime * 1000 + // // } else { + // // begTime = startTime + // // eldTime = startTime + // // } + // // // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) + // // // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) + // // if begTime <= pageTime && pageTime <= eldTime { + // // // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) + // // if yzVal, isOk := mv[yField]; isOk { + // // minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + // // if err == nil { + // // valAry = append(valAry, minVal) + // // } + // // } + + // // } + // // // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) + // // } + // if yzVal, isOk := mv[yField]; isOk { + // minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + // if err == nil { + // valAry = append(valAry, minVal) + // } + // } + // } + // jieguo = len(valAry) + // }''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' return } @@ -485,32 +574,40 @@ func (s *SeriesList) QuChongData(startTime, endTime int64, val interface{}, xFie if yVal, isOk := val.([]map[string]interface{}); isOk { var valAry []float64 for _, mv := range yVal { - if xVal, isOk := mv[xField]; isOk { - pageTime, _ := publicmethod.StringToInt64(xVal) - var begTime int64 - var eldTime int64 - if publicmethod.GetIntLength(pageTime) >= 13 { - begTime = startTime * 1000 - eldTime = endTime * 1000 - } else { - begTime = startTime - eldTime = startTime - } - // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) - // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) - if begTime <= pageTime && pageTime <= eldTime { - // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) - if yzVal, isOk := mv[yField]; isOk { - minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) - if err == nil { - if !publicmethod.IsInTrue[float64](minVal, valAry) { - valAry = append(valAry, minVal) - } - } + // if xVal, isOk := mv[xField]; isOk { + // pageTime, _ := publicmethod.StringToInt64(xVal) + // var begTime int64 + // var eldTime int64 + // if publicmethod.GetIntLength(pageTime) >= 13 { + // begTime = startTime * 1000 + // eldTime = endTime * 1000 + // } else { + // begTime = startTime + // eldTime = startTime + // } + // // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) + // // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) + // if begTime <= pageTime && pageTime <= eldTime { + // // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) + // if yzVal, isOk := mv[yField]; isOk { + // minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + // if err == nil { + // if !publicmethod.IsInTrue[float64](minVal, valAry) { + // valAry = append(valAry, minVal) + // } + // } + // } + + // } + // // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) + // } + if yzVal, isOk := mv[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + if !publicmethod.IsInTrue[float64](minVal, valAry) { + valAry = append(valAry, minVal) } - } - // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) } } jieguo = len(valAry) @@ -599,36 +696,49 @@ func (s *SeriesList) QuMaxData(startTime, endTime int64, val interface{}, xField if yVal, isOk := val.([]map[string]interface{}); isOk { var sumVal float64 for i, mv := range yVal { - if xVal, isOk := mv[xField]; isOk { - pageTime, _ := publicmethod.StringToInt64(xVal) - var begTime int64 - var eldTime int64 - if publicmethod.GetIntLength(pageTime) >= 13 { - begTime = startTime * 1000 - eldTime = endTime * 1000 - } else { - begTime = startTime - eldTime = startTime - } - // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) - // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) - if begTime <= pageTime && pageTime <= eldTime { - // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) - if yzVal, isOk := mv[yField]; isOk { - minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) - if err == nil { - if i == 0 { - sumVal = minVal - } else { - if sumVal <= minVal { - sumVal = minVal - } - } + // if xVal, isOk := mv[xField]; isOk { + // pageTime, _ := publicmethod.StringToInt64(xVal) + // var begTime int64 + // var eldTime int64 + // if publicmethod.GetIntLength(pageTime) >= 13 { + // begTime = startTime * 1000 + // eldTime = endTime * 1000 + // } else { + // begTime = startTime + // eldTime = startTime + // } + // // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) + // // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) + // if begTime <= pageTime && pageTime <= eldTime { + // // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) + // if yzVal, isOk := mv[yField]; isOk { + // minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + // if err == nil { + // if i == 0 { + // sumVal = minVal + // } else { + // if sumVal <= minVal { + // sumVal = minVal + // } + // } + // } + // } + + // } + // // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) + // } + + if yzVal, isOk := mv[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + if i == 0 { + sumVal = minVal + } else { + if sumVal <= minVal { + sumVal = minVal } } - } - // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) } } jieguo = publicmethod.DataChuli(sumVal, format) @@ -717,36 +827,49 @@ func (s *SeriesList) QuMinData(startTime, endTime int64, val interface{}, xField if yVal, isOk := val.([]map[string]interface{}); isOk { var sumVal float64 for i, mv := range yVal { - if xVal, isOk := mv[xField]; isOk { - pageTime, _ := publicmethod.StringToInt64(xVal) - var begTime int64 - var eldTime int64 - if publicmethod.GetIntLength(pageTime) >= 13 { - begTime = startTime * 1000 - eldTime = endTime * 1000 - } else { - begTime = startTime - eldTime = startTime - } - // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) - // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) - if begTime <= pageTime && pageTime <= eldTime { - // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) - if yzVal, isOk := mv[yField]; isOk { - minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) - if err == nil { - if i == 0 { - sumVal = minVal - } else { - if sumVal >= minVal { - sumVal = minVal - } - } + // if xVal, isOk := mv[xField]; isOk { + // pageTime, _ := publicmethod.StringToInt64(xVal) + // var begTime int64 + // var eldTime int64 + // if publicmethod.GetIntLength(pageTime) >= 13 { + // begTime = startTime * 1000 + // eldTime = endTime * 1000 + // } else { + // begTime = startTime + // eldTime = startTime + // } + // // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) + // // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) + // if begTime <= pageTime && pageTime <= eldTime { + // // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) + // if yzVal, isOk := mv[yField]; isOk { + // minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + // if err == nil { + // if i == 0 { + // sumVal = minVal + // } else { + // if sumVal >= minVal { + // sumVal = minVal + // } + // } + // } + // } + + // } + // // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) + // } + + if yzVal, isOk := mv[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + if i == 0 { + sumVal = minVal + } else { + if sumVal >= minVal { + sumVal = minVal } } - } - // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) } } jieguo = publicmethod.DataChuli(sumVal, format) @@ -771,6 +894,7 @@ func (s *SeriesList) NewsumData(xField, yField, types string, val interface{}, f var monthAry []interface{} for _, v := range timeAry { // if i == 0 { + // fmt.Printf("%v---------%v\n\n", types, v) switch types { case "year": startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) @@ -786,7 +910,7 @@ func (s *SeriesList) NewsumData(xField, yField, types string, val interface{}, f startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) monthAry = append(monthAry, s.QuSumData(startTime, endTime, val, xField, yField, format)) - fmt.Printf("计算一天的数据:\n\n%v 到 %v 结果:%v\n\n", startTime, endTime, monthAry) + // fmt.Printf("计算一天%v的数据:\n\n%v 到 %v 结果:%v\n\n", v, startTime, endTime, monthAry) case "hour": startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) @@ -832,11 +956,12 @@ func (s *SeriesList) QuSumData(startTime, endTime int64, val interface{}, xField // } // jieguo = publicmethod.DataChuli(sumVal, format) // } - // fmt.Printf("时间数组:\n\n%v======3=======>%v\n\n", startTime, endTime) + fmt.Printf("时间数组:\n\n%v======3=======>%v\n\n", startTime, endTime) if yVal, isOk := val.([]map[string]interface{}); isOk { var sumVal float64 for _, mv := range yVal { if xVal, isOk := mv[xField]; isOk { + fmt.Printf("12345时间数组:\n\n%v======3=======>%v\n\n", startTime, xVal) pageTime, _ := publicmethod.StringToInt64(xVal) var begTime int64 var eldTime int64 @@ -847,8 +972,8 @@ func (s *SeriesList) QuSumData(startTime, endTime int64, val interface{}, xField begTime = startTime eldTime = endTime } - // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) - // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) + // // fmt.Printf("时间数组:\n\n%v==2====1==2=====>%v==2=====>%v\n\n", begTime, eldTime, pageTime) + // // fmt.Printf("技术只:\n\n%v======3=======>%v\n\n", begTime <= pageTime, pageTime <= endTime) if begTime <= pageTime && pageTime <= eldTime { // fmt.Printf("技术只:\n\n%v======1=======>%v\n\n", yField, pageTime) if yzVal, isOk := mv[yField]; isOk { @@ -859,11 +984,20 @@ func (s *SeriesList) QuSumData(startTime, endTime int64, val interface{}, xField } } - // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) + // // fmt.Printf("时间数组:\n\n%v======1=======>%v\n\n", yField, pageTime) } + + // if yzVal, isOk := mv[yField]; isOk { + // minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + // if err == nil { + // sumVal = sumVal + minVal + // } + // } } - fmt.Printf("时间数组:\n\n%v======1=======>%v======1=======>%v======1=======>%v\n\n", publicmethod.UnixTimeToDay(startTime, 14), xField, yField, sumVal) + // fmt.Printf("时间数组:\n\n%v======1=======>%v======1=======>%v======1=======>%v\n\n", publicmethod.UnixTimeToDay(startTime, 14), xField, yField, sumVal) jieguo = publicmethod.DataChuli(sumVal, format) + } else { + jieguo = 0 } return } diff --git a/api/version1/customChartesing/barRace.go b/api/version1/customChartesing/barRace.go index db9c2a8..1544064 100644 --- a/api/version1/customChartesing/barRace.go +++ b/api/version1/customChartesing/barRace.go @@ -31,6 +31,8 @@ func (c *ChartInfo) barRaceChart(val interface{}, untis []customerform.MasterStr func (c *ChartInfo) BarRaceDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, chartType string, untis []customerform.MasterStruct) (charData BarRace) { fmt.Printf("人员--->%v\n\n", val) var timeList []string //根据维度分组 + var SunWdList []SunWd + var allMasterKey []string if yVal, isOk := val.([]map[string]interface{}); isOk { fmt.Printf("人员--1->%v\n\n", yVal) for _, mv := range yVal { @@ -39,6 +41,14 @@ func (c *ChartInfo) BarRaceDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{} pageTime := publicmethod.TypeToInterface(xVal) if !publicmethod.IsInTrue[string](pageTime, timeList) { timeList = append(timeList, pageTime) + if mastKey, isok := mv["masters_key"]; isok { + mastKeyStr := publicmethod.TypeToInterface(mastKey) + var SunWdInfo SunWd + SunWdInfo.TitleVal = pageTime + SunWdInfo.MasterKey = mastKeyStr + allMasterKey = append(allMasterKey, mastKeyStr) + SunWdList = append(SunWdList, SunWdInfo) + } } } } @@ -54,8 +64,47 @@ func (c *ChartInfo) BarRaceDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{} } charData.Max = len(weiDu) charData.BarRaceAnalyRadarData(x.Field, weiDu, y, val) + if len(SunWdList) > 0 { + charData.SunWuTimeAnalyBarRace(SunWdList, c.XSunAxis, c.YSunAxis, chartType, allMasterKey) + } return } +func (b *BarRace) SunWuTimeAnalyBarRace(sunWdList []SunWd, x, y []SunTableSetup, chartType string, allMasterKey []string) { + dlValMap := AllSunTableGroup(x, y, allMasterKey) + var timeList []string + for _, v := range sunWdList { //x轴分布 + if !publicmethod.IsInTrue[string](v.TitleVal, timeList) { + timeList = append(timeList, v.TitleVal) + } + + } + // for _, v := range sunWdList { //x轴分布 + for _, dv := range dlValMap { + for _, yv := range y { + var seriesInfo SeriesList + titleStr := fmt.Sprintf("%v:%v-%v", dv.Title, dv.Label, yv.Title) + seriesInfo.Name = titleStr + seriesInfo.Types = chartType + + switch yv.Method { + case 2: + seriesInfo.AverageValuees(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 3: + seriesInfo.StatisticalQuantityes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 4: + seriesInfo.RemoveDuplicateCountss(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 5: + seriesInfo.maxDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 6: + seriesInfo.minDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + default: + seriesInfo.sumDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + } + + } + } + // } +} /* * diff --git a/api/version1/customChartesing/chartType.go b/api/version1/customChartesing/chartType.go index 2036dbc..0799e25 100644 --- a/api/version1/customChartesing/chartType.go +++ b/api/version1/customChartesing/chartType.go @@ -30,7 +30,8 @@ type LegendStruct struct { //渲染图标结构 type SeriesList struct { - Name string `json:"name"` - Data []interface{} `json:"data"` - Types string `json:"type"` + Name string `json:"name"` + Data []interface{} `json:"data"` + Types string `json:"type"` + ItemStyle ColorVal `json:"itemStyle"` } diff --git a/api/version1/customChartesing/formTable.go b/api/version1/customChartesing/formTable.go index acec647..aab7047 100644 --- a/api/version1/customChartesing/formTable.go +++ b/api/version1/customChartesing/formTable.go @@ -4,11 +4,13 @@ import ( "appPlatform/api/version1/customerform" datacenter "appPlatform/api/version1/dataCenter" "appPlatform/models/modelAppPlatform" + "appPlatform/models/modelshr" "appPlatform/overall" "appPlatform/overall/publicmethod" "encoding/json" "fmt" "sort" + "strconv" "strings" "time" @@ -52,7 +54,7 @@ func (a *ApiMethod) DimMeaFormTable(c *gin.Context) { var MeaList []ChartFieldInfo isCreaterTimg := true var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(requestData.Id, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(requestData.Id, "", formJsonCont.List, true) for _, v := range formUnitCont.MasterInfo { if v.Name == "creater_time" { isCreaterTimg = false @@ -60,7 +62,7 @@ func (a *ApiMethod) DimMeaFormTable(c *gin.Context) { if publicmethod.IsInTrue[string](v.Type, publicmethod.Dimension) { var dimInfo ChartFieldInfo dimInfo.Title = v.Item.Label - fmt.Printf("\n\n组件量化--->%v--->%v\n\n", v.Item.Label, v.Type) + // fmt.Printf("\n\n组件量化--->%v--->%v\n\n", v.Item.Label, v.Type) if publicmethod.IsInTrue[string](v.Type, publicmethod.TimeUint) { dimInfo.Type = 3 } else { @@ -83,33 +85,62 @@ func (a *ApiMethod) DimMeaFormTable(c *gin.Context) { MeaList = append(MeaList, meaInfo) } } - // for _, v := range formJsonCont.List { - // if v.Name == "creater_time" { - // isCreaterTimg = false - // } - // if publicmethod.IsInTrue[string](v.Type, publicmethod.Dimension) { - // var dimInfo ChartFieldInfo - // dimInfo.Title = v.Item.Label - // if publicmethod.IsInTrue[string](v.Type, publicmethod.TimeUint) { - // dimInfo.Type = 2 - // } else { - // dimInfo.Type = 1 - // } - // dimInfo.Field = v.Name - // DimList = append(DimList, dimInfo) - // } - // if publicmethod.IsInTrue[string](v.Type, publicmethod.Quantization) { - // var meaInfo ChartFieldInfo - // meaInfo.Title = v.Item.Label - // if publicmethod.IsInTrue[string](v.Type, publicmethod.TimeUint) { - // meaInfo.Type = 2 - // } else { - // meaInfo.Type = 1 - // } - // meaInfo.Field = v.Name - // MeaList = append(MeaList, meaInfo) - // } - // } + var SunMeaListAry []SunDimMea + var SunDimListAry []SunDimMea + //子表数据维度与量化字段统计 + SunMeaList := make(map[string][]ChartFieldInfo) + SunDimList := make(map[string][]ChartFieldInfo) + for _, v := range formUnitCont.SunFormInfo { + var sunMeatInfo ChartFieldInfo + var sunDimlInfo ChartFieldInfo + + var sunMeatInfoEs SunDimMea + var sunDimlInfoEs SunDimMea + for ni, nv := range v.UbitInfo { + + sunMeatInfoEs.TableKey = v.TableName + sunMeatInfoEs.TableName = v.TableTitle + + sunMeatInfo.Field = ni + sunMeatInfo.Title = nv.Item.Label + sunMeatInfo.TableKey = v.TableName + sunMeatInfo.Options = nv.Options + fmt.Printf("子表数据维度与量化字段统计\n\n%v------------>%v\n\n", ni, nv) + if publicmethod.IsInTrue[string](nv.Type, publicmethod.Dimension) { + if publicmethod.IsInTrue[string](nv.Type, publicmethod.TimeUint) { + sunMeatInfo.Type = 3 + } else { + sunMeatInfo.Type = 1 + } + SunMeaList[v.TableName] = append(SunMeaList[v.TableName], sunMeatInfo) + + sunMeatInfoEs.TableUnit = append(sunMeatInfoEs.TableUnit, sunMeatInfo) + } + + sunDimlInfoEs.TableKey = v.TableName + sunDimlInfoEs.TableName = v.TableTitle + + sunDimlInfo.Field = ni + sunDimlInfo.Title = nv.Item.Label + sunDimlInfo.TableKey = v.TableName + sunDimlInfo.Options = nv.Options + if publicmethod.IsInTrue[string](nv.Type, publicmethod.Quantization) { + if publicmethod.IsInTrue[string](nv.Type, publicmethod.TimeUint) { + sunDimlInfo.Type = 3 + } else { + sunDimlInfo.Type = 2 + } + SunDimList[v.TableName] = append(SunDimList[v.TableName], sunDimlInfo) + sunDimlInfoEs.TableUnit = append(sunDimlInfoEs.TableUnit, sunDimlInfo) + } + } + if len(sunMeatInfoEs.TableUnit) < 1 { + sunMeatInfoEs.TableUnit = sunDimlInfoEs.TableUnit + } + SunMeaListAry = append(SunMeaListAry, sunMeatInfoEs) + SunDimListAry = append(SunDimListAry, sunDimlInfoEs) + } + if isCreaterTimg { var dimInfoOther ChartFieldInfo dimInfoOther.Title = "创建时间" @@ -127,6 +158,10 @@ func (a *ApiMethod) DimMeaFormTable(c *gin.Context) { sendMap["dimList"] = DimList sendMap["meaList"] = MeaList sendMap["formUnitCont"] = formUnitCont + sendMap["sunMeaList"] = SunMeaList + sendMap["sunDimList"] = SunDimList + sendMap["SunMeaListAry"] = SunMeaListAry + sendMap["SunDimListAry"] = SunDimListAry publicmethod.Result(0, sendMap, c) } @@ -312,6 +347,9 @@ func (a *ApiMethod) AnalyzeChartData(c *gin.Context) { @ 功能: 解析柱状图 */ func (c *ChartInfo) AnalyzeBarChart(tableName string, formJsonCont customerform.CustomerFormMaster) interface{} { + + fmt.Printf("数据表--->%v\n\n\n", tableName) + var formList []map[string]interface{} var gormDb *gorm.DB if formJsonCont.Form.DataSource == "yes" { //外链表单 @@ -363,7 +401,7 @@ func (c *ChartInfo) AnalyzeBarChart(tableName string, formJsonCont customerform. return nil } - // fmt.Printf("\n\n%v\n\n", formList) + // fmt.Printf("获取查询结果\n\n%v\n\n", formList) return formList } @@ -571,3 +609,110 @@ func Dengshi(t int, field, val string) (sqlStr string) { } return } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-26 10:46:30 +@ 功能: 初始化个人图表配置及数据 +*/ +func (a *ApiMethod) GetMyChartSetupAndData(c *gin.Context) { + var requestData publicmethod.CommonId[string] + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(200, err, c, "数据参数错误!") + return + } + if requestData.Id == "" { + publicmethod.Result(200, err, c, "未知表单,不可操作!") + return + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + if userCont.Key == 0 { + publicmethod.Result(300, err, c, "未知操作人!登陆是否超时!") + return + } + var chartInfo modelAppPlatform.Mychart + chartInfo.GetCont(map[string]interface{}{"`tableKey`": requestData.Id, "`userKey`": userCont.Key}) + sendData := publicmethod.MapOut[string]() + if chartInfo.Uuid != 0 { + sendData["myChartId"] = strconv.FormatInt(chartInfo.Uuid, 10) + } else { + sendData["myChartId"] = "" + } + + if chartInfo.ChartView == "" { + sendData["chartList"] = []interface{}{} + + publicmethod.Result(0, sendData, c) + return + } + var chartList interface{} + json.Unmarshal([]byte(chartInfo.ChartView), &chartList) + sendData["chartList"] = chartList + publicmethod.Result(0, sendData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-29 14:01:49 +@ 功能: 保存跟人图表设置 +*/ +func (a *ApiMethod) SaveMyBiCharts(c *gin.Context) { + var requestData SaveChartSetup + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(1, err, c) + return + } + if requestData.TableKey == "" { + publicmethod.Result(1, requestData, c, "未知数据源表!") + return + } + var custForm modelAppPlatform.CustomerForm + err = custForm.GetCont(map[string]interface{}{"`tablename`": requestData.TableKey}, "chartView", "`signCode`") + if err != nil { + publicmethod.Result(1, requestData, c, "未知数据源表!不可添加!") + return + } + chartJson, err := json.Marshal(requestData.ChartList) + if err != nil { + publicmethod.Result(1, requestData, c, "图表数据不正确!不可写入!") + return + } + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + if userCont.Key == 0 { + publicmethod.Result(300, err, c, "未知操作人!登陆是否超时!") + return + } + var chartInfo modelAppPlatform.Mychart + chartInfo.GetCont(map[string]interface{}{"`tableKey`": requestData.TableKey, "`userKey`": userCont.Key}) + if chartInfo.Uuid != 0 { + var chartInfoSave modelAppPlatform.Mychart + saveData := publicmethod.MapOut[string]() + saveData["`chartView`"] = string(chartJson) + saveData["`editTime`"] = time.Now().Unix() + err = chartInfoSave.EiteCont(map[string]interface{}{"`uuid`": chartInfo.Uuid}, saveData) + if err != nil { + publicmethod.Result(1, err, c) + return + } + } else { + chartInfo.Uuid = publicmethod.GetUUid(1) + chartInfo.TableKey = requestData.TableKey + chartInfo.UserKey = userCont.Key + chartInfo.ChartView = string(chartJson) + chartInfo.EditTime = time.Now().Unix() + err = overall.CONSTANT_DB_AppPlatform.Create(&chartInfo).Error + if err != nil { + publicmethod.Result(1, err, c) + return + } + } + publicmethod.Result(0, err, c) +} diff --git a/api/version1/customChartesing/newAnaly.go b/api/version1/customChartesing/newAnaly.go new file mode 100644 index 0000000..06368ca --- /dev/null +++ b/api/version1/customChartesing/newAnaly.go @@ -0,0 +1,579 @@ +package customChartesing + +import ( + "appPlatform/overall/publicmethod" + "fmt" + "strconv" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-22 15:56:52 +@ 功能: 以时间线为主的子表数据处理 +1:求和;2:平均值;3:计数;4:去重计数;5:最大值;6:最小值 +当字段为时间类型时. 1:自动(原始值);2:整数;3:保留1位小数;4:保留2位小数;5:百分比;6:百分比1位小数;7:百分比2位小数; +# masterFiled 主表维度字段 +# masterVal 主表相关数据 +# val 子表所有数据 +# x ,y 子表维度于度量 +# chartType 图表类型 +# types 时间类型 +*/ +func (b *BarDataInfo) SunDayVal(masterFiled string, masterVal interface{}, x, y []SunTableSetup, chartType, types string, timeAry []string) { + var dataMastKey []string + if valMapAry, isOk := masterVal.([]map[string]interface{}); isOk { + for _, v := range valMapAry { + if mastKey, isok := v["masters_key"]; isok { + + key := publicmethod.TypeToInterface(mastKey) + if !publicmethod.IsInTrue[string](key, dataMastKey) { + dataMastKey = append(dataMastKey, key) + + } + } + + } + } + if len(dataMastKey) > 0 { + var SunTabelName []string //子表名称 + var weiduDataMap []EveryOneSunTableData //子表数据 + for _, v := range x { + if !publicmethod.IsInTrue[string](v.TableKey, SunTabelName) { + SunTabelName = append(SunTabelName, v.TableKey) + weiduDataMap = append(weiduDataMap, SunTableDataList(v, dataMastKey)) + } + } + if len(weiduDataMap) > 0 { //存在子表数据 + for _, v := range weiduDataMap { + for _, lv := range v.List { //每个子表数据 + for _, yv := range y { //子表度量字段 + var seriesInfo SeriesList //输出单元 + titleStr := fmt.Sprintf("%v:%v-%v", lv.Title, lv.Label, yv.Title) + seriesInfo.Name = titleStr + seriesInfo.Types = chartType + if !publicmethod.IsInTrue[string](titleStr, b.Legend.Data) { + b.Legend.Data = append(b.Legend.Data, titleStr) + } + switch yv.Method { //结算类型 + case 2: + seriesInfo.SunSumDataNewAverage(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) + case 3: + seriesInfo.SunSumDataNewjs(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) + case 4: + seriesInfo.SunSumDataNewQcjs(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) + case 5: + seriesInfo.SunSumDataNewMax(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) + case 6: + seriesInfo.SunSumDataNewMin(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) + default: + // seriesInfo.SunSumData(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) + seriesInfo.SunSumDataNew(masterFiled, masterVal, lv.List, lv.Field, yv.Field, types, yv.Format, timeAry) + + } + b.Series = append(b.Series, seriesInfo) + } + } + } + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 09:13:23 +@ 功能: 求最小值 +*/ +func (s *SeriesList) SunSumDataNewMin(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime.AllTime, sunListDate, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMin(startTime, endTime, sunListDate, xField, yField, format)) + default: + } + } + s.Data = monthAry +} + +/* +*AA +@ 作者: 秦东 +@ 时间: 2025-09-23 09:14:05 +@ 功能: 计算最大着 +*/ +func (s *SeriesList) QuSumDataNewMin(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { + + if yVal, isOk := val.([]interface{}); isOk { + var sumVal float64 + for i, mv := range yVal { + if mapVal, isOk := mv.(map[string]interface{}); isOk { + if yzVal, isOk := mapVal[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + if i == 0 { + sumVal = minVal + } else { + if sumVal >= minVal { + sumVal = minVal + } + } + } + } + } + + } + jieguo = publicmethod.DataChuli(sumVal, format) + } else { + jieguo = 0 + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 08:57:58 +@ 功能: 求最大值 +*/ +func (s *SeriesList) SunSumDataNewMax(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime.AllTime, sunListDate, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewMax(startTime, endTime, sunListDate, xField, yField, format)) + default: + } + } + s.Data = monthAry +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 09:14:05 +@ 功能: 计算最大着 +*/ +func (s *SeriesList) QuSumDataNewMax(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { + + if yVal, isOk := val.([]interface{}); isOk { + var sumVal float64 + for i, mv := range yVal { + if mapVal, isOk := mv.(map[string]interface{}); isOk { + if yzVal, isOk := mapVal[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + if i == 0 { + sumVal = minVal + } else { + if sumVal <= minVal { + sumVal = minVal + } + } + } + } + } + + } + jieguo = publicmethod.DataChuli(sumVal, format) + } else { + jieguo = 0 + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 09:03:55 +@ 功能: 去重计数 +*/ +func (s *SeriesList) SunSumDataNewQcjs(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime.AllTime, sunListDate, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewQcjs(startTime, endTime, sunListDate, xField, yField, format)) + default: + } + } + s.Data = monthAry +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 08:04:59 +@ 功能:计数 +*/ +func (s *SeriesList) QuSumDataNewQcjs(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { + + if yVal, isOk := val.([]interface{}); isOk { + var valAry []float64 + for _, mv := range yVal { + if mapVal, isOk := mv.(map[string]interface{}); isOk { + if yzVal, isOk := mapVal[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + if !publicmethod.IsInTrue[float64](minVal, valAry) { + valAry = append(valAry, minVal) + } + } + } + } + + } + jieguo = len(valAry) + // jieguo = publicmethod.DataChuli(sumVal, format) + } else { + jieguo = 0 + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 09:03:55 +@ 功能: 计数 +*/ +func (s *SeriesList) SunSumDataNewjs(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime.AllTime, sunListDate, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewjs(startTime, endTime, sunListDate, xField, yField, format)) + default: + } + } + s.Data = monthAry +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 08:04:59 +@ 功能:计数 +*/ +func (s *SeriesList) QuSumDataNewjs(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { + + if yVal, isOk := val.([]interface{}); isOk { + var valAry []float64 + for _, mv := range yVal { + if mapVal, isOk := mv.(map[string]interface{}); isOk { + if yzVal, isOk := mapVal[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + valAry = append(valAry, minVal) + } + } + } + + } + jieguo = len(valAry) + // jieguo = publicmethod.DataChuli(sumVal, format) + } else { + jieguo = 0 + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 08:58:06 +@ 功能: 求平均值 +*/ +func (s *SeriesList) SunSumDataNewAverage(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime.AllTime, sunListDate, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNewpj(startTime, endTime, sunListDate, xField, yField, format)) + default: + } + } + s.Data = monthAry +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 08:04:59 +@ 功能:平均值 +*/ +func (s *SeriesList) QuSumDataNewpj(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { + + if yVal, isOk := val.([]interface{}); isOk { + var sumVal float64 + jibuqi := len(yVal) + for _, mv := range yVal { + if mapVal, isOk := mv.(map[string]interface{}); isOk { + if yzVal, isOk := mapVal[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + sumVal = sumVal + minVal + } + } + } + + } + if jibuqi > 0 { + avgVal := sumVal / float64(jibuqi) + jieguo = publicmethod.DataChuli(avgVal, format) + } else { + jieguo = 0 + } + // jieguo = publicmethod.DataChuli(sumVal, format) + } else { + jieguo = 0 + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 08:57:58 +@ 功能: 求和 +*/ +func (s *SeriesList) SunSumDataNew(masterFiled string, masterVal, sunVal interface{}, xField, yField, types string, format int, timeAry []string) { + var monthAry []interface{} + for _, v := range timeAry { + switch types { + case "year": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01-01 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-12-31 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format)) + case "month": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-01 00:00:00", v)) + yearValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 16)) + monthValInt, _ := strconv.Atoi(publicmethod.UnixTimeToDay(startTime, 17)) + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + sunListDate := MasterToSunData(startTime, endTime.AllTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime.AllTime, sunListDate, xField, yField, format)) + case "day": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 00:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v 23:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format)) + case "hour": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format)) + case "minute": + startTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:00", v)) + endTime := publicmethod.DateToTimeStampOld(fmt.Sprintf("%v:59", v)) + sunListDate := MasterToSunData(startTime, endTime, masterFiled, masterVal, sunVal) + monthAry = append(monthAry, s.QuSumDataNew(startTime, endTime, sunListDate, xField, yField, format)) + default: + } + } + s.Data = monthAry +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-23 08:04:59 +@ 功能: +*/ +func (s *SeriesList) QuSumDataNew(startTime, endTime int64, val interface{}, xField, yField string, format int) (jieguo interface{}) { + + if yVal, isOk := val.([]interface{}); isOk { + var sumVal float64 + for _, mv := range yVal { + if mapVal, isOk := mv.(map[string]interface{}); isOk { + if yzVal, isOk := mapVal[yField]; isOk { + minVal, err := strconv.ParseFloat(publicmethod.TypeToInterface(yzVal), 64) + if err == nil { + sumVal = sumVal + minVal + } + } + } + + } + jieguo = publicmethod.DataChuli(sumVal, format) + } else { + jieguo = 0 + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-09-22 16:55:06 +@ 功能: 获取当前时间段内的主数据,然后推导出当此时间段中的子数据 +*/ +func MasterToSunData(startTime, endTime int64, masterFiled string, masterVal, sunVal interface{}) interface{} { + var dataMastKey []string + if mVal, isOk := masterVal.([]map[string]interface{}); isOk { + for _, mv := range mVal { + if xVal, isOk := mv[masterFiled]; isOk { + pageTime, _ := publicmethod.StringToInt64(xVal) + var begTime int64 + var eldTime int64 + if publicmethod.GetIntLength(pageTime) >= 13 { + if publicmethod.GetIntLength(startTime) < 13 { + begTime = startTime * 1000 + } + if publicmethod.GetIntLength(endTime) < 13 { + eldTime = endTime * 1000 + } + } else { + begTime = startTime + eldTime = endTime + } + if begTime <= pageTime && pageTime <= eldTime { + if mastKey, isok := mv["masters_key"]; isok { + key := publicmethod.TypeToInterface(mastKey) + if !publicmethod.IsInTrue[string](key, dataMastKey) { + dataMastKey = append(dataMastKey, key) + } + } + } + } + } + } + var sunListData []interface{} + if sVal, isOk := sunVal.([]map[string]interface{}); isOk { + for _, mv := range sVal { + if mastKey, isok := mv["masters_key"]; isok { + key := publicmethod.TypeToInterface(mastKey) + if publicmethod.IsInTrue[string](key, dataMastKey) { + sunListData = append(sunListData, mv) + } + } + } + } + return sunListData +} diff --git a/api/version1/customChartesing/radar.go b/api/version1/customChartesing/radar.go index 6cd04f1..c609f7c 100644 --- a/api/version1/customChartesing/radar.go +++ b/api/version1/customChartesing/radar.go @@ -524,6 +524,8 @@ func TianJiaCanshu(val float64) float64 { // 普通字段 func (c *ChartInfo) RadarDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, chartType string, untis []customerform.MasterStruct) (charData RadarInfo) { var timeList []string //根据维度分组 + var SunWdList []SunWd + var allMasterKey []string if yVal, isOk := val.([]map[string]interface{}); isOk { for _, mv := range yVal { @@ -532,6 +534,14 @@ func (c *ChartInfo) RadarDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, pageTime := publicmethod.TypeToInterface(xVal) if !publicmethod.IsInTrue[string](pageTime, timeList) { timeList = append(timeList, pageTime) + if mastKey, isok := mv["masters_key"]; isok { + mastKeyStr := publicmethod.TypeToInterface(mastKey) + var SunWdInfo SunWd + SunWdInfo.TitleVal = pageTime + SunWdInfo.MasterKey = mastKeyStr + allMasterKey = append(allMasterKey, mastKeyStr) + SunWdList = append(SunWdList, SunWdInfo) + } } } } @@ -547,9 +557,50 @@ func (c *ChartInfo) RadarDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, weiDu = append(weiDu, weiduInfo) } charData.AnalyRadarData(x.Field, weiDu, y, val) + if len(SunWdList) > 0 { + charData.SunWuTimeAnalyRang(SunWdList, c.XSunAxis, c.YSunAxis, chartType, allMasterKey) + } return } +func (b *RadarInfo) SunWuTimeAnalyRang(sunWdList []SunWd, x, y []SunTableSetup, chartType string, allMasterKey []string) { + dlValMap := AllSunTableGroup(x, y, allMasterKey) + var timeList []string + for _, v := range sunWdList { //x轴分布 + if !publicmethod.IsInTrue[string](v.TitleVal, timeList) { + timeList = append(timeList, v.TitleVal) + } + + } + // for _, v := range sunWdList { //x轴分布 + for _, dv := range dlValMap { + for _, yv := range y { + var seriesInfo SeriesList + titleStr := fmt.Sprintf("%v:%v-%v", dv.Title, dv.Label, yv.Title) + seriesInfo.Name = titleStr + seriesInfo.Types = chartType + + switch yv.Method { + case 2: + seriesInfo.AverageValuees(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 3: + seriesInfo.StatisticalQuantityes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 4: + seriesInfo.RemoveDuplicateCountss(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 5: + seriesInfo.maxDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + case 6: + seriesInfo.minDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + default: + seriesInfo.sumDataes(dv.Field, yv.Field, timeList, dv.List, yv.Format) + } + + // b.Series = append(b.Series, seriesInfo) + } + } + // } +} + /* * @ 作者: 秦东 diff --git a/api/version1/customChartesing/target.go b/api/version1/customChartesing/target.go index b2e4f37..e781501 100644 --- a/api/version1/customChartesing/target.go +++ b/api/version1/customChartesing/target.go @@ -441,6 +441,8 @@ func (t *TargetInfo) TimesumDataes(y YAxisInfo, val interface{}, format int) { */ func (c *ChartInfo) TargetDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, chartType string, untis []customerform.MasterStruct) (charData []TargetInfo) { var timeList []string //根据维度分组 + var SunWdList []SunWd + var allMasterKey []string if yVal, isOk := val.([]map[string]interface{}); isOk { for _, mv := range yVal { if xVal, isOk := mv[x.Field]; isOk { @@ -448,6 +450,14 @@ func (c *ChartInfo) TargetDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, pageTime := publicmethod.TypeToInterface(xVal) if !publicmethod.IsInTrue[string](pageTime, timeList) { timeList = append(timeList, pageTime) + if mastKey, isok := mv["masters_key"]; isok { + mastKeyStr := publicmethod.TypeToInterface(mastKey) + var SunWdInfo SunWd + SunWdInfo.TitleVal = pageTime + SunWdInfo.MasterKey = mastKeyStr + allMasterKey = append(allMasterKey, mastKeyStr) + SunWdList = append(SunWdList, SunWdInfo) + } } } } @@ -460,6 +470,9 @@ func (c *ChartInfo) TargetDataAnaly(x XAxisInfo, y []YAxisInfo, val interface{}, charInfo.AnalyRadarData(x.Field, v, y, val) charData = append(charData, charInfo) } + if len(SunWdList) > 0 { + // charData.SunWuTimeAnaly(SunWdList, c.XSunAxis, c.YSunAxis, chartType, allMasterKey) + } return } diff --git a/api/version1/customChartesing/type.go b/api/version1/customChartesing/type.go index 37f02be..f10e204 100644 --- a/api/version1/customChartesing/type.go +++ b/api/version1/customChartesing/type.go @@ -39,16 +39,21 @@ func (a *ApiMethod) Index(c *gin.Context) { @ 功能: 字段图表格式 */ type ChartFieldInfo struct { - Title string `json:"title"` - Type int `json:"type"` //1:普通类;2:时间类 - Field string `json:"field"` - Options []customerform.OptionsStruct `json:"options"` + Title string `json:"title"` + Type int `json:"type"` //1:普通类;2:时间类 + Field string `json:"field"` + TableKey string `json:"tableKey"` //表单识别符 + Options []customerform.OptionsStruct `json:"options"` } type OptionsInfo struct { Label string `json:"label"` Value string `json:"value"` } +// 子表相关字段 +type SunChartFieldInfo struct { +} + /* * @ 作者: 秦东 @@ -67,16 +72,19 @@ type SaveChartSetup struct { @ 功能: 提交设定的结构体 */ type ChartInfo struct { - Uuid string `json:"uuid"` - Icon string `json:"icon"` - Type string `json:"type"` - Title string `json:"title"` - WidthBox int `json:"widthBox"` - YAxis []YAxisInfo `json:"y"` - XAxis []XAxisInfo `json:"x"` - Filter []FilterInfo `json:"filter"` - TimeLength int `json:"timelength"` - Search interface{} `json:"search"` + Uuid string `json:"uuid"` + Icon string `json:"icon"` + Type string `json:"type"` + Title string `json:"title"` + WidthBox int `json:"widthBox"` + YAxis []YAxisInfo `json:"y"` + XAxis []XAxisInfo `json:"x"` + YSunAxis []SunTableSetup `json:"ysun"` + XSunAxis []SunTableSetup `json:"xsun"` + Filter []FilterInfo `json:"filter"` + SunFilter []SunTableSetup `json:"sunFilter"` + TimeLength int `json:"timelength"` + Search interface{} `json:"search"` } type ChartInfoTest struct { Uuid string `json:"uuid"` @@ -91,6 +99,20 @@ type ChartInfoTest struct { Search interface{} `json:"search"` } +// 子表设定 +type SunTableSetup struct { + Types int `json:"type"` + Title string `json:"title"` + TableKey string `json:"tableKey"` + Field string `json:"field"` + Options interface{} `json:"options"` + Meadim int `json:"meadim"` + OldTitle string `json:"oldTitle"` + TimeType string `json:"timeType"` + Method int `json:"method"` + Format int `json:"format"` +} + /* * @ 作者: 秦东 @@ -270,3 +292,44 @@ type RadarTimeInfo struct { XName string DataVal []map[string]interface{} } + +// 指标纬度与度量统一格式 +type SunDimMea struct { + TableName string `json:"tableName"` + TableKey string `json:"tableKey"` + TableUnit []ChartFieldInfo `json:"tableUnit"` +} + +// 每个子表得数据 +type EveryOneSunTableData struct { + TableName string + List []WeiDuInfos +} + +type WeiDuInfos struct { + Field string `json:"field"` + Title string + DataVal string + Label string + List []map[string]interface{} +} + +// 不以时间为维度 +type SunWd struct { + TitleVal string + MasterKey string +} + +type ColorValue struct { + Value interface{} `json:"value"` + ItemStyle ColorVal `json:"itemStyle"` +} + +type ColorVal struct { + Color interface{} `json:"color"` +} + +// 接受个人图表设置 +type MyBiCharts struct { + TableKey string `json:"tableKey"` +} diff --git a/api/version1/customerApp/appControll.go b/api/version1/customerApp/appControll.go index 373abb6..bb7f5a1 100644 --- a/api/version1/customerApp/appControll.go +++ b/api/version1/customerApp/appControll.go @@ -279,15 +279,23 @@ func (a *ApiMethod) GainAppEditPsge(c *gin.Context) { publicmethod.Result(102, err, c) return } - var appCont modelAppPlatform.CustomerFormView + // var appCont modelAppPlatform.CustomerFormView + var appCont CallBackFormStruct err = appCont.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": requestData.Id}) if err != nil { publicmethod.Result(105, err, c) return } + if appCont.PowerStr != "" { + // var powAry []NodePowerInfoNew + json.Unmarshal([]byte(appCont.PowerStr), &appCont.PowerAry) + // tableFormPage.PowerAry = powAry + } + sendInfo := publicmethod.MapOut[string]() sendInfo["appName"] = appCont.Name + sendInfo["powerAry"] = appCont.PowerAry sendInfo["appKey"] = appCont.TableKey sendInfo["uuid"] = strconv.FormatInt(appCont.SignCode, 10) sendInfo["state"] = appCont.Status @@ -1483,12 +1491,18 @@ func (a *ApiMethod) GainAppPageInfo(c *gin.Context) { publicmethod.Result(102, err, c) return } - var appFormPage modelAppPlatform.CustomerFormView + // var appFormPage modelAppPlatform.CustomerFormView + var appFormPage CallBackFormStruct err = appFormPage.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": requestData.Id}) if err != nil { publicmethod.Result(105, err, c) return } + if appFormPage.PowerStr != "" { + // var powAry []NodePowerInfoNew + json.Unmarshal([]byte(appFormPage.PowerStr), &appFormPage.PowerAry) + // tableFormPage.PowerAry = powAry + } context, _ := c.Get(overall.MyContJwt) var userCont modelshr.ManCont @@ -1506,6 +1520,7 @@ func (a *ApiMethod) GainAppPageInfo(c *gin.Context) { // return sendData := publicmethod.MapOut[string]() sendData["appForm"] = appFormPage + sendData["powerAry"] = appFormPage.PowerAry sendData["versionId"] = strconv.FormatInt(appFormPage.Id, 10) sendData["flowkey"] = strconv.FormatInt(appFormPage.Flowkey, 10) sendData["groupid"] = strconv.FormatInt(appFormPage.Groupid, 10) @@ -1532,13 +1547,13 @@ func (a *ApiMethod) GainAppPageInfo(c *gin.Context) { sendData["chartList"] = chartList sendData["appFlow"] = false if appFormPage.FlowIsOpen == 1 { - + var flowInfor FlowMainBody var appFormFlow modelAppPlatform.FlowVersion - err = appFormFlow.GetCont(map[string]interface{}{"`state`": 1, "`key`": appFormPage.Flowkey}, "`content`") + err = appFormFlow.GetCont(map[string]interface{}{"`state`": 1, "`key`": appFormPage.Flowkey}) if err != nil { sendData["workFlow"] = "" } else { - var flowInfor interface{} + // var flowInfor interface{} err = json.Unmarshal([]byte(appFormFlow.Content), &flowInfor) if err != nil { sendData["workFlow"] = "" @@ -1546,11 +1561,14 @@ func (a *ApiMethod) GainAppPageInfo(c *gin.Context) { sendData["workFlow"] = flowInfor sendData["appFlow"] = true } + var wordKey []string + sendData["channerUpdate"] = flowInfor.NodeConfig.BianLiShiyongWork(wordKey) } - + sendData["nodeKey"] = flowInfor.NodeConfig.NodeNumber } else { sendData["workFlow"] = "" } + var fieldList []string if appFormPage.TableKey != "" { masterFieldAry, mastErr := customerform.ReadDatabaseForm(appFormPage.TableKey) @@ -1583,6 +1601,86 @@ func (a *ApiMethod) GainAppPageInfo(c *gin.Context) { publicmethod.Result(0, sendData, c) } +// 遍历流程所有节点 +func (n *NodePublicInfo) BianLiShiyongWork(wordKey []string) []string { + //判断节点类型 0:发起人;1:审批;2:抄送;3:执行人;4:条件;5:路由 + switch n.Types { + case 1, 3: + if n.Settype == 8 { + for _, v := range n.NodeUserList { + fmt.Printf("\n\n\n遍历流程所有节点--------1---------->%v\n\n\n", v.Id) + if !publicmethod.IsInTrue[string](v.Id, wordKey) { + wordKey = append(wordKey, v.Id) + } + } + } + if n.ChildNode != nil { + + return n.ChildNode.BianLiShiyongWork(wordKey) + } + case 2: + if n.Settype == 8 { + for _, v := range n.NodeUserList { + fmt.Printf("\n\n\n遍历流程所有节点--------2--------->%v\n\n\n", v.Id) + if !publicmethod.IsInTrue[string](v.Id, wordKey) { + wordKey = append(wordKey, v.Id) + } + } + } + if n.ChildNode != nil { + + return n.ChildNode.BianLiShiyongWork(wordKey) + } + case 4: + case 5: + if len(n.ConditionNodes) > 0 { + for _, v := range n.ConditionNodes { + if len(v.ConditionList) > 0 { + for _, cv := range v.ConditionList { + if !publicmethod.IsInTrue[string](cv.Factorid, wordKey) { + wordKey = append(wordKey, cv.Factorid) + } + if len(cv.CustomFields) > 0 { + for _, fv := range cv.CustomFields { + fmt.Printf("\n\n\n遍历流程所有节点---%v-----3----%v------>%v\n\n\n", v.NodeName, cv.Types, fv.Wordfield) + if !publicmethod.IsInTrue[string](fv.Wordfield, wordKey) { + wordKey = append(wordKey, fv.Wordfield) + } + } + } + // switch cv.Types { + // case 3: + // if len(cv.CustomFields) > 0 { + // for _, fv := range cv.CustomFields { + // fmt.Printf("\n\n\n遍历流程所有节点---%v-----3----%v------>%v\n\n\n", v.NodeName, cv.Types, fv.Wordfield) + // if !publicmethod.IsInTrue[string](fv.Wordfield, wordKey) { + // wordKey = append(wordKey, fv.Wordfield) + // } + // } + // } + // default: + // fmt.Printf("\n\n\n遍历流程所有节点---%v-----4---%v------->%v\n\n\n", v.NodeName, cv.Types, cv.Factorid) + // if !publicmethod.IsInTrue[string](cv.Factorid, wordKey) { + // wordKey = append(wordKey, cv.Factorid) + // } + // } + } + } + } + } + if n.ChildNode != nil { + + return n.ChildNode.BianLiShiyongWork(wordKey) + } + default: + if n.ChildNode != nil { + + return n.ChildNode.BianLiShiyongWork(wordKey) + } + } + return wordKey +} + /* * @ 作者: 秦东 diff --git a/api/version1/customerApp/commont.go b/api/version1/customerApp/commont.go new file mode 100644 index 0000000..daefb37 --- /dev/null +++ b/api/version1/customerApp/commont.go @@ -0,0 +1,607 @@ +package customerApp + +import ( + "appPlatform/middleware/grocerystore" + "appPlatform/models/customerForm" + "appPlatform/models/modelshr" + "appPlatform/models/teamlog" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/csv" + "encoding/json" + "fmt" + "mime/multipart" + "path" + "strconv" + "strings" + "time" + + "github.com/360EntSecGroup-Skylar/excelize" + "github.com/gin-gonic/gin" + "golang.org/x/text/encoding/simplifiedchinese" + "golang.org/x/text/transform" +) + +var RongXinArrOrg []modelshr.AdministrativeOrganization + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-18 14:16:25 +@ 功能: 下载排班模板 +*/ +func (a *ApiMethod) DownLoadDutyPage(c *gin.Context) { + orgId := c.Query("orgid") //哪个行政组织 + types := c.Query("types") //什么类型 + timeVal := c.Query("timeval") //时间 + if orgId == "undefined" || orgId == "" || orgId == "" { + fmt.Printf("%v--%v--%v", orgId, types, timeVal) + return + } + // var orgInfo modelshr.AdministrativeOrganization + // err := orgInfo.GetCont(map[string]interface{}{"`id`": orgId}) + +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-19 08:09:34 +@ 功能: 上传文档并解析(Redis) +*/ +func (a *ApiMethod) UploadFilesRedis(c *gin.Context) { + orgId := c.Request.FormValue("orgId") + types := c.Request.FormValue("types") + dateTime := c.Request.FormValue("dateTime") //附加参数 + fileInfo, fileHeader, fileErr := c.Request.FormFile("file") //上传的文件 + if fileErr != nil { + publicmethod.Result(200, fileErr, c) + return + } + defer fileInfo.Close() + // fmt.Printf("argVal-dateTime-->%T--->%v\n\n\n", orgId, orgId) + // fmt.Printf("argVal-types-->%T--->%v\n\n\n", types, types) + // fmt.Printf("argVal-dateTime-->%T--->%v\n\n\n", dateTime, dateTime) + + if orgId == "" { + publicmethod.Result(200, fileErr, c, "未知行政组织!数据不可导入!") + return + } + typesInt := 1 + if types != "" { + typesVal, _ := strconv.Atoi(types) + if typesVal > 0 { + typesInt = typesVal + } + } + currTime := time.Now().Unix() + if dateTime != "" { + currTimes, _ := strconv.ParseInt(dateTime, 10, 64) + if currTimes > 0 { + if publicmethod.GetIntLength(currTimes) >= 13 { + currTime = currTimes / 1000 + } else { + currTime = currTimes + } + + } + } + encoding := c.Request.FormValue("encoding") + if encoding == "" { + encoding = "utf-8" // 默认使用UTF-8 + } + // fmt.Printf("argVal-currTime-->%T--->%v\n\n\n", currTime, currTime) + // fmt.Printf("argVal-encoding-->%T--->%v\n\n\n", encoding, encoding) + tageExt := path.Ext(fileHeader.Filename) //获取文件后缀 + fileType := publicmethod.JudgeUpFileType(tageExt) + if fileType != 5 && fileType != 6 { + publicmethod.Result(200, fileType, c, "您上传的不是电子表格!请上传正确的文件!") + return + } + orgIdInt, _ := strconv.ParseInt(orgId, 10, 64) + var orgCont []string + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`name`").Where("`superior` = ?", orgId).Find(&orgCont) + if len(orgCont) < 1 { + publicmethod.Result(200, orgCont, c, "未知行政组织!数据不可导入") + return + } + redisListKey := fmt.Sprintf("ExcelCsvImport:List:u_%v_%v", orgId, publicmethod.GetUUid(1)) //获取当前列表的Key + sendData := publicmethod.MapOut[string]() + sendData["redisKey"] = redisListKey + isTrue := true + callBackMsg := "" + switch fileType { + case 5: + xlsx, err := excelize.OpenReader(fileInfo) //读取文件内容 + if err != nil { + publicmethod.Result(2, xlsx, c, tageExt) + return + } + rows := xlsx.GetRows(xlsx.GetSheetName(xlsx.GetActiveSheetIndex())) + fmt.Printf("row--->%T\n\n\n", rows) + if len(rows) < 1 { + publicmethod.Result(200, err, c, "你没有写入数据!") + return + } + sendData["total"], callBackMsg, isTrue = ParseExcelCsvData(rows, orgCont, typesInt, orgIdInt, currTime, redisListKey) + case 6: + // xlsx := csv.NewReader() + records, err := ReadCSVFromMultipartFileWithEncoding(fileInfo, "gbk") + if err != nil || len(records) < 1 { + publicmethod.Result(200, err, c, "你没有写入数据!") + return + } + sendData["total"], callBackMsg, isTrue = ParseExcelCsvData(records, orgCont, typesInt, orgIdInt, currTime, redisListKey) + default: + + } + if !isTrue { + publicmethod.Result(200, sendData, c, callBackMsg) + return + } + publicmethod.Result(0, sendData, c) +} + +// File读取CSV数据 +func ReadCSVFromMultipartFileWithEncoding(file multipart.File, encoding string) ([][]string, error) { + var reader *csv.Reader + + // 根据指定的编码创建相应的reader + switch encoding { + case "gbk", "gb2312": + // 创建GBK解码器 + gbkReader := transform.NewReader(file, simplifiedchinese.GBK.NewDecoder()) + reader = csv.NewReader(gbkReader) + case "utf-8", "utf8": + fallthrough + default: + // 默认使用UTF-8 + reader = csv.NewReader(file) + } + + // 设置CSV选项 + reader.Comma = ',' // 设置分隔符 + reader.LazyQuotes = true // 允许非标准的引号 + + // 读取所有记录 + records, err := reader.ReadAll() + if err != nil { + return nil, fmt.Errorf("读取CSV失败: %w", err) + } + + return records, nil +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-19 11:44:51 +@ 功能: 解析数据 + +#row 多数的表格数据 +#orgList 行政组织列表 +#types 1:按月;非1:按天 +#orgIdInt 公司 +#redisKey redis唯一识别符 +*/ +func ParseExcelCsvData(row [][]string, orgList []string, types int, orgIdInt, currTime int64, redisKey string) (totalNum int, msg string, isOk bool) { + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) + redisClient.SetRedisTime(86400) + year, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 16)) + month, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 17)) + day, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 18)) + for i, v := range row { + // for vi, vv := range v { + // fmt.Printf("%v-%v:%v\n\n", i, vi, vv) + // if i == 1 && vi == 0 { + // if types == 1 { + // var timeVal publicmethod.DateTimeTotimes + // timeVal.BaisStrToTime(vv) + // if timeVal.AllTime <= 0 { + // msg = "书写的导入日期不正确;请按照规定书写日期。" + // return + // } + // } else { + // var timeVal publicmethod.DateTimeTotimes + // timeVal.BaisStrToTime(vv) + // if timeVal.AllTime <= 0 { + // msg = "书写的导入日期不正确;请按照规定书写日期。" + // return + // } + // } + // } + // if orgIdInt == 309 { + // if i == 2 && vi == 0 { + // if vv != "公司带班" { + // msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + // return + // } + // } + // if i == 3 && vi == 0 { + // if vv != "公司值班" { + // msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + // return + // } + // } + // } else { + // if i == 2 && vi == 0 { + // if vv != "公司带班" { + // msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + // return + // } + // } + // } + + // } + if i == 1 { + if v[0] == "" { + msg = "书写的导入日期不正确;请按照规定书写日期。" + return + } else { + if types == 1 { + var timeVal publicmethod.DateTimeTotimes + timeVal.BaisStrToTimeExcel(v[0]) + if timeVal.AllTime <= 0 { + msg = "书写的导入日期不正确;请按照规定书写日期。" + return + } + timeYear, _ := strconv.Atoi(timeVal.Years) + timeMonth, _ := strconv.Atoi(timeVal.Months) + if year != timeYear || month != timeMonth { + // msg = "导入日期,与模版设定日期不符!请检查!。" + msg = fmt.Sprintf("%v-%v-%v导入日期,与模版设定日期不符!请检查!%v-%v", year, month, day, timeYear, timeMonth) + return + } + } else { + var timeVal publicmethod.DateTimeTotimes + timeVal.BaisStrToTimeExcel(v[0]) + if timeVal.AllTime <= 0 { + msg = "书写的导入日期不正确;请按照规定书写日期。" + return + } + timeYear, _ := strconv.Atoi(timeVal.Years) + timeMonth, _ := strconv.Atoi(timeVal.Months) + timeDay, _ := strconv.Atoi(timeVal.Days) + if year != timeYear || month != timeMonth || day != timeDay { + msg = fmt.Sprintf("%v-%v-%v导入日期,与模版设定日期不符!请检查!%v-%v-%v", year, month, day, timeYear, timeMonth, timeDay) + return + } + } + } + // fmt.Printf("v---0---->%v\n\n", v[0]) + } + if orgIdInt == 309 { + if i == 2 { + if v[0] == "" { + msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + return + } else { + if v[0] != "公司带班" { + msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + return + } + } + } + if i == 3 { + if v[0] == "" { + msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + return + } else { + if v[0] != "公司值班" { + msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + return + } + } + } + } else { + if i == 2 { + if v[0] == "" { + msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + return + } else { + if v[0] != "公司带班" { + msg = "您的导入的数据所使用得模版不符合当前公司导入模版格式。请先下载相应的模版后,重新编辑数据,再上传!" + return + } + } + } + } + if i > 1 { + jsonStr, _ := json.Marshal(v) + redisClient.Lpush(redisKey, jsonStr) + totalNum++ + } + } + if totalNum > 0 { + isOk = true + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-19 15:34:42 +@ 功能: 将排班信息解写入数据库 +*/ +func (a *ApiMethod) AnalysisDutyData(c *gin.Context) { + var requestData AlaDutyInfo + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.OrgId == 0 { + publicmethod.Result(200, err, c, "未知行政组织!非法数据据") + return + } + if requestData.Types == 0 { + requestData.Types = 1 + } + currTime := time.Now().Unix() + if requestData.DateTime != 0 { + if publicmethod.GetIntLength(requestData.DateTime) >= 13 { + currTime = requestData.DateTime / 1000 + } else { + currTime = requestData.DateTime + } + } + if requestData.RedisKey == "" { + publicmethod.Result(200, err, c, "数据获取识别!没有找到数据! ") + return + } + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) + orgDutyList, err := redisClient.Llen(requestData.RedisKey) //获取列表总长度 + if err != nil { + publicmethod.Result(200, err, c, "数据获取识别!没有找到数据! ") + return + } + redisVal, err := redisClient.Lindex(requestData.RedisKey, requestData.Number) + if err != nil { + publicmethod.Result(200, err, c, "数据获取识别!没有找到数据! ") + return + } + var redisDataMap []string + err = json.Unmarshal([]byte(redisVal), &redisDataMap) + if err != nil { + publicmethod.Result(200, err, c, "数据格式不正取!") + return + } + var msgStr string + var orgCompunt modelshr.AdministrativeOrganization + orgCompunt.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`") + year, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 16)) + month, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 17)) + day, _ := strconv.Atoi(publicmethod.UnixTimeToDay(currTime, 18)) + if requestData.Types == 1 { + if len(redisDataMap) >= 1 { + if redisDataMap[0] != "" { + orgKey, orgTitle, orgErr := CallBackOrgIdName(requestData.OrgId, redisDataMap[0]) + if orgErr != nil { + msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, "未知行政组织", time.Now().Unix()) + } else { + for i, v := range redisDataMap { + fmt.Printf("读取的回写数据:\ni:%v------------------>%v\n", i, v) + if i > 0 { + if v != "" { + msgStr = SaveDutyData(orgCompunt.Name, orgTitle, orgKey, year, month, i, v) + } else { + msgStr = fmt.Sprintf("%v[%v]数据处理完成!--->%v", orgCompunt.Name, orgTitle, time.Now().Unix()) + } + } + } + } + } else { + msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, "未知行政组织", time.Now().Unix()) + } + } + + } else { + if len(redisDataMap) >= 2 { + if redisDataMap[0] != "" { + orgKey, orgTitle, orgErr := CallBackOrgIdName(requestData.OrgId, redisDataMap[0]) + if orgErr != nil { + msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, "未知行政组织", time.Now().Unix()) + } else { + if redisDataMap[1] != "" { + msgStr = SaveDutyData(orgCompunt.Name, orgTitle, orgKey, year, month, day, redisDataMap[1]) + } else { + msgStr = fmt.Sprintf("%v[%v]数据处理完成!--->%v", orgCompunt.Name, orgTitle, time.Now().Unix()) + } + + } + } else { + msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, "未知行政组织", time.Now().Unix()) + } + + } else { + msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", orgCompunt.Name, redisDataMap[0], time.Now().Unix()) + } + } + + sendData := publicmethod.MapOut[string]() + sendData["currTime"] = currTime + sendData["orgDutyList"] = orgDutyList + sendData["msg"] = msgStr + publicmethod.Result(0, sendData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-19 16:28:20 +@ 功能: 编辑排班数据 +*/ +func SaveDutyData(compurtNam, orgNam string, orgid int64, year, month, day int, userStr string) (msgStr string) { + var comDutyLog teamlog.Companylog + err := comDutyLog.GetCont(map[string]interface{}{"`orgid`": orgid, "`years`": year, "`months`": month, "`days`": day}) + fmt.Printf("编辑排班数据:\n%v---->%v---->%v---->%v---->%v\n\n\n", orgid, year, month, day, userStr) + var userKeyAllDayAry []string + var userKeyBaiTianAry []string + var userKeyNightAry []string + var userKeyMorningAry []string + var userKeyAfternoonAry []string + holiday := 2 + userAry := strings.Split(userStr, ",") + if len(userStr) > 0 { //获取排班人员 + // fmt.Printf("编辑排班数据:\n%v---->%v---->%v---->%v---->%v\n\n\n", orgid, year, month, day, userAry) + for _, v := range userAry { + userInfoStr := publicmethod.MatchBracket(v, "(", ")") + fmt.Printf("编辑排班数据110:\n%v\n\n\n", userInfoStr) + if userInfoStr != "" { + userAttr := strings.Split(userInfoStr, "*") + if len(userAttr) > 0 { + var usInfo modelshr.PersonArchives + usInfo.GetCont(map[string]interface{}{"`number`": userAttr[0]}) + if len(userAttr) >= 2 { + //(B:白天;Y:夜间;S:上午;X:下午;Z:值班)不填默认为值班(Z) + if usInfo.Key != 0 { + switch userAttr[1] { + case "B": + holiday = 1 + userKeyBaiTianAry = append(userKeyBaiTianAry, strconv.FormatInt(usInfo.Key, 10)) + case "Y": + holiday = 1 + userKeyNightAry = append(userKeyNightAry, strconv.FormatInt(usInfo.Key, 10)) + case "S": + userKeyMorningAry = append(userKeyMorningAry, strconv.FormatInt(usInfo.Key, 10)) + case "X": + userKeyAfternoonAry = append(userKeyAfternoonAry, strconv.FormatInt(usInfo.Key, 10)) + default: + userKeyAllDayAry = append(userKeyAllDayAry, strconv.FormatInt(usInfo.Key, 10)) + } + } + + } else { + if usInfo.Key != 0 { + userKeyAllDayAry = append(userKeyAllDayAry, strconv.FormatInt(usInfo.Key, 10)) + } + } + } + } + // fmt.Printf("编辑排班数据val:\n%v---->%v---->%v---->%v---->%v\n\n\n", orgid, year, month, day, v) + } + + } + if err == nil && comDutyLog.ID != 0 { //存在,进行修改 + saveEitd := publicmethod.MapOut[string]() + saveEitd["`holiday`"] = holiday + saveEitd["allDay"] = strings.Join(userKeyAllDayAry, ",") + saveEitd["baiTian"] = strings.Join(userKeyBaiTianAry, ",") + saveEitd["night"] = strings.Join(userKeyNightAry, ",") + saveEitd["morning"] = strings.Join(userKeyMorningAry, ",") + saveEitd["afternoon"] = strings.Join(userKeyAfternoonAry, ",") + saveEitd["saveTime"] = time.Now().Unix() + var newDutyCont teamlog.Companylog + err = newDutyCont.EiteCont(map[string]interface{}{"`id`": comDutyLog.ID}, saveEitd) + if err == nil { + msgStr = fmt.Sprintf("%v[%v]数据处理完成!--->%v", compurtNam, orgNam, time.Now().Unix()) + } else { + msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", compurtNam, orgNam, time.Now().Unix()) + } + } else { //不存在!进行新增 + var saveConter teamlog.Companylog + saveConter.Orgid = orgid // 行政组织ID + saveConter.RunTime = time.Now().Unix() // 执行时间 + saveConter.Years = year // 年 + saveConter.Months = month // 月 + saveConter.Days = day // 日 + saveConter.Holiday = holiday // 假日(1:是;2:否) + saveConter.AllDay = strings.Join(userKeyAllDayAry, ",") // 全天值班人员 + saveConter.BaiTian = strings.Join(userKeyBaiTianAry, ",") // 白天值班人员 + saveConter.Night = strings.Join(userKeyNightAry, ",") // 夜晚值班人员 + saveConter.Morning = strings.Join(userKeyMorningAry, ",") // 夜晚值班人员 + saveConter.Afternoon = strings.Join(userKeyAfternoonAry, ",") // 夜晚值班人员 + saveConter.SaveTime = time.Now().Unix() // 编辑时间 + err = overall.CONSTANT_DB_TeamsLog.Create(&saveConter).Error + if err == nil { + msgStr = fmt.Sprintf("%v[%v]数据处理完成!--->%v", compurtNam, orgNam, time.Now().Unix()) + } else { + msgStr = fmt.Sprintf("%v[%v]数据处理失败!--->%v", compurtNam, orgNam, time.Now().Unix()) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-19 16:17:31 +@ 功能: 返回当前行政组织的id与名称 +*/ +func CallBackOrgIdName(superiorId int64, orgName string) (orgId int64, orgTitle string, err error) { + + switch orgName { + case "公司带班": + orgId = superiorId * 10000 + orgTitle = orgName + case "公司值班": + orgId = superiorId*10000 + 1 + orgTitle = orgName + default: + var orgBan modelshr.AdministrativeOrganization + err = orgBan.GetCont(map[string]interface{}{"`superior`": superiorId, "`name`": orgName}, "`id`") + if err != nil { + return + } + orgId = orgBan.Id + orgTitle = orgName + } + + return +} + +// 判断有无换班申请 +func ShiftChange(userCode string, userKey int64, year, month, day int) (userInfo modelshr.ManCont, isTrue bool) { + monthStr := "01" + if month > 0 && month <= 12 { + if month < 10 { + monthStr = fmt.Sprintf("0%v", month) + } else { + monthStr = strconv.Itoa(month) + } + } + dayStr := "01" + if day > 0 && day <= 12 { + if day < 10 { + dayStr = fmt.Sprintf("0%v", day) + } else { + dayStr = strconv.Itoa(day) + } + } + fullDayStr := fmt.Sprintf("%v-%v-%v", year, monthStr, dayStr) + startTime, endTime := publicmethod.OenDayStartOrEndTime(fullDayStr, 1) + kaishi, _ := publicmethod.StringToInt64(startTime) + beginTime := kaishi * 1000 + jieshu, _ := publicmethod.StringToInt64(endTime) + lastTime := jieshu * 1000 + //被调换人到当前日期 + var diaoban []customerForm.SCApplication + overall.CONSTANT_DB_CustomerForm.Model(&customerForm.SCApplication{}).Where("FIND_IN_SET(?,`diao4huan4ren2`) AND `dang1zhi2ri4qi141995810` BETWEEN ? AND ?", userCode, beginTime, lastTime).Find(&diaoban) + if len(diaoban) > 0 { + for _, v := range diaoban { + var taskInfo customerForm.RunFlowTask + taskInfo.GetCont(map[string]interface{}{"`masters_key`": v.MastersKey}, "status") + if taskInfo.Status == 4 { + isTrue = true + userInfo.GetCont(map[string]interface{}{"`number`": userCode}) + break + } + } + } + //申请人到调换日期 + var shenQing []customerForm.SCApplication + overall.CONSTANT_DB_CustomerForm.Model(&customerForm.SCApplication{}).Where("`creater` = ? AND `diao4huan4ri4qi1` BETWEEN ? AND ?", userKey, beginTime, lastTime).Find(&shenQing) + if len(shenQing) > 0 { + for _, v := range shenQing { + var taskInfo customerForm.RunFlowTask + taskInfo.GetCont(map[string]interface{}{"`masters_key`": v.MastersKey}, "status") + if taskInfo.Status == 4 { + isTrue = true + userInfo.GetCont(map[string]interface{}{"`key`": userKey}) + break + } + } + } + return +} diff --git a/api/version1/customerApp/companyduty.go b/api/version1/customerApp/companyduty.go new file mode 100644 index 0000000..2c2cbd7 --- /dev/null +++ b/api/version1/customerApp/companyduty.go @@ -0,0 +1,1030 @@ +package customerApp + +import ( + "appPlatform/middleware/grocerystore" + "appPlatform/models/modelshr" + "appPlatform/models/modelssystempermission" + "appPlatform/models/teamlog" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "sort" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +var paichu = []int64{163, 281, 319} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-11 15:33:40 +@ 功能: 初始化排版页面 +*/ +func (a *ApiMethod) CompanyDutyInit(c *gin.Context) { + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + sendData := publicmethod.MapOut[string]() + if userCont.Company == 402 { + userCont.Company = 296 + } + sendData["currentOrg"] = userCont.Company + var orgCurre modelshr.AdministrativeOrganization + orgCurre.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`") + currentTime := time.Now().Unix() + yearVal := publicmethod.UnixTimeToDay(currentTime, 16) + yearValInt, _ := strconv.Atoi(yearVal) + monthVal := publicmethod.UnixTimeToDay(currentTime, 17) + monthValInt, _ := strconv.Atoi(monthVal) + currentDay := int(time.Now().Day()) + sendData["title"] = fmt.Sprintf("%v.%v.%v%v值班表", yearVal, monthVal, currentDay, orgCurre.Name) + sendData["titlePc"] = fmt.Sprintf("%v年%v月%v值班表", yearVal, monthVal, orgCurre.Name) + sendData["year"] = yearValInt + sendData["month"] = monthValInt + sendData["currentOrgName"] = orgCurre.Name + sendData["currentTime"] = time.Now().Unix() * 1000 + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthEndDay, _ := strconv.Atoi(endTime.Days) + var monthAllDay []string + for i := 1; i <= monthEndDay; i++ { + monthAllDay = append(monthAllDay, fmt.Sprintf("%v日", i)) + } + + //角色权限范围判定 + //1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有 + switch SearchRoleLevev(userCont.Role) { + case 5: + sendData["orgLevel"] = 5 + // sendData["orgList"] = GetOrgLevel(313, 1) + case 4: + sendData["orgLevel"] = 4 + // sendData["orgList"] = GetOrgLevel(userCont.Company, 1) + case 3: + sendData["orgLevel"] = 3 + // sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) + case 2: + sendData["orgLevel"] = 2 + // sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) + case 1: + sendData["orgLevel"] = 1 + // sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) + default: + } + sendData["orgList"] = GetOrgLevel(313, 1) + + sendData["currentDay"] = currentDay + // sendData["endTime"] = endTime + sendData["monthAllDay"] = monthAllDay + publicmethod.Result(0, sendData, c) +} + +// 获取行政组织层级 +func GetOrgLevel(partenId int64, types int) (orgList []GaveOrgAry) { + gormDb := overall.CONSTANT_DB_HR.Model(&GaveOrgAry{}).Where("`state` = 1") + if types == 1 { + gormDb = gormDb.Where("`superior` = ?", partenId) + } else { + gormDb = gormDb.Where("`id` = ?", partenId) + } + gormDb.Order("`sort` ASC").Find(&orgList) + sort.Slice(orgList, func(i, j int) bool { + return orgList[i].Sort < orgList[j].Sort + }) + return +} + +// 获取最大查询范围 +func SearchRoleLevev(roles string) (level int) { + roleList := strings.Split(roles, ",") + var roleVerify []modelssystempermission.RoleEmpower + overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `id` IN ? ", "appsystem", roleList).Find(&roleVerify) + + fmt.Printf("获取最大查询范围-->%v\n\n\n", roleVerify) + + for _, v := range roleVerify { + fmt.Printf("获取最大查询范围-->%v\n\n\n", v.Level) + if v.Level >= level { + level = v.Level + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-12 08:36:19 +@ 功能: 获取根据年月获取排班目录表 +*/ +func (a *ApiMethod) GetYearMonthWorkMan(c *gin.Context) { + var requestData PaiBanInfo + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.OrgId == 0 { + publicmethod.Result(1, err, c, "未知行政组织!") + return + } + + currentTime := time.Now().Unix() + yearVal := publicmethod.UnixTimeToDay(currentTime, 16) + yearValInt, _ := strconv.Atoi(yearVal) + monthVal := publicmethod.UnixTimeToDay(currentTime, 17) + monthValInt, _ := strconv.Atoi(monthVal) + if requestData.Years != 0 { + yearValInt = requestData.Years + } + if requestData.Months != 0 { + monthValInt = requestData.Months + } + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthEndDay, _ := strconv.Atoi(endTime.Days) + + sendCenter := publicmethod.MapOut[string]() + var currOrgInfo GaveOrgAry + currOrgInfo.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`") + sendCenter["title"] = fmt.Sprintf("%v年%v月%v", yearVal, monthValInt, currOrgInfo.Name) + sendCenter["orgId"] = requestData.OrgId + sendCenter["orgName"] = currOrgInfo.Name + var sendData []SendCompanyWork + var orgList []GaveOrgAry + + if requestData.OrgId == 309 { + var gsdaban GaveOrgAry + gsdaban.Id = requestData.OrgId * 10000 + gsdaban.Name = "公司带班" + gsdaban.IsCompany = 1 + orgList = append(orgList, gsdaban) + var gszhiban GaveOrgAry + gszhiban.Id = requestData.OrgId*10000 + 1 + gszhiban.Name = "公司值班" + gszhiban.IsCompany = 1 + orgList = append(orgList, gszhiban) + } else { + var gsld GaveOrgAry + gsld.Id = requestData.OrgId * 10000 + gsld.Name = "公司值班" + gsld.IsCompany = 1 + orgList = append(orgList, gsld) + } + orgListAry := GetOrgLevel(requestData.OrgId, 1) + orgList = append(orgList, orgListAry...) + for _, v := range orgList { + if !publicmethod.IsInTrue[int64](v.Id, paichu) { + var sendInfo SendCompanyWork + sendInfo.OrgInfo.Id = v.Id + sendInfo.OrgInfo.Name = v.Name + sendInfo.OrgInfo.IsCompany = v.IsCompany + var comLog []teamlog.Companylog + overall.CONSTANT_DB_TeamsLog.Where("`orgid` = ? AND `years` = ? AND `months` = ?", v.Id, yearValInt, monthValInt).Find(&comLog) + sendInfo.DutyList = GetOrgParWork(comLog, yearValInt, monthValInt, monthEndDay) + sendData = append(sendData, sendInfo) + } + + } + sendCenter["list"] = sendData + publicmethod.Result(0, sendCenter, c) +} + +func GetOrgParWork(comLog []teamlog.Companylog, yearValInt, monthValInt, monthEndDay int) (DutyList []DutyListStruct) { + for i := 1; i <= monthEndDay; i++ { + var dayWorkMan DutyListStruct + + dayWorkMan.Years = yearValInt + dayWorkMan.Months = monthValInt + dayWorkMan.Days = i + for _, v := range comLog { + if i == v.Days { + dayWorkMan.Id = v.ID + dayWorkMan.Holiday = v.Holiday + dayWorkMan.AllDay = GetMAnInfo(v.AllDay, yearValInt, monthValInt, i) + dayWorkMan.BaiTian = GetMAnInfo(v.BaiTian, yearValInt, monthValInt, i) + dayWorkMan.Night = GetMAnInfo(v.Night, yearValInt, monthValInt, i) + dayWorkMan.Morning = GetMAnInfo(v.Morning, yearValInt, monthValInt, i) + dayWorkMan.Afternoon = GetMAnInfo(v.Afternoon, yearValInt, monthValInt, i) + } + } + DutyList = append(DutyList, dayWorkMan) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-12 10:11:10 +@ 功能: 值班人员信息 +*/ +func GetMAnInfo(userKey string, yearValInt, monthValInt, dayValInt int) (userList []UserCentor) { + if userKey != "" { + userAry := strings.Split(userKey, ",") + + if len(userAry) > 0 { + var jieguo []UserCentor + var man []modelshr.ManCont + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`,`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`emp_type` BETWEEN ? AND ? AND `key` IN ?", 1, 10, userAry).Find(&man) + for _, v := range man { + + var userInfo UserCentor + + huanbenInfo, isTrue := ShiftChange(v.Number, v.Key, yearValInt, monthValInt, dayValInt) + if isTrue { + userInfo.Id = strconv.FormatInt(huanbenInfo.Id, 10) + userInfo.UserKey = strconv.FormatInt(huanbenInfo.Key, 10) + userInfo.Coder = huanbenInfo.Number + userInfo.Name = huanbenInfo.Name + userInfo.Icon = huanbenInfo.Icon + if huanbenInfo.IconPhpto != "" { + userInfo.Icon = huanbenInfo.IconPhpto + } + userInfo.Wechat = huanbenInfo.Wechat + userInfo.WorkWechat = huanbenInfo.WorkWechat + userInfo.Tel = huanbenInfo.Mobilephone + userInfo.Gender = huanbenInfo.Gender + } else { + userInfo.Id = strconv.FormatInt(v.Id, 10) + userInfo.UserKey = strconv.FormatInt(v.Key, 10) + userInfo.Coder = v.Number + userInfo.Name = v.Name + userInfo.Icon = v.Icon + if v.IconPhpto != "" { + userInfo.Icon = v.IconPhpto + } + userInfo.Wechat = v.Wechat + userInfo.WorkWechat = v.WorkWechat + userInfo.Tel = v.Mobilephone + userInfo.Gender = v.Gender + } + + jieguo = append(jieguo, userInfo) + } + if len(jieguo) > 0 { + for _, v := range userAry { + for _, vv := range jieguo { + if v == vv.UserKey { + userList = append(userList, vv) + } + } + } + } + + } + + } + return +} + +// 根据行政组织获取人员信息 +func (a *ApiMethod) GeiOrgAllPeople(c *gin.Context) { + var requestData GetOrgPeopel + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.OrgId == 0 { + publicmethod.Result(1, err, c, "未知行政组织!") + return + } + if requestData.IsAll == 0 { + requestData.IsAll = 1 + } + if requestData.IsAll == 1 { + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSun(requestData.OrgId) + sunOrg.Id = append(sunOrg.Id, requestData.OrgId) + var userList []UserCentor + if len(sunOrg.Id) > 0 { + var man []modelshr.ManCont + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`,`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`emp_type` BETWEEN ? AND ? AND `admin_org` IN ?", 1, 10, sunOrg.Id).Find(&man) + for _, v := range man { + var userInfo UserCentor + userInfo.Id = strconv.FormatInt(v.Id, 10) + userInfo.UserKey = strconv.FormatInt(v.Key, 10) + userInfo.Coder = v.Number + userInfo.Name = fmt.Sprintf("%v(%v)", v.Name, v.Number) + userInfo.Icon = v.Icon + if v.IconPhpto != "" { + userInfo.Icon = v.IconPhpto + } + userInfo.Wechat = v.Wechat + userInfo.WorkWechat = v.WorkWechat + userInfo.Tel = v.Mobilephone + userInfo.Gender = v.Gender + userList = append(userList, userInfo) + } + } + publicmethod.Result(0, userList, c) + } else { + + } + +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-13 08:42:32 +@ 功能: 编辑值班信息 +*/ +func (a *ApiMethod) SaveEditDutyInfo(c *gin.Context) { + var requestData DutyOrgInfo + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Orgid == 0 { + publicmethod.Result(1, err, c, "未知行政组织!") + return + } + if requestData.Years == 0 || requestData.Months == 0 || requestData.Days == 0 { + publicmethod.Result(1, err, c, "未知时间安排!") + return + } + holiday := 2 + if requestData.Holiday != "" { + holiday, _ = strconv.Atoi(requestData.Holiday) + if holiday == 0 { + holiday = 2 + } + } + isAdd := true + monthval := fmt.Sprintf("%v", requestData.Months) + if requestData.Months < 10 { + monthval = fmt.Sprintf("0%v", requestData.Months) + } + daysval := fmt.Sprintf("%v", requestData.Days) + if requestData.Days < 10 { + daysval = fmt.Sprintf("0%v", requestData.Days) + } + timeStr := fmt.Sprintf("%v-%v-%v 12:00:00", requestData.Years, monthval, daysval) + var timeVal publicmethod.DateTimeTotimes + timeVal.BaisStrToTime(timeStr) + if requestData.Id != 0 { + var oldDutyCont teamlog.Companylog + err = oldDutyCont.GetCont(map[string]interface{}{"`id`": requestData.Id}) + if err == nil { + isAdd = false + saveEitd := publicmethod.MapOut[string]() + saveEitd["`holiday`"] = holiday + saveEitd["allDay"] = strings.Join(requestData.AllDay, ",") + saveEitd["baiTian"] = strings.Join(requestData.BaiTian, ",") + saveEitd["night"] = strings.Join(requestData.Night, ",") + saveEitd["morning"] = strings.Join(requestData.Morning, ",") + saveEitd["afternoon"] = strings.Join(requestData.Afternoon, ",") + saveEitd["saveTime"] = time.Now().Unix() + var newDutyCont teamlog.Companylog + err = newDutyCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveEitd) + if err != nil { + publicmethod.Result(106, err, c) + return + } + } + } + + if isAdd { + var saveConter teamlog.Companylog + saveConter.Orgid = requestData.Orgid // 行政组织ID + saveConter.RunTime = timeVal.AllTime // 执行时间 + saveConter.Years = requestData.Years // 年 + saveConter.Months = requestData.Months // 月 + saveConter.Days = requestData.Days // 日 + saveConter.Holiday = holiday // 假日(1:是;2:否) + saveConter.AllDay = strings.Join(requestData.AllDay, ",") // 全天值班人员 + saveConter.BaiTian = strings.Join(requestData.BaiTian, ",") // 白天值班人员 + saveConter.Night = strings.Join(requestData.Night, ",") // 夜晚值班人员 + saveConter.Morning = strings.Join(requestData.Morning, ",") // 夜晚值班人员 + saveConter.Afternoon = strings.Join(requestData.Afternoon, ",") // 夜晚值班人员 + saveConter.SaveTime = time.Now().Unix() // 编辑时间 + err = overall.CONSTANT_DB_TeamsLog.Create(&saveConter).Error + if err != nil { + publicmethod.Result(106, err, c) + return + } + } + publicmethod.Result(0, err, c) +} + +// 根据日期获取行政组织排班列表 +func (a *ApiMethod) GeyOneDayDuty(c *gin.Context) { + var requestData OenDayDuty + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.OrgId == 0 { + publicmethod.Result(1, err, c, "未知行政组织!") + return + } + currentTime := time.Now().Unix() + yearVal := publicmethod.UnixTimeToDay(currentTime, 16) + yearValInt, _ := strconv.Atoi(yearVal) + monthVal := publicmethod.UnixTimeToDay(currentTime, 17) + monthValInt, _ := strconv.Atoi(monthVal) + dayhVal := publicmethod.UnixTimeToDay(currentTime, 18) + dayhValInt, _ := strconv.Atoi(dayhVal) + if requestData.Years != 0 { + yearValInt = requestData.Years + } + if requestData.Months != 0 { + monthValInt = requestData.Months + } + if requestData.Days != 0 { + dayhValInt = requestData.Days + } + sendCenter := publicmethod.MapOut[string]() + var currOrgInfo GaveOrgAry + currOrgInfo.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`") + sendCenter["title"] = fmt.Sprintf("%v.%v.%v%v", yearVal, monthValInt, dayhValInt, currOrgInfo.Name) + sendCenter["orgId"] = requestData.OrgId + var orgList []GaveOrgAry + + if requestData.OrgId == 309 { + var gsdaban GaveOrgAry + gsdaban.Id = requestData.OrgId * 10000 + gsdaban.Name = "公司带班" + gsdaban.IsCompany = 1 + orgList = append(orgList, gsdaban) + var gszhiban GaveOrgAry + gszhiban.Id = requestData.OrgId*10000 + 1 + gszhiban.Name = "公司值班" + gsdaban.IsCompany = 1 + orgList = append(orgList, gszhiban) + } else { + var gsld GaveOrgAry + gsld.Id = requestData.OrgId * 10000 + gsld.Name = "公司值班" + gsld.IsCompany = 1 + orgList = append(orgList, gsld) + } + orgListAry := GetOrgLevel(requestData.OrgId, 1) + orgList = append(orgList, orgListAry...) + + var sendData []WebSendTo + for _, v := range orgList { + if !publicmethod.IsInTrue[int64](v.Id, paichu) { + var sendInfo WebSendTo + sendInfo.OrgId = v.Id + sendInfo.OrgName = v.Name + sendInfo.IsCompany = v.IsCompany + var comLog teamlog.Companylog + err = overall.CONSTANT_DB_TeamsLog.Where("`orgid` = ? AND `years` = ? AND `months` = ? AND `days` = ?", v.Id, yearValInt, monthValInt, dayhValInt).First(&comLog).Error + if err == nil { + sendInfo.Id = strconv.FormatInt(comLog.ID, 10) + sendInfo.Holiday = comLog.Holiday + sendInfo.AllDay = GetMAnInfo(comLog.AllDay, yearValInt, monthValInt, dayhValInt) + sendInfo.BaiTian = GetMAnInfo(comLog.BaiTian, yearValInt, monthValInt, dayhValInt) + sendInfo.Night = GetMAnInfo(comLog.Night, yearValInt, monthValInt, dayhValInt) + sendInfo.Morning = GetMAnInfo(comLog.Morning, yearValInt, monthValInt, dayhValInt) + sendInfo.Afternoon = GetMAnInfo(comLog.Afternoon, yearValInt, monthValInt, dayhValInt) + if comLog.AllDay != "" || comLog.BaiTian != "" || comLog.Night != "" || comLog.Morning != "" || comLog.Afternoon != "" { + sendData = append(sendData, sendInfo) + } + + } + + } + + } + sendCenter["list"] = sendData + publicmethod.Result(0, sendCenter, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-13 21:24:02 +@ 功能: 清空日期值班 +*/ +func (a *ApiMethod) DelOneDayDuty(c *gin.Context) { + var requestData publicmethod.CommonId[int64] + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == 0 { + publicmethod.Result(1, err, c, "未知删除项目!") + return + } + var comLog teamlog.Companylog + err = comLog.DelCont(map[string]interface{}{"`id`": requestData.Id}) + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-14 11:20:51 +@ 功能: 获取排版信息 +*/ +func (a *ApiMethod) GetDutyCont(c *gin.Context) { + var requestData publicmethod.PublicId + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(1, err, c, "未知项目!") + return + } + var comLog CompanyDutyCont + comLog.GetCont(map[string]interface{}{"`id`": requestData.Id}) + if comLog.AllDay != "" { + userKeyAry := strings.Split(comLog.AllDay, ",") + comLog.AllDayAry = userKeyAry + comLog.AllDayAryAll = HaveUSerInfo(userKeyAry) + } else { + comLog.AllDayAry = []string{} + comLog.AllDayAryAll = []SendOrgPeopelList{} + } + if comLog.BaiTian != "" { + userKeyAry := strings.Split(comLog.BaiTian, ",") + comLog.BaiTianAry = userKeyAry + comLog.BaiTianAryAll = HaveUSerInfo(userKeyAry) + } else { + comLog.BaiTianAry = []string{} + comLog.BaiTianAryAll = []SendOrgPeopelList{} + } + if comLog.Night != "" { + userKeyAry := strings.Split(comLog.Night, ",") + comLog.NightAry = userKeyAry + comLog.NightAryAll = HaveUSerInfo(userKeyAry) + } else { + comLog.NightAry = []string{} + comLog.NightAryAll = []SendOrgPeopelList{} + } + if comLog.Morning != "" { + userKeyAry := strings.Split(comLog.Morning, ",") + comLog.MorningAry = userKeyAry + comLog.MorningAryAll = HaveUSerInfo(userKeyAry) + } else { + comLog.MorningAry = []string{} + comLog.MorningAryAll = []SendOrgPeopelList{} + } + if comLog.Afternoon != "" { + userKeyAry := strings.Split(comLog.Afternoon, ",") + comLog.AfternoonAry = userKeyAry + comLog.AfternoonAryAll = HaveUSerInfo(userKeyAry) + } else { + comLog.AfternoonAry = []string{} + comLog.AfternoonAryAll = []SendOrgPeopelList{} + } + publicmethod.Result(0, comLog, c) +} + +// 获取人员信息 +func HaveUSerInfo(userKey []string) (manAry []SendOrgPeopelList) { + if len(userKey) > 0 { + var jieguo []SendOrgPeopelList + var manList []modelshr.ManCont + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`,`mobilephone`").Where("`key` IN ? AND `emp_type` BETWEEN ? AND ?", userKey, 1, 10).Find(&manList) + for _, v := range manList { + var manInfo SendOrgPeopelList + manInfo.UserNumber = v.Number // + manInfo.UserName = v.Name // + manInfo.UserKey = strconv.FormatInt(v.Key, 10) // + manInfo.TelStr = v.Mobilephone + manInfo.UserAvatar = v.IconPhpto // + if v.Icon != "" { + manInfo.UserAvatar = v.Icon + } + jieguo = append(jieguo, manInfo) + } + if len(jieguo) > 0 { + for _, v := range userKey { + for _, vv := range jieguo { + if v == vv.UserKey { + manAry = append(manAry, vv) + } + } + } + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-19 10:41:34 +@ 功能: 获取行政组织及相关人员 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GetOrgAndEveryOnePeople(c *gin.Context) { + var requestData OrgAndMAnThreeType + c.ShouldBindJSON(&requestData) + redisKey := fmt.Sprintf("Auth:Org_%v_Info", requestData.Id) + if requestData.Id == "" { + redisKey = fmt.Sprintf("Auth:Org_%v_Info", "orgAll") + } + + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) + isTrue, jsApiTickerInfo := redisClient.Get(redisKey) //读取redis数据 + if isTrue && jsApiTickerInfo != "" && jsApiTickerInfo != "[]" { + // var sendMap interface{} + var govAry []OrgAndManThree + json.Unmarshal([]byte(jsApiTickerInfo), &govAry) + publicmethod.Result(0, govAry, c, "这是Redsi值") + } else { + var origin int64 + var orgIdList []int64 + isNotIn := 0 + var sunOrg publicmethod.GetOrgAllParent + if requestData.All == 0 { + if requestData.Id == "" { + origin = 0 + isNotIn = 1 + orgIdList = []int64{312, 293, 305, 306, 307} + } else { + idInt64, _ := strconv.ParseInt(requestData.Id, 10, 64) + origin = idInt64 + sunOrg.GetOrgSun(idInt64) + sunOrg.Id = append(sunOrg.Id, idInt64) + orgIdList = sunOrg.Id + } + } else { + if requestData.Id != "" { + idInt64, _ := strconv.ParseInt(requestData.Id, 10, 64) + origin = idInt64 + sunOrg.GetOrgSun(idInt64) + sunOrg.Id = append(sunOrg.Id, idInt64) + orgIdList = sunOrg.Id + } else { + origin = 0 + isNotIn = 1 + orgIdList = []int64{312, 293, 305, 306, 307} + } + } + if !publicmethod.IsInTrue[int64](origin, orgIdList) { + orgIdList = append(orgIdList, origin) + } + var orgAndPeopleListCont empowerSync //启用协程结构体 + synPro.Add(1) + go orgAndPeopleListCont.GetOrgList(isNotIn, orgIdList, requestData.Level) //获取行政组织 + synPro.Add(1) + go orgAndPeopleListCont.GetPeopleList(isNotIn, orgIdList) //获取人员 + synPro.Wait() + orgAndManList := orgAndPeopleListCont.readDataLock() + + sort.Slice(orgAndManList, func(i, j int) bool { + return orgAndManList[i].Type < orgAndManList[j].Type + }) + sort.Slice(orgAndManList, func(i, j int) bool { + return orgAndManList[i].Sort < orgAndManList[j].Sort + }) + sendList := OrgAndManNewThree(origin, orgAndManList) + orgMap, _ := json.Marshal(sendList) + redisClient.SetRedisTime(86400) + redisClient.Set(redisKey, string(orgMap)) + publicmethod.Result(0, sendList, c) + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-19 14:28:48 +@ 功能: 新版人员与行政组织树 +@ 参数 + + #parentId 上级ID + #govAry 数据 + +@ 返回值 + + # + +@ 方法原型 + + #func OrgAndManNewThree(parentId int64, govAry []OrgAndEveryOnePeople) []OrgAndManThree +*/ +func OrgAndManNewThree(parentId int64, govAry []OrgAndEveryOnePeople) []OrgAndManThree { + orgAndMAnMap := []OrgAndManThree{} + for _, v := range govAry { + // var zhucont govThree + parentIdInt, _ := strconv.ParseInt(v.Superior, 10, 64) + // fmt.Printf("------------->%v---->%v\n", parentIdInt, parentId) + if parentIdInt == parentId { + + child := OrgAndManNewThree(v.OrgId, govAry) + + var node OrgAndManThree + node.Id = v.Id //识别符 + node.OrgId = v.OrgId + node.Number = v.Number //编号 + node.Name = v.Name //姓名 + node.Superior = v.Superior //上级 + node.Icon = v.Icon + node.IconPhoto = v.IconPhoto + node.Type = v.Type + node.Key = v.Key + node.Sort = v.Sort + if len(child) > 0 { + node.Child = child + } + + orgAndMAnMap = append(orgAndMAnMap, node) + + } + + } + return orgAndMAnMap +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-19 11:24:44 +@ 功能: 获取人员(协程) +@ 参数 + + #orgId 行政组织ID + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (e *empowerSync) GetPeopleList(isNotIn int, orgId []int64) { + e.mutext.Lock() + defer e.mutext.Unlock() + var peopleList []modelshr.PersonArchives + gormDnMan := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`").Where("`emp_type` BETWEEN ? AND ?", 1, 10) + if len(orgId) > 0 { + if isNotIn == 1 { + gormDnMan = gormDnMan.Where("`admin_org` NOT IN ?", orgId) + } else { + gormDnMan = gormDnMan.Where("`admin_org` IN ?", orgId) + } + + } + err := gormDnMan.Find(&peopleList).Error + if err == nil && len(peopleList) > 0 { + for _, v := range peopleList { + var peopleCont OrgAndEveryOnePeople + peopleCont.Id = strconv.FormatInt(v.Key, 10) //识别符 + peopleCont.OrgId = -1 + peopleCont.Number = v.Number //编号 + peopleCont.Name = v.Name //姓名 + peopleCont.Superior = strconv.FormatInt(v.AdminOrg, 10) //上级 + peopleCont.Icon = v.Icon + peopleCont.IconPhoto = v.IconPhoto + peopleCont.Type = 2 + peopleCont.Key = fmt.Sprintf("U%v", v.Key) + e.orgAndPeopleList = append(e.orgAndPeopleList, peopleCont) + } + } + synPro.Done() +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-19 11:18:39 +@ 功能: 获取行政组织(协程) +@ 参数 + + #orgId 行政组织ID + #level 获取等级 + +@ 返回值 + + # + +@ 方法原型 + + #func (e *empowerSync) GetOrgList(orgId []int64, level int) +*/ +func (e *empowerSync) GetOrgList(isNotIn int, orgId []int64, level int) { + e.mutext.Lock() + defer e.mutext.Unlock() + var orgList []modelshr.AdministrativeOrganization + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`number`,`name`,`superior`").Where("`state` = ? ", 1) + if len(orgId) > 0 { + if isNotIn == 1 { + gormDb = gormDb.Where("`id` NOT IN ?", orgId) + } else { + gormDb = gormDb.Where("`id` IN ?", orgId) + } + } + if level != 0 { + gormDb = gormDb.Where("`level` <= ?", level) + } + err := gormDb.Find(&orgList).Error + if err == nil && len(orgList) > 0 { + for _, v := range orgList { + var orgCont OrgAndEveryOnePeople + orgCont.Id = strconv.FormatInt(v.Id, 10) //识别符 + orgCont.OrgId = v.Id + orgCont.Number = v.Number //编号 + orgCont.Name = v.Name //姓名 + orgCont.Superior = strconv.FormatInt(v.Superior, 10) //上级 + orgCont.Type = 1 + orgCont.Sort = v.Sort + orgCont.Key = fmt.Sprintf("A%v", v.Id) + e.orgAndPeopleList = append(e.orgAndPeopleList, orgCont) + } + } + synPro.Done() +} + +// 获取行政组织树 +func (a *ApiMethod) GetOrgTree(c *gin.Context) { + var requestData publicmethod.CommonId[int64] + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + var origin int64 + var orgIdList []int64 + isNotIn := 0 + var sunOrg publicmethod.GetOrgAllParent + if requestData.Id == 0 { + origin = 0 + isNotIn = 1 + orgIdList = []int64{312, 293, 305, 306, 307} + } else { + var pickOrg modelshr.AdministrativeOrganization + pickOrg.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`superior`") + origin = pickOrg.Superior + sunOrg.GetOrgSun(requestData.Id) + sunOrg.Id = append(sunOrg.Id, requestData.Id) + orgIdList = sunOrg.Id + } + var orgConterList []modelshr.AdministrativeOrganization + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`,`superior`,`sort`").Where("`state` = ? ", 1) + if len(orgIdList) > 0 { + if isNotIn == 1 { + gormDb = gormDb.Where("`id` NOT IN ?", orgIdList) + } else { + gormDb = gormDb.Where("`id` IN ?", orgIdList) + } + } + err = gormDb.Find(&orgConterList).Error + var orgAry []JianLueOrgTree + for _, v := range orgConterList { + var orgInfo JianLueOrgTree + orgInfo.Id = v.Id + orgInfo.Name = v.Name + orgInfo.Superior = v.Superior + orgInfo.Sort = v.Sort + orgAry = append(orgAry, orgInfo) + } + sort.Slice(orgAry, func(i, j int) bool { + return orgAry[i].Sort < orgAry[j].Sort + }) + orgTreeAry := GovOrgTree(origin, orgAry) + publicmethod.Result(0, orgTreeAry, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-01-16 08:57:31 +@ 功能: 生成行政组织树 +*/ +func GovOrgTree(parentId int64, govList []JianLueOrgTree) (govMap []JianLueOrgTree) { + for i := 0; i < len(govList); i++ { + if govList[i].Superior == parentId { + var govCont JianLueOrgTree + govCont.Id = govList[i].Id + govCont.Name = govList[i].Name //组织名称"` + govCont.Superior = govList[i].Superior //上级ID"` + govCont.Sort = govList[i].Sort //是否为实权部门"` + govCont.Children = GovOrgTree(govList[i].Id, govList) + govMap = append(govMap, govCont) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-16 14:30:38 +@ 功能: 获取人员信息 +*/ +func (a *ApiMethod) GetOrgPeopleList(c *gin.Context) { + var requestData OrgPeopinCenter + c.ShouldBindJSON(&requestData) + fmt.Printf("翻页数据--->%v\n\n", requestData) + if requestData.Page == 0 { + requestData.Page = 1 + } + if requestData.PageSize == 0 { + requestData.PageSize = 6 + } + var orgIdList []int64 + var sunOrg publicmethod.GetOrgAllParent + if requestData.Id == 0 { + orgIdListNoIn := []int64{312, 293, 305, 306, 307} + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = ? ", 1).Where("`id` NOT IN ?", orgIdListNoIn).Find(&orgIdList) + } else { + sunOrg.GetOrgSun(requestData.Id) + sunOrg.Id = append(sunOrg.Id, requestData.Id) + orgIdList = sunOrg.Id + } + var manList []modelshr.ManCont + // gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`,`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`,`mobilephone`").Where("`emp_type` BETWEEN ? AND ?", 1, 10).Where("`admin_org` IN ?", orgIdList) + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`,`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`,`mobilephone`").Where("`number` NOT LIKE ?", "%W%").Where("`emp_type` BETWEEN ? AND ?", 1, 10) + if requestData.Id == 389 { + jiuan := []int64{389, 126} + gormDb = gormDb.Where("`company` IN ? OR `maindeparment` = ? OR admin_org IN ?", jiuan, 126, orgIdList) + } else { + gormDb = gormDb.Where("`company` = ? OR admin_org IN ?", requestData.Id, orgIdList) + } + if requestData.Name != "" { + gormDb = gormDb.Where("`name` LIKE ? OR `number` LIKE ? OR `mobilephone` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%", "%"+requestData.Name+"%") + } + + var total int64 + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) + gormDb.Order("`id` DESC").Find(&manList) + var sendAry []SendOrgPeopelList + for _, v := range manList { + var usMAn SendOrgPeopelList + usMAn.UserNumber = v.Number //er"` + usMAn.UserName = v.Name //"` + usMAn.UserKey = strconv.FormatInt(v.Key, 10) //` + usMAn.UserAvatar = v.IconPhpto //ar"` + if v.Icon != "" { + usMAn.UserAvatar = v.Icon + } + usMAn.TelStr = v.Mobilephone // + sendAry = append(sendAry, usMAn) + } + // publicmethod.Result(0, requestData, c) + publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendAry)), sendAry, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-18 11:19:31 +@ 功能: 日历表单一删除值班人 +*/ +func (a *ApiMethod) DelMonthOneus(c *gin.Context) { + var requestData DelOneUsRili + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == 0 { + publicmethod.Result(1, err, c, "未知删除对象!") + return + } + var comLog teamlog.Companylog + err = comLog.GetCont(map[string]interface{}{"`id`": requestData.Id}) + if err != nil { + publicmethod.Result(100, err, c) + return + } + saveInfo := publicmethod.MapOut[string]() + switch requestData.Types { + case 2: + saveInfo["`night`"] = strings.Join(requestData.UserAry, ",") + case 3: + saveInfo["`allDay`"] = strings.Join(requestData.UserAry, ",") + + case 4: + saveInfo["`morning`"] = strings.Join(requestData.UserAry, ",") + case 5: + saveInfo["`baiTian`"] = strings.Join(requestData.UserAry, ",") + default: + saveInfo["`baiTian`"] = strings.Join(requestData.UserAry, ",") + } + saveInfo["`saveTime`"] = time.Now().Unix() + var comLogEdit teamlog.Companylog + err = comLogEdit.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveInfo) + publicmethod.Result(0, err, c) +} diff --git a/api/version1/customerApp/companyduty_test.go b/api/version1/customerApp/companyduty_test.go new file mode 100644 index 0000000..8b6b311 --- /dev/null +++ b/api/version1/customerApp/companyduty_test.go @@ -0,0 +1,529 @@ +package customerApp + +import ( + "appPlatform/models/modelshr" + "appPlatform/models/modelssystempermission" + "appPlatform/models/teamlog" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "fmt" + "sort" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +// var paichu = []int64{163, 281, 319} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-11 15:33:40 +@ 功能: 初始化排版页面 +*/ +func (a *ApiMethod) TestCompanyDutyInit(c *gin.Context) { + context, _ := c.Get(overall.MyContJwt) + var userCont modelshr.ManCont + userCont.GetLoginCont(context) //当前操作人 + sendData := publicmethod.MapOut[string]() + + sendData["currentOrg"] = userCont.Company + var orgCurre modelshr.AdministrativeOrganization + // orgCurre.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`") + overall.CONSTANT_DB_HrInside.Model(&orgCurre).Select("`name`").Where("`id` = ?", userCont.Company).First(&orgCurre) + + currentTime := time.Now().Unix() + yearVal := publicmethod.UnixTimeToDay(currentTime, 16) + yearValInt, _ := strconv.Atoi(yearVal) + monthVal := publicmethod.UnixTimeToDay(currentTime, 17) + monthValInt, _ := strconv.Atoi(monthVal) + currentDay := int(time.Now().Day()) + sendData["title"] = fmt.Sprintf("%v.%v.%v%v值班表", yearVal, monthVal, currentDay, orgCurre.Name) + sendData["titlePc"] = fmt.Sprintf("%v年%v月%v值班表", yearVal, monthVal, orgCurre.Name) + sendData["year"] = yearValInt + sendData["month"] = monthValInt + + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthEndDay, _ := strconv.Atoi(endTime.Days) + var monthAllDay []string + for i := 1; i <= monthEndDay; i++ { + monthAllDay = append(monthAllDay, fmt.Sprintf("%v日", i)) + } + + //角色权限范围判定 + //1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有 + switch SearchRoleLevev(userCont.Role) { + case 5: + sendData["orgLevel"] = 5 + sendData["orgList"] = GetOrgLevel(313, 1) + case 4: + sendData["orgLevel"] = 4 + sendData["orgList"] = GetOrgLevel(userCont.Company, 1) + case 3: + sendData["orgLevel"] = 3 + sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) + case 2: + sendData["orgLevel"] = 2 + sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) + case 1: + sendData["orgLevel"] = 1 + sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2) + default: + } + + sendData["currentDay"] = currentDay + // sendData["endTime"] = endTime + sendData["monthAllDay"] = monthAllDay + publicmethod.Result(0, sendData, c) +} + +// 获取行政组织层级 +func TestGetOrgLevel(partenId int64, types int) (orgList []GaveOrgAry) { + + gormDb := overall.CONSTANT_DB_HrInside.Model(&GaveOrgAry{}).Where("`state` = 1") + if types == 1 { + gormDb = gormDb.Where("`superior` = ?", partenId) + } else { + gormDb = gormDb.Where("`id` = ?", partenId) + } + gormDb.Order("`sort` ASC").Find(&orgList) + sort.Slice(orgList, func(i, j int) bool { + return orgList[i].Sort < orgList[j].Sort + }) + return +} + +// 获取最大查询范围 +func TestSearchRoleLevev(roles string) (level int) { + roleList := strings.Split(roles, ",") + var roleVerify []modelssystempermission.RoleEmpower + overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `id` IN ? ", "appsystem", roleList).Find(&roleVerify) + for _, v := range roleVerify { + if v.Level >= level { + level = v.Level + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-12 08:36:19 +@ 功能: 获取根据年月获取排班目录表 +*/ +func (a *ApiMethod) TestGetYearMonthWorkMan(c *gin.Context) { + var requestData PaiBanInfo + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.OrgId == 0 { + publicmethod.Result(1, err, c, "未知行政组织!") + return + } + + currentTime := time.Now().Unix() + yearVal := publicmethod.UnixTimeToDay(currentTime, 16) + yearValInt, _ := strconv.Atoi(yearVal) + monthVal := publicmethod.UnixTimeToDay(currentTime, 17) + monthValInt, _ := strconv.Atoi(monthVal) + if requestData.Years != 0 { + yearValInt = requestData.Years + } + if requestData.Months != 0 { + monthValInt = requestData.Months + } + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthEndDay, _ := strconv.Atoi(endTime.Days) + + sendCenter := publicmethod.MapOut[string]() + var currOrgInfo GaveOrgAry + currOrgInfo.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`") + sendCenter["title"] = fmt.Sprintf("%v年%v月%v", yearVal, monthValInt, currOrgInfo.Name) + sendCenter["orgId"] = requestData.OrgId + + var sendData []SendCompanyWork + var orgList []GaveOrgAry + + if requestData.OrgId == 309 { + var gsdaban GaveOrgAry + gsdaban.Id = requestData.OrgId * 10000 + gsdaban.Name = "公司带班" + gsdaban.IsCompany = 1 + orgList = append(orgList, gsdaban) + var gszhiban GaveOrgAry + gszhiban.Id = requestData.OrgId*10000 + 1 + gszhiban.Name = "公司值班" + gszhiban.IsCompany = 1 + orgList = append(orgList, gszhiban) + } else { + var gsld GaveOrgAry + gsld.Id = requestData.OrgId * 10000 + gsld.Name = "公司值班" + gsld.IsCompany = 1 + orgList = append(orgList, gsld) + } + orgListAry := GetOrgLevel(requestData.OrgId, 1) + orgList = append(orgList, orgListAry...) + for _, v := range orgList { + if !publicmethod.IsInTrue[int64](v.Id, paichu) { + var sendInfo SendCompanyWork + sendInfo.OrgInfo.Id = v.Id + sendInfo.OrgInfo.Name = v.Name + sendInfo.OrgInfo.IsCompany = v.IsCompany + var comLog []teamlog.Companylog + overall.CONSTANT_DB_TeamsLog.Where("`orgid` = ? AND `years` = ? AND `months` = ?", v.Id, yearValInt, monthValInt).Find(&comLog) + sendInfo.DutyList = GetOrgParWork(comLog, yearValInt, monthValInt, monthEndDay) + sendData = append(sendData, sendInfo) + } + + } + sendCenter["list"] = sendData + publicmethod.Result(0, sendCenter, c) +} + +func TestGetOrgParWork(comLog []teamlog.Companylog, yearValInt, monthValInt, monthEndDay int) (DutyList []DutyListStruct) { + for i := 1; i <= monthEndDay; i++ { + var dayWorkMan DutyListStruct + + dayWorkMan.Years = yearValInt + dayWorkMan.Months = monthValInt + dayWorkMan.Days = i + for _, v := range comLog { + if i == v.Days { + dayWorkMan.Id = v.ID + dayWorkMan.Holiday = v.Holiday + dayWorkMan.AllDay = GetMAnInfo(v.AllDay, yearValInt, monthValInt, i) + dayWorkMan.BaiTian = GetMAnInfo(v.BaiTian, yearValInt, monthValInt, i) + dayWorkMan.Night = GetMAnInfo(v.Night, yearValInt, monthValInt, i) + dayWorkMan.Morning = GetMAnInfo(v.Morning, yearValInt, monthValInt, i) + dayWorkMan.Afternoon = GetMAnInfo(v.Afternoon, yearValInt, monthValInt, i) + } + } + DutyList = append(DutyList, dayWorkMan) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-12 10:11:10 +@ 功能: 值班人员信息 +*/ +func TestGetMAnInfo(userKey string) (userList []UserCentor) { + if userKey != "" { + userAry := strings.Split(userKey, ",") + if len(userAry) > 0 { + var man []modelshr.ManCont + + overall.CONSTANT_DB_HrInside.Model(&modelshr.ManCont{}).Select("`id`,`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`state` = 1 AND `emp_type` BETWEEN ? AND ? AND `key` IN ?", 1, 10, userAry).Find(&man) + for _, v := range man { + var userInfo UserCentor + userInfo.Id = strconv.FormatInt(v.Id, 10) + userInfo.UserKey = strconv.FormatInt(v.Key, 10) + userInfo.Coder = v.Number + userInfo.Name = v.Name + userInfo.Icon = v.Icon + if v.IconPhpto != "" { + userInfo.Icon = v.IconPhpto + } + userInfo.Wechat = v.Wechat + userInfo.WorkWechat = v.WorkWechat + userInfo.Tel = v.Mobilephone + userInfo.Gender = v.Gender + userList = append(userList, userInfo) + } + } + } + return +} + +// 根据行政组织获取人员信息 +func (a *ApiMethod) TestGeiOrgAllPeople(c *gin.Context) { + var requestData GetOrgPeopel + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.OrgId == 0 { + publicmethod.Result(1, err, c, "未知行政组织!") + return + } + if requestData.IsAll == 0 { + requestData.IsAll = 1 + } + if requestData.IsAll == 1 { + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSunNei(requestData.OrgId) + sunOrg.Id = append(sunOrg.Id, requestData.OrgId) + var userList []UserCentor + if len(sunOrg.Id) > 0 { + var man []modelshr.ManCont + overall.CONSTANT_DB_HrInside.Model(&modelshr.ManCont{}).Select("`id`,`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`state` = 1 AND `emp_type` BETWEEN ? AND ? AND `admin_org` IN ?", 1, 10, sunOrg.Id).Find(&man) + for _, v := range man { + var userInfo UserCentor + userInfo.Id = strconv.FormatInt(v.Id, 10) + userInfo.UserKey = strconv.FormatInt(v.Key, 10) + userInfo.Coder = v.Number + userInfo.Name = fmt.Sprintf("%v(%v)", v.Name, v.Number) + userInfo.Icon = v.Icon + if v.IconPhpto != "" { + userInfo.Icon = v.IconPhpto + } + userInfo.Wechat = v.Wechat + userInfo.WorkWechat = v.WorkWechat + userInfo.Tel = v.Mobilephone + userInfo.Gender = v.Gender + userList = append(userList, userInfo) + } + } + publicmethod.Result(0, userList, c) + } else { + + } + +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-13 08:42:32 +@ 功能: 编辑值班信息 +*/ +func (a *ApiMethod) TestSaveEditDutyInfo(c *gin.Context) { + var requestData DutyOrgInfo + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Orgid == 0 { + publicmethod.Result(1, err, c, "未知行政组织!") + return + } + if requestData.Years == 0 || requestData.Months == 0 || requestData.Days == 0 { + publicmethod.Result(1, err, c, "未知时间安排!") + return + } + holiday := 2 + if requestData.Holiday != "" { + holiday, _ = strconv.Atoi(requestData.Holiday) + if holiday == 0 { + holiday = 2 + } + } + isAdd := true + monthval := fmt.Sprintf("%v", requestData.Months) + if requestData.Months < 10 { + monthval = fmt.Sprintf("0%v", requestData.Months) + } + daysval := fmt.Sprintf("%v", requestData.Days) + if requestData.Days < 10 { + daysval = fmt.Sprintf("0%v", requestData.Days) + } + timeStr := fmt.Sprintf("%v-%v-%v 12:00:00", requestData.Years, monthval, daysval) + var timeVal publicmethod.DateTimeTotimes + timeVal.BaisStrToTime(timeStr) + if requestData.Id != 0 { + var oldDutyCont teamlog.Companylog + err = oldDutyCont.GetCont(map[string]interface{}{"`id`": requestData.Id}) + if err == nil { + isAdd = false + saveEitd := publicmethod.MapOut[string]() + saveEitd["`holiday`"] = holiday + saveEitd["allDay"] = strings.Join(requestData.AllDay, ",") + saveEitd["baiTian"] = strings.Join(requestData.BaiTian, ",") + saveEitd["night"] = strings.Join(requestData.Night, ",") + saveEitd["morning"] = strings.Join(requestData.Morning, ",") + saveEitd["afternoon"] = strings.Join(requestData.Afternoon, ",") + saveEitd["saveTime"] = time.Now().Unix() + var newDutyCont teamlog.Companylog + err = newDutyCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveEitd) + if err != nil { + publicmethod.Result(106, err, c) + return + } + } + } + + if isAdd { + var saveConter teamlog.Companylog + saveConter.Orgid = requestData.Orgid // 行政组织ID + saveConter.RunTime = timeVal.AllTime // 执行时间 + saveConter.Years = requestData.Years // 年 + saveConter.Months = requestData.Months // 月 + saveConter.Days = requestData.Days // 日 + saveConter.Holiday = holiday // 假日(1:是;2:否) + saveConter.AllDay = strings.Join(requestData.AllDay, ",") // 全天值班人员 + saveConter.BaiTian = strings.Join(requestData.BaiTian, ",") // 白天值班人员 + saveConter.Night = strings.Join(requestData.Night, ",") // 夜晚值班人员 + saveConter.Morning = strings.Join(requestData.Morning, ",") // 夜晚值班人员 + saveConter.Afternoon = strings.Join(requestData.Afternoon, ",") // 夜晚值班人员 + saveConter.SaveTime = time.Now().Unix() // 编辑时间 + err = overall.CONSTANT_DB_TeamsLog.Create(&saveConter).Error + if err != nil { + publicmethod.Result(106, err, c) + return + } + } + publicmethod.Result(0, err, c) +} + +// 根据日期获取行政组织排班列表 +func (a *ApiMethod) TestGeyOneDayDuty(c *gin.Context) { + var requestData OenDayDuty + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.OrgId == 0 { + publicmethod.Result(1, err, c, "未知行政组织!") + return + } + currentTime := time.Now().Unix() + yearVal := publicmethod.UnixTimeToDay(currentTime, 16) + yearValInt, _ := strconv.Atoi(yearVal) + monthVal := publicmethod.UnixTimeToDay(currentTime, 17) + monthValInt, _ := strconv.Atoi(monthVal) + dayhVal := publicmethod.UnixTimeToDay(currentTime, 18) + dayhValInt, _ := strconv.Atoi(dayhVal) + if requestData.Years != 0 { + yearValInt = requestData.Years + } + if requestData.Months != 0 { + monthValInt = requestData.Months + } + if requestData.Days != 0 { + dayhValInt = requestData.Days + } + sendCenter := publicmethod.MapOut[string]() + var currOrgInfo GaveOrgAry + // currOrgInfo.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`") + overall.CONSTANT_DB_HrInside.Model(&currOrgInfo).Select("`name`").Where("`id` = ?", requestData.OrgId).First(&currOrgInfo) + sendCenter["title"] = fmt.Sprintf("%v.%v.%v%v", yearVal, monthValInt, dayhValInt, currOrgInfo.Name) + sendCenter["orgId"] = requestData.OrgId + var orgList []GaveOrgAry + + if requestData.OrgId == 309 { + var gsdaban GaveOrgAry + gsdaban.Id = requestData.OrgId * 10000 + gsdaban.Name = "公司带班" + gsdaban.IsCompany = 1 + orgList = append(orgList, gsdaban) + var gszhiban GaveOrgAry + gszhiban.Id = requestData.OrgId*10000 + 1 + gszhiban.Name = "公司值班" + gsdaban.IsCompany = 1 + orgList = append(orgList, gszhiban) + } else { + var gsld GaveOrgAry + gsld.Id = requestData.OrgId * 10000 + gsld.Name = "公司值班" + gsld.IsCompany = 1 + orgList = append(orgList, gsld) + } + orgListAry := GetOrgLevel(requestData.OrgId, 1) + orgList = append(orgList, orgListAry...) + + var sendData []WebSendTo + for _, v := range orgList { + if !publicmethod.IsInTrue[int64](v.Id, paichu) { + var sendInfo WebSendTo + sendInfo.OrgId = v.Id + sendInfo.OrgName = v.Name + sendInfo.IsCompany = v.IsCompany + var comLog teamlog.Companylog + err = overall.CONSTANT_DB_TeamsLog.Where("`orgid` = ? AND `years` = ? AND `months` = ? AND `days` = ?", v.Id, yearValInt, monthValInt, dayhValInt).First(&comLog).Error + if err == nil { + sendInfo.Id = strconv.FormatInt(comLog.ID, 10) + sendInfo.Holiday = comLog.Holiday + sendInfo.AllDay = GetMAnInfo(comLog.AllDay, yearValInt, monthValInt, dayhValInt) + sendInfo.BaiTian = GetMAnInfo(comLog.BaiTian, yearValInt, monthValInt, dayhValInt) + sendInfo.Night = GetMAnInfo(comLog.Night, yearValInt, monthValInt, dayhValInt) + sendInfo.Morning = GetMAnInfo(comLog.Morning, yearValInt, monthValInt, dayhValInt) + sendInfo.Afternoon = GetMAnInfo(comLog.Afternoon, yearValInt, monthValInt, dayhValInt) + sendData = append(sendData, sendInfo) + } + + } + + } + sendCenter["list"] = sendData + publicmethod.Result(0, sendCenter, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-13 21:24:02 +@ 功能: 清空日期值班 +*/ +func (a *ApiMethod) TestDelOneDayDuty(c *gin.Context) { + var requestData publicmethod.CommonId[int64] + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == 0 { + publicmethod.Result(1, err, c, "未知删除项目!") + return + } + var comLog teamlog.Companylog + err = comLog.DelCont(map[string]interface{}{"`id`": requestData.Id}) + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-14 11:20:51 +@ 功能: 获取排版信息 +*/ +func (a *ApiMethod) TestGetDutyCont(c *gin.Context) { + var requestData publicmethod.PublicId + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(1, err, c, "未知项目!") + return + } + var comLog CompanyDutyCont + comLog.GetCont(map[string]interface{}{"`id`": requestData.Id}) + if comLog.AllDay != "" { + comLog.AllDayAry = strings.Split(comLog.AllDay, ",") + } else { + comLog.AllDayAry = []string{} + } + if comLog.BaiTian != "" { + comLog.BaiTianAry = strings.Split(comLog.BaiTian, ",") + } else { + comLog.BaiTianAry = []string{} + } + if comLog.Night != "" { + comLog.NightAry = strings.Split(comLog.Night, ",") + } else { + comLog.NightAry = []string{} + } + if comLog.Morning != "" { + comLog.MorningAry = strings.Split(comLog.Morning, ",") + } else { + comLog.MorningAry = []string{} + } + if comLog.Afternoon != "" { + comLog.AfternoonAry = strings.Split(comLog.Afternoon, ",") + } else { + comLog.AfternoonAry = []string{} + } + publicmethod.Result(0, comLog, c) +} diff --git a/api/version1/customerApp/type.go b/api/version1/customerApp/type.go index c0dbc7f..0f74461 100644 --- a/api/version1/customerApp/type.go +++ b/api/version1/customerApp/type.go @@ -5,6 +5,7 @@ import ( "appPlatform/api/version1/publicapi" "appPlatform/models/modelAppPlatform" "appPlatform/models/modelshr" + "appPlatform/models/teamlog" "appPlatform/overall/publicmethod" "sync" @@ -323,3 +324,386 @@ type MoveAppMenusId struct { type AppSunMenus struct { Key []int64 `json:"key"` } + +// 输出公司值班页面 +type PaiBanInfo struct { + OrgId int64 `json:"orgId"` + Years int `json:"years"` + Months int `json:"month"` +} + +// 获取单日值班信息 +type OenDayDuty struct { + PaiBanInfo + Days int `json:"day"` +} + +// 返回排班列表 +type SendCompanyWork struct { + OrgInfo OrgInfoStruct `json:"orgInfo"` //行政组织信息 + DutyList []DutyListStruct `json:"dutyList"` //值班信息 +} + +// 人员列表 +type DutyListStruct struct { + Id int64 `json:"id"` + Years int `json:"years"` //年 + Months int `json:"month"` //月 + Days int `json:"days"` //日 + Holiday int `json:"holiday"` // 假日(1:是;2:否) + AllDay []UserCentor `json:"allDay"` // 全天值班人员 + BaiTian []UserCentor ` json:"baiTian"` // 白天值班人员 + Night []UserCentor `json:"night"` // 夜晚值班人员 + Morning []UserCentor `json:"morning"` // 上午值班人员 + Afternoon []UserCentor `json:"afternoon"` // 下午值班人员 +} + +// 人员信息 +type UserCentor struct { + publicmethod.CommonId[string] + publicmethod.PublicName + Coder string `json:"coder"` //工号 + Icon string `json:"icon"` //头像 + Wechat string `json:"wechat"` //微信 + WorkWechat string `json:"workWechat"` //企业微信微信 + Tel string `json:"tel"` //联系电话 + Gender int `json:"gender"` //性别 + UserKey string `json:"userKey"` //员工唯一识别符 +} + +// 行政组织信息 +type OrgInfoStruct struct { + Id int64 `json:"id"` + publicmethod.PublicName + IsCompany int `json:"isCompany"` +} + +// 接收行政组织排版信息 +type DutyOrgInfo struct { + Id int64 `json:"id"` + Orgid int64 `json:"orgid"` + Years int `json:"years"` //年 + Months int `json:"month"` //月 + Days int `json:"days"` //日 + Holiday string `json:"holiday"` // 假日(1:是;2:否) + AllDay []string `json:"allDay"` // 全天值班人员 + BaiTian []string ` json:"baiTian"` // 白天值班人员 + Night []string `json:"night"` // 夜晚值班人员 + Morning []string `json:"morning"` // 上午值班人员 + Afternoon []string `json:"afternoon"` // 下午值班人员 +} + +// 写入身份认证 +type WriteIderCont struct { + Openid string `json:"openid"` + Key string `json:"key"` + Token string `json:"token"` + UserInfo UserInfoCont `json:"userinfo"` +} + +// 人员信息 +type UserInfoCont struct { + Number string `json:"number"` + Password string `json:"password"` + Key string `json:"key"` +} + +// 使用端输出 +type WebSendTo struct { + publicmethod.CommonId[string] + OrgId int64 `json:"orgId"` + OrgName string `json:"orgName"` // 假日(1:是;2:否) + Holiday int `json:"holiday"` // 假日(1:是;2:否) + AllDay []UserCentor `json:"allDay"` // 全天值班人员 + BaiTian []UserCentor ` json:"baiTian"` // 白天值班人员 + Night []UserCentor `json:"night"` // 夜晚值班人员 + Morning []UserCentor `json:"morning"` // 上午值班人员 + Afternoon []UserCentor `json:"afternoon"` // 下午值班人员 + IsCompany int `json:"isCompany" ` +} + +// 获取人员 +type GetOrgPeopel struct { + OrgId int64 `json:"orgId"` + CompanyId int64 `json:"companyId"` + IsAll int `json:"isAll"` +} + +type GaveOrgAry struct { + modelshr.AdministrativeOrganization + IsCompany int `json:"isCompany" gorm:"-"` +} + +// 输出个人信息 +type CompanyDutyCont struct { + teamlog.Companylog + AllDayAry []string `json:"allDayAry" gorm:"-"` // 全天值班人员 + BaiTianAry []string `json:"baiTianAry" gorm:"-"` // 白天值班人员 + NightAry []string `json:"nightAry" gorm:"-"` + MorningAry []string `json:"morningAry" gorm:"-"` + AfternoonAry []string `json:"afternoonAry" gorm:"-"` + AllDayAryAll []SendOrgPeopelList `json:"allDayAryAll" gorm:"-"` // 全天值班人员 + BaiTianAryAll []SendOrgPeopelList `json:"baiTianAryAll" gorm:"-"` // 白天值班人员 + NightAryAll []SendOrgPeopelList `json:"nightAryAll" gorm:"-"` + MorningAryAll []SendOrgPeopelList `json:"morningAryAll" gorm:"-"` + AfternoonAryAll []SendOrgPeopelList `json:"afternoonAryAll" gorm:"-"` +} + +// 人员基础信息 +type PeopleInfo struct { + UserNumber string `json:"userNumber"` + UserName string `json:"userName"` + UserKey string `json:"userKey"` + UserAvatar string `json:"userAvatar"` +} + +// 行政组织树查询 +type OrgAndMAnThreeType struct { + Id string `json:"id"` + Level int `json:"level"` + All int `json:"all"` +} + +// 输出行政组织与人员 +type OrgAndManThree struct { + OrgAndEveryOnePeople + Child []OrgAndManThree `json:"child"` //子栏目 +} + +// 行政组织与个人列表 +type OrgAndEveryOnePeople struct { + Id string `json:"id"` //识别符 + OrgId int64 `json:"orgid"` //行政组织Id + Number string `json:"number"` //编号 + Name string `json:"name"` //姓名 + Superior string `json:"superior"` //上级 + Icon string `json:"icon"` //头像 + IconPhoto string `json:"icon_photo"` //头像 + Type int `json:"type"` //类型 1:行政组织;2:人员 + Key string `json:"key"` //列表识别 + Sort int `json:"sort"` //排序 + Wechat string `json:"wechat"` //微信或企业微信 + DepartmentId int64 `json:"departmentid"` //部门ID + DepartmentName string `json:"departmentname"` //部门名称 + PostId int64 `json:"postid"` //岗位ID + PostName string `json:"postname"` //岗位名称 + Tema int64 `json:"tema"` //班组Id + TemaName string `json:"temaname"` //班组名称 +} + +// 授权协程操作 +var synPro = sync.WaitGroup{} + +type empowerSync struct { + orgAndPeopleList []OrgAndEveryOnePeople + mutext sync.RWMutex +} + +// 读取行政组织与个人列表协程数据 +func (d *empowerSync) readDataLock() []OrgAndEveryOnePeople { + d.mutext.RLock() + defer d.mutext.RUnlock() + return d.orgAndPeopleList +} + +// 解除人员信息锁定 +type JieLockUser struct { + UserId string `json:"userId"` +} + +// 简略行政树 +type JianLueOrgTree struct { + Id int64 `json:"id"` + Name string `json:"name"` + Superior int64 `json:"superior"` + Sort int `json:"sort"` + Children []JianLueOrgTree `json:"children"` +} + +// 获取行政组织人员信息 +type OrgPeopinCenter struct { + Id int64 `json:"id"` + Name string `json:"name"` + Page int `json:"page"` + PageSize int `json:"pagesize"` +} + +// 输出行政组织人员 +type SendOrgPeopelList struct { + PeopleInfo + TelStr string `json:"telStr"` +} + +// 删除日历单一人员 +type DelOneUsRili struct { + Id int64 `json:"id"` + Types int `json:"types"` + UserAry []string `json:"userAry"` // 全天值班人员 +} + +// 人员基础信息 +type UploaArg struct { + OrgId interface{} `json:"orgId"` + Types interface{} `json:"types"` + DateTime interface{} `json:"dateTime"` +} + +// 解析排班信息 +type AlaDutyInfo struct { + OrgId int64 `json:"orgId"` + Types int `json:"types"` + DateTime int64 `json:"dateTime"` + RedisKey string `json:"redisKey"` + Number int64 `json:"number"` +} + +type NodePublicInfoES struct { + NodeNumber string `json:"nodeNumber"` //节点识别符 + NodeName string `json:"nodeName"` //节点名称 + Types int `json:"type"` //0:发起人;1:审批;2:抄送;3:执行人;4:条件;5:路由 + FromNode string `json:"fromNode"` //来源节点 + GotoNode []string `json:"gotoNode"` //流向节点 + PriorityLevel int `json:"priorityLevel"` // 条件优先级 + Attribute int `json:"attribute"` //属性 1:申请人为基线;2:目标人为基线 + Errors bool `json:"error"` //当前审批是否通过校验 + CcSelfSelectFlag int `json:"ccSelfSelectFlag"` //允许发起人自选抄送人(0:不允许;1:允许) + NodeUserList []NodeUserListInfo `json:"nodeUserList"` //操作人 + ConditionList []ConditionListInfo `json:"conditionList"` //判断条件主体 + ChildNode *NodePublicInfo `json:"childNode"` //子节点 + ChannerUpdates []string `json:"channerUpdate"` //触发更新流程字段 +} + +// 判断条件主体 +type ConditionListInfo struct { + publicmethod.CommonId[int] //条件顺序 + publicmethod.PublicName //条件名称 + Factorid string `json:"factorid"` //条件识别字段 + Types int `json:"type"` //条件类型:1:人员、行政组织、角色;2:自定义字段;3:关联表单字段; + Isok bool `json:"isok"` //页面渲染使用 + IsCheckbox bool `json:"isCheckbox"` //结果值多选 + Options []OptionsInfo `json:"options"` //可选项(用于关联表单使用) + Oneanswer string `json:"oneanswer"` //可选项锚定值(用于关联表单使用) + Answers []string `json:"answers"` //可选项锚定值(用于关联表单使用) + CustomFields []CustomFieldsInfo `json:"customFields"` //自定义字段条件主体 + NodeUserList []FlowPermissionInfo `json:"nodeUserList"` //人员、行政组织、角色为条件主体 +} + +// 自定义字段条件主体 +type CustomFieldsInfo struct { + Wordfield string `json:"wordfield"` //判断字段 + OptType string `json:"optType"` //判定方法(1:小于;2:大于;3:小于等于;4:等于;5:大于等于;6:介于两数之间;7:包含;8:不包含) + LeftVal string `json:"leftval"` //左侧值 + LeftOptType string `json:"leftoptType"` //OptType值为6时;左侧判定方法 + RightOptType string `json:"rightoptType"` //OptType值为6时;右侧判定方法 + RightVal string `json:"rightval"` //OptType值为6时;右侧值 +} + +// 节点执行人 +type NodeUserListInfo struct { + FlowPermissionInfo + publicmethod.CommonId[string] + publicmethod.PublicName + Options []OptionsInfo `json:"options"` //可选项(用于关联表单使用) + IsCheckbox bool `json:"isCheckbox"` //结果值多选 +} + +// 人员;角色;行政组织;职务通用结构体 +type FlowPermissionInfo struct { + Types int `json:"type"` //1:人员;2:角色;3:行政组织;4:职务 + TargetId string `json:"targetId"` //相关内容识别符 + publicmethod.PublicName //相关内容名称 + Icon string `json:"icon"` //头像 + IconToBase64 string `json:"iconToBase64"` //头像Base64 +} + +// 可选项(用于关联表单使用) +type OptionsInfo struct { + Label string `json:"label"` //名称 + Value string `json:"value"` //值 +} + +// 流程节点 +type NodePublicInfo struct { + NodePublicInfoES + Settype int `json:"settype"` // 审批人设置 1:指定成员; 2:主管;3:行政岗位; 4:发起人自选; 5:发起人自己;6:连续多级主管;7:指定前置审批为本节点设置审批人;8:表单字段;9:权限矩阵 + SelectMode int `json:"selectMode"` //审批人数 1选一个人 2选多个人 + SelectRange int `json:"selectRange"` //选择范围 1.全公司 2指定成员 3指定角色 + DirectorLevel int `json:"directorLevel"` //审批终点 最高层主管数 + ExamineMode int `json:"examineMode"` //多人审批时采用的审批方式 1:依次审批; 2:会签;3:非会签 + NoHanderAction int `json:"noHanderAction"` //审批人为空时 1自动审批通过/不允许发起 2转交给审核管理员 + ExamineEndDirectorLevel int `json:"examineEndDirectorLevel"` //审批终点 第n层主管 + SendBackNode string `json:"sendBackNode"` //退回哪个节点 + CustomNode string `json:"customNode"` //指定前置审批为本节点设置审批人 + + ConditionNodes []NodePublicInfoES `json:"conditionNodes"` //判断条件,当节点是路由时有效 + Executionaddress string `json:"executionaddress"` //第三方执行地址 + + ChildNode *NodePublicInfo `json:"childNode"` //子节点 + Matrix MatrixInfo `json:"matrix"` // + OrgList []int64 `json:"orgList"` //指定行政组织,由其负责人审批 + HelpTips string `json:"helpTips"` //节点帮助说明 + + ChannerUpdate []string `json:"channerUpdate"` //触发更新流程字段 +} + +// 矩阵信息 +type MatrixInfo struct { + MatrixId int64 `json:"matrixid"` + FactorId int64 `json:"factorid"` + OutcomeId int64 `json:"outcomeid"` + MatrixName string `json:"matrixName"` + FactorName string `json:"factorName"` + OutcomeName string `json:"outcomeName"` + List []MartOpter `json:"list"` +} +type MartOpter struct { + OutcomeId int64 `json:"outcomeid"` + OutcomeName string `json:"outcomeName"` +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-04-09 10:56:48 +@ 功能: 工作流结构主体 +*/ +type FlowMainBody struct { + TableId string `json:"tableId"` //工作流识别吗 + WorkFlowDef WorkFlowDefInfo `json:"workFlowDef"` //工作流主体属性 + DirectorMaxLevel int `json:"directorMaxLevel"` //审批主管最大层级 + FlowPermission []FlowPermissionInfo `json:"flowPermission"` //流程发起人 + NodeConfig NodePublicInfo `json:"nodeConfig"` //节点信息内容 +} + +// 工作流主体属性 +type WorkFlowDefInfo struct { + FormKey string `json:"formKey"` //关联操作ID + publicmethod.PublicName //姓名 +} + +// 返回自定义表单数据 +type CallBackFormStruct struct { + modelAppPlatform.CustomerFormView + FlowkeyStr string `json:"flowkeystr" gorm:"-"` + CreaterStr string `json:"createrstr" gorm:"-"` + IdStr string `json:"idStr" gorm:"-"` + PowerAry []NodePowerInfoNew `json:"powerAry" gorm:"-"` +} + +// 节点权限结构体--> +type NodePowerInfoNew struct { + NodeKey string `json:"nodeKey"` + PowerAry []NodesUnitNameStatue `json:"powerAry"` + ApiSetup apiSetupStruct `json:"apiSetup"` +} +type NodesUnitNameStatue struct { + publicmethod.PublicId + publicmethod.PublicName + publicmethod.PublicStatus + IsLook bool `json:"isLook"` + IsEdit bool `json:"isEdit"` +} +type apiSetupStruct struct { + Title []interface{} `json:"title"` + Library []interface{} `json:"library"` +} diff --git a/api/version1/customerform/calendarData.go b/api/version1/customerform/calendarData.go index 1674811..3550086 100644 --- a/api/version1/customerform/calendarData.go +++ b/api/version1/customerform/calendarData.go @@ -75,7 +75,7 @@ func (a *ApiMethod) CalendarDataList(c *gin.Context) { 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) + go listSynv.HaveEveryDayData(v, formInfo, userCont, requestData.Search, listField, listFieldsMap.View, formJsonCont) } syncSeting.Wait() sendListArt := TimeHaveAry(requestData.TimeAry, listSynv.List) @@ -95,7 +95,7 @@ func (a *ApiMethod) CalendarDataList(c *gin.Context) { 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) + go listSynv.HaveEveryDayData(tv, formInfo, userCont, requestData.Search, listField, listFieldsMap.View, formJsonCont) } syncSeting.Wait() sendMonthList = append(sendMonthList, TimeHaveAry(v, listSynv.List)) @@ -127,12 +127,12 @@ func (a *ApiMethod) CalendarDataList(c *gin.Context) { # */ -func (c *CalendarList) HaveEveryDayData(day TimeAryInfo, tableName string, userCont modelshr.ManCont, Search FormPageListAttr, listField []SearchButtonInfo, viewCondition map[string]ViewInfo, listJson string, formJsonCont CustomerFormMaster) { +func (c *CalendarList) HaveEveryDayData(day TimeAryInfo, formInfo modelAppPlatform.CustomerFormView, userCont modelshr.ManCont, Search FormPageListAttr, listField []SearchButtonInfo, viewCondition map[string]ViewInfo, formJsonCont CustomerFormMaster) { defer syncSeting.Done() - tableName = fmt.Sprintf("`%v` as f", tableName) //表明 + 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.`creater` = ? ", userCont.Key) // gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2) gormDb = gormDb.Where("f.`states` = ?", 1) gormDb = AnalysisSerachTermSqlIng(listField, gormDb) //将查询条件转换成 @@ -158,17 +158,33 @@ func (c *CalendarList) HaveEveryDayData(day TimeAryInfo, tableName string, userC } } else { whySql := fmt.Sprintf("f.`creater_time` BETWEEN %v AND %v", startTime, endTime) + fmt.Printf("语句5===》%v\n", whySql) gormDb = gormDb.Where(whySql) } } else { whySql := fmt.Sprintf("f.`creater_time` BETWEEN %v AND %v", startTime, endTime) + fmt.Printf("语句6===》%v\n", whySql) gormDb = gormDb.Where(whySql) } + + //Step 2 权限处理 + var powerSearch publicmethod.GainUserPower + powerSearch.SystemName = "appsystem" //系统名称 + powerSearch.RoleId = userCont.Role //角色列表 + powerSearch.OrgId = userCont.AdminOrg //行政组织 + powerSearch.PostId = userCont.Position //岗位 + powerSearch.AppKey = formInfo.Groupid //归属哪个App + powerSearch.TableId = formInfo.CfId //归属哪个表格 + gormDb = powerSearch.MakeSearchSql(gormDb, userCont, formJsonCont.Form.DataSource) + var formList []map[string]interface{} err := gormDb.Order("`id` DESC").Find(&formList).Error - if listJson != "" { + + fmt.Printf("查询出来的结果是------>%v\n\n\n\n", formList) + + if formInfo.ListJson != "" { var listFieldsMap ListPageFields - err = json.Unmarshal([]byte(listJson), &listFieldsMap) + err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) if err == nil { formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont) } diff --git a/api/version1/customerform/form.go b/api/version1/customerform/form.go index eaf4f8a..ddf87db 100644 --- a/api/version1/customerform/form.go +++ b/api/version1/customerform/form.go @@ -1271,6 +1271,14 @@ func (a *ApiMethod) EnableVersion(c *gin.Context) { } overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerFormVersion{}).Where("`tablekey` = ? AND `status` = 1", formVersion.TableKey).Updates(map[string]interface{}{"`status`": 2}) err = formVersion.EiteCont(map[string]interface{}{"`id`": requestData.Id}, map[string]interface{}{"`status`": 1}) + if formVersion.ListJsonInfo != "" { + var customerFormInfo modelAppPlatform.CustomerForm + editInfo := publicmethod.MapOut[string]() + editInfo["listjson"] = formVersion.ListJsonInfo + editInfo["edit_time"] = time.Now().Unix() + err = customerFormInfo.EiteCont(map[string]interface{}{"`tablename`": formVersion.TableKey}, editInfo) + } + publicmethod.Result(0, err, c) } diff --git a/api/version1/customerform/formTable.go b/api/version1/customerform/formTable.go index 6c4a4ff..b8a7052 100644 --- a/api/version1/customerform/formTable.go +++ b/api/version1/customerform/formTable.go @@ -580,7 +580,7 @@ func MakeSql(tablename string, fieldCont AnalysisFormSubUnitClass, fieldList []R # */ -func (f *FormUnitInfo) GainMasterAndSunFormUnit(tablename string, subUnitAry []MasterStruct, isMaster bool) { +func (f *FormUnitInfo) GainMasterAndSunFormUnit(tablename, tableTitle string, subUnitAry []MasterStruct, isMaster bool) { if len(subUnitAry) > 0 { unitAry := make(map[string]MasterStruct) for _, v := range subUnitAry { @@ -588,17 +588,17 @@ func (f *FormUnitInfo) GainMasterAndSunFormUnit(tablename string, subUnitAry []M switch wordClass.UnitName { case "flex", "table": if len(v.List) > 0 { - f.GainMasterAndSunFormUnit(v.Name, v.List, false) + f.GainMasterAndSunFormUnit(v.Name, v.Item.Label, v.List, false) } case "grid", "tabs": if len(v.Columns) > 0 { for _, mv := range v.Columns { - f.GainMasterAndSunFormUnit(tablename, mv.List, isMaster) + f.GainMasterAndSunFormUnit(tablename, v.Item.Label, mv.List, isMaster) } } case "card", "div": if len(v.List) > 0 { - f.GainMasterAndSunFormUnit(tablename, v.List, isMaster) + f.GainMasterAndSunFormUnit(tablename, v.Item.Label, v.List, isMaster) } default: // unitAry = append(unitAry, v) @@ -626,12 +626,14 @@ func (f *FormUnitInfo) GainMasterAndSunFormUnit(tablename string, subUnitAry []M if isWrite { var sunTableCont SunFormInfoList sunTableCont.TableName = tablename + sunTableCont.TableTitle = tableTitle sunTableCont.UbitInfo = unitAry f.SunFormInfo = append(f.SunFormInfo, sunTableCont) } } else { var sunTableCont SunFormInfoList sunTableCont.TableName = tablename + sunTableCont.TableTitle = tableTitle sunTableCont.UbitInfo = unitAry f.SunFormInfo = append(f.SunFormInfo, sunTableCont) } @@ -775,16 +777,20 @@ func (a *ApiMethod) GainFormTableField(c *gin.Context) { return } var customerFormMaster modelAppPlatform.CustomerFormView - err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`") + err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`listJsonInfo`") if err != nil { publicmethod.Result(1, err, c, "未知表单!无法获取字段!") return } + ListJsonCentent := customerFormMaster.ListJson + if customerFormMaster.ListJsonInfo != "" { + ListJsonCentent = customerFormMaster.ListJsonInfo + } var masterTable []Result var listFieldsMap ListPageFields - if customerFormMaster.ListJson != "" { + if ListJsonCentent != "" { - json.Unmarshal([]byte(customerFormMaster.ListJson), &listFieldsMap) + json.Unmarshal([]byte(ListJsonCentent), &listFieldsMap) fmt.Printf("判断结果%v", JhudgeIsTitle(listFieldsMap)) if JhudgeIsTitle(listFieldsMap) { var myKeyWord Result @@ -825,6 +831,7 @@ func (a *ApiMethod) GainFormTableField(c *gin.Context) { if err == nil { masterTable = append(masterTable, masterTableAll...) } + } else { masterTableAll, err := GainFormTableField(customerFormMaster.TableKey) if err == nil { @@ -1298,6 +1305,11 @@ func (a *ApiMethod) EditCustomerFormList(c *gin.Context) { publicmethod.Result(1, err, c, "编辑失败!请重新提交!") return } + editInfoVersion := publicmethod.MapOut[string]() + editInfoVersion["listJsonInfo"] = requestData.Data + editInfoVersion["edit_time"] = time.Now().Unix() + var formInfo modelAppPlatform.CustomerFormView + formInfo.EiteCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, editInfoVersion) publicmethod.Result(0, err, c) } @@ -1335,6 +1347,12 @@ func (a *ApiMethod) GainFormListCont(c *gin.Context) { publicmethod.Result(1, err, c, "未知表单!无法获取字段!3") return } + + var formInfo modelAppPlatform.CustomerFormView + formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`listJsonInfo`") + if formInfo.ListJsonInfo != "" { + customerFormInfo.ListJson = formInfo.ListJsonInfo + } publicmethod.Result(0, customerFormInfo, c) } @@ -1642,6 +1660,8 @@ func gainMasterSunList(tableName string, masterKey int64, formJsonCont CustomerF sunTable = v } } + jsonCont, _ := json.Marshal(sunTable) + fmt.Printf(" 获取每条数据得子数据列表------->%v\n------->%v\n------->%v\n", tableName, masterKey, string(jsonCont)) list = listFieldsMap.SunTableForm(list, masterKey, sunTable) } @@ -1660,6 +1680,7 @@ func (l *ListPageFields) SunTableForm(listData []map[string]interface{}, masterK for _, v := range listData { sendInfo := publicmethod.MapOut[string]() for mi, mv := range v { + // fmt.Printf("mi------------>%v\n\n\n", mi) switch mi { case "creater": mvInt, _ := publicmethod.StringToInt64(mv) @@ -1667,21 +1688,34 @@ func (l *ListPageFields) SunTableForm(listData []map[string]interface{}, masterK var myInfo modelshr.PersonArchives myInfo.GetCont(map[string]interface{}{"`key`": mvInt}, "`name`") sendInfo[mi] = myInfo.Name + } else { + sendInfo[mi] = "" } case "creater_time": timeInt, _ := publicmethod.StringToInt64(mv) - sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + if timeInt == 0 { + sendInfo[mi] = "" + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + } case "edit_time": + timeInt, _ := publicmethod.StringToInt64(mv) - sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27) + if timeInt == 0 { + sendInfo[mi] = "" + } else { + 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 { + // fmt.Printf("lv.FieldClass------------>%v\n\n\n", lv.FieldClass) switch lv.FieldClass { case "radio": for _, ov := range lv.Options { @@ -1697,25 +1731,66 @@ func (l *ListPageFields) SunTableForm(listData []map[string]interface{}, masterK switch lv.Auxiliary { case "year": - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 16) + if timeVal == 0 { + sendInfo[mi] = "" + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 16) + } case "month": - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 15) + if timeVal == 0 { + sendInfo[mi] = "" + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 15) + } case "datetime": - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 11) + if timeVal == 0 { + sendInfo[mi] = "" + } else { + sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 11) + } case "week": - sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 41) + if timeVal == 0 { + sendInfo[mi] = "" + } else { + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 41) + sendInfo[mi] = beginTime + } + // sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 41) case "datetimerange": - beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 11) - sendInfo[mi] = beginTime + if timeVal == 0 { + sendInfo[mi] = "" + } else { + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 11) + sendInfo[mi] = beginTime + } + // beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 11) + // sendInfo[mi] = beginTime case "daterange": - beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) - sendInfo[mi] = beginTime + if timeVal == 0 { + sendInfo[mi] = "" + } else { + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) + sendInfo[mi] = beginTime + } + // beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) + // sendInfo[mi] = beginTime case "monthrange": - beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 15) - sendInfo[mi] = beginTime + if timeVal == 0 { + sendInfo[mi] = "" + } else { + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 15) + sendInfo[mi] = beginTime + } + // beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 15) + // sendInfo[mi] = beginTime default: - beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) - sendInfo[mi] = beginTime + if timeVal == 0 { + sendInfo[mi] = "" + } else { + beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14) + sendInfo[mi] = beginTime + } + } case "timePicker": timeVal, _ := publicmethod.StringToInt64(mv) @@ -1785,12 +1860,155 @@ func (l *ListPageFields) SunTableForm(listData []map[string]interface{}, masterK @ 功能: 根据字段显示格式处理数据 */ func (l *ListPageFields) BaseSunTableAttrField(key string, val interface{}, sunTable MasterStruct) interface{} { - if len(l.TableData.Columns) < 0 { - return val + // fmt.Printf("l.TableData.Columns------------>%v\n\n\n", val) + // if len(l.TableData.Columns) < 0 { + // return val + // } + for _, v := range sunTable.List { + if v.Name == key { + fmt.Printf("l.TableData.Columns------123------>%v-------->%v-------->%v\n\n\n", v.Name, key, v.Type) + switch v.Type { + case "radio": + for _, ov := range v.Options { + + radioId := publicmethod.TypeToInterface(val) + if radioId == ov.Value { + return ov.Label + } + } + case "datePicker": + var beginTime int64 + timeVal, _ := publicmethod.StringToInt64(val) + if publicmethod.GetIntLength(timeVal) >= 13 { + beginTime = timeVal / 1000 + } else { + beginTime = timeVal + } + switch v.Control.Type { + case "year": + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 16) + } + // return publicmethod.UnixTimeToDay(beginTime, 16) + case "month": + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 15) + } + // return publicmethod.UnixTimeToDay(beginTime, 15) + case "datetime": + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 11) + } + // return publicmethod.UnixTimeToDay(beginTime, 11) + case "week": + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 41) + } + // return publicmethod.UnixTimeToDay(beginTime, 41) + case "datetimerange": + // beginTime = publicmethod.UnixTimeToDay(beginTime, 11) + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 11) + } + // return publicmethod.UnixTimeToDay(beginTime, 11) + case "daterange": + // beginTime = publicmethod.UnixTimeToDay(beginTime, 14) + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 14) + } + // return publicmethod.UnixTimeToDay(beginTime, 14) + case "monthrange": + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 15) + } + // return publicmethod.UnixTimeToDay(beginTime, 15) + default: + // beginTime = publicmethod.UnixTimeToDay(beginTime, 14) + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 14) + } + + } + case "timePicker": + var beginTime int64 + timeVal, _ := publicmethod.StringToInt64(val) + if publicmethod.GetIntLength(timeVal) >= 13 { + beginTime = timeVal / 1000 + } else { + beginTime = timeVal + } + if beginTime == 0 { + return "" + } else { + return publicmethod.UnixTimeToDay(beginTime, 11) + } + + case "deptOrg": + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": val}, "`name`") + return orgCont.Name + case "owner": + var userInfo modelshr.PersonArchives + userInfo.GetCont(map[string]interface{}{"`key`": val}, "`name`", "`number`") + return fmt.Sprintf("%v(%v)", userInfo.Name, userInfo.Number) + case "expand-user": + var userAry []string + jsonStr := publicmethod.TypeToInterface(val) + json.Unmarshal([]byte(jsonStr), &userAry) + return strings.Join(userAry, " , ") + case "select": + var sendInfp []string + if val != nil { + fmt.Printf("Step1:\n") + 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 { + fmt.Printf("Step2:\n") + sendInfp = append(sendInfp, v.Label) + } + } + } + + } else { + fmt.Printf("Step3:\n") + for _, v := range v.Options { + if v.Value == valStr { + fmt.Printf("Step4:\n") + sendInfp = append(sendInfp, v.Label) + } + } + } + return strings.Join(sendInfp, " , ") + + } + default: + } + } } for _, v := range l.TableData.Columns { if v.Id == key { - fmt.Printf("组件类型---->\n\n%v\n\n", v.FieldClass) + // fmt.Printf("组件类型--2006-->\n\n%v\n\n", v.FieldClass) switch v.FieldClass { case "checkbox": if val != nil { @@ -2935,6 +3153,9 @@ func TableFormAttributeForm(formField Result, tableFieldList []FormFieldInfo) (f for _, v := range tableFieldList { fmt.Printf("v.Field--->%v\n", v.Id) if v.Id == formField.Field { + if v.FieldClass == "datePicker" { + formField.Comment = v.Label + } fieldInfo = formField return } diff --git a/api/version1/customerform/formTableList.go b/api/version1/customerform/formTableList.go index 75040d8..53f3c5f 100644 --- a/api/version1/customerform/formTableList.go +++ b/api/version1/customerform/formTableList.go @@ -239,6 +239,7 @@ func (a *ApiMethod) GainFormPageListContNew(c *gin.Context) { redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3) formList[i]["retract_true"], _ = redisClient.Get(redisKey) } + fmt.Printf("masterKey---------->%v\n\n\n", masterKey) for _, sv := range sunMap { formList[i][sv] = gainMasterSunList(sv, masterKey, formJsonCont, overall.CONSTANT_DB_CustomerForm) } @@ -247,3 +248,77 @@ func (a *ApiMethod) GainFormPageListContNew(c *gin.Context) { } } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-27 13:12:03 +@ 功能: 获取当前活跃表格字段 +*/ +func (a *ApiMethod) GainFormTableFieldes(c *gin.Context) { + var requestData publicmethod.PublicId + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(1, err, c, "未知表单!无法获取字段!") + return + } + var customerFormMaster modelAppPlatform.CustomerFormView + err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`") + if err != nil { + publicmethod.Result(1, err, c, "未知表单!无法获取字段!") + return + } + var formJsonCont CustomerFormMaster + json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &formJsonCont) + + var masterTable []Result + // var listFieldsMap ListPageFields + if formJsonCont.Form.DataSource == "yes" { + var sqlDb datacenter.DataBastType + sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType + sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip + sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName + sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port + sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName + sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password + sqlDborm, err := sqlDb.StartDataBast() + if err != nil { + sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id) + if err != nil { + publicmethod.Result(0, sqlDb, c) + return + } + } + masterTableAll, err := GainFormAllFieldList(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey) + if err == nil { + masterTable = append(masterTable, masterTableAll...) + } + } else { + masterTableAll, err := GainFormTableField(customerFormMaster.TableKey) + if err == nil { + masterTable = append(masterTable, masterTableAll...) + } + + } + sendTableList := publicmethod.MapOut[string]() + + CompareActiveField(masterTable, formJsonCont.List) + + sendTableList["masterTable"] = masterTable + sendTableList["formJsonCont.List"] = formJsonCont.List + publicmethod.Result(0, sendTableList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-27 13:45:51 +@ 功能: 比对活跃字段 +*/ +func CompareActiveField(masterTable []Result, tableUnit []MasterStruct) { + +} diff --git a/api/version1/customerform/formTableView.go b/api/version1/customerform/formTableView.go index 2c9b794..1f234a5 100644 --- a/api/version1/customerform/formTableView.go +++ b/api/version1/customerform/formTableView.go @@ -49,20 +49,36 @@ func (a *ApiMethod) MultiViewPAge(c *gin.Context) { 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`") + err := formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`", "`listJsonInfo`") if err != nil { publicmethod.Result(1, err, c, "未知表单!无法获取字段!") return } + + //解析表单列表数据结构 + var formJsonCont CustomerFormMaster + json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) + 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.`creater` = ? ", userCont.Key) gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2) gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) + + //Step 2 权限处理 + var powerSearch publicmethod.GainUserPower + powerSearch.SystemName = "appsystem" //系统名称 + powerSearch.RoleId = userCont.Role //角色列表 + powerSearch.OrgId = userCont.AdminOrg //行政组织 + powerSearch.PostId = userCont.Position //岗位 + powerSearch.AppKey = formInfo.Groupid //归属哪个App + powerSearch.TableId = formInfo.CfId //归属哪个表格 + gormDb = powerSearch.MakeSearchSql(gormDb, userCont, formJsonCont.Form.DataSource) + var total int64 totalErr := gormDb.Count(&total).Error if totalErr != nil { @@ -212,9 +228,14 @@ func (a *ApiMethod) MultiViewPAge(c *gin.Context) { } } // fmt.Printf("formList----> %v----> %v\n", len(formList), formList) - if formInfo.ListJson != "" { + listJsonCenter := formInfo.ListJson + if formInfo.ListJsonInfo != "" { + listJsonCenter = formInfo.ListJsonInfo + } + + if listJsonCenter != "" { var listFieldsMap ListPageFields - err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap) + err = json.Unmarshal([]byte(listJsonCenter), &listFieldsMap) var formJsonCont CustomerFormMaster if formInfo.MastesFormJson != "" { json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont) @@ -806,11 +827,11 @@ func (a *ApiMethod) GainCalendarList(c *gin.Context) { */ func TimeHaveAry(dateList []TimeAryInfo, listDate []map[string]interface{}) []TimeAryInfo { for ti, tv := range dateList { - fmt.Printf("测试类型--->%v=============>%v\n", ti, tv) + // fmt.Printf("测试类型--->%v=============>%v\n", ti, tv) for _, v := range listDate { for mi, mv := range v { if tv.Date == mi { - fmt.Printf("测试类型--1->%v=============>%v\n", tv.Date, mi) + // fmt.Printf("测试类型--1->%v=============>%v\n", tv.Date, mi) dateList[ti].List = mv } } diff --git a/api/version1/customerform/tableList.go b/api/version1/customerform/tableList.go index ce566e6..7dc40e1 100644 --- a/api/version1/customerform/tableList.go +++ b/api/version1/customerform/tableList.go @@ -151,6 +151,8 @@ func (a *ApiMethod) TableCusterField(c *gin.Context) { if err == nil { formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont) } + formKJK, _ := json.Marshal(formList) + fmt.Printf("\n\n-->\n\n%v\n\n---<\n\n", string(formKJK)) for _, v := range formList { var sendInfo KaPianField sendInfo.TableKey = formInfo.TableKey @@ -205,7 +207,7 @@ func (a *ApiMethod) TableCusterField(c *gin.Context) { if mastrKeyInt != 0 { var runFlowInfo customerForm.RunWorkflow runFlowInfo.GetCont(map[string]interface{}{"`id`": mastrKey}, "`id`", "`current_step`", "`next_step`") - sendInfo.RunFlowInfo = strconv.FormatInt(runFlowInfo.Id, 10) + sendInfo.RunFlowInfo = strconv.FormatInt(mastrKeyInt, 10) if stateVal, ok := v["taskStatus"]; ok { if stauval, ok := stateVal.(string); ok { if stauval == "3" && runFlowInfo.NextStep != 0 { @@ -297,7 +299,7 @@ func HaveImgInfo(val map[string]interface{}, view map[string]ViewInfo, unitList return titleStr case 4: if viewCard, ok := view["card"]; ok { - fmt.Printf("\n\n\n\n描述类型----->%T------------1------------->%v\n\n\n\n", viewCard.Form.Describe, viewCard.Form.Describe) + // fmt.Printf("\n\n\n\n描述类型----->%T------------1------------->%v\n\n\n\n", viewCard.Form.Describe, viewCard.Form.Describe) switch descVal := viewCard.Form.Describe.(type) { case []interface{}: var descAry []string diff --git a/api/version1/customerform/type.go b/api/version1/customerform/type.go index f13032f..955d722 100644 --- a/api/version1/customerform/type.go +++ b/api/version1/customerform/type.go @@ -407,8 +407,9 @@ type FormUnitInfo struct { SunFormInfo []SunFormInfoList //子表 } type SunFormInfoList struct { - TableName string //表名称 - UbitInfo map[string]MasterStruct //相关组件 + TableName string //表名称 + TableTitle string //表名称 + UbitInfo map[string]MasterStruct //相关组件 } // 表单分组列表参数 diff --git a/api/version1/entry.go b/api/version1/entry.go index 63c8738..d4da2f6 100644 --- a/api/version1/entry.go +++ b/api/version1/entry.go @@ -8,10 +8,12 @@ import ( "appPlatform/api/version1/datamanagement/redisController" "appPlatform/api/version1/dict" "appPlatform/api/version1/grantpowers" + "appPlatform/api/version1/humanResources" matrixapi "appPlatform/api/version1/matrixApi" "appPlatform/api/version1/menus" "appPlatform/api/version1/newsclass" "appPlatform/api/version1/publicapi" + "appPlatform/api/version1/setupRoule" matsformula "appPlatform/api/version1/taskplatform/matsFormula" "appPlatform/api/version1/taskplatform/taskflowing" "appPlatform/api/version1/taskplatform/taskmanagement" @@ -40,6 +42,8 @@ type ApiEntry struct { WebSocketApi webstocetmsg.ApiMethod //webSocket通讯相关 WorkFlowApi workflowRun.ApiMethod //工作流相关 ChartApi customChartesing.ApiMethod + AuthorizeApi setupRoule.ApiMethod + HrApi humanResources.ApiMethod //人力资源 } var AppApiEntry = new(ApiEntry) diff --git a/api/version1/grantpowers/postpower.go b/api/version1/grantpowers/postpower.go index a457758..3cc483f 100644 --- a/api/version1/grantpowers/postpower.go +++ b/api/version1/grantpowers/postpower.go @@ -241,14 +241,38 @@ func (a *ApiMethod) GetRoleGrantPowers(c *gin.Context) { # */ func (a *ApiMethod) GainAppList(c *gin.Context) { + var requestData GainAppIdAndRoleNew + c.ShouldBindJSON(&requestData) + if requestData.PowerType == "" { + requestData.PowerType = "org" + } + if requestData.AppType == "" { + requestData.AppType = "system" + } + if requestData.RoleId == "" { + requestData.RoleId = "0" + } + powerInfo := publicmethod.GetSystemAppPower(requestData.PowerType, requestData.AppType, requestData.RoleId) + var custForm modelAppPlatform.CustomerForm list, _ := custForm.ContMap(map[string]interface{}{"`states`": 1, "`classify`": 3}, "`name`", "`signCode`", "`id`") var sendList []interface{} - for _, v := range list { + for i, v := range list { mapInfo := publicmethod.MapOut[string]() mapInfo["id"] = strconv.FormatInt(v.Id, 10) mapInfo["signCode"] = strconv.FormatInt(v.SignCode, 10) mapInfo["name"] = v.Name + mapInfo["isPick"] = false + if i == 0 { + mapInfo["isPick"] = true + } + mapInfo["pickAll"] = false + for _, pv := range powerInfo { + if pv.SystemId == v.SignCode { + mapInfo["pickAll"] = pv.SystemIsPick + } + } + sendList = append(sendList, mapInfo) } publicmethod.Result(0, sendList, c) @@ -478,3 +502,91 @@ func (a *AppTableMsgInfo) AppTablePowerSave(roleId, appSignCode string, list Cus a.TableMsg = append(a.TableMsg, errInfo) } } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-11 11:35:56 +@ 功能: 获取应用基本盘面 +*/ +func (a *ApiMethod) GainAppTableListNew(c *gin.Context) { + var requestData GainAppIdAndRoleNew + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + publicmethod.Result(1, err, c, "未知App!不可获取表单列表!") + return + } + // if requestData.RoleId == "" { + // publicmethod.Result(1, err, c, "未知角色!不可获取表单列表!") + // return + // } + roleIdInt, _ := strconv.ParseInt(requestData.RoleId, 10, 64) + + powerInfo := publicmethod.GetSystemPower(requestData.PowerType, requestData.AppType, requestData.RoleId, requestData.Id) + // var appInfo modelAppPlatform.CustomerForm + // appInfo.GetCont(map[string]interface{}{"`signCode`":requestData.Id},"``") + var custForm []modelAppPlatform.CustomerForm + overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Where("`states` = 1 AND `groupid` = ? AND `classify` IN (2,4)", requestData.Id).Find(&custForm) + var sendList []CusterAppTablePower + for _, v := range custForm { + powerInfo, isOk := CallBackTablePower(v, powerInfo.PowerList) + if isOk { + sendList = append(sendList, powerInfo) + } else { + formPower := GainAppTablePower(roleIdInt, v.Groupid, v.Id) + var sendInfo CusterAppTablePower + sendInfo.Id = strconv.FormatInt(v.Id, 10) + sendInfo.Name = v.Name + sendInfo.SignCode = strconv.FormatInt(v.SignCode, 10) + sendInfo.TablePower = formPower.TablePower + sendInfo.ListPower = formPower.ListPower + if v.ListJson != "" { + sendInfo.IstIsTrue = true + } else { + sendInfo.IstIsTrue = false + } + sendInfo.DatePower.Types = formPower.DatePower.Types + sendInfo.DatePower.Attribute = formPower.DatePower.Attribute + sendList = append(sendList, sendInfo) + } + + } + publicmethod.Result(0, sendList, c) + // publicmethod.Result(0, custForm, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-21 17:04:28 +@ 功能: 回显表单权限 +*/ +func CallBackTablePower(tableInfo modelAppPlatform.CustomerForm, powerList []publicmethod.ItemInfo) (sendInfo CusterAppTablePower, isOk bool) { + for _, v := range powerList { + if tableInfo.Id == v.ItemId { + sendInfo.Id = strconv.FormatInt(tableInfo.Id, 10) + sendInfo.Name = tableInfo.Name + sendInfo.SignCode = strconv.FormatInt(tableInfo.SignCode, 10) + sendInfo.TablePower = v.TablePower + sendInfo.ListPower = v.ListPower + if tableInfo.ListJson != "" { + sendInfo.IstIsTrue = true + } else { + sendInfo.IstIsTrue = false + } + sendInfo.ListIsAll = v.IsPick + sendInfo.DatePower.Types = int64(v.VisibleRange) + var attId []int64 + for _, iv := range v.VisibleOrg { + attId = append(attId, int64(iv)) + } + sendInfo.DatePower.Attribute = attId + isOk = true + } + } + return +} diff --git a/api/version1/grantpowers/type.go b/api/version1/grantpowers/type.go index 84b8368..1d8b9cb 100644 --- a/api/version1/grantpowers/type.go +++ b/api/version1/grantpowers/type.go @@ -123,3 +123,40 @@ type SendAppTablePower struct { ListPower []string `json:"listPower"` //列表权限 DatePower DatePowerInfo `json:"datePower"` //数据权限 } + +type GainAppIdAndRoleNew struct { + publicmethod.PublicId + AppType string `json:"appType"` + PowerType string `json:"powerType"` + RoleId string `json:"roleId"` +} + +// 提交授权数据 +type GetAuthPowerInfo struct { + AppSystem AppSystemInfo `json:"appSystem"` +} + +type AppSystemInfo struct { + PowerType string `json:"powerType"` //权限分组 + RoleId string `json:"roleId"` //权限个体Id + AppSystem string `json:"appSystem"` //系统分类 + AppId string `json:"powerappIdType"` //子系统ID + SystemPower SystemPowerInfo `json:"SysstemPowerInfo"` +} + +type SystemPowerInfo struct { + Id int64 `json:"id"` + IsTrue bool `json:"isTrue"` + Name string `json:"name"` + ParentId int64 `json:"parentId"` + Perm int64 `json:"perm"` + Sort int `json:"sort"` + Types int `json:"types"` + Visible int `json:"visible"` + VisibleRange visibleRangeInfo `json:"visibleRange"` +} + +type visibleRangeInfo struct { + Typrs int `json:"typrs"` //可见范围 //1、本人;2、本岗位、3、本部门;4、本分部、5、指定行政组织;6、所有 + Val []int `json:"val"` //自定义行政组织 +} diff --git a/api/version1/humanResources/enter.go b/api/version1/humanResources/enter.go new file mode 100644 index 0000000..375c341 --- /dev/null +++ b/api/version1/humanResources/enter.go @@ -0,0 +1,33 @@ +package humanResources + +import ( + "appPlatform/models/modelshr" + "appPlatform/overall/publicmethod" + "sync" + + "github.com/gin-gonic/gin" +) + +// 协程设置 +var syncSeting = sync.WaitGroup{} + +type ApiMethod struct{} + +// 人力资源 +func (a *ApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["index"] = "人力资源入口" + publicmethod.Result(0, outputCont, c) +} + +// 菜单ID +type MenuIdCont struct { + MenuId string `json:"menuId"` +} + +// 赋权菜单树 +type OrgTreePower struct { + modelshr.OrgCont + Status bool `json:"status"` + Child []OrgTreePower `json:"child"` +} diff --git a/api/version1/humanResources/org.go b/api/version1/humanResources/org.go new file mode 100644 index 0000000..5d14b46 --- /dev/null +++ b/api/version1/humanResources/org.go @@ -0,0 +1,116 @@ +package humanResources + +import ( + "appPlatform/models/modelshr" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + + "github.com/gin-gonic/gin" +) + +/** +@ 作者: 秦东 +@ 时间: 2025-11-27 13:15:24 +@ 功能: 行政组织事务处理模块 +*/ + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-27 13:19:44 +@ 功能: 行政组织树 +*/ +func (a *ApiMethod) AuthorizeOrgTree(c *gin.Context) { + var requestData MenuIdCont + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + context, _ := c.Get(overall.MyContJwt) + var myContInfo modelshr.ManCont + jsonCont, _ := json.Marshal(context) + json.Unmarshal(jsonCont, &myContInfo) + + var orgList []modelshr.OrgCont + gotmDb := overall.CONSTANT_DB_HR.Model(&modelshr.OrgCont{}).Where("state = ?", 1) + fmt.Printf("权限-----22222222222222222222222222222222222222222222222222222222222222222222222---->%v\n\n\n", gotmDb) + //获取权限 + myPower := publicmethod.GetMyMenuPower(myContInfo.Key, requestData.MenuId) + fmt.Printf("权限--------->%v------>%v\n\n\n", myPower.Scope, myPower) + switch myPower.Scope { //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有) + case 2: + var sunGroupId publicmethod.GetOrgAllParent + sunGroupId.GetFormGroupSun(myContInfo.AdminOrg) + sunGroupId.Id = append(sunGroupId.Id, myContInfo.AdminOrg) + gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id) + case 3: + var sunGroupId publicmethod.GetOrgAllParent + sunGroupId.GetFormGroupSun(myContInfo.MainDeparment) + sunGroupId.Id = append(sunGroupId.Id, myContInfo.MainDeparment) + gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id) + case 4: + var sunGroupId publicmethod.GetOrgAllParent + sunGroupId.GetFormGroupSun(myContInfo.Company) + sunGroupId.Id = append(sunGroupId.Id, myContInfo.Company) + gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id) + case 5: + gotmDb = gotmDb.Where("`id` IN ?", myPower.ScopeManAry) + case 6: + default: + var sunGroupId publicmethod.GetOrgAllParent + sunGroupId.GetFormGroupSun(myContInfo.AdminOrg) + sunGroupId.Id = append(sunGroupId.Id, myContInfo.AdminOrg) + gotmDb = gotmDb.Where("`id` IN ?", sunGroupId.Id) + } + err = gotmDb.Find(&orgList).Error + var sendTree []OrgTreePower + if err != nil { + publicmethod.Result(0, sendTree, c) + return + } + fmt.Printf("权限--------->%v------>%v\n\n\n", myPower.Scope, orgList) + sendTree = GovOrgTree(0, orgList) + publicmethod.Result(0, sendTree, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-27 16:34:15 +@ 功能: 组装行政树 +*/ +func GovOrgTree(parentId int64, govList []modelshr.OrgCont) (govMap []OrgTreePower) { + + for i := 0; i < len(govList); i++ { + if govList[i].Superior == parentId { + var govCont OrgTreePower + govCont.Id = govList[i].Id // + govCont.Number = govList[i].Number //行政编码"` + govCont.Name = govList[i].Name //组织名称"` + govCont.Superior = govList[i].Superior //上级ID"` + govCont.OrganizationType = govList[i].OrganizationType //行政组织类型"` + govCont.Abbreviation = govList[i].Abbreviation //行政组织简称"` + govCont.Time = govList[i].Time //创建时间"` + govCont.State = govList[i].State //状态(1:启用;2:禁用;3:删除)"` + govCont.WechatOrganizationId = govList[i].WechatOrganizationId //微信组织架构对照码"` + govCont.SuperiorSun = govList[i].SuperiorSun //级联ID"` + govCont.Schoole = govList[i].Schoole //原知行学院对照码"` + govCont.KingdeeId = govList[i].KingdeeId //金蝶对照ID"` + govCont.IsPower = govList[i].IsPower //是否为实权部门"` + govCont.Sort = govList[i].Sort //排序"` + govCont.TypeName = govList[i].TypeName //'类型名称"` + govCont.Level = govList[i].Level //级别"` + if govList[i].State == 1 { + govCont.Status = true + } else { + govCont.Status = false + } + govCont.Child = GovOrgTree(govList[i].Id, govList) + govMap = append(govMap, govCont) + } + } + return +} diff --git a/api/version1/menus/menus.go b/api/version1/menus/menus.go index c32dde0..622ae05 100644 --- a/api/version1/menus/menus.go +++ b/api/version1/menus/menus.go @@ -40,6 +40,11 @@ var allRulesLog teamlog.TeamsLog # */ func (a *ApiMethod) GetMenusThree(c *gin.Context) { + context, _ := c.Get(overall.MyContJwt) + var myContInfo modelshr.ManCont + jsonCont, _ := json.Marshal(context) + json.Unmarshal(jsonCont, &myContInfo) + var menusList []modelAppPlatform.Menus err := overall.CONSTANT_DB_AppPlatform.Where("`type` IN ? AND `visible` = ? AND `outside` IN ?", []int{1, 2, 3, 5}, 1, []int{1, 3}).Order("sort ASC").Find(&menusList).Error if err != nil && len(menusList) < 1 { @@ -49,8 +54,16 @@ func (a *ApiMethod) GetMenusThree(c *gin.Context) { // sort.Slice(menusList, func(i, j int) bool { // return menusList[i].Sort > menusList[j].Sort // }) + powerInfo := publicmethod.GetSystemPowerInfo(myContInfo.Key) + + var havePowerMenu []modelAppPlatform.Menus + for _, v := range menusList { + if publicmethod.IsInTrue[int64](int64(v.Id), powerInfo.MenuIdAry) { + havePowerMenu = append(havePowerMenu, v) + } + } - routerThree := publicmethod.GetMenuRouterThree(0, menusList) + routerThree := publicmethod.GetMenuRouterThree(0, havePowerMenu) publicmethod.Result(0, routerThree, c) } diff --git a/api/version1/publicapi/updownpage.go b/api/version1/publicapi/updownpage.go new file mode 100644 index 0000000..4b85522 --- /dev/null +++ b/api/version1/publicapi/updownpage.go @@ -0,0 +1,133 @@ +package publicapi + +import ( + "appPlatform/models/modelshr" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/csv" + "fmt" + "net/url" + "sort" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-18 14:16:25 +@ 功能: 下载排班模板 +*/ +func (a *ApiMethod) DownLoadDutyPage(c *gin.Context) { + orgId := c.Query("orgid") //哪个行政组织 + types := c.Query("types") //什么类型 + timeVal := c.Query("timeval") //时间 + if orgId == "undefined" || orgId == "" || orgId == "" { + c.Writer.Write([]byte("未知行政组织")) + return + } + fmt.Printf("types:%T----->%v\n\n", types, types) + fmt.Printf("timeVal:%T----->%v\n\n", timeVal, timeVal) + var orgInfo modelshr.AdministrativeOrganization + err := orgInfo.GetCont(map[string]interface{}{"`id`": orgId}) + if err != nil { + c.Writer.Write([]byte("未知行政组织")) + return + } + orgIdInt, _ := strconv.ParseInt(orgId, 10, 64) + var orgList []modelshr.AdministrativeOrganization + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("`state` = 1") + gormDb = gormDb.Where("`superior` = ?", orgIdInt) + gormDb.Order("`sort` ASC").Find(&orgList) + sort.Slice(orgList, func(i, j int) bool { + return orgList[i].Sort < orgList[j].Sort + }) + dayAll := time.Now().Unix() + if timeVal != "" { + dayAll, _ = strconv.ParseInt(timeVal, 10, 64) + if publicmethod.GetIntLength(dayAll) >= 13 { + dayAll = dayAll / 1000 + } + } + fmt.Printf("首行--timeVal----------->%v------------->%v\n\n\n", timeVal, dayAll) + + dutyTitle := fmt.Sprintf("%v周末(节假日)在岗人员", orgInfo.Name) + fileName := fmt.Sprintf("%v_%v.csv", dutyTitle, publicmethod.GetUUid(1)) + shuoMing := "人员录入格式为姓名(工号);括号为英文模式下括号;在岗时间代替方式为(B:白天;Y:夜间;S:上午;X:下午;Z:值班)不填默认为值班(Z),填写格式为:秦东(300450*Z)。代表姓名:秦东;工号:300450;今天值班。多个人员用英文','分开。如:杜婷婷(206527*B),秦东(300450*Z)。不要随意更改格式,也不要更改固定好的行政组织位置及其他模版中自带的信息。否则信息会录入失败!!!" + if types == "1" { + + yearVal := publicmethod.UnixTimeToDay(dayAll, 16) + yearValInt, _ := strconv.Atoi(yearVal) + monthVal := publicmethod.UnixTimeToDay(dayAll, 17) + monthValInt, _ := strconv.Atoi(monthVal) + + endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt) + monthEndDay, _ := strconv.Atoi(endTime.Days) + + fmt.Printf("首行--timeVal-----monthValInt------>%v------------->%v------------->%v\n\n\n", yearValInt, monthValInt, endTime) + + var builder strings.Builder + builder.WriteString("\xEF\xBB\xBF") //写入UTF-8 BOM 防止乱码 + writer := csv.NewWriter(&builder) + writer.Write([]string{dutyTitle, shuoMing}) //标题 + // dayAllStr := publicmethod.UnixTimeToDay(dayAll, 15) + var fristHane []string + dayAllStr := fmt.Sprintf("\t%v", publicmethod.UnixTimeToDay(dayAll, 15)) + // fristHane = append(fristHane, fmt.Sprintf("%v年%v月", yearVal, monthVal)) + fristHane = append(fristHane, dayAllStr) + + for i := 1; i <= monthEndDay; i++ { + fristHane = append(fristHane, strconv.Itoa(i)) + } + fmt.Printf("首行------------->%v------------->%v\n\n\n", monthEndDay, fristHane) + writer.Write(fristHane) //首行 + if orgIdInt == 309 { + writer.Write([]string{"公司带班"}) + } + writer.Write([]string{"公司值班"}) + //循环输出体 + for _, v := range orgList { + writer.Write([]string{v.Name}) // + } + writer.Flush() + + 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())) + } else { + + dayAllStr := fmt.Sprintf("\t%v", publicmethod.UnixTimeToDay(dayAll, 14)) + dayHao := publicmethod.UnixTimeToDay(dayAll, 18) + + // dayInt, _ := strconv.ParseInt(dayHao, 10, 64) + var builder strings.Builder + builder.WriteString("\xEF\xBB\xBF") //写入UTF-8 BOM 防止乱码 + writer := csv.NewWriter(&builder) + writer.Write([]string{dutyTitle, shuoMing}) //标题 + writer.Write([]string{dayAllStr, dayHao}) //首行 + if orgIdInt == 309 { + writer.Write([]string{"公司带班"}) + } + writer.Write([]string{"公司值班"}) + //循环输出体 + for _, v := range orgList { + writer.Write([]string{v.Name, ""}) // + } + writer.Flush() + + 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())) + } + + // c.Writer.Write([]byte("未知行政组织")) +} diff --git a/api/version1/setupRoule/authorization.go b/api/version1/setupRoule/authorization.go new file mode 100644 index 0000000..f2e9fb9 --- /dev/null +++ b/api/version1/setupRoule/authorization.go @@ -0,0 +1,267 @@ +package setupRoule + +import ( + "appPlatform/models/modelssystempermission" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "strconv" + "time" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-19 09:05:13 +@ 功能: 授权 +*/ +func (a *ApiMethod) SystemAppAuthorization(c *gin.Context) { + var requestData AppSystemInfo + c.ShouldBindJSON(&requestData) + if requestData.PowerType == "" { + publicmethod.Result(1, requestData, c, "未知赋权分类!请明确!") + return + } + if requestData.AppSystem == "" { + publicmethod.Result(2, requestData, c, "未知系统分类!请明确!") + return + } + if requestData.RoleId == "" { + publicmethod.Result(3, requestData, c, "未知赋权项目!请明确!") + return + } + + var powerMastInfo modelssystempermission.AuthPower + gormDb := overall.CONSTANT_DB_System_Permission.Model(&powerMastInfo).Where("`orgPowerType` = ? AND `orgOrUserKey` = ? AND `appType` = ?", requestData.PowerType, requestData.RoleId, requestData.AppSystem) + var powerInfo interface{} + istrue := 0 + if requestData.IsPick { + istrue = 1 + } + switch requestData.AppSystem { + case "app": + if requestData.AppId == "" { + publicmethod.Result(4, requestData, c, "未知赋权系统!请明确!") + return + } + if len(requestData.CustomizeApp) < 1 { + publicmethod.Result(5, requestData, c, "为对任何项目赋权!请明确!") + return + } + powerInfo = requestData.CustomizeApp + gormDb = gormDb.Where("`appKey` = ?", requestData.AppId) + case "system": + if len(requestData.SystemPower) < 1 { + publicmethod.Result(6, requestData, c, "为对任何项目赋权!请明确!") + return + } + powerInfo = requestData.SystemPower + gormDb = gormDb.Where("`appKey` = 0") + default: + } + jsonPowerInfo, _ := json.Marshal(powerInfo) + err := gormDb.First(&powerMastInfo).Error + uuid := publicmethod.GetUUid(1) + oukId, _ := strconv.ParseInt(requestData.RoleId, 10, 64) + appId, _ := strconv.ParseInt(requestData.AppId, 10, 64) + if err != nil { + powerMastInfo.Id = uuid // + powerMastInfo.OrgPowerType = requestData.PowerType //赋权类型(org:组织;job:岗位;role:角色;person:个人)" + powerMastInfo.OrgOrUserKey = oukId // unsigned;default:0;comment:行政组织或角色、人员识别符 + powerMastInfo.AppType = requestData.AppSystem //ment:系统类型(system:系统平台;app:自定义表单与应用)" + powerMastInfo.AppKey = appId //ned;default:0;comment:自定义应用App" + powerMastInfo.Time = time.Now().Unix() //编辑时间 + powerMastInfo.IsTrue = istrue //是否有权(1:有;非1:无) + powerMastInfo.PowerInfo = string(jsonPowerInfo) //权限结构体" + err = overall.CONSTANT_DB_System_Permission.Create(&powerMastInfo).Error + } else { + uuid = powerMastInfo.Id + saveData := publicmethod.MapOut[string]() + saveData["`isTrue`"] = istrue + saveData["`powerInfo`"] = string(jsonPowerInfo) + saveData["`time`"] = time.Now().Unix() + var saveInfo modelssystempermission.AuthPower + err = saveInfo.EiteCont(map[string]interface{}{"`id`": uuid}, saveData) + } + if err != nil { + publicmethod.Result(7, requestData, c, "授权失败!请重新提交授权数据!") + return + } + + //权限拆分 + err = requestData.SplitPermissions(uuid) + if err != nil { + publicmethod.Result(8, err, c, "授权失败!请重新提交授权数据!") + return + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-20 10:08:09 +@ 功能: 拆分权限 +*/ +func (a *AppSystemInfo) SplitPermissions(uuid int64) error { + var oldPower modelssystempermission.PowerInfo + err := oldPower.DelCont(map[string]interface{}{"`authId`": uuid}) + var insterAry []modelssystempermission.PowerInfo + switch a.AppSystem { + case "app": + + for _, v := range a.CustomizeApp { + isPick := 0 + if v.ListIsAll { + isPick = 1 + } + var saveInfo modelssystempermission.PowerInfo + saveInfo.AuthId = uuid //归属权限 + saveInfo.ItemId, _ = strconv.ParseInt(v.Id, 10, 64) //项目ID + saveInfo.IsPick = isPick //是否有权(1:有;非1:无) + tpAry := MyCreateTablePower(v.TablePower) + if tpAry == "null" { + tpAry = "[]" + } + saveInfo.TablePower = tpAry //表单权限 + lpAry := MyCreateTablePower(v.ListPower) + if lpAry == "null" { + lpAry = "[]" + } + saveInfo.ListPower = lpAry //列表权限 + saveInfo.VisibleRange = v.DatePower.Types //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有) + visibleOrgStr, _ := json.Marshal(v.DatePower.Attribute) + saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数 + saveInfo.ButPower = "[]" //按钮权限 + saveInfo.Time = time.Now().Unix() //编辑时间 + insterAry = append(insterAry, saveInfo) + } + case "system": + for _, v := range a.SystemPower { + isPick := 0 + if v.IsTrue { + isPick = 1 + } + var saveInfo modelssystempermission.PowerInfo + saveInfo.AuthId = uuid //归属权限 + saveInfo.ItemId = int64(v.Id) //项目ID + saveInfo.IsPick = isPick //是否有权(1:有;非1:无) + saveInfo.TablePower = "[]" //表单权限 + saveInfo.ListPower = "[]" //列表权限 + saveInfo.VisibleRange = v.VisibleRange.Types //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有) + visibleOrgStr, _ := json.Marshal(v.VisibleRange.Val) + // fmt.Printf("\n\n转换福泉击缶提---------------->%v\n\n", fsdfsd) + saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数 + jieguo := ButPower(v.ButtenPower) + if jieguo == "null" { + jieguo = "[]" + } + saveInfo.ButPower = jieguo //按钮权限 + saveInfo.Time = time.Now().Unix() //编辑时间 + insterAry = append(insterAry, saveInfo) + if len(v.Children) > 0 { + var childAry SystemTreePower + childAry.WriteSystemInfo(uuid, v.Children) + if len(childAry.WriteInfo) > 0 { + insterAry = append(insterAry, childAry.WriteInfo...) + } + } + } + default: + } + if len(insterAry) > 0 { + err = overall.CONSTANT_DB_System_Permission.Create(&insterAry).Error + } + return err +} + +func (s *SystemTreePower) WriteSystemInfo(uuid int64, list []AppPowerTree) { + if len(list) > 0 { + for _, v := range list { + isPick := 0 + if v.IsTrue { + isPick = 1 + } + var saveInfo modelssystempermission.PowerInfo + saveInfo.AuthId = uuid //归属权限 + saveInfo.ItemId = int64(v.Id) //项目ID + saveInfo.IsPick = isPick //是否有权(1:有;非1:无) + saveInfo.TablePower = "[]" //表单权限 + saveInfo.ListPower = "[]" //列表权限 + saveInfo.VisibleRange = v.VisibleRange.Types //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有) + visibleOrgStr, _ := json.Marshal(v.VisibleRange.Val) + saveInfo.VisibleOrg = string(visibleOrgStr) //可见范围辅助参数 + jieguo := ButPower(v.ButtenPower) + if jieguo == "null" { + jieguo = "[]" + } + saveInfo.ButPower = jieguo //按钮权限 + saveInfo.Time = time.Now().Unix() //编辑时间 + s.WriteInfo = append(s.WriteInfo, saveInfo) + if len(v.Children) > 0 { + s.WriteSystemInfo(uuid, v.Children) + } + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-20 11:39:52 +@ 功能: 解释自定义表单权限 +*/ +func MyCreateTablePower(powerList []string) string { + if len(powerList) <= 0 { + return "[]" + } + var powerAry []string + for _, v := range powerList { + if !publicmethod.IsInTrue[string](v, powerAry) { + powerAry = append(powerAry, v) + } + } + jsonStr, _ := json.Marshal(powerAry) + return string(jsonStr) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-20 11:28:56 +@ 功能: 按钮列表处理 +*/ +func ButPower(butList []AppPowerInfo) string { + if len(butList) <= 0 { + return "[]" + } + var powerAry []int + for _, v := range butList { + if v.IsTrue { + if !publicmethod.IsInTrue[int](v.Id, powerAry) { + powerAry = append(powerAry, v.Id) + } + } + } + jsonStr, _ := json.Marshal(powerAry) + return string(jsonStr) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-20 14:31:23 +@ 功能: 数据范围转换格式 +*/ +func PowerOrg(orgAry []int) string { + // if len(orgAry) <= 0{ + return "[]" + // } + // var orgStr []string + // for _,v := range orgAry{ + // vStr := strconv.Itoa(v) + // // if + // } +} diff --git a/api/version1/setupRoule/entry.go b/api/version1/setupRoule/entry.go new file mode 100644 index 0000000..1f83cc8 --- /dev/null +++ b/api/version1/setupRoule/entry.go @@ -0,0 +1,150 @@ +package setupRoule + +import ( + "appPlatform/models/modelssystempermission" + "appPlatform/overall/publicmethod" + "sync" + + "github.com/gin-gonic/gin" +) + +// 处理角色问题 +type ApiMethod struct{} + +// 协程设置 +var syncSeting = sync.WaitGroup{} + +// 处理角色入口 +func (a *ApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["index"] = "处理角色入口" + publicmethod.Result(0, outputCont, c) +} + +// 角色赋权输出结构体 +type RolePower struct { + Id string `json:"id"` + Label string `json:"label"` + Types string `json:"types"` + Children []RolePower `json:"children"` +} + +// 获取参数 +type GetPowerUnitParameter struct { + PowerType string `json:"powerType"` //行政组织、岗位、角色(org、position、role) + AppSystem string `json:"appSystem"` //系统类型 + RoleId string `json:"roleId"` //角色 + AppId string `json:"appId"` //角色 +} + +// 平台授权结构体 +type AppPowerInfo struct { + Id int `gorm:"column:id;type:int(10) unsigned;primary_key;AUTO_INCREMENT" json:"id"` + Name string `gorm:"column:name;type:varchar(255);comment:菜单名称" json:"name"` //菜单名称 + Types int `gorm:"column:type;type:int(10) unsigned;default:1;comment:菜单类型(1-菜单;2-目录;3-外链;4-按钮权限);NOT NULL" json:"types"` //菜单类型(1-菜单;2-目录;3-外链;4-按钮权限) + Perm int64 `gorm:"column:perm;type:bigint(20) unsigned;default:0;comment:权限标识;NOT NULL" json:"perm"` //权限标识 + Sort int `gorm:"column:sort;type:int(10) unsigned;default:50;comment:排序(数字越小排名越靠前);NOT NULL" json:"sort"` //排序(数字越小排名越靠前) + ParentId int `gorm:"column:parentId;type:int(10) unsigned;default:0;comment:父菜单ID;NOT NULL" json:"parentId"` //父菜单ID + IsTrue bool `gorm:"-" json:"isTrue"` +} + +// 分流 +type AppMenuBut struct { + AppPowerInfo + AppPowerList []int64 `json:"appPowerList"` + ButtenPower []AppPowerInfo `json:"buttenPower"` + Visible int `json:"visible"` //1、自己;2、本岗位、3、本部门;4、本公司;5:自定义范围;6、所有 + VisibleRange VisibleRangeInfo `json:"visibleRange"` //当可见范围为自定义范围时。此辅助选项生效 +} + +// 平台授权结构树 +type AppPowerTree struct { + AppMenuBut + Children []AppPowerTree `json:"children"` + Visible int `json:"visible"` //1、自己;2、本岗位、3、本部门;4、本公司;5:自定义范围;6、所有 + VisibleRange VisibleRangeInfo `json:"visibleRange"` //当可见范围为自定义范围时。此辅助选项生效 +} + +type VisibleRangeInfo struct { + Types int `json:"typrs"` //1、行政组织;2、岗位;3:人员 + Val []int `json:"val"` +} + +// 输出获取首层子行政组织和本组织下的人员 +type HaveOrgLeveID struct { + publicmethod.PublicId + Level int `json:"level"` +} +type TopSunOrgAndPeople struct { + publicmethod.PublicId + publicmethod.PublicName + Types int `json:"types"` + IsLeaf bool `json:"isLeaf"` //指定节点是否为叶子节点,仅在指定了 lazy 属性的情况下生效 +} + +// 输出获取首层子行政组织和本组织岗位下的人员 +type HaveOrgPostLeveID struct { + publicmethod.PublicId + Types int `json:"types"` + Level int `json:"level"` +} + +// 授权页面获取人员 +type PowerPageUser struct { + publicmethod.PagesTurn + publicmethod.PublicName + OrgId int64 `json:"orgId"` +} + +// 输出授权页人员 +type SendPowerPage struct { + publicmethod.PublicId + publicmethod.PublicName + Code string `json:"code"` + Icon string `json:"icon"` + Org string `json:"org"` +} + +type AppSystemInfo struct { + PowerType string `json:"powerType"` //权限分组 + RoleId string `json:"roleId"` //权限个体Id + AppSystem string `json:"appSystem"` //系统分类 + AppId string `json:"appId"` //子系统ID + IsPick bool `json:"isPick"` //当前自定义系统是否可见 + SystemPower []AppPowerTree `json:"sysstemPowerInfo"` //平台系统 + CustomizeApp []CusterAppTablePower `json:"CustomizeApp"` //自定义表单系统 +} + +type CusterAppTablePower struct { + Id string `json:"id"` //表单ID + Name string `json:"name"` //表单名称 + SignCode string `json:"signCode"` //表单识别符 + IsTrue bool `json:"isTrue"` + TableIsAll bool `json:"tableIsAll"` + TablePower []string `json:"tablePower"` //表单权限 + ListIsAll bool `json:"listIsAll"` + ListPower []string `json:"listPower"` //列表权限 + DatePower DatePowerInfo `json:"datePower"` //数据权限 +} + +type DatePowerInfo struct { + Types int `json:"types"` //权限类型 + Attribute []int64 `json:"attribute"` //全选属性 +} + +// 权限树写入 +type SystemTreePower struct { + WriteInfo []modelssystempermission.PowerInfo +} + +// 获取角色所有人 +type GetRolePople struct { + RoleId int64 `json:"roleId"` + publicmethod.PublicName +} + +// 设置角色使用人 +type SetupRoleMan struct { + RoleId int64 `json:"roleId"` + UserKey []string `json:"userKey"` +} diff --git a/api/version1/setupRoule/orgPeople.go b/api/version1/setupRoule/orgPeople.go new file mode 100644 index 0000000..80d24f5 --- /dev/null +++ b/api/version1/setupRoule/orgPeople.go @@ -0,0 +1,459 @@ +package setupRoule + +import ( + "appPlatform/models/modelshr" + "appPlatform/models/modelssystempermission" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "strconv" + "time" + + "github.com/gin-gonic/gin" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-13 09:25:55 +@ 功能: 获取首层子行政组织和本组织下的人员 +*/ +func (a *ApiMethod) GetMyPeopleAndSunOrg(c *gin.Context) { + var requestData HaveOrgLeveID + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + requestData.Id = "0" + } + orgId, _ := strconv.ParseInt(requestData.Id, 10, 64) + var snedList []TopSunOrgAndPeople + if requestData.Level == 0 { + if requestData.Id == "0" { + + orgList := GetOrgList(orgId) + snedList = append(snedList, orgList...) + // orgManList := GetOrgPeopleList(orgId) + // snedList = append(snedList, orgManList...) + } else { + var myOrgMyInfo modelshr.AdministrativeOrganization + err = myOrgMyInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`,`name`") + if err != nil { + publicmethod.Result(0, err, c, "没有此行政组织") + return + } + var sendMyInfo TopSunOrgAndPeople + sendMyInfo.Id = strconv.FormatInt(myOrgMyInfo.Id, 10) + sendMyInfo.Name = myOrgMyInfo.Name + sendMyInfo.Types = 1 + sendMyInfo.IsLeaf = false + snedList = append(snedList, sendMyInfo) + // orgManList := GetOrgPeopleList(orgId) + // snedList = append(snedList, orgManList...) + } + + } else { + orgList := GetOrgList(orgId) + snedList = append(snedList, orgList...) + } + + publicmethod.Result(0, snedList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-13 11:03:47 +@ 功能: 获取行政组织列表 +*/ +func GetOrgList(orgId int64) (snedList []TopSunOrgAndPeople) { + var orgList []modelshr.AdministrativeOrganization + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`").Where("`state` = 1 AND `superior` = ?", orgId).Find(&orgList) + if len(orgList) > 0 { + for _, v := range orgList { + var sendInfo TopSunOrgAndPeople + sendInfo.Id = strconv.FormatInt(v.Id, 10) + sendInfo.Name = v.Name + sendInfo.Types = 1 + sendInfo.IsLeaf = false + snedList = append(snedList, sendInfo) + + } + } + orgManList := GetOrgPeopleList(orgId) + snedList = append(snedList, orgManList...) + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-13 11:03:47 +@ 功能: 获取行政组织岗位 +*/ +func GetOrgPostPeopleList(postId int64) (snedList []TopSunOrgAndPeople) { + var orgList []modelshr.Position + overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`id`,`name`,`number`").Where("`state` = 1 AND `administrative_organization` = ?", postId).Find(&orgList) + if len(orgList) > 0 { + for _, v := range orgList { + var sendInfo TopSunOrgAndPeople + sendInfo.Id = strconv.FormatInt(v.Id, 10) + sendInfo.Name = v.Name + sendInfo.Types = 2 + sendInfo.IsLeaf = false + snedList = append(snedList, sendInfo) + + } + } + // orgManList := GetPostPeopleList(postId) + // snedList = append(snedList, orgManList...) + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-13 11:03:47 +@ 功能: 获取行政组织人员 +*/ +func GetOrgPeopleList(orgId int64) (snedList []TopSunOrgAndPeople) { + var peopleList []modelshr.PersonArchives + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`name`,`number`").Where("`state` = 1 AND `emp_type` BETWEEN 1 AND 10 AND `admin_org` = ?", orgId).Find(&peopleList) + if len(peopleList) > 0 { + for _, v := range peopleList { + var sendInfo TopSunOrgAndPeople + sendInfo.Id = strconv.FormatInt(v.Key, 10) + sendInfo.Name = fmt.Sprintf("%v(%v)", v.Name, v.Number) + sendInfo.Types = 3 + sendInfo.IsLeaf = true + snedList = append(snedList, sendInfo) + } + } + orgManList := GetOrgPostPeopleList(orgId) + snedList = append(snedList, orgManList...) + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-13 11:03:47 +@ 功能: 获取岗位人员 +*/ +func GetPostPeopleList(orgId int64) (snedList []TopSunOrgAndPeople) { + var peopleList []modelshr.PersonArchives + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`name`,`number`").Where("`state` = 1 AND `emp_type` BETWEEN 1 AND 10 AND `position` = ?", orgId).Find(&peopleList) + if len(peopleList) > 0 { + for _, v := range peopleList { + var sendInfo TopSunOrgAndPeople + sendInfo.Id = strconv.FormatInt(v.Key, 10) + sendInfo.Name = fmt.Sprintf("%v(%v)", v.Name, v.Number) + sendInfo.Types = 3 + sendInfo.IsLeaf = true + snedList = append(snedList, sendInfo) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-13 09:25:55 +@ 功能: 获取首层子行政组织和本组织下的岗位及人员 +*/ +func (a *ApiMethod) GetMyPeopleAndSunOrgPost(c *gin.Context) { + var requestData HaveOrgPostLeveID + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.Id == "" { + requestData.Id = "0" + } + if requestData.Types == 0 { + requestData.Types = 1 + } + orgId, _ := strconv.ParseInt(requestData.Id, 10, 64) + var snedList []TopSunOrgAndPeople + if requestData.Level == 0 { + if requestData.Id == "0" { + orgList := GetOrgPostList(orgId) + snedList = append(snedList, orgList...) + } else { + if requestData.Types == 1 { + orgList := GetOrgPostList(orgId) + snedList = append(snedList, orgList...) + } else { + orgManList := GetPostPeopleList(orgId) + snedList = append(snedList, orgManList...) + } + } + + } else { + + if requestData.Types == 1 { + orgList := GetOrgPostList(orgId) + snedList = append(snedList, orgList...) + } else { + orgManList := GetPostPeopleList(orgId) + snedList = append(snedList, orgManList...) + } + } + + publicmethod.Result(0, snedList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-13 11:03:47 +@ 功能: 获取行政组织列表 +*/ +func GetOrgPostList(orgId int64) (snedList []TopSunOrgAndPeople) { + var orgList []modelshr.AdministrativeOrganization + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`").Where("`state` = 1 AND `superior` = ?", orgId).Find(&orgList) + if len(orgList) > 0 { + for _, v := range orgList { + var sendInfo TopSunOrgAndPeople + sendInfo.Id = strconv.FormatInt(v.Id, 10) + sendInfo.Name = v.Name + sendInfo.Types = 1 + sendInfo.IsLeaf = false + snedList = append(snedList, sendInfo) + + } + } + if orgId != 0 { + orgManList := GetOrgPostPeopleList(orgId) + snedList = append(snedList, orgManList...) + } + return +} + +/* +@ 作者: 秦东 +@ 时间: 2025-11-13 11:03:47 +@ 功能: 获取行政组织岗位 +*/ +func GetPostPeopleListAry(postId int64) (snedList []TopSunOrgAndPeople) { + var orgList []modelshr.Position + overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`id`,`name`,`number`").Where("`state` = 1 AND `superior` = ?", postId).Find(&orgList) + if len(orgList) > 0 { + for _, v := range orgList { + var sendInfo TopSunOrgAndPeople + sendInfo.Id = strconv.FormatInt(v.Id, 10) + sendInfo.Name = v.Name + sendInfo.Types = 2 + sendInfo.IsLeaf = false + snedList = append(snedList, sendInfo) + + } + } + orgManList := GetPostPeopleList(postId) + snedList = append(snedList, orgManList...) + return +} + +// 获取人员 +func (a *ApiMethod) GetPowerPageUser(c *gin.Context) { + var requestData PowerPageUser + c.ShouldBindJSON(&requestData) + if requestData.Page == 0 { + requestData.Page = 1 + } + if requestData.PageSize == 0 { + requestData.PageSize = 20 + } + var peopleList []modelshr.PersonArchives + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`name`,`number`,`icon`,`company`,`maindeparment`,`admin_org`,`icon_photo`").Where("`state` = 1 AND `emp_type` BETWEEN 1 AND 10 ") + if requestData.Name != "" { + gormDb = gormDb.Where("`name` LIKE ? OR `number` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%") + } + if requestData.OrgId != 0 { + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSun(requestData.OrgId) + sunOrg.Id = append(sunOrg.Id, requestData.OrgId) + gormDb = gormDb.Where("`admin_org` IN ?", sunOrg.Id) + } + var total int64 + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) + err := gormDb.Order("`id` DESC").Find(&peopleList).Error + if err != nil { + publicmethod.Result(105, err, c) + return + } + var sendList []SendPowerPage + for _, v := range peopleList { + var sendCont SendPowerPage + sendCont.Id = strconv.FormatInt(v.Key, 10) + sendCont.Name = v.Name + sendCont.Code = v.Number + sendCont.Icon = v.IconPhoto + if v.Icon != "" { + sendCont.Icon = v.Icon + } + orgName := "" + if v.Company != 0 { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") + if orgCont.Name != "" { + orgName = orgCont.Name + } + } + if v.MainDeparment != 0 && v.MainDeparment != v.Company { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": v.MainDeparment}, "`name`") + if orgCont.Name != "" { + orgName = fmt.Sprintf("%v-%v", orgName, orgCont.Name) + } else { + orgName = orgCont.Name + } + } + if v.AdminOrg != 0 && v.AdminOrg != v.MainDeparment && v.AdminOrg != 0 { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`") + if orgCont.Name != "" { + orgName = fmt.Sprintf("%v-%v", orgName, orgCont.Name) + } else { + orgName = orgCont.Name + } + } + sendCont.Org = orgName + sendList = append(sendList, sendCont) + } + publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-27 08:42:43 +@ 功能: 获取角色使用人 +*/ +func (a *ApiMethod) GetRolePeople(c *gin.Context) { + var requestData GetRolePople + c.ShouldBindJSON(&requestData) + if requestData.RoleId == 0 { + publicmethod.Result(3, requestData, c, "未知赋权项目!请明确!") + return + } + var roleInfo modelssystempermission.SystemRole + err := overall.CONSTANT_DB_System_Permission.Model(&roleInfo).Where("`id` = ?", requestData.RoleId).First(&roleInfo).Error + if err != nil { + publicmethod.Result(1, requestData, c, "未知赋权项目!请明确!") + return + } + outPut := publicmethod.MapOut[string]() + var sendList []SendPowerPage + if roleInfo.Roleuser == "" { + outPut["userKey"] = []string{} + outPut["list"] = sendList + publicmethod.Result(0, outPut, c) + return + } + + var userKey []string + json.Unmarshal([]byte(roleInfo.Roleuser), &userKey) + var userList []modelshr.PersonArchives + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`key`,`name`,`number`,`icon`,`company`,`maindeparment`,`admin_org`,`icon_photo`").Where("`key` IN ?", userKey).Find(&userList) + if requestData.Name != "" { + gormDb = gormDb.Where("`name` LIKE ? OR `number` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%") + } + err = gormDb.Find(&userList).Error + + if err != nil { + outPut["userKey"] = userKey + outPut["list"] = sendList + publicmethod.Result(0, outPut, c) + return + } + for _, v := range userList { + var sendCont SendPowerPage + sendCont.Id = strconv.FormatInt(v.Key, 10) + sendCont.Name = v.Name + sendCont.Code = v.Number + sendCont.Icon = v.IconPhoto + if v.Icon != "" { + sendCont.Icon = v.Icon + } + orgName := "" + if v.Company != 0 { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") + if orgCont.Name != "" { + orgName = orgCont.Name + } + } + if v.MainDeparment != 0 && v.MainDeparment != v.Company { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": v.MainDeparment}, "`name`") + if orgCont.Name != "" { + orgName = fmt.Sprintf("%v-%v", orgName, orgCont.Name) + } else { + orgName = orgCont.Name + } + } + if v.AdminOrg != 0 && v.AdminOrg != v.MainDeparment && v.AdminOrg != 0 { + var orgCont modelshr.AdministrativeOrganization + orgCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`") + if orgCont.Name != "" { + orgName = fmt.Sprintf("%v-%v", orgName, orgCont.Name) + } else { + orgName = orgCont.Name + } + } + sendCont.Org = orgName + sendList = append(sendList, sendCont) + } + outPut["userKey"] = userKey + outPut["list"] = sendList + publicmethod.Result(0, outPut, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-27 10:21:20 +@ 功能: 保存角色使用人 +*/ +func (a *ApiMethod) SavePickRoleMan(c *gin.Context) { + var requestData SetupRoleMan + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.RoleId == 0 { + publicmethod.Result(3, requestData, c, "未知赋权项目!请明确!") + return + } + var roleInfo modelssystempermission.SystemRole + err = overall.CONSTANT_DB_System_Permission.Model(&roleInfo).Where("`id` = ?", requestData.RoleId).First(&roleInfo).Error + if err != nil { + publicmethod.Result(1, requestData, c, "未知赋权项目!请明确!") + return + } + saveData := publicmethod.MapOut[string]() + if len(requestData.UserKey) > 0 { + peopleJson, _ := json.Marshal(requestData.UserKey) + saveData["roleuser"] = string(peopleJson) + } else { + saveData["roleuser"] = "" + } + saveData["`time`"] = time.Now().Unix() + err = roleInfo.EiteCont(map[string]interface{}{"`id`": requestData.RoleId}, saveData) + if err != nil { + publicmethod.Result(106, err, c) + return + } + publicmethod.Result(0, err, c) +} diff --git a/api/version1/setupRoule/power.go b/api/version1/setupRoule/power.go new file mode 100644 index 0000000..1be8a70 --- /dev/null +++ b/api/version1/setupRoule/power.go @@ -0,0 +1,149 @@ +package setupRoule + +import ( + "appPlatform/models/modelAppPlatform" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "sort" + + "github.com/gin-gonic/gin" +) + +// 获取平台授权项目 +func (a *ApiMethod) AppPowerUnit(c *gin.Context) { + var requestData GetPowerUnitParameter + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.PowerType == "" { + requestData.PowerType = "org" + } + if requestData.AppSystem == "" { + requestData.AppSystem = "appsystem" + } + if requestData.RoleId == "" { + requestData.RoleId = "0" + } + powerInfo := publicmethod.GetSystemPower(requestData.PowerType, requestData.AppSystem, requestData.RoleId, requestData.PowerType) + var appPowerTrue []AppPowerTree + switch requestData.AppSystem { + default: + appPowerTrue = AppMenuPower(requestData.PowerType, requestData.RoleId, powerInfo) + } + publicmethod.Result(0, appPowerTrue, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-10 10:02:54 +@ 功能: 数通智联平台菜单 +*/ +func AppMenuPower(powerType, unitId string, powerInfo publicmethod.SendSystemPower) []AppPowerTree { + var menuList []AppPowerInfo + overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Menus{}).Where("`visible` = 1").Find(&menuList) + sort.Slice(menuList, func(i, j int) bool { + return menuList[i].Sort < menuList[j].Sort + }) + var noButMenu []AppPowerInfo + var ButMenu []AppPowerInfo + for _, v := range menuList { + if v.Types != 4 { + noButMenu = append(noButMenu, v) + } else { + ButMenu = append(ButMenu, v) + } + } + butList := MenuPower(MenuButList(noButMenu, ButMenu), powerInfo) + return AppMenuTrue(0, butList) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-21 14:20:46 +@ 功能: 判断按钮 +*/ +func JuadgeBut(menuInfo []AppPowerInfo, powerInfo publicmethod.ItemInfo) (butPower []AppPowerInfo) { + for _, v := range menuInfo { + if publicmethod.IsInTrue[int](v.Id, powerInfo.ButPower) { + v.IsTrue = true + } else { + v.IsTrue = false + } + butPower = append(butPower, v) + } + return +} + +// 组合菜单按钮 +func MenuButList(noButMenu, ButMenu []AppPowerInfo) (menuButList []AppMenuBut) { + // var but []int64 + for _, v := range noButMenu { + var menuButInfo AppMenuBut + menuButInfo.Id = v.Id + menuButInfo.Name = v.Name //菜单名称 + menuButInfo.Types = v.Types //菜单类型(1-菜单;2-目录;3-外链;4-按钮权限) + menuButInfo.Perm = v.Perm //权限标识 + menuButInfo.Sort = v.Sort //排序(数字越小排名越靠前) + menuButInfo.ParentId = v.ParentId //父菜单ID + menuButInfo.IsTrue = v.IsTrue + menuButInfo.AppPowerList = []int64{1} + for _, bv := range ButMenu { + if bv.ParentId == v.Id { + menuButInfo.ButtenPower = append(menuButInfo.ButtenPower, bv) + } + } + menuButList = append(menuButList, menuButInfo) + } + return +} + +func AppMenuTrue(parentId int, list []AppMenuBut) []AppPowerTree { + treeList := []AppPowerTree{} + for _, v := range list { + if v.ParentId == parentId { + var treeInfo AppPowerTree + treeInfo.Id = v.Id // + treeInfo.Name = v.Name //菜单名称 + treeInfo.Types = v.Types //菜单类型(1-菜单;2-目录;3-外链;4-按钮权限) + treeInfo.Perm = v.Perm //权限标识 + treeInfo.Sort = v.Sort //排序(数字越小排名越靠前) + treeInfo.ParentId = v.ParentId //父菜单ID + treeInfo.IsTrue = v.IsTrue // + treeInfo.Visible = v.Visible + treeInfo.ButtenPower = v.ButtenPower + treeInfo.VisibleRange.Types = v.VisibleRange.Types + treeInfo.VisibleRange.Val = v.VisibleRange.Val + if v.Types != 4 { + treeInfo.Children = AppMenuTrue(v.Id, list) + } + treeList = append(treeList, treeInfo) + } + } + return treeList +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-21 14:12:32 +@ 功能: 菜单判断是否选中 +*/ +func MenuPower(menuInfo []AppMenuBut, powerInfo publicmethod.SendSystemPower) (menuPower []AppMenuBut) { + for _, v := range menuInfo { + for _, pv := range powerInfo.PowerList { + if pv.ItemId == int64(v.Id) { + v.IsTrue = pv.IsPick + v.Visible = pv.VisibleRange + v.VisibleRange.Types = pv.VisibleRange + v.VisibleRange.Val = pv.VisibleOrg + v.ButtenPower = JuadgeBut(v.ButtenPower, pv) + } + } + menuPower = append(menuPower, v) + } + return +} diff --git a/api/version1/taskplatform/taskflowing/analyFormJson.go b/api/version1/taskplatform/taskflowing/analyFormJson.go new file mode 100644 index 0000000..c6c2fc6 --- /dev/null +++ b/api/version1/taskplatform/taskflowing/analyFormJson.go @@ -0,0 +1,302 @@ +package taskflowing + +import ( + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "sort" + + "github.com/gin-gonic/gin" +) + +// 解析表单格式 +func (a *ApiMethod) AnalyFormJsonMap(c *gin.Context) { + var requestData AnalysisNodesUnitPower + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if requestData.NodeKey == "" { + requestData.NodeKey = "begin" + } + + var unitCont TypesAnalysisNodesUnit + json.Unmarshal([]byte(requestData.NodeJson), &unitCont.UnitList) //获取当前表单Json配置数据 + var flowUnit FlowTypeKeyWordAry + + if purviewList, ok := unitCont.UnitList["purview"]; ok { + + if purviewAry, ok := purviewList.([]interface{}); ok { + for _, v := range purviewAry { + if vMap, ok := v.(map[string]interface{}); ok { + if nodeKey, ok := vMap["nodeKey"]; ok { + if publicmethod.TypeToInterface(nodeKey) == requestData.NodeKey { + if powerList, ok := vMap["powerAry"]; ok { + if powerListAry, ok := powerList.([]interface{}); ok { + flowUnit.NodePower = SplitNodeUnitPurviewNew(powerListAry) + } + } + + } + } + } + + } + // recUnitAry = SplitNodeUnitPurviewNew(purviewAry) + } + } + + // fmt.Printf("授权清空\n%T----------------%v\n\n", flowUnit, flowUnit) + + //获取组件 + if list, ok := unitCont.UnitList["list"]; ok { + if listAry, ok := list.([]interface{}); ok { + var mainTable FlowTypeKeyWord + mainTable.Id = "masterid" + mainTable.Name = "主表" + mainTable.IsEdit = true + mainTable.IsLook = true + mainTable.Status = 4 + mainTable.Sort = 0 + flowUnit.SplitComponents(mainTable, listAry) + } + } + sort.Slice(flowUnit.ListAry, func(i, j int) bool { + return flowUnit.ListAry[i].Sort < flowUnit.ListAry[j].Sort + }) + sendData := publicmethod.MapOut[string]() + sendData["nodeKey"] = requestData.NodeKey + sendData["recUnitAry"] = flowUnit.ListAry + publicmethod.Result(0, sendData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2024-03-14 08:38:32 +@ 功能: 拆分节点已有得权限 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func SplitNodeUnitPurviewNew(purviewAry []interface{}) (nodeUnitPowerAry []NodesUnitNameStatue) { + jsonCont, jsonErr := json.Marshal(purviewAry) + // fmt.Printf("purviewList:%T--->%v--->%v\n", jsonCont, jsonErr, string(jsonCont)) + if jsonErr == nil { + json.Unmarshal(jsonCont, &nodeUnitPowerAry) + } + return +} + +// 拆分组件 +func (f *FlowTypeKeyWordAry) SplitComponents(tableInfo FlowTypeKeyWord, unitList []interface{}) { + var masterUnit []NodesUnitNameStatue + for i, v := range unitList { + if mapVal, ok := v.(map[string]interface{}); ok { + if mapType, ok := mapVal["type"]; ok { //获取组件类型 + // fmt.Printf("\n====1======\n%v:\n%v\n======1====\n", i, mapType) + unitName := "" + unitLabelName := "" + if mapName, ok := mapVal["name"]; ok { + unitName = publicmethod.TypeToInterface(mapName) + } + if item, ok := mapVal["item"]; ok { + if itemMap, ok := item.(map[string]interface{}); ok { + if itemName, ok := itemMap["label"]; ok { + unitLabelName = publicmethod.TypeToInterface(itemName) + } + } + } + + switch mapType { + case "flex": + + var mainTable FlowTypeKeyWord + mainTable.Id = unitName + if unitLabelName == "" { + if mapName, ok := mapVal["unitName"]; ok { + mainTable.Name = publicmethod.TypeToInterface(mapName) + } + } else { + mainTable.Name = unitLabelName + } + // mainTable.IsEdit = true + // mainTable.IsLook = true + mainTable.IsLook, mainTable.IsEdit, mainTable.Status = f.JuadgeUnitStatus(unitName) + // mainTable.Status = 4 + mainTable.Sort = i + 1 + if list, ok := mapVal["list"]; ok { + if listAry, ok := list.([]interface{}); ok { + + f.SplitComponents(mainTable, listAry) + } + } + case "table": + var mainTable FlowTypeKeyWord + mainTable.Id = unitName + if unitLabelName == "" { + if mapName, ok := mapVal["unitName"]; ok { + mainTable.Name = publicmethod.TypeToInterface(mapName) + } + } else { + mainTable.Name = unitLabelName + } + // mainTable.IsEdit = true + // mainTable.IsLook = true + mainTable.IsLook, mainTable.IsEdit, mainTable.Status = f.JuadgeUnitStatus(unitName) + // mainTable.Status = 4 + mainTable.Sort = i + 1 + if list, ok := mapVal["list"]; ok { + if listAry, ok := list.([]interface{}); ok { + + f.SplitComponents(mainTable, listAry) + } + } + case "grid": + var mainTable FlowTypeKeyWord + + if unitName == "" { + mainTable.Id = fmt.Sprintf("%v_%v", mapType, i) + } else { + mainTable.Id = unitName + } + if unitLabelName == "" { + if mapName, ok := mapVal["unitName"]; ok { + mainTable.Name = publicmethod.TypeToInterface(mapName) + } + } else { + mainTable.Name = unitLabelName + } + // mainTable.IsEdit = true + // mainTable.IsLook = true + mainTable.IsLook, mainTable.IsEdit, mainTable.Status = f.JuadgeUnitStatus(unitName) + mainTable.Sort = i + 1 + // mainTable.Status = 4 + if columnsList, ok := mapVal["columns"]; ok { + if listAry, ok := columnsList.([]interface{}); ok { + for _, colVal := range listAry { + if colList, ok := colVal.(map[string]interface{}); ok { + + if listMap, ok := colList["list"]; ok { + if colListAry, ok := listMap.([]interface{}); ok { + f.SplitComponents(mainTable, colListAry) + } + } + } + } + } + } + case "tabs": + var mainTable FlowTypeKeyWord + + if unitName == "" { + mainTable.Id = fmt.Sprintf("%v_%v", mapType, i) + } else { + mainTable.Id = unitName + } + if unitLabelName == "" { + if mapName, ok := mapVal["unitName"]; ok { + mainTable.Name = publicmethod.TypeToInterface(mapName) + } + } else { + mainTable.Name = unitLabelName + } + // mainTable.IsEdit = true + // mainTable.IsLook = true + mainTable.IsLook, mainTable.IsEdit, mainTable.Status = f.JuadgeUnitStatus(unitName) + // mainTable.Status = 4 + mainTable.Sort = i + 1 + if columnsList, ok := mapVal["columns"]; ok { + if listAry, ok := columnsList.([]interface{}); ok { + for ci, colVal := range listAry { + if colList, ok := colVal.(map[string]interface{}); ok { + if mapName, ok := colList["label"]; ok { + mainTable.Name = publicmethod.TypeToInterface(mapName) + } + mainTable.Id = fmt.Sprintf("%v_%v", mainTable.Id, ci) + if listMap, ok := colList["list"]; ok { + if colListAry, ok := listMap.([]interface{}); ok { + f.SplitComponents(mainTable, colListAry) + } + } + } + } + } + } + case "card", "div": + // fmt.Printf("\n===普通容器,无需授权组装=======\n%v:\n%v\n==========\n", i, mapType) + if list, ok := mapVal["list"]; ok { + if listAry, ok := list.([]interface{}); ok { + + f.SplitComponents(tableInfo, listAry) + } + } + case "title", "txt", "button": + // fmt.Printf("\n===无需授权组装=======\n%v:\n%v\n==========\n", i, mapType) + default: + var masterMainUnit NodesUnitNameStatue + masterMainUnit.Id = unitName + masterMainUnit.Name = unitLabelName + // masterMainUnit.IsEdit = true + // masterMainUnit.IsLook = true + masterMainUnit.IsLook, masterMainUnit.IsEdit, masterMainUnit.Status = f.JuadgeUnitStatus(unitName) + // masterMainUnit.Status = 4 + masterUnit = append(masterUnit, masterMainUnit) + } + } + } + } + // jsonByte, err := json.Marshal(masterUnit) + // fmt.Printf("\n====2======\n%v:\n%v\n\n%v\n=====2=====\n", err, string(jsonByte), tableInfo) + if len(masterUnit) > 0 { + isNew := true + // fmt.Printf("\n=---------%v--------->\n=", len(f.ListAry)) + if len(f.ListAry) > 0 { + for i, v := range f.ListAry { + // fmt.Printf("\n=---------%v-----%v-----%v--------->\n=", v.Id, tableInfo.Id, v.Id == tableInfo.Id) + if v.Id == tableInfo.Id { + isNew = false + f.ListAry[i].List = append(f.ListAry[i].List, masterUnit...) + } + } + if isNew { + tableInfo.List = append(tableInfo.List, masterUnit...) + f.ListAry = append(f.ListAry, tableInfo) + } + } else { + tableInfo.List = append(tableInfo.List, masterUnit...) + f.ListAry = append(f.ListAry, tableInfo) + } + } +} + +// 判断组件授权状态 +func (f *FlowTypeKeyWordAry) JuadgeUnitStatus(key string) (isLook, isErit bool, states int) { + isLook = true + isErit = true + for _, v := range f.NodePower { + if v.Id == key { + isLook = v.IsLook + isErit = v.IsEdit + } + } + if isLook && isErit { + states = 4 + } else if isLook && !isErit { + states = 3 + } else if !isLook && isErit { + states = 2 + } else { + states = 1 + } + return +} diff --git a/api/version1/taskplatform/taskflowing/appTaskFlow.go b/api/version1/taskplatform/taskflowing/appTaskFlow.go index a344d68..60d24d1 100644 --- a/api/version1/taskplatform/taskflowing/appTaskFlow.go +++ b/api/version1/taskplatform/taskflowing/appTaskFlow.go @@ -88,6 +88,15 @@ func (a *ApiMethod) GainAppTaskList(c *gin.Context) { overall.CONSTANT_DB_CustomerForm.Model(&customerForm.RunFlowTask{}).Where("`id` IN ?", idAry).Order("`start_time` desc").Find(&userList) for i := 0; i < len(userList); i++ { userList[i].FormVersionId = strconv.FormatInt(userList[i].VersionId, 10) + if userList[i].VersionId != 0 { + var cfvInfo modelAppPlatform.CustomerFormVersion + cfvInfo.GetCont(map[string]interface{}{"`id`": userList[i].VersionId}) + if cfvInfo.PowerStr != "" { + // var powerAry []NodePowerInfoNew + json.Unmarshal([]byte(cfvInfo.PowerStr), &userList[i].PowerAry) + } + + } userList[i].IdStr = strconv.FormatInt(userList[i].Id, 10) userList[i].RunFlowIdStr = strconv.FormatInt(userList[i].Id, 10) userList[i].FlowKeys = strconv.FormatInt(userList[i].FlowKey, 10) @@ -106,6 +115,7 @@ func (a *ApiMethod) GainAppTaskList(c *gin.Context) { nodeCont, idTrue := GainCurreNode(userList[i].FlowCont, userList[i].CurrentStep, userList[i].NextStep, userList[i].Status) if idTrue { userList[i].CurrentNodeName = nodeCont.NodeName + userList[i].CurrentNodeKey = nodeCont.NodeKey } } if userList[i].MastesForm == "" || userList[i].MastesFormJson == "" { @@ -329,7 +339,7 @@ func (a *ApiMethod) EditTaskAppInfo(c *gin.Context) { return } var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { @@ -528,7 +538,7 @@ func (a *ApiMethod) SaveDraftAgain(c *gin.Context) { json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串 var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件 + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, "", formJsonCont.List, true) //获取主表及子表相关组件 //主表组件 masterUnitList := make(map[string]customerform.MasterStruct) @@ -651,7 +661,7 @@ func (a *ApiMethod) AfreshAppSubmit(c *gin.Context) { json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串 var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件 + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, "", formJsonCont.List, true) //获取主表及子表相关组件 //主表组件 masterUnitList := make(map[string]customerform.MasterStruct) diff --git a/api/version1/taskplatform/taskflowing/editformflow.go b/api/version1/taskplatform/taskflowing/editformflow.go index 0ee7261..ad432d0 100644 --- a/api/version1/taskplatform/taskflowing/editformflow.go +++ b/api/version1/taskplatform/taskflowing/editformflow.go @@ -71,7 +71,7 @@ func (a *ApiMethod) GainEditFormFlowInfo(c *gin.Context) { return } var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { @@ -448,7 +448,7 @@ func (a *ApiMethod) EditFormLogData(c *gin.Context) { json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) //解析表单字符串 var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) //获取主表及子表相关组件 + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, "", formJsonCont.List, true) //获取主表及子表相关组件 //主表组件 masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { diff --git a/api/version1/taskplatform/taskflowing/types.go b/api/version1/taskplatform/taskflowing/types.go index 9061d41..9ba1447 100644 --- a/api/version1/taskplatform/taskflowing/types.go +++ b/api/version1/taskplatform/taskflowing/types.go @@ -248,18 +248,20 @@ type SendTaskFlowInfo struct { // 输出任务列表 type SendAppTaskFlowInfo struct { customerForm.RunFlowTask - FlowKeys string `json:"flowkeys" gorm:"-"` //唯一标识符 - CreaterInfo UserSmallInfo `json:"creatorInfo" gorm:"-"` //创建人信息 - StartDate string `json:"startDate" gorm:"-"` //创建日期 - CurrentNodeName string `json:"currentNodeName" gorm:"-"` //当前节点名称 - CurrentNodeUser []UserSmallInfo `json:"currentNodeUser" gorm:"-"` //节点操作人 - IdStr string `json:"idStr" gorm:"-"` // - FormVersionId string `json:"formVersionId" gorm:"-"` - IsRetract bool `json:"isRetract" gorm:"-"` //是否可以撤回 - MastersKeyStr string `json:"mastersKeyStr" gorm:"-"` //唯一标识符 - AppKeyStr string `json:"appKeyStr" gorm:"-"` //唯一标识符 - TableKeyStr string `json:"tableKeyStr" gorm:"-"` //唯一标识符 - RunFlowIdStr string `json:"runFlowIdStr" gorm:"-"` //唯一标识符 + FlowKeys string `json:"flowkeys" gorm:"-"` //唯一标识符 + CreaterInfo UserSmallInfo `json:"creatorInfo" gorm:"-"` //创建人信息 + StartDate string `json:"startDate" gorm:"-"` //创建日期 + CurrentNodeName string `json:"currentNodeName" gorm:"-"` //当前节点名称 + CurrentNodeKey string `json:"currentNodeKey" gorm:"-"` //当前节点识别符 + CurrentNodeUser []UserSmallInfo `json:"currentNodeUser" gorm:"-"` //节点操作人 + IdStr string `json:"idStr" gorm:"-"` // + FormVersionId string `json:"formVersionId" gorm:"-"` + IsRetract bool `json:"isRetract" gorm:"-"` //是否可以撤回 + MastersKeyStr string `json:"mastersKeyStr" gorm:"-"` //唯一标识符 + AppKeyStr string `json:"appKeyStr" gorm:"-"` //唯一标识符 + TableKeyStr string `json:"tableKeyStr" gorm:"-"` //唯一标识符 + RunFlowIdStr string `json:"runFlowIdStr" gorm:"-"` //唯一标识符 + PowerAry []NodePowerInfoNew `json:"powerAry" gorm:"-"` //节点权限 } // 人员剪短信息 @@ -330,6 +332,17 @@ type NodePowerInfo struct { PowerAry []NodesUnitNameStatue `json:"powerAry"` } +// 节点权限结构体--> +type NodePowerInfoNew struct { + NodeKey string `json:"nodeKey"` + PowerAry []NodesUnitNameStatue `json:"powerAry"` + ApiSetup apiSetupStruct `json:"apiSetup"` +} +type apiSetupStruct struct { + Title []interface{} `json:"title"` + Library []interface{} `json:"library"` +} + // 编辑表单字段权限 type FlowFormPowerInfo struct { FormKey string `json:"formKey"` @@ -382,3 +395,19 @@ type SendWorkMsgRangField struct { Types string `json:"types"` //类型 MultipleChoice bool `json:"multipleChoice"` //值多选 } + +// 分门类处理数据 +type FlowTypeKeyWord struct { + NodesUnitNameStatue + Sort int `json:"sort"` + List []NodesUnitNameStatue `json:"list"` +} +type FlowTypeKeyWordAry struct { + ListAry []FlowTypeKeyWord + NodePower []NodesUnitNameStatue `json:"-"` +} + +// 审批阶段权限 +type NodePower struct { + NodePower []NodesUnitNameStatue `json:"-"` +} diff --git a/api/version1/taskplatform/taskmanagement/appControl.go b/api/version1/taskplatform/taskmanagement/appControl.go index 4aae90b..56cfa10 100644 --- a/api/version1/taskplatform/taskmanagement/appControl.go +++ b/api/version1/taskplatform/taskmanagement/appControl.go @@ -96,7 +96,7 @@ func (a *ApiMethod) CreateAppTask(c *gin.Context) { json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { masterUnitList[v.Name] = v diff --git a/api/version1/taskplatform/taskmanagement/appform.go b/api/version1/taskplatform/taskmanagement/appform.go index 2003d72..b73b289 100644 --- a/api/version1/taskplatform/taskmanagement/appform.go +++ b/api/version1/taskplatform/taskmanagement/appform.go @@ -507,7 +507,7 @@ func (a *ApiMethod) CustomerFormEditData(c *gin.Context) { json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { masterUnitList[v.Name] = v @@ -595,7 +595,7 @@ func (a *ApiMethod) LookCustomerFormData(c *gin.Context) { json.Unmarshal([]byte(customerFormCont.MastesFormJson), &formJsonCont) var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(customerFormCont.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(customerFormCont.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { masterUnitList[v.Name] = v @@ -697,7 +697,7 @@ func (a *ApiMethod) LookNewCustomerFormData(c *gin.Context) { return } var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(customerFormInfo.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { masterUnitList[v.Name] = v @@ -1208,7 +1208,7 @@ func (a *ApiMethod) NewCustomerFormEditData(c *gin.Context) { json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { masterUnitList[v.Name] = v diff --git a/api/version1/taskplatform/taskmanagement/flowNode.go b/api/version1/taskplatform/taskmanagement/flowNode.go index 51f4e42..e21be88 100644 --- a/api/version1/taskplatform/taskmanagement/flowNode.go +++ b/api/version1/taskplatform/taskmanagement/flowNode.go @@ -41,6 +41,8 @@ type NodePublicInfo struct { Matrix MatrixInfo `json:"matrix"` // OrgList []int64 `json:"orgList"` //指定行政组织,由其负责人审批 HelpTips string `json:"helpTips"` //节点帮助说明 + + ChannerUpdate []string `json:"channerUpdate"` //触发更新流程字段 } type NodePublicInfoES struct { @@ -56,6 +58,7 @@ type NodePublicInfoES struct { NodeUserList []NodeUserListInfo `json:"nodeUserList"` //操作人 ConditionList []ConditionListInfo `json:"conditionList"` //判断条件主体 ChildNode *NodePublicInfo `json:"childNode"` //子节点 + ChannerUpdates []string `json:"channerUpdate"` //触发更新流程字段 } //节点执行人 diff --git a/api/version1/taskplatform/taskmanagement/formcontrol.go b/api/version1/taskplatform/taskmanagement/formcontrol.go index cbfa731..e628d49 100644 --- a/api/version1/taskplatform/taskmanagement/formcontrol.go +++ b/api/version1/taskplatform/taskmanagement/formcontrol.go @@ -560,7 +560,7 @@ func (a *ApiMethod) AddFormAddNewData(c *gin.Context) { json.Unmarshal([]byte(formCont.MastesFormJson), &formJsonCont) var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { masterUnitList[v.Name] = v @@ -872,7 +872,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { cureeTime := time.Now().Unix() //写入时间 var formUnitCont customerform.FormUnitInfo - formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, formJsonCont.List, true) + formUnitCont.GainMasterAndSunFormUnit(formCont.TableKey, "", formJsonCont.List, true) masterUnitList := make(map[string]customerform.MasterStruct) for _, v := range formUnitCont.MasterInfo { masterUnitList[v.Name] = v @@ -988,7 +988,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { sendMsgInfo = sendMsgInterface.SendMsg // msgid, _ := sendMsgInfo.SendMsg(userCont, taskCont.Title, uuid, cureeTime, masterField, masrWriteMap, masterUnitList) msgid, _ := sendMsgInfo.NewSendMsg(userCont, uuid, cureeTime, taskCont.Title, masterField, masrWriteMap, masterUnitList) - fmt.Printf("发送返回信息------------->%v\n\n\n", msgid) + // fmt.Printf("发送返回信息------------->%v\n\n\n", msgid) if msgid != "" { //设定redis Key名称 redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", uuid) @@ -1643,6 +1643,7 @@ func (s *SendMsgInfo) TableFieldsSendMsg(fieldVal map[string]interface{}, userCo for _, v := range s.SendRangeList { for fi, fv := range fieldVal { if v.Id == fi { + // fmt.Printf("处理自定义表格字段发送乏味v.Types------->%v\n\n\n", v.Types) switch v.Types { case "orgCentent": //选择组织 val, _ := publicmethod.StringToInt64(fv) @@ -1692,7 +1693,9 @@ func (s *SendMsgInfo) TableFieldsSendMsg(fieldVal map[string]interface{}, userCo Recipient = append(Recipient, RecipientRole(val)...) } case "expand-user": //选择用户 + // fmt.Printf("处理自定义表格字段发送乏味v.Types---fv---->%v\n\n\n", fv) val := publicmethod.TypeToInterface(fv) + // fmt.Printf("处理自定义表格字段发送乏味v.Types---val---->%v\n\n\n", val) if val != "" { Recipient = append(Recipient, RegexpToMap(val)...) } @@ -1708,6 +1711,7 @@ func (s *SendMsgInfo) TableFieldsSendMsg(fieldVal map[string]interface{}, userCo } } } + // fmt.Printf("处理自定义表格字段发送乏味v.Types---Recipient---->%v\n\n\n", Recipient) } return } @@ -1768,6 +1772,7 @@ func RecipientPost(val []string) (wechatMap []string) { @ 功能: 通过正则表达式获取人员编号 */ func RegexpToMap(val string) (wechatMap []string) { + fmt.Printf("通过正则表达式获取人员编号---->%v\n\n\n", val) if val != "" { var userNumber []string ruleSet := regexp.MustCompile(`\(([^)]+)\)`) @@ -1782,20 +1787,22 @@ func RegexpToMap(val string) (wechatMap []string) { } } } + fmt.Printf("通过正则表达式获取人员编号--userNumber-->%v\n\n\n", userNumber) 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 `number` 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.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) } } } } + fmt.Printf("通过正则表达式获取人员编号--wechatMap-->%v\n\n\n", wechatMap) } return } @@ -1952,6 +1959,6 @@ func (a *ApiMethod) RecalSendMsg(c *gin.Context) { redisClient.DelKey(redisKey) publicmethod.Result(0, err, c) } else { - publicmethod.Result(1, err, c, "数据撤回失败!") + publicmethod.Result(101, err, c, "数据撤回失败!") } } diff --git a/api/version1/taskplatform/taskmanagement/ruanTask.go b/api/version1/taskplatform/taskmanagement/ruanTask.go index 1c343f7..0d63e16 100644 --- a/api/version1/taskplatform/taskmanagement/ruanTask.go +++ b/api/version1/taskplatform/taskmanagement/ruanTask.go @@ -40,7 +40,7 @@ import ( # */ func (a *ApiMethod) GainTaskFormInfo(c *gin.Context) { - var requestData publicmethod.PublicId + var requestData LookFlow err := c.ShouldBindJSON(&requestData) if err != nil { publicmethod.Result(100, err, c) @@ -62,10 +62,35 @@ func (a *ApiMethod) GainTaskFormInfo(c *gin.Context) { publicmethod.Result(107, err, c) return } + if formVersionInfo.PowerStr != "" { + // var powAry []NodePowerInfoNew + json.Unmarshal([]byte(formVersionInfo.PowerStr), &formVersionInfo.PowerAry) + // tableFormPage.PowerAry = powAry + } formVersionInfo.FlowkeyStr = strconv.FormatInt(formVersionInfo.Flowkey, 10) formVersionInfo.CreaterStr = strconv.FormatInt(formVersionInfo.Creater, 10) formVersionInfo.MastesForm = taskInfo.MastesForm formVersionInfo.MastesFormJson = taskInfo.MastesFormJson + sendData := publicmethod.MapOut[string]() + sendData["nodeKey"] = "" + if requestData.RunFlowId != "" { + var runFlowInfo customerForm.RunWorkflow + // err = runFlowInfo.GetCont(map[string]interface{}{"`flow_key`": requestData.Id}) + err = runFlowInfo.GetCont(map[string]interface{}{"`id`": requestData.RunFlowId}) + if err == nil { + var flowList []RunFlow + err = json.Unmarshal([]byte(runFlowInfo.FlowCont), &flowList) + if err == nil { + if runFlowInfo.NextStep != 0 { + for _, v := range flowList { + if v.Step == runFlowInfo.NextStep { + sendData["nodeKey"] = v.NodeKey + } + } + } + } + } + } //展开表单 var formJsonCont customerform.CustomerFormMaster @@ -74,9 +99,10 @@ func (a *ApiMethod) GainTaskFormInfo(c *gin.Context) { var tableUnitList customerform.TableFormUnit tableUnitList.AnalysisTableFormUnitAttribute("", formJsonCont.List) - sendData := publicmethod.MapOut[string]() sendData["structure"] = formVersionInfo + fmt.Printf("数据源---->%v\n\n", formJsonCont.Form.DataSource) + if formJsonCont.Form.DataSource == "yes" { var sqlDb datacenter.DataBastType sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType @@ -1416,6 +1442,12 @@ func (a *ApiMethod) EchoTableFormPage(c *gin.Context) { publicmethod.Result(107, err, c) return } + if tableFormPage.PowerStr != "" { + // var powAry []NodePowerInfoNew + json.Unmarshal([]byte(tableFormPage.PowerStr), &tableFormPage.PowerAry) + // tableFormPage.PowerAry = powAry + } + tableFormPage.FlowkeyStr = strconv.FormatInt(tableFormPage.Flowkey, 10) tableFormPage.CreaterStr = strconv.FormatInt(tableFormPage.Creater, 10) tableFormPage.IdStr = strconv.FormatInt(tableFormPage.Id, 10) @@ -1445,6 +1477,8 @@ func (a *ApiMethod) EchoTableFormPage(c *gin.Context) { sendInfo.Step = 1 sendInfo.NodeKey, sendInfo.NextStep, sendInfo.FlowList = ReformFlow(1, workFlowInfo) sendPage["flowPage"] = sendInfo + var wordKey []string + sendPage["channerUpdate"] = flowCont.NodeConfig.BianLiShiyongWork(wordKey) } } } else { @@ -1453,6 +1487,86 @@ func (a *ApiMethod) EchoTableFormPage(c *gin.Context) { publicmethod.Result(0, sendPage, c) } +// 遍历流程所有节点 +func (n *NodePublicInfo) BianLiShiyongWork(wordKey []string) []string { + //判断节点类型 0:发起人;1:审批;2:抄送;3:执行人;4:条件;5:路由 + switch n.Types { + case 1, 3: + if n.Settype == 8 { + for _, v := range n.NodeUserList { + fmt.Printf("\n\n\n遍历流程所有节点--------1---------->%v\n\n\n", v.Id) + if !publicmethod.IsInTrue[string](v.Id, wordKey) { + wordKey = append(wordKey, v.Id) + } + } + } + if n.ChildNode != nil { + + return n.ChildNode.BianLiShiyongWork(wordKey) + } + case 2: + if n.Settype == 8 { + for _, v := range n.NodeUserList { + fmt.Printf("\n\n\n遍历流程所有节点--------2--------->%v\n\n\n", v.Id) + if !publicmethod.IsInTrue[string](v.Id, wordKey) { + wordKey = append(wordKey, v.Id) + } + } + } + if n.ChildNode != nil { + + return n.ChildNode.BianLiShiyongWork(wordKey) + } + case 4: + case 5: + if len(n.ConditionNodes) > 0 { + for _, v := range n.ConditionNodes { + if len(v.ConditionList) > 0 { + for _, cv := range v.ConditionList { + if !publicmethod.IsInTrue[string](cv.Factorid, wordKey) { + wordKey = append(wordKey, cv.Factorid) + } + if len(cv.CustomFields) > 0 { + for _, fv := range cv.CustomFields { + fmt.Printf("\n\n\n遍历流程所有节点---%v-----3----%v------>%v\n\n\n", v.NodeName, cv.Types, fv.Wordfield) + if !publicmethod.IsInTrue[string](fv.Wordfield, wordKey) { + wordKey = append(wordKey, fv.Wordfield) + } + } + } + // switch cv.Types { + // case 3: + // if len(cv.CustomFields) > 0 { + // for _, fv := range cv.CustomFields { + // fmt.Printf("\n\n\n遍历流程所有节点---%v-----3----%v------>%v\n\n\n", v.NodeName, cv.Types, fv.Wordfield) + // if !publicmethod.IsInTrue[string](fv.Wordfield, wordKey) { + // wordKey = append(wordKey, fv.Wordfield) + // } + // } + // } + // default: + // fmt.Printf("\n\n\n遍历流程所有节点---%v-----4---%v------->%v\n\n\n", v.NodeName, cv.Types, cv.Factorid) + // if !publicmethod.IsInTrue[string](cv.Factorid, wordKey) { + // wordKey = append(wordKey, cv.Factorid) + // } + // } + } + } + } + } + if n.ChildNode != nil { + + return n.ChildNode.BianLiShiyongWork(wordKey) + } + default: + if n.ChildNode != nil { + + return n.ChildNode.BianLiShiyongWork(wordKey) + } + } + return wordKey +} + /* * @ 作者: 秦东 @@ -2482,7 +2596,7 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) { default: } } - fmt.Printf("\n\n\n员工----------->%v------->%v\n\n\n", oneIdAry, userList) + // fmt.Printf("\n\n\n员工----------->%v------->%v\n\n\n", oneIdAry, userList) if len(oneIdAry) > 0 { var userOneContMap []modelshr.ManCont overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`key` IN ?", oneIdAry).Find(&userOneContMap) @@ -2510,7 +2624,7 @@ func OperatorHandle(userList []NodeUserListInfo) (userAry []OperatorList) { userAry = append(userAry, TransformPublicUs(v)) } } - fmt.Printf("\n\n\n员工----1------->%v------->%v\n\n\n", oneIdAry, userAry) + // fmt.Printf("\n\n\n员工----1------->%v------->%v\n\n\n", oneIdAry, userAry) } return } diff --git a/api/version1/taskplatform/taskmanagement/sendWorkWatchMsg.go b/api/version1/taskplatform/taskmanagement/sendWorkWatchMsg.go index 080bf75..5b72f3f 100644 --- a/api/version1/taskplatform/taskmanagement/sendWorkWatchMsg.go +++ b/api/version1/taskplatform/taskmanagement/sendWorkWatchMsg.go @@ -419,26 +419,33 @@ func (s *SendMsgInfo) NewSendMsg(userCont modelshr.ManCont, uuid, cureeTime int6 } case 5: //表格中指定 sendTyleList.Class = 5 + // fmt.Printf("获取表格中的人员------fieldVal--->%v\n\n\n", fieldVal) sendUserAll := s.TableFieldsSendMsg(fieldVal, userCont) sendUserCount := len(sendUserAll) + // fmt.Printf("获取表格中的人员------sendUserAll--->%v\n\n\n", sendUserAll) + // fmt.Printf("获取表格中的人员------sendUserCount--->%v\n\n\n", sendUserCount) if sendUserCount > 0 { var guoDu []string - for i := 1; i < sendUserCount; i++ { + for i := 1; i <= sendUserCount; i++ { if i%100 == 0 { + // fmt.Printf("获取表格中的人员------100i--->%v\n\n\n", guoDu) sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) guoDu = []string{} guoDu = append(guoDu, sendUserAll[i-1]) } else { + // fmt.Printf("获取表格中的人员------i--->%v\n\n\n", sendUserAll[i-1]) guoDu = append(guoDu, sendUserAll[i-1]) } } if len(guoDu) > 0 { + // fmt.Printf("获取表格中的人员------guoDu--->%v\n\n\n", guoDu) sendTyleList.SendList = append(sendTyleList.SendList, strings.Join(guoDu, "|")) guoDu = []string{} } } else { isSend = false } + // fmt.Printf("获取表格中的人员%v\n\n\n", sendTyleList) case 6: //自定义 sendTyleList.Class = 6 sendUserAll := s.CustomizeSendMsg() @@ -461,6 +468,7 @@ func (s *SendMsgInfo) NewSendMsg(userCont modelshr.ManCont, uuid, cureeTime int6 } else { isSend = false } + default: isSend = false } diff --git a/api/version1/taskplatform/taskmanagement/types.go b/api/version1/taskplatform/taskmanagement/types.go index cce4eb9..c58e6f3 100644 --- a/api/version1/taskplatform/taskmanagement/types.go +++ b/api/version1/taskplatform/taskmanagement/types.go @@ -77,9 +77,10 @@ type GainCustomerFormLogInfo struct { // 返回自定义表单数据 type CallBackFormStruct struct { modelAppPlatform.CustomerFormView - FlowkeyStr string `json:"flowkeystr" gorm:"-"` - CreaterStr string `json:"createrstr" gorm:"-"` - IdStr string `json:"idStr" gorm:"-"` + FlowkeyStr string `json:"flowkeystr" gorm:"-"` + CreaterStr string `json:"createrstr" gorm:"-"` + IdStr string `json:"idStr" gorm:"-"` + PowerAry []NodePowerInfoNew `json:"powerAry" gorm:"-"` } // 批量删除数据 @@ -261,3 +262,26 @@ type SendMsgNumber struct { Class int SendList []string } + +// 节点权限结构体--> +type NodePowerInfoNew struct { + NodeKey string `json:"nodeKey"` + PowerAry []NodesUnitNameStatue `json:"powerAry"` + ApiSetup apiSetupStruct `json:"apiSetup"` +} +type NodesUnitNameStatue struct { + publicmethod.PublicId + publicmethod.PublicName + publicmethod.PublicStatus + IsLook bool `json:"isLook"` + IsEdit bool `json:"isEdit"` +} +type apiSetupStruct struct { + Title []interface{} `json:"title"` + Library []interface{} `json:"library"` +} + +type LookFlow struct { + publicmethod.PublicId + RunFlowId string `json:"runFlowId"` +} diff --git a/api/version1/user/setPower.go b/api/version1/user/setPower.go new file mode 100644 index 0000000..e653f73 --- /dev/null +++ b/api/version1/user/setPower.go @@ -0,0 +1,483 @@ +package user + +import ( + "appPlatform/models/modelAppPlatform" + "appPlatform/models/modelssystempermission" + "appPlatform/overall" + "appPlatform/overall/publicmethod" + "encoding/json" + "fmt" + "strconv" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-24 08:30:44 +@ 功能: 获取个人系统权限 +*/ +func GetMyPower(powerType string, oupk, org, poetId int64) (allPower SendAllPower, err error) { + + //获取系统权限 + var systemPower []modelssystempermission.AuthPowerList + err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = 'system' AND `orgPowerType` = 'person' AND `orgOrUserKey` = ? AND `appKey` = 0", oupk).Find(&systemPower).Error + if len(systemPower) > 0 { //首先判断个人是否已经赋权 + for _, v := range systemPower { + var sysPower SystemInfoPower + sysPower.AppId = strconv.FormatInt(v.ItemId, 10) + if v.IsPick == 1 { + sysPower.IsPick = true + if !publicmethod.IsInTrue[int64](v.ItemId, allPower.MenuIdAry) { + allPower.MenuIdAry = append(allPower.MenuIdAry, v.ItemId) + } + } else { + sysPower.IsPick = false + } + if v.ButPower != "" && v.ButPower != "null" { + json.Unmarshal([]byte(v.ButPower), &sysPower.ButIdAry) + } + sysPower.Scope = v.VisibleRange + if v.VisibleRange == 5 && v.ButPower != "" && v.ButPower != "null" { + json.Unmarshal([]byte(v.VisibleOrg), &sysPower.ScopeManAry) + } + allPower.SystemPower = append(allPower.SystemPower, sysPower) + } + } else { + // var systemPower []modelssystempermission.AuthPowerList + // err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = 'system' AND `orgPowerType` IN ('org','job','role') AND `orgOrUserKey` = ? AND `appKey` = 0", oupk).Find(&systemPower).Error + var mySysMenuPower XieChengPowerSys + mySysMenuPower.GetPowerSystem(systemPower) + allPower.MenuIdAry = mySysMenuPower.MenuId + allPower.SystemPower = mySysMenuPower.SystemPower + syncSeting.Add(1) + go mySysMenuPower.GetOrgSysPower("system", "org", org) + syncSeting.Add(1) + go mySysMenuPower.GetOrgSysPower("system", "job", poetId) + syncSeting.Add(1) + go mySysMenuPower.GetOrgSysPower("system", "role", oupk) + syncSeting.Wait() + mySysMenuPower.GetPowerSystem(mySysMenuPower.SysTemList) + allPower.MenuIdAry = mySysMenuPower.MenuId + var menuList []modelAppPlatform.Menus + overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Menus{}).Select("`id`,`name`").Where("`id` IN ?", mySysMenuPower.MenuId).Find(&menuList) + for _, v := range menuList { + for si, sv := range mySysMenuPower.SystemPower { + if strconv.Itoa(v.Id) == sv.AppId { + mySysMenuPower.SystemPower[si].Name = v.Name + } + } + } + allPower.SystemPower = mySysMenuPower.SystemPower + } + + //获取自定义表单权限 + var appPower []modelssystempermission.AuthPower + overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPower{}).Where("`appType` = 'app' AND `orgPowerType` = 'person' AND `orgOrUserKey` = ?", oupk).Find(&appPower) + if len(appPower) > 0 { //首先判断个人是否已经赋权 + for _, v := range appPower { + var myAppInfo AppMyPower + myAppInfo.AppId = strconv.FormatInt(v.AppKey, 10) + if v.IsTrue == 1 { + allPower.AppKeyAry = append(allPower.AppKeyAry, strconv.FormatInt(v.AppKey, 10)) + myAppInfo.IsPick = true + } else { + myAppInfo.IsPick = false + } + myAppInfo.FormTrue, myAppInfo.FormPower = GetTablePower(v.Id) + allPower.AppSystemPower = append(allPower.AppSystemPower, myAppInfo) + } + } else { + var myAppPower XieChengPowerSys + syncSeting.Add(1) + go myAppPower.GetAppFormPower("app", "org", org) + syncSeting.Add(1) + go myAppPower.GetAppFormPower("app", "job", poetId) + syncSeting.Add(1) + go myAppPower.GetAppFormPower("app", "role", oupk) + syncSeting.Wait() + var tableId []string + for _, v := range myAppPower.AppUUID { + if !publicmethod.IsInTrue[string](v, tableId) { + tableId = append(tableId, v) + } + } + + allPower.AppKeyAry = tableId + allPower.AppSystemPower = MergePower(myAppPower.FormTable) + } + return +} + +// 合并组织、角色、岗位权限 +func MergePower(FormTable []AppMyPower) (list []AppMyPower) { + for _, v := range FormTable { //循环所有授权 + isNewApp := true + for li, lv := range list { //循环已合并过的授权 + if v.AppId == lv.AppId { //判断在已合并中是否已经存在 + isNewApp = false + for _, fv := range v.FormTrue { //合并App中已经授权的表单 + if !publicmethod.IsInTrue[string](fv, lv.FormTrue) { + list[li].FormTrue = append(list[li].FormTrue, fv) + } + } + for _, pv := range v.FormPower { //相应表单权限细节整合 + if pv.IsPick { + if !publicmethod.IsInTrue[string](pv.AppId, list[li].FormTrue) { + list[li].FormTrue = append(list[li].FormTrue, pv.AppId) + } + } + isNewTable := true + for fpi, fpv := range lv.FormPower { + if pv.AppId == fpv.AppId { + isNewTable = false + list[li].FormPower[fpi].ListPower = publicmethod.MergeStruct[string](pv.ListPower, fpv.ListPower) + list[li].FormPower[fpi].TablePower = publicmethod.MergeStruct[string](pv.TablePower, fpv.TablePower) + if pv.Scope < 1 { + pv.Scope = 1 + } + if pv.Scope >= fpv.Scope { + list[li].FormPower[fpi].Scope = pv.Scope + list[li].FormPower[fpi].ScopeManAry = publicmethod.MergeStruct[int](pv.ScopeManAry, fpv.ScopeManAry) + } + } + } + if isNewTable { + list[li].FormPower = append(list[li].FormPower, pv) + } + } + + } + } + if isNewApp { + list = append(list, v) + } + } + return +} + +// 自定义App +func (x *XieChengPowerSys) GetAppFormPower(sysType, powerType string, key int64) { + defer syncSeting.Done() + switch powerType { + case "org": + //Step 1:获取可见App + var appAuthPower []modelssystempermission.AuthPower + overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` = ? AND `appKey` <> 0", sysType, powerType, key).Find(&appAuthPower) + if len(appAuthPower) > 0 { + for _, v := range appAuthPower { + appKeyStr := strconv.FormatInt(v.AppKey, 10) + var appSetUpPower AppMyPower + appSetUpPower.AppId = appKeyStr + if v.IsTrue == 1 { + appSetUpPower.IsPick = true + + if !publicmethod.IsInTrue[string](appKeyStr, x.AppUUID) { + x.AppUUID = append(x.AppUUID, appKeyStr) + } + } else { + appSetUpPower.IsPick = false + } + appSetUpPower.FormTrue, appSetUpPower.FormPower = GetMyAppTableForm(v.Id) + x.FormTable = append(x.FormTable, appSetUpPower) + } + } else { + var allFirstOrgId publicmethod.GetOrgAllParent + allFirstOrgId.GetOrgFirst(key) + if len(allFirstOrgId.Id) > 0 { //继承最近父级授权 + for _, v := range allFirstOrgId.Id { + var appAuthFirstPower []modelssystempermission.AuthPower + overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` = ? AND `appKey` <> 0", sysType, powerType, v).Find(&appAuthFirstPower) + if len(appAuthFirstPower) > 0 { + for _, v := range appAuthFirstPower { + appKeyStr := strconv.FormatInt(v.AppKey, 10) + var appSetUpPower AppMyPower + appSetUpPower.AppId = appKeyStr + if v.IsTrue == 1 { + appSetUpPower.IsPick = true + + if !publicmethod.IsInTrue[string](appKeyStr, x.AppUUID) { + x.AppUUID = append(x.AppUUID, appKeyStr) + } + } else { + appSetUpPower.IsPick = false + } + appSetUpPower.FormTrue, appSetUpPower.FormPower = GetMyAppTableForm(v.Id) + x.FormTable = append(x.FormTable, appSetUpPower) + } + } + } + } + } + case "role": + var roleId []int64 + overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`id`").Where("FIND_IN_SET(?, `superior`)", key).Find(&roleId) + if len(roleId) > 0 { + var appAuthPower []modelssystempermission.AuthPower + overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` IN ? AND `appKey` <> 0", sysType, powerType, roleId).Find(&appAuthPower) + if len(appAuthPower) > 0 { + for _, v := range appAuthPower { + appKeyStr := strconv.FormatInt(v.AppKey, 10) + var appSetUpPower AppMyPower + appSetUpPower.AppId = appKeyStr + if v.IsTrue == 1 { + appSetUpPower.IsPick = true + + if !publicmethod.IsInTrue[string](appKeyStr, x.AppUUID) { + x.AppUUID = append(x.AppUUID, appKeyStr) + } + } else { + appSetUpPower.IsPick = false + } + appSetUpPower.FormTrue, appSetUpPower.FormPower = GetMyAppTableForm(v.Id) + x.FormTable = append(x.FormTable, appSetUpPower) + } + } + } + default: + var appAuthPower []modelssystempermission.AuthPower + overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` = ? AND `appKey` <> 0", sysType, powerType, key).Find(&appAuthPower) + if len(appAuthPower) > 0 { + for _, v := range appAuthPower { + appKeyStr := strconv.FormatInt(v.AppKey, 10) + var appSetUpPower AppMyPower + appSetUpPower.AppId = appKeyStr + if v.IsTrue == 1 { + appSetUpPower.IsPick = true + if !publicmethod.IsInTrue[string](appKeyStr, x.AppUUID) { + x.AppUUID = append(x.AppUUID, appKeyStr) + } + } else { + appSetUpPower.IsPick = false + } + appSetUpPower.FormTrue, appSetUpPower.FormPower = GetMyAppTableForm(v.Id) + x.FormTable = append(x.FormTable, appSetUpPower) + } + } + } +} + +// 获取自定义App表单 +func GetMyAppTableForm(authid int64) (formId []string, list []AppMyPowerTable) { + var formListPow []modelssystempermission.PowerInfo + overall.CONSTANT_DB_System_Permission.Where("`authId` = ? ", authid).Find(&formListPow) + for _, v := range formListPow { + idStr := strconv.FormatInt(v.ItemId, 10) + var formInfo AppMyPowerTable + formInfo.AppId = idStr + if v.IsPick == 1 { + formInfo.IsPick = true + if !publicmethod.IsInTrue[string](idStr, formId) { + formId = append(formId, idStr) + } + } else { + formInfo.IsPick = false + } + if v.ListPower != "" && v.ListPower != "null" { + json.Unmarshal([]byte(v.ListPower), &formInfo.ListPower) + } + if v.TablePower != "" && v.TablePower != "null" { + json.Unmarshal([]byte(v.TablePower), &formInfo.TablePower) + } + if v.VisibleRange == 0 { + v.VisibleRange = 1 + } + formInfo.Scope = v.VisibleRange + if v.VisibleOrg != "" && v.VisibleOrg != "null" { + json.Unmarshal([]byte(v.VisibleOrg), &formInfo.ScopeManAry) + } + list = append(list, formInfo) + } + return +} + +// 系统菜单 +func (x *XieChengPowerSys) GetOrgSysPower(sysType, powerType string, key int64) { + defer syncSeting.Done() + // var systemPower []modelssystempermission.AuthPowerList + goromDb := overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = ? AND `orgPowerType` = ? AND `appKey` = 0", sysType, powerType) + switch powerType { + case "org": + + var orgPowList []modelssystempermission.AuthPowerList + overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = ? AND `orgPowerType` = ? AND `appKey` = 0 AND `orgOrUserKey` = ? ", sysType, powerType, key).Find(&orgPowList) + if len(orgPowList) > 0 { + x.SysTemList = append(x.SysTemList, orgPowList...) + } else { + var allFirstOrgId publicmethod.GetOrgAllParent + allFirstOrgId.GetOrgFirst(key) + if len(allFirstOrgId.Id) > 0 { + for _, v := range allFirstOrgId.Id { + var fatherOrgPower []modelssystempermission.AuthPowerList + overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.AuthPowerList{}).Where("`appType` = ? AND `orgPowerType` = ? AND `appKey` = 0 AND `orgOrUserKey` = ?", sysType, powerType, v).Find(&fatherOrgPower) + if len(fatherOrgPower) > 0 { + fmt.Printf("Org--%v--->%v\n\n", v, len(fatherOrgPower)) + x.SysTemList = append(x.SysTemList, fatherOrgPower...) + break + } + } + } + } + + // var allFirstOrgId publicmethod.GetOrgAllParent + // allFirstOrgId.GetOrgFirst(key) + // allFirstOrgId.Id = append(allFirstOrgId.Id, key) + + // goromDb = goromDb.Where("`orgOrUserKey` IN ?", allFirstOrgId.Id) + // goromDb.Find(&x.SysTemList) + case "role": + var roleId []int64 + overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`id`").Where("FIND_IN_SET(?, `superior`)", key).Find(&roleId) + // fmt.Printf("role----->%v\n\n", roleId) + if len(roleId) > 0 { + goromDb = goromDb.Where("`orgOrUserKey` IN ?", roleId) + goromDb.Find(&x.SysTemList) + } + + default: + // fmt.Printf("post----->%v\n\n", key) + goromDb = goromDb.Where("`orgOrUserKey` = ?", key) + goromDb.Find(&x.SysTemList) + + } + + // if len(systemPower) > 0 { + // x.GetPowerSystem(systemPower) + // } +} + +func (x *XieChengPowerSys) GetPowerSystem(list []modelssystempermission.AuthPowerList) { + // fmt.Printf("管理范围----list--->%v--->%v\n\n\n", len(list), len(x.SystemPower)) + for _, v := range list { + // fmt.Printf("管理范围----list--->%v--->%v--->%v\n\n\n", len(list), v.VisibleRange, len(v.VisibleOrg)) + appId := strconv.FormatInt(v.ItemId, 10) + if len(x.SystemPower) > 0 { //判断是否已经存在该项赋值 + isWrite := true + for xi, xv := range x.SystemPower { + if appId == xv.AppId { //存在赋值,修改 + // fmt.Printf("管理范围-----%v----->%v----->%v\n\n\n", appId, v.VisibleRange, xv.Scope) + + isWrite = false + if v.IsPick == 1 { + x.SystemPower[xi].IsPick = true + } + if v.ButPower != "" && v.ButPower != "null" { + var butPow []int64 + json.Unmarshal([]byte(v.ButPower), &butPow) + for _, bv := range butPow { + if !publicmethod.IsInTrue[int64](bv, x.SystemPower[xi].ButIdAry) { + x.SystemPower[xi].ButIdAry = append(x.SystemPower[xi].ButIdAry, bv) + } + } + } + if v.VisibleRange == 0 { + v.VisibleRange = 1 + } + if v.VisibleRange > xv.Scope { + x.SystemPower[xi].Scope = v.VisibleRange + if v.VisibleOrg != "" && v.VisibleOrg != "null" { + var visAry []int + json.Unmarshal([]byte(v.VisibleOrg), &visAry) + for _, vv := range visAry { + if !publicmethod.IsInTrue[int](vv, x.SystemPower[xi].ScopeManAry) { + x.SystemPower[xi].ScopeManAry = append(x.SystemPower[xi].ScopeManAry, vv) + } + } + } + } + + } + } + if isWrite { //没有赋值新增 + var menuPower SystemInfoPower + menuPower.AppId = appId + if v.IsPick == 1 { + menuPower.IsPick = true + } else { + menuPower.IsPick = false + } + if v.ButPower != "" && v.ButPower != "null" { + json.Unmarshal([]byte(v.ButPower), &menuPower.ButIdAry) + } else { + menuPower.ButIdAry = []int64{} + } + if v.VisibleRange == 0 { + v.VisibleRange = 1 + } + menuPower.Scope = v.VisibleRange + if v.VisibleOrg != "" && v.VisibleOrg != "null" { + json.Unmarshal([]byte(v.VisibleOrg), &menuPower.ScopeManAry) + } else { + menuPower.ScopeManAry = []int{} + } + x.SystemPower = append(x.SystemPower, menuPower) + } + } else { //没有赋值新增 + var menuPower SystemInfoPower + menuPower.AppId = appId + if v.IsPick == 1 { + menuPower.IsPick = true + } else { + menuPower.IsPick = false + } + if v.ButPower != "" && v.ButPower != "null" { + json.Unmarshal([]byte(v.ButPower), &menuPower.ButIdAry) + } else { + menuPower.ButIdAry = []int64{} + } + menuPower.Scope = 1 + if v.VisibleRange > menuPower.Scope { + menuPower.Scope = v.VisibleRange + } + + if v.VisibleOrg != "" && v.VisibleOrg != "null" { + json.Unmarshal([]byte(v.VisibleOrg), &menuPower.ScopeManAry) + } else { + menuPower.ScopeManAry = []int{} + } + x.SystemPower = append(x.SystemPower, menuPower) + } + if v.IsPick == 1 { + // idStr := strconv.FormatInt(v.ItemId, 10) + if !publicmethod.IsInTrue[int64](v.ItemId, x.MenuId) { + x.MenuId = append(x.MenuId, v.ItemId) + } + } + + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-24 14:55:49 +@ 功能: 获取自定义表单权限解析 +*/ +func GetTablePower(authId int64) (itenIdAry []string, TableList []AppMyPowerTable) { + var tableInfo []modelssystempermission.PowerInfo + overall.CONSTANT_DB_System_Permission.Where("`authId` = ?", authId).Find(&tableInfo) + for _, v := range tableInfo { + var formPwInfo AppMyPowerTable + itemIdSte := strconv.FormatInt(v.ItemId, 10) + formPwInfo.AppId = itemIdSte + if v.IsPick == 1 { + if !publicmethod.IsInTrue[string](itemIdSte, itenIdAry) { + itenIdAry = append(itenIdAry, itemIdSte) + } + formPwInfo.IsPick = true + } else { + formPwInfo.IsPick = false + } + formPwInfo.Scope = v.VisibleRange + if v.VisibleRange == 5 && v.ButPower != "" && v.ButPower != "null" { + json.Unmarshal([]byte(v.VisibleOrg), &formPwInfo.ScopeManAry) + } + if v.TablePower != "" && v.TablePower != "null" { + json.Unmarshal([]byte(v.TablePower), &formPwInfo.TablePower) + } + if v.ListPower != "" && v.ListPower != "null" { + json.Unmarshal([]byte(v.ListPower), &formPwInfo.ListPower) + } + TableList = append(TableList, formPwInfo) + } + return +} diff --git a/api/version1/user/type.go b/api/version1/user/type.go index 09387aa..3871f74 100644 --- a/api/version1/user/type.go +++ b/api/version1/user/type.go @@ -2,6 +2,7 @@ package user import ( "appPlatform/models/modelAppPlatform" + "appPlatform/models/modelssystempermission" "appPlatform/overall/publicmethod" "sync" @@ -40,6 +41,8 @@ type SendUserCont struct { EmpType int `json:"emptype"` Mobilephone string `json:"mobilephone"` Currentresidence string `json:"currentresidence"` + + AllPowerConfig SendAllPower `json:"allPowerConfig"` //所有权限 } // 年龄结构 @@ -121,3 +124,67 @@ type SendOrgAndManInfo struct { OrgManList []OrgAndPeopleInfo `json:"orgManList"` //行政组织Joi Breadcrumb []OrgAndPeopleInfo `json:"breadcrumb"` //面包屑 } + +// 输出权限列表 +type SendAllPower struct { + SystemPower []SystemInfoPower `json:"systemPower"` + MenuIdAry []int64 `json:"menuIdAry"` + AppSystemPower []AppMyPower `json:"AppSystemPower"` + AppKeyAry []string `json:"appKeyAry"` +} + +type SystemInfoPower struct { + AppId string `json:"AppId"` + publicmethod.PublicName + IsPick bool `json:"isPick` + OutPowerInfo +} + +type OutPowerInfo struct { + ButIdAry []int64 `json:"butIdAry"` + Scope int `json:"scope"` + ScopeManAry []int `json:"scopeManAry"` +} + +// 自定义应用授权 +type MyAppPower struct { + AppId string `json:"AppId"` + IsPick bool `json:"isPick` + ItemIDAry []string `json:"itemIDAry"` + TableList []TableInfoPower `json:"tableList"` +} + +// 表单陪权 +type TableInfoPower struct { + TableId string `json:"tableId"` + IsPick bool `json:"isPick` + ListPower []string `json:"listPower"` + FormPower []string `json:"formPower"` + Scope int + ScopeManAry []int +} + +// 协程处理其他权限 +type XieChengPowerSys struct { + MenuId []int64 //赋权的菜单 + SystemPower []SystemInfoPower `json:"systemPower"` + SysTemList []modelssystempermission.AuthPowerList + + AppUUID []string //赋权的菜单 + FormTable []AppMyPower +} + +type AppMyPower struct { + AppId string `json:"AppId"` + IsPick bool `json:"isPick` + FormTrue []string `json:"formTrue"` + FormPower []AppMyPowerTable `json:"formPower"` +} +type AppMyPowerTable struct { + AppId string `json:"AppId"` + IsPick bool `json:"isPick` + ListPower []string `json:"listPower"` + TablePower []string `json:"tablePower"` + Scope int `json:"scope"` + ScopeManAry []int `json:"scopeManAry"` +} diff --git a/api/version1/user/userCont.go b/api/version1/user/userCont.go index d018585..aa5cf70 100644 --- a/api/version1/user/userCont.go +++ b/api/version1/user/userCont.go @@ -56,7 +56,7 @@ func (a *ApiMethod) GetUserCont(c *gin.Context) { sendData.DepartmentName = departCont.Name //主部门名称 sendData.Organization = strconv.FormatInt(myContInfo.AdminOrg, 10) //行政组织 var orgCont modelshr.AdministrativeOrganization - orgCont.GetCont(map[string]interface{}{"`id`": myContInfo.MainDeparment}, "`name`") + orgCont.GetCont(map[string]interface{}{"`id`": myContInfo.AdminOrg}, "`name`") sendData.OrganizationName = orgCont.Name //行政组织名称 sendData.Avatar = myContInfo.Icon if myContInfo.IconPhpto != "" { @@ -82,11 +82,14 @@ func (a *ApiMethod) GetUserCont(c *gin.Context) { sendData.PostList = GainOrgPostLog(myContInfo.Key) sendData.Mobilephone = myContInfo.Mobilephone sendData.Currentresidence = myContInfo.Currentresidence + + sendData.AllPowerConfig, _ = GetMyPower("person", myContInfo.Key, myContInfo.AdminOrg, myContInfo.Position) + writeRedisData, _ := json.Marshal(sendData.AllPowerConfig) + publicmethod.SetupPowerInfo(myContInfo.Key, string(writeRedisData)) publicmethod.Result(0, sendData, c) } /* -* @ 作者: 秦东 @ 时间: 2023-11-07 10:19:45 @ 功能: 获取集团内任职记录 diff --git a/api/version1/workWechat/sendMsg.go b/api/version1/workWechat/sendMsg.go index 06bfe87..5e6e641 100644 --- a/api/version1/workWechat/sendMsg.go +++ b/api/version1/workWechat/sendMsg.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "strconv" + "strings" "time" "github.com/gin-gonic/gin" @@ -308,21 +309,29 @@ func RecallWorkWechatMsg(systemApp, msgId string) bool { if err != nil { return false } - sendInfo := publicmethod.MapOut[string]() - sendInfo["msgid"] = msgId - sendMsgData, _ := json.Marshal(sendInfo) - callBackByte := publicmethod.CurlPostJosn(sendUrl, sendMsgData) - var callBackMap interface{} - err = json.Unmarshal(callBackByte, &callBackMap) - fmt.Printf("jsonCont==>%v\n\n\n\n", string(sendMsgData)) - fmt.Printf("\n\n\n\n企业微信返回数据==>%v\n\n\n\n", string(callBackByte)) - if val, isOk := callBackMap.(map[string]interface{}); isOk { - if mapVal, isOk := val["errcode"]; isOk { - val, _ := publicmethod.StringToInt64(mapVal) - if val == 0 { - return true + isTrue := false + if msgId != "" { + msgIdAry := strings.Split(msgId, ",") + for _, v := range msgIdAry { + sendInfo := publicmethod.MapOut[string]() + sendInfo["msgid"] = v + sendMsgData, _ := json.Marshal(sendInfo) + callBackByte := publicmethod.CurlPostJosn(sendUrl, sendMsgData) + var callBackMap interface{} + err = json.Unmarshal(callBackByte, &callBackMap) + fmt.Printf("jsonCont==>%v\n\n\n\n", string(sendMsgData)) + fmt.Printf("\n\n\n\n企业微信返回数据==>%v\n\n\n\n", string(callBackByte)) + if val, isOk := callBackMap.(map[string]interface{}); isOk { + if mapVal, isOk := val["errcode"]; isOk { + val, _ := publicmethod.StringToInt64(mapVal) + if val == 0 { + // return true + isTrue = true + } + } } } } - return false + + return isTrue } diff --git a/apirouter/appPower/entry.go b/apirouter/appPower/entry.go new file mode 100644 index 0000000..d8924db --- /dev/null +++ b/apirouter/appPower/entry.go @@ -0,0 +1,3 @@ +package appPower + +type ApiRouter struct{} diff --git a/apirouter/appPower/powerRole.go b/apirouter/appPower/powerRole.go new file mode 100644 index 0000000..3ad929d --- /dev/null +++ b/apirouter/appPower/powerRole.go @@ -0,0 +1,32 @@ +package appPower + +import ( + "appPlatform/api/version1" + + "github.com/gin-gonic/gin" +) + +/** +@ 作者: 秦东 +@ 时间: 2025-11-10 10:50:19 +@ 功能: 权限处理 +*/ + +func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { + apiRouter := router.Group("authorize") + + var methodBinding = version1.AppApiEntry.AuthorizeApi + { + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + + apiRouter.POST("appPowerUnit", methodBinding.AppPowerUnit) //获取平台授权项目 + apiRouter.POST("getMyPeoplceAndSunOrg", methodBinding.GetMyPeopleAndSunOrg) //获取首层子行政组织和本组织下的人员 + apiRouter.POST("getMyPeopleAndSunOrgPost", methodBinding.GetMyPeopleAndSunOrgPost) //获取首层子行政组织和本组织下的岗位及人员 + apiRouter.POST("getPowerPageUser", methodBinding.GetPowerPageUser) //获取人员 + apiRouter.POST("systemAppAuthorization", methodBinding.SystemAppAuthorization) //授权 + apiRouter.POST("getRolePeople", methodBinding.GetRolePeople) //获取角色使用人 + apiRouter.POST("savePickRoleMan", methodBinding.SavePickRoleMan) //保存角色使用人 + } + +} diff --git a/apirouter/authenticationroute/entry.go b/apirouter/authenticationroute/entry.go index 0b418c5..a362e8a 100644 --- a/apirouter/authenticationroute/entry.go +++ b/apirouter/authenticationroute/entry.go @@ -2,3 +2,4 @@ package authenticationroute //身份验证 type ApiRouter struct{} +type RoleApiRouter struct{} diff --git a/apirouter/authenticationroute/signcoderoute.go b/apirouter/authenticationroute/signcoderoute.go index dc9a2e3..c27614a 100644 --- a/apirouter/authenticationroute/signcoderoute.go +++ b/apirouter/authenticationroute/signcoderoute.go @@ -13,8 +13,23 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { var methodBinding = authentication.AppApiEntry.SingCodeApi { - apiRouter.GET("", methodBinding.Index) //入口 - apiRouter.POST("", methodBinding.Index) //入口 - apiRouter.POST("signcode", methodBinding.SignCode) //验证身份 + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + apiRouter.POST("signcode", methodBinding.SignCode) //验证身份 + apiRouter.POST("haveMyCode", methodBinding.HaveMyCode) //获取身份 + } +} +func (a *RoleApiRouter) RouterGroup(router *gin.RouterGroup) { + apiRouter := router.Group("permission") + + var methodBinding = authentication.AppApiEntry.RoleApi + { + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + apiRouter.POST("giveRoleGroupTree", methodBinding.GiveRoleGroupTree) //获取角色分组树 + apiRouter.POST("giveRoleTree", methodBinding.GiveRoleTree) //获取角色树 + apiRouter.POST("editRoleCont", methodBinding.EditRoleCont) //编辑角色组 + apiRouter.POST("editRoleStatus", methodBinding.EditRoleStatus) //修改角色状态 + apiRouter.POST("getOrgPostTree", methodBinding.GetOrgPostTree) //获取行政组织加岗位树 } } diff --git a/apirouter/entry.go b/apirouter/entry.go index 978a95d..e3f5cb9 100644 --- a/apirouter/entry.go +++ b/apirouter/entry.go @@ -2,7 +2,9 @@ package apirouter import ( "appPlatform/apirouter/apishiyan" + "appPlatform/apirouter/appPower" "appPlatform/apirouter/authenticationroute" + "appPlatform/apirouter/hrRoute" "appPlatform/apirouter/personalityAssessment" "appPlatform/apirouter/v1/customChartRouter" "appPlatform/apirouter/v1/customerformrouter" @@ -41,6 +43,9 @@ type RouterGroup struct { WebSocketRouters websocketrouter.ApiRouter CharacterTestRongXin personalityAssessment.ApiRouter ChartRouter customChartRouter.ApiRouter + RoleApiRouter authenticationroute.RoleApiRouter + AuthorizeRouter appPower.ApiRouter + HrApiRoute hrRoute.ApiRouter } var RouterGroupEntry = new(RouterGroup) diff --git a/apirouter/hrRoute/enter.go b/apirouter/hrRoute/enter.go new file mode 100644 index 0000000..c74e20c --- /dev/null +++ b/apirouter/hrRoute/enter.go @@ -0,0 +1,3 @@ +package hrRoute + +type ApiRouter struct{} diff --git a/apirouter/hrRoute/hrrouter.go b/apirouter/hrRoute/hrrouter.go new file mode 100644 index 0000000..0613d45 --- /dev/null +++ b/apirouter/hrRoute/hrrouter.go @@ -0,0 +1,18 @@ +package hrRoute + +import ( + "appPlatform/api/version1" + + "github.com/gin-gonic/gin" +) + +// 授权 +func (p *ApiRouter) InitRouterGroup(route *gin.RouterGroup) { + apiRouter := route.Group("hr") + var apiHandle = version1.AppApiEntry.HrApi + { + apiRouter.GET("", apiHandle.Index) //入口 + apiRouter.POST("", apiHandle.Index) //入口 + apiRouter.POST("authorizeOrgTree", apiHandle.AuthorizeOrgTree) //行政组织树 + } +} diff --git a/apirouter/v1/customChartRouter/chartRouter.go b/apirouter/v1/customChartRouter/chartRouter.go index ec76387..be53655 100644 --- a/apirouter/v1/customChartRouter/chartRouter.go +++ b/apirouter/v1/customChartRouter/chartRouter.go @@ -15,9 +15,11 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter.GET("", dataApi.Index) //入口 apiRouter.POST("", dataApi.Index) //入口 - apiRouter.POST("dimMeaFormTable", dataApi.DimMeaFormTable) //获取维度及度量字段 - apiRouter.POST("countChartValue", dataApi.CountChartValue) //将图表信息写入数据库 - apiRouter.POST("getChartCont", dataApi.GetChartCont) //获取图表设定信息 - apiRouter.POST("analyzeChartData", dataApi.AnalyzeChartData) //根据条件解析图标结果 + apiRouter.POST("dimMeaFormTable", dataApi.DimMeaFormTable) //获取维度及度量字段 + apiRouter.POST("countChartValue", dataApi.CountChartValue) //将图表信息写入数据库 + apiRouter.POST("getChartCont", dataApi.GetChartCont) //获取图表设定信息 + apiRouter.POST("analyzeChartData", dataApi.AnalyzeChartData) //根据条件解析图标结果 + apiRouter.POST("getMyChartSetupAndData", dataApi.GetMyChartSetupAndData) //初始化个人图表配置及数据 + apiRouter.POST("saveMyBiCharts", dataApi.SaveMyBiCharts) //保存跟人图表设置 } } diff --git a/apirouter/v1/customerformrouter/router.go b/apirouter/v1/customerformrouter/router.go index 93f5fba..ebc6a80 100644 --- a/apirouter/v1/customerformrouter/router.go +++ b/apirouter/v1/customerformrouter/router.go @@ -43,7 +43,10 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("edit_form_field", methodBinding.EditFormField) //编辑数据库表字段信息 apiRouter.POST("gainFormTableField", methodBinding.GainFormTableField) //获取表格字段 - apiRouter.POST("gainTableField", methodBinding.GainTableField) //获取数据库表字段 + + apiRouter.POST("gainFormTableFields", methodBinding.GainFormTableFieldes) //获取表格字段新 + + apiRouter.POST("gainTableField", methodBinding.GainTableField) //获取数据库表字段 apiRouter.POST("gainTableVersionField", methodBinding.GainTableVersionField) //根据版本Id获取相应的表单结构 @@ -113,5 +116,22 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { appApiRouter.POST("gainAppGroupMenus", methodAppHand.GainAppGroupMenus) //获取分组App菜单 appApiRouter.POST("moveAppMenus", methodAppHand.MoveAppMenus) //移动栏目 + + appApiRouter.POST("companyDutyInit", methodAppHand.CompanyDutyInit) //初始化排版页面 + appApiRouter.POST("getYearMonthWorkMan", methodAppHand.GetYearMonthWorkMan) //获取根据年月获取排班目录表 + appApiRouter.POST("geiOrgAllPeople", methodAppHand.GeiOrgAllPeople) //根据行政组织获取人员信息 + appApiRouter.POST("saveEditDutyInfo", methodAppHand.SaveEditDutyInfo) //编辑值班信息 + appApiRouter.POST("geyOneDayDuty", methodAppHand.GeyOneDayDuty) //根据日期获取行政组织排班列表 + + appApiRouter.POST("delOneDayDuty", methodAppHand.DelOneDayDuty) //清空日期值班 + appApiRouter.POST("getDutyCont", methodAppHand.GetDutyCont) //获取排版信息 + + appApiRouter.POST("get_org_everyone_people", methodAppHand.GetOrgAndEveryOnePeople) //行政组织树及相关人员(新版) + appApiRouter.POST("getOrgTree", methodAppHand.GetOrgTree) //获取行政组织树 + appApiRouter.POST("getOrgPeopleList", methodAppHand.GetOrgPeopleList) //获取人员信息 + appApiRouter.POST("delMonthOneus", methodAppHand.DelMonthOneus) //日历表单一删除值班人 + appApiRouter.GET("downLoadDutyPage", methodAppHand.DownLoadDutyPage) //下载排班模板 + appApiRouter.POST("uploadFilesRedis", methodAppHand.UploadFilesRedis) //上传文档并解析(Redis) + appApiRouter.POST("analysisDutyData", methodAppHand.AnalysisDutyData) //将排班信息解写入数据库 } } diff --git a/apirouter/v1/grantsystempower/pc.go b/apirouter/v1/grantsystempower/pc.go index 22932bd..e542176 100644 --- a/apirouter/v1/grantsystempower/pc.go +++ b/apirouter/v1/grantsystempower/pc.go @@ -19,5 +19,6 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("gainAppList", methodBinding.GainAppList) //不分类别的自定义App列表 apiRouter.POST("gainAppTableList", methodBinding.GainAppTableList) //获取对应App下边的表单 apiRouter.POST("setpAppTableForms", methodBinding.SetpAppTableForm) //提交APp单一表单权限 + apiRouter.POST("gainAppTableListNew", methodBinding.GainAppTableListNew) //获取对应App下边的表单 } } diff --git a/apirouter/v1/public/router.go b/apirouter/v1/public/router.go index 62fe1b8..9f2d903 100644 --- a/apirouter/v1/public/router.go +++ b/apirouter/v1/public/router.go @@ -25,5 +25,6 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.GET("verifyIdentity", methodBinding.VerifyIdentity) //验证身份登录 apiRouter.POST("silentLogin", methodBinding.SilentLogin) //验证无感登录 apiRouter.POST("gainAllRole", methodBinding.GainAllRole) //获取角色列表 + apiRouter.GET("downLoadDutyPage", methodBinding.DownLoadDutyPage) //获取角色列表 } } diff --git a/apirouter/v1/taskrouter/taskrouter.go b/apirouter/v1/taskrouter/taskrouter.go index c612154..f8648a5 100644 --- a/apirouter/v1/taskrouter/taskrouter.go +++ b/apirouter/v1/taskrouter/taskrouter.go @@ -77,7 +77,9 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { taskFlowApi.POST("judgeFormFlowIsOpen", taskFlowRouter.JudgeFormFlowIsOpen) //判断是否已经存在工作流以及是否开启 taskFlowApi.POST("openFormFlow", taskFlowRouter.OpenFormFlow) //开启或关闭表单流程 - taskFlowApi.POST("analysisForm", taskFlowRouter.AnalysisForm) //解析自定义表单组件 + taskFlowApi.POST("analysisForm", taskFlowRouter.AnalysisForm) //解析自定义表单组件 + taskFlowApi.POST("analyFormJsonMap", taskFlowRouter.AnalyFormJsonMap) //解析表单格式 + taskFlowApi.POST("setFlowFormKeyPower", taskFlowRouter.SetFlowFormKeyPower) //设置工作流表单字段权限 taskFlowApi.POST("startRunFlow", taskFlowRouter.StartRunFlow) //发起工作流 diff --git a/config/configDatabase/database.yaml b/config/configDatabase/database.yaml index 9ec4d36..29f5b5e 100644 --- a/config/configDatabase/database.yaml +++ b/config/configDatabase/database.yaml @@ -215,17 +215,17 @@ systemPermission: #应用平台数据库 appPlatformDatabase: - url_path: '172.20.5.34' #数据库地址 - port: 4000 #数据库端口 - name: 'app_platform' #数据库名称 - username: 'root' #数据库用户民 - password: '9z_Bu28r1*DZ3K6@+a' #数据库密码 - - # url_path: '127.0.0.1' #数据库地址 - # port: 3306 #数据库端口 + # url_path: '172.20.5.34' #数据库地址 + # port: 4000 #数据库端口 # name: 'app_platform' #数据库名称 # username: 'root' #数据库用户民 - # password: 'root' #数据库密码 + # password: '9z_Bu28r1*DZ3K6@+a' #数据库密码 + + url_path: '127.0.0.1' #数据库地址 + port: 3306 #数据库端口 + name: 'app_platform' #数据库名称 + username: 'root' #数据库用户民 + password: 'root' #数据库密码 charset: 'utf8mb4' #数据库编码方式 @@ -287,17 +287,17 @@ tidbrmaster: #自定义数据库 customerFormDatabase: - url_path: '172.20.5.34' #数据库地址 - port: 4000 #数据库端口 - name: 'customer_form' #数据库名称 - username: 'root' #数据库用户民 - password: '9z_Bu28r1*DZ3K6@+a' #数据库密码 - - # url_path: '127.0.0.1' #数据库地址 - # port: 3306 #数据库端口 + # url_path: '172.20.5.34' #数据库地址 + # port: 4000 #数据库端口 # name: 'customer_form' #数据库名称 # username: 'root' #数据库用户民 - # password: 'root' #数据库密码 + # password: '9z_Bu28r1*DZ3K6@+a' #数据库密码 + + url_path: '127.0.0.1' #数据库地址 + port: 3306 #数据库端口 + name: 'customer_form' #数据库名称 + username: 'root' #数据库用户民 + password: 'root' #数据库密码 charset: 'utf8mb4' #数据库编码方式 parseTime: 'True' #是否自动转换时间 diff --git a/go.mod b/go.mod index b1ed0c7..eefb965 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ module appPlatform go 1.24 require ( + github.com/360EntSecGroup-Skylar/excelize v1.4.1 github.com/dengsgo/math-engine v0.0.0-20230823154425-78f211b48149 github.com/flipped-aurora/gin-vue-admin/server v0.0.0-20231212025023-e0a8e9370425 github.com/fsnotify/fsnotify v1.7.0 @@ -30,6 +31,7 @@ require ( github.com/jackc/pgx/v5 v5.5.5 // indirect github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/microsoft/go-mssqldb v1.7.2 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/richardlehane/mscfb v1.0.4 // indirect github.com/richardlehane/msoleps v1.0.4 // indirect github.com/tiendc/go-deepcopy v1.6.0 // indirect diff --git a/go.sum b/go.sum index 01f9636..139bbc4 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/360EntSecGroup-Skylar/excelize v1.4.1 h1:l55mJb6rkkaUzOpSsgEeKYtS6/0gHwBYyfo5Jcjv/Ks= +github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5EvSCJcmH3dT9luvxzu8iGAE= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= @@ -155,6 +157,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/mozillazg/go-pinyin v0.20.0 h1:BtR3DsxpApHfKReaPO1fCqF4pThRwH9uwvXzm+GnMFQ= github.com/mozillazg/go-pinyin v0.20.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc= @@ -193,6 +197,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= diff --git a/initialization/route/initRoute.go b/initialization/route/initRoute.go index 147fc36..726ba98 100644 --- a/initialization/route/initRoute.go +++ b/initialization/route/initRoute.go @@ -113,12 +113,24 @@ func InitialRouter() *gin.Engine { { chartInitRouterApi.RouterGroup(VerifyIdentity) } + //赋权处理 + permission := apirouter.RouterGroupEntry.RoleApiRouter + { + permission.RouterGroup(appLoadRouterGroup) + } + //新版权限处理 + newAuthorizePower := apirouter.RouterGroupEntry.AuthorizeRouter + { + newAuthorizePower.RouterGroup(appLoadRouterGroup) + } } //验证身份接口 无需鉴权Url(主要web端使用) VerifyIdentityWeb := router.Group("") VerifyIdentityWeb.Use(interceptor.AuthenticateUser()) { - + //hr人力资源 + hrAutorizRouteApi := apirouter.RouterGroupEntry.HrApiRoute + hrAutorizRouteApi.InitRouterGroup(VerifyIdentityWeb) } //Token身份验证 VerifyIdentityToken := router.Group("") diff --git a/models/customerForm/shiftChangeApplication.go b/models/customerForm/shiftChangeApplication.go new file mode 100644 index 0000000..e80337c --- /dev/null +++ b/models/customerForm/shiftChangeApplication.go @@ -0,0 +1,78 @@ +package customerForm + +import ( + "appPlatform/overall" + "strings" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2024-03-06 13:23:03 +@ 功能: 公司值班设定表 +*/ +type SCApplication struct { + Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"` + MastersKey int64 `gorm:"column:masters_key;type:bigint(20) unsigned;default:0;comment:主表标识;NOT NULL" json:"masters_key"` + Creater int64 `gorm:"column:creater;type:bigint(20);comment:申请人" json:"creater"` + CreaterTime int64 `gorm:"column:creater_time;type:bigint(20) unsigned;default:0;comment:创建时间;NOT NULL" json:"creater_time"` + EditTime int64 `gorm:"column:edit_time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"edit_time"` + FlowId int64 `gorm:"column:flow_id;type:bigint(20) unsigned;default:0;comment:流程识别标识;NOT NULL" json:"flow_id"` + States int `gorm:"column:states;type:int(11) unsigned;default:1;comment:状态(1:启用,2:禁用;3:删除);NOT NULL" json:"states"` + FlowIsOpen int `gorm:"column:flowIsOpen;type:int(1) unsigned;default:2;comment:是否开启工作流;NOT NULL" json:"flowIsOpen"` + Diao4Huan4Ren2 string `gorm:"column:diao4huan4ren2;type:mediumtext;comment:调换人" json:"diao4huan4ren2"` + Shen1Qing3Yuan2Yin1 string `gorm:"column:shen1qing3yuan2yin1;type:mediumtext;comment:申请原因" json:"shen1qing3yuan2yin1"` + Diao4Huan4Fang1Shi4 string `gorm:"column:diao4huan4fang1shi4;type:varchar(50);comment:调换方式" json:"diao4huan4fang1shi4"` + Shou3Ji1Hao4 string `gorm:"column:shou3ji1hao4;type:varchar(255);comment:手机号" json:"shou3ji1hao4"` + CreaterOrg int `gorm:"column:createrOrg;type:int(1) unsigned;default:2;comment:创建人行政组织;NOT NULL" json:"createrOrg"` + Dang1Zhi2Ri4Qi141995810 int64 `gorm:"column:dang1zhi2ri4qi141995810;type:bigint(20) unsigned;default:0;comment:当值日期;NOT NULL" json:"dang1zhi2ri4qi141995810"` + Zhi2Ban1Lei4Xing2 string `gorm:"column:zhi2ban1lei4xing2;type:varchar(50);comment:值班类型" json:"zhi2ban1lei4xing2"` + Diao4Huan4Ri4Qi1 int64 `gorm:"column:diao4huan4ri4qi1;type:bigint(20) unsigned;default:0;comment:调换日期;NOT NULL" json:"diao4huan4ri4qi1"` + Fu4Jian4 string `gorm:"column:fu4jian4;type:mediumtext;comment:附件" json:"fu4jian4"` + Shou3Ji1Hao453554781 string `gorm:"column:shou3ji1hao453554781;type:varchar(255);comment:手机号" json:"shou3ji1hao453554781"` +} + +func (cont *SCApplication) TableName() string { + return "shiftChangeApplication" +} + +// 编辑内容 +func (cont *SCApplication) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *SCApplication) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_CustomerForm.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *SCApplication) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_CustomerForm.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *SCApplication) ContMap(whereMap interface{}, field ...string) (countAry []SCApplication, err error) { + gormDb := overall.CONSTANT_DB_CustomerForm.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *SCApplication) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_CustomerForm.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelAppPlatform/customer_form_version.go b/models/modelAppPlatform/customer_form_version.go index 2e22255..391b743 100644 --- a/models/modelAppPlatform/customer_form_version.go +++ b/models/modelAppPlatform/customer_form_version.go @@ -27,6 +27,7 @@ type CustomerFormVersion struct { AuthorizedOrg string `json:"authorizedOrg" gorm:"column:authorizedOrg;type:mediumtext;default:'';comment:授权行政组织"` AuthorizedPosition string `json:"authorizedPosition" gorm:"column:authorizedPosition;type:mediumtext;default:'';comment:授权职务"` SignCode int64 `json:"signCode" gorm:"column:signCode;type:bigint(20) unsigned NOT NULL DEFAULT '0';comment:唯一标识"` + ListJsonInfo string `json:"listJsonInfo" gorm:"column:listJsonInfo;type:longtext;default:'';comment:列表结构体"` } func (CustomerFormVersion *CustomerFormVersion) TableName() string { diff --git a/models/modelAppPlatform/customer_form_view.go b/models/modelAppPlatform/customer_form_view.go index 7517a33..d8ada34 100644 --- a/models/modelAppPlatform/customer_form_view.go +++ b/models/modelAppPlatform/customer_form_view.go @@ -41,6 +41,7 @@ type CustomerFormView struct { SignCode int64 `json:"signCode" gorm:"column:signCode;type:bigint(20) unsigned NOT NULL DEFAULT '0';comment:唯一标识"` Describe string `json:"describe" gorm:"column:describe;type:longtext;default:'';comment:描述"` ChartView string `json:"chartView" gorm:"column:chartView;type:longtext;default:'';comment:图表视图"` + ListJsonInfo string `json:"listJsonInfo" gorm:"column:listJsonInfo;type:longtext;default:'';comment:列表结构体"` } func (CustomerFormView *CustomerFormView) TableName() string { diff --git a/models/modelAppPlatform/mychart..go b/models/modelAppPlatform/mychart..go new file mode 100644 index 0000000..ff78b65 --- /dev/null +++ b/models/modelAppPlatform/mychart..go @@ -0,0 +1,70 @@ +package modelAppPlatform + +import ( + "appPlatform/overall" + "strings" +) + +// 个人图表设置 +type Mychart struct { + Uuid int64 `gorm:"column:uuid;type:bigint(20) unsigned;primary_key" json:"uuid"` + TableKey string `gorm:"column:tableKey;type:varchar(200);comment:关联得表单key" json:"tableKey"` + UserKey int64 `gorm:"column:userKey;type:bigint(20) unsigned;comment:使用人的KEY;NOT NULL" json:"userKey"` + ChartView string `gorm:"column:chartView;type:longtext;comment:图标设定值" json:"chartView"` + EditTime int64 `gorm:"column:editTime;type:bigint(20) unsigned;comment:编辑时间" json:"editTime"` +} + +func (m Mychart) Create(mychart *Mychart) { + panic("unimplemented") +} + +func (m *Mychart) TableName() string { + return "mychart" +} + +// 写入内容 +func (cont *Mychart) WriteCont() (err error) { + err = overall.CONSTANT_DB_AppPlatform.Create(&cont).Error + return +} + +// 编辑内容 +func (cont *Mychart) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Mychart) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *Mychart) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Mychart) ContMap(whereMap interface{}, field ...string) (countAry []Mychart, err error) { + gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *Mychart) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelshr/org_cont.go b/models/modelshr/org_cont.go new file mode 100644 index 0000000..d6e0ad6 --- /dev/null +++ b/models/modelshr/org_cont.go @@ -0,0 +1,82 @@ +package modelshr + +import ( + "appPlatform/middleware/grocerystore" + "appPlatform/overall" + "encoding/json" + "fmt" + "strings" +) + +// 行政组织内哦他那个 +type OrgCont struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` + Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` + Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` + OrganizationType int64 `json:"organizationtype" gorm:"column:organization_type;type:bigint(20) unsigned;default:0;not null;comment:行政组织类型"` + Abbreviation string `json:"abbreviation" gorm:"column:abbreviation;type:varchar(255) unsigned;default:'';not null;comment:行政组织简称"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + WechatOrganizationId int64 `json:"wechatorganizationid" gorm:"column:wechat_organization_id;type:bigint(20) unsigned;default:0;not null;comment:微信组织架构对照码"` + SuperiorSun string `json:"superiorsun" gorm:"column:superior_sun;type:mediumtext;comment:级联ID"` + Schoole int64 `json:"schoole" gorm:"column:schoole;type:bigint(20) unsigned;default:0;not null;comment:原知行学院对照码"` + KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` + IsPower int `json:"ispower" gorm:"column:ispower;type:int(1) unsigned;default:2;not null;comment:是否为实权部门"` + Sort int `json:"sort" gorm:"column:sort;type:int(6) unsigned;default:100;not null;comment:排序"` + TypeName string `json:"typeName" gorm:"column:type_name;type:varchar(255) unsigned;default:'';not null;comment:类型名称"` + Level int64 `json:"level" gorm:"column:level;type:int(5) unsigned;default:1;not null;comment:级别"` +} + +func (OrgCont *OrgCont) TableName() string { + return "org_cont" +} + +// 获取行政组织内容 +func (cont *OrgCont) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *OrgCont) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *OrgCont) ContMap(whereMap interface{}, field ...string) (countAry []OrgCont) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb.Where(whereMap).Find(&countAry) + return +} + +// 根据ID获取行政组织内容 +func (cont *OrgCont) RedisCont(orgId int64) (err error) { + redisFileKey := fmt.Sprintf("org:Info:%v_%v", orgId, overall.CONSTANT_CONFIG.RedisPrefixStr.Alias) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) //设定redis库 + isTrue, tokens := redisClient.Get(redisFileKey) + if isTrue && tokens != "" { + err = json.Unmarshal([]byte(tokens), &cont) + return + } else { + var jsonStr []byte + err = overall.CONSTANT_DB_HR.Model(&cont).Where("`id` = ?", orgId).First(&cont).Error + if err == nil { + redisClient.SetRedisTime(0) + jsonStr, err = json.Marshal(cont) + redisClient.Set(redisFileKey, string(jsonStr)) + } + } + return +} diff --git a/models/modelssystempermission/auth_power.go b/models/modelssystempermission/auth_power.go new file mode 100644 index 0000000..e4a0497 --- /dev/null +++ b/models/modelssystempermission/auth_power.go @@ -0,0 +1,63 @@ +package modelssystempermission + +import ( + "appPlatform/overall" + "strings" +) + +// 新版赋权表单 +type AuthPower struct { + Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key" json:"id"` + OrgPowerType string `gorm:"column:orgPowerType;type:varchar(20);comment:赋权类型(org:组织;job:岗位;role:角色;person:个人)" json:"orgPowerType"` + OrgOrUserKey int64 `gorm:"column:orgOrUserKey;type:bigint(20) unsigned;default:0;comment:行政组织或角色、人员识别符;NOT NULL" json:"orgOrUserKey"` + AppType string `gorm:"column:appType;type:varchar(30);comment:系统类型(system:系统平台;app:自定义表单与应用)" json:"appType"` + AppKey int64 `gorm:"column:appKey;type:bigint(20) unsigned;default:0;comment:自定义应用App" json:"appKey"` + Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"` + IsTrue int `gorm:"column:isTrue;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isTrue"` + PowerInfo string `gorm:"column:powerInfo;type:text;comment:权限结构体" json:"powerInfo"` +} + +func (cont *AuthPower) TableName() string { + return "auth_power" +} + +// 编辑内容 +func (cont *AuthPower) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *AuthPower) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *AuthPower) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *AuthPower) ContMap(whereMap interface{}, field ...string) (countAry []AuthPower, err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *AuthPower) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelssystempermission/authpowerlist.go b/models/modelssystempermission/authpowerlist.go new file mode 100644 index 0000000..880b21c --- /dev/null +++ b/models/modelssystempermission/authpowerlist.go @@ -0,0 +1,72 @@ +package modelssystempermission + +import ( + "appPlatform/overall" + "strings" +) + +// 新版赋权表单 +type AuthPowerList struct { + Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"` + AuthId int64 `gorm:"column:authId;type:bigint(20) unsigned;default:0;comment:归属权限;NOT NULL" json:"authId"` + ItemId int64 `gorm:"column:itemId;type:bigint(20) unsigned;default:0;comment:项目ID;NOT NULL" json:"itemId"` + IsPick int `gorm:"column:isPick;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isPick"` + TablePower string `gorm:"column:tablePower;type:text;comment:表单权限" json:"tablePower"` + ListPower string `gorm:"column:listPower;type:text;comment:列表权限" json:"listPower"` + VisibleRange int `gorm:"column:visibleRange;type:int(1);comment:可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有);NOT NULL" json:"visibleRange"` + VisibleOrg string `gorm:"column:visibleOrg;type:text;comment:可见范围辅助参数" json:"visibleOrg"` + ButPower string `gorm:"column:butPower;type:text;comment:按钮权限" json:"butPower"` + Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"` + + OrgPowerType string `gorm:"column:orgPowerType;type:varchar(20);comment:赋权类型(org:组织;job:岗位;role:角色;person:个人)" json:"orgPowerType"` + OrgOrUserKey int64 `gorm:"column:orgOrUserKey;type:bigint(20) unsigned;default:0;comment:行政组织或角色、人员识别符;NOT NULL" json:"orgOrUserKey"` + AppType string `gorm:"column:appType;type:varchar(30);comment:系统类型(system:系统平台;app:自定义表单与应用)" json:"appType"` + AppKey int64 `gorm:"column:appKey;type:bigint(20) unsigned;default:0;comment:自定义应用App" json:"appKey"` + IsTrue int `gorm:"column:isTrue;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isTrue"` + PowerInfo string `json:"powerInfo" gorm:"column:powerInfo;type:text;comment:权限结构体"` +} + +func (cont *AuthPowerList) TableName() string { + return "authpowerlist" +} + +// 编辑内容 +func (cont *AuthPowerList) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *AuthPowerList) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *AuthPowerList) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *AuthPowerList) ContMap(whereMap interface{}, field ...string) (countAry []AuthPowerList, err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *AuthPowerList) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelssystempermission/power_info.go b/models/modelssystempermission/power_info.go new file mode 100644 index 0000000..df80cf4 --- /dev/null +++ b/models/modelssystempermission/power_info.go @@ -0,0 +1,65 @@ +package modelssystempermission + +import ( + "appPlatform/overall" + "strings" +) + +// 权限配置详情 +type PowerInfo struct { + Id int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"` + AuthId int64 `gorm:"column:authId;type:bigint(20) unsigned;default:0;comment:归属权限;NOT NULL" json:"authId"` + ItemId int64 `gorm:"column:itemId;type:bigint(20) unsigned;default:0;comment:项目ID;NOT NULL" json:"itemId"` + IsPick int `gorm:"column:isPick;type:int(1) unsigned;default:0;comment:是否有权(1:有;非1:无);NOT NULL" json:"isPick"` + TablePower string `gorm:"column:tablePower;type:text;comment:表单权限" json:"tablePower"` + ListPower string `gorm:"column:listPower;type:text;comment:列表权限" json:"listPower"` + VisibleRange int `gorm:"column:visibleRange;type:int(1);comment:可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有);NOT NULL" json:"visibleRange"` + VisibleOrg string `gorm:"column:visibleOrg;type:text;comment:可见范围辅助参数" json:"visibleOrg"` + ButPower string `gorm:"column:butPower;type:text;comment:按钮权限" json:"butPower"` + Time int64 `gorm:"column:time;type:bigint(20) unsigned;default:0;comment:编辑时间;NOT NULL" json:"time"` +} + +func (cont *PowerInfo) TableName() string { + return "power_info" +} + +// 编辑内容 +func (cont *PowerInfo) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *PowerInfo) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *PowerInfo) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *PowerInfo) ContMap(whereMap interface{}, field ...string) (countAry []PowerInfo, err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *PowerInfo) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelssystempermission/system_role.go b/models/modelssystempermission/system_role.go index 46590b1..249b852 100644 --- a/models/modelssystempermission/system_role.go +++ b/models/modelssystempermission/system_role.go @@ -7,11 +7,14 @@ import ( // 系统角色表 type SystemRole struct { - Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` - Name string `json:"name" gorm:"column:name;type:varchar(255) ;comment:系统名称"` - State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` - Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` - Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:50;not null;comment:排序"` + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Name string `json:"name" gorm:"column:name;type:varchar(255) ;comment:系统名称"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:50;not null;comment:排序"` + Types int `json:"types" gorm:"column:types;type:int(1) unsigned;default:50;not null;comment:类型"` + Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级"` + Roleuser string `json:"roleuser" gorm:"column:roleuser;type:longtext;comment:使用人员"` } func (SystemRole *SystemRole) TableName() string { diff --git a/models/teamlog/companylog.go b/models/teamlog/companylog.go new file mode 100644 index 0000000..d99a908 --- /dev/null +++ b/models/teamlog/companylog.go @@ -0,0 +1,69 @@ +// Code generated by sql2gorm. DO NOT EDIT. +package teamlog + +import ( + "appPlatform/overall" + "strings" +) + +// 公司值班表记录 +type Companylog struct { + ID int64 `gorm:"column:id;type:bigint(20) unsigned;primary_key;AUTO_INCREMENT" json:"id"` + Orgid int64 `gorm:"column:orgid;type:bigint(20) unsigned;default:0;NOT NULL" json:"orgid"` // 行政组织ID + RunTime int64 `gorm:"column:runTime;type:bigint(20) unsigned;default:0;NOT NULL" json:"runTime"` // 执行时间 + Years int `gorm:"column:years;type:int(5) unsigned;default:0;NOT NULL" json:"years"` // 年 + Months int `gorm:"column:months;type:int(3) unsigned;default:0;NOT NULL" json:"months"` // 月 + Days int `gorm:"column:days;type:int(3) unsigned;default:0;NOT NULL" json:"days"` // 日 + Holiday int `gorm:"column:holiday;type:int(1) unsigned;default:2;NOT NULL" json:"holiday"` // 假日(1:是;2:否) + AllDay string `gorm:"column:allDay;type:mediumtext" json:"allDay"` // 全天值班人员 + BaiTian string `gorm:"column:baiTian;type:mediumtext" json:"baiTian"` // 白天值班人员 + Night string `gorm:"column:night;type:mediumtext" json:"night"` // 夜晚值班人员 + SaveTime int64 `gorm:"column:saveTime;type:bigint(20);NOT NULL" json:"saveTime"` // 编辑时间 + Morning string `gorm:"column:morning;type:mediumtext" json:"morning"` // 上午值班人员 + Afternoon string `gorm:"column:afternoon;type:mediumtext" json:"afternoon"` // 下午值班人员 +} + +func (m *Companylog) TableName() string { + return "companylog" +} + +// 编辑内容 +func (cont *Companylog) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_TeamsLog.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Companylog) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_TeamsLog.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *Companylog) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_TeamsLog.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Companylog) ContMap(whereMap interface{}, field ...string) (countAry []TeamsLog, err error) { + gormDb := overall.CONSTANT_DB_TeamsLog.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *Companylog) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_TeamsLog.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/publicmethod/getUserPower.go b/overall/publicmethod/getUserPower.go index 0d546ab..7b55152 100644 --- a/overall/publicmethod/getUserPower.go +++ b/overall/publicmethod/getUserPower.go @@ -4,6 +4,7 @@ import ( "appPlatform/models/modelshr" "appPlatform/models/modelssystempermission" "appPlatform/overall" + "encoding/json" "fmt" "strconv" "strings" @@ -37,9 +38,11 @@ func (g *GainUserPower) GetUserPower() (powerInfo SendUserPower) { var rolePowerList []modelssystempermission.RoleEmpower overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.RoleEmpower{}).Where("`state` = 1 AND `system` = ? AND `role_id` IN ?", g.SystemName, roleAry).Find(&rolePowerList) for _, v := range rolePowerList { + fmt.Printf("Level------------->%v\n\n", v.Level) if v.Level >= powerInfo.System.Level { powerInfo.System.Level = v.Level } + if v.PointId != "" { pointIdAry := strings.Split(v.PointId, ",") for _, pv := range pointIdAry { @@ -195,6 +198,7 @@ func (g *GainUserPower) GetUserPower() (powerInfo SendUserPower) { } } } + fmt.Printf("powerInfo.System.Level------------->%v\n\n", powerInfo.System.Level) return } @@ -218,7 +222,8 @@ func (g *GainUserPower) GetUserPower() (powerInfo SendUserPower) { */ func (g *GainUserPower) MakeSearchSql(gormDb *gorm.DB, userCont modelshr.ManCont, isOdeb string) *gorm.DB { powerInfo := g.GetUserPower() - fmt.Printf("\n\n\n等级-----%v------->%v\n\n\n", powerInfo.AppSystem.Level, g) + // js, _ := json.Marshal(powerInfo) + fmt.Printf("\n\n\n等级-----%v--- ---->%v\n\n\n", isOdeb, powerInfo) if isOdeb == "yes" { switch powerInfo.AppSystem.Level { case 2, 3, 4, 5: @@ -240,12 +245,113 @@ func (g *GainUserPower) MakeSearchSql(gormDb *gorm.DB, userCont modelshr.ManCont } else { gormDb = gormDb.Where("f.`creater` = ?", userCont.Key) } + fmt.Printf("语句7===》%v\n", powerInfo.AppSystem) case 6: - + fmt.Printf("语句8===》%v\n", powerInfo.AppSystem) default: - gormDb = gormDb.Where("f.`creater` = ?", userCont.Key) + fmt.Printf("语句9===》%v\n", powerInfo.AppSystem) + // gormDb = gormDb.Where("f.`creater` = ?", userCont.Key) } } return gormDb } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-21 09:38:23 +@ 功能: 根据系统参数获取权限 +*/ +func GetSystemPower(powerType, systemTyep, powerId, systemId string) (powerInfo SendSystemPower) { + powerInfo.PowerType = powerType + powerInfo.SystemTyep = systemTyep + powerInfo.PowerId = powerId + powerInfo.SystemId = systemId + powerInfo.SystemIsPick = false + if powerType == "" || systemTyep == "" || powerId == "" { + return + } + if systemId != "system" && systemId == "" { + return + } + + var masterPower modelssystempermission.AuthPower + gormDb := overall.CONSTANT_DB_System_Permission.Model(&masterPower).Where("`orgPowerType` = ? AND `orgOrUserKey` = ? AND `appType` = ?", powerType, powerId, systemTyep) + switch systemTyep { + case "app": + gormDb = gormDb.Where("`appKey` = ?", systemId) + case "system": + gormDb = gormDb.Where("`appKey` = 0") + default: + } + err := gormDb.First(&masterPower).Error + if err != nil { + return + } + if masterPower.IsTrue == 1 { + powerInfo.SystemIsPick = true + } + var poserList []modelssystempermission.PowerInfo + overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.PowerInfo{}).Where("`authId` = ?", masterPower.Id).Find(&poserList) + if len(poserList) > 0 { + for _, v := range poserList { + var itemContent ItemInfo + itemContent.ItemId = v.ItemId + itemContent.IsPick = false + if v.IsPick == 1 { + itemContent.IsPick = true + } + if v.TablePower != "" && v.TablePower != "null" { + json.Unmarshal([]byte(v.TablePower), &itemContent.TablePower) + } + if v.ListPower != "" && v.ListPower != "null" { + json.Unmarshal([]byte(v.ListPower), &itemContent.ListPower) + } + if v.ButPower != "" && v.ButPower != "null" { + json.Unmarshal([]byte(v.ButPower), &itemContent.ButPower) + } + itemContent.VisibleRange = v.VisibleRange + if v.VisibleOrg != "" && v.VisibleOrg != "null" { + json.Unmarshal([]byte(v.VisibleOrg), &itemContent.VisibleOrg) + } + powerInfo.PowerList = append(powerInfo.PowerList, itemContent) + } + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-21 16:34:31 +@ 功能: 自定义应用权限 +*/ +func GetSystemAppPower(powerType, systemTyep, powerId string) (powerAry []SendSystemAppPower) { + // powerInfo.PowerType = powerType + // powerInfo.SystemTyep = systemTyep + // powerInfo.PowerId = powerId + // powerInfo.SystemId = systemId + // powerInfo.SystemIsPick = false + if powerType == "" || systemTyep == "" || powerId == "" { + return + } + var masterPower []modelssystempermission.AuthPower + err := overall.CONSTANT_DB_System_Permission.Where("`orgPowerType` = ? AND `orgOrUserKey` = ? AND `appType` = ?", powerType, powerId, systemTyep).Find(&masterPower).Error + if err != nil { + return + } + for _, v := range masterPower { + var powerInfo SendSystemAppPower + powerInfo.PowerType = powerType + powerInfo.SystemTyep = systemTyep + powerInfo.PowerId = powerId + powerInfo.SystemId = v.AppKey + powerInfo.SystemIsPick = false + if v.IsTrue == 1 { + powerInfo.SystemIsPick = true + } + powerAry = append(powerAry, powerInfo) + } + return +} diff --git a/overall/publicmethod/powerRedis.go b/overall/publicmethod/powerRedis.go new file mode 100644 index 0000000..0e56239 --- /dev/null +++ b/overall/publicmethod/powerRedis.go @@ -0,0 +1,53 @@ +package publicmethod + +import ( + "appPlatform/middleware/grocerystore" + "appPlatform/overall" + "encoding/json" + "fmt" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-26 14:04:11 +@ 功能: 设置权限Redis +*/ +func SetupPowerInfo(userKey int64, powerInfo string) { + redisFileKey := fmt.Sprintf("SystemPower:AllPower_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) + redisClient.SetRedisTime(86400) + redisClient.Set(redisFileKey, powerInfo) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-26 14:08:15 +@ 功能: 获取权限 +*/ +func GetSystemPowerInfo(userKey int64) (powerInfo SendAllPower) { + redisFileKey := fmt.Sprintf("SystemPower:AllPower_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) + isTrue, powerStr := redisClient.Get(redisFileKey) + if isTrue { + json.Unmarshal([]byte(powerStr), &powerInfo) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2025-11-27 15:21:00 +@ 功能: 获取我的菜单权限 +*/ +func GetMyMenuPower(userKey int64, menuId string) (menuPower SystemInfoPower) { + myPower := GetSystemPowerInfo(userKey) + for _, v := range myPower.SystemPower { + if v.AppId == menuId { + menuPower = v + } + } + return +} diff --git a/overall/publicmethod/tableUnit.go b/overall/publicmethod/tableUnit.go index 9e2b997..f71843c 100644 --- a/overall/publicmethod/tableUnit.go +++ b/overall/publicmethod/tableUnit.go @@ -1,6 +1,7 @@ package publicmethod //自定义表单量化类型 -var Dimension = []string{"input", "textarea", "datePicker", "timePicker", "organization", "tinymce", "colorPicker", "treeSelect", "serialNumber", "expand-user", "orgCentent", "founder", "founderTime", "editTime", "owner", "deptOrg", "pickpost", "pickrole", "radio", "checkbox"} //维度字段 -var Quantization = []string{"digitpage", "select", "cascader", "switch", "inputNumber", "slider", "rate"} //可量化字段 -var TimeUint = []string{"founderTime", "editTime", "timePicker", "datePicker"} //时间 +var Dimension = []string{"input", "textarea", "select", "datePicker", "timePicker", "organization", "tinymce", "colorPicker", "treeSelect", "serialNumber", "expand-user", "orgCentent", "founder", "founderTime", "editTime", "owner", "deptOrg", "pickpost", "pickrole", "radio", "checkbox"} //维度字段 +var Quantization = []string{"digitpage", "select", "cascader", "switch", "inputNumber", "slider", "rate"} //可量化字段 +var TimeUint = []string{"founderTime", "editTime", "timePicker", "datePicker"} //时间 +var SunXuColor = []string{"#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#00FFFF", "#FF00FF", "#808080", "#A52A2A", "#FFD700", "#FFA500", "#800080", "#FFC0CB", "#00008B", "#006400", "#8B0000", "#ADD8E6", "#90EE90", "#FFA07A", "#808000", "#4B0082", "#C0C0C0", "#008B8B", "#B22222", "#FF7F50", "#9370DB", "#E6E6FA", "#20B2AA", "#DAA520", "#0000CD", "#c289f8ff", "#2E8B57", "#4682B4", "#FF1493", "#FAF0E6", "#B8860B", "#FF6347", "#8A2BE2", "#A9A9A9", "#000000"} diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index ac8ff67..3cf843b 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -1885,13 +1885,29 @@ func OenDayStartOrEndTime(day string, class int) (startTime, endTime interface{} return } +/* +* +@ 作者: 秦东 +@ 时间: 2025-08-19 14:02:10 +@ 功能: 去除特殊字符 +*/ +func DelTeshuZifu(str string) string { + str = strings.Replace(str, "\t", "", -1) // 移除制表符 + str = strings.Replace(str, " ", "", -1) // 移除空格 + str = strings.Replace(str, "\n", "", -1) // 移除换行符 + str = strings.Replace(str, "\r", "", -1) // 移除回车符(可选) + return str +} + // 根据字符串组合时间 //补全时间 /* #dateTime 日期 */ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) { + // timeStrAry := strings.Split(DelTeshuZifu(dateTime), "-") timeStrAry := strings.Split(dateTime, "-") + fmt.Printf("补全时间--->%v-----%v\n\n\n", len(timeStrAry), timeStrAry) switch len(timeStrAry) { case 1: dateTime = fmt.Sprintf("%v-01-01 12:00:00", dateTime) @@ -1901,6 +1917,170 @@ func (d *DateTimeTotimes) BaisStrToTime(dateTime string) { } else { dateTime = fmt.Sprintf("%v-%v-01 12:00:00", timeStrAry[0], timeStrAry[1]) } + fmt.Printf("补全时间--->%v-----%v\n\n\n", len(timeStrAry), dateTime) + case 3: + monthStr := timeStrAry[1] + if len(timeStrAry[1]) < 2 { + monthStr = fmt.Sprintf("0%v", timeStrAry[1]) + } + dayAry := strings.Split(timeStrAry[2], " ") + // fmt.Printf("dayAry:%v------>%v\n", dayAry, len(dayAry)) + dayStr := dayAry[0] + if len(dayAry[0]) < 2 { + dayStr = fmt.Sprintf("0%v", dayAry[0]) + } + if len(dayAry) > 1 { + // fmt.Printf("dayAry[1]:%v------>%v\n", dayAry[1], len(dayAry[1])) + if len(dayAry[1]) > 0 { + Hours := "00" + minutes := "00" + seconds := "00" + hisAry := strings.Split(dayAry[1], ":") + switch len(hisAry) { + case 1: + if len(hisAry[0]) < 2 { + Hours = fmt.Sprintf("0%v", hisAry[0]) + } else { + Hours = hisAry[0] + } + case 2: + if len(hisAry[0]) < 2 { + Hours = fmt.Sprintf("0%v", hisAry[0]) + } else { + Hours = hisAry[0] + } + if len(hisAry[1]) < 2 { + minutes = fmt.Sprintf("0%v", hisAry[1]) + } else { + minutes = hisAry[1] + } + case 3: + if len(hisAry[0]) < 2 { + Hours = fmt.Sprintf("0%v", hisAry[0]) + } else { + Hours = hisAry[0] + } + if len(hisAry[1]) < 2 { + minutes = fmt.Sprintf("0%v", hisAry[1]) + } else { + minutes = hisAry[1] + } + if len(hisAry[2]) < 2 { + seconds = fmt.Sprintf("0%v", hisAry[2]) + } else { + seconds = hisAry[2] + } + default: + } + dayStr = fmt.Sprintf("%v %v:%v:%v", dayStr, Hours, minutes, seconds) + } + } + // dayStr := timeStrAry[2] + // if len(timeStrAry[2]) < 2 { + // dayStr = fmt.Sprintf("0%v", timeStrAry[2]) + // } + dateTime = fmt.Sprintf("%v-%v-%v", timeStrAry[0], monthStr, dayStr) + + default: + } + + // fmt.Printf("dateTime:%v---1--->%v\n", dateTime, len(dateTime)) + orgTime, orgTimeErr := DateToTimeStamp(fmt.Sprintf("%v-01-01 12:00:00", dateTime)) + if orgTimeErr { + d.AllTime = orgTime + d.AllTimeString = dateTime + d.Years = strconv.FormatInt(ComputingTime(orgTime, 1), 10) + d.Quarter = strconv.FormatInt(ComputingTime(orgTime, 2), 10) + d.Months = strconv.FormatInt(ComputingTime(orgTime, 3), 10) + d.Week = strconv.FormatInt(ComputingTime(orgTime, 4), 10) + d.Days = strconv.FormatInt(ComputingTime(orgTime, 5), 10) + d.Hours = strconv.FormatInt(ComputingTime(orgTime, 7), 10) + d.Minutes = strconv.FormatInt(ComputingTime(orgTime, 8), 10) + d.Second = strconv.FormatInt(ComputingTime(orgTime, 9), 10) + } else { + + orgTime, orgTimeErr = DateToTimeStamp(fmt.Sprintf("%v-01 12:00:00", dateTime)) + if orgTimeErr { + d.AllTime = orgTime + d.Years = strconv.FormatInt(ComputingTime(orgTime, 1), 10) + d.Quarter = strconv.FormatInt(ComputingTime(orgTime, 2), 10) + d.Months = strconv.FormatInt(ComputingTime(orgTime, 3), 10) + d.Week = strconv.FormatInt(ComputingTime(orgTime, 4), 10) + d.Days = strconv.FormatInt(ComputingTime(orgTime, 5), 10) + d.Hours = strconv.FormatInt(ComputingTime(orgTime, 7), 10) + d.Minutes = strconv.FormatInt(ComputingTime(orgTime, 8), 10) + d.Second = strconv.FormatInt(ComputingTime(orgTime, 9), 10) + + fmt.Printf("dateTime:%v---2--->%v--->%v\n", orgTime, d.AllTime, d.Quarter) + } else { + orgTime, orgTimeErr = DateToTimeStamp(fmt.Sprintf("%v 12:00:00", dateTime)) + if orgTimeErr { + d.AllTime = orgTime + d.Years = strconv.FormatInt(ComputingTime(orgTime, 1), 10) + d.Quarter = strconv.FormatInt(ComputingTime(orgTime, 2), 10) + d.Months = strconv.FormatInt(ComputingTime(orgTime, 3), 10) + d.Week = strconv.FormatInt(ComputingTime(orgTime, 4), 10) + d.Days = strconv.FormatInt(ComputingTime(orgTime, 5), 10) + d.Hours = strconv.FormatInt(ComputingTime(orgTime, 7), 10) + d.Minutes = strconv.FormatInt(ComputingTime(orgTime, 8), 10) + d.Second = strconv.FormatInt(ComputingTime(orgTime, 9), 10) + } else { + orgTime, orgTimeErr = DateToTimeStamp(fmt.Sprintf("%v:00:00", dateTime)) + if orgTimeErr { + d.AllTime = orgTime + d.Years = strconv.FormatInt(ComputingTime(orgTime, 1), 10) + d.Quarter = strconv.FormatInt(ComputingTime(orgTime, 2), 10) + d.Months = strconv.FormatInt(ComputingTime(orgTime, 3), 10) + d.Week = strconv.FormatInt(ComputingTime(orgTime, 4), 10) + d.Days = strconv.FormatInt(ComputingTime(orgTime, 5), 10) + d.Hours = strconv.FormatInt(ComputingTime(orgTime, 7), 10) + d.Minutes = strconv.FormatInt(ComputingTime(orgTime, 8), 10) + d.Second = strconv.FormatInt(ComputingTime(orgTime, 9), 10) + } else { + orgTime, orgTimeErr = DateToTimeStamp(fmt.Sprintf("%v:00", dateTime)) + if orgTimeErr { + d.AllTime = orgTime + d.Years = strconv.FormatInt(ComputingTime(orgTime, 1), 10) + d.Quarter = strconv.FormatInt(ComputingTime(orgTime, 2), 10) + d.Months = strconv.FormatInt(ComputingTime(orgTime, 3), 10) + d.Week = strconv.FormatInt(ComputingTime(orgTime, 4), 10) + d.Days = strconv.FormatInt(ComputingTime(orgTime, 5), 10) + d.Hours = strconv.FormatInt(ComputingTime(orgTime, 7), 10) + d.Minutes = strconv.FormatInt(ComputingTime(orgTime, 8), 10) + d.Second = strconv.FormatInt(ComputingTime(orgTime, 9), 10) + } else { + orgTime, orgTimeErr = DateToTimeStamp(dateTime) + if orgTimeErr { + d.AllTime = orgTime + d.Years = strconv.FormatInt(ComputingTime(orgTime, 1), 10) + d.Quarter = strconv.FormatInt(ComputingTime(orgTime, 2), 10) + d.Months = strconv.FormatInt(ComputingTime(orgTime, 3), 10) + d.Week = strconv.FormatInt(ComputingTime(orgTime, 4), 10) + d.Days = strconv.FormatInt(ComputingTime(orgTime, 5), 10) + d.Hours = strconv.FormatInt(ComputingTime(orgTime, 7), 10) + d.Minutes = strconv.FormatInt(ComputingTime(orgTime, 8), 10) + d.Second = strconv.FormatInt(ComputingTime(orgTime, 9), 10) + } + } + } + } + } + d.AllTimeString = UnixTimeToDay(d.AllTime, 11) + } +} +func (d *DateTimeTotimes) BaisStrToTimeExcel(dateTime string) { + timeStrAry := strings.Split(DelTeshuZifu(dateTime), "-") + fmt.Printf("补全时间--->%v-----%v\n\n\n", len(timeStrAry), timeStrAry) + switch len(timeStrAry) { + case 1: + dateTime = fmt.Sprintf("%v-01-01 12:00:00", dateTime) + case 2: + if len(timeStrAry[1]) < 2 { + dateTime = fmt.Sprintf("%v-0%v-01 12:00:00", timeStrAry[0], timeStrAry[1]) + } else { + dateTime = fmt.Sprintf("%v-%v-01 12:00:00", timeStrAry[0], timeStrAry[1]) + } + fmt.Printf("补全时间--->%v-----%v\n\n\n", len(timeStrAry), dateTime) case 3: monthStr := timeStrAry[1] if len(timeStrAry[1]) < 2 { @@ -2584,9 +2764,47 @@ func (g *GetOrgAllParent) GetOrgSun(superior int64) { } } +func (g *GetOrgAllParent) GetOrgSunNei(superior int64) { + var id []int64 + if superior == 0 { + return + } + err := overall.CONSTANT_DB_HrInside.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1 AND `superior` = ?", superior).Find(&id).Error + if err != nil || len(id) < 1 { + return + } + for _, v := range id { + if !IsInTrue[int64](v, g.Id) { + g.Id = append(g.Id, v) + } + g.GetOrgSunNei(v) + } +} + /* * @ 作者: 秦东 +@ 时间: 2025-11-25 13:09:26 +@ 功能: 获取父级ID +*/ +func (g *GetOrgAllParent) GetOrgFirst(myId int64) { + var id int64 + // fmt.Printf("父级--%v------->%v\n\n\n", myId, id) + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`superior`").Where("`id` = ?", myId).First(&id) + + if id == 0 { + return + } + if !IsInTrue[int64](id, g.Id) { + g.Id = append(g.Id, id) + } + g.GetOrgFirst(id) +} + +/* +overall.CONSTANT_DB_HrInside.Model(&orgCurre).Select("`name`").Where("`id` = ?", userCont.Company).First(orgCurre) +* +@ 作者: 秦东 @ 时间: 2024-11-27 09:44:25 @ 功能: 获取自定义App子菜单 */ @@ -3065,17 +3283,83 @@ func DataChuli(val float64, types int) interface{} { case 2: guodu = int64(val) case 3: - guodu = fmt.Sprintf("%.1f", val) + if val == 0 { + guodu = 0 + } else { + guodu = fmt.Sprintf("%.1f", val) + } + case 4: - guodu = fmt.Sprintf("%.2f", val) + if val == 0 { + guodu = 0 + } else { + guodu = fmt.Sprintf("%.2f", val) + } + case 5: - guodu = fmt.Sprintf("%v%", val) + if val == 0 { + guodu = 0 + } else { + guodu = fmt.Sprintf("%v%", val) + } + case 6: - guodu = fmt.Sprintf("%.1f%", val) + if val == 0 { + guodu = 0 + } else { + guodu = fmt.Sprintf("%.1f%", val) + } + case 7: - guodu = fmt.Sprintf("%.2f%", val) + if val == 0 { + guodu = 0 + } else { + guodu = fmt.Sprintf("%.2f%", val) + } + default: - guodu = val + valTwo := val * 100 + roundTeo := math.RoundToEven(valTwo) + guodu = roundTeo / 100 } return guodu } + +// 判断文件上传的TYPE +func JudgeUpFileType(extTage string) int { + images := []string{".jpg", ".jpeg", ".png", ".gif", ".bmp", ".avif", ".webp", ".tif", ".pcx", ".tga", ".exif", ".fpx", ".svg", ".psd", ".cdr", ".pcd", ".dxf", ".ufo", ".hdri", ".eps", ".flic", ".ai", ".ico", ".emf", ".raw", ".WMF", ".avif", ".apng", ".Webp", ".BMP", ".PCX", ".TIF", ".GIF", ".JPEG", ".JPG", ".TGA", ".EXIF", ".FPX", ".SVG", ".PSD", ".CDR", ".PCD", ".DXF", ".UFO", ".EPS", ".AI", ".PNG", ".HDRI", ".RAW", ".WMF", ".FLIC", ".EMF", ".APNG", ".ICO"} + videoExt := []string{".mp4", ".avi", ".3gp", ".flv", ".rm", ".rmvb", ".wmv", ".mpeg", ".mpeg1", ".mpeg2", ".divx", ".xvid", ".dv", ".mkv", ".asf", ".asx", ".mov", ".m4v", ".dat", ".mkv", ".vob", ".ogg", ".mod", ".MP4", ".3GP", ".AVI", ".RM", ".RMVB", ".WMV", ".MPEG", ".MPEG1", ".MPEG2", ".DivX", ".XVID", ".DV", ".MKV", ".MOV", ".OGG", ".MOD", ".M4V", ".DAT", ".VOB"} + officeExt := []string{".doc", ".docx", ".xml", ".ppt", ".pptx", ".pot", ".PPS", ".dot", ".mht", ".xlt"} + zipExt := []string{".rar", ".zip", ".7z", ".ar", ".bz", ".car", ".dar", ".cpgz", ".f", ".ha"} + excel := []string{".xls", ".xlsx"} + csv := []string{".csv"} + if IsInTrue[string](extTage, images) { + return 1 + } + if IsInTrue[string](extTage, videoExt) { + return 2 + } + if IsInTrue[string](extTage, officeExt) { + return 3 + } + if IsInTrue[string](extTage, zipExt) { + return 4 + } + if IsInTrue[string](extTage, excel) { + return 5 + } + if IsInTrue[string](extTage, csv) { + return 6 + } + return 7 +} + +// 随机生成16进制颜色 +func GenerateRandomHexColor() string { + // // 生成三个0到255之间的随机数 + r, _ := rand.Int(rand.Reader, big.NewInt(256)) + g, _ := rand.Int(rand.Reader, big.NewInt(256)) + b, _ := rand.Int(rand.Reader, big.NewInt(256)) + // 将每个数值格式化为两位十六进制数,并用#连接起来 + return fmt.Sprintf("#%02X%02X%02X", r, g, b) +} diff --git a/overall/publicmethod/type.go b/overall/publicmethod/type.go index 0937aba..aa7938d 100644 --- a/overall/publicmethod/type.go +++ b/overall/publicmethod/type.go @@ -373,3 +373,63 @@ type SystemPower struct { Operation []string //按钮级&列表 OrgList []int64 //可见行政组织&数据可见行政组织 } + +// 输出系统授权 +type SendSystemPower struct { + PowerType string `json:"powerType"` + SystemTyep string `json:"systemTyep"` + PowerId string `json:"powerId"` + SystemId string `json:"systemId"` + SystemIsPick bool `json:"systemIsPick"` + PowerList []ItemInfo `json:"powerList"` +} + +// 权限列表 +type ItemInfo struct { + ItemId int64 `json:"itemId"` + IsPick bool `json:"isPick"` + TablePower []string `json:"tablePower"` + ListPower []string `json:"listPower"` + ButPower []int `json:"ButPower"` + VisibleRange int `json:"visibleRange"` + VisibleOrg []int `json:"visibleOrg"` +} +type SendSystemAppPower struct { + PowerType string `json:"powerType"` + SystemTyep string `json:"systemTyep"` + PowerId string `json:"powerId"` + SystemId int64 `json:"systemId"` + SystemIsPick bool `json:"systemIsPick"` +} + +type SendAllPower struct { + SystemPower []SystemInfoPower `json:"systemPower"` + MenuIdAry []int64 `json:"menuIdAry"` + AppSystemPower []AppMyPower `json:"AppSystemPower"` + AppKeyAry []string `json:"appKeyAry"` +} +type SystemInfoPower struct { + AppId string `json:"AppId"` + PublicName + IsPick bool `json:"isPick` + OutPowerInfo +} +type OutPowerInfo struct { + ButIdAry []int64 `json:"butIdAry"` + Scope int `json:"scope"` + ScopeManAry []int `json:"scopeManAry"` +} +type AppMyPower struct { + AppId string `json:"AppId"` + IsPick bool `json:"isPick` + FormTrue []string `json:"formTrue"` + FormPower []AppMyPowerTable `json:"formPower"` +} +type AppMyPowerTable struct { + AppId string `json:"AppId"` + IsPick bool `json:"isPick` + ListPower []string `json:"listPower"` + TablePower []string `json:"tablePower"` + Scope int `json:"scope"` + ScopeManAry []int `json:"scopeManAry"` +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3c493ab --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "unplugin-vue-components": "^29.1.0", + "unplugin-auto-import": "^20.2.0" + } +}