Browse Source

添加员工信息完成

v2_dev
超级管理员 3 years ago
parent
commit
6c042ad09c
  1. 37
      README_ZHAH.md
  2. 5
      api/version1/administrativeorganization/duties.go
  3. 95
      api/version1/administrativeorganization/position.go
  4. 2
      api/version1/administrativeorganization/type.go
  5. 35
      api/version1/personnelapi/controll.go
  6. 55
      api/version1/personnelapi/creadcsv.go
  7. 19
      api/version1/personnelapi/export_type.go
  8. 228
      api/version1/personnelapi/staff.go
  9. 153
      api/version1/personnelapi/staffarchives.go
  10. 44
      api/version1/personnelapi/type.go
  11. 1
      apirouter/organization/organization_group.go
  12. 5
      apirouter/personnel/people.go
  13. 13
      overall/overallhandle/overall_handle.go
  14. 1359
      uploads/人员档案表-57063582495412224.csv
  15. 1359
      uploads/人员档案表-57064901968924672.csv
  16. 1359
      uploads/人员档案表-57065368216145920.csv
  17. 1359
      uploads/人员档案表-57067478924136448.csv
  18. 1359
      uploads/人员档案表-57067938540163072.csv

37
README_ZHAH.md

@ -19,13 +19,14 @@
|—— overall
|—— middleware
```
## Hr 文件结构说明
| 文件夹 | 说明 | 描述|
|--------- |------ |-----|
| 文件夹 | 说明 | 描述 |
| ------------------ | ---------------- | ---------------------------------- |
| `api` | api相关业务 | api业务实现 |
| `--version1` | 业务版本文件夹 | 版本界定 |
| `--empower` |OAuth 2.0 授权 |授权Token|
| `--empower` | OAuth 2.0 授权 | 授权Token |
| `router` | 路由器 | 业务路由设定 |
| `initialization` | 初始化相关业务 | 系统初始化方面的实现 |
| `--database` | 数据库业务 | 数据库业务初始化实现 |
@ -38,10 +39,11 @@
| `--nosql` | nosql数据库业务 | nosql业务系统配置实现(例:Redis) |
| `--app` | app数据库业务 | app业务系统配置实现 |
| `models` | 数据模型 | 数据库方面的配置 |
| `overall` | 全局对象 | 全局对象|
| `overall` | 全局对象 | 全局对象 |
| `middleware` | 中间件 | 中间件 |
## 加密规则
```
1、分解步骤
one = md5(CodeString)+md5(AppKey)
@ -56,14 +58,16 @@
1、以POST方式访问 http://xxxx/empower/gaintoken
#### 参数
```json
{
"username":"jindie",
"password":"jindie123"
}
```
| 参数 | 说明 |
|---------|---------|
| -------- | ---- |
| username | 账号 |
| password | 密码 |
@ -81,20 +85,19 @@
```
| 参数 | 说明 | |
|---------|---------|---------|
| ---- | ------ | -------------------------- |
| code | | 状态码 |
| msg | | 信息 |
| data | | 附加值 |
| | token | Token(有效时间为180分钟) |
| | number | 随机数 |
1、以POST方式访问 http://xxxx/接口
#### Header参数
| 参数 | 说明 |
|---------|---------|
| ------------ | ------------------------------ |
| token | 获取到得参数 |
| number | 加密后得随机数(参考加密规则) |
| Content-Type | 内容类型 |
@ -102,18 +105,19 @@
| User-Agent | 用户代理 |
#### Body参数 (接口需要得添加参数)
```json
{
"page":"1",
"pagesize":"20"
}
```
| 参数 | 说明 |
|---------|---------|
| -------- | -------------- |
| page | 页码 |
| pagesize | 每页显示多少条 |
#### 返回值
```json
@ -131,7 +135,7 @@
```
| 参数 | 说明 | |
|---------|---------|---------|
| ---- | -------- | -------------- |
| code | | 状态码 |
| msg | | 信息 |
| data | | 附加值 |
@ -140,10 +144,11 @@
| | pageSize | 每页显示多少条 |
| | .... | .... |
#### 认证信息
| 参数 | 说明 |
|---------|---------|
| UserKey | zhihuianhuan|
| Password | zhi@hui$an%huan |
| VerificationCode | zhah_hr |
| ---------------- | ------------------------ |
| UserKey | SdRxjt@zhah001 |
| Password | Rx@Zhi$Hui%AnHuan |
| VerificationCode | rxjt_zhan |
| 访问地址 | http://120.224.6.6:39168 |

5
api/version1/administrativeorganization/duties.go

@ -34,7 +34,12 @@ func (o *OrganizationApi) DutiesList(c *gin.Context) {
if requestData.JobId != "" {
gormDb = gormDb.Where("duties.job_type = ?", requestData.JobId)
}
if requestData.State != 0 {
gormDb = gormDb.Where("duties.state = ?", requestData.State)
} else {
gormDb = gormDb.Where("duties.state IN ?", []int{1, 2})
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {

95
api/version1/administrativeorganization/position.go

@ -52,7 +52,12 @@ func (o *OrganizationApi) PositionList(c *gin.Context) {
if requestData.Department != "" {
gormDb = gormDb.Where("p.department = ?", requestData.Department)
}
if requestData.State == 0 {
gormDb = gormDb.Where("p.state IN ?", []int{1, 2})
} else {
gormDb = gormDb.Where("p.state = ?", requestData.State)
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
@ -698,3 +703,93 @@ func (o *OrganizationApi) EitePositionContNew(c *gin.Context) {
overallhandle.Result(0, saveData, c)
}
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-26 09:29:38
@ 功能: 获取本行政组织下的岗位
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (o *OrganizationApi) GetMyPositionList(c *gin.Context) {
var requestData lookPositionList
c.ShouldBindJSON(&requestData)
if requestData.Page < 0 {
requestData.Page = 1
}
if requestData.PageSize < 0 {
requestData.PageSize = 10
}
// gormDb := overall.CONSTANT_DB_HR.Model(&models.JobClass{}).Select("").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type")
var positionType models.Position
gormDb := overall.CONSTANT_DB_HR.Table(fmt.Sprintf("%s p", positionType.TableName())).Select("p.*,d.name as dutiesname,d.number as dutiesnumber,ao.name as aoname,ao.number as aonumber,j.name as jobname").Joins("left join duties as d on d.id = p.duties").Joins("left join administrative_organization as ao on ao.id = p.administrative_organization").Joins("left join job_class as j on j.id = d.job_type")
if requestData.Name != "" {
gormDb = gormDb.Where("p.name LIKE ?", "%"+requestData.Name+"%")
}
if requestData.Number != "" {
gormDb = gormDb.Where("p.number LIKE ?", "%"+requestData.Number+"%")
}
if requestData.Duties != "" {
gormDb = gormDb.Where("p.duties = ?", requestData.Duties)
}
if requestData.Organization != "" {
// orgIdInt, _ := strconv.ParseInt(requestData.Organization, 10, 64)
// orgIdList := overallhandle.GetDepartmentSun(orgIdInt, []int64{})
// orgIdList = append(orgIdList, orgIdInt)
gormDb = gormDb.Where("p.administrative_organization = ?", requestData.Organization)
// fmt.Printf("所有子集--->%v\n", orgIdList)
// var sunAry overallhandle.AllSunList[int64]
// sunAry.GetAllSunOrg(orgIdInt)
// sunAry.SunList = append(sunAry.SunList, orgIdInt)
// gormDb = gormDb.Where("p.administrative_organization IN ?", sunAry.SunList)
}
if requestData.InCharge != 0 {
gormDb = gormDb.Where("p.person_in_charge = ?", requestData.InCharge)
}
if requestData.Department != "" {
gormDb = gormDb.Where("p.department = ?", requestData.Department)
}
gormDb = gormDb.Where("p.state = ?", 1)
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
var positionAry []positionOutInfo
// errGorm := gormDb.Order("p.department DESC,p.duties DESC,p.duties ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&positionAry).Error
errGorm := gormDb.Order("p.id DESC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&positionAry).Error
for i, v := range positionAry {
var getSpur models.Position
getWhe := overallhandle.MapOut()
getWhe["id"] = v.Superior
// fmt.Printf("%v\n", v.Superior)
getSpur.GetCont(getWhe, "number", "name")
positionAry[i].SuperiorNumber = getSpur.Number
positionAry[i].SuperiorName = getSpur.Name
var getSpurDepart models.AdministrativeOrganization
getWheDepart := overallhandle.MapOut()
getWheDepart["id"] = v.Department
getSpurDepart.GetCont(getWheDepart, "name")
positionAry[i].DepartmentName = getSpurDepart.Name
positionAry[i].IdStr = strconv.FormatInt(v.Id, 10)
}
if errGorm != nil {
overallhandle.Result(105, errGorm, c)
} else {
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c)
}
}

2
api/version1/administrativeorganization/type.go

@ -49,6 +49,7 @@ type EiteJobStateDel struct {
type dutiesListType struct {
JobClassPageSelect
JobId string `json:"jobid"`
State int `json:"state"`
}
// 职务输出
@ -155,6 +156,7 @@ type lookPositionList struct {
Organization string `json:"organization"` //归属行政组织
InCharge int `json:"incharge"` //是否为本部门负责人(1:是;2:否)
Department string `json:"department"` //部门
State int `json:"state"` //1:启用;2:禁用,3:删除
}
// 职务列表输出

35
api/version1/personnelapi/controll.go

@ -304,3 +304,38 @@ func hestacademicdegreeToInt(hir string) int {
return 0
}
}
func EmptypeToStr(emp int) string {
switch emp {
case 1:
return "临时工"
case 2:
return "编外人员"
case 3:
return "实习&实习生"
case 4:
return "试用员工"
case 5:
return "待分配"
case 6:
return "待岗"
case 7:
return "临时调入"
case 8:
return "正式员工"
case 9:
return "长期病假"
case 10:
return "停薪留职"
case 11:
return "退休"
case 12:
return "辞职"
case 13:
return "辞退"
case 14:
return "离职"
default:
return "临时工"
}
}

55
api/version1/personnelapi/creadcsv.go

@ -0,0 +1,55 @@
package personnelapi
import (
"encoding/csv"
"fmt"
"hr_server/middleware/snowflake"
"hr_server/overall/overallhandle"
"os"
)
/**
@ 作者: 秦东
@ 时间: 2022-11-26 10:01:34
@ 功能: 创建csv文件
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func WriteCsvFile(fileName string, titleAry []string, bodyAry []ExportPeopleCont) (string, error) {
if len(titleAry) < 1 && len(bodyAry) < 1 {
return "", nil
}
var manKeyNum int64 = 0
node, nodeErr := snowflake.NewWorker(1)
if nodeErr == nil {
manKeyNum = node.GetId()
} else {
manKeyNum = overallhandle.TableNumber()
}
//创建csv文件
filename := fmt.Sprintf("%v-%v.csv", fileName, manKeyNum)
xlsFile, fErr := os.OpenFile("uploads/"+filename, os.O_RDWR|os.O_CREATE, 0766)
if fErr != nil {
fmt.Println("Export:created excel file failed ==", fErr)
return "", fErr
}
defer xlsFile.Close()
//开始写入内容
xlsFile.WriteString("\xEF\xBB\xBF") //写入UTF-8 BOM,此处如果不写入就会导致写入的汉字乱码
wStr := csv.NewWriter(xlsFile)
wStr.Write(titleAry) //写入标题栏
//写入主体
for _, v := range bodyAry {
wStr.Write([]string{fmt.Sprintf("%v\t", v.Number), v.Name, fmt.Sprintf("%v\t", v.Tel), fmt.Sprintf("%v\t", v.Idcardenddate), v.Org, v.Post, v.Team, v.EmpTypeNAme})
}
// wStr.Write(bodyAry)
wStr.Flush()
return filename, nil
}

19
api/version1/personnelapi/export_type.go

@ -0,0 +1,19 @@
package personnelapi
import "github.com/gin-gonic/gin"
type ExportServer struct {
engine *gin.Engine
}
//导出人员信息
type ExportPeopleCont struct {
Number string `json:"number"`
Name string `json:"name"`
Tel string `json:"tel"`
Idcardenddate string `json:"idcardenddate"`
Org string `json:"org"`
Post string `json:"post"`
Team string `json:"team"`
EmpTypeNAme string `json:"emptype"`
}

228
api/version1/personnelapi/staff.go

@ -1471,3 +1471,231 @@ func (s *StaffApi) EditPassWord(c *gin.Context) {
}
overallhandle.Result(0, err, c, "修改成功!")
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-26 13:36:23
@ 功能: 添加员工信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (s *StaffApi) AddPeopleCont(c *gin.Context) {
var requestData AddNewPeopleCont
c.ShouldBindJSON(&requestData)
if requestData.Number == "" {
overallhandle.Result(1, requestData.Number, c, "工号不能为空!")
return
}
if requestData.Name == "" {
overallhandle.Result(1, requestData.Name, c, "姓名不能为空!")
return
}
if requestData.Icon == "" {
overallhandle.Result(1, requestData.Name, c, "请上传员工照片")
return
}
if requestData.Gender == 0 {
requestData.Gender = 1
}
if requestData.HireType == 0 {
requestData.HireType = 1
}
if requestData.EmpType == 0 {
requestData.HireType = 3
}
if requestData.AdminOrg == 0 {
overallhandle.Result(1, requestData.AdminOrg, c, "请选择员工归属行政组织!")
return
}
if requestData.Position == 0 {
overallhandle.Result(1, requestData.Position, c, "请选择人员职务!")
return
}
if requestData.TeamId == 0 {
overallhandle.Result(1, requestData.TeamId, c, "请选择人员归属班组!")
return
}
if requestData.PositionGrade == 0 {
requestData.PositionGrade = 3
return
}
if requestData.Mobilephone == "" {
overallhandle.Result(1, requestData.Mobilephone, c, "请输入人员手机号!")
return
}
if requestData.Health == 0 {
requestData.Health = 2
return
}
if requestData.EntryDate == "" {
overallhandle.Result(1, requestData.EntryDate, c, "请输入人员入职日期!")
return
}
if requestData.ProbationPeriod == 0 {
requestData.ProbationPeriod = 3
return
}
if requestData.IDCardNo == "" {
overallhandle.Result(1, requestData.IDCardNo, c, "请输入员工身份证号码!")
return
}
if requestData.PoliticalOutlook == 0 {
requestData.PoliticalOutlook = 1 //政治面貌
}
if requestData.HireType == 0 {
requestData.HireType = 1
}
// if requestData.JobId == 0 {
// requestData.JobId = 1
// }
if requestData.Maritalstatus == 0 {
requestData.Maritalstatus = 1
}
if requestData.Constellation == 0 {
requestData.Constellation = 1
}
if requestData.Isveterans == 0 {
requestData.Isveterans = 2
}
//员工档案主
var staffInfo models.PersonArchives
//判断工号是存在
whereAry := overallhandle.MapOut()
whereAry["number"] = requestData.Number
if judgeNoErr := staffInfo.GetCont(whereAry, "number"); judgeNoErr == nil {
overallhandle.Result(1, requestData, c, "该工号已经被使用!请不要重复使用!")
return
}
isMeKey := overallhandle.OnlyOneNumber(3) //获取唯一编号
setTime := time.Now().Unix()
staffInfo.Number = requestData.Number
staffInfo.Name = requestData.Name
staffInfo.Icon = requestData.Icon
staffInfo.HireClass = requestData.HireType
staffInfo.EmpType = requestData.EmpType
//获取相关行政组织
_, companyId, departmentId, sunDepartId, _ := overallhandle.GetOrgStructure(requestData.AdminOrg)
staffInfo.Company = companyId //公司
staffInfo.MainDeparment = departmentId //主部门
staffInfo.SunMainDeparment = sunDepartId //二级部门
staffInfo.AdminOrg = requestData.AdminOrg //行政组织
staffInfo.TeamId = requestData.TeamId //班组
staffInfo.Position = requestData.Position
//获取职务及职务分类
if requestData.JobId == 0 {
var postDuitesCont models.PostDutiesJob
postDuitesCont.GetCont(map[string]interface{}{"id": requestData.Position}, "`duties`", "`job_type`")
staffInfo.JobClass = postDuitesCont.JobType
staffInfo.JobId = postDuitesCont.Duties
} else {
var dutiesCont models.Duties
dutiesCont.GetCont(map[string]interface{}{"id": requestData.JobId}, "`job_type`")
staffInfo.JobClass = dutiesCont.JobType
staffInfo.JobId = requestData.JobId
}
staffInfo.JobLeve = requestData.PositionGrade //入职等级
staffInfo.Time = setTime
staffInfo.EiteTime = setTime
staffInfo.State = 1
staffInfo.Key = isMeKey
staffInfo.WorkWechat = requestData.WeorWechat
//员工资料副表
var peopleContEs models.PersonnelContent
peopleContEs.Key = isMeKey
peopleContEs.Number = requestData.Number
peopleContEs.Passportno = requestData.Passportno
peopleContEs.Globalroaming = requestData.Globalroaming
peopleContEs.Idcardno = requestData.IDCardNo
peopleContEs.Mobilephone = requestData.Mobilephone
peopleContEs.Gender = requestData.Gender
brrthday, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.Birthday))
peopleContEs.Birthday = brrthday
peopleContEs.Myfolk = requestData.Nation
peopleContEs.Nativeplace = requestData.NativePlace
idCardStarTime := time.Now().Unix()
if requestData.IdCardStartDate != "" {
idCardStarTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.IdCardStartDate))
}
peopleContEs.Idcardstartdate = idCardStarTime //身份证有效期开始
idCardEndTime := time.Now().Unix()
if requestData.IdCardEndDate != "" {
idCardEndTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.IdCardEndDate))
}
peopleContEs.Idcardenddate = idCardEndTime //身份证有效期结束
peopleContEs.Health = requestData.Health
peopleContEs.Maritalstatus = requestData.Maritalstatus
peopleContEs.Internaltelephone = ""
peopleContEs.Currentresidence = requestData.CurrentResidence
peopleContEs.Time = setTime
peopleContEs.Constellation = requestData.Constellation
peopleContEs.Isveterans = requestData.Isveterans
peopleContEs.Veteransnumber = requestData.Veteransnumber
workInData := setTime
if requestData.WorkingDate != "" {
workInData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.WorkingDate))
}
peopleContEs.Jobstartdate = workInData
entryData := setTime
if requestData.EntryDate != "" {
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.EntryDate))
}
peopleContEs.Entrydate = entryData
peopleContEs.Probationperiod = requestData.ProbationPeriod
planformalData := setTime
if requestData.ConfirmationDate != "" {
planformalData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.ConfirmationDate))
} else {
planformalData = overallhandle.GetFutureMonthTime(entryData, requestData.ProbationPeriod, 2)
}
peopleContEs.Planformaldate = planformalData
peopleContEs.PoliticalOutlook = requestData.PoliticalOutlook
//开启事务
gromDbBeginAffair := overall.CONSTANT_DB_HR.Begin()
gromDbBeginAffair.SavePoint("CallBackBegin")
mainPeopenContErr := gromDbBeginAffair.Create(&staffInfo).Error
mainPeopenContEsErr := gromDbBeginAffair.Create(&peopleContEs).Error
fmt.Printf("开启事务%v----------%v\n", mainPeopenContErr, mainPeopenContEsErr)
if mainPeopenContErr == nil && mainPeopenContEsErr == nil {
addErr := gromDbBeginAffair.Commit().Error
overallhandle.Result(0, addErr, c)
} else {
gromDbBeginAffair.RollbackTo("CallBackBegin")
addErr := gromDbBeginAffair.Rollback().Error
overallhandle.Result(104, addErr, c)
}
// addErr := overall.CONSTANT_DB_HR.Transaction(func(tx *gorm.DB) error {
// mainPeopenContErr := tx.Create(&staffInfo).Error
// if mainPeopenContErr != nil {
// return mainPeopenContErr
// }
// mainPeopenContEsErr := tx.Create(&peopleContEs).Error
// if mainPeopenContEsErr != nil {
// return mainPeopenContEsErr
// }
// return nil
// })
// if addErr != nil {
// overallhandle.Result(104, addErr, c)
// } else {
// overallhandle.Result(0, addErr, c)
// }
}

153
api/version1/personnelapi/staffarchives.go

@ -1802,3 +1802,156 @@ func (s *StaffApi) EditUsWechatOpenId(c *gin.Context) {
}
overallhandle.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-26 10:57:26
@ 功能: 导出人员信息
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (s *StaffApi) ArchivesListExporCsv(c *gin.Context) {
var requestData peopleList
c.ShouldBindJSON(&requestData)
if requestData.Page < 0 {
requestData.Page = 1
}
if requestData.PageSize < 0 {
requestData.PageSize = 10
}
gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("state = 1")
if requestData.Number != "" {
gormDb = gormDb.Where("number LIKE ?", "%"+requestData.Number+"%")
}
if requestData.Name != "" {
gormDb = gormDb.Where("name LIKE ?", "%"+requestData.Name+"%")
}
if requestData.HireClass != 0 {
gormDb = gormDb.Where("hire_class = ?", requestData.HireClass)
}
if requestData.Company != 0 {
gormDb = gormDb.Where("company = ?", requestData.Company)
}
// if requestData.Deparment != "" {
// gormDb = gormDb.Where("FIND_IN_SET(?,`deparment`)", requestData.Deparment)
// }
if requestData.AdminOrg != 0 {
var sunAry overallhandle.AllSunList[int64]
sunAry.GetAllSunOrg(requestData.AdminOrg)
sunAry.SunList = append(sunAry.SunList, requestData.AdminOrg)
gormDb = gormDb.Where("admin_org IN ?", sunAry.SunList)
}
if requestData.Position != 0 {
gormDb = gormDb.Where("position = ?", requestData.Position)
}
if requestData.EmpType != 0 {
gormDb = gormDb.Where("emp_type = ?", requestData.EmpType)
} else {
gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 1, 10)
}
if requestData.Role != "" {
gormDb = gormDb.Where("FIND_IN_SET(?,`role`)", requestData.Role)
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
var idAry []int64
// errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&staffList).Error
errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&idAry).Error
var positionAry []peopleManOutList
var manContList []models.ManCont
errGorm = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Find(&manContList).Error
var peopleContList []ExportPeopleCont
for _, v := range manContList {
var staffInfo peopleManOutList
staffInfo.ManCont = v
var getSpur models.Position
getWhe := overallhandle.MapOut()
getWhe["id"] = v.Position
getSpur.GetCont(getWhe, "name", "person_in_charge")
staffInfo.PositionName = getSpur.Name
staffInfo.PersonInCharge = getSpur.PersonInCharge
staffInfo.KeyStr = strconv.FormatInt(v.Key, 10)
//公司
if v.Company != 0 {
var getSpurDepart models.AdministrativeOrganization
getWheDepart := overallhandle.MapOut()
getWheDepart["id"] = v.Company
getSpurDepart.GetCont(getWheDepart, "name")
staffInfo.CompanyName = getSpurDepart.Name
}
//主部门
if v.MainDeparment != 0 {
var getSpurDepartMain models.AdministrativeOrganization
getWheDepartMain := overallhandle.MapOut()
getWheDepartMain["id"] = v.MainDeparment
getSpurDepartMain.GetCont(getWheDepartMain, "name")
staffInfo.MainDeparmentName = getSpurDepartMain.Name
}
//二级著部门
if v.SunMainDeparment != 0 {
var sunMainDepart models.AdministrativeOrganization
sunMainDepart.GetCont(map[string]interface{}{"`id`": v.SunMainDeparment}, "`name`")
staffInfo.SunMainDeparmentName = sunMainDepart.Name
}
//获取部门
// departmentAry := strings.Split(v.Deparment, ",")
// if len(departmentAry) > 0 {
// var departCont []getDepartmentInfo
// departErr := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("id,number,name").Where("`id` IN ?", departmentAry).Order("`organization_type` ASC").Find(&departCont).Error
// if departErr == nil {
// var departNameAry []string
// for _, d_v := range departCont {
// departNameAry = append(departNameAry, d_v.Name)
// }
// if len(departNameAry) > 0 {
// staffInfo.DeparmentName = strings.Join(departNameAry, " ")
// }
// }
// }
var orgContTypeCont models.OrgContType
orgContTypeCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`", "`level`")
if orgContTypeCont.Level >= 6 {
staffInfo.WorkPostName = orgContTypeCont.Name
}
positionAry = append(positionAry, staffInfo)
var peoCont ExportPeopleCont
peoCont.Number = staffInfo.Number // `json:"number"`
peoCont.Name = staffInfo.Name // `json:"name"`
peoCont.Tel = staffInfo.Mobilephone // `json:"tel"`
peoCont.Idcardenddate = staffInfo.Idcardno // `json:"idcardenddate"`
peoCont.Org = fmt.Sprintf("%v/%v/%v", staffInfo.CompanyName, staffInfo.MainDeparmentName, staffInfo.SunMainDeparmentName) // `json:"org"`
peoCont.Post = staffInfo.PositionName // `json:"post"`
peoCont.Team = staffInfo.TeamName // `json:"team"`
peoCont.EmpTypeNAme = EmptypeToStr(staffInfo.EmpType)
peopleContList = append(peopleContList, peoCont)
}
if errGorm != nil {
overallhandle.Result(105, errGorm, c)
} else {
titleAry := []string{"工号", "姓名", "联系电话", "身份证号", "行政组织", "职务", "班组", "状态"}
filename, errCsv := WriteCsvFile("人员档案表", titleAry, peopleContList)
// overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c)
fmt.Printf("导出------------->%v,%v", filename, errCsv)
overallhandle.Result(1, filename, c)
}
}

