From 90cc34d9e4ca8b08b95d0a5b288253e43522c8d2 Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Fri, 25 Nov 2022 10:49:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=A1=A3=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../administrativeorganization/duties.go | 14 +- .../administrativeorganization/govcont.go | 66 ++++- .../administrativeorganization/position.go | 273 +++++++++++++++++- .../administrativeorganization/team.go | 29 +- .../administrativeorganization/type.go | 40 ++- api/version1/personnelapi/staffarchives.go | 13 +- apirouter/organization/organization_group.go | 16 +- models/position.go | 9 +- overall/overallhandle/overall_handle.go | 18 ++ overall/overallhandle/type.go | 5 + 10 files changed, 439 insertions(+), 44 deletions(-) diff --git a/api/version1/administrativeorganization/duties.go b/api/version1/administrativeorganization/duties.go index 31ab725..cdf3f93 100644 --- a/api/version1/administrativeorganization/duties.go +++ b/api/version1/administrativeorganization/duties.go @@ -11,7 +11,7 @@ import ( "github.com/gin-gonic/gin" ) -//职务 +// 职务 func (o *OrganizationApi) DutiesList(c *gin.Context) { var requestData dutiesListType c.ShouldBindJSON(&requestData) @@ -40,7 +40,7 @@ func (o *OrganizationApi) DutiesList(c *gin.Context) { if totalErr != nil { total = 0 } - errGorm := gormDb.Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&dutiesList).Error + errGorm := gormDb.Order("`weight` ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&dutiesList).Error if errGorm != nil { overallhandle.Result(105, errGorm, c) } else { @@ -48,7 +48,7 @@ func (o *OrganizationApi) DutiesList(c *gin.Context) { } } -//添加职务 +// 添加职务 func (o *OrganizationApi) AddDutiesCont(c *gin.Context) { var requestData addDutiesInfo err := c.ShouldBindJSON(&requestData) @@ -92,7 +92,7 @@ func (o *OrganizationApi) AddDutiesCont(c *gin.Context) { } } -//获取职务编号 +// 获取职务编号 func getDutiesNumber() (number string) { var countId int64 overall.CONSTANT_DB_HR.Model(&models.Duties{}).Select("`id`").Pluck("COALESCE(COUNT(`id`), 0) as countid", &countId) @@ -119,7 +119,7 @@ func getDutiesNumber() (number string) { return } -//获取职务详情 +// 获取职务详情 func (o *OrganizationApi) GetDutiesCont(c *gin.Context) { var requestData overallhandle.GetId err := c.ShouldBindJSON(&requestData) @@ -144,7 +144,7 @@ func (o *OrganizationApi) GetDutiesCont(c *gin.Context) { } } -//修改职务 +// 修改职务 func (o *OrganizationApi) EiteDutiesInfo(c *gin.Context) { var requestData eiteDutiesCont err := c.ShouldBindJSON(&requestData) @@ -195,7 +195,7 @@ func (o *OrganizationApi) EiteDutiesInfo(c *gin.Context) { } } -//编辑状态或删除 +// 编辑状态或删除 func (o *OrganizationApi) EiteDutiesStatOrDel(c *gin.Context) { var requestData EiteJobStateDel err := c.ShouldBindJSON(&requestData) diff --git a/api/version1/administrativeorganization/govcont.go b/api/version1/administrativeorganization/govcont.go index f562daf..320cdff 100644 --- a/api/version1/administrativeorganization/govcont.go +++ b/api/version1/administrativeorganization/govcont.go @@ -42,7 +42,11 @@ func (o *OrganizationApi) GovList(c *gin.Context) { gormDb = gormDb.Where("administrative_organization.organization_type = ?", requestData.GovClass) } if requestData.Superior != "" { - gormDb = gormDb.Where("administrative_organization.superior = ?", requestData.Superior) + // gormDb = gormDb.Where("administrative_organization.superior = ?", requestData.Superior) + superiorInt, _ := strconv.ParseInt(requestData.Superior, 10, 64) + var sunAry overallhandle.AllSunList[int64] + sunAry.GetAllSunOrg(superiorInt) + gormDb = gormDb.Where("administrative_organization.superior = ? OR administrative_organization.`id` IN ?", requestData.Superior, sunAry.SunList) } var total int64 totalErr := gormDb.Count(&total).Error @@ -300,6 +304,56 @@ func (o *OrganizationApi) GovThree(c *gin.Context) { overallhandle.Result(0, govMapThree, c) } +/* +* +@ 作者: 秦东 +@ 时间: 2022-11-21 08:59:34 +@ 功能: 行政组织树(全) +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (o *OrganizationApi) GovThreeIng(c *gin.Context) { + var requestData govThreeType + c.ShouldBindJSON(&requestData) + if requestData.Id == 0 && requestData.IdStr == "" { + requestData.Id = 0 + } + if requestData.IdStr != "" { + idInt64, _ := strconv.ParseInt(requestData.IdStr, 10, 64) + requestData.Id = idInt64 + } + fmt.Printf("requestData---------------->%v\n", requestData) + var govMap overallhandle.MenuList + // gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` IN ?", []int{1, 2}).Where("administrative_organization.id NOT IN ?", []int{312, 293, 305, 306, 307}) + gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` BETWEEN ? AND ?", 1, 2) + if requestData.All == 0 { + requestData.Id = 312 + gormDb = gormDb.Where("administrative_organization.id NOT IN ?", []int{312, 293, 305, 306, 307}) + } + if requestData.Level != 0 { + gormDb = gormDb.Where("aot.level <= ?", requestData.Level) + } + err := gormDb.Find(&govMap).Error + if err != nil { + overallhandle.Result(107, err, c) + return + } + // fmt.Printf("id==========>%v", govMap) + // govMap.GovRecursion(requestData.Id, 0) + fmt.Printf("govAry---------------->%v\n", requestData.Id) + govMapThree := overallhandle.GovThreeList(requestData.Id, govMap) + overallhandle.Result(0, govMapThree, c) +} + // 获取当前行政组织的所有子类 func (o *OrganizationApi) GetOrgAllSun(c *gin.Context) { var requestData overallhandle.GetId @@ -313,8 +367,14 @@ func (o *OrganizationApi) GetOrgAllSun(c *gin.Context) { } // fmt.Printf("\nrequestData---->%v\n", requestData) var idAry []int64 - idAry = overallhandle.GetDepartmentSun(requestData.Id, idAry) - idAry = append(idAry, requestData.Id) + // idAry = overallhandle.GetDepartmentSun(requestData.Id, idAry) + // idAry = append(idAry, requestData.Id) + + var sunAry overallhandle.AllSunList[int64] + sunAry.GetAllSunOrg(requestData.Id) + sunAry.SunList = append(sunAry.SunList, requestData.Id) + idAry = sunAry.SunList + //获取行政组织信息 var orgList []models.AdministrativeOrganization if len(idAry) < 1 { diff --git a/api/version1/administrativeorganization/position.go b/api/version1/administrativeorganization/position.go index fcc6df5..2be9df5 100644 --- a/api/version1/administrativeorganization/position.go +++ b/api/version1/administrativeorganization/position.go @@ -29,13 +29,22 @@ func (o *OrganizationApi) PositionList(c *gin.Context) { gormDb = gormDb.Where("p.name LIKE ?", "%"+requestData.Name+"%") } if requestData.Number != "" { - gormDb = gormDb.Where("p.number = ?", requestData.Number) + gormDb = gormDb.Where("p.number LIKE ?", "%"+requestData.Number+"%") } if requestData.Duties != "" { gormDb = gormDb.Where("p.duties = ?", requestData.Duties) } if requestData.Organization != "" { - gormDb = gormDb.Where("p.administrative_organization = ?", requestData.Organization) + orgIdInt, _ := strconv.ParseInt(requestData.Organization, 10, 64) + // orgIdList := overallhandle.GetDepartmentSun(orgIdInt, []int64{}) + // orgIdList = append(orgIdList, orgIdInt) + // gormDb = gormDb.Where("p.administrative_organization IN ?", orgIdList) + // fmt.Printf("所有子集--->%v\n", orgIdList) + + var sunAry overallhandle.AllSunList[int64] + sunAry.GetAllSunOrg(orgIdInt) + sunAry.SunList = append(sunAry.SunList, orgIdInt) + gormDb = gormDb.Where("p.administrative_organization IN ?", sunAry.SunList) } if requestData.InCharge != 0 { gormDb = gormDb.Where("p.person_in_charge = ?", requestData.InCharge) @@ -50,7 +59,8 @@ func (o *OrganizationApi) PositionList(c *gin.Context) { total = 0 } var positionAry []positionOutInfo - errGorm := gormDb.Order("p.department DESC,p.duties DESC,p.duties ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&positionAry).Error + // errGorm := gormDb.Order("p.department DESC,p.duties DESC,p.duties ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&positionAry).Error + errGorm := gormDb.Order("p.id DESC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&positionAry).Error for i, v := range positionAry { var getSpur models.Position getWhe := overallhandle.MapOut() @@ -185,6 +195,26 @@ func (o *OrganizationApi) GetPositionCont(c *gin.Context) { getSpur.GetCont(getWhe, "number", "name") postCont.SuperiorNumber = getSpur.Number postCont.SuperiorName = getSpur.Name + if postCont.OrgList != "" { + json.Unmarshal([]byte(postCont.OrgList), postCont.OrgListAry) + } else { + groupId, companyId, departmentId, sunDepartId, workShopId := overallhandle.GetOrgStructure(postCont.AdministrativeOrganization) + if groupId != 0 && overallhandle.IsInTrue[int64](groupId, postCont.OrgListAry) == false { + postCont.OrgListAry = append(postCont.OrgListAry, groupId) + } + if companyId != 0 && overallhandle.IsInTrue[int64](companyId, postCont.OrgListAry) == false { + postCont.OrgListAry = append(postCont.OrgListAry, companyId) + } + if departmentId != 0 && overallhandle.IsInTrue[int64](departmentId, postCont.OrgListAry) == false { + postCont.OrgListAry = append(postCont.OrgListAry, departmentId) + } + if sunDepartId != 0 && overallhandle.IsInTrue[int64](sunDepartId, postCont.OrgListAry) == false { + postCont.OrgListAry = append(postCont.OrgListAry, sunDepartId) + } + if workShopId != 0 && overallhandle.IsInTrue[int64](workShopId, postCont.OrgListAry) == false { + postCont.OrgListAry = append(postCont.OrgListAry, workShopId) + } + } overallhandle.Result(0, postCont, c) } @@ -431,3 +461,240 @@ func MenuOperation(jurisd int, menuId int64) (isTrue bool, operation []models.Me } return } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-11-22 08:40:38 +@ 功能: 根据行政组织获取岗位 +@ 参数 + + #requestData 行政组织数组 + +@ 返回值 + + # + +@ 方法原型 + + #func (o *OrganizationApi) BasisOrgGetPostList(c *gin.Context) +*/ +func (o *OrganizationApi) BasisOrgGetPostList(c *gin.Context) { + var requestData OrgGivePost + err := c.ShouldBindJSON(&requestData) + if err != nil || len(requestData.Id) < 1 { + overallhandle.Result(100, requestData, c) + return + } + orgList := []int64{312, 313} + groupId, companyId, departmentId, _, _ := overallhandle.GetOrgStructure(requestData.Id[len(requestData.Id)-1]) + fmt.Printf("空间看到----->%v----->%v----->%v\n", groupId, companyId, departmentId) + if overallhandle.IsInTrue[int64](groupId, orgList) == false { + orgList = append(orgList, groupId) + } + if overallhandle.IsInTrue[int64](companyId, orgList) == false { + orgList = append(orgList, companyId) + } + var postList []models.Position + err = overall.CONSTANT_DB_HR.Model(&models.Position{}).Where("`state` = 1 AND `administrative_organization` IN ?", orgList).Or("`department` = ?", departmentId).Order("person_in_charge ASC").Find(&postList).Error + if err != nil { + overallhandle.Result(107, err, c) + return + } + overallhandle.Result(0, postList, c) +} + +/** +@ 作者: 秦东 +@ 时间: 2022-11-22 10:04:48 +@ 功能: 添加职位(岗位)新版 +@ 参数 + # +@ 返回值 + # +@ 方法原型 + # +*/ +// +func (o *OrganizationApi) AddPositionContNew(c *gin.Context) { + var requestData addPositionInfoNew + err := c.ShouldBindJSON(&requestData) + if err != nil { + overallhandle.Result(100, err, c) + return + } + if requestData.Number == "" { + overallhandle.Result(101, requestData.Number, c, "职位编码不能为空!") + return + } + if requestData.Name == "" { + overallhandle.Result(101, requestData.Name, c, "职位名称不能为空!") + return + } + if requestData.Duties == 0 { + overallhandle.Result(101, requestData.Duties, c, "请指定该职位的职务!") + return + } + if len(requestData.Organization) < 1 { + overallhandle.Result(101, requestData.Organization, c, "请指定该职位归属的行政组织!") + return + } + orgListJson, _ := json.Marshal(requestData.Organization) + if requestData.InCharge == 0 { + requestData.InCharge = 2 + } + + var positionCont models.Position + //判断编号是否已经存在 + isNumExit := overallhandle.MapOut() + isNumExit["number"] = requestData.Number + judgeNumErr := positionCont.GetCont(isNumExit) + if judgeNumErr == nil { + overallhandle.Result(101, isNumExit, c, "该编号已经存在!请不要重复使用!") + return + } + organizationId := requestData.Organization[len(requestData.Organization)-1] + _, companyId, departmentId, _, _ := overallhandle.GetOrgStructure(organizationId) + + if departmentId == 0 { + departmentId = companyId + } + + //判断岗位名称是否已经存在 + isExit := overallhandle.MapOut() + isExit["department"] = departmentId + isExit["name"] = requestData.Name + isExit["administrative_organization"] = organizationId + judgeErr := positionCont.GetCont(isExit) + if judgeErr == nil { + overallhandle.Result(101, isExit, c, "该职位在本行政组织下已经存在!请不要重复添加") + return + } + positionCont.Number = requestData.Number + positionCont.Name = requestData.Name + positionCont.Duties = requestData.Duties + positionCont.AdministrativeOrganization = organizationId + positionCont.Superior = requestData.Superior + positionCont.PersonInCharge = requestData.InCharge + positionCont.Department = departmentId + positionCont.State = 1 + positionCont.Time = time.Now().Unix() + positionCont.OrgList = string(orgListJson) + addDataErr := overall.CONSTANT_DB_HR.Create(&positionCont).Error + if addDataErr != nil { + overallhandle.Result(104, addDataErr, c) + } else { + overallhandle.Result(0, addDataErr, c) + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-11-23 08:44:11 +@ 功能: 编辑职位(岗位) +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (o *OrganizationApi) EitePositionContNew(c *gin.Context) { + var requestData eitePositionInfoNes + err := c.ShouldBindJSON(&requestData) + if err != nil { + overallhandle.Result(100, err, c) + return + } + if requestData.Id == 0 && requestData.IdStr == "" { + overallhandle.Result(101, err, c, "行政类别Id不能为空!") + return + } + if len(requestData.Organization) < 1 { + overallhandle.Result(101, requestData.Organization, c, "请指定该职位归属的行政组织!") + return + } + if requestData.IdStr != "" { + idInt64, _ := strconv.ParseInt(requestData.IdStr, 10, 64) + requestData.Id = idInt64 + } + whereAry := overallhandle.MapOut() + whereAry["id"] = requestData.Id + var govCont models.Position + judgeErr := govCont.GetCont(whereAry) + if judgeErr != nil { + overallhandle.Result(107, judgeErr, c) + return + } + saveData := overallhandle.MapOut() + + if requestData.Number != "" && requestData.Number != govCont.Number { + isNumExit := overallhandle.MapOut() + isNumExit["number"] = requestData.Number + var govContNum models.Position + judgeNumErr := govContNum.GetCont(isNumExit, "id", "number") + if judgeNumErr == nil { + overallhandle.Result(101, isNumExit, c, "该编号已经存在!请不要重复使用!") + return + } + saveData["number"] = requestData.Number + } + + organizationId := requestData.Organization[len(requestData.Organization)-1] + _, companyId, departmentId, _, _ := overallhandle.GetOrgStructure(organizationId) + if departmentId == 0 { + departmentId = companyId + } + departIsTrue := false + if departmentId != 0 && departmentId != govCont.Department { + departIsTrue = true + orgListJson, _ := json.Marshal(requestData.Organization) + saveData["department"] = departmentId + saveData["orglist"] = orgListJson + } + + if requestData.Name != "" && requestData.Name != govCont.Name { + if departIsTrue == true { + //判断岗位名称是否已经存在 + isExit := overallhandle.MapOut() + isExit["department"] = departmentId + isExit["name"] = requestData.Name + var govContName models.Position + judgeErr := govContName.GetCont(isExit, "id", "department", "name") + if judgeErr == nil { + overallhandle.Result(101, isExit, c, "该职位在本部门下已经存在!请不要重复添加") + return + } + } + saveData["name"] = requestData.Name + } + if requestData.Duties != 0 && requestData.Duties != govCont.Duties { + saveData["duties"] = requestData.Duties + } + if organizationId != 0 && organizationId != govCont.AdministrativeOrganization { + saveData["administrative_organization"] = organizationId + } + if requestData.Superior != 0 && requestData.Superior != govCont.Superior { + saveData["superior"] = requestData.Superior + } + if requestData.InCharge != 0 { + saveData["person_in_charge"] = requestData.InCharge + } + if len(saveData) < 1 { + overallhandle.Result(0, saveData, c) + return + } + saveData["time"] = time.Now().Unix() + eiteErr := govCont.EiteCont(whereAry, saveData) + if eiteErr != nil { + overallhandle.Result(106, eiteErr, c) + } else { + overallhandle.Result(0, saveData, c) + } +} diff --git a/api/version1/administrativeorganization/team.go b/api/version1/administrativeorganization/team.go index b88e99e..e10a935 100644 --- a/api/version1/administrativeorganization/team.go +++ b/api/version1/administrativeorganization/team.go @@ -4,12 +4,13 @@ import ( "hr_server/models" "hr_server/overall" "hr_server/overall/overallhandle" + "strconv" "time" "github.com/gin-gonic/gin" ) -//获取班组内容 +// 获取班组内容 func (o *OrganizationApi) GetTeamCont(c *gin.Context) { var requestData overallhandle.GetId err := c.ShouldBindJSON(&requestData) @@ -30,7 +31,7 @@ func (o *OrganizationApi) GetTeamCont(c *gin.Context) { overallhandle.Result(0, getTeamCont, c) } -//添加班组 +// 添加班组 func (o *OrganizationApi) AddTeamCont(c *gin.Context) { var requestData NameVal err := c.ShouldBindJSON(&requestData) @@ -60,7 +61,7 @@ func (o *OrganizationApi) AddTeamCont(c *gin.Context) { } } -//编辑班组 +// 编辑班组 func (o *OrganizationApi) EiteTeamCont(c *gin.Context) { var requestData eidtTeamCont err := c.ShouldBindJSON(&requestData) @@ -103,7 +104,7 @@ func (o *OrganizationApi) EiteTeamCont(c *gin.Context) { } } -//编辑状态与删除班组 +// 编辑状态与删除班组 func (o *OrganizationApi) EidtDelTeamCont(c *gin.Context) { var requestData EiteJobStateDel err := c.ShouldBindJSON(&requestData) @@ -111,10 +112,17 @@ func (o *OrganizationApi) EidtDelTeamCont(c *gin.Context) { overallhandle.Result(100, requestData, c) return } - if requestData.IdStr == "" { + // fmt.Printf("requestData.IdStr--1->%v--->%v\n", requestData.IdStr, requestData.Id) + if requestData.IdStr == "" && requestData.Id == 0 { overallhandle.Result(101, requestData, c) return } + if requestData.IdStr != "" { + + idStrToInt, _ := strconv.ParseInt(requestData.IdStr, 10, 64) + requestData.Id = idStrToInt + } + // fmt.Printf("requestData.IdStr--->%v--->%v\n", requestData.IdStr, requestData.Id) if requestData.State == 0 { requestData.State = 1 } @@ -122,17 +130,17 @@ func (o *OrganizationApi) EidtDelTeamCont(c *gin.Context) { requestData.IsTrue = 2 } var getTeamCont models.TeamGroup - getErr := getTeamCont.GetCont(map[string]interface{}{"`id`": requestData.IdStr}) + getErr := getTeamCont.GetCont(map[string]interface{}{"`id`": requestData.Id}) if getErr != nil { overallhandle.Result(105, getErr, c) return } whereAry := overallhandle.MapOut() - whereAry["id"] = requestData.IdStr + whereAry["id"] = requestData.Id saveData := overallhandle.MapOut() saveData["time"] = time.Now().Unix() saveData["state"] = requestData.State - + // fmt.Printf("requestData.IdStr-2-->%v--->%v\n", whereAry, saveData) if requestData.State != 3 { eiteErr := getTeamCont.EiteTeamGroupCont(whereAry, saveData) if eiteErr != nil { @@ -159,13 +167,14 @@ func (o *OrganizationApi) EidtDelTeamCont(c *gin.Context) { } } } + } -//班组列表 +// 班组列表 func (o *OrganizationApi) TeamContList(c *gin.Context) { var requestData JobClassPageSelect c.ShouldBindJSON(&requestData) - gormDb := overall.CONSTANT_DB_HR.Model(&models.TeamGroup{}).Where("`state` = 1") + gormDb := overall.CONSTANT_DB_HR.Model(&models.TeamGroup{}).Where("`state` IN (1,2)") if requestData.Name != "" { gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Name+"%") } diff --git a/api/version1/administrativeorganization/type.go b/api/version1/administrativeorganization/type.go index 0cc32f2..ef4accc 100644 --- a/api/version1/administrativeorganization/type.go +++ b/api/version1/administrativeorganization/type.go @@ -160,15 +160,16 @@ type lookPositionList struct { // 职务列表输出 type positionOutInfo struct { models.Position - DutiesName string `json:"dutiesname" gorm:"column:dutiesname;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` - DutiesNumber string `json:"dutiesnumber" gorm:"column:dutiesnumber;type:varchar(255) unsigned;default:'';not null;comment:职务编号"` - AoName string `json:"aoname" gorm:"column:aoname;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` - AoNumber string `json:"aonumber" gorm:"column:aonumber;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` - JobName string `json:"jobname" gorm:"column:jobname;type:varchar(255) unsigned;default:'';not null;comment:职务类型"` - SuperiorName string `json:"superiorname"` //上级名称 - SuperiorNumber string `json:"superiornumber"` //上级编号 - DepartmentName string `json:"departmentname"` - IdStr string `json:"idstr"` + DutiesName string `json:"dutiesname" gorm:"column:dutiesname;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` + DutiesNumber string `json:"dutiesnumber" gorm:"column:dutiesnumber;type:varchar(255) unsigned;default:'';not null;comment:职务编号"` + AoName string `json:"aoname" gorm:"column:aoname;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` + AoNumber string `json:"aonumber" gorm:"column:aonumber;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` + JobName string `json:"jobname" gorm:"column:jobname;type:varchar(255) unsigned;default:'';not null;comment:职务类型"` + SuperiorName string `json:"superiorname"` //上级名称 + SuperiorNumber string `json:"superiornumber"` //上级编号 + DepartmentName string `json:"departmentname"` + IdStr string `json:"idstr"` + OrgListAry []int64 `json:"orglistary"` } // 行政组织树查询 @@ -244,3 +245,24 @@ type OrgAndPeopleThreeZZ struct { *OrgAndPeople Child []*OrgAndPeopleThreeZZ `json:"child"` //子栏目 } + +// 根据行政组织获取岗位 +type OrgGivePost struct { + Id []int64 `json:"id"` +} + +// 添加职位(岗位)新版 +type addPositionInfoNew struct { + Number string `json:"number"` //职位编码 + NameVal //职位名称 + Duties int64 `json:"duties"` //职务 + Organization []int64 `json:"organization"` //归属行政组织 + Superior int64 `json:"superior"` //上级 + InCharge int `json:"incharge"` //是否为本部门负责人(1:是;2:否) +} + +// 编辑职位(岗位) +type eitePositionInfoNes struct { + overallhandle.GetId + addPositionInfoNew +} diff --git a/api/version1/personnelapi/staffarchives.go b/api/version1/personnelapi/staffarchives.go index f2f7b4b..e4ae4f0 100644 --- a/api/version1/personnelapi/staffarchives.go +++ b/api/version1/personnelapi/staffarchives.go @@ -42,10 +42,15 @@ func (s *StaffApi) ArchivesList(c *gin.Context) { // gormDb = gormDb.Where("FIND_IN_SET(?,`deparment`)", requestData.Deparment) // } if requestData.AdminOrg != 0 { - var idAry []int64 - idAry = overallhandle.GetDepartmentSun(requestData.AdminOrg, idAry) - idAry = append(idAry, requestData.AdminOrg) - gormDb = gormDb.Where("admin_org IN ?", idAry) + // var idAry []int64 + // idAry = overallhandle.GetDepartmentSun(requestData.AdminOrg, idAry) + // idAry = append(idAry, requestData.AdminOrg) + // gormDb = gormDb.Where("admin_org IN ?", idAry) + var sunAry overallhandle.AllSunList[int64] + sunAry.GetAllSunOrg(requestData.AdminOrg) + sunAry.SunList = append(sunAry.SunList, requestData.AdminOrg) + gormDb = gormDb.Where("admin_org IN ?", sunAry.SunList) + } if requestData.Position != 0 { gormDb = gormDb.Where("position = ?", requestData.Position) diff --git a/apirouter/organization/organization_group.go b/apirouter/organization/organization_group.go index b3a3e62..fc94843 100644 --- a/apirouter/organization/organization_group.go +++ b/apirouter/organization/organization_group.go @@ -39,6 +39,7 @@ func (o *OrganizationRoute) InitRouterGroup(route *gin.RouterGroup) { apiRouter.POST("eitegovstateordel", apiHandle.EiteGovStateOrDel) //编辑行政组织状态或删除 apiRouter.POST("govthree", apiHandle.GovThree) //行政组织树 + apiRouter.POST("govthreeing", apiHandle.GovThreeIng) //行政组织树(副本) apiRouter.POST("getorgallsun", apiHandle.GetOrgAllSun) //获取当前行政组织的所有子类 apiRouter.POST("govthreeaboutman", apiHandle.GovThreeAboutMan) //行政组织树及相关人员 @@ -46,13 +47,18 @@ func (o *OrganizationRoute) InitRouterGroup(route *gin.RouterGroup) { apiRouter.POST("getcompanydeparment", apiHandle.GetCompanyDeparment) //获取当前行政组织的所有主行政部门 //职位(岗位) - apiRouter.POST("positionlist", apiHandle.PositionList) //职位(岗位)列表 - apiRouter.POST("getpositioncont", apiHandle.GetPositionCont) //获取职位(岗位) - apiRouter.POST("addpositioncont", apiHandle.AddPositionCont) //添加职位(岗位) - apiRouter.POST("eitepositioncont", apiHandle.EitePositionCont) //编辑职位(岗位) + apiRouter.POST("positionlist", apiHandle.PositionList) //职位(岗位)列表 + apiRouter.POST("getpositioncont", apiHandle.GetPositionCont) //获取职位(岗位) + apiRouter.POST("addpositioncont", apiHandle.AddPositionCont) //添加职位(岗位) + apiRouter.POST("eitepositioncont", apiHandle.EitePositionCont) //编辑职位(岗位) + apiRouter.POST("eitepositioncontnew", apiHandle.EitePositionContNew) //编辑职位(岗位)新 + apiRouter.POST("eitepositionstateordel", apiHandle.EitePositionStateOrDel) //编辑职位(岗位)状态或删除 apiRouter.POST("getpositionrole", apiHandle.GetPositionRole) //岗位(职位)配权 GetPositionRole + apiRouter.POST("basis_org_postList", apiHandle.BasisOrgGetPostList) //根据行政组织获取岗位 + apiRouter.POST("addpositioncontnew", apiHandle.AddPositionContNew) //添加职位(岗位)新版 + //班组 apiRouter.POST("teamcontlist", apiHandle.TeamContList) //班组列表 apiRouter.POST("getteamcont", apiHandle.GetTeamCont) //获取班组 @@ -98,6 +104,8 @@ func (o *OrganizationRouteOpen) InitRouterGroup(route *gin.RouterGroup) { apiRouter.POST("govthree", apiHandle.GovThree) //行政组织树 apiRouter.POST("getorgallsun", apiHandle.GetOrgAllSun) //获取当前行政组织的所有子类 + apiRouter.POST("govthreeing", apiHandle.GovThreeIng) //行政组织树(副本) + apiRouter.POST("govthreeaboutman", apiHandle.GovThreeAboutMan) //行政组织树及相关人员 apiRouter.POST("search_org_people", apiHandle.SearchOrgAndPeople) //角色组织与人员搜索列表 diff --git a/models/position.go b/models/position.go index 6dd9207..eddb39e 100644 --- a/models/position.go +++ b/models/position.go @@ -5,7 +5,7 @@ import ( "strings" ) -//职位(岗位) +// 职位(岗位) type Position 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:职位编码"` @@ -21,19 +21,20 @@ type Position struct { ButtonPermit string `json:"buttonpermit" gorm:"column:button_permit;type:longtext;comment:按钮许可"` School int64 `json:"school" gorm:"column:school;type:bigint(20) unsigned;default:0;not null;comment:部门"` KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` + OrgList string `json:"orglist" gorm:"column:orglist;type:text;comment:行政组织关系"` } func (Position *Position) TableName() string { return "position" } -//编辑职务分类内容 +// 编辑职务分类内容 func (cont *Position) EiteCont(whereMap interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取行政组织内容 +// 获取行政组织内容 func (cont *Position) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { @@ -45,7 +46,7 @@ func (cont *Position) GetCont(whereMap interface{}, field ...string) (err error) return } -//根据条件获取总数 +// 根据条件获取总数 func (cont *Position) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return diff --git a/overall/overallhandle/overall_handle.go b/overall/overallhandle/overall_handle.go index 37f8edd..5937409 100644 --- a/overall/overallhandle/overall_handle.go +++ b/overall/overallhandle/overall_handle.go @@ -738,3 +738,21 @@ func GetDepartmentSun(superior int64, idary []int64) (orgIdAry []int64) { } return } + +// 获取所有子集 +func (a *AllSunList[int64]) GetAllSunOrg(superior int64) (err error) { + var orgAry []models.AdministrativeOrganization + err = overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1 AND `superior` = ?", superior).Find(&orgAry).Error + if err != nil { + return + } + for _, v := range orgAry { + // var idInt int64 + idInt := int64(v.Id) + if IsInTrue[int64](idInt, a.SunList) == false { + a.SunList = append(a.SunList, idInt) + } + a.GetAllSunOrg(idInt) + } + return +} diff --git a/overall/overallhandle/type.go b/overall/overallhandle/type.go index b01495a..dea3698 100644 --- a/overall/overallhandle/type.go +++ b/overall/overallhandle/type.go @@ -62,3 +62,8 @@ type MenuPermitThree struct { type GenericityVariable interface { int | int8 | int16 | int32 | int64 | string } + +//所有子集 +type AllSunList[T GenericityVariable] struct { + SunList []T `json:"sunlist"` +}