13 changed files with 1049 additions and 22 deletions
@ -0,0 +1,470 @@ |
|||
package personnelapi |
|||
|
|||
import ( |
|||
"fmt" |
|||
"hr_server/models" |
|||
"hr_server/models/hrmodels" |
|||
"hr_server/overall" |
|||
"hr_server/overall/overallhandle" |
|||
"time" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-06-29 15:10:35 |
|||
@ 功能: 离职率 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (s *StaffApi) DimissionRate(c *gin.Context) { |
|||
var requestData TurnoverRate |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
requestData.Id = 313 |
|||
} |
|||
if requestData.Id == 0 { |
|||
requestData.Id = 313 |
|||
} |
|||
currentTime := time.Now().Unix() |
|||
statisticalTime := currentTime |
|||
if requestData.Time != "" { |
|||
var timeCont overallhandle.DateTimeTotimes |
|||
timeCont.BaisStrToTime(requestData.Time) |
|||
statisticalTime = timeCont.AllTime |
|||
} |
|||
//行政组织
|
|||
var orgList []models.AdministrativeOrganization |
|||
err = overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("`id`,`name`").Where("`state` = 1 AND `superior` = ?", requestData.Id).Order("`sort` ASC").Find(&orgList).Error |
|||
if err != nil { |
|||
overallhandle.Result(107, err, c) |
|||
return |
|||
} |
|||
currentYear := overallhandle.ComputingTime(statisticalTime, 1) |
|||
currentMonths := overallhandle.ComputingTime(statisticalTime, 3) |
|||
// var i int64
|
|||
if currentYear != overallhandle.ComputingTime(currentTime, 1) { |
|||
currentMonths = 12 |
|||
} |
|||
var calRateCont CalTurRateContBlack |
|||
calRateCont.CurrentOrgId = requestData.Id |
|||
for _, v := range orgList { //行政组织
|
|||
calRateCont.Dfg(currentYear, currentMonths, v) |
|||
} |
|||
fmt.Printf("行政组织总数----->%v----->%v\n", len(orgList), len(calRateCont.List)) |
|||
overallhandle.Result(0, calRateCont, c) |
|||
} |
|||
|
|||
func (c *CalTurRateContBlack) Dfg(years, months int64, orgCont models.AdministrativeOrganization) { |
|||
// defer synPro.Done()
|
|||
var contData SendCalTurRateCont |
|||
contData.OrgId = orgCont.Id |
|||
contData.OrgName = orgCont.Name |
|||
var sunAry overallhandle.AllSunList[int64] |
|||
sunAry.GetAllSunOrg(orgCont.Id) |
|||
|
|||
var sumPeople int64 |
|||
overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("admin_org IN ? AND emp_type BETWEEN ? AND ?", sunAry.SunList, 1, 10).Count(&sumPeople) |
|||
|
|||
var i int64 |
|||
for i = 1; i <= months; i++ { |
|||
var timeCont overallhandle.DateTimeTotimes |
|||
timeCont.BaisStrToTime(fmt.Sprintf("%v-%v-01 00:00:00", years, i)) |
|||
// fmt.Printf("时间--->%v\n", timeCont.Time)
|
|||
hjsdk := overallhandle.UnixTimeToDay(timeCont.AllTime, 14) |
|||
startTime, endTime := overallhandle.GetAppointMonthStarAndEndTimeEs(hjsdk) |
|||
var reatCount int64 |
|||
overall.CONSTANT_DB_HR.Model(&hrmodels.UserEmp{}).Select("`id`").Where("admin_org IN ? AND leave_date BETWEEN ? AND ?", sunAry.SunList, startTime, endTime).Count(&reatCount) |
|||
beiChuShu := sumPeople + reatCount |
|||
if beiChuShu == 0 { |
|||
contData.Odds = append(contData.Odds, 0) |
|||
} else { |
|||
|
|||
reatVal := overallhandle.DecimalEs((float64(reatCount)/float64(beiChuShu))*100, 3) |
|||
contData.Odds = append(contData.Odds, reatVal) |
|||
} |
|||
} |
|||
c.List = append(c.List, contData) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-06-29 16:10:50 |
|||
@ 功能: 根据行政组织计算时间内的离职率 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (c *CalTurRateCont) CalculateTurnoverRate(years, months int64, orgCont models.AdministrativeOrganization) { |
|||
// defer synPro.Done()
|
|||
var calCont CalculateTurnoverRateCont |
|||
calCont.OrgId = orgCont.Id |
|||
calCont.OrgName = orgCont.Name |
|||
calCont.Months = months |
|||
calCont.Odds = months |
|||
c.List = append(c.List, calCont) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-07-01 09:36:07 |
|||
@ 功能: 获取单一行政组织离职率 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (s *StaffApi) GetOenOrgDimRate(c *gin.Context) { |
|||
userKey := c.Request.Header.Get("user-key") |
|||
myCont, myErr := overallhandle.GetCreetUserCont(userKey) |
|||
var requestData TurnoverRate |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
|
|||
if myErr != nil { |
|||
requestData.Id = 309 |
|||
} else { |
|||
requestData.Id = myCont.Company |
|||
} |
|||
} |
|||
if requestData.Id == 0 { |
|||
if myErr != nil { |
|||
requestData.Id = 309 |
|||
} else { |
|||
requestData.Id = myCont.Company |
|||
} |
|||
} |
|||
fmt.Printf("获得行政组织--->%v\n--->%v\n--->%v\n", userKey, myCont, requestData) |
|||
|
|||
currentTime := time.Now().Unix() |
|||
statisticalTime := currentTime |
|||
if requestData.Time != "" { |
|||
var timeCont overallhandle.DateTimeTotimes |
|||
timeCont.BaisStrToTime(requestData.Time) |
|||
statisticalTime = timeCont.AllTime |
|||
} |
|||
//行政组织
|
|||
var orgList []models.AdministrativeOrganization |
|||
err = overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("`id`,`name`").Where("`state` = 1 AND `superior` = ?", requestData.Id).Order("`sort` ASC").Find(&orgList).Error |
|||
if err != nil { |
|||
overallhandle.Result(107, err, c) |
|||
return |
|||
} |
|||
currentYear := overallhandle.ComputingTime(statisticalTime, 1) |
|||
currentMonths := overallhandle.ComputingTime(statisticalTime, 3) |
|||
// var i int64
|
|||
if currentYear != overallhandle.ComputingTime(currentTime, 1) { |
|||
currentMonths = 12 |
|||
} |
|||
var calRateCont CalTurRateContBlack |
|||
calRateCont.CurrentOrgId = requestData.Id |
|||
for _, v := range orgList { //行政组织
|
|||
calRateCont.Dfg(currentYear, currentMonths, v) |
|||
} |
|||
fmt.Printf("行政组织总数----->%v----->%v\n", len(orgList), len(calRateCont.List)) |
|||
overallhandle.Result(0, calRateCont, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-07-01 14:08:40 |
|||
@ 功能: 获取公司指定年月的离职率 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (s *StaffApi) GetOrgTimeRate(c *gin.Context) { |
|||
userKey := c.Request.Header.Get("user-key") |
|||
myCont, myErr := overallhandle.GetCreetUserCont(userKey) |
|||
var requestData TurnoverRate |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
if myErr != nil { |
|||
requestData.Id = 309 |
|||
} else { |
|||
requestData.Id = myCont.Company |
|||
} |
|||
} |
|||
if requestData.Id == 0 { |
|||
if myErr != nil { |
|||
requestData.Id = 309 |
|||
} else { |
|||
requestData.Id = myCont.Company |
|||
} |
|||
} |
|||
//行政组织
|
|||
var orgList []models.AdministrativeOrganization |
|||
err = overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("`id`,`name`").Where("`state` = 1 AND `superior` = ?", requestData.Id).Order("`sort` ASC").Find(&orgList).Error |
|||
if err != nil { |
|||
overallhandle.Result(107, err, c) |
|||
return |
|||
} |
|||
|
|||
currentTime := time.Now().Unix() |
|||
hjsdk := overallhandle.UnixTimeToDay(currentTime, 14) |
|||
startTime, endTime := overallhandle.GetAppointMonthStarAndEndTimeEs(hjsdk) |
|||
if requestData.Time != "" { |
|||
var timeCont overallhandle.DateTimeTotimes |
|||
timeCont.BaisStrToTime(requestData.Time) |
|||
fmt.Printf("时间--->%v\n--->%v\n", requestData.Time, timeCont.Time) |
|||
hjsdks := overallhandle.UnixTimeToDay(timeCont.AllTime, 14) |
|||
fmt.Printf("时间--222->%v\n", hjsdks) |
|||
startTime, endTime = overallhandle.GetAppointMonthStarAndEndTimeEs(hjsdks) |
|||
} |
|||
var calRateCont SendPicRateInfo |
|||
calRateCont.CurrentOrgId = requestData.Id |
|||
for _, v := range orgList { //行政组织
|
|||
calRateCont.MonthsRate(startTime, endTime, v) |
|||
} |
|||
overallhandle.Result(0, calRateCont, c) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-07-01 14:17:14 |
|||
@ 功能: 计算指定月份离职率 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (c *SendPicRateInfo) MonthsRate(startTime, endTime int64, orgCont models.AdministrativeOrganization) { |
|||
var contData SendPicRateCont |
|||
contData.OrgId = orgCont.Id |
|||
contData.OrgName = orgCont.Name |
|||
var sunAry overallhandle.AllSunList[int64] |
|||
sunAry.GetAllSunOrg(orgCont.Id) |
|||
|
|||
var sumPeople int64 |
|||
overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("admin_org IN ? AND emp_type BETWEEN ? AND ?", sunAry.SunList, 1, 10).Count(&sumPeople) |
|||
var reatCount int64 |
|||
overall.CONSTANT_DB_HR.Model(&hrmodels.UserEmp{}).Select("`id`").Where("admin_org IN ? AND leave_date BETWEEN ? AND ?", sunAry.SunList, startTime, endTime).Count(&reatCount) |
|||
beiChuShu := sumPeople + reatCount |
|||
if beiChuShu == 0 { |
|||
contData.Odds = 0 |
|||
} else { |
|||
|
|||
reatVal := overallhandle.DecimalEs((float64(reatCount)/float64(beiChuShu))*100, 3) |
|||
contData.Odds = reatVal |
|||
} |
|||
c.List = append(c.List, contData) |
|||
} |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-07-01 15:49:31 |
|||
@ 功能: 获取学历结构 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (s *StaffApi) GetEducationalStructure(c *gin.Context) { |
|||
userKey := c.Request.Header.Get("user-key") |
|||
myCont, myErr := overallhandle.GetCreetUserCont(userKey) |
|||
var requestData overallhandle.PublicId[int64] |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
if myErr != nil { |
|||
requestData.Id = 309 |
|||
} else { |
|||
requestData.Id = myCont.Company |
|||
} |
|||
} |
|||
if requestData.Id == 0 { |
|||
if myErr != nil { |
|||
requestData.Id = 309 |
|||
} else { |
|||
requestData.Id = myCont.Company |
|||
} |
|||
} |
|||
var sunAry overallhandle.AllSunList[int64] |
|||
sunAry.GetAllSunOrg(requestData.Id) |
|||
//学历列表
|
|||
var eduStruListCont []hrmodels.EducationalStructure |
|||
err = overall.CONSTANT_DB_HR.Distinct("`number`,MAX(`education`) as educationmax ").Where("admin_org IN ?", sunAry.SunList).Group("`number`").Find(&eduStruListCont).Error |
|||
if err != nil { |
|||
overallhandle.Result(0, err, c) |
|||
} |
|||
a1 := 0 |
|||
a2 := 0 |
|||
a3 := 0 |
|||
a4 := 0 |
|||
a5 := 0 |
|||
a6 := 0 |
|||
a7 := 0 |
|||
a8 := 0 |
|||
a9 := 0 |
|||
a10 := 0 |
|||
a11 := 0 |
|||
a12 := 0 |
|||
for _, v := range eduStruListCont { |
|||
switch v.EducationMax { |
|||
case 1: |
|||
a1++ |
|||
case 2: |
|||
a2++ |
|||
case 3: |
|||
a3++ |
|||
case 4: |
|||
a4++ |
|||
case 5: |
|||
a5++ |
|||
case 6: |
|||
a6++ |
|||
case 7: |
|||
a7++ |
|||
case 8: |
|||
a8++ |
|||
case 9: |
|||
a9++ |
|||
case 10: |
|||
a10++ |
|||
case 11: |
|||
a11++ |
|||
case 12: |
|||
a12++ |
|||
default: |
|||
} |
|||
} |
|||
var sendEducStruCont []EducStruCont |
|||
sumPie := a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + a11 + a12 |
|||
if a1 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a1)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "初中及以下", Percentage: proportion}) |
|||
} |
|||
if a2 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a2)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "中专", Percentage: proportion}) |
|||
} |
|||
if a3 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a3)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "高中", Percentage: proportion}) |
|||
} |
|||
if a4 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a4)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "中技", Percentage: proportion}) |
|||
} |
|||
if a5 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a5)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "高技", Percentage: proportion}) |
|||
} |
|||
if a6 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a6)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "函数专科", Percentage: proportion}) |
|||
} |
|||
if a7 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a7)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "大学专科", Percentage: proportion}) |
|||
} |
|||
if a8 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a8)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "函数本科", Percentage: proportion}) |
|||
} |
|||
if a9 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a9)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "大学本科", Percentage: proportion}) |
|||
} |
|||
if a10 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a10)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "硕士研究生", Percentage: proportion}) |
|||
} |
|||
if a11 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a11)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "博士研究生", Percentage: proportion}) |
|||
} |
|||
if a12 != 0 { |
|||
var proportion float64 |
|||
if sumPie != 0 { |
|||
proportion = overallhandle.DecimalEs((float64(a12)/float64(sumPie))*100, 3) |
|||
} |
|||
sendEducStruCont = append(sendEducStruCont, EducStruCont{Education: "专家、教授", Percentage: proportion}) |
|||
} |
|||
overallhandle.Result(0, sendEducStruCont, c) |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package hrmodels |
|||
|
|||
import ( |
|||
"hr_server/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 学历结构
|
|||
type EducationalStructure struct { |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;comment:员工工号"` |
|||
Education int `json:"education" gorm:"column:education;type:int(5) unsigned;default:1;comment:学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)"` |
|||
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"` |
|||
EducationMax int `json:"educationmax" gorm:"column:educationmax;type:int(5) unsigned;default:1;comment:学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)"` |
|||
} |
|||
|
|||
func (EducationalStructure *EducationalStructure) TableName() string { |
|||
return "educational_structure" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *EducationalStructure) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *EducationalStructure) 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 *EducationalStructure) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *EducationalStructure) ContMap(whereMap interface{}, field ...string) (countAry []EducationalStructure, 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 *EducationalStructure) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
package hrmodels |
|||
|
|||
import ( |
|||
"hr_server/overall" |
|||
"strings" |
|||
) |
|||
|
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-06-29 15:21:07 |
|||
@ 功能: 人员变动时间 |
|||
@ 参数 |
|||
# |
|||
@ 返回值 |
|||
# |
|||
@ 方法原型 |
|||
# |
|||
*/ |
|||
// 金蝶人员状态关键字
|
|||
type EmpOnbArc struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
UserId int64 `json:"userid" gorm:"column:userid;type:bigint(20) unsigned;default:0;not null;comment:员工ID"` |
|||
EntryTime int64 `json:"entrytime" gorm:"column:entry_time;type:bigint(20) unsigned;default:0;not null;comment:入职时间"` |
|||
LeaveDate int64 `json:"leavedate" gorm:"column:leave_date;type:bigint(20) unsigned;default:0;not null;comment:离职日期"` |
|||
ZhuanZheng int64 `json:"zhuanzheng" gorm:"column:zhuan_zheng;type:bigint(20) unsigned;default:0;not null;comment:转正"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:时间"` |
|||
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:行政组织"` |
|||
} |
|||
|
|||
func (EmpOnbArc *EmpOnbArc) TableName() string { |
|||
return "emp_onb_arc" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *EmpOnbArc) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *EmpOnbArc) 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 *EmpOnbArc) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *EmpOnbArc) ContMap(whereMap interface{}, field ...string) (countAry []EmpOnbArc, 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 *EmpOnbArc) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
package hrmodels |
|||
|
|||
import ( |
|||
"hr_server/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 金蝶人员状态关键字
|
|||
type UserEmp struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
UserId int64 `json:"userid" gorm:"column:userid;type:bigint(20) unsigned;default:0;not null;comment:员工ID"` |
|||
EntryTime int64 `json:"entrytime" gorm:"column:entry_time;type:bigint(20) unsigned;default:0;not null;comment:入职时间"` |
|||
LeaveDate int64 `json:"leavedate" gorm:"column:leave_date;type:bigint(20) unsigned;default:0;not null;comment:离职日期"` |
|||
ZhuanZheng int64 `json:"zhuanzheng" gorm:"column:zhuan_zheng;type:bigint(20) unsigned;default:0;not null;comment:转正"` |
|||
RetireTime int64 `json:"retiretime" gorm:"column:retire_time;type:bigint(20) unsigned;default:0;not null;comment:退休"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:时间"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` |
|||
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"` |
|||
} |
|||
|
|||
func (UserEmp *UserEmp) TableName() string { |
|||
return "user_emp" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *UserEmp) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *UserEmp) 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 *UserEmp) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *UserEmp) ContMap(whereMap interface{}, field ...string) (countAry []UserEmp, 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 *UserEmp) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
Loading…
Reference in new issue