Browse Source

排班源点设置完成

v2_dev
超级管理员 3 years ago
parent
commit
0cd87ea378
  1. 11
      api/version1/personnelapi/mancont.go
  2. 12
      api/version1/personnelapi/staffarchives.go
  3. 2
      api/version1/personnelapi/type.go
  4. 3
      api/version1/personnelapi/types.go
  5. 56
      api/version1/workrostering/structsetup.go
  6. 457
      api/version1/workrostering/teamtime.go
  7. 3
      apirouter/workteamapi/apigroupurl.go
  8. 1
      models/man_cont.go
  9. 5
      models/personarchives.go
  10. 61
      models/workgroup/genesis.go
  11. 62
      models/workgroup/polling_rules.go
  12. 9
      models/workgroup/work_time_type.go
  13. 13
      models/workgroup/working_time_period.go
  14. 3
      overall/overallhandle/type.go

11
api/version1/personnelapi/mancont.go

@ -5,6 +5,7 @@ import (
"hr_server/models"
"hr_server/overall"
"hr_server/overall/overallhandle"
"strconv"
"time"
"github.com/gin-gonic/gin"
@ -54,6 +55,10 @@ func (s *StaffApi) EditManOrgCont(c *gin.Context) {
overallhandle.Result(1, requestData, c, "请选择班组!")
return
}
if requestData.Ruleid == "" {
overallhandle.Result(1, requestData, c, "请选择排班规则!!")
return
}
if requestData.JobLeve == 0 {
requestData.JobLeve = 3
}
@ -83,7 +88,7 @@ func (s *StaffApi) EditManOrgCont(c *gin.Context) {
}
if requestData.JobId != myCont.JobId {
var jobCont models.DutiesClassLeve
jobCont.GetCont(map[string]interface{}{"`d_id`": requestData.Id}, "`c_id`")
jobCont.GetCont(map[string]interface{}{"`d_id`": requestData.JobId}, "`c_id`")
saveData["job_class"] = jobCont.ClassId
saveData["job_id"] = requestData.JobId
}
@ -93,6 +98,10 @@ func (s *StaffApi) EditManOrgCont(c *gin.Context) {
if requestData.TeamId != myCont.TeamId {
saveData["teamid"] = requestData.TeamId
}
ruleidStr := strconv.FormatInt(myCont.Ruleid, 10)
if requestData.Ruleid != ruleidStr {
saveData["ruleid"] = requestData.Ruleid
}
if len(saveData) < 1 {
overallhandle.Result(0, saveData, c)
return

12
api/version1/personnelapi/staffarchives.go

@ -4,6 +4,7 @@ import (
"fmt"
"hr_server/grocerystore"
"hr_server/models"
"hr_server/models/workgroup"
"hr_server/overall"
"hr_server/overall/overallhandle"
"strconv"
@ -2144,7 +2145,10 @@ func (s *StaffApi) GetArchivesCon(c *gin.Context) {
}
staffCenter.PoliticalOutlookName = overallhandle.PolitiToString(satffCont.PoliticalOutlook)
var ruleCont workgroup.WorkTimeType
ruleCont.GetCont(map[string]interface{}{"`id`": satffCont.Ruleid}, "`name`")
staffCenter.RuleId = strconv.FormatInt(satffCont.Ruleid, 10)
staffCenter.RuleName = ruleCont.Name
overallhandle.Result(0, staffCenter, c)
// return
}
@ -2180,7 +2184,7 @@ func (s *StaffApi) GetPeopleMainCont(c *gin.Context) {
}
}
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`")
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`")
if err != nil {
overallhandle.Result(107, requestData, c)
return
@ -2253,6 +2257,10 @@ func (s *StaffApi) GetPeopleMainCont(c *gin.Context) {
var manContEs models.PersonnelContent
manContEs.GetCont(map[string]interface{}{"`key`": myCont.Key}, "`mobilephone`")
myInfo.Tel = manContEs.Mobilephone
var ruleCont workgroup.WorkTimeType
ruleCont.GetCont(map[string]interface{}{"`id`": myCont.Ruleid}, "`name`")
myInfo.RuleId = strconv.FormatInt(myCont.Ruleid, 10)
myInfo.RuleName = ruleCont.Name
overallhandle.Result(0, myInfo, c)
}

2
api/version1/personnelapi/type.go

@ -314,6 +314,8 @@ type staffArchivesCont struct {
WorkPostName string `json:"workpostname"` //工段
TeamName string `json:"teamname"` //班组名
AllOrgList []int64 `json:"allorglist"` //全行政组织
RuleId string `json:"ruleid"` //轮询规则ID
RuleName string `json:"rulename"` //轮询规则名称
}
// 双职工

3
api/version1/personnelapi/types.go

@ -139,6 +139,8 @@ type MyMainCont struct {
JobName string `json:"jobname"` //职务名称
JobLeveName string `json:"joblevename"`
Tel string `json:"tel"` //联系电话
RuleId string `json:"ruleid"` //轮询规则ID
RuleName string `json:"rulename"` //轮询规则名称
}
//输出学历
@ -186,6 +188,7 @@ type EditOrgPeople struct {
TeamId int64 `json:"teamid"` //班组
JobId int64 `json:"jobid"` //职务
JobLeve int64 `json:"jobleve"` //职务等级
Ruleid string `json:"ruleid"` //排班规则
}
//编辑人员主体信息

56
api/version1/workrostering/structsetup.go

@ -8,8 +8,14 @@ type WorkTimeList struct {
//添加工作时间段
type SetWorkTime struct {
Name string `json:"name"` //名称
Rule []TimeRule `json:"rule"` //轮询规则
List []TemaTime `json:"list"` // 班次安排
}
type SetWorkTimeEdit struct {
Name string `json:"name"` //名称
Rule []TimeRules `json:"rule"` //轮询规则
List []TemaTimes `json:"list"` // 班次安排
}
//通用班次时间
type TemaTime struct {
@ -17,13 +23,31 @@ type TemaTime struct {
StartTime string `json:"startTime"` //开始时间
EndTime string `json:"endTime"` //结束时间
}
type TemaTimes struct {
Id string `json:"id"`
Title string `json:"title"` //班次名称
StartTime string `json:"startTime"` //开始时间
EndTime string `json:"endTime"` //结束时间
}
//轮询规则
type TimeRule struct {
Sort int `json:"sort"` //排序
Teamid string `json:"teamid"` //班组名称
}
type TimeRules struct {
Id string `json:"id"` //
Sort int `json:"sort"` //排序
Teamid string `json:"teamid"` //班组名称
}
//输出工作时间段列表
type SendWorkTime struct {
Id string `json:"id"` //
State int `json:"state"` //
States bool `json:"states"` //
SetWorkTime
RuleName string `json:"rulename"` //
SetWorkTimeEdit
}
//编辑工作时间段内容
@ -31,3 +55,33 @@ type EditWorkTimeCont struct {
Id string `json:"id"` //
SetWorkTime
}
type EditWorkTimeConts struct {
Id string `json:"id"` //
SetWorkTimeEdit
}
//输出工作时段及轮询规则列表
type SendPeriodRules struct {
Id string `json:"id"` //
Time string `json:"time"` //
Teamid string `json:"teamid"` //班组名称
RuleId string `json:"ruleid"` //轮询规则
List []TemaTimes `json:"list"` // 班次安排
Rule []TimeRuleSend `json:"rule"` //轮询规则
}
type TimeRuleSend struct {
Id string `json:"id"` //
Sort int `json:"sort"` //排序
Teamid string `json:"teamid"` //班组名称
TeamName string `json:"teamname"` //班组名称
}
//设置倒班源点
type SetOrigin struct {
Id string `json:"id"` //
Rule string `json:"rule"` //轮询规则
ShiftTime string `json:"shifttime"` // 班次安排
StartTime string `json:"starttime"` // 起源时间
}

457
api/version1/workrostering/teamtime.go

@ -1,10 +1,13 @@
package workrostering
import (
"fmt"
"hr_server/models"
"hr_server/models/workgroup"
"hr_server/overall"
"hr_server/overall/overallhandle"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
@ -54,15 +57,27 @@ func (a *ApiModer) TeamTimeList(c *gin.Context) {
} else {
sendCont.States = false
}
sendCont.RuleName = v.Rule
var workTimeCont workgroup.WorkingTimePeriod
timeContList, _ := workTimeCont.ContMap(map[string]interface{}{`type_id`: v.Id}, "`name`", "`start_time`", "`end_time`")
timeContList, _ := workTimeCont.ContMap(map[string]interface{}{`type_id`: v.Id}, "`id`", "`name`", "`start_time`", "`end_time`")
for _, wv := range timeContList {
var teamContTime TemaTime
var teamContTime TemaTimes
teamContTime.Id = strconv.FormatInt(wv.Id, 10)
teamContTime.Title = wv.Name
teamContTime.StartTime = wv.StartTime
teamContTime.EndTime = wv.EndTime
sendCont.List = append(sendCont.List, teamContTime)
}
//获取轮询规则
var ruleCont workgroup.PollingRules
ruleList, _ := ruleCont.ContMap(map[string]interface{}{`type_id`: v.Id}, "`id`", "`teamid`", "`sort`", "`teamname`")
for _, rlv := range ruleList {
var ruleInfo TimeRules
ruleInfo.Id = strconv.FormatInt(rlv.Id, 10)
ruleInfo.Sort = rlv.Sort
ruleInfo.Teamid = strconv.FormatInt(rlv.Teamid, 10)
sendCont.Rule = append(sendCont.Rule, ruleInfo)
}
sendList = append(sendList, sendCont)
}
overallhandle.Result(0, sendList, c)
@ -96,6 +111,10 @@ func (a *ApiModer) AddTeamTime(c *gin.Context) {
overallhandle.Result(101, requestData, c)
return
}
if len(requestData.Rule) < 1 {
overallhandle.Result(101, requestData, c)
return
}
if len(requestData.List) < 1 {
overallhandle.Result(1, requestData, c, "没有划分工作时间段!")
return
@ -124,6 +143,7 @@ func (a *ApiModer) AddTeamTime(c *gin.Context) {
workTimeType.Name = requestData.Name //type:string comment:类型名称 version:2022-11-13 16:57
workTimeType.State = 1 //类型:(1:启用;2:禁用;3:删除) version:2022-11-13 16:57
workTimeType.Time = time.Now().Unix()
// workTimeType.Rule = requestData.Rule
//工作时段
var workTimeList []workgroup.WorkingTimePeriod
for _, lv := range requestData.List {
@ -133,14 +153,33 @@ func (a *ApiModer) AddTeamTime(c *gin.Context) {
workTimeCont.TypeId = key //type:int64 comment:类型 version:2022-11-13 16:59
workTimeCont.StartTime = lv.StartTime //type:string comment:开始时间 version:2022-11-13 16:59
workTimeCont.EndTime = lv.EndTime //type:string comment:结束时间 version:2022-11-13 16:59
workTimeCont.State = 1
workTimeList = append(workTimeList, workTimeCont)
}
//轮询规则
var teamName []string
var ruleList []workgroup.PollingRules
for _, rv := range requestData.Rule {
var ruleCont workgroup.PollingRules
ruleCont.Teamid, _ = strconv.ParseInt(rv.Teamid, 10, 64) //type:int64 comment:班组 version:2022-11-16 09:16
ruleCont.State = 1 //type:*int comment:状态(1:启用;2:禁用;3:删除);状态(1:启用;2:禁用;3:删除) version:2022-11-16 09:16
ruleCont.Time = time.Now().Unix() //type:int64 comment:时间;时间 version:2022-11-16 09:16
ruleCont.Sort = rv.Sort //type:*int comment:排序 version:2022-11-16 09:16
ruleCont.TypeId = key //type:int64 comment:类型
var teamCont models.TeamGroup
teamCont.GetCont(map[string]interface{}{"`id`": rv.Teamid}, "`name`")
ruleCont.TeamName = teamCont.Name
teamName = append(teamName, teamCont.Name)
ruleList = append(ruleList, ruleCont)
}
workTimeType.Rule = strings.Join(teamName, ",")
err = overall.CONSTANT_DB_HR.Create(&workTimeType).Error
if err != nil {
overallhandle.Result(104, requestData, c)
return
}
WriteWorkTime(key, workTimeList)
WriteWorkTimeRule(key, ruleList)
overallhandle.Result(0, requestData, c)
}
@ -169,6 +208,31 @@ func WriteWorkTime(key int64, workTimeList []workgroup.WorkingTimePeriod) (err e
return
}
/*
*
@ 作者: 秦东
@ 时间: 2022-12-16 09:17:39
@ 功能: 写入轮询顺序
@ 参数
#key 类型ID
#ruleList 时段列表
@ 返回值
#
@ 方法原型
#
*/
func WriteWorkTimeRule(key int64, ruleList []workgroup.PollingRules) (err error) {
var workTimeCont workgroup.PollingRules
workTimeCont.DelCont(map[string]interface{}{"`type_id`": key})
err = overall.CONSTANT_DB_HR.Create(&ruleList).Error
return
}
/*
*
@ 作者: 秦东
@ -263,6 +327,75 @@ func (a *ApiModer) EditWorkTimeState(c *gin.Context) {
#
*/
func (a *ApiModer) EditWorkTimeCont(c *gin.Context) {
var requestData EditWorkTimeConts
err := c.ShouldBindJSON(&requestData)
if err != nil {
overallhandle.Result(100, err, c)
return
}
if requestData.Id == "" {
overallhandle.Result(101, requestData, c)
return
}
if requestData.Name == "" {
overallhandle.Result(101, requestData, c)
return
}
if len(requestData.Rule) < 1 {
overallhandle.Result(101, requestData, c)
return
}
if len(requestData.List) < 1 {
overallhandle.Result(1, requestData, c, "没有划分工作时间段!")
return
}
isTrue := true
for _, v := range requestData.List {
if v.Title == "" || v.StartTime == "" || v.EndTime == "" {
isTrue = false
}
// beginTime := fmt.Sprintf("%v",)
}
if !isTrue {
overallhandle.Result(1, requestData, c, "您划分的工作时间段,有不符合规定的!请改正!")
return
}
wher := overallhandle.MapOut()
wher["id"] = requestData.Id
var oldCont workgroup.WorkTimeType
err = oldCont.GetCont(wher)
if err != nil {
overallhandle.Result(107, err, c)
return
}
editCont := overallhandle.MapOut()
editCont["name"] = requestData.Name
// editCont["rule"] = requestData.Rule
editCont["time"] = time.Now().Unix()
//轮询规则
var teamName []string
// var ruleList []workgroup.PollingRules
for _, rv := range requestData.Rule {
var teamCont models.TeamGroup
teamCont.GetCont(map[string]interface{}{"`id`": rv.Teamid}, "`name`")
teamName = append(teamName, teamCont.Name)
}
editCont["rule"] = strings.Join(teamName, ",")
err = oldCont.EiteCont(wher, editCont)
if err != nil {
overallhandle.Result(106, err, c)
return
}
//工作时段
EditPeriodTime(oldCont.Id, requestData.List)
//编辑轮询规则
EditPollingRule(oldCont.Id, requestData.Rule)
overallhandle.Result(0, err, c)
}
func (a *ApiModer) EditWorkTimeContOld(c *gin.Context) {
var requestData EditWorkTimeCont
err := c.ShouldBindJSON(&requestData)
if err != nil {
@ -277,6 +410,10 @@ func (a *ApiModer) EditWorkTimeCont(c *gin.Context) {
overallhandle.Result(101, requestData, c)
return
}
if len(requestData.Rule) < 1 {
overallhandle.Result(101, requestData, c)
return
}
if len(requestData.List) < 1 {
overallhandle.Result(1, requestData, c, "没有划分工作时间段!")
return
@ -302,12 +439,33 @@ func (a *ApiModer) EditWorkTimeCont(c *gin.Context) {
}
editCont := overallhandle.MapOut()
editCont["name"] = requestData.Name
// editCont["rule"] = requestData.Rule
editCont["time"] = time.Now().Unix()
//轮询规则
var teamName []string
var ruleList []workgroup.PollingRules
for _, rv := range requestData.Rule {
var ruleCont workgroup.PollingRules
ruleCont.Teamid, _ = strconv.ParseInt(rv.Teamid, 10, 64) //type:int64 comment:班组 version:2022-11-16 09:16
ruleCont.State = 1 //type:*int comment:状态(1:启用;2:禁用;3:删除);状态(1:启用;2:禁用;3:删除) version:2022-11-16 09:16
ruleCont.Time = time.Now().Unix() //type:int64 comment:时间;时间 version:2022-11-16 09:16
ruleCont.Sort = rv.Sort //type:*int comment:排序 version:2022-11-16 09:16
ruleCont.TypeId = oldCont.Id //type:int64 comment:类型
var teamCont models.TeamGroup
teamCont.GetCont(map[string]interface{}{"`id`": rv.Teamid}, "`name`")
ruleCont.TeamName = teamCont.Name
teamName = append(teamName, teamCont.Name)
ruleList = append(ruleList, ruleCont)
}
editCont["rule"] = strings.Join(teamName, ",")
err = oldCont.EiteCont(wher, editCont)
if err != nil {
overallhandle.Result(106, err, c)
return
}
WriteWorkTimeRule(oldCont.Id, ruleList)
//工作时段
var workTimeList []workgroup.WorkingTimePeriod
for _, lv := range requestData.List {
@ -320,5 +478,300 @@ func (a *ApiModer) EditWorkTimeCont(c *gin.Context) {
workTimeList = append(workTimeList, workTimeCont)
}
WriteWorkTime(oldCont.Id, workTimeList)
overallhandle.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2022-12-16 16:23:22
@ 功能: 编辑轮询规则
@ 参数
#typeId 类型识别符
#ruleList 规则列表
@ 返回值
#
@ 方法原型
#
*/
func EditPollingRule(typeId int64, ruleList []TimeRules) {
var ruleCont workgroup.PollingRules
oldRuleList, _ := ruleCont.ContMap(map[string]interface{}{"`type_id`": typeId})
var saveData []workgroup.PollingRules
var editId []string
for _, rv := range ruleList {
var teamCont models.TeamGroup
teamCont.GetCont(map[string]interface{}{"`id`": rv.Teamid}, "`name`")
if rv.Id != "" {
var ruleContJude workgroup.PollingRules
//判断是否存在
err := ruleContJude.GetCont(map[string]interface{}{"`id`": rv.Id})
if err == nil {
if overallhandle.IsInTrue[string](rv.Id, editId) == false {
editId = append(editId, rv.Id)
}
editCont := overallhandle.MapOut()
editCont["`state`"] = 1
editCont["`teamid`"], _ = strconv.ParseInt(rv.Teamid, 10, 64)
editCont["`teamname`"] = teamCont.Name
editCont["`sort`"] = rv.Sort
editCont["`time`"] = time.Now().Unix()
var ruleContNewEdit workgroup.PollingRules
ruleContNewEdit.EiteCont(map[string]interface{}{"`id`": rv.Id}, editCont)
} else {
var ruleContNew workgroup.PollingRules
ruleContNew.Teamid, _ = strconv.ParseInt(rv.Teamid, 10, 64) //type:int64 comment:班组 version:2022-11-16 09:16
ruleContNew.State = 1 //type:*int comment:状态(1:启用;2:禁用;3:删除);状态(1:启用;2:禁用;3:删除) version:2022-11-16 09:16
ruleContNew.Time = time.Now().Unix() //type:int64 comment:时间;时间 version:2022-11-16 09:16
ruleContNew.Sort = rv.Sort //type:*int comment:排序 version:2022-11-16 09:16
ruleContNew.TypeId = typeId //type:int64 comment:类型
ruleContNew.TeamName = teamCont.Name
saveData = append(saveData, ruleContNew)
}
} else {
var ruleContNewAdd workgroup.PollingRules
ruleContNewAdd.Teamid, _ = strconv.ParseInt(rv.Teamid, 10, 64) //type:int64 comment:班组 version:2022-11-16 09:16
ruleContNewAdd.State = 1 //type:*int comment:状态(1:启用;2:禁用;3:删除);状态(1:启用;2:禁用;3:删除) version:2022-11-16 09:16
ruleContNewAdd.Time = time.Now().Unix() //type:int64 comment:时间;时间 version:2022-11-16 09:16
ruleContNewAdd.Sort = rv.Sort //type:*int comment:排序 version:2022-11-16 09:16
ruleContNewAdd.TypeId = typeId //type:int64 comment:类型
ruleContNewAdd.TeamName = teamCont.Name
saveData = append(saveData, ruleContNewAdd)
}
}
//将不在使用的项目删除
for _, dv := range oldRuleList {
idStr := strconv.FormatInt(dv.Id, 10)
if overallhandle.IsInTrue[string](idStr, editId) == false {
editCont := overallhandle.MapOut()
editCont["`state`"] = 3
editCont["`time`"] = time.Now().Unix()
var ruleContNewAddAll workgroup.PollingRules
ruleContNewAddAll.EiteCont(map[string]interface{}{"`id`": dv.Id}, editCont)
}
}
if len(saveData) > 0 {
overall.CONSTANT_DB_HR.Create(&saveData)
}
}
/*
*
@ 作者: 秦东
@ 时间: 2022-12-16 17:10:13
@ 功能: 编辑工作时段
@ 参数
#typeId 类型识别符
#ruleList 分班时间表
@ 返回值
#
@ 方法原型
#
*/
func EditPeriodTime(typeId int64, ruleList []TemaTimes) {
var workTimeCont workgroup.WorkingTimePeriod
workTimeListCont, _ := workTimeCont.ContMap(map[string]interface{}{"`type_id`": typeId})
var editId []string
var saveData []workgroup.WorkingTimePeriod
for _, v := range ruleList {
if v.Id != "" {
var workTimeContJudge workgroup.WorkingTimePeriod
err := workTimeContJudge.GetCont(map[string]interface{}{"`id`": v.Id})
if err == nil {
if overallhandle.IsInTrue[string](v.Id, editId) == false {
editId = append(editId, v.Id)
}
editCont := overallhandle.MapOut()
editCont["`state`"] = 1
editCont["`name`"] = v.Title
editCont["`time`"] = time.Now().Unix()
editCont["`start_time`"] = v.StartTime
editCont["`end_time`"] = v.EndTime
var workTimeContEs workgroup.WorkingTimePeriod
workTimeContEs.EiteCont(map[string]interface{}{"`id`": v.Id}, editCont)
} else {
var workTimeContAdd workgroup.WorkingTimePeriod
workTimeContAdd.Name = v.Title //type:string comment:工作时间段名称 version:2022-11-13 16:59
workTimeContAdd.Time = time.Now().Unix() //type:int64 comment:编辑时间;0 version:2022-11-13 16:59
workTimeContAdd.TypeId = typeId //type:int64 comment:类型 version:2022-11-13 16:59
workTimeContAdd.StartTime = v.StartTime //type:string comment:开始时间 version:2022-11-13 16:59
workTimeContAdd.EndTime = v.EndTime //type:string comment:结束时间 version:2022-11-13 16:59
saveData = append(saveData, workTimeContAdd)
}
} else {
var workTimeContAdd workgroup.WorkingTimePeriod
workTimeContAdd.Name = v.Title //type:string comment:工作时间段名称 version:2022-11-13 16:59
workTimeContAdd.Time = time.Now().Unix() //type:int64 comment:编辑时间;0 version:2022-11-13 16:59
workTimeContAdd.TypeId = typeId //type:int64 comment:类型 version:2022-11-13 16:59
workTimeContAdd.StartTime = v.StartTime //type:string comment:开始时间 version:2022-11-13 16:59
workTimeContAdd.EndTime = v.EndTime //type:string comment:结束时间 version:2022-11-13 16:59
saveData = append(saveData, workTimeContAdd)
}
}
//将不在使用的项目删除
for _, dv := range workTimeListCont {
idStr := strconv.FormatInt(dv.Id, 10)
if overallhandle.IsInTrue[string](idStr, editId) == false {
editCont := overallhandle.MapOut()
editCont["`state`"] = 3
editCont["`time`"] = time.Now().Unix()
var workTimeContEss workgroup.WorkingTimePeriod
workTimeContEss.EiteCont(map[string]interface{}{"`id`": dv.Id}, editCont)
}
}
if len(saveData) > 0 {
overall.CONSTANT_DB_HR.Create(&saveData)
}
}
/*
*
@ 作者: 秦东
@ 时间: 2022-12-17 09:35:20
@ 功能: 获取工作时段及轮询规则列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiModer) GetPeriodAndRuleList(c *gin.Context) {
var requestData overallhandle.ConstId
err := c.ShouldBindJSON(&requestData)
if err != nil {
overallhandle.Result(100, err, c)
return
}
if requestData.Id == "" {
overallhandle.Result(101, err, c)
return
}
var sendData SendPeriodRules
sendData.Id = requestData.Id
var genesisCont workgroup.Genesis
genesisCont.GetCont(map[string]interface{}{"`type_id`": requestData.Id})
if genesisCont.StartTime != 0 {
sendData.Time = overallhandle.UnixTimeToDay(genesisCont.StartTime, 14) //
}
if genesisCont.PeriodId != 0 {
sendData.Teamid = strconv.FormatInt(genesisCont.PeriodId, 10) //班组名称
}
if genesisCont.Rules != 0 {
sendData.RuleId = strconv.FormatInt(genesisCont.Rules, 10) //轮询规则
}
//获取工作时段列表
var periodCont workgroup.WorkingTimePeriod
periodList, _ := periodCont.ContMap(map[string]interface{}{"`state`": 1, "`type_id`": requestData.Id})
for _, v := range periodList {
var teamPeriod TemaTimes
teamPeriod.Id = strconv.FormatInt(v.Id, 10)
teamPeriod.Title = v.Name //班次名称
teamPeriod.StartTime = v.StartTime //开始时间
teamPeriod.EndTime = v.EndTime //结束时间
sendData.List = append(sendData.List, teamPeriod)
}
//获取轮询规则
var ruleList []workgroup.PollingRules
// ruleList, _ := ruleCont.ContMap(map[string]interface{}{`type_id`: requestData.Id})
overall.CONSTANT_DB_HR.Where("`state` = 1 AND `type_id` = ?", requestData.Id).Order("`sort` ASC").Order("`id` ASC").Find(&ruleList)
for _, vr := range ruleList {
var teamRule TimeRuleSend
teamRule.Id = strconv.FormatInt(vr.Id, 10) //
teamRule.Sort = vr.Sort //排序
teamRule.Teamid = strconv.FormatInt(vr.Teamid, 10) //班组名称
teamRule.TeamName = vr.TeamName //班组名称
sendData.Rule = append(sendData.Rule, teamRule)
}
overallhandle.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2022-12-17 10:51:12
@ 功能: 写入轮询源点
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiModer) SetOirginCont(c *gin.Context) {
var requestData SetOrigin
err := c.ShouldBindJSON(&requestData)
if err != nil {
overallhandle.Result(100, err, c)
return
}
if requestData.Id == "" {
overallhandle.Result(101, err, c)
return
}
if requestData.Rule == "" {
overallhandle.Result(101, err, c)
return
}
if requestData.ShiftTime == "" {
overallhandle.Result(101, err, c)
return
}
if requestData.StartTime == "" {
overallhandle.Result(101, err, c)
return
}
timeInt, timeErr := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", requestData.StartTime))
if !timeErr {
overallhandle.Result(1, err, c, "你提交的日期不符合规范!请改正后提交!")
return
}
var genesisCont workgroup.Genesis
err = genesisCont.GetCont(map[string]interface{}{"`type_id`": requestData.Id})
if err != nil {
genesisCont.TypeId, _ = strconv.ParseInt(requestData.Id, 10, 64) //type:int64 comment:类型
genesisCont.PeriodId, _ = strconv.ParseInt(requestData.ShiftTime, 10, 64) //type:int64 comment:锚定工作段
genesisCont.Rules, _ = strconv.ParseInt(requestData.Rule, 10, 64) //type:int64 comment:锚定轮询规则起点
genesisCont.StartTime = timeInt //type:int64 comment:锚定历史原点
genesisCont.Time = time.Now().Unix() //type:int64
err = overall.CONSTANT_DB_HR.Create(&genesisCont).Error
} else {
editCont := overallhandle.MapOut()
editCont["type_id"] = requestData.Id
editCont["period_id"] = requestData.ShiftTime
editCont["rules"] = requestData.Rule
editCont["start_time"] = timeInt
err = genesisCont.EiteCont(map[string]interface{}{"`id`": genesisCont.Id}, editCont)
}
if err != nil {
overallhandle.Result(1, err, c, "设置失败!")
return
}
overallhandle.Result(0, err, c)
}

3
apirouter/workteamapi/apigroupurl.go

@ -18,6 +18,7 @@ func (a *ApiRouter) InitRouterGroup(route *gin.RouterGroup) {
apiRouter.POST("add_team_time", apiHandle.AddTeamTime) //添加工作时间段设定
apiRouter.POST("edit_work_time_state", apiHandle.EditWorkTimeState) //编辑工作时间段状态
apiRouter.POST("edit_work_time_cont", apiHandle.EditWorkTimeCont) //编辑工作时间段内容
apiRouter.POST("get_period_rule_list", apiHandle.GetPeriodAndRuleList) //获取工作时段及轮询规则列表
apiRouter.POST("set_oirgin_cont", apiHandle.SetOirginCont) //写入轮询源点
}
}

1
models/man_cont.go

@ -58,6 +58,7 @@ type ManCont struct {
Planformaldate int64 `json:"planformaldate" gorm:"column:planformaldate;type:bigint(20) unsigned;default:0;comment:预计转正日期"`
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:曾用名"`
Ruleid int64 `json:"ruleid" gorm:"column:ruleid;type:bigint(20) unsigned;default:0;comment:轮询规则"`
}
func (ManCont *ManCont) TableName() string {

5
models/personarchives.go

@ -31,11 +31,10 @@ type PersonArchives struct {
IsAdmin int `json:"isadmin" gorm:"column:is_admin;type:tinyint(1) unsigned;default:1;not null;comment:是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管`
Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"`
Role string `json:"role" gorm:"column:role;type:longtext;comment:角色"`
EmpTypeName string `json:"emptypename" gorm:"column:emp_type_name;type:varchar(255) unsigned;default:'';not null;comment:用工关系中文"`
HireClassName string `json:"hireclassname" gorm:"column:hire_class_name;type:varchar(255) unsigned;default:'';not null;comment:雇佣类型中文"`
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:轮询规则"`
}
func (PersonArchives *PersonArchives) TableName() string {

61
models/workgroup/genesis.go

@ -0,0 +1,61 @@
package workgroup
import (
"hr_server/overall"
"strings"
)
// 轮询规则
type Genesis struct {
Id int64 `gorm:"primaryKey;column:id" json:"id"` //type:int64
TypeId int64 `gorm:"column:type_id" json:"typeid"` //type:int64 comment:类型
PeriodId int64 `gorm:"column:period_id" json:"periodid"` //type:int64 comment:锚定工作段
Rules int64 `gorm:"column:rules" json:"rules"` //type:int64 comment:锚定轮询规则起点
StartTime int64 `gorm:"column:start_time" json:"starttime"` //type:int64 comment:锚定历史原点
Time int64 `gorm:"column:time" json:"time"` //type:int64
}
func (Genesis *Genesis) TableName() string {
return "genesis"
}
// 编辑内容
func (cont *Genesis) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *Genesis) 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 *Genesis) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *Genesis) ContMap(whereMap interface{}, field ...string) (countAry []Genesis, err error) {
gormDb := overall.CONSTANT_DB_HR.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Find(&countAry).Error
return
}
// 删除内容
func (cont *Genesis) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error
return
}

62
models/workgroup/polling_rules.go

@ -0,0 +1,62 @@
package workgroup
import (
"hr_server/overall"
"strings"
)
// 轮询规则
type PollingRules struct {
Id int64 `gorm:"primaryKey;column:id" json:"id"` //type:int64 comment: version:2022-11-16 09:16
Teamid int64 `gorm:"column:teamid" json:"teamid"` //type:int64 comment:班组;规则 version:2022-11-16 09:16
State int `gorm:"column:state" json:"state"` //type:*int comment:状态(1:启用;2:禁用;3:删除);状态(1:启用;2:禁用;3:删除) version:2022-11-16 09:16
Time int64 `gorm:"column:time" json:"time"` //type:int64 comment:时间;时间 version:2022-11-16 09:16
Sort int `gorm:"column:sort" json:"sort"` //type:*int comment:排序 version:2022-11-16 09:16
TypeId int64 `gorm:"column:type_id" json:"typeid"` //type:int64 comment:类型
TeamName string `gorm:"column:teamname" json:"teamname"`
}
func (PollingRules *PollingRules) TableName() string {
return "polling_rules"
}
// 编辑内容
func (cont *PollingRules) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *PollingRules) 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 *PollingRules) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *PollingRules) ContMap(whereMap interface{}, field ...string) (countAry []PollingRules, err error) {
gormDb := overall.CONSTANT_DB_HR.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Find(&countAry).Error
return
}
// 删除内容
func (cont *PollingRules) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error
return
}

9
models/workgroup/work_time_type.go

@ -7,10 +7,11 @@ import (
)
type WorkTimeType struct {
Id int64 `gorm:"primaryKey;column:id" json:"Id"` //type:int64 comment: version:2022-11-13 16:57
Name string `gorm:"column:name" json:"Name"` //type:string comment:类型名称 version:2022-11-13 16:57
State int `gorm:"column:state" json:"State"` //type:*int comment:类型:(1:启用;2:禁用;3:删除) version:2022-11-13 16:57
Time int64 `gorm:"column:time" json:"Time"` //type:int64 comment: version:2022-11-13 16:57
Id int64 `gorm:"primaryKey;column:id" json:"id"` //type:int64 comment: version:2022-11-13 16:57
Name string `gorm:"column:name" json:"name"` //type:string comment:类型名称 version:2022-11-13 16:57
State int `gorm:"column:state" json:"state"` //type:*int comment:类型:(1:启用;2:禁用;3:删除) version:2022-11-13 16:57
Time int64 `gorm:"column:time" json:"time"` //type:int64 comment: version:2022-11-13 16:57
Rule string `gorm:"column:rule" json:"rule"` //type:string comment:规则
}
func (WorkTimeType *WorkTimeType) TableName() string {

13
models/workgroup/working_time_period.go

@ -7,12 +7,13 @@ import (
// 工作时间段
type WorkingTimePeriod struct {
Id int64 `gorm:"primaryKey;column:id" json:"Id"` //type:int64 comment: version:2022-11-13 16:59
Name string `gorm:"column:name" json:"Name"` //type:string comment:工作时间段名称 version:2022-11-13 16:59
Time int64 `gorm:"column:time" json:"Time"` //type:int64 comment:编辑时间;0 version:2022-11-13 16:59
TypeId int64 `gorm:"column:type_id" json:"TypeId"` //type:int64 comment:类型 version:2022-11-13 16:59
StartTime string `gorm:"column:start_time" json:"StartTime"` //type:string comment:开始时间 version:2022-11-13 16:59
EndTime string `gorm:"column:end_time" json:"EndTime"` //type:string comment:结束时间 version:2022-11-13 16:59
Id int64 `gorm:"primaryKey;column:id" json:"id"` //type:int64 comment: version:2022-11-13 16:59
Name string `gorm:"column:name" json:"name"` //type:string comment:工作时间段名称 version:2022-11-13 16:59
Time int64 `gorm:"column:time" json:"time"` //type:int64 comment:编辑时间;0 version:2022-11-13 16:59
TypeId int64 `gorm:"column:type_id" json:"typeid"` //type:int64 comment:类型 version:2022-11-13 16:59
StartTime string `gorm:"column:start_time" json:"starttime"` //type:string comment:开始时间 version:2022-11-13 16:59
EndTime string `gorm:"column:end_time" json:"endtime"` //type:string comment:结束时间 version:2022-11-13 16:59
State int `gorm:"column:state" json:"state"`
}
func (WorkingTimePeriod *WorkingTimePeriod) TableName() string {

3
overall/overallhandle/type.go

@ -14,6 +14,9 @@ type GetId struct {
Id int64 `json:"id"`
IdStr string `json:"idstr"`
}
type ConstId struct {
Id string `json:"id"`
}
//翻页格式化
type PageTurning struct {

Loading…
Cancel
Save