44
api/version1/personnelapi/type.go

@ -62,6 +62,7 @@ type peopleManOutList struct {
WorkPostName string `json:"workpostname"` //工段名称
PositionName string `json:"positionname"` //职位
KeyStr string `json:"keystr"` //身份认证
TeamName string `json:"teamname"` //班组
PersonInCharge int `json:"personincharge"` //负责人
}
@ -472,3 +473,46 @@ type EditweChatUserId struct {
WechatId string `json:"wechatid"` //微信OpenId
WorkWechatId string `json:"workwechatid"` //企业微信OpenId
}
// 添加新员工
type AddNewPeopleCont struct {
Number string `json:"number"` //工号1 v
Name string `json:"name"` //姓名1 v
Icon string `json:"icon"` //头像 v
HireType int `json:"hiretype"` //1雇佣类型(1:雇佣入职;2:再入职;3:返聘) L
EmpType int `json:"emptype"` //用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职) int L
AdminOrg int64 `json:"adminorg"` //工段 v
Position int64 `json:"position"` //职位(岗位)1 v
JobId int64 `json:"jobid"` //职务 L
PositionGrade int64 `json:"positiongrade"` //入职等级 int64 L
TeamId int64 `json:"team"` //班组 v
WeorWechat string `json:"weorwechat"` //企业微信Openid
Mobilephone string `json:"mobilephone"` //联系电话 v
Gender int `json:"gender"` //性别 L
Birthday string `json:"birthday"` //生日
Nation string `json:"nation"` //民族
Health int `json:"health"` //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废 v
Maritalstatus int `json:"maritalstatus"` //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异) L
NativePlace string `json:"nativeplace"` //籍贯
CurrentResidence string `json:"currentresidence"` //现居地
WorkingDate string `json:"workingdate"` //参加工作日期
EntryDate string `json:"entrydate"` //入职日期 v
ProbationPeriod int `json:"probationperiod"` //试用期(月) v
ConfirmationDate string `json:"confirmationdate"` //转正日期
Constellation int `json:"constellation"` //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座) L
PoliticalOutlook int `json:"politicaloutlook"` //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
Isveterans int `json:"isveterans"` //是否为退役军人(1:是;2:否) L
Veteransnumber string `json:"veteransnumber"` //退役证编号
IDCardNo string `json:"idcardno"` //身份证号码 v
Passportno string `json:"passportno"` //护照号码
Globalroaming string `json:"globalroaming"` //国际区号
IdCardStartDate string `json:"idcardstartdate"` //身份证有效期开始时间
IdCardEndDate string `json:"idcardenddate"` //身份证有效期结束时间
}
// 密码相关
type passwordCont struct {
Password string `json:"password"` //密码1 v
ConfirmPassword string `json:"confirmPassword"` // v
}

