16 changed files with 2099 additions and 229 deletions
@ -0,0 +1,7 @@ |
|||
{ |
|||
// 使用 IntelliSense 了解相关属性。 |
|||
// 悬停以查看现有属性的描述。 |
|||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 |
|||
"version": "0.2.0", |
|||
"configurations": [] |
|||
} |
|||
@ -0,0 +1,500 @@ |
|||
package menus |
|||
|
|||
import ( |
|||
"appPlatform/middleware/grocerystore" |
|||
"appPlatform/models/modelshr" |
|||
"appPlatform/models/teamlog" |
|||
"appPlatform/overall" |
|||
"appPlatform/overall/publicmethod" |
|||
"encoding/json" |
|||
"fmt" |
|||
"sort" |
|||
"strconv" |
|||
"time" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-21 08:52:46 |
|||
@ 功能: 原点日期排班设定 |
|||
@ 参数 |
|||
|
|||
#dataInfo 当前日期属性 |
|||
#timeVal 当天日期参数 |
|||
#zuoXiTime 作息时间 |
|||
#lunXunShiXu 轮询列表 |
|||
|
|||
|
|||
#RedisKey说明 SchedulingTeam:StartingPoint_行政组织_年月日_倒班制度 |
|||
|
|||
@ 返回值 |
|||
|
|||
#logMap 当天安排 |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (g *GenesInfo) TeamsYuanDianRunNew(dataInfo CalendarStructure, timeVal publicmethod.DateTimeTotimes, zuoXiTime []modelshr.WorkingTimePeriod, lunXunShiXu []modelshr.PollingRules) (logMap []map[string]interface{}) { |
|||
dayRedisKey := fmt.Sprintf("SchedulingTeam:StartingPoint_%v_%v%v%v_%v", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS2) |
|||
isTrue, logContent := redisClient.Get(dayRedisKey) |
|||
var dayTimeLog []teamlog.TeamsLog |
|||
if isTrue { //redis存在获取redis数据
|
|||
json.Unmarshal([]byte(logContent), &logMap) |
|||
json.Unmarshal([]byte(logContent), &dayTimeLog) |
|||
// fmt.Printf("Step1: %v\n", logContent)
|
|||
} else { //redis不存在从数据库中获取数据
|
|||
overall.CONSTANT_DB_TeamsLog.Model(&teamlog.TeamsLog{}).Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId).Order("`sort` ASC").Find(&logMap) |
|||
if len(logMap) > 0 { |
|||
redisClient.SetRedisTime(5256000) |
|||
jsonVal, _ := json.Marshal(logMap) |
|||
redisClient.Set(dayRedisKey, string(jsonVal)) |
|||
json.Unmarshal([]byte(jsonVal), &dayTimeLog) |
|||
// fmt.Printf("Step2: %v\n", string(jsonVal))
|
|||
} else { //数据库中不存在开始计算
|
|||
|
|||
// fmt.Printf("Step3: %v\n", zuoXiTime)
|
|||
//按时间先后将工作时段进行排序排序
|
|||
sort.Slice(zuoXiTime, func(i, j int) bool { |
|||
return zuoXiTime[i].StartTime < zuoXiTime[j].StartTime |
|||
}) |
|||
|
|||
zouXinAllNum := len(zuoXiTime) //获取作息时间总长度
|
|||
yuanDianWeizhi := 1 //原点在数组中的索引位置
|
|||
for i := 0; i < zouXinAllNum; i++ { |
|||
if zuoXiTime[i].Id == g.PeriodId { |
|||
yuanDianWeizhi = i |
|||
} |
|||
zuoXiTime[i].Sort = i + 1 |
|||
} |
|||
// for i, v := range zuoXiTime {
|
|||
// if v.Id == g.PeriodId {
|
|||
// yuanDianWeizhi = i
|
|||
// }
|
|||
// v.Sort = i + 1
|
|||
// }
|
|||
// fmt.Printf("%v-%v\n", yuanDianWeizhi, zuoXiTime)
|
|||
//判断所在数组位置前边是否有数据
|
|||
if yuanDianWeizhi > 0 { |
|||
for i := yuanDianWeizhi - 1; i >= 0; i-- { |
|||
creeLunXun := LunXunGuiZe(lunXunShiXu, g.Rules, i, 1) |
|||
var logInfo teamlog.TeamsLog |
|||
overall.CONSTANT_DB_TeamsLog.Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ? AND `rankId` = ? AND `rulesId` = ? AND `teamsId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId, zuoXiTime[i].Id, creeLunXun.Id, creeLunXun.Id).Order("`sort` ASC").First(&logInfo) |
|||
if logInfo.Id == 0 { |
|||
// var logInfo teamlog.TeamsLog
|
|||
logInfo.OrgId = g.OrgId //班组ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = zuoXiTime[i].Id //班次"`
|
|||
logInfo.RulesId = creeLunXun.Id //轮询规则Id"`
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.IsmName = g.TypeName |
|||
logInfo.RankName = zuoXiTime[i].Name |
|||
logInfo.RulesName = creeLunXun.TeamName |
|||
logInfo.Sort = zuoXiTime[i].Sort |
|||
logInfo.TeamsId = creeLunXun.Id |
|||
logInfo.StartTime = zuoXiTime[i].StartTime |
|||
logInfo.EndTime = zuoXiTime[i].EndTime |
|||
overall.CONSTANT_DB_TeamsLog.Create(&logInfo) |
|||
} |
|||
|
|||
dayTimeLog = append(dayTimeLog, logInfo) |
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
} |
|||
} |
|||
//计算原点位置
|
|||
var logInfoYuan teamlog.TeamsLog |
|||
overall.CONSTANT_DB_TeamsLog.Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ? AND `rankId` = ? AND `rulesId` = ? AND `teamsId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId, g.PeriodId, g.Rules, g.Rules).Order("`sort` ASC").First(&logInfoYuan) |
|||
if logInfoYuan.Id == 0 { |
|||
logInfoYuan.OrgId = g.OrgId //班组ID"`
|
|||
logInfoYuan.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfoYuan.IsmId = g.TypeId //制度ID"`
|
|||
logInfoYuan.RankId = g.PeriodId //班次"`
|
|||
logInfoYuan.RulesId = g.Rules //轮询规则Id"`
|
|||
logInfoYuan.Days, _ = strconv.Atoi(timeVal.Days) //日"`
|
|||
logInfoYuan.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfoYuan.Years, _ = strconv.Atoi(timeVal.Years) //年"`
|
|||
logInfoYuan.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfoYuan.IsmName = g.TypeName |
|||
logInfoYuan.RankName = g.PeriodName |
|||
logInfoYuan.RulesName = g.RulesName |
|||
logInfoYuan.Sort = zuoXiTime[yuanDianWeizhi].Sort |
|||
logInfoYuan.TeamsId = g.Rules |
|||
logInfoYuan.StartTime = zuoXiTime[yuanDianWeizhi].StartTime |
|||
logInfoYuan.EndTime = zuoXiTime[yuanDianWeizhi].EndTime |
|||
overall.CONSTANT_DB_TeamsLog.Create(&logInfoYuan) |
|||
} |
|||
|
|||
dayTimeLog = append(dayTimeLog, logInfoYuan) |
|||
jsonValYuan, _ := json.Marshal(logInfoYuan) |
|||
valMapYuan := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonValYuan, &valMapYuan) |
|||
logMap = append(logMap, valMapYuan) |
|||
//计算源点后边得数据
|
|||
for j := yuanDianWeizhi + 1; j < zouXinAllNum; j++ { |
|||
creeLunXun := LunXunGuiZe(lunXunShiXu, g.Rules, j-1, 2) |
|||
var logInfo teamlog.TeamsLog |
|||
overall.CONSTANT_DB_TeamsLog.Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ? AND `rankId` = ? AND `rulesId` = ? AND `teamsId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId, zuoXiTime[j].Id, creeLunXun.Id, creeLunXun.Id).Order("`sort` ASC").First(&logInfo) |
|||
if logInfo.Id == 0 { |
|||
logInfo.OrgId = g.OrgId //班组ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = zuoXiTime[j].Id //班次"`
|
|||
logInfo.RulesId = creeLunXun.Id //轮询规则Id"`
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.IsmName = g.TypeName |
|||
logInfo.RankName = zuoXiTime[j].Name |
|||
logInfo.RulesName = creeLunXun.TeamName |
|||
logInfo.Sort = zuoXiTime[j].Sort |
|||
logInfo.TeamsId = creeLunXun.Id |
|||
logInfo.StartTime = zuoXiTime[j].StartTime |
|||
logInfo.EndTime = zuoXiTime[j].EndTime |
|||
overall.CONSTANT_DB_TeamsLog.Create(&logInfo) |
|||
} |
|||
|
|||
dayTimeLog = append(dayTimeLog, logInfo) |
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
} |
|||
|
|||
redisClient.SetRedisTime(5256000) |
|||
jsonVal, _ := json.Marshal(logMap) |
|||
redisClient.Set(dayRedisKey, string(jsonVal)) |
|||
} |
|||
} |
|||
if len(dayTimeLog) > 0 { |
|||
allRulesLog = dayTimeLog[len(dayTimeLog)-1] |
|||
} |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-20 10:14:52 |
|||
@ 功能: 获取指定日期班组情况 |
|||
@ 参数 |
|||
|
|||
#dataInfo 当前日期属性 |
|||
#timeVal 当天日期参数 |
|||
#zuoXiTime 作息时间 |
|||
#lunXunShiXu 轮询列表 |
|||
|
|||
@ 返回值 |
|||
|
|||
#logMap 当天安排 |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (g *GenesInfo) SpecifyDateTeams(dataInfo CalendarStructure, timeVal publicmethod.DateTimeTotimes, zuoXiTime []modelshr.WorkingTimePeriod, lunXunShiXu []modelshr.PollingRules) (logMap []map[string]interface{}) { |
|||
if len(zuoXiTime) < 1 && len(lunXunShiXu) < 1 { //没有设置工作时间段,也没有轮询规则
|
|||
return |
|||
} else if len(zuoXiTime) == 1 && len(lunXunShiXu) == 1 { //单一工作段,单一轮询规则
|
|||
//判断当前日期是不是周末
|
|||
if dataInfo.IsWeek { //为周末;默认双休
|
|||
if dataInfo.IsWorks { //是不是周末补班
|
|||
var logInfo teamlog.TeamsLog |
|||
logInfo.OrgId = g.OrgId //行政组织ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = zuoXiTime[0].Id //班次"`
|
|||
logInfo.RulesId = lunXunShiXu[0].Id //轮询规则Id"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.RankName = zuoXiTime[0].Name //执行倒班名称
|
|||
logInfo.RulesName = lunXunShiXu[0].TeamName //当天班组或休班
|
|||
logInfo.IsmName = g.TypeName //执行倒班制度名称
|
|||
logInfo.TeamsId = lunXunShiXu[0].Teamid //班组ID"`
|
|||
logInfo.Sort = lunXunShiXu[0].Sort //排序
|
|||
logInfo.StartTime = zuoXiTime[0].StartTime //作业开始时间
|
|||
logInfo.EndTime = zuoXiTime[0].EndTime //作业结束时间
|
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
} else { |
|||
var logInfo teamlog.TeamsLog |
|||
logInfo.OrgId = g.OrgId //行政组织ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = zuoXiTime[0].Id //班次"`
|
|||
logInfo.RulesId = 0 //轮询规则Id"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.RankName = zuoXiTime[0].Name //执行倒班名称
|
|||
logInfo.RulesName = "休" //当天班组或休班
|
|||
logInfo.IsmName = g.TypeName //执行倒班制度名称
|
|||
logInfo.TeamsId = 0 //班组ID"`
|
|||
logInfo.Sort = 0 //排序
|
|||
logInfo.StartTime = zuoXiTime[0].StartTime //作业开始时间
|
|||
logInfo.EndTime = zuoXiTime[0].EndTime //作业结束时间
|
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
} |
|||
} else if dataInfo.IsHolidays { //为假期;默认按国家法定节假日
|
|||
var logInfo teamlog.TeamsLog |
|||
logInfo.OrgId = g.OrgId //行政组织ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = zuoXiTime[0].Id //班次"`
|
|||
logInfo.RulesId = 0 //轮询规则Id"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.RankName = zuoXiTime[0].Name //执行倒班名称
|
|||
logInfo.RulesName = "休" //当天班组或休班
|
|||
logInfo.IsmName = g.TypeName //执行倒班制度名称
|
|||
logInfo.TeamsId = 0 //班组ID"`
|
|||
logInfo.Sort = 0 //排序
|
|||
logInfo.StartTime = zuoXiTime[0].StartTime //作业开始时间
|
|||
logInfo.EndTime = zuoXiTime[0].EndTime //作业结束时间
|
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
} else { |
|||
var logInfo teamlog.TeamsLog |
|||
logInfo.OrgId = g.OrgId //行政组织ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = zuoXiTime[0].Id //班次"`
|
|||
logInfo.RulesId = lunXunShiXu[0].Id //轮询规则Id"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.RankName = zuoXiTime[0].Name //执行倒班名称
|
|||
logInfo.RulesName = lunXunShiXu[0].TeamName //当天班组或休班
|
|||
logInfo.IsmName = g.TypeName //执行倒班制度名称
|
|||
logInfo.TeamsId = lunXunShiXu[0].Teamid //班组ID"`
|
|||
logInfo.Sort = lunXunShiXu[0].Sort //排序
|
|||
logInfo.StartTime = zuoXiTime[0].StartTime //作业开始时间
|
|||
logInfo.EndTime = zuoXiTime[0].EndTime //作业结束时间
|
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
} |
|||
} else { |
|||
teamSpan := 1 //班组跨度
|
|||
teamSpanStep := 1 //班组临时跨度
|
|||
lxSum := len(lunXunShiXu) |
|||
if lxSum > 1 { |
|||
for i := 0; i < lxSum-1; i++ { |
|||
if i+1 <= lxSum-1 { |
|||
if lunXunShiXu[i].Teamid == lunXunShiXu[i+1].Teamid { |
|||
teamSpanStep++ |
|||
} else { |
|||
teamSpanStep = 1 |
|||
} |
|||
if teamSpanStep >= teamSpan { |
|||
teamSpan = teamSpanStep |
|||
} |
|||
} |
|||
} |
|||
} |
|||
AnalysisWorkRule(timeVal, zuoXiTime) |
|||
fmt.Printf("连续跨度:%v\n", teamSpan) |
|||
//根据班组连续跨度进行班组安排
|
|||
switch teamSpan { |
|||
case 2: //一班同一工作段上连续两天
|
|||
case 3: //一班同一工作段上连续三天
|
|||
case 4: //一班同一工作段上连续四天
|
|||
case 5: //一班同一工作段上连续五天
|
|||
case 6: //一班同一工作段上连续六天
|
|||
case 7: //一班同一工作段上连续七天
|
|||
default: //班组没有连续跨度,单一顺班
|
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-20 14:00:11 |
|||
@ 功能: 计算当前工作时间段在当天还是明天及所在工作段顺位 |
|||
#timeVal 当前时间 |
|||
#zuoXiTime 工作时段 |
|||
*/ |
|||
func AnalysisWorkRule(timeVal publicmethod.DateTimeTotimes, zuoXiTime []modelshr.WorkingTimePeriod) []modelshr.WorkingTimePeriod { |
|||
if len(zuoXiTime) <= 2 { //根据现实生产逻辑。当一天轮询工作时间不超过2个时间段的时候。不会产生快日期排班情况
|
|||
return zuoXiTime |
|||
} else { |
|||
sort.Slice(zuoXiTime, func(i, j int) bool { |
|||
return zuoXiTime[i].StartTime < zuoXiTime[j].StartTime |
|||
}) |
|||
// for i, v := range zuoXiTime {
|
|||
// canji := v.Sort - i
|
|||
// fmt.Printf("%v------------------> %v\n", canji, v)
|
|||
// }
|
|||
} |
|||
return zuoXiTime |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-20 16:03:42 |
|||
@ 功能: 计算返回轮询规则信息 |
|||
#lunXunShiXu 轮询规则 |
|||
#startId 开始的点位 |
|||
#step 执行几步 |
|||
#posNeg 前进还是后退 1:前进,2:后退 |
|||
*/ |
|||
func LunXunGuiZe(lunXunShiXu []modelshr.PollingRules, startId int64, step, posNeg int) (lunXunGuiZe modelshr.PollingRules) { |
|||
creetStep := 0 |
|||
for i, v := range lunXunShiXu { |
|||
if v.Id == startId { |
|||
creetStep = i |
|||
} |
|||
} |
|||
// creetStep = creetStep
|
|||
fallNum := len(lunXunShiXu) //总共多少步伐
|
|||
sendNum := 0 |
|||
if posNeg == 1 { //前进
|
|||
sendNum = ((creetStep-step)%fallNum+fallNum)%fallNum - 1 |
|||
if sendNum < 0 { |
|||
sendNum = fallNum - 1 |
|||
} |
|||
fmt.Printf("前进---->%v\n", sendNum) |
|||
fmt.Printf("前进---->%v---->%v---->%v\n", creetStep, step, fallNum) |
|||
} else { |
|||
sendNum = (creetStep + step) % fallNum |
|||
fmt.Printf("后退---->%v---->%v---->%v---->%v\n", sendNum, creetStep, step, fallNum) |
|||
} |
|||
lunXunGuiZe = lunXunShiXu[sendNum] |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-24 09:35:42 |
|||
@ 功能: 长白班解析 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (g *GenesInfo) changBaiBan(WeekAllDay []CalendarStructure, zuoXiTimeOne modelshr.WorkingTimePeriod, lunXunShiXu []modelshr.TeamsRules) map[string]interface{} { |
|||
isWeek := publicmethod.MapOut[string]() |
|||
if len(WeekAllDay) < 1 { |
|||
return isWeek |
|||
} |
|||
|
|||
var dayTimeLog []teamlog.TeamsLog |
|||
for i, v := range WeekAllDay { |
|||
var logMap []map[string]interface{} |
|||
var timeVal publicmethod.DateTimeTotimes |
|||
timeVal.BaisStrToTime(v.Date) |
|||
dayRedisKey := fmt.Sprintf("SchedulingTeam:StartingPoint_%v_%v%v%v_%v_2", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS2) |
|||
isTrue, logContent := redisClient.Get(dayRedisKey) |
|||
if isTrue { //redis存在获取redis数据
|
|||
json.Unmarshal([]byte(logContent), &logMap) |
|||
json.Unmarshal([]byte(logContent), &dayTimeLog) |
|||
// fmt.Printf("Step1: %v\n", logContent)
|
|||
} else { //redis不存在从数据库中获取数据
|
|||
overall.CONSTANT_DB_TeamsLog.Model(&teamlog.TeamsLog{}).Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId).Order("`sort` ASC").Find(&logMap) |
|||
if len(logMap) > 0 { //数据库中存在直接用数据的数据
|
|||
redisClient.SetRedisTime(5256000) |
|||
jsonVal, _ := json.Marshal(logMap) |
|||
redisClient.Set(dayRedisKey, string(jsonVal)) |
|||
json.Unmarshal([]byte(jsonVal), &dayTimeLog) |
|||
} else { //数据库中不存在开始计算
|
|||
var logInfo teamlog.TeamsLog |
|||
overall.CONSTANT_DB_TeamsLog.Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ? AND `rankId` = ? AND `rulesId` = ? AND `teamsId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId, zuoXiTimeOne.Id, lunXunShiXu[i].TeamsId, lunXunShiXu[i].TeamsId).Order("`sort` ASC").First(&logInfo) |
|||
if logInfo.Id == 0 { |
|||
logInfo.OrgId = g.OrgId //班组ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = zuoXiTimeOne.Id //班次"`
|
|||
if lunXunShiXu[i].CycleWorkTime != 0 { |
|||
logInfo.RulesId = lunXunShiXu[i].TeamsId //轮询规则Id"`
|
|||
} |
|||
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.IsmName = g.TypeName |
|||
logInfo.RankName = zuoXiTimeOne.Name |
|||
if !v.IsHolidays { |
|||
if lunXunShiXu[i].CycleWorkTime != 0 { |
|||
logInfo.RulesName = lunXunShiXu[i].TeamsName |
|||
fmt.Printf("i ----1---->: %v\n", i) |
|||
} else { |
|||
if v.IsWorks { //是不是周末补班
|
|||
logInfo.RulesName = "补" |
|||
fmt.Printf("i ----2---->: %v\n", i) |
|||
} else { |
|||
if lunXunShiXu[i].CycleWorkName == "" { |
|||
logInfo.RulesName = "休" |
|||
fmt.Printf("i ----3---->: %v\n", i) |
|||
} else { |
|||
logInfo.RulesName = lunXunShiXu[i].CycleWorkName |
|||
fmt.Printf("i ----4---->: %v\n", i) |
|||
} |
|||
} |
|||
} |
|||
} else { |
|||
logInfo.RulesName = "假日" |
|||
} |
|||
|
|||
logInfo.Sort = zuoXiTimeOne.Sort |
|||
if lunXunShiXu[i].CycleWorkTime != 0 { |
|||
logInfo.TeamsId = lunXunShiXu[i].TeamsId |
|||
} |
|||
logInfo.StartTime = zuoXiTimeOne.StartTime |
|||
logInfo.EndTime = zuoXiTimeOne.EndTime |
|||
overall.CONSTANT_DB_TeamsLog.Create(&logInfo) |
|||
} |
|||
dayTimeLog = append(dayTimeLog, logInfo) |
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
redisClient.SetRedisTime(5256000) |
|||
jsonValLog, _ := json.Marshal(logMap) |
|||
redisClient.Set(dayRedisKey, string(jsonValLog)) |
|||
} |
|||
} |
|||
isWeek[v.Date] = logMap |
|||
jscvv, _ := json.Marshal(lunXunShiXu) |
|||
fmt.Printf("\n\n\n\n\n\ni%v--------->v:%v----->lx:%v----->lx:%v\n\n\n\n\n\n", i, v, lunXunShiXu[i], string(jscvv)) |
|||
} |
|||
if len(dayTimeLog) > 0 { |
|||
allRulesLog = dayTimeLog[len(dayTimeLog)-1] |
|||
} |
|||
return isWeek |
|||
} |
|||
@ -0,0 +1,866 @@ |
|||
package menus |
|||
|
|||
import ( |
|||
"appPlatform/middleware/grocerystore" |
|||
"appPlatform/models/modelshr" |
|||
"appPlatform/models/teamlog" |
|||
"appPlatform/overall" |
|||
"appPlatform/overall/publicmethod" |
|||
"encoding/json" |
|||
"fmt" |
|||
"sort" |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-21 15:41:06 |
|||
@ 功能: 添加工作时间设置 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) AddTeamTime(c *gin.Context) { |
|||
var requestData SetWorkTime |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
if requestData.Name == "" { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
if len(requestData.List) < 1 { |
|||
publicmethod.Result(1, requestData, c, "没有划分工作时间段!") |
|||
return |
|||
} |
|||
isTrue := true |
|||
for _, v := range requestData.List { |
|||
if v.Title == "" || v.StartTime == "" || v.EndTime == "" { |
|||
isTrue = false |
|||
} |
|||
} |
|||
if !isTrue { |
|||
publicmethod.Result(1, requestData, c, "您划分的工作时间段,有不符合规定的!请改正!") |
|||
return |
|||
} |
|||
timeKey := publicmethod.GetUUid(5) |
|||
//工作时间段类型
|
|||
var workTimeType modelshr.WorkTimeType |
|||
//判断是否有同类型的安排
|
|||
err = workTimeType.GetCont(map[string]interface{}{"`name`": requestData.Name}, "`id`") |
|||
if err == nil { |
|||
publicmethod.Result(1, requestData, c, "该名称已经存在!请不要重复添加!") |
|||
return |
|||
} |
|||
workTimeType.Id = timeKey |
|||
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() |
|||
//工作时段
|
|||
var workTimeList []modelshr.WorkingTimePeriod |
|||
for i, lv := range requestData.List { |
|||
var workTimeCont modelshr.WorkingTimePeriod |
|||
workTimeCont.Name = lv.Title //type:string comment:工作时间段名称 version:2022-11-13 16:59
|
|||
workTimeCont.Time = time.Now().Unix() //type:int64 comment:编辑时间;0 version:2022-11-13 16:59
|
|||
workTimeCont.TypeId = timeKey //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 |
|||
workTimeCont.Sort = i + 1 |
|||
workTimeList = append(workTimeList, workTimeCont) |
|||
} |
|||
err = overall.CONSTANT_DB_HR.Create(&workTimeType).Error |
|||
if err != nil { |
|||
publicmethod.Result(104, requestData, c) |
|||
return |
|||
} |
|||
WriteWorkTime(timeKey, workTimeList) |
|||
publicmethod.Result(0, requestData, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2022-12-13 18:06:08 |
|||
@ 功能: 写入工作时段 |
|||
@ 参数 |
|||
|
|||
#key 类型ID |
|||
#workTimeList 时段列表 |
|||
|
|||
@ 返回值 |
|||
|
|||
#err 返回状态 |
|||
|
|||
@ 方法原型 |
|||
|
|||
# WriteWorkTime(key int64, workTimeList []modelshr.WorkingTimePeriod) (err error) |
|||
*/ |
|||
func WriteWorkTime(key int64, workTimeList []modelshr.WorkingTimePeriod) (err error) { |
|||
var workTimeCont modelshr.WorkingTimePeriod |
|||
workTimeCont.DelCont(map[string]interface{}{"`type_id`": key}) |
|||
err = overall.CONSTANT_DB_HR.Create(&workTimeList).Error |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2022-12-14 09:20:07 |
|||
@ 功能: 编辑时间段 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) EditWorkTimeCont(c *gin.Context) { |
|||
var requestData EditWorkTimeConts |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
if requestData.Name == "" { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
|
|||
if len(requestData.List) < 1 { |
|||
publicmethod.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 { |
|||
publicmethod.Result(1, requestData, c, "您划分的工作时间段,有不符合规定的!请改正!") |
|||
return |
|||
} |
|||
wher := publicmethod.MapOut[string]() |
|||
wher["id"] = requestData.Id |
|||
var oldCont modelshr.WorkTimeType |
|||
err = oldCont.GetCont(wher) |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
editCont := publicmethod.MapOut[string]() |
|||
editCont["name"] = requestData.Name |
|||
// editCont["rule"] = requestData.Rule
|
|||
editCont["time"] = time.Now().Unix() |
|||
|
|||
err = oldCont.EiteCont(wher, editCont) |
|||
if err != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
|
|||
//工作时段
|
|||
EditPeriodTime(oldCont.Id, requestData.List) |
|||
|
|||
publicmethod.Result(0, err, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2022-12-16 17:10:13 |
|||
@ 功能: 编辑工作时段 |
|||
@ 参数 |
|||
|
|||
#typeId 类型识别符 |
|||
#ruleList 分班时间表 |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func EditPeriodTime(typeId int64, ruleList []TemaTimes) { |
|||
var workTimeCont modelshr.WorkingTimePeriod |
|||
workTimeListCont, _ := workTimeCont.ContMap(map[string]interface{}{"`type_id`": typeId}) |
|||
var editId []string |
|||
var saveData []modelshr.WorkingTimePeriod |
|||
for i, v := range ruleList { |
|||
if v.Id != "" { |
|||
var workTimeContJudge modelshr.WorkingTimePeriod |
|||
err := workTimeContJudge.GetCont(map[string]interface{}{"`id`": v.Id}) |
|||
if err == nil { |
|||
if publicmethod.IsInTrue[string](v.Id, editId) == false { |
|||
editId = append(editId, v.Id) |
|||
} |
|||
|
|||
editCont := publicmethod.MapOut[string]() |
|||
editCont["`sort`"] = i + 1 |
|||
editCont["`state`"] = 1 |
|||
editCont["`name`"] = v.Title |
|||
editCont["`time`"] = time.Now().Unix() |
|||
editCont["`start_time`"] = v.StartTime |
|||
editCont["`end_time`"] = v.EndTime |
|||
var workTimeContEs modelshr.WorkingTimePeriod |
|||
workTimeContEs.EiteCont(map[string]interface{}{"`id`": v.Id}, editCont) |
|||
} else { |
|||
var workTimeContAdd modelshr.WorkingTimePeriod |
|||
workTimeContAdd.Sort = i + 1 |
|||
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 modelshr.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
|
|||
workTimeContAdd.Sort = i + 1 |
|||
saveData = append(saveData, workTimeContAdd) |
|||
} |
|||
} |
|||
//将不在使用的项目删除
|
|||
for _, dv := range workTimeListCont { |
|||
idStr := strconv.FormatInt(dv.Id, 10) |
|||
if publicmethod.IsInTrue[string](idStr, editId) == false { |
|||
editCont := publicmethod.MapOut[string]() |
|||
editCont["`state`"] = 3 |
|||
editCont["`time`"] = time.Now().Unix() |
|||
var workTimeContEss modelshr.WorkingTimePeriod |
|||
workTimeContEss.EiteCont(map[string]interface{}{"`id`": dv.Id}, editCont) |
|||
} |
|||
} |
|||
if len(saveData) > 0 { |
|||
overall.CONSTANT_DB_HR.Create(&saveData) |
|||
} |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-23 09:41:25 |
|||
@ 功能: 编辑制度轮询规则 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) SaveCycleRules(c *gin.Context) { |
|||
var requestData JieShoeTeamsRules |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
if len(requestData.List) <= 0 { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
teamIsOk := true |
|||
cycleIsOk := false |
|||
for _, v := range requestData.List { |
|||
if v.Id == "" || len(v.List) <= 0 { |
|||
teamIsOk = false |
|||
} |
|||
for _, lv := range v.List { |
|||
if lv.Id != 0 { |
|||
cycleIsOk = true |
|||
} |
|||
} |
|||
} |
|||
if !teamIsOk || !cycleIsOk { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
var teamsRulesInfo modelshr.TeamsRules |
|||
teamsRulesInfo.DelCont(map[string]interface{}{"`ruleTypeId`": requestData.Id}) |
|||
|
|||
var sendMap []interface{} |
|||
for _, v := range requestData.List { |
|||
|
|||
for _, lv := range v.List { |
|||
var teamsRulesInfoNew modelshr.TeamsRules |
|||
teamsRulesInfoNew.RuleTypeId, _ = strconv.ParseInt(requestData.Id, 10, 64) |
|||
teamsRulesInfoNew.RuleTypeName = requestData.Name |
|||
teamsRulesInfoNew.Cycle = requestData.Cycle |
|||
teamsRulesInfoNew.TeamsId, _ = strconv.ParseInt(v.Id, 10, 64) |
|||
teamsRulesInfoNew.TeamsName = v.Name |
|||
|
|||
teamsRulesInfoNew.CycleSort = lv.Id |
|||
teamsRulesInfoNew.CycleName = lv.Name |
|||
teamsRulesInfoNew.CycleWorkTime, _ = strconv.ParseInt(lv.Value, 10, 64) |
|||
if lv.Value != "" { |
|||
teamsRulesInfoNew.CycleWorkName = lv.Days |
|||
} |
|||
teamsRulesInfoNew.Time = time.Now().Unix() |
|||
sendMap = append(sendMap, teamsRulesInfoNew) |
|||
overall.CONSTANT_DB_HR.Create(&teamsRulesInfoNew) |
|||
} |
|||
} |
|||
publicmethod.Result(0, sendMap, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-23 10:49:25 |
|||
@ 功能: 获取轮询规则 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) GainCycleRule(c *gin.Context) { |
|||
var requestData publicmethod.PublicId |
|||
err := c.ShouldBindJSON(&requestData) |
|||
var sendData JieShoeTeamsRules |
|||
if err != nil { |
|||
publicmethod.Result(200, sendData, c) |
|||
return |
|||
} |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(200, sendData, c) |
|||
return |
|||
} |
|||
var teamsRulesList []modelshr.TeamsRules |
|||
overall.CONSTANT_DB_HR.Where("`ruleTypeId` = ?", requestData.Id).Find(&teamsRulesList) |
|||
if len(teamsRulesList) < 1 { |
|||
publicmethod.Result(200, sendData, c) |
|||
return |
|||
} |
|||
|
|||
var workTimeTypeInfo modelshr.WorkTimeType |
|||
err = workTimeTypeInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`name`") |
|||
if err != nil { |
|||
publicmethod.Result(200, sendData, c) |
|||
return |
|||
} |
|||
sendData.Id = requestData.Id |
|||
sendData.Name = workTimeTypeInfo.Name |
|||
|
|||
// var workPeriodList []modelshr.WorkingTimePeriod
|
|||
// overall.CONSTANT_DB_HR.Where("`type_id` = ?", requestData.Id).Find(&workPeriodList)
|
|||
// if len(workPeriodList) < 1 {
|
|||
// publicmethod.Result(200, sendData, c)
|
|||
// return
|
|||
// }
|
|||
var teamIdAry []int64 |
|||
var teamsAry []RulesInfo |
|||
for _, v := range teamsRulesList { |
|||
if !publicmethod.IsInTrue[int64](v.TeamsId, teamIdAry) { |
|||
teamIdAry = append(teamIdAry, v.TeamsId) |
|||
var teamsInfo RulesInfo |
|||
teamsInfo.Id = strconv.FormatInt(v.TeamsId, 10) |
|||
teamsInfo.Name = v.TeamsName |
|||
teamsAry = append(teamsAry, teamsInfo) |
|||
} |
|||
} |
|||
if len(teamsAry) < 1 { |
|||
publicmethod.Result(200, sendData, c) |
|||
return |
|||
} |
|||
for i, v := range teamsAry { |
|||
for _, tv := range teamsRulesList { |
|||
tvId := strconv.FormatInt(tv.TeamsId, 10) |
|||
// fmt.Printf("%v------%v\n", tvId, v.Id)
|
|||
if tvId == v.Id { |
|||
var cycleInfo CycleRulesInfo |
|||
cycleInfo.Id = tv.CycleSort |
|||
cycleInfo.Name = tv.CycleName |
|||
if tv.CycleWorkTime != 0 { |
|||
cycleInfo.Value = strconv.FormatInt(tv.CycleWorkTime, 10) |
|||
} |
|||
fmt.Printf("%v------%v------%v\n", tvId, tv.CycleWorkTime, cycleInfo.Value) |
|||
cycleInfo.Days = tv.CycleWorkName |
|||
sendData.Cycle = tv.Cycle |
|||
teamsAry[i].List = append(teamsAry[i].List, cycleInfo) |
|||
} |
|||
} |
|||
} |
|||
sendData.List = teamsAry |
|||
publicmethod.Result(0, sendData, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-23 14:47:50 |
|||
@ 功能: 解析日历生成排班顺序(新版本) |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) AnalysisMonthRulersNews(c *gin.Context) { |
|||
var requestData AnYuePaiBan |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.OrgId == "" { |
|||
publicmethod.Result(1, requestData, c, "未知行政单位") |
|||
return |
|||
} |
|||
var sendMonthList []interface{} |
|||
orgIdInt, _ := strconv.ParseInt(requestData.OrgId, 10, 64) |
|||
menuCont, cureeOrgId, err := CureeRunRules(orgIdInt) |
|||
fmt.Printf("%v\n", cureeOrgId) |
|||
if err != nil { |
|||
publicmethod.Result(200, sendMonthList, c) |
|||
return |
|||
} |
|||
//获取源点起始工作时间段
|
|||
menuCont.BegainTime = publicmethod.UnixTimeToDay(menuCont.StartTime, 14) |
|||
menuCont.TypeIdStr = strconv.FormatInt(menuCont.TypeId, 10) |
|||
//获取倒班规则
|
|||
var paiBanType modelshr.WorkTimeType |
|||
paiBanType.GetCont(map[string]interface{}{"`id`": menuCont.TypeId}, " `name`") |
|||
menuCont.TypeName = paiBanType.Name |
|||
|
|||
//作息时间
|
|||
var zuoXiTime []modelshr.WorkingTimePeriod |
|||
overall.CONSTANT_DB_HR.Where("`state` = 1 AND `type_id` = ?", menuCont.TypeId).Order("`sort` ASC").Find(&zuoXiTime) |
|||
//轮询规则
|
|||
|
|||
var lunXunShiXu []modelshr.TeamsRules |
|||
overall.CONSTANT_DB_HR.Where("`ruleTypeId` = ?", menuCont.TypeId).Find(&lunXunShiXu) |
|||
if len(zuoXiTime) < 1 || len(lunXunShiXu) < 1 { |
|||
for _, v := range requestData.MonthAllDay { |
|||
var listSynv CalendarList |
|||
sendMonthList = append(sendMonthList, TimeHaveAry(v, listSynv.List)) |
|||
} |
|||
publicmethod.Result(200, sendMonthList, c) |
|||
return |
|||
} |
|||
cycle := 1 |
|||
for _, v := range lunXunShiXu { |
|||
cycle = v.Cycle |
|||
} |
|||
// val,_:=json.Marshal(menuCont)
|
|||
// sendMa := publicmethod.MapOut[string]()
|
|||
// sendMa["menuCont"] = menuCont
|
|||
// sendMa["lunXunShiXu"] = lunXunShiXu
|
|||
// sendMa["orgIdInt"] = orgIdInt
|
|||
// publicmethod.Result(200, sendMa, c)
|
|||
// return
|
|||
//Step 4: 计算当前时间段与原点关系
|
|||
switch cycle { |
|||
case 2: |
|||
//作息时间
|
|||
var zuoXiTimeOne modelshr.WorkingTimePeriod |
|||
overall.CONSTANT_DB_HR.Where("`state` = 1 AND `type_id` = ?", menuCont.TypeId).Order("`sort` ASC").First(&zuoXiTimeOne) |
|||
for _, v := range requestData.MonthAllDay { |
|||
var listSynv CalendarList |
|||
inDate := menuCont.changBaiBan(v, zuoXiTimeOne, lunXunShiXu) |
|||
listSynv.List = append(listSynv.List, inDate) |
|||
sendMonthList = append(sendMonthList, TimeHaveAry(v, listSynv.List)) |
|||
} |
|||
default: |
|||
lastDayNumber := 0 |
|||
var starTemasTime publicmethod.DateTimeTotimes |
|||
starTemasTime.BaisStrToTime(menuCont.BegainTime) |
|||
for _, v := range requestData.MonthAllDay { |
|||
var listSynv CalendarList |
|||
for _, wv := range v { |
|||
var wvTimeAll publicmethod.DateTimeTotimes |
|||
wvTimeAll.BaisStrToTime(wv.Date) |
|||
if wvTimeAll.AllTime < starTemasTime.AllTime { |
|||
lastDayNumber++ |
|||
} else if wvTimeAll.AllTime == starTemasTime.AllTime { |
|||
listAry := menuCont.RuleYuanDianRunNew(wv, wvTimeAll, zuoXiTime, lunXunShiXu) |
|||
inDate := publicmethod.MapOut[string]() |
|||
inDate[wv.Date] = listAry |
|||
listSynv.List = append(listSynv.List, inDate) |
|||
} else { |
|||
sjc := ((wvTimeAll.AllTime - starTemasTime.AllTime) / 86400) + 1 |
|||
listAry := menuCont.SpecifyDateTeamsNew(wv, wvTimeAll, zuoXiTime, lunXunShiXu, sjc) |
|||
inDate := publicmethod.MapOut[string]() |
|||
inDate[wv.Date] = listAry |
|||
listSynv.List = append(listSynv.List, inDate) |
|||
} |
|||
|
|||
} |
|||
sendMonthList = append(sendMonthList, TimeHaveAry(v, listSynv.List)) |
|||
} |
|||
} |
|||
|
|||
publicmethod.Result(0, sendMonthList, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-21 08:52:46 |
|||
@ 功能: 原点日期排班设定 |
|||
@ 参数 |
|||
|
|||
#dataInfo 当前日期属性 |
|||
#timeVal 当天日期参数 |
|||
#zuoXiTime 作息时间 |
|||
#lunXunShiXu 轮询列表 |
|||
|
|||
|
|||
#RedisKey说明 SchedulingTeam:StartingPoint_行政组织_年月日_倒班制度 |
|||
|
|||
@ 返回值 |
|||
|
|||
#logMap 当天安排 |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (g *GenesInfo) RuleYuanDianRunNew(dataInfo CalendarStructure, timeVal publicmethod.DateTimeTotimes, zuoXiTime []modelshr.WorkingTimePeriod, lunXunShiXu []modelshr.TeamsRules) (logMap []map[string]interface{}) { |
|||
dayRedisKey := fmt.Sprintf("SchedulingTeam:StartingPoint_%v_%v%v%v_%v_1", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS2) |
|||
isTrue, logContent := redisClient.Get(dayRedisKey) |
|||
var dayTimeLog []teamlog.TeamsLog |
|||
if isTrue { //redis存在获取redis数据
|
|||
json.Unmarshal([]byte(logContent), &logMap) |
|||
json.Unmarshal([]byte(logContent), &dayTimeLog) |
|||
// fmt.Printf("Step1: %v\n", logContent)
|
|||
} else { //redis不存在从数据库中获取数据
|
|||
overall.CONSTANT_DB_TeamsLog.Model(&teamlog.TeamsLog{}).Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId).Order("`sort` ASC").Find(&logMap) |
|||
if len(logMap) > 0 { //数据库中存在直接用数据的数据
|
|||
redisClient.SetRedisTime(5256000) |
|||
jsonVal, _ := json.Marshal(logMap) |
|||
redisClient.Set(dayRedisKey, string(jsonVal)) |
|||
json.Unmarshal([]byte(jsonVal), &dayTimeLog) |
|||
} else { //数据库中不存在开始计算
|
|||
sort.Slice(zuoXiTime, func(i, j int) bool { |
|||
return zuoXiTime[i].StartTime < zuoXiTime[j].StartTime |
|||
}) |
|||
|
|||
for _, v := range zuoXiTime { |
|||
cyclesInfo := GainRuleCycleTeams(lunXunShiXu, 1, v.Id) |
|||
fmt.Printf("cyclesInfo--->%v\n", cyclesInfo) |
|||
var logInfo teamlog.TeamsLog |
|||
overall.CONSTANT_DB_TeamsLog.Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ? AND `rankId` = ? AND `rulesId` = ? AND `teamsId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId, v.Id, cyclesInfo.TeamsId, cyclesInfo.TeamsId).Order("`sort` ASC").First(&logInfo) |
|||
if logInfo.Id == 0 { |
|||
logInfo.OrgId = g.OrgId //班组ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = v.Id //班次"`
|
|||
logInfo.RulesId = cyclesInfo.TeamsId //轮询规则Id"`
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.IsmName = g.TypeName |
|||
logInfo.RankName = v.Name |
|||
logInfo.RulesName = cyclesInfo.TeamsName |
|||
logInfo.Sort = v.Sort |
|||
logInfo.TeamsId = cyclesInfo.TeamsId |
|||
logInfo.StartTime = v.StartTime |
|||
logInfo.EndTime = v.EndTime |
|||
overall.CONSTANT_DB_TeamsLog.Create(&logInfo) |
|||
} |
|||
dayTimeLog = append(dayTimeLog, logInfo) |
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
} |
|||
redisClient.SetRedisTime(5256000) |
|||
jsonVal, _ := json.Marshal(logMap) |
|||
redisClient.Set(dayRedisKey, string(jsonVal)) |
|||
} |
|||
} |
|||
if len(dayTimeLog) > 0 { |
|||
allRulesLog = dayTimeLog[len(dayTimeLog)-1] |
|||
} |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-23 16:03:33 |
|||
@ 功能: 获取轮询中的班组 |
|||
#lunXunShiXu 轮询规则 |
|||
#sort 第几步 |
|||
#cycleWorkTime 工作段Id |
|||
*/ |
|||
func GainRuleCycleTeams(lunXunShiXu []modelshr.TeamsRules, sort int64, cycleWorkTime int64) (cycleInfo modelshr.TeamsRules) { |
|||
fmt.Printf("\n\n\n\n\n 获取轮询中的班组---------sort:%v--------cycleWorkTime:%v----lunXunShiXu:%v--》\n\n\n\n\n ", sort, cycleWorkTime, lunXunShiXu) |
|||
for _, v := range lunXunShiXu { |
|||
if v.CycleSort == sort && v.CycleWorkTime == cycleWorkTime { |
|||
cycleInfo = v |
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-23 16:27:05 |
|||
@ 功能: |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (g *GenesInfo) SpecifyDateTeamsNew(dataInfo CalendarStructure, timeVal publicmethod.DateTimeTotimes, zuoXiTime []modelshr.WorkingTimePeriod, lunXunShiXu []modelshr.TeamsRules, differeTime int64) (logMap []map[string]interface{}) { |
|||
// differeTime = differeTime + 1
|
|||
fmt.Printf("\n\n\n\n\ndataInfo---1---->%v---->%v---->%v\n\n\n\n\n", timeVal.Years, timeVal.Months, timeVal.Days) |
|||
dayRedisKey := fmt.Sprintf("SchedulingTeam:StartingPoint_%v_%v%v%v_%v_1", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS2) |
|||
isTrue, logContent := redisClient.Get(dayRedisKey) |
|||
var dayTimeLog []teamlog.TeamsLog |
|||
// isTrue = false
|
|||
if isTrue { //redis存在获取redis数据
|
|||
json.Unmarshal([]byte(logContent), &logMap) |
|||
json.Unmarshal([]byte(logContent), &dayTimeLog) |
|||
// fmt.Printf("Step1: %v\n", logContent)
|
|||
} else { //redis不存在从数据库中获取数据
|
|||
var teamIdAry []int64 |
|||
for _, v := range lunXunShiXu { |
|||
if !publicmethod.IsInTrue[int64](v.CycleWorkTime, teamIdAry) { |
|||
teamIdAry = append(teamIdAry, v.CycleWorkTime) |
|||
} |
|||
} |
|||
teamMap := make(map[int64][]modelshr.TeamsRules) |
|||
|
|||
fmt.Printf("teanAry---3---->%v\n", teamIdAry) |
|||
|
|||
for _, v := range teamIdAry { |
|||
var teanAry []modelshr.TeamsRules |
|||
for _, tv := range lunXunShiXu { |
|||
if v == tv.CycleWorkTime { |
|||
teanAry = append(teanAry, tv) |
|||
} |
|||
} |
|||
fmt.Printf("teanAry------->%v\n", teanAry) |
|||
if len(teanAry) > 0 { |
|||
teamMap[v] = append(teamMap[v], teanAry...) |
|||
} |
|||
fmt.Printf("teanAry---1---->%v\n", teamMap) |
|||
} |
|||
overall.CONSTANT_DB_TeamsLog.Model(&teamlog.TeamsLog{}).Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId).Order("`sort` ASC").Find(&logMap) |
|||
if len(logMap) > 0 { //数据库中存在直接用数据的数据
|
|||
redisClient.SetRedisTime(5256000) |
|||
jsonVal, _ := json.Marshal(logMap) |
|||
redisClient.Set(dayRedisKey, string(jsonVal)) |
|||
json.Unmarshal([]byte(jsonVal), &dayTimeLog) |
|||
} else { //数据库中不存在开始计算
|
|||
sort.Slice(zuoXiTime, func(i, j int) bool { |
|||
return zuoXiTime[i].StartTime < zuoXiTime[j].StartTime |
|||
}) |
|||
for _, v := range zuoXiTime { |
|||
var ruleStep int64 = 1 |
|||
if workVal, isOk := teamMap[v.Id]; isOk { |
|||
lenNunm := len(workVal) |
|||
if differeTime > int64(lenNunm) { |
|||
|
|||
ruleStep = int64(differeTime) % int64(lenNunm) |
|||
if ruleStep == 0 { |
|||
ruleStep = int64(lenNunm) |
|||
} |
|||
} else { |
|||
ruleStep = int64(differeTime) |
|||
} |
|||
fmt.Printf("\n\n\n\ncyclesInfo--->%v--->%v\n\n\n\n", lenNunm, differeTime) |
|||
} |
|||
cyclesInfo := GainRuleCycleTeams(lunXunShiXu, ruleStep, v.Id) |
|||
fmt.Printf("\n\n\n\ncyclesInfo--->%v--->%v\n\n\n\n", cyclesInfo, ruleStep) |
|||
var logInfo teamlog.TeamsLog |
|||
overall.CONSTANT_DB_TeamsLog.Where("`orgId` = ? AND `years` = ? AND `months` = ? AND `days` = ? AND `ismId` = ? AND `rankId` = ? AND `rulesId` = ? AND `teamsId` = ?", g.OrgId, timeVal.Years, timeVal.Months, timeVal.Days, g.TypeId, v.Id, cyclesInfo.TeamsId, cyclesInfo.TeamsId).Order("`sort` ASC").First(&logInfo) |
|||
if logInfo.Id == 0 { |
|||
logInfo.OrgId = g.OrgId //班组ID"`
|
|||
logInfo.TeamsTime = timeVal.AllTime //日期"`
|
|||
logInfo.IsmId = g.TypeId //制度ID"`
|
|||
logInfo.RankId = v.Id //班次"`
|
|||
logInfo.RulesId = cyclesInfo.TeamsId //轮询规则Id"`
|
|||
logInfo.Days, _ = strconv.Atoi(timeVal.Days) //日"`
|
|||
logInfo.Months, _ = strconv.Atoi(timeVal.Months) //月"`
|
|||
logInfo.Years, _ = strconv.Atoi(timeVal.Years) //年"`
|
|||
logInfo.Time = time.Now().Unix() //编辑时间"`
|
|||
logInfo.IsmName = g.TypeName |
|||
logInfo.RankName = v.Name |
|||
logInfo.RulesName = cyclesInfo.TeamsName |
|||
logInfo.Sort = v.Sort |
|||
logInfo.TeamsId = cyclesInfo.TeamsId |
|||
logInfo.StartTime = v.StartTime |
|||
logInfo.EndTime = v.EndTime |
|||
overall.CONSTANT_DB_TeamsLog.Create(&logInfo) |
|||
} |
|||
dayTimeLog = append(dayTimeLog, logInfo) |
|||
jsonVal, _ := json.Marshal(logInfo) |
|||
valMap := publicmethod.MapOut[string]() |
|||
json.Unmarshal(jsonVal, &valMap) |
|||
logMap = append(logMap, valMap) |
|||
} |
|||
redisClient.SetRedisTime(5256000) |
|||
jsonVal, _ := json.Marshal(logMap) |
|||
redisClient.Set(dayRedisKey, string(jsonVal)) |
|||
} |
|||
} |
|||
if len(dayTimeLog) > 0 { |
|||
allRulesLog = dayTimeLog[len(dayTimeLog)-1] |
|||
} |
|||
return |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2025-01-24 11:35:54 |
|||
@ 功能: |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) AnalysisWeekRulers(c *gin.Context) { |
|||
var requestData AnZhouPaiBan |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.OrgId == "" { |
|||
publicmethod.Result(1, requestData, c, "未知行政单位") |
|||
return |
|||
} |
|||
var sendMonthList interface{} |
|||
orgIdInt, _ := strconv.ParseInt(requestData.OrgId, 10, 64) |
|||
menuCont, cureeOrgId, err := CureeRunRules(orgIdInt) |
|||
fmt.Printf("%v\n", cureeOrgId) |
|||
if err != nil { |
|||
publicmethod.Result(200, sendMonthList, c) |
|||
return |
|||
} |
|||
//获取源点起始工作时间段
|
|||
menuCont.BegainTime = publicmethod.UnixTimeToDay(menuCont.StartTime, 14) |
|||
menuCont.TypeIdStr = strconv.FormatInt(menuCont.TypeId, 10) |
|||
//获取倒班规则
|
|||
var paiBanType modelshr.WorkTimeType |
|||
paiBanType.GetCont(map[string]interface{}{"`id`": menuCont.TypeId}, " `name`") |
|||
menuCont.TypeName = paiBanType.Name |
|||
|
|||
//作息时间
|
|||
var zuoXiTime []modelshr.WorkingTimePeriod |
|||
overall.CONSTANT_DB_HR.Where("`state` = 1 AND `type_id` = ?", menuCont.TypeId).Order("`sort` ASC").Find(&zuoXiTime) |
|||
//轮询规则
|
|||
|
|||
var lunXunShiXu []modelshr.TeamsRules |
|||
overall.CONSTANT_DB_HR.Where("`ruleTypeId` = ?", menuCont.TypeId).Find(&lunXunShiXu) |
|||
if len(zuoXiTime) < 1 || len(lunXunShiXu) < 1 { |
|||
var listSynv CalendarList |
|||
sendMonthList = TimeHaveAry(requestData.WeekAllDay, listSynv.List) |
|||
publicmethod.Result(200, sendMonthList, c) |
|||
return |
|||
} |
|||
cycle := 1 |
|||
for _, v := range lunXunShiXu { |
|||
cycle = v.Cycle |
|||
} |
|||
var sendCont []CalendarStructure |
|||
|
|||
switch cycle { |
|||
case 2: |
|||
var zuoXiTimeOne modelshr.WorkingTimePeriod |
|||
overall.CONSTANT_DB_HR.Where("`state` = 1 AND `type_id` = ?", menuCont.TypeId).Order("`sort` ASC").First(&zuoXiTimeOne) |
|||
var listSynv CalendarList |
|||
inDate := menuCont.changBaiBan(requestData.WeekAllDay, zuoXiTimeOne, lunXunShiXu) |
|||
listSynv.List = append(listSynv.List, inDate) |
|||
sendCont = TimeHaveAry(requestData.WeekAllDay, listSynv.List) |
|||
default: |
|||
lastDayNumber := 0 |
|||
var starTemasTime publicmethod.DateTimeTotimes |
|||
starTemasTime.BaisStrToTime(menuCont.BegainTime) |
|||
var listSynv CalendarList |
|||
for _, wv := range requestData.WeekAllDay { |
|||
var wvTimeAll publicmethod.DateTimeTotimes |
|||
wvTimeAll.BaisStrToTime(wv.Date) |
|||
if wvTimeAll.AllTime < starTemasTime.AllTime { |
|||
lastDayNumber++ |
|||
} else if wvTimeAll.AllTime == starTemasTime.AllTime { |
|||
listAry := menuCont.RuleYuanDianRunNew(wv, wvTimeAll, zuoXiTime, lunXunShiXu) |
|||
inDate := publicmethod.MapOut[string]() |
|||
inDate[wv.Date] = listAry |
|||
listSynv.List = append(listSynv.List, inDate) |
|||
} else { |
|||
sjc := ((wvTimeAll.AllTime - starTemasTime.AllTime) / 86400) + 1 |
|||
listAry := menuCont.SpecifyDateTeamsNew(wv, wvTimeAll, zuoXiTime, lunXunShiXu, sjc) |
|||
inDate := publicmethod.MapOut[string]() |
|||
inDate[wv.Date] = listAry |
|||
listSynv.List = append(listSynv.List, inDate) |
|||
} |
|||
|
|||
} |
|||
sendCont = TimeHaveAry(requestData.WeekAllDay, listSynv.List) |
|||
} |
|||
if len(sendCont) == 1 { |
|||
var onInfo CalendarStructure |
|||
for _, v := range sendCont { |
|||
onInfo = v |
|||
} |
|||
publicmethod.Result(0, onInfo, c) |
|||
return |
|||
} |
|||
sendMonthList = sendCont |
|||
publicmethod.Result(0, sendMonthList, c) |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
package customerForm |
|||
|
|||
import ( |
|||
"appPlatform/overall" |
|||
"strings" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-03-06 13:23:03 |
|||
@ 功能: 自定义表单分组 |
|||
*/ |
|||
type DiaoBanSetup struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` |
|||
Appid int64 `json:"appid" gorm:"column:appid;type:bigint(20) unsigned;default:0;not null;comment:归属哪个app"` |
|||
Source string `json:"source" gorm:"column:source;type:varchar(255) unsigned;default:'';not null;comment:是否引用数据源(yes ; no)"` |
|||
Ip string `json:"ip" gorm:"column:ip;type:varchar(255) unsigned;default:'';not null;comment:数据源地址"` |
|||
DataBaseName string `json:"dataBaseName" gorm:"column:dataBaseName;type:varchar(255) unsigned;default:'';not null;comment:是否引用数据源(yes ; no)"` |
|||
SqlType string `json:"sqlType" gorm:"column:sqlType;type:varchar(255) unsigned;default:'';not null;comment:数据库类型"` |
|||
Port int64 `json:"port" gorm:"column:port;type:int(7) unsigned;default:50;not null;comment:端口"` |
|||
TableKey string `json:"tableKey" gorm:"column:tableKey;type:varchar(255);default:'';comment:数据表标识"` |
|||
TableNames string `json:"tableName" gorm:"column:tableName;type:varchar(255);default:'';comment:数据表名称"` |
|||
UserName string `json:"userName" gorm:"column:userName;type:varchar(255);default:'';comment:数据库用户名"` |
|||
Pwd string `json:"pwd" gorm:"column:pwd;type:varchar(255);default:'';comment:数据库密码"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
SourceId string `json:"sourceId" gorm:"column:sourceId;type:varchar(255);default:'';comment:所愿"` |
|||
} |
|||
|
|||
func (DiaoBanSetup *DiaoBanSetup) TableName() string { |
|||
return "diaoBanSetup" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *DiaoBanSetup) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *DiaoBanSetup) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.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 *DiaoBanSetup) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *DiaoBanSetup) ContMap(whereMap interface{}, field ...string) (countAry []DiaoBanSetup, err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
err = gormDb.Where(whereMap).Find(&countAry).Error |
|||
return |
|||
} |
|||
|
|||
// 删除内容
|
|||
func (cont *DiaoBanSetup) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
package modelshr |
|||
|
|||
import ( |
|||
"appPlatform/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 排班记录
|
|||
type TeamsRules struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;index"` |
|||
RuleTypeId int64 `json:"ruleTypeId" gorm:"column:ruleTypeId;type:bigint(20) unsigned;default:0;not null;comment:排班制度ID"` |
|||
RuleTypeName string `json:"ruleTypeName" gorm:"column:ruleTypeName;type:varchar(255);comment:制度名称"` |
|||
Cycle int `json:"cycle" gorm:"column:cycle;type:int(4) unsigned;default:1;not null;comment:周期类型"` |
|||
TeamsId int64 `json:"teamsId" gorm:"column:teamsId;type:bigint(20) unsigned;default:0;not null;comment:班组Id"` |
|||
TeamsName string `json:"teamsName" gorm:"column:teamsName;type:varchar(255);comment:班组姓名"` |
|||
CycleSort int64 `json:"cycleSort" gorm:"column:cycleSort;type:int(4) unsigned;default:1;not null;comment:周期排序"` |
|||
CycleName string `json:"cycleName" gorm:"column:cycleName;type:varchar(255);comment:周期名称"` |
|||
CycleWorkTime int64 `json:"cycleWorkTime" gorm:"column:cycleWorkTime;type:bigint(20) unsigned;default:0;not null;comment:工作时间段Id"` |
|||
CycleWorkName string `json:"cycleWorkName" gorm:"column:cycleWorkName;type:varchar(255);comment:工作时间段名称"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` |
|||
} |
|||
|
|||
func (TeamsRules *TeamsRules) TableName() string { |
|||
return "teams_rules" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *TeamsRules) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *TeamsRules) 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 *TeamsRules) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *TeamsRules) ContMap(whereMap interface{}, field ...string) (countAry []TeamsRules, 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 *TeamsRules) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
Loading…
Reference in new issue