Browse Source

修改组织关系

v2_dev
超级管理员 3 years ago
parent
commit
9dbb6406c2
  1. 31
      api/version1/personnelapi/mancont.go
  2. 35
      api/version1/personnelapi/staffarchives.go
  3. 2
      api/version1/personnelapi/type.go
  4. 6
      api/version1/personnelapi/types.go
  5. 4
      models/man_cont.go
  6. 3
      models/personarchives.go

31
api/version1/personnelapi/mancont.go

@ -1,11 +1,13 @@
package personnelapi package personnelapi
import ( import (
"encoding/json"
"fmt" "fmt"
"hr_server/models" "hr_server/models"
"hr_server/overall" "hr_server/overall"
"hr_server/overall/overallhandle" "hr_server/overall/overallhandle"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -62,6 +64,11 @@ func (s *StaffApi) EditManOrgCont(c *gin.Context) {
if requestData.JobLeve == 0 { if requestData.JobLeve == 0 {
requestData.JobLeve = 3 requestData.JobLeve = 3
} }
if requestData.PersonInCharge != 1 {
requestData.PersonInCharge = 2
}
// fmt.Printf("%v\n", requestData)
// return
wher := map[string]interface{}{"`id`": requestData.Id} wher := map[string]interface{}{"`id`": requestData.Id}
var myCont models.PersonArchives var myCont models.PersonArchives
err = myCont.GetCont(wher, "`id`", "`admin_org`", "`position`", "`job_id`", "`job_leve`", "`teamid`") err = myCont.GetCont(wher, "`id`", "`admin_org`", "`position`", "`job_id`", "`job_leve`", "`teamid`")
@ -102,6 +109,30 @@ func (s *StaffApi) EditManOrgCont(c *gin.Context) {
if requestData.Ruleid != ruleidStr { if requestData.Ruleid != ruleidStr {
saveData["ruleid"] = requestData.Ruleid saveData["ruleid"] = requestData.Ruleid
} }
if requestData.PersonInCharge != myCont.PersonInCharge {
saveData["person_in_charge"] = requestData.PersonInCharge
}
if len(requestData.OrgresList) > 0 {
jsonCont, jsonErr := json.Marshal(requestData.OrgresList)
if jsonErr == nil {
saveData["responsible_department_json"] = string(jsonCont)
}
}
if len(requestData.Resallorg) > 0 {
var orgResList []string
for i := 0; i < len(requestData.Resallorg); i++ {
resAllOrgIdStr := strconv.Itoa(requestData.Resallorg[i])
if overallhandle.IsInTrue[string](resAllOrgIdStr, orgResList) == false {
orgResList = append(orgResList, resAllOrgIdStr)
}
}
orgResListStr := strings.Join(orgResList, ",")
saveData["responsible_department"] = orgResListStr
}
// fmt.Printf("%v\n", saveData)
// return
if len(saveData) < 1 { if len(saveData) < 1 {
overallhandle.Result(0, saveData, c) overallhandle.Result(0, saveData, c)
return return

35
api/version1/personnelapi/staffarchives.go

@ -1,6 +1,7 @@
package personnelapi package personnelapi
import ( import (
"encoding/json"
"fmt" "fmt"
"hr_server/grocerystore" "hr_server/grocerystore"
"hr_server/models" "hr_server/models"
@ -82,6 +83,10 @@ func (s *StaffApi) ArchivesList(c *gin.Context) {
for _, v := range manContList { for _, v := range manContList {
var staffInfo peopleManOutList var staffInfo peopleManOutList
staffInfo.ManCont = v staffInfo.ManCont = v
if v.IconPhoto != "" {
staffInfo.Icon = v.IconPhoto
}
var getSpur models.Position var getSpur models.Position
getWhe := overallhandle.MapOut() getWhe := overallhandle.MapOut()
getWhe["id"] = v.Position getWhe["id"] = v.Position
@ -133,6 +138,22 @@ func (s *StaffApi) ArchivesList(c *gin.Context) {
staffInfo.WorkPostName = orgContTypeCont.Name staffInfo.WorkPostName = orgContTypeCont.Name
} }
// if requestData.AdminOrg == v.AdminOrg && v.PersonInCharge == 1 {
// staffInfo.PersonInCharge = 1
// } else {
// staffInfo.PersonInCharge = 2
// }
staffInfo.PersonInCharge = 2
if v.PersonInCharge == 1 {
orgResList := strings.Split(v.ResponsibleDepartment, ",")
if len(orgResList) > 0 {
orgIdStr := strconv.FormatInt(requestData.AdminOrg, 10)
if overallhandle.IsInTrue[string](orgIdStr, orgResList) == true {
staffInfo.PersonInCharge = 1
}
}
}
positionAry = append(positionAry, staffInfo) positionAry = append(positionAry, staffInfo)
} }
@ -2092,6 +2113,11 @@ func (s *StaffApi) GetArchivesCon(c *gin.Context) {
postisInfo.GetCont(map[string]interface{}{"`id`": satffCont.Position}, "`name`", "`person_in_charge`") postisInfo.GetCont(map[string]interface{}{"`id`": satffCont.Position}, "`name`", "`person_in_charge`")
staffCenter.PositionName = postisInfo.Name staffCenter.PositionName = postisInfo.Name
staffCenter.PersonInCharge = postisInfo.PersonInCharge staffCenter.PersonInCharge = postisInfo.PersonInCharge
if postisInfo.PersonInCharge != 1 {
staffCenter.PersonInCharge = satffCont.PersonInCharge
}
} else {
staffCenter.PersonInCharge = satffCont.PersonInCharge
} }
if satffCont.JobClass != 0 { if satffCont.JobClass != 0 {
var jobsInfo models.JobClass var jobsInfo models.JobClass
@ -2149,6 +2175,9 @@ func (s *StaffApi) GetArchivesCon(c *gin.Context) {
ruleCont.GetCont(map[string]interface{}{"`id`": satffCont.Ruleid}, "`name`") ruleCont.GetCont(map[string]interface{}{"`id`": satffCont.Ruleid}, "`name`")
staffCenter.RuleId = strconv.FormatInt(satffCont.Ruleid, 10) staffCenter.RuleId = strconv.FormatInt(satffCont.Ruleid, 10)
staffCenter.RuleName = ruleCont.Name staffCenter.RuleName = ruleCont.Name
jsonErr := json.Unmarshal([]byte(satffCont.ResponsibleDepartmentJson), &staffCenter.OrgresList)
fmt.Printf("satffCont---------->%v---------->%v---------->%v\n", satffCont.ResponsibleDepartmentJson, satffCont, jsonErr)
overallhandle.Result(0, staffCenter, c) overallhandle.Result(0, staffCenter, c)
// return // return
} }
@ -2184,17 +2213,21 @@ func (s *StaffApi) GetPeopleMainCont(c *gin.Context) {
} }
} }
var myCont models.PersonArchives var myCont models.PersonArchives
err := myCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`number`", "`name`", "`icon`", "`admin_org`", "`position`", "`teamid`", "`job_id`", "`job_class`", "`job_leve`", "`wechat`", "`work_wechat`", "`key`", "`company`", "`maindeparment`", "`sun_main_deparment`", "`ruleid`") err := myCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`number`", "`name`", "`icon`", "`admin_org`", "`position`", "`teamid`", "`job_id`", "`job_class`", "`job_leve`", "`wechat`", "`work_wechat`", "`key`", "`company`", "`maindeparment`", "`sun_main_deparment`", "`ruleid`", "`icon_photo`")
if err != nil { if err != nil {
overallhandle.Result(107, requestData, c) overallhandle.Result(107, requestData, c)
return return
} }
// fmt.Printf("员工信息-------->%v\n", myCont)
var myInfo MyMainCont var myInfo MyMainCont
myInfo.Id = strconv.FormatInt(myCont.Id, 10) myInfo.Id = strconv.FormatInt(myCont.Id, 10)
myInfo.Key = strconv.FormatInt(myCont.Key, 10) //员工key myInfo.Key = strconv.FormatInt(myCont.Key, 10) //员工key
myInfo.Number = myCont.Number //员工工号 myInfo.Number = myCont.Number //员工工号
myInfo.Name = myCont.Name //姓名 myInfo.Name = myCont.Name //姓名
myInfo.Icon = myCont.Icon //头像 myInfo.Icon = myCont.Icon //头像
if myCont.IconPhoto != "" {
myInfo.Icon = myCont.IconPhoto
}
myInfo.AdminOrg = myCont.AdminOrg //所属行政组织 myInfo.AdminOrg = myCont.AdminOrg //所属行政组织
myInfo.TeamId = myCont.TeamId //班组 myInfo.TeamId = myCont.TeamId //班组
myInfo.Position = myCont.Position //职位 myInfo.Position = myCont.Position //职位

2
api/version1/personnelapi/type.go

@ -316,6 +316,8 @@ type staffArchivesCont struct {
AllOrgList []int64 `json:"allorglist"` //全行政组织 AllOrgList []int64 `json:"allorglist"` //全行政组织
RuleId string `json:"ruleid"` //轮询规则ID RuleId string `json:"ruleid"` //轮询规则ID
RuleName string `json:"rulename"` //轮询规则名称 RuleName string `json:"rulename"` //轮询规则名称
// PersonInCharge int `json:"personincharge"` //负责人(1:是;2:否)
OrgresList [][]int `json:"orgreslist"` //负责部门列表json
} }
// 双职工 // 双职工

6
api/version1/personnelapi/types.go

@ -189,8 +189,14 @@ type EditOrgPeople struct {
JobId int64 `json:"jobid"` //职务 JobId int64 `json:"jobid"` //职务
JobLeve int64 `json:"jobleve"` //职务等级 JobLeve int64 `json:"jobleve"` //职务等级
Ruleid string `json:"ruleid"` //排班规则 Ruleid string `json:"ruleid"` //排班规则
PersonInCharge int `json:"personInCharge"` //部门负责人(1:是;2:否)
OrgresList [][]int `json:"orgreslist"` //负责部门列表json
Resallorg []int `json:"resallorg"` //负责部门列表
} }
// type OrgresListStruct struct{
// []int
// }
//编辑人员主体信息 //编辑人员主体信息
type EditContData struct { type EditContData struct {
Id string `json:"id"` Id string `json:"id"`

4
models/man_cont.go

@ -59,6 +59,10 @@ type ManCont struct {
PoliticalOutlook int `json:"politicaloutlook" gorm:"column:political_outlook;type:tinyint(3) unsigned;default:1;comment:政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"` PoliticalOutlook int `json:"politicaloutlook" gorm:"column:political_outlook;type:tinyint(3) unsigned;default:1;comment:政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"`
NameUsedBefore string `json:"nameusedbefore" gorm:"column:name_used_before;type:varchar(255) unsigned;default:'';not null;comment:曾用名"` NameUsedBefore string `json:"nameusedbefore" gorm:"column:name_used_before;type:varchar(255) unsigned;default:'';not null;comment:曾用名"`
Ruleid int64 `json:"ruleid" gorm:"column:ruleid;type:bigint(20) unsigned;default:0;comment:轮询规则"` Ruleid int64 `json:"ruleid" gorm:"column:ruleid;type:bigint(20) unsigned;default:0;comment:轮询规则"`
IconPhoto string `json:"iconphoto" gorm:"column:icon_photo;type:longtext;default:'';not null;comment:照片"`
PersonInCharge int `json:"personincharge" gorm:"column:person_in_charge;type:tinyint(1) unsigned;default:1;not null;comment:负责人(1:是;2:否)`
ResponsibleDepartment string `json:"responsibledepartment" gorm:"column:responsible_department;type:longtext;default:'';not null;comment:负责的行政组织"`
ResponsibleDepartmentJson string `json:"responsibledepartmentjson" gorm:"column:responsible_department_json;type:longtext;default:'';not null;comment:负责的行政组织json"`
} }
func (ManCont *ManCont) TableName() string { func (ManCont *ManCont) TableName() string {

3
models/personarchives.go

@ -36,6 +36,9 @@ type PersonArchives struct {
SunMainDeparment int64 `json:"sunmaindeparment" gorm:"column:sun_main_deparment;type:bigint(20) unsigned;default:0;not null;comment:二级主部门"` SunMainDeparment int64 `json:"sunmaindeparment" gorm:"column:sun_main_deparment;type:bigint(20) unsigned;default:0;not null;comment:二级主部门"`
Ruleid int64 `json:"ruleid" gorm:"column:ruleid;type:bigint(20) unsigned;default:0;not null;comment:轮询规则"` Ruleid int64 `json:"ruleid" gorm:"column:ruleid;type:bigint(20) unsigned;default:0;not null;comment:轮询规则"`
IconPhoto string `json:"iconphoto" gorm:"column:icon_photo;type:longtext;default:'';not null;comment:照片"` IconPhoto string `json:"iconphoto" gorm:"column:icon_photo;type:longtext;default:'';not null;comment:照片"`
PersonInCharge int `json:"personincharge" gorm:"column:person_in_charge;type:tinyint(1) unsigned;default:1;not null;comment:负责人(1:是;2:否)`
ResponsibleDepartment string `json:"responsibledepartment" gorm:"column:responsible_department;type:longtext;default:'';not null;comment:负责的行政组织"`
ResponsibleDepartmentJson string `json:"responsibledepartmentjson" gorm:"column:responsible_department_json;type:longtext;default:'';not null;comment:负责的行政组织json"`
} }
func (PersonArchives *PersonArchives) TableName() string { func (PersonArchives *PersonArchives) TableName() string {

Loading…
Cancel
Save