1
apirouter/organization/organization_group.go

@ -58,6 +58,7 @@ func (o *OrganizationRoute) InitRouterGroup(route *gin.RouterGroup) {
apiRouter.POST("basis_org_postList", apiHandle.BasisOrgGetPostList) //根据行政组织获取岗位
apiRouter.POST("addpositioncontnew", apiHandle.AddPositionContNew) //添加职位(岗位)新版
apiRouter.POST("get_my_posit_list", apiHandle.GetMyPositionList) //获取本岗位下的职位(岗位)列表不包含子行政组织
//班组
apiRouter.POST("teamcontlist", apiHandle.TeamContList) //班组列表

5
apirouter/personnel/people.go

@ -54,6 +54,11 @@ func (p *PersonnelRoute) InitRouterGroup(route *gin.RouterGroup) {
apiRouter.POST("addinsidehistory", apiHandle.AddInsideHistory) //添加集团工作履历
apiRouter.POST("eidtinsidehistoryworkcont", apiHandle.EidtInsideHistoryWorkCont) //编辑集团工作履历
apiRouter.POST("editordelinsideworkhistorystate", apiHandle.EditOrDelInsideWorkHistoryState) //编辑集团工作履历状态
apiRouter.POST("archives_list_exporcsv", apiHandle.ArchivesListExporCsv) //导出人员信息
apiRouter.POST("add_people_cont", apiHandle.AddPeopleCont) //写入人员信息(新版)
}
}

