You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1030 lines
31 KiB
1030 lines
31 KiB
package customerApp
|
|
|
|
import (
|
|
"appPlatform/middleware/grocerystore"
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/models/modelssystempermission"
|
|
"appPlatform/models/teamlog"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"encoding/json"
|
|
"fmt"
|
|
"sort"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
var paichu = []int64{163, 281, 319}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-08-11 15:33:40
|
|
@ 功能: 初始化排版页面
|
|
*/
|
|
func (a *ApiMethod) CompanyDutyInit(c *gin.Context) {
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
sendData := publicmethod.MapOut[string]()
|
|
if userCont.Company == 402 {
|
|
userCont.Company = 296
|
|
}
|
|
sendData["currentOrg"] = userCont.Company
|
|
var orgCurre modelshr.AdministrativeOrganization
|
|
orgCurre.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`")
|
|
currentTime := time.Now().Unix()
|
|
yearVal := publicmethod.UnixTimeToDay(currentTime, 16)
|
|
yearValInt, _ := strconv.Atoi(yearVal)
|
|
monthVal := publicmethod.UnixTimeToDay(currentTime, 17)
|
|
monthValInt, _ := strconv.Atoi(monthVal)
|
|
currentDay := int(time.Now().Day())
|
|
sendData["title"] = fmt.Sprintf("%v.%v.%v%v值班表", yearVal, monthVal, currentDay, orgCurre.Name)
|
|
sendData["titlePc"] = fmt.Sprintf("%v年%v月%v值班表", yearVal, monthVal, orgCurre.Name)
|
|
sendData["year"] = yearValInt
|
|
sendData["month"] = monthValInt
|
|
sendData["currentOrgName"] = orgCurre.Name
|
|
sendData["currentTime"] = time.Now().Unix() * 1000
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt)
|
|
monthEndDay, _ := strconv.Atoi(endTime.Days)
|
|
var monthAllDay []string
|
|
for i := 1; i <= monthEndDay; i++ {
|
|
monthAllDay = append(monthAllDay, fmt.Sprintf("%v日", i))
|
|
}
|
|
|
|
//角色权限范围判定
|
|
//1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有
|
|
switch SearchRoleLevev(userCont.Role) {
|
|
case 5:
|
|
sendData["orgLevel"] = 5
|
|
// sendData["orgList"] = GetOrgLevel(313, 1)
|
|
case 4:
|
|
sendData["orgLevel"] = 4
|
|
// sendData["orgList"] = GetOrgLevel(userCont.Company, 1)
|
|
case 3:
|
|
sendData["orgLevel"] = 3
|
|
// sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2)
|
|
case 2:
|
|
sendData["orgLevel"] = 2
|
|
// sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2)
|
|
case 1:
|
|
sendData["orgLevel"] = 1
|
|
// sendData["orgList"] = GetOrgLevel(userCont.MainDeparment, 2)
|
|
default:
|
|
}
|
|
sendData["orgList"] = GetOrgLevel(313, 1)
|
|
|
|
sendData["currentDay"] = currentDay
|
|
// sendData["endTime"] = endTime
|
|
sendData["monthAllDay"] = monthAllDay
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
// 获取行政组织层级
|
|
func GetOrgLevel(partenId int64, types int) (orgList []GaveOrgAry) {
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&GaveOrgAry{}).Where("`state` = 1")
|
|
if types == 1 {
|
|
gormDb = gormDb.Where("`superior` = ?", partenId)
|
|
} else {
|
|
gormDb = gormDb.Where("`id` = ?", partenId)
|
|
}
|
|
gormDb.Order("`sort` ASC").Find(&orgList)
|
|
sort.Slice(orgList, func(i, j int) bool {
|
|
return orgList[i].Sort < orgList[j].Sort
|
|
})
|
|
return
|
|
}
|
|
|
|
// 获取最大查询范围
|
|
func SearchRoleLevev(roles string) (level int) {
|
|
roleList := strings.Split(roles, ",")
|
|
var roleVerify []modelssystempermission.RoleEmpower
|
|
overall.CONSTANT_DB_System_Permission.Where("`state` = 1 AND `system` = ? AND `id` IN ? ", "appsystem", roleList).Find(&roleVerify)
|
|
|
|
fmt.Printf("获取最大查询范围-->%v\n\n\n", roleVerify)
|
|
|
|
for _, v := range roleVerify {
|
|
fmt.Printf("获取最大查询范围-->%v\n\n\n", v.Level)
|
|
if v.Level >= level {
|
|
level = v.Level
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-08-12 08:36:19
|
|
@ 功能: 获取根据年月获取排班目录表
|
|
*/
|
|
func (a *ApiMethod) GetYearMonthWorkMan(c *gin.Context) {
|
|
var requestData PaiBanInfo
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.OrgId == 0 {
|
|
publicmethod.Result(1, err, c, "未知行政组织!")
|
|
return
|
|
}
|
|
|
|
currentTime := time.Now().Unix()
|
|
yearVal := publicmethod.UnixTimeToDay(currentTime, 16)
|
|
yearValInt, _ := strconv.Atoi(yearVal)
|
|
monthVal := publicmethod.UnixTimeToDay(currentTime, 17)
|
|
monthValInt, _ := strconv.Atoi(monthVal)
|
|
if requestData.Years != 0 {
|
|
yearValInt = requestData.Years
|
|
}
|
|
if requestData.Months != 0 {
|
|
monthValInt = requestData.Months
|
|
}
|
|
endTime := publicmethod.GetDaysInMonth(yearValInt, monthValInt)
|
|
monthEndDay, _ := strconv.Atoi(endTime.Days)
|
|
|
|
sendCenter := publicmethod.MapOut[string]()
|
|
var currOrgInfo GaveOrgAry
|
|
currOrgInfo.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`")
|
|
sendCenter["title"] = fmt.Sprintf("%v年%v月%v", yearVal, monthValInt, currOrgInfo.Name)
|
|
sendCenter["orgId"] = requestData.OrgId
|
|
sendCenter["orgName"] = currOrgInfo.Name
|
|
var sendData []SendCompanyWork
|
|
var orgList []GaveOrgAry
|
|
|
|
if requestData.OrgId == 309 {
|
|
var gsdaban GaveOrgAry
|
|
gsdaban.Id = requestData.OrgId * 10000
|
|
gsdaban.Name = "公司带班"
|
|
gsdaban.IsCompany = 1
|
|
orgList = append(orgList, gsdaban)
|
|
var gszhiban GaveOrgAry
|
|
gszhiban.Id = requestData.OrgId*10000 + 1
|
|
gszhiban.Name = "公司值班"
|
|
gszhiban.IsCompany = 1
|
|
orgList = append(orgList, gszhiban)
|
|
} else {
|
|
var gsld GaveOrgAry
|
|
gsld.Id = requestData.OrgId * 10000
|
|
gsld.Name = "公司值班"
|
|
gsld.IsCompany = 1
|
|
orgList = append(orgList, gsld)
|
|
}
|
|
orgListAry := GetOrgLevel(requestData.OrgId, 1)
|
|
orgList = append(orgList, orgListAry...)
|
|
for _, v := range orgList {
|
|
if !publicmethod.IsInTrue[int64](v.Id, paichu) {
|
|
var sendInfo SendCompanyWork
|
|
sendInfo.OrgInfo.Id = v.Id
|
|
sendInfo.OrgInfo.Name = v.Name
|
|
sendInfo.OrgInfo.IsCompany = v.IsCompany
|
|
var comLog []teamlog.Companylog
|
|
overall.CONSTANT_DB_TeamsLog.Where("`orgid` = ? AND `years` = ? AND `months` = ?", v.Id, yearValInt, monthValInt).Find(&comLog)
|
|
sendInfo.DutyList = GetOrgParWork(comLog, yearValInt, monthValInt, monthEndDay)
|
|
sendData = append(sendData, sendInfo)
|
|
}
|
|
|
|
}
|
|
sendCenter["list"] = sendData
|
|
publicmethod.Result(0, sendCenter, c)
|
|
}
|
|
|
|
func GetOrgParWork(comLog []teamlog.Companylog, yearValInt, monthValInt, monthEndDay int) (DutyList []DutyListStruct) {
|
|
for i := 1; i <= monthEndDay; i++ {
|
|
var dayWorkMan DutyListStruct
|
|
|
|
dayWorkMan.Years = yearValInt
|
|
dayWorkMan.Months = monthValInt
|
|
dayWorkMan.Days = i
|
|
for _, v := range comLog {
|
|
if i == v.Days {
|
|
dayWorkMan.Id = v.ID
|
|
dayWorkMan.Holiday = v.Holiday
|
|
dayWorkMan.AllDay = GetMAnInfo(v.AllDay, yearValInt, monthValInt, i)
|
|
dayWorkMan.BaiTian = GetMAnInfo(v.BaiTian, yearValInt, monthValInt, i)
|
|
dayWorkMan.Night = GetMAnInfo(v.Night, yearValInt, monthValInt, i)
|
|
dayWorkMan.Morning = GetMAnInfo(v.Morning, yearValInt, monthValInt, i)
|
|
dayWorkMan.Afternoon = GetMAnInfo(v.Afternoon, yearValInt, monthValInt, i)
|
|
}
|
|
}
|
|
DutyList = append(DutyList, dayWorkMan)
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-08-12 10:11:10
|
|
@ 功能: 值班人员信息
|
|
*/
|
|
func GetMAnInfo(userKey string, yearValInt, monthValInt, dayValInt int) (userList []UserCentor) {
|
|
if userKey != "" {
|
|
userAry := strings.Split(userKey, ",")
|
|
|
|
if len(userAry) > 0 {
|
|
var jieguo []UserCentor
|
|
var man []modelshr.ManCont
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`,`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`emp_type` BETWEEN ? AND ? AND `key` IN ?", 1, 10, userAry).Find(&man)
|
|
for _, v := range man {
|
|
|
|
var userInfo UserCentor
|
|
|
|
huanbenInfo, isTrue := ShiftChange(v.Number, v.Key, yearValInt, monthValInt, dayValInt)
|
|
if isTrue {
|
|
userInfo.Id = strconv.FormatInt(huanbenInfo.Id, 10)
|
|
userInfo.UserKey = strconv.FormatInt(huanbenInfo.Key, 10)
|
|
userInfo.Coder = huanbenInfo.Number
|
|
userInfo.Name = huanbenInfo.Name
|
|
userInfo.Icon = huanbenInfo.Icon
|
|
if huanbenInfo.IconPhpto != "" {
|
|
userInfo.Icon = huanbenInfo.IconPhpto
|
|
}
|
|
userInfo.Wechat = huanbenInfo.Wechat
|
|
userInfo.WorkWechat = huanbenInfo.WorkWechat
|
|
userInfo.Tel = huanbenInfo.Mobilephone
|
|
userInfo.Gender = huanbenInfo.Gender
|
|
} else {
|
|
userInfo.Id = strconv.FormatInt(v.Id, 10)
|
|
userInfo.UserKey = strconv.FormatInt(v.Key, 10)
|
|
userInfo.Coder = v.Number
|
|
userInfo.Name = v.Name
|
|
userInfo.Icon = v.Icon
|
|
if v.IconPhpto != "" {
|
|
userInfo.Icon = v.IconPhpto
|
|
}
|
|
userInfo.Wechat = v.Wechat
|
|
userInfo.WorkWechat = v.WorkWechat
|
|
userInfo.Tel = v.Mobilephone
|
|
userInfo.Gender = v.Gender
|
|
}
|
|
|
|
jieguo = append(jieguo, userInfo)
|
|
}
|
|
if len(jieguo) > 0 {
|
|
for _, v := range userAry {
|
|
for _, vv := range jieguo {
|
|
if v == vv.UserKey {
|
|
userList = append(userList, vv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
return
|
|
}
|
|
|
|
// 根据行政组织获取人员信息
|
|
func (a *ApiMethod) GeiOrgAllPeople(c *gin.Context) {
|
|
var requestData GetOrgPeopel
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.OrgId == 0 {
|
|
publicmethod.Result(1, err, c, "未知行政组织!")
|
|
return
|
|
}
|
|
if requestData.IsAll == 0 {
|
|
requestData.IsAll = 1
|
|
}
|
|
if requestData.IsAll == 1 {
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
sunOrg.GetOrgSun(requestData.OrgId)
|
|
sunOrg.Id = append(sunOrg.Id, requestData.OrgId)
|
|
var userList []UserCentor
|
|
if len(sunOrg.Id) > 0 {
|
|
var man []modelshr.ManCont
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`,`key`,`name`,`number`,`icon`,`icon_photo`,`wechat`,`work_wechat`,`admin_org`,`position`,`teamid`,`mobilephone`,`company`").Where("`emp_type` BETWEEN ? AND ? AND `admin_org` IN ?", 1, 10, sunOrg.Id).Find(&man)
|
|
for _, v := range man {
|
|
var userInfo UserCentor
|
|
userInfo.Id = strconv.FormatInt(v.Id, 10)
|
|
userInfo.UserKey = strconv.FormatInt(v.Key, 10)
|
|
userInfo.Coder = v.Number
|
|
userInfo.Name = fmt.Sprintf("%v(%v)", v.Name, v.Number)
|
|
userInfo.Icon = v.Icon
|
|
if v.IconPhpto != "" {
|
|
userInfo.Icon = v.IconPhpto
|
|
}
|
|
userInfo.Wechat = v.Wechat
|
|
userInfo.WorkWechat = v.WorkWechat
|
|
userInfo.Tel = v.Mobilephone
|
|
userInfo.Gender = v.Gender
|
|
userList = append(userList, userInfo)
|
|
}
|
|
}
|
|
publicmethod.Result(0, userList, c)
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-08-13 08:42:32
|
|
@ 功能: 编辑值班信息
|
|
*/
|
|
func (a *ApiMethod) SaveEditDutyInfo(c *gin.Context) {
|
|
var requestData DutyOrgInfo
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Orgid == 0 {
|
|
publicmethod.Result(1, err, c, "未知行政组织!")
|
|
return
|
|
}
|
|
if requestData.Years == 0 || requestData.Months == 0 || requestData.Days == 0 {
|
|
publicmethod.Result(1, err, c, "未知时间安排!")
|
|
return
|
|
}
|
|
holiday := 2
|
|
if requestData.Holiday != "" {
|
|
holiday, _ = strconv.Atoi(requestData.Holiday)
|
|
if holiday == 0 {
|
|
holiday = 2
|
|
}
|
|
}
|
|
isAdd := true
|
|
monthval := fmt.Sprintf("%v", requestData.Months)
|
|
if requestData.Months < 10 {
|
|
monthval = fmt.Sprintf("0%v", requestData.Months)
|
|
}
|
|
daysval := fmt.Sprintf("%v", requestData.Days)
|
|
if requestData.Days < 10 {
|
|
daysval = fmt.Sprintf("0%v", requestData.Days)
|
|
}
|
|
timeStr := fmt.Sprintf("%v-%v-%v 12:00:00", requestData.Years, monthval, daysval)
|
|
var timeVal publicmethod.DateTimeTotimes
|
|
timeVal.BaisStrToTime(timeStr)
|
|
if requestData.Id != 0 {
|
|
var oldDutyCont teamlog.Companylog
|
|
err = oldDutyCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
if err == nil {
|
|
isAdd = false
|
|
saveEitd := publicmethod.MapOut[string]()
|
|
saveEitd["`holiday`"] = holiday
|
|
saveEitd["allDay"] = strings.Join(requestData.AllDay, ",")
|
|
saveEitd["baiTian"] = strings.Join(requestData.BaiTian, ",")
|
|
saveEitd["night"] = strings.Join(requestData.Night, ",")
|
|
saveEitd["morning"] = strings.Join(requestData.Morning, ",")
|
|
saveEitd["afternoon"] = strings.Join(requestData.Afternoon, ",")
|
|
saveEitd["saveTime"] = time.Now().Unix()
|
|
var newDutyCont teamlog.Companylog
|
|
err = newDutyCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveEitd)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
if isAdd {
|
|
var saveConter teamlog.Companylog
|
|
saveConter.Orgid = requestData.Orgid // 行政组织ID
|
|
saveConter.RunTime = timeVal.AllTime // 执行时间
|
|
saveConter.Years = requestData.Years // 年
|
|
saveConter.Months = requestData.Months // 月
|
|
saveConter.Days = requestData.Days // 日
|
|
saveConter.Holiday = holiday // 假日(1:是;2:否)
|
|
saveConter.AllDay = strings.Join(requestData.AllDay, ",") // 全天值班人员
|
|
saveConter.BaiTian = strings.Join(requestData.BaiTian, ",") // 白天值班人员
|
|
saveConter.Night = strings.Join(requestData.Night, ",") // 夜晚值班人员
|
|
saveConter.Morning = strings.Join(requestData.Morning, ",") // 夜晚值班人员
|
|
saveConter.Afternoon = strings.Join(requestData.Afternoon, ",") // 夜晚值班人员
|
|
saveConter.SaveTime = time.Now().Unix() // 编辑时间
|
|
err = overall.CONSTANT_DB_TeamsLog.Create(&saveConter).Error
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
// 根据日期获取行政组织排班列表
|
|
func (a *ApiMethod) GeyOneDayDuty(c *gin.Context) {
|
|
var requestData OenDayDuty
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.OrgId == 0 {
|
|
publicmethod.Result(1, err, c, "未知行政组织!")
|
|
return
|
|
}
|
|
currentTime := time.Now().Unix()
|
|
yearVal := publicmethod.UnixTimeToDay(currentTime, 16)
|
|
yearValInt, _ := strconv.Atoi(yearVal)
|
|
monthVal := publicmethod.UnixTimeToDay(currentTime, 17)
|
|
monthValInt, _ := strconv.Atoi(monthVal)
|
|
dayhVal := publicmethod.UnixTimeToDay(currentTime, 18)
|
|
dayhValInt, _ := strconv.Atoi(dayhVal)
|
|
if requestData.Years != 0 {
|
|
yearValInt = requestData.Years
|
|
}
|
|
if requestData.Months != 0 {
|
|
monthValInt = requestData.Months
|
|
}
|
|
if requestData.Days != 0 {
|
|
dayhValInt = requestData.Days
|
|
}
|
|
sendCenter := publicmethod.MapOut[string]()
|
|
var currOrgInfo GaveOrgAry
|
|
currOrgInfo.GetCont(map[string]interface{}{"`id`": requestData.OrgId}, "`name`")
|
|
sendCenter["title"] = fmt.Sprintf("%v.%v.%v%v", yearVal, monthValInt, dayhValInt, currOrgInfo.Name)
|
|
sendCenter["orgId"] = requestData.OrgId
|
|
var orgList []GaveOrgAry
|
|
|
|
if requestData.OrgId == 309 {
|
|
var gsdaban GaveOrgAry
|
|
gsdaban.Id = requestData.OrgId * 10000
|
|
gsdaban.Name = "公司带班"
|
|
gsdaban.IsCompany = 1
|
|
orgList = append(orgList, gsdaban)
|
|
var gszhiban GaveOrgAry
|
|
gszhiban.Id = requestData.OrgId*10000 + 1
|
|
gszhiban.Name = "公司值班"
|
|
gsdaban.IsCompany = 1
|
|
orgList = append(orgList, gszhiban)
|
|
} else {
|
|
var gsld GaveOrgAry
|
|
gsld.Id = requestData.OrgId * 10000
|
|
gsld.Name = "公司值班"
|
|
gsld.IsCompany = 1
|
|
orgList = append(orgList, gsld)
|
|
}
|
|
orgListAry := GetOrgLevel(requestData.OrgId, 1)
|
|
orgList = append(orgList, orgListAry...)
|
|
|
|
var sendData []WebSendTo
|
|
for _, v := range orgList {
|
|
if !publicmethod.IsInTrue[int64](v.Id, paichu) {
|
|
var sendInfo WebSendTo
|
|
sendInfo.OrgId = v.Id
|
|
sendInfo.OrgName = v.Name
|
|
sendInfo.IsCompany = v.IsCompany
|
|
var comLog teamlog.Companylog
|
|
err = overall.CONSTANT_DB_TeamsLog.Where("`orgid` = ? AND `years` = ? AND `months` = ? AND `days` = ?", v.Id, yearValInt, monthValInt, dayhValInt).First(&comLog).Error
|
|
if err == nil {
|
|
sendInfo.Id = strconv.FormatInt(comLog.ID, 10)
|
|
sendInfo.Holiday = comLog.Holiday
|
|
sendInfo.AllDay = GetMAnInfo(comLog.AllDay, yearValInt, monthValInt, dayhValInt)
|
|
sendInfo.BaiTian = GetMAnInfo(comLog.BaiTian, yearValInt, monthValInt, dayhValInt)
|
|
sendInfo.Night = GetMAnInfo(comLog.Night, yearValInt, monthValInt, dayhValInt)
|
|
sendInfo.Morning = GetMAnInfo(comLog.Morning, yearValInt, monthValInt, dayhValInt)
|
|
sendInfo.Afternoon = GetMAnInfo(comLog.Afternoon, yearValInt, monthValInt, dayhValInt)
|
|
if comLog.AllDay != "" || comLog.BaiTian != "" || comLog.Night != "" || comLog.Morning != "" || comLog.Afternoon != "" {
|
|
sendData = append(sendData, sendInfo)
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
sendCenter["list"] = sendData
|
|
publicmethod.Result(0, sendCenter, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-08-13 21:24:02
|
|
@ 功能: 清空日期值班
|
|
*/
|
|
func (a *ApiMethod) DelOneDayDuty(c *gin.Context) {
|
|
var requestData publicmethod.CommonId[int64]
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == 0 {
|
|
publicmethod.Result(1, err, c, "未知删除项目!")
|
|
return
|
|
}
|
|
var comLog teamlog.Companylog
|
|
err = comLog.DelCont(map[string]interface{}{"`id`": requestData.Id})
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-08-14 11:20:51
|
|
@ 功能: 获取排版信息
|
|
*/
|
|
func (a *ApiMethod) GetDutyCont(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(1, err, c, "未知项目!")
|
|
return
|
|
}
|
|
var comLog CompanyDutyCont
|
|
comLog.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
if comLog.AllDay != "" {
|
|
userKeyAry := strings.Split(comLog.AllDay, ",")
|
|
comLog.AllDayAry = userKeyAry
|
|
comLog.AllDayAryAll = HaveUSerInfo(userKeyAry)
|
|
} else {
|
|
comLog.AllDayAry = []string{}
|
|
comLog.AllDayAryAll = []SendOrgPeopelList{}
|
|
}
|
|
if comLog.BaiTian != "" {
|
|
userKeyAry := strings.Split(comLog.BaiTian, ",")
|
|
comLog.BaiTianAry = userKeyAry
|
|
comLog.BaiTianAryAll = HaveUSerInfo(userKeyAry)
|
|
} else {
|
|
comLog.BaiTianAry = []string{}
|
|
comLog.BaiTianAryAll = []SendOrgPeopelList{}
|
|
}
|
|
if comLog.Night != "" {
|
|
userKeyAry := strings.Split(comLog.Night, ",")
|
|
comLog.NightAry = userKeyAry
|
|
comLog.NightAryAll = HaveUSerInfo(userKeyAry)
|
|
} else {
|
|
comLog.NightAry = []string{}
|
|
comLog.NightAryAll = []SendOrgPeopelList{}
|
|
}
|
|
if comLog.Morning != "" {
|
|
userKeyAry := strings.Split(comLog.Morning, ",")
|
|
comLog.MorningAry = userKeyAry
|
|
comLog.MorningAryAll = HaveUSerInfo(userKeyAry)
|
|
} else {
|
|
comLog.MorningAry = []string{}
|
|
comLog.MorningAryAll = []SendOrgPeopelList{}
|
|
}
|
|
if comLog.Afternoon != "" {
|
|
userKeyAry := strings.Split(comLog.Afternoon, ",")
|
|
comLog.AfternoonAry = userKeyAry
|
|
comLog.AfternoonAryAll = HaveUSerInfo(userKeyAry)
|
|
} else {
|
|
comLog.AfternoonAry = []string{}
|
|
comLog.AfternoonAryAll = []SendOrgPeopelList{}
|
|
}
|
|
publicmethod.Result(0, comLog, c)
|
|
}
|
|
|
|
// 获取人员信息
|
|
func HaveUSerInfo(userKey []string) (manAry []SendOrgPeopelList) {
|
|
if len(userKey) > 0 {
|
|
var jieguo []SendOrgPeopelList
|
|
var manList []modelshr.ManCont
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`,`mobilephone`").Where("`key` IN ? AND `emp_type` BETWEEN ? AND ?", userKey, 1, 10).Find(&manList)
|
|
for _, v := range manList {
|
|
var manInfo SendOrgPeopelList
|
|
manInfo.UserNumber = v.Number //
|
|
manInfo.UserName = v.Name //
|
|
manInfo.UserKey = strconv.FormatInt(v.Key, 10) //
|
|
manInfo.TelStr = v.Mobilephone
|
|
manInfo.UserAvatar = v.IconPhpto //
|
|
if v.Icon != "" {
|
|
manInfo.UserAvatar = v.Icon
|
|
}
|
|
jieguo = append(jieguo, manInfo)
|
|
}
|
|
if len(jieguo) > 0 {
|
|
for _, v := range userKey {
|
|
for _, vv := range jieguo {
|
|
if v == vv.UserKey {
|
|
manAry = append(manAry, vv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-01-19 10:41:34
|
|
@ 功能: 获取行政组织及相关人员
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GetOrgAndEveryOnePeople(c *gin.Context) {
|
|
var requestData OrgAndMAnThreeType
|
|
c.ShouldBindJSON(&requestData)
|
|
redisKey := fmt.Sprintf("Auth:Org_%v_Info", requestData.Id)
|
|
if requestData.Id == "" {
|
|
redisKey = fmt.Sprintf("Auth:Org_%v_Info", "orgAll")
|
|
}
|
|
|
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4)
|
|
isTrue, jsApiTickerInfo := redisClient.Get(redisKey) //读取redis数据
|
|
if isTrue && jsApiTickerInfo != "" && jsApiTickerInfo != "[]" {
|
|
// var sendMap interface{}
|
|
var govAry []OrgAndManThree
|
|
json.Unmarshal([]byte(jsApiTickerInfo), &govAry)
|
|
publicmethod.Result(0, govAry, c, "这是Redsi值")
|
|
} else {
|
|
var origin int64
|
|
var orgIdList []int64
|
|
isNotIn := 0
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
if requestData.All == 0 {
|
|
if requestData.Id == "" {
|
|
origin = 0
|
|
isNotIn = 1
|
|
orgIdList = []int64{312, 293, 305, 306, 307}
|
|
} else {
|
|
idInt64, _ := strconv.ParseInt(requestData.Id, 10, 64)
|
|
origin = idInt64
|
|
sunOrg.GetOrgSun(idInt64)
|
|
sunOrg.Id = append(sunOrg.Id, idInt64)
|
|
orgIdList = sunOrg.Id
|
|
}
|
|
} else {
|
|
if requestData.Id != "" {
|
|
idInt64, _ := strconv.ParseInt(requestData.Id, 10, 64)
|
|
origin = idInt64
|
|
sunOrg.GetOrgSun(idInt64)
|
|
sunOrg.Id = append(sunOrg.Id, idInt64)
|
|
orgIdList = sunOrg.Id
|
|
} else {
|
|
origin = 0
|
|
isNotIn = 1
|
|
orgIdList = []int64{312, 293, 305, 306, 307}
|
|
}
|
|
}
|
|
if !publicmethod.IsInTrue[int64](origin, orgIdList) {
|
|
orgIdList = append(orgIdList, origin)
|
|
}
|
|
var orgAndPeopleListCont empowerSync //启用协程结构体
|
|
synPro.Add(1)
|
|
go orgAndPeopleListCont.GetOrgList(isNotIn, orgIdList, requestData.Level) //获取行政组织
|
|
synPro.Add(1)
|
|
go orgAndPeopleListCont.GetPeopleList(isNotIn, orgIdList) //获取人员
|
|
synPro.Wait()
|
|
orgAndManList := orgAndPeopleListCont.readDataLock()
|
|
|
|
sort.Slice(orgAndManList, func(i, j int) bool {
|
|
return orgAndManList[i].Type < orgAndManList[j].Type
|
|
})
|
|
sort.Slice(orgAndManList, func(i, j int) bool {
|
|
return orgAndManList[i].Sort < orgAndManList[j].Sort
|
|
})
|
|
sendList := OrgAndManNewThree(origin, orgAndManList)
|
|
orgMap, _ := json.Marshal(sendList)
|
|
redisClient.SetRedisTime(86400)
|
|
redisClient.Set(redisKey, string(orgMap))
|
|
publicmethod.Result(0, sendList, c)
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-01-19 14:28:48
|
|
@ 功能: 新版人员与行政组织树
|
|
@ 参数
|
|
|
|
#parentId 上级ID
|
|
#govAry 数据
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#func OrgAndManNewThree(parentId int64, govAry []OrgAndEveryOnePeople) []OrgAndManThree
|
|
*/
|
|
func OrgAndManNewThree(parentId int64, govAry []OrgAndEveryOnePeople) []OrgAndManThree {
|
|
orgAndMAnMap := []OrgAndManThree{}
|
|
for _, v := range govAry {
|
|
// var zhucont govThree
|
|
parentIdInt, _ := strconv.ParseInt(v.Superior, 10, 64)
|
|
// fmt.Printf("------------->%v---->%v\n", parentIdInt, parentId)
|
|
if parentIdInt == parentId {
|
|
|
|
child := OrgAndManNewThree(v.OrgId, govAry)
|
|
|
|
var node OrgAndManThree
|
|
node.Id = v.Id //识别符
|
|
node.OrgId = v.OrgId
|
|
node.Number = v.Number //编号
|
|
node.Name = v.Name //姓名
|
|
node.Superior = v.Superior //上级
|
|
node.Icon = v.Icon
|
|
node.IconPhoto = v.IconPhoto
|
|
node.Type = v.Type
|
|
node.Key = v.Key
|
|
node.Sort = v.Sort
|
|
if len(child) > 0 {
|
|
node.Child = child
|
|
}
|
|
|
|
orgAndMAnMap = append(orgAndMAnMap, node)
|
|
|
|
}
|
|
|
|
}
|
|
return orgAndMAnMap
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-01-19 11:24:44
|
|
@ 功能: 获取人员(协程)
|
|
@ 参数
|
|
|
|
#orgId 行政组织ID
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (e *empowerSync) GetPeopleList(isNotIn int, orgId []int64) {
|
|
e.mutext.Lock()
|
|
defer e.mutext.Unlock()
|
|
var peopleList []modelshr.PersonArchives
|
|
gormDnMan := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`").Where("`emp_type` BETWEEN ? AND ?", 1, 10)
|
|
if len(orgId) > 0 {
|
|
if isNotIn == 1 {
|
|
gormDnMan = gormDnMan.Where("`admin_org` NOT IN ?", orgId)
|
|
} else {
|
|
gormDnMan = gormDnMan.Where("`admin_org` IN ?", orgId)
|
|
}
|
|
|
|
}
|
|
err := gormDnMan.Find(&peopleList).Error
|
|
if err == nil && len(peopleList) > 0 {
|
|
for _, v := range peopleList {
|
|
var peopleCont OrgAndEveryOnePeople
|
|
peopleCont.Id = strconv.FormatInt(v.Key, 10) //识别符
|
|
peopleCont.OrgId = -1
|
|
peopleCont.Number = v.Number //编号
|
|
peopleCont.Name = v.Name //姓名
|
|
peopleCont.Superior = strconv.FormatInt(v.AdminOrg, 10) //上级
|
|
peopleCont.Icon = v.Icon
|
|
peopleCont.IconPhoto = v.IconPhoto
|
|
peopleCont.Type = 2
|
|
peopleCont.Key = fmt.Sprintf("U%v", v.Key)
|
|
e.orgAndPeopleList = append(e.orgAndPeopleList, peopleCont)
|
|
}
|
|
}
|
|
synPro.Done()
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-01-19 11:18:39
|
|
@ 功能: 获取行政组织(协程)
|
|
@ 参数
|
|
|
|
#orgId 行政组织ID
|
|
#level 获取等级
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#func (e *empowerSync) GetOrgList(orgId []int64, level int)
|
|
*/
|
|
func (e *empowerSync) GetOrgList(isNotIn int, orgId []int64, level int) {
|
|
e.mutext.Lock()
|
|
defer e.mutext.Unlock()
|
|
var orgList []modelshr.AdministrativeOrganization
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`number`,`name`,`superior`").Where("`state` = ? ", 1)
|
|
if len(orgId) > 0 {
|
|
if isNotIn == 1 {
|
|
gormDb = gormDb.Where("`id` NOT IN ?", orgId)
|
|
} else {
|
|
gormDb = gormDb.Where("`id` IN ?", orgId)
|
|
}
|
|
}
|
|
if level != 0 {
|
|
gormDb = gormDb.Where("`level` <= ?", level)
|
|
}
|
|
err := gormDb.Find(&orgList).Error
|
|
if err == nil && len(orgList) > 0 {
|
|
for _, v := range orgList {
|
|
var orgCont OrgAndEveryOnePeople
|
|
orgCont.Id = strconv.FormatInt(v.Id, 10) //识别符
|
|
orgCont.OrgId = v.Id
|
|
orgCont.Number = v.Number //编号
|
|
orgCont.Name = v.Name //姓名
|
|
orgCont.Superior = strconv.FormatInt(v.Superior, 10) //上级
|
|
orgCont.Type = 1
|
|
orgCont.Sort = v.Sort
|
|
orgCont.Key = fmt.Sprintf("A%v", v.Id)
|
|
e.orgAndPeopleList = append(e.orgAndPeopleList, orgCont)
|
|
}
|
|
}
|
|
synPro.Done()
|
|
}
|
|
|
|
// 获取行政组织树
|
|
func (a *ApiMethod) GetOrgTree(c *gin.Context) {
|
|
var requestData publicmethod.CommonId[int64]
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
var origin int64
|
|
var orgIdList []int64
|
|
isNotIn := 0
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
if requestData.Id == 0 {
|
|
origin = 0
|
|
isNotIn = 1
|
|
orgIdList = []int64{312, 293, 305, 306, 307}
|
|
} else {
|
|
var pickOrg modelshr.AdministrativeOrganization
|
|
pickOrg.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`superior`")
|
|
origin = pickOrg.Superior
|
|
sunOrg.GetOrgSun(requestData.Id)
|
|
sunOrg.Id = append(sunOrg.Id, requestData.Id)
|
|
orgIdList = sunOrg.Id
|
|
}
|
|
var orgConterList []modelshr.AdministrativeOrganization
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`,`superior`,`sort`").Where("`state` = ? ", 1)
|
|
if len(orgIdList) > 0 {
|
|
if isNotIn == 1 {
|
|
gormDb = gormDb.Where("`id` NOT IN ?", orgIdList)
|
|
} else {
|
|
gormDb = gormDb.Where("`id` IN ?", orgIdList)
|
|
}
|
|
}
|
|
err = gormDb.Find(&orgConterList).Error
|
|
var orgAry []JianLueOrgTree
|
|
for _, v := range orgConterList {
|
|
var orgInfo JianLueOrgTree
|
|
orgInfo.Id = v.Id
|
|
orgInfo.Name = v.Name
|
|
orgInfo.Superior = v.Superior
|
|
orgInfo.Sort = v.Sort
|
|
orgAry = append(orgAry, orgInfo)
|
|
}
|
|
sort.Slice(orgAry, func(i, j int) bool {
|
|
return orgAry[i].Sort < orgAry[j].Sort
|
|
})
|
|
orgTreeAry := GovOrgTree(origin, orgAry)
|
|
publicmethod.Result(0, orgTreeAry, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-01-16 08:57:31
|
|
@ 功能: 生成行政组织树
|
|
*/
|
|
func GovOrgTree(parentId int64, govList []JianLueOrgTree) (govMap []JianLueOrgTree) {
|
|
for i := 0; i < len(govList); i++ {
|
|
if govList[i].Superior == parentId {
|
|
var govCont JianLueOrgTree
|
|
govCont.Id = govList[i].Id
|
|
govCont.Name = govList[i].Name //组织名称"`
|
|
govCont.Superior = govList[i].Superior //上级ID"`
|
|
govCont.Sort = govList[i].Sort //是否为实权部门"`
|
|
govCont.Children = GovOrgTree(govList[i].Id, govList)
|
|
govMap = append(govMap, govCont)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-08-16 14:30:38
|
|
@ 功能: 获取人员信息
|
|
*/
|
|
func (a *ApiMethod) GetOrgPeopleList(c *gin.Context) {
|
|
var requestData OrgPeopinCenter
|
|
c.ShouldBindJSON(&requestData)
|
|
fmt.Printf("翻页数据--->%v\n\n", requestData)
|
|
if requestData.Page == 0 {
|
|
requestData.Page = 1
|
|
}
|
|
if requestData.PageSize == 0 {
|
|
requestData.PageSize = 6
|
|
}
|
|
var orgIdList []int64
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
if requestData.Id == 0 {
|
|
orgIdListNoIn := []int64{312, 293, 305, 306, 307}
|
|
overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = ? ", 1).Where("`id` NOT IN ?", orgIdListNoIn).Find(&orgIdList)
|
|
} else {
|
|
sunOrg.GetOrgSun(requestData.Id)
|
|
sunOrg.Id = append(sunOrg.Id, requestData.Id)
|
|
orgIdList = sunOrg.Id
|
|
}
|
|
var manList []modelshr.ManCont
|
|
// gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`,`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`,`mobilephone`").Where("`emp_type` BETWEEN ? AND ?", 1, 10).Where("`admin_org` IN ?", orgIdList)
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("`id`,`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`,`mobilephone`").Where("`number` NOT LIKE ?", "%W%").Where("`emp_type` BETWEEN ? AND ?", 1, 10)
|
|
if requestData.Id == 389 {
|
|
jiuan := []int64{389, 126}
|
|
gormDb = gormDb.Where("`company` IN ? OR `maindeparment` = ? OR admin_org IN ?", jiuan, 126, orgIdList)
|
|
} else {
|
|
gormDb = gormDb.Where("`company` = ? OR admin_org IN ?", requestData.Id, orgIdList)
|
|
}
|
|
if requestData.Name != "" {
|
|
gormDb = gormDb.Where("`name` LIKE ? OR `number` LIKE ? OR `mobilephone` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%", "%"+requestData.Name+"%")
|
|
}
|
|
|
|
var total int64
|
|
totalErr := gormDb.Count(&total).Error
|
|
if totalErr != nil {
|
|
total = 0
|
|
}
|
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
|
|
gormDb.Order("`id` DESC").Find(&manList)
|
|
var sendAry []SendOrgPeopelList
|
|
for _, v := range manList {
|
|
var usMAn SendOrgPeopelList
|
|
usMAn.UserNumber = v.Number //er"`
|
|
usMAn.UserName = v.Name //"`
|
|
usMAn.UserKey = strconv.FormatInt(v.Key, 10) //`
|
|
usMAn.UserAvatar = v.IconPhpto //ar"`
|
|
if v.Icon != "" {
|
|
usMAn.UserAvatar = v.Icon
|
|
}
|
|
usMAn.TelStr = v.Mobilephone //
|
|
sendAry = append(sendAry, usMAn)
|
|
}
|
|
// publicmethod.Result(0, requestData, c)
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendAry)), sendAry, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-08-18 11:19:31
|
|
@ 功能: 日历表单一删除值班人
|
|
*/
|
|
func (a *ApiMethod) DelMonthOneus(c *gin.Context) {
|
|
var requestData DelOneUsRili
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == 0 {
|
|
publicmethod.Result(1, err, c, "未知删除对象!")
|
|
return
|
|
}
|
|
var comLog teamlog.Companylog
|
|
err = comLog.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
saveInfo := publicmethod.MapOut[string]()
|
|
switch requestData.Types {
|
|
case 2:
|
|
saveInfo["`night`"] = strings.Join(requestData.UserAry, ",")
|
|
case 3:
|
|
saveInfo["`allDay`"] = strings.Join(requestData.UserAry, ",")
|
|
|
|
case 4:
|
|
saveInfo["`morning`"] = strings.Join(requestData.UserAry, ",")
|
|
case 5:
|
|
saveInfo["`baiTian`"] = strings.Join(requestData.UserAry, ",")
|
|
default:
|
|
saveInfo["`baiTian`"] = strings.Join(requestData.UserAry, ",")
|
|
}
|
|
saveInfo["`saveTime`"] = time.Now().Unix()
|
|
var comLogEdit teamlog.Companylog
|
|
err = comLogEdit.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveInfo)
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|