From cb8a9775d00113c98e0b8795ee692e61a368d58f Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Tue, 6 May 2025 10:53:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/version1/customerApp/appControll.go | 2 +- api/version1/customerApp/runAppControll.go | 1 + api/version1/customerform/calendarData.go | 110 ++++++++++++++++++ api/version1/customerform/form.go | 50 +++++++- api/version1/customerform/formTable.go | 24 +++- api/version1/customerform/type.go | 1 + api/version1/dataCenter/runDataBase.go | 6 + api/version1/matrixApi/api.go | 3 +- api/version1/menus/menus.go | 7 +- .../taskplatform/taskflow/appTaskFlow.go | 8 +- .../taskplatform/taskflow/editformflow.go | 8 +- .../taskplatform/taskflow/flowType.go | 14 ++- .../taskplatform/taskflow/flowengine.go | 1 + .../taskplatform/taskmanagement/appControl.go | 6 +- .../taskplatform/taskmanagement/appform.go | 12 +- .../taskplatform/taskmanagement/flowNode.go | 13 ++- .../taskmanagement/formcontrol.go | 24 ++-- .../taskplatform/taskmanagement/ruanTask.go | 24 +++- api/version1/workWechat/wechat.go | 99 ++++++++++++++++ go.mod | 3 +- models/customerForm/taskrecord.go | 1 + models/modelAppPlatform/customer_form.go | 2 + 22 files changed, 371 insertions(+), 48 deletions(-) diff --git a/api/version1/customerApp/appControll.go b/api/version1/customerApp/appControll.go index aa4f7cb..f23d3a7 100644 --- a/api/version1/customerApp/appControll.go +++ b/api/version1/customerApp/appControll.go @@ -2369,7 +2369,7 @@ func (a *ApiMethod) MoveAppMenus(c *gin.Context) { //修改主应用表 var mastMenuEdit modelAppPlatform.CustomerForm editMenuInfo := publicmethod.MapOut[string]() - editMenuInfo["groupid"] = newFormInfo.Groupid + editMenuInfo["groupid"] = newFormInfo.SignCode editMenuInfo["edit_time"] = time.Now().Unix() err = mastMenuEdit.EiteCont(map[string]interface{}{"`signCode`": requestData.OldMenuId}, editMenuInfo) if err != nil { diff --git a/api/version1/customerApp/runAppControll.go b/api/version1/customerApp/runAppControll.go index e33aab1..60e3da9 100644 --- a/api/version1/customerApp/runAppControll.go +++ b/api/version1/customerApp/runAppControll.go @@ -170,6 +170,7 @@ func (t *TreeJwtPower) JwtPeopleViewsIsTrue(jwpUser, userKEy string) { # */ func (t *TreeJwtPower) JwtOrgViewsIsTrue(jwpOrg string, userOrg int64) { + defer syncSeting.Done() if jwpOrg == "" { t.Org = true } else { diff --git a/api/version1/customerform/calendarData.go b/api/version1/customerform/calendarData.go index cabb6bb..aa57950 100644 --- a/api/version1/customerform/calendarData.go +++ b/api/version1/customerform/calendarData.go @@ -3,10 +3,13 @@ package customerform import ( "appPlatform/models/modelAppPlatform" "appPlatform/models/modelshr" + "appPlatform/models/modelssystempermission" "appPlatform/overall" "appPlatform/overall/publicmethod" "encoding/json" "fmt" + "strconv" + "strings" "github.com/gin-gonic/gin" ) @@ -176,3 +179,110 @@ func (c *CalendarList) HaveEveryDayData(day TimeAryInfo, tableName string, userC c.List = append(c.List, inDate) } } + +/* +* +@ 作者: 秦东 +@ 时间: 2025-04-15 14:47:41 +@ 功能: 根据角色配置 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func GainRolePower(userCont modelshr.ManCont) (userKey []string, isTrue bool) { + isTrue = false + if userCont.Role == "" { + return + } + roleAry := strings.Split(userCont.Role, ",") + if len(roleAry) < 1 { + return + } + + for _, v := range roleAry { + var rolePwoerInfo modelssystempermission.RoleEmpower + rolePwoerInfo.GetCont(map[string]interface{}{"`role_id`": v, "`system`": "appsystem"}, "`level`", "`organization`") + switch rolePwoerInfo.Level { + case 1: + var postUsrt []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("`emp_type` BETWEEN 1 AND 10").Where("`position` = ?", userCont.Position).Find(&postUsrt) + if len(postUsrt) > 0 { + for _, pv := range postUsrt { + keyStr := strconv.FormatInt(pv, 10) + if !publicmethod.IsInTrue(keyStr, userKey) { + userKey = append(userKey, keyStr) + } + } + + } + case 2: + var postUsrt []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("`emp_type` BETWEEN 1 AND 10").Where("`maindeparment` = ?", userCont.MainDeparment).Find(&postUsrt) + if len(postUsrt) > 0 { + for _, pv := range postUsrt { + keyStr := strconv.FormatInt(pv, 10) + if !publicmethod.IsInTrue(keyStr, userKey) { + userKey = append(userKey, keyStr) + } + } + + } + case 3: + var postUsrt []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("`emp_type` BETWEEN 1 AND 10").Where("`company` = ?", userCont.Company).Find(&postUsrt) + if len(postUsrt) > 0 { + for _, pv := range postUsrt { + keyStr := strconv.FormatInt(pv, 10) + if !publicmethod.IsInTrue(keyStr, userKey) { + userKey = append(userKey, keyStr) + } + } + + } + case 4: + if rolePwoerInfo.Organization != "" { + orgAry := strings.Split(rolePwoerInfo.Organization, ",") + + if len(orgAry) > 0 { + var orgId []int64 + for _, ov := range orgAry { + oId, _ := strconv.ParseInt(ov, 10, 64) + var sunOrg publicmethod.GetOrgAllParent + sunOrg.GetOrgSun(oId) + sunOrg.Id = append(sunOrg.Id, oId) + orgId = append(orgId, sunOrg.Id...) + } + if len(orgId) > 0 { + orgMap := publicmethod.RemoveDuplicate[int64](orgId) + var postUsrt []int64 + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`").Where("`emp_type` BETWEEN 1 AND 10").Where("`maindeparment` IN ?", orgMap).Find(&postUsrt) + if len(postUsrt) > 0 { + for _, pv := range postUsrt { + keyStr := strconv.FormatInt(pv, 10) + if !publicmethod.IsInTrue(keyStr, userKey) { + userKey = append(userKey, keyStr) + } + } + + } + } + } + + } + case 5: + isTrue = true + default: + isTrue = false + userKey = []string{} + } + } + return +} diff --git a/api/version1/customerform/form.go b/api/version1/customerform/form.go index 6b53c14..eaf4f8a 100644 --- a/api/version1/customerform/form.go +++ b/api/version1/customerform/form.go @@ -109,11 +109,57 @@ func (a *ApiMethod) CustomerFormList(c *gin.Context) { } else { formList[i].IsOpen = false } + formList[i].IsEdit = JudgeEditFormOrApp(userCont, v.AppManager, v.AppRoleManager, v.AppOrgMan) // sendList = append(sendList, sendCont) } publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c) } +/** +@ 作者: 秦东 +@ 时间: 2025-04-17 09:43:17 +@ 功能: 判断当前用户是否可编辑此表单或App +#userCont 当前操作员信息 +#appManager 应用管理员 +#appRoleManager 应用管理角色 +#appOrgMan 应用管理行政组织 +*/ + +func JudgeEditFormOrApp(userCont modelshr.ManCont, appManager, appRoleManager, appOrgMan string) bool { + appManagerAry := strings.Split(appManager, ",") + appRoleManagerAry := strings.Split(appRoleManager, ",") + appOrgManAry := strings.Split(appOrgMan, ",") + if userCont.Role != "" { + roleAry := strings.Split(userCont.Role, ",") + if len(roleAry) > 0 { + if publicmethod.IsInTrue[string]("1", roleAry) { + return true + } + if len(appRoleManagerAry) > 0 { + for _, v := range roleAry { + if publicmethod.IsInTrue[string](v, appRoleManagerAry) { + return true + } + } + } + + } + } + if len(appManagerAry) > 0 { + userKeyStr := strconv.FormatInt(userCont.Key, 10) + if publicmethod.IsInTrue[string](userKeyStr, appManagerAry) { + return true + } + } + if len(appOrgManAry) > 0 { + orgStr := strconv.FormatInt(userCont.AdminOrg, 10) + if publicmethod.IsInTrue[string](orgStr, appOrgManAry) { + return true + } + } + return false +} + /* * @ 作者: 秦东 @@ -1488,11 +1534,11 @@ func CreateDataSourceForm(sqlDb *gorm.DB, formName, notes, engine string, isMast if !isTrue { //当数据表不存在时进行创建 if isMasters { //创建主表 - sqlCreateTable := fmt.Sprintf("CREATE TABLE `%v` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`masters_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识',`creater` bigint(20) unsigned DEFAULT '0' COMMENT '创建人',`creater_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`edit_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间',`flow_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '流程识别标识',`states` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用,2:禁用;3:删除)',`flowIsOpen` int(1) unsigned NOT NULL DEFAULT '2' COMMENT '是否开启工作流',PRIMARY KEY (`id`) USING BTREE,UNIQUE KEY `id` (`id`) USING HASH,UNIQUE KEY `masters_key` (`masters_key`) USING HASH) ENGINE=%v DEFAULT CHARSET=utf8mb4 COMMENT='%v'", formName, engine, notes) + sqlCreateTable := fmt.Sprintf("CREATE TABLE `%v` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`masters_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识',`creater` bigint(20) unsigned DEFAULT '0' COMMENT '创建人',`createrOrg` bigint(20) unsigned DEFAULT '0' COMMENT '创建人行政组织',`creater_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`edit_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间',`flow_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '流程识别标识',`states` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用,2:禁用;3:删除)',`flowIsOpen` int(1) unsigned NOT NULL DEFAULT '2' COMMENT '是否开启工作流',PRIMARY KEY (`id`) USING BTREE,UNIQUE KEY `id` (`id`) USING HASH,UNIQUE KEY `masters_key` (`masters_key`) USING HASH) ENGINE=%v DEFAULT CHARSET=utf8mb4 COMMENT='%v'", formName, engine, notes) err = sqlDb.Exec(sqlCreateTable).Error } else { //创建子表 - sqlCreateTable := fmt.Sprintf("CREATE TABLE `%v` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`masters_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识',`creater` bigint(20) unsigned DEFAULT '0' COMMENT '创建人',`creater_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`edit_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间',`states` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用,2:禁用;3:删除)',PRIMARY KEY (`id`) USING BTREE,UNIQUE KEY `id` (`id`) USING HASH,KEY `masters_key` (`masters_key`) USING HASH) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='%v'", formName, notes) + sqlCreateTable := fmt.Sprintf("CREATE TABLE `%v` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`masters_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识',`creater` bigint(20) unsigned DEFAULT '0' COMMENT '创建人',`createrOrg` bigint(20) unsigned DEFAULT '0' COMMENT '创建人行政组织',`creater_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',`edit_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间',`states` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用,2:禁用;3:删除)',PRIMARY KEY (`id`) USING BTREE,UNIQUE KEY `id` (`id`) USING HASH,KEY `masters_key` (`masters_key`) USING HASH) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='%v'", formName, notes) err = sqlDb.Exec(sqlCreateTable).Error } } diff --git a/api/version1/customerform/formTable.go b/api/version1/customerform/formTable.go index 6e21d3d..3879256 100644 --- a/api/version1/customerform/formTable.go +++ b/api/version1/customerform/formTable.go @@ -347,7 +347,7 @@ func (f *FormTableSql) TableSubUnitAnalysis(tablename string, subUnitAry []Maste var sqlAllAry []string fmt.Printf("tablename--->%v===>%v\n", tablename, isMaster) - oldTable := []string{"id", "masters_key", "creater", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen"} + oldTable := []string{"id", "masters_key", "creater", "createrOrg", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen"} var alreadyExists []string for _, v := range subUnitAry { @@ -1373,6 +1373,11 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { context, _ := c.Get(overall.MyContJwt) var userCont modelshr.ManCont userCont.GetLoginCont(context) //当前操作人 + + userKeyMap, isTrue := GainRolePower(userCont) + + // fmt.Printf() + var formInfo modelAppPlatform.CustomerFormView err = formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`") if err != nil { @@ -1404,7 +1409,13 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { } gormDb := sqlDborm.Table(formJsonCont.Form.DataSourceConfig.TableKey) gormDb = gormDb.Where("`states` BETWEEN ? AND ?", 1, 2) - + if !isTrue { + if len(userKeyMap) > 0 { + gormDb = gormDb.Where("`creater` IN ? ", userKeyMap) + } else { + gormDb = gormDb.Where("`creater` = ? ", userCont.Key) + } + } gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) var total int64 totalErr := gormDb.Count(&total).Error @@ -1516,7 +1527,14 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) { // gormDb = gormDb.Where(why) // } 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) + if !isTrue { + if len(userKeyMap) > 0 { + gormDb = gormDb.Where("f.`creater` IN ? ", userKeyMap) + } else { + gormDb = gormDb.Where("f.`creater` = ? ", userCont.Key) + } + } gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2) gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb) diff --git a/api/version1/customerform/type.go b/api/version1/customerform/type.go index f3c205c..4024e04 100644 --- a/api/version1/customerform/type.go +++ b/api/version1/customerform/type.go @@ -252,6 +252,7 @@ type SendCustomerForm struct { SignCodeStr string `json:"signCodeStr" gorm:"-"` IsOften bool `json:"isoften" gorm:"-"` IsOpen bool `json:"isOpen" gorm:"-"` + IsEdit bool `json:"isEdit" gorm:"-"` } // 输出自定义表格基础信息 diff --git a/api/version1/dataCenter/runDataBase.go b/api/version1/dataCenter/runDataBase.go index 6d09185..3dd69b5 100644 --- a/api/version1/dataCenter/runDataBase.go +++ b/api/version1/dataCenter/runDataBase.go @@ -54,5 +54,11 @@ func (a *ApiMethod) GainDataTable(c *gin.Context) { } tableInfo, err := requestData.ObtainDataBaseAllTableMysql() fmt.Printf("tableInfo:%v\n", tableInfo) + // for _, v := range tableInfo { + // if v.TableKey != "taskrecord" { + // sql := fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '是否开启工作流';", v.TableKey, "createrOrg") + // overall.CONSTANT_DB_CustomerForm.Exec(sql) + // } + // } publicmethod.Result(0, tableInfo, c) } diff --git a/api/version1/matrixApi/api.go b/api/version1/matrixApi/api.go index 1e37339..6b3869f 100644 --- a/api/version1/matrixApi/api.go +++ b/api/version1/matrixApi/api.go @@ -507,9 +507,10 @@ func (a *ApiMethod) GainMatrixData(c *gin.Context) { sendCont.PinYin = w.PinYin var handCont []modelAppPlatform.MatrixHandler overall.CONSTANT_DB_AppPlatform.Where("`mc_id` = ? AND `mh_id` = ? AND `number` = ?", requestData.Id, w.Id, v).Find(&handCont) + sendCont.Number = strconv.FormatInt(v, 10) if len(handCont) > 0 { for _, j := range handCont { - sendCont.Number = strconv.FormatInt(j.Number, 10) + var userCont UserListCont userCont.Id = strconv.FormatInt(j.HandId, 10) if j.Types == 1 { diff --git a/api/version1/menus/menus.go b/api/version1/menus/menus.go index dccc94a..c32dde0 100644 --- a/api/version1/menus/menus.go +++ b/api/version1/menus/menus.go @@ -488,17 +488,22 @@ func (a *ApiMethod) AccordRoleGiveOrg(c *gin.Context) { sendData := publicmethod.MapOut[string]() if len(powerOrgId) > 0 { var orgList []modelshr.AdministrativeOrganization - overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("`state` = 1 AND `id` IN ?", powerOrgId).Find(&orgList) + switch maxLevel { case 2: + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("`state` = 1 AND `id` IN ?", powerOrgId).Find(&orgList) orgTree = GovOrgTree(userMyCont.MainDeparment, orgList) case 3: + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("`state` = 1 AND `id` IN ?", powerOrgId).Find(&orgList) orgTree = GovOrgTree(userMyCont.Company, orgList) case 4: + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("`state` = 1 AND `id` IN ?", powerOrgId).Find(&orgList) orgTree = GovOrgTree(313, orgList) case 5: + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("`state` = 1 ").Find(&orgList) orgTree = GovOrgTree(313, orgList) default: + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Where("`state` = 1 AND `id` IN ?", powerOrgId).Find(&orgList) orgTree = GovOrgTree(userMyCont.AdminOrg, orgList) } sendData["companyName"] = gainOrgName(userMyCont.Company, orgList) diff --git a/api/version1/taskplatform/taskflow/appTaskFlow.go b/api/version1/taskplatform/taskflow/appTaskFlow.go index 254d288..6a046e6 100644 --- a/api/version1/taskplatform/taskflow/appTaskFlow.go +++ b/api/version1/taskplatform/taskflow/appTaskFlow.go @@ -536,7 +536,7 @@ func (a *ApiMethod) SaveDraftAgain(c *gin.Context) { masterUnitList[v.Name] = v } sendInfo := publicmethod.MapOut[string]() - masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, cureeTime, masterField, masterUnitList, 2) + masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 2) if len(masrWriteMap) > 0 { oldMasterData, _ := taskmanagement.MasterTableHandle(formCont.TableKey, userCont.Key, cureeTime, masrWriteMap) sendInfo["oldMasterData"] = oldMasterData @@ -548,7 +548,7 @@ func (a *ApiMethod) SaveDraftAgain(c *gin.Context) { for _, v := range formUnitCont.SunFormInfo { sunTypeAry[v.TableName] = v.UbitInfo } - sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) sendInfo["sunTableData"] = sunTableData if len(sunTableData) > 0 { sonList, _ := taskmanagement.SonTableHandle(taskId, userCont.Key, cureeTime, sunFieldAry) @@ -659,7 +659,7 @@ func (a *ApiMethod) AfreshAppSubmit(c *gin.Context) { masterUnitList[v.Name] = v } sendInfo := publicmethod.MapOut[string]() - masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, cureeTime, masterField, masterUnitList, 2) + masrWriteMap := taskmanagement.MakeFormMapData(formCont.Flowkey, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 2) if len(masrWriteMap) > 0 { oldMasterData, _ := taskmanagement.MasterTableHandle(formCont.TableKey, userCont.Key, cureeTime, masrWriteMap) sendInfo["oldMasterData"] = oldMasterData @@ -671,7 +671,7 @@ func (a *ApiMethod) AfreshAppSubmit(c *gin.Context) { for _, v := range formUnitCont.SunFormInfo { sunTypeAry[v.TableName] = v.UbitInfo } - sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + sunTableData := EditSunDatabase(formCont.Flowkey, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) sendInfo["sunTableData"] = sunTableData if len(sunTableData) > 0 { sonList, _ := taskmanagement.SonTableHandle(taskId, userCont.Key, cureeTime, sunFieldAry) diff --git a/api/version1/taskplatform/taskflow/editformflow.go b/api/version1/taskplatform/taskflow/editformflow.go index a8a3ab9..bb5ab91 100644 --- a/api/version1/taskplatform/taskflow/editformflow.go +++ b/api/version1/taskplatform/taskflow/editformflow.go @@ -473,7 +473,7 @@ func (a *ApiMethod) EditFormLogData(c *gin.Context) { saveData := publicmethod.MapOut[string]() //组装数据表新增数据 - masrWriteMap := taskmanagement.MakeFormMapData(flowInfo.FlowKey, userCont.Key, cureeTime, masterField, masterUnitList, 2) + masrWriteMap := taskmanagement.MakeFormMapData(flowInfo.FlowKey, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 2) masterTableJson, _ := json.Marshal(masrWriteMap) editFormDataLogInfo.DataCont = string(masterTableJson) //判断是否有子表 @@ -483,7 +483,7 @@ func (a *ApiMethod) EditFormLogData(c *gin.Context) { for _, v := range formUnitCont.SunFormInfo { sunTypeAry[v.TableName] = v.UbitInfo } - sunTableData := EditSunDatabase(flowInfo.FlowKey, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + sunTableData := EditSunDatabase(flowInfo.FlowKey, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) fmt.Printf("判断是否有子表得数据-->%v\n", sunTableData) saveData["sunTypeAry"] = sunTableData sunTableJson, _ := json.Marshal(sunTableData) @@ -558,7 +558,7 @@ func (a *ApiMethod) EditFormLogData(c *gin.Context) { # */ -func EditSunDatabase(uuid, creater, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (sunTableData map[string]interface{}) { +func EditSunDatabase(uuid, creater, createrOrg, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (sunTableData map[string]interface{}) { if len(masterDataCont) > 0 { if len(sunDataList) > 0 { sunMasterMap := publicmethod.MapOut[string]() @@ -577,7 +577,7 @@ func EditSunDatabase(uuid, creater, createrTime int64, masterTableName string, m for _, sv := range s { //拆分子表 if sdf, isOk := sv.(map[string]interface{}); isOk { if sunTableType, sunIsOk := sunTable[k]; sunIsOk { - masterWriteVal := taskmanagement.MakeFormMapData(uuid, creater, createrTime, sdf, sunTableType, 2) //转换数据表值 + masterWriteVal := taskmanagement.MakeFormMapData(uuid, creater, createrOrg, createrTime, sdf, sunTableType, 2) //转换数据表值 // fmt.Printf("处理指标字段值-1-->%v--->%v\n", sunTableType, masterWriteVal) if len(masterWriteVal) > 0 { sunCont = append(sunCont, masterWriteVal) diff --git a/api/version1/taskplatform/taskflow/flowType.go b/api/version1/taskplatform/taskflow/flowType.go index 1a21140..ae5fbbf 100644 --- a/api/version1/taskplatform/taskflow/flowType.go +++ b/api/version1/taskplatform/taskflow/flowType.go @@ -68,11 +68,17 @@ type NodePublicInfo struct { //矩阵信息 type MatrixInfo struct { - MatrixId int64 `json:"matrixid"` - FactorId int64 `json:"factorid"` + 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 []MatrListInfo `json:"list"` +} + +type MatrListInfo struct { OutcomeId int64 `json:"outcomeid"` - MatrixName string `json:"matrixName"` - FactorName string `json:"factorName"` OutcomeName string `json:"outcomeName"` } diff --git a/api/version1/taskplatform/taskflow/flowengine.go b/api/version1/taskplatform/taskflow/flowengine.go index 91d9d0d..278315f 100644 --- a/api/version1/taskplatform/taskflow/flowengine.go +++ b/api/version1/taskplatform/taskflow/flowengine.go @@ -210,6 +210,7 @@ func (a *ApiMethod) EditFlowCont(c *gin.Context) { publicmethod.Result(100, err, c) return } + fmt.Printf("=======================>%v\n", requestData) why := publicmethod.MapOut[string]() why["`id`"] = requestData.Id var flowVersionInfo modelAppPlatform.FlowVersion diff --git a/api/version1/taskplatform/taskmanagement/appControl.go b/api/version1/taskplatform/taskmanagement/appControl.go index 6ddd005..78c05c5 100644 --- a/api/version1/taskplatform/taskmanagement/appControl.go +++ b/api/version1/taskplatform/taskmanagement/appControl.go @@ -102,7 +102,7 @@ func (a *ApiMethod) CreateAppTask(c *gin.Context) { masterUnitList[v.Name] = v } - masrWriteMap := MakeFormMapData(uuid, userCont.Key, cureeTime, masterField, masterUnitList, 1) + masrWriteMap := MakeFormMapData(uuid, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 1) masrWriteMap["flowIsOpen"] = formCont.FlowIsOpen //任务列表 var taskCont customerForm.TaskRecord @@ -149,7 +149,7 @@ func (a *ApiMethod) CreateAppTask(c *gin.Context) { sunTypeAry[v.TableName] = v.UbitInfo } - err = WriteSunDatabaseSoucer(sqlDborm, uuid, userCont.Key, cureeTime, formJsonCont.Form.DataSourceConfig.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + err = WriteSunDatabaseSoucer(sqlDborm, uuid, userCont.Key, userCont.AdminOrg, cureeTime, formJsonCont.Form.DataSourceConfig.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) } else { // //无子表 @@ -165,7 +165,7 @@ func (a *ApiMethod) CreateAppTask(c *gin.Context) { sunTypeAry[v.TableName] = v.UbitInfo } - err = WriteSunDatabase(uuid, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + err = WriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) } else { // //无子表 diff --git a/api/version1/taskplatform/taskmanagement/appform.go b/api/version1/taskplatform/taskmanagement/appform.go index 35effe5..2003d72 100644 --- a/api/version1/taskplatform/taskmanagement/appform.go +++ b/api/version1/taskplatform/taskmanagement/appform.go @@ -513,7 +513,7 @@ func (a *ApiMethod) CustomerFormEditData(c *gin.Context) { masterUnitList[v.Name] = v } uuid, _ := strconv.ParseInt(mapData["formId"].(string), 10, 64) - masrWriteMap := MakeFormMapData(uuid, userCont.Key, cureeTime, masterField, masterUnitList, 2) + masrWriteMap := MakeFormMapData(uuid, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 2) //判断是否 if len(sunFieldAry) > 0 { @@ -523,7 +523,7 @@ func (a *ApiMethod) CustomerFormEditData(c *gin.Context) { for _, v := range formUnitCont.SunFormInfo { sunTypeAry[v.TableName] = v.UbitInfo } - err = EditWriteSunDatabase(uuid, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + err = EditWriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) } else { err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Where("`masters_key` = ?", uuid).Updates(masrWriteMap).Error @@ -1017,7 +1017,7 @@ func CustomerFormCallBackVal(val map[string]interface{}, valClass map[string]cus # */ -func EditWriteSunDatabase(uuid, creater, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (err error) { +func EditWriteSunDatabase(uuid, creater, createrOrgId, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (err error) { if len(masterDataCont) > 0 { if len(sunDataList) > 0 { sunMasterMap := publicmethod.MapOut[string]() @@ -1035,7 +1035,7 @@ func EditWriteSunDatabase(uuid, creater, createrTime int64, masterTableName stri for _, sv := range s { //拆分子表 if sdf, isOk := sv.(map[string]interface{}); isOk { if sunTableType, sunIsOk := sunTable[k]; sunIsOk { - masterWriteVal := MakeFormMapData(uuid, creater, createrTime, sdf, sunTableType, 2) //转换数据表值 + masterWriteVal := MakeFormMapData(uuid, creater, createrOrgId, createrTime, sdf, sunTableType, 2) //转换数据表值 if len(masterWriteVal) > 0 { sunCont = append(sunCont, masterWriteVal) } @@ -1214,7 +1214,7 @@ func (a *ApiMethod) NewCustomerFormEditData(c *gin.Context) { masterUnitList[v.Name] = v } uuid, _ := strconv.ParseInt(mapData["flowKey"].(string), 10, 64) - masrWriteMap := MakeFormMapData(uuid, userCont.Key, cureeTime, masterField, masterUnitList, 2) + masrWriteMap := MakeFormMapData(uuid, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 2) //判断是否 if len(sunFieldAry) > 0 { @@ -1224,7 +1224,7 @@ func (a *ApiMethod) NewCustomerFormEditData(c *gin.Context) { for _, v := range formUnitCont.SunFormInfo { sunTypeAry[v.TableName] = v.UbitInfo } - err = EditWriteSunDatabase(uuid, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + err = EditWriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) } else { err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Where("`masters_key` = ?", uuid).Updates(masrWriteMap).Error diff --git a/api/version1/taskplatform/taskmanagement/flowNode.go b/api/version1/taskplatform/taskmanagement/flowNode.go index 37cb0c1..51f4e42 100644 --- a/api/version1/taskplatform/taskmanagement/flowNode.go +++ b/api/version1/taskplatform/taskmanagement/flowNode.go @@ -78,11 +78,16 @@ type FlowPermissionInfo struct { //矩阵信息 type MatrixInfo struct { - MatrixId int64 `json:"matrixid"` - FactorId int64 `json:"factorid"` + 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"` - MatrixName string `json:"matrixName"` - FactorName string `json:"factorName"` OutcomeName string `json:"outcomeName"` } diff --git a/api/version1/taskplatform/taskmanagement/formcontrol.go b/api/version1/taskplatform/taskmanagement/formcontrol.go index 585435b..7651627 100644 --- a/api/version1/taskplatform/taskmanagement/formcontrol.go +++ b/api/version1/taskplatform/taskmanagement/formcontrol.go @@ -114,7 +114,7 @@ func (a *ApiMethod) AddFormAddData(c *gin.Context) { //判断是否 if len(sunFieldAry) > 0 { //有子表 - err = WriteSunDatabase(uuid, userCont.Key, cureeTime, formCont.TableKey, masterWriteVal, sunFieldAry, sunTable) + err = WriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masterWriteVal, sunFieldAry, sunTable) } else { //无子表 err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Create(masterWriteVal).Error @@ -165,7 +165,7 @@ func (a *ApiMethod) AddFormAddData(c *gin.Context) { # */ -func WriteSunDatabase(uuid, creater, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (err error) { +func WriteSunDatabase(uuid, creater, userOrg, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (err error) { if len(masterDataCont) > 0 { if len(sunDataList) > 0 { sunMasterMap := publicmethod.MapOut[string]() @@ -183,7 +183,7 @@ func WriteSunDatabase(uuid, creater, createrTime int64, masterTableName string, for _, sv := range s { //拆分子表 if sdf, isOk := sv.(map[string]interface{}); isOk { if sunTableType, sunIsOk := sunTable[k]; sunIsOk { - masterWriteVal := MakeFormMapData(uuid, creater, createrTime, sdf, sunTableType, 2) //转换数据表值 + masterWriteVal := MakeFormMapData(uuid, creater, userOrg, createrTime, sdf, sunTableType, 2) //转换数据表值 if len(masterWriteVal) > 0 { sunCont = append(sunCont, masterWriteVal) } @@ -566,7 +566,7 @@ func (a *ApiMethod) AddFormAddNewData(c *gin.Context) { masterUnitList[v.Name] = v } - masrWriteMap := MakeFormMapData(uuid, userCont.Key, cureeTime, masterField, masterUnitList, 1) + masrWriteMap := MakeFormMapData(uuid, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 1) masrWriteMap["flowIsOpen"] = formCont.FlowIsOpen //任务列表 var taskCont modelAppPlatform.Task @@ -595,7 +595,7 @@ func (a *ApiMethod) AddFormAddNewData(c *gin.Context) { sunTypeAry[v.TableName] = v.UbitInfo } - err = WriteSunDatabase(uuid, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + err = WriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) } else { // //无子表 err = overall.CONSTANT_DB_CustomerForm.Table(formCont.TableKey).Create(masrWriteMap).Error @@ -647,13 +647,14 @@ func (a *ApiMethod) AddFormAddNewData(c *gin.Context) { # */ -func MakeFormMapData(uuid, userKey, cureeTime int64, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct, calss int) map[string]interface{} { +func MakeFormMapData(uuid, userKey, userOrg, cureeTime int64, fieldVal map[string]interface{}, subUnit map[string]customerform.MasterStruct, calss int) map[string]interface{} { keyAndVal := make(map[string]interface{}) if calss == 1 { keyAndVal["creater_time"] = cureeTime } keyAndVal["masters_key"] = uuid keyAndVal["creater"] = userKey + keyAndVal["createrOrg"] = userOrg keyAndVal["edit_time"] = cureeTime for k, v := range fieldVal { fmt.Printf("写入字段:%v->%v\n", k, v) @@ -874,7 +875,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { masterUnitList[v.Name] = v } - masrWriteMap := MakeFormMapData(uuid, userCont.Key, cureeTime, masterField, masterUnitList, 1) + masrWriteMap := MakeFormMapData(uuid, userCont.Key, userCont.AdminOrg, cureeTime, masterField, masterUnitList, 1) masrWriteMap["flowIsOpen"] = formCont.FlowIsOpen //任务列表 var taskCont customerForm.TaskRecord @@ -888,6 +889,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { taskCont.Types = formCont.FlowIsOpen //类型(1:流程表单;2:普通表单)"` taskCont.VersionId = formCont.Id //来源于哪个表单"` taskCont.Status = status + taskCont.CreaterOrg = userCont.AdminOrg if formCont.FlowIsOpen == 1 { taskCont.Status = 3 taskCont.FlowKey = formCont.Flowkey @@ -921,7 +923,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { sunTypeAry[v.TableName] = v.UbitInfo } - err = WriteSunDatabaseSoucer(sqlDborm, uuid, userCont.Key, cureeTime, formJsonCont.Form.DataSourceConfig.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + err = WriteSunDatabaseSoucer(sqlDborm, uuid, userCont.Key, userCont.AdminOrg, cureeTime, formJsonCont.Form.DataSourceConfig.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) } else { // //无子表 @@ -939,7 +941,7 @@ func (a *ApiMethod) AddCustomerForm(c *gin.Context) { sunTypeAry[v.TableName] = v.UbitInfo } - err = WriteSunDatabase(uuid, userCont.Key, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) + err = WriteSunDatabase(uuid, userCont.Key, userCont.AdminOrg, cureeTime, formCont.TableKey, masrWriteMap, sunFieldAry, sunTypeAry) } else { // //无子表 @@ -1732,7 +1734,7 @@ func GainOrgManWechat(orgId int64) (wechatMap []string) { # */ -func WriteSunDatabaseSoucer(sqlDb *gorm.DB, uuid, creater, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (err error) { +func WriteSunDatabaseSoucer(sqlDb *gorm.DB, uuid, creater, userOrg, createrTime int64, masterTableName string, masterDataCont, sunDataList map[string]interface{}, sunTable map[string]map[string]customerform.MasterStruct) (err error) { if len(masterDataCont) > 0 { if len(sunDataList) > 0 { sunMasterMap := publicmethod.MapOut[string]() @@ -1750,7 +1752,7 @@ func WriteSunDatabaseSoucer(sqlDb *gorm.DB, uuid, creater, createrTime int64, ma for _, sv := range s { //拆分子表 if sdf, isOk := sv.(map[string]interface{}); isOk { if sunTableType, sunIsOk := sunTable[k]; sunIsOk { - masterWriteVal := MakeFormMapData(uuid, creater, createrTime, sdf, sunTableType, 2) //转换数据表值 + masterWriteVal := MakeFormMapData(uuid, creater, userOrg, createrTime, sdf, sunTableType, 2) //转换数据表值 if len(masterWriteVal) > 0 { sunCont = append(sunCont, masterWriteVal) } diff --git a/api/version1/taskplatform/taskmanagement/ruanTask.go b/api/version1/taskplatform/taskmanagement/ruanTask.go index edc2d52..1b1b77b 100644 --- a/api/version1/taskplatform/taskmanagement/ruanTask.go +++ b/api/version1/taskplatform/taskmanagement/ruanTask.go @@ -1637,6 +1637,7 @@ func (n *NodePublicInfo) CircularParsing(step int, creater modelshr.ManCont, org nodeInfo.Operator = GainUserCode(userNumber) } case 9: //权限矩阵 + fmt.Printf("权限矩阵-->\n\n\n%v\n\n\n", n.Matrix) if n.Attribute == 1 { nodeInfo.Operator = GainMatrixUserList(creater.AdminOrg, n.Matrix) } else { @@ -1760,11 +1761,13 @@ func GainOrgPostUserList(orgId int64, approvers []NodeUserListInfo) (UserList [] var userAry MultiLeveUserList for _, v := range approvers { //逐行分析职务 if v.Types == 4 { + fmt.Printf("获取行政组织----111-------》%v\n", v.Options) syncSeting.Add(1) go userAry.GainOrgPostPeople(allOrgId, v.Options) } } syncSeting.Wait() + fmt.Printf("获取行政组织-----------》%v\n", approvers) UserList = userAry.UserList } return @@ -1798,7 +1801,7 @@ func (m *MultiLeveUserList) GainOrgPostPeople(orgId []int64, options []OptionsIn } if len(postId) > 0 { var userInfoAry []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("`person_in_charge` = 1 AND `admin_org` IN ? AND position IN ? AND `emp_type` BETWEEN ? AND ?", orgId, postId, 1, 10).Find(&userInfoAry) + overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where(" `admin_org` IN ? AND position IN ? AND `emp_type` BETWEEN ? AND ?", orgId, postId, 1, 10).Find(&userInfoAry) if len(userInfoAry) > 0 { for _, uv := range userInfoAry { m.UserList = append(m.UserList, TransformPublicUs(uv)) @@ -1828,14 +1831,29 @@ func (m *MultiLeveUserList) GainOrgPostPeople(orgId []int64, options []OptionsIn */ func GainMatrixUserList(orgId int64, matrix MatrixInfo) (UserList []OperatorList) { allOrgId := publicmethod.HaveAllOrgRelation(orgId) //获取全部归属行政单位 - // fmt.Printf("全部行政组织:%v---->%v\n", orgId, allOrgId) + fmt.Printf("全部行政组织:%v---->%v\n", orgId, allOrgId) var keyVal int64 err := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`number`").Where("`types` = 1 AND `mc_id` = ? AND `mh_id` = ? AND `hand_id` IN ?", matrix.MatrixId, matrix.FactorId, allOrgId).First(&keyVal).Error if err != nil { return } var userKeys []int64 - err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`hand_id`").Where("`types` = 2 AND `mc_id` = ? AND `mh_id` = ? AND `number` = ?", matrix.MatrixId, matrix.OutcomeId, keyVal).Find(&userKeys).Error + if len(matrix.List) > 0 { + var outcomeidAry []int64 + for _, v := range matrix.List { + if !publicmethod.IsInTrue[int64](v.OutcomeId, outcomeidAry) { + outcomeidAry = append(outcomeidAry, v.OutcomeId) + } + } + if len(outcomeidAry) > 0 { + err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`hand_id`").Where("`types` = 2 AND `mc_id` = ? AND `mh_id` IN ? AND `number` = ?", matrix.MatrixId, outcomeidAry, keyVal).Find(&userKeys).Error + } else { + err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`hand_id`").Where("`types` = 2 AND `mc_id` = ? AND `mh_id` = ? AND `number` = ?", matrix.MatrixId, matrix.OutcomeId, keyVal).Find(&userKeys).Error + } + } else { + err = overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.MatrixHandler{}).Select("`hand_id`").Where("`types` = 2 AND `mc_id` = ? AND `mh_id` = ? AND `number` = ?", matrix.MatrixId, matrix.OutcomeId, keyVal).Find(&userKeys).Error + } + if err != nil || len(userKeys) < 1 { return } diff --git a/api/version1/workWechat/wechat.go b/api/version1/workWechat/wechat.go index 7b4d5c5..031a306 100644 --- a/api/version1/workWechat/wechat.go +++ b/api/version1/workWechat/wechat.go @@ -4,6 +4,7 @@ import ( "appPlatform/api/version1/user" "appPlatform/middleware/grocerystore" "appPlatform/models/modelshr" + "appPlatform/models/modelsschool" "appPlatform/overall" "appPlatform/overall/publicmethod" "encoding/json" @@ -553,6 +554,11 @@ func (a *ApiMethod) WechatCallBackPage(c *gin.Context) { urlRedirectKey = append(urlRedirectKey, fmt.Sprintf("masters_key=%v", c.Query("masters_key"))) // urlRedirectKey = append(urlRedirectKey, fmt.Sprintf("runFlowId=%v", c.Query("runFlowId"))) + var userCont modelshr.ManCont + userErr := userCont.GetCont(map[string]interface{}{"number": wechatCont.UserInfo.Number}) + if userErr == nil { + CuliLogin(userCont, wechatCont.UserKey, wechatCont.Token) + } urlParameter := strings.Join(urlRedirectKey, "&") //合并成参数字符串 // callBackLoginUrl := fmt.Sprintf("%v/#/?callback=1&usernum=%v&openid=%v&userkey=%v&token=%v", overall.CONSTANT_CONFIG.Appsetup.WebKpiUrl, userNum, wechatCont.UserInfo.Number, wechatCont.UserKey, wechatCont.Token) @@ -571,3 +577,96 @@ func (a *ApiMethod) WechatCallBackPage(c *gin.Context) { fmt.Printf("\n\n返回路径:%v\n\n", callBackLoginUrl) c.Redirect(http.StatusMovedPermanently, callBackLoginUrl) } + +// 获取权限点位 +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 +} + +/** +@ 作者: 秦东 +@ 时间: 2025-04-09 14:19:13 +@ 功能: 处理登陆信息 +*/ + +func CuliLogin(userCont modelshr.ManCont, userKeyCode, sha1Token string) { + 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) + //缓存写入个人信息 + 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["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:中共党员) + + redisClient.HashMsetAdd(redisMyContKey, myCont) +} diff --git a/go.mod b/go.mod index 6416c9c..af25121 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module appPlatform -go 1.19 +//go 1.19 +go 1.21 require ( github.com/dengsgo/math-engine v0.0.0-20230823154425-78f211b48149 diff --git a/models/customerForm/taskrecord.go b/models/customerForm/taskrecord.go index b7d30f5..b28730f 100644 --- a/models/customerForm/taskrecord.go +++ b/models/customerForm/taskrecord.go @@ -30,6 +30,7 @@ type TaskRecord struct { AppKey int64 `json:"appKey" gorm:"column:appKey;type:bigint(20) unsigned;default:0;not null;comment:归属App(0:非app表单)"` RunFlowId int64 `json:"runFlowId" gorm:"column:runFlowId;type:bigint(20) unsigned;default:0;not null;comment:正在执行得流程"` MsgId int64 `json:"msgId" gorm:"column:msgId;type:bigint(20) unsigned;default:0;not null;comment:发送消息得任务ID"` + CreaterOrg int64 `json:"createrOrg" gorm:"column:createrOrg;type:bigint(20) unsigned;default:0;not null;comment:发起人行政组织"` } func (TaskRecord *TaskRecord) TableName() string { diff --git a/models/modelAppPlatform/customer_form.go b/models/modelAppPlatform/customer_form.go index d1d126a..7540ae0 100644 --- a/models/modelAppPlatform/customer_form.go +++ b/models/modelAppPlatform/customer_form.go @@ -29,6 +29,8 @@ type CustomerForm struct { AppManager string `json:"appManager" gorm:"column:appManager;type:mediumtext;default:'';comment:应用管理员"` AppRoleManager string `json:"appRoleManager" gorm:"column:appRoleManager;type:mediumtext;default:'';comment:应用管理角色"` AppOrgMan string `json:"appOrgMan" gorm:"column:appOrgMan;type:mediumtext;default:'';comment:应用管理行政组织"` + AgentId string `json:"agentId" gorm:"column:agentId;type:varchar(255);default:'';comment:企业微信应用识别码"` + AppSecret string `json:"appSecret" gorm:"column:appSecret;type:text;default:'';comment:验证符号"` } func (CustomerForm *CustomerForm) TableName() string {