From 67068fa982c0defdc99653ab06d62045e452be9f Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Mon, 19 Dec 2022 13:51:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9B=86=E5=9B=A2=E5=86=85?= =?UTF-8?q?=E9=83=A8=E5=B7=A5=E4=BD=9C=E7=BB=8F=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/version1/personnelapi/controll.go | 4 + api/version1/personnelapi/kingdeenew.go | 311 ++++++++++++++++++++- api/version1/personnelapi/staffarchives.go | 4 +- api/version1/workrostering/structsetup.go | 23 ++ api/version1/workrostering/teamtime.go | 98 +++++++ apirouter/workteamapi/apigroupurl.go | 3 + models/personarchives.go | 1 + overall/overallhandle/overall_handle.go | 51 ++++ 8 files changed, 484 insertions(+), 11 deletions(-) diff --git a/api/version1/personnelapi/controll.go b/api/version1/personnelapi/controll.go index dea996e..1a4b5f3 100644 --- a/api/version1/personnelapi/controll.go +++ b/api/version1/personnelapi/controll.go @@ -33,6 +33,8 @@ func EmptypeToInt(emp string) int { return 11 case "辞职": return 12 + case "批准辞职": + return 12 case "辞退": return 13 case "离职": @@ -238,6 +240,8 @@ func changeTypeToInt(emp string) int { return 12 case "离职": return 13 + case "批准辞职": + return 13 case "退休": return 14 case "返聘": diff --git a/api/version1/personnelapi/kingdeenew.go b/api/version1/personnelapi/kingdeenew.go index df31ef9..fee2940 100644 --- a/api/version1/personnelapi/kingdeenew.go +++ b/api/version1/personnelapi/kingdeenew.go @@ -33,8 +33,8 @@ func (s *StaffApi) NewKingdee(c *gin.Context) { saveKingDee.Cont = string(requesJson) saveKingDee.Time = time.Now().Unix() overallhandle.WriteLog("i", "KingDee对接数据!", saveKingDee) - kingdeeErr := overall.CONSTANT_DB_HR.Create(&saveKingDee).Error - overallhandle.WriteLog("w", "KingDee写入数据库状态!", kingdeeErr) + // kingdeeErr := overall.CONSTANT_DB_HR.Create(&saveKingDee).Error + // overallhandle.WriteLog("w", "KingDee写入数据库状态!", kingdeeErr) var manContent models.PersonArchives manErr := manContent.GetCont(map[string]interface{}{"`number`": requestData.Number}) if manErr == nil { @@ -54,16 +54,39 @@ func (s *StaffApi) NewKingdee(c *gin.Context) { overallhandle.Result(0, manErr, c) } -// 编辑员工 +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-19 09:35:48 +@ 功能: 编辑员工 +@ 参数 + + #perArcInfo 原始头像 + #manCont 接收得员工数据 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ func eidtAddManContJinDie(perArcInfo models.PersonArchives, manCont addKingdeePersonneles) error { - fmt.Printf("编辑") + fmt.Printf("编辑--->%v\n", manCont) + eidtManCont := overallhandle.MapOut() if manCont.Name != "" && manCont.Name != perArcInfo.Name { eidtManCont["`name`"] = manCont.Name } - if manCont.Icon != "" && manCont.Icon != perArcInfo.Icon { - eidtManCont["`icon`"] = manCont.Icon + if manCont.Icon != "" { + newIcon := fmt.Sprintf("data:image/jpeg;base64,%v", strings.Replace(manCont.Icon, "\r\n", "", -1)) + if newIcon != perArcInfo.Icon { + eidtManCont["`icon_photo`"] = newIcon + } + } + if manCont.HireType != "" { hireTypes, hireTypesErr := overallhandle.StringToInt(manCont.HireType) if hireTypesErr != nil { @@ -212,6 +235,7 @@ func eidtAddManContJinDie(perArcInfo models.PersonArchives, manCont addKingdeePe manChangeRecord.JobLevel = positionGrade changeRecordTrue = true } + // fmt.Printf("第一学历--->%v--->%v\n", changeRecordTrue, manChangeRecord) if len(eidtManCont) > 0 { var manMainCont models.PersonArchives @@ -237,6 +261,7 @@ func eidtAddManContJinDie(perArcInfo models.PersonArchives, manCont addKingdeePe } } + //编辑人员附属信息 synPro.Add(1) go editManAuxiliaryDataNew(perArcInfo.Key, manCont) @@ -254,7 +279,8 @@ func eidtAddManContJinDie(perArcInfo models.PersonArchives, manCont addKingdeePe go editWorkHistoryMan(perArcInfo.Key, manCont.Number, manCont.WorkHistoryList) //编辑集团内工作履历 synPro.Add(1) - go editInsideWorkHistoryMan(perArcInfo.Key, manCont.InsideWorkHistory) + // go editInsideWorkHistoryMan(perArcInfo.Key, manCont.InsideWorkHistory) + go editInsideWorkHistoryManNew(perArcInfo.Key, manCont.InsideWorkHistory) synPro.Wait() return nil @@ -385,7 +411,11 @@ func newAddManContJinDie(oldSchool models.WorkMan, manCont addKingdeePersonneles var oldPersonArchives models.Personnel oldPersErr := overall.CONSTANT_DB_HR_Jin.Where(map[string]interface{}{"`number`": manCont.Number}).First(&oldPersonArchives).Error if oldPersErr == nil { - if manCont.Icon == "" { + if manCont.Icon != "" { + + manMainCont.IconPhoto = fmt.Sprintf("data:image/jpeg;base64,%v", strings.Replace(manCont.Icon, "\r\n", "", -1)) + } + if oldPersonArchives.Icon != "" { manMainCont.Icon = oldPersonArchives.Icon } if oldPersonArchives.Key != 0 { @@ -448,7 +478,8 @@ func newAddManContJinDie(oldSchool models.WorkMan, manCont addKingdeePersonneles go editWorkHistoryMan(manKeyNum, manCont.Number, manCont.WorkHistoryList) //编辑集团内工作履历 synPro.Add(1) - go editInsideWorkHistoryMan(manKeyNum, manCont.InsideWorkHistory) + // go editInsideWorkHistoryMan(manKeyNum, manCont.InsideWorkHistory) + go editInsideWorkHistoryManNew(manKeyNum, manCont.InsideWorkHistory) synPro.Wait() } return nil @@ -1730,3 +1761,265 @@ func editInsideWorkHistoryMan(manKeyNum int64, contList []insideHistoryer) { } } } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-19 10:16:57 +@ 功能: 编辑集团内工作经历 +@ 参数 + + #manKeyNum 员工Key + #contList 工作经历 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func editInsideWorkHistoryManNew(manKeyNum int64, contList []insideHistoryer) { + defer synPro.Done() + if len(contList) > 0 && manKeyNum > 0 { + var topGroup int64 = 0 // 集团ID + var groupTopCont models.AdministrativeOrganization + groupTopCont.GetCont(map[string]interface{}{"superior": 0}, "id") + topGroup = groupTopCont.Id + + //获取个人信息 + var myCont models.PersonArchives + myCont.GetCont(map[string]interface{}{"key": manKeyNum}, "`company`", "`maindeparment`", "`admin_org`", "`sun_main_deparment`", "`position`", "`teamid`") + + //1、判断是否存在集团工作经历 + var oldInsideWork []models.InsideWorkHistory + overall.CONSTANT_DB_HR.Where("`key` = ?", manKeyNum).Find(&oldInsideWork) + + //已经写入得编号 + var writeIn []int + var creadAllData []models.InsideWorkHistory //新增工作经历 + for i, v := range contList { + WorkShop := myCont.SunMainDeparment + if v.Workshop != "" { + var workShopCont models.AdministrativeOrganization + workShopErr := workShopCont.GetCont(map[string]interface{}{"kingdeeid": v.Workshop}, "id") + if workShopErr == nil { + WorkShop = workShopCont.Id //部室"` + } + } + WorkshopSection := myCont.AdminOrg + // fmt.Printf("v.WorkshopSection --------------------->%v\n", v.WorkshopSection) + if v.WorkshopSection != "" { + var workShopSecCont models.AdministrativeOrganization + workShopSecErr := workShopSecCont.GetCont(map[string]interface{}{"kingdeeid": v.WorkshopSection}, "id") + // fmt.Printf("v.WorkshopSection ----------id----------->%v\n", workShopSecCont) + if workShopSecErr == nil { + WorkshopSection = workShopSecCont.Id //工段"` + + // if v.Department == v.Company { + // cont.Department = overallhandle.RecursionOrgLeve(workShopSecCont.Id, 4) + // } + // if cont.WorkShop == 0 { + // cont.WorkShop = overallhandle.RecursionOrgLeve(workShopSecCont.Id, 5) + // } + + } + } + + var wssCont models.AdministrativeOrganization + wssCont.GetCont(map[string]interface{}{"kingdeeid": v.WorkshopSection}, "id") //工段信息 + if wssCont.Id == 0 { + wssCont.Id = myCont.AdminOrg + } + //集团 + var groupContes models.AdministrativeOrganization + if v.Group != "" { + groupContes.GetCont(map[string]interface{}{"kingdeeid": v.Group}, "id") + if groupContes.Id == 0 { + groupContes.Id = topGroup + } + } else { + groupContes.Id = topGroup + } + //部门 + var dempCont models.AdministrativeOrganization + dempCont.GetCont(map[string]interface{}{"kingdeeid": v.Department}, "id") + if dempCont.Id == groupContes.Id { + if wssCont.Id != 0 { + dempCont.Id = overallhandle.RecursionOrgLeve(wssCont.Id, 4) + } + } + if dempCont.Id == 0 { + dempCont.Id = myCont.MainDeparment + } + //公司 + var compayCont models.AdministrativeOrganization + compayCont.GetCont(map[string]interface{}{"kingdeeid": v.Company}, "id") + if compayCont.Id == 0 { + compayCont.Id = myCont.Company + } + //职务 + var postCont models.Position + postCont.GetCont(map[string]interface{}{"kingdeeid": v.Position}, "id") + if postCont.Id == 0 { + postCont.Id = myCont.Position + } + //判断是否存在集团内部工作经历 + if len(oldInsideWork) > 0 { + + changeTypeInt := changeTypeToInt(v.ChangeType) + //判断当前工作经历是否存在 + var insiCont models.InsideWorkHistory + isErr := insiCont.GetCont(map[string]interface{}{"`key`": manKeyNum, "`group`": groupContes.Id, "`company`": compayCont.Id, "`department`": dempCont.Id, "workshop_section": wssCont.Id, "position": postCont.Id, "`change_type`": changeTypeInt}) + if isErr == nil { + //此项存在 + if overallhandle.IsInTrue[int](i, writeIn) == false { + writeIn = append(writeIn, i) + } + editSaveData := overallhandle.MapOut() + startTime := time.Now().Unix() + if v.StartTime != "" { + var startTimeErr bool + startTime, startTimeErr = overallhandle.DateToTimeStamp(v.StartTime) + if startTimeErr == false { + startTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.StartTime)) + } + } + if startTime != insiCont.StartTime { + editSaveData["`start_time`"] = startTime + } + state := 1 + var endTime int64 + if v.EndTime != "" { + if v.EndTime != "至今" && v.EndTime != "2199-12-31 00:00:00" && v.EndTime != "2199-12-31" && v.EndTime != "7258003200" { + var endTimeErr bool + endTime, endTimeErr = overallhandle.DateToTimeStamp(v.EndTime) + if endTimeErr == false { + endTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.EndTime)) + } + state = 2 //状态(1:启用;2:休眠;3:删除)"` + } + } + if changeTypeInt > 12 && changeTypeInt <= 14 { + endTime = time.Now().Unix() + } + if endTime != insiCont.EndTime { + editSaveData["`end_time`"] = endTime + editSaveData["`state`"] = state + } + if insiCont.GradePositions != v.GradePositions { + editSaveData["`grade_positions`"] = v.GradePositions + } + if insiCont.ChangeType != changeTypeInt { + editSaveData["`change_type`"] = changeTypeInt + } + assignTypeInt := assignTypeToInt(v.AssignType) + if insiCont.AssignType != assignTypeInt { + editSaveData["`assign_type`"] = assignTypeInt + } + if len(editSaveData) > 0 { + var editCont models.InsideWorkHistory + editCont.EditCont(map[string]interface{}{"`id`": insiCont.Id}, editSaveData) + } + } else { + if overallhandle.IsInTrue[int](i, writeIn) == false { + writeIn = append(writeIn, i) + } + //此项不存在 + var creadCont models.InsideWorkHistory + creadCont.Key = manKeyNum //员工识别符"` + creadCont.Group = groupContes.Id //集团"` + creadCont.Company = compayCont.Id //公司"` + creadCont.Department = dempCont.Id // 部室"` + creadCont.WorkShop = WorkShop //二级部门或车间"` + creadCont.WorkshopSection = WorkshopSection //工段"` + creadCont.Position = postCont.Id //职位"` + creadCont.GradePositions = v.GradePositions //职等"` + startTime := time.Now().Unix() + if v.StartTime != "" { + var startTimeErr bool + startTime, startTimeErr = overallhandle.DateToTimeStamp(v.StartTime) + if startTimeErr == false { + startTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.StartTime)) + } + } + creadCont.StartTime = startTime //开始日期"` + state := 1 + var endTime int64 + if v.EndTime != "" { + if v.EndTime != "至今" && v.EndTime != "2199-12-31 00:00:00" && v.EndTime != "2199-12-31" && v.EndTime != "7258003200" { + var endTimeErr bool + endTime, endTimeErr = overallhandle.DateToTimeStamp(v.EndTime) + if endTimeErr == false { + endTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.EndTime)) + } + state = 2 //状态(1:启用;2:休眠;3:删除)"` + } + } + changeTypeInted := changeTypeToInt(v.ChangeType) + if changeTypeInted > 12 && changeTypeInted <= 14 { + endTime = time.Now().Unix() + } + + creadCont.EndTime = endTime //结束日期"` + creadCont.Team = myCont.TeamId //(1:长白;2:甲;3:乙;4:丙;5:丁)"` + creadCont.ChangeType = changeTypeToInt(v.ChangeType) // 变动类型(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;)"` + creadCont.Time = time.Now().Unix() //创建时间"` + creadCont.State = state //状态(1:启用;2:禁用;3:删除)"` + creadCont.AssignType = assignTypeToInt(v.AssignType) // 1、主职;2:兼职"` + creadAllData = append(creadAllData, creadCont) + } + } else { + if overallhandle.IsInTrue[int](i, writeIn) == false { + writeIn = append(writeIn, i) + } + var creadCont models.InsideWorkHistory + creadCont.Key = manKeyNum //员工识别符"` + creadCont.Group = groupContes.Id //集团"` + creadCont.Company = compayCont.Id //公司"` + creadCont.Department = dempCont.Id // 部室"` + creadCont.WorkShop = WorkShop //二级部门或车间"` + creadCont.WorkshopSection = WorkshopSection //工段"` + creadCont.Position = postCont.Id //职位"` + creadCont.GradePositions = v.GradePositions //职等"` + startTime := time.Now().Unix() + if v.StartTime != "" { + var startTimeErr bool + startTime, startTimeErr = overallhandle.DateToTimeStamp(v.StartTime) + if startTimeErr == false { + startTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.StartTime)) + } + } + creadCont.StartTime = startTime //开始日期"` + state := 1 + var endTime int64 + if v.EndTime != "" { + if v.EndTime != "至今" && v.EndTime != "2199-12-31 00:00:00" && v.EndTime != "2199-12-31" && v.EndTime != "7258003200" { + var endTimeErr bool + endTime, endTimeErr = overallhandle.DateToTimeStamp(v.EndTime) + if endTimeErr == false { + endTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.EndTime)) + } + state = 2 //状态(1:启用;2:休眠;3:删除)"` + } + } + achangeTypeInted := changeTypeToInt(v.ChangeType) + if achangeTypeInted > 12 && achangeTypeInted <= 14 { + endTime = time.Now().Unix() + } + creadCont.EndTime = endTime //结束日期"` + creadCont.Team = myCont.TeamId //(1:长白;2:甲;3:乙;4:丙;5:丁)"` + creadCont.ChangeType = changeTypeToInt(v.ChangeType) // 变动类型(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;)"` + creadCont.Time = time.Now().Unix() //创建时间"` + creadCont.State = state //状态(1:启用;2:禁用;3:删除)"` + creadCont.AssignType = assignTypeToInt(v.AssignType) // 1、主职;2:兼职"` + creadAllData = append(creadAllData, creadCont) + } + + } + if len(creadAllData) > 1 { + overall.CONSTANT_DB_HR.Create(&creadAllData) + } + } +} diff --git a/api/version1/personnelapi/staffarchives.go b/api/version1/personnelapi/staffarchives.go index a69dda1..b7be551 100644 --- a/api/version1/personnelapi/staffarchives.go +++ b/api/version1/personnelapi/staffarchives.go @@ -2289,8 +2289,8 @@ func (s *StaffApi) GetInsideWorkHistoryList(c *gin.Context) { return } var insideWorkHistoryList []models.InsideWorkHistory - gormDb := overall.CONSTANT_DB_HR.Model(&models.InsideWorkHistory{}).Where("`state` = 1 AND `key` = ?", requestData.Id) - err := gormDb.Order("end_time asc").Order("start_time desc").Order("`id` desc").Find(&insideWorkHistoryList).Error + gormDb := overall.CONSTANT_DB_HR.Model(&models.InsideWorkHistory{}).Where("`state` BETWEEN 1 AND 2 AND `key` = ?", requestData.Id) + err := gormDb.Order("start_time desc").Order("end_time asc").Order("`id` desc").Find(&insideWorkHistoryList).Error if err != nil { overallhandle.Result(107, err, c) return diff --git a/api/version1/workrostering/structsetup.go b/api/version1/workrostering/structsetup.go index b37c584..db0fc7f 100644 --- a/api/version1/workrostering/structsetup.go +++ b/api/version1/workrostering/structsetup.go @@ -1,5 +1,7 @@ package workrostering +import "hr_server/overall/overallhandle" + //工作时间段列表查询 type WorkTimeList struct { Name string `json:"name"` //名称 @@ -85,3 +87,24 @@ type SetOrigin struct { ShiftTime string `json:"shifttime"` // 班次安排 StartTime string `json:"starttime"` // 起源时间 } + +//排班查询列表 +type Schedule struct { + overallhandle.PageTurning + Organization string `json:"organization"` //归属行政组织 + NameOrName string `json:"nameorname"` //姓名或工号 + YearAndMonth string `json:"yearandmonth"` //时间 +} + +//排班列表输出 +type SendScheduleList struct { + Title string `json:"title"` //表名称 + HeadList []headtype `json:"headList"` //表头数组 + DataList []map[string]interface{} `json:"dataList"` //数据值 +} + +//表头结构体 +type headtype struct { + Name string `json:"name"` //结构体字段 + Label string `json:"label"` //表头名称 +} diff --git a/api/version1/workrostering/teamtime.go b/api/version1/workrostering/teamtime.go index ffea653..760b853 100644 --- a/api/version1/workrostering/teamtime.go +++ b/api/version1/workrostering/teamtime.go @@ -775,3 +775,101 @@ func (a *ApiModer) SetOirginCont(c *gin.Context) { } overallhandle.Result(0, err, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-17 14:48:07 +@ 功能: 获取排班表 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiModer) GetSchedule(c *gin.Context) { + var requestData Schedule + c.ShouldBindJSON(&requestData) + dayTime := time.Now().Unix() + if requestData.YearAndMonth != "" { //判断是否有搜索的时间。默认为当前系统时间 + timeInt, timeIsTrue := overallhandle.DateToTimeStamp(fmt.Sprintf("%v-01 00:00:00", requestData.YearAndMonth)) + if timeIsTrue { + dayTime = timeInt + } + } + if requestData.Page != 0 { + requestData.Page = 1 + } + if requestData.PageSize != 0 { + requestData.PageSize = 10 + } + yearInt := overallhandle.GetIntTime(dayTime, 1) + monthInt := overallhandle.GetIntTime(dayTime, 2) + dayInt := overallhandle.GetYearOfMonthHaveDay(yearInt, monthInt) + + var sendData SendScheduleList + sendData.Title = fmt.Sprintf("%v年%v月排班表", yearInt, monthInt) + + // //获取行政组织所有子类 + + //获取人员列表 + var peopleList []models.PersonArchives + gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`name`,`number`,`key`,`teamid`,`ruleid`").Where("`emp_type` BETWEEN ? AND ?", 1, 8) + if requestData.NameOrName != "" { + gormDb = gormDb.Where("`number` LIKE ? OR `name` LIKE ?", "%"+requestData.NameOrName+"%", "%"+requestData.NameOrName+"%") + } + if requestData.Organization != "" { + orgIdInt, _ := strconv.ParseInt(requestData.Organization, 10, 64) + var sunAry overallhandle.AllSunList[int64] + sunAry.GetAllSunOrg(orgIdInt) + sunAry.SunList = append(sunAry.SunList, orgIdInt) + gormDb = gormDb.Where("`admin_org` IN ?", sunAry.SunList) + } + var total int64 + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + err := gormDb.Order("`company` ASC").Order("`maindeparment` ASC").Order("`admin_org` ASC").Order("`teamid` ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&peopleList).Error + if err != nil { + overallhandle.Result(105, err, c) + return + } + var tableHead []headtype + + var tableHeadUser headtype + tableHeadUser.Name = "name" + tableHeadUser.Label = "姓名" + tableHead = append(tableHead, tableHeadUser) + + userCont := overallhandle.MapOut() + userCont["name"] = "秦东" + for i := 1; i <= dayInt; i++ { + tableName := fmt.Sprintf("day%v", i) + var headLoop headtype + headLoop.Name = tableName + headLoop.Label = strconv.Itoa(i) + tableHead = append(tableHead, headLoop) + userCont[tableName] = i + } + + sendData.HeadList = tableHead + sendData.DataList = append(sendData.DataList, userCont) + + cont := overallhandle.MapOut() + na := fmt.Sprintf("%v%v", "name", 1) + cont[na] = "张三" + cont["yearInt"] = yearInt + cont["monthInt"] = monthInt + cont["dayInt"] = dayInt + cont["peopleList"] = peopleList + + // overallhandle.Result(0, sendData, c) + overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(peopleList)), cont, c) +} diff --git a/apirouter/workteamapi/apigroupurl.go b/apirouter/workteamapi/apigroupurl.go index 19497b6..0ebc33f 100644 --- a/apirouter/workteamapi/apigroupurl.go +++ b/apirouter/workteamapi/apigroupurl.go @@ -20,5 +20,8 @@ func (a *ApiRouter) InitRouterGroup(route *gin.RouterGroup) { apiRouter.POST("edit_work_time_cont", apiHandle.EditWorkTimeCont) //编辑工作时间段内容 apiRouter.POST("get_period_rule_list", apiHandle.GetPeriodAndRuleList) //获取工作时段及轮询规则列表 apiRouter.POST("set_oirgin_cont", apiHandle.SetOirginCont) //写入轮询源点 + + apiRouter.POST("get_schedule", apiHandle.GetSchedule) //获取排班表 + } } diff --git a/models/personarchives.go b/models/personarchives.go index 2870a69..e7968ef 100644 --- a/models/personarchives.go +++ b/models/personarchives.go @@ -35,6 +35,7 @@ type PersonArchives struct { 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:二级主部门"` 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:照片"` } func (PersonArchives *PersonArchives) TableName() string { diff --git a/overall/overallhandle/overall_handle.go b/overall/overallhandle/overall_handle.go index 43e1dbc..b00029f 100644 --- a/overall/overallhandle/overall_handle.go +++ b/overall/overallhandle/overall_handle.go @@ -130,6 +130,21 @@ func UnixTimeToDay(timeStamp int64, timeType int) (dateStr string) { return } +// 获取整型年月日 +func GetIntTime(timeStamp int64, timeType int) (timeInt int) { + dayMonth := time.Unix(timeStamp, 0) + switch timeType { + case 1: + timeInt = dayMonth.Year() + case 2: + fmt.Printf("%v\n", dayMonth.Format("01")) + timeInt, _ = strconv.Atoi(dayMonth.Format("01")) + default: + timeInt = dayMonth.Day() + } + return +} + /* 日期转时间戳 */ @@ -791,3 +806,39 @@ func DecimalEs(value float64, weishu int) float64 { return value } + +/* +* +获取月份有多少天 +@year 年 +@month 月 +*/ +func GetYearOfMonthHaveDay(year, month int) (day int) { + //有31天的月份 + day31 := map[int]bool{ + 1: true, + 3: true, + 5: true, + 7: true, + 8: true, + 10: true, + 12: true, + } + if day31[month] == true { + return 31 + } + //有30天的月份 + day30 := map[int]bool{ + 4: true, + 6: true, + 9: true, + 11: true, + } + if day30[month] == true { + return 30 + } + if (year%4 == 0 && year%100 != 0) || (year%400 == 0) { + return 29 + } + return 28 +}