13
overall/overallhandle/overall_handle.go

@ -7,6 +7,7 @@ import (
"crypto/sha1"
"encoding/hex"
"fmt"
"hr_server/middleware/snowflake"
"hr_server/models"
"hr_server/overall"
"math"
@ -32,6 +33,18 @@ func TableNumber(class ...string) (number int64) {
return
}
// 获取唯一编号
func OnlyOneNumber(id int64) (manKeyNum int64) {
node, nodeErr := snowflake.NewWorker(id)
if nodeErr == nil {
manKeyNum = node.GetId()
} else {
idStr := strconv.FormatInt(id, 10)
manKeyNum = TableNumber(idStr)
}
return
}
// 初始化map
func MapOut() (data map[string]interface{}) {
data = make(map[string]interface{}) //必可不少,分配内存

1359
uploads/人员档案表-57063582495412224.csv

File diff suppressed because it is too large

1359
uploads/人员档案表-57064901968924672.csv

File diff suppressed because it is too large

1359
uploads/人员档案表-57065368216145920.csv

File diff suppressed because it is too large

1359
uploads/人员档案表-57067478924136448.csv

File diff suppressed because it is too large

1359
uploads/人员档案表-57067938540163072.csv

File diff suppressed because it is too large
Loading…
Cancel
Save