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.
923 lines
32 KiB
923 lines
32 KiB
package positionkpi
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"gin_server_admin/commonus"
|
|
"gin_server_admin/global"
|
|
"gin_server_admin/model/assessmentmodel"
|
|
"gin_server_admin/model/common/response"
|
|
"gin_server_admin/model/hrsystem"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
//岗位定性指标及指标细则
|
|
|
|
// 获取指标关联的岗位
|
|
func (a *ApiMethod) TargetOrgList(c *gin.Context) {
|
|
var requestData idType
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(100, err, "参数错误!", c)
|
|
return
|
|
}
|
|
var targetPostCont assessmentmodel.PostTarget
|
|
tarErr := targetPostCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "rele_depart", "departments_post")
|
|
if tarErr != nil {
|
|
response.Result(100, err, "该指标不存在", c)
|
|
return
|
|
}
|
|
postAry := strings.Split(targetPostCont.DepartmentsPost, ",")
|
|
|
|
var outList postTargetDepart
|
|
outList.DepartmentId = strconv.FormatInt(targetPostCont.ReleDepart, 10)
|
|
var postContAry []hrsystem.AdministrativeOrganization
|
|
var postContAryErr error
|
|
if len(postAry) > 0 {
|
|
postContAry, postContAryErr = getOrgList(postAry)
|
|
if postContAryErr != nil {
|
|
postContAry, postContAryErr = getOrgList(targetPostCont.ReleDepart)
|
|
}
|
|
} else {
|
|
postContAry, postContAryErr = getOrgList(targetPostCont.ReleDepart)
|
|
}
|
|
for _, v := range postContAry {
|
|
var outOrgCont idAndName
|
|
outOrgCont.Id = strconv.FormatInt(v.Id, 10)
|
|
outOrgCont.Name = v.Name
|
|
outList.PostList = append(outList.PostList, outOrgCont)
|
|
}
|
|
response.Result(0, outList, "查询成功!", c)
|
|
}
|
|
|
|
// 获取行政组织岗位
|
|
func getOrgList(wher interface{}) (orgCont []hrsystem.AdministrativeOrganization, err error) {
|
|
switch wher.(type) {
|
|
case []string:
|
|
err = global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("`id`,`name`").Where("`id` IN ?", wher).Find(&orgCont).Error
|
|
case int64:
|
|
err = global.GVA_DB_HrDataBase.Model(&hrsystem.AdministrativeOrganization{}).Select("`id`,`name`").Where("`superior` = ?", wher).Find(&orgCont).Error
|
|
default:
|
|
}
|
|
return
|
|
}
|
|
|
|
// 添加岗位细则
|
|
func (a *ApiMethod) AddPostTargetCont(c *gin.Context) {
|
|
var requestData addPostContTarget
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.TargetId == "" {
|
|
response.Result(100, requestData, "请选择岗位指标!", c)
|
|
return
|
|
}
|
|
if requestData.DepartmentId == "" {
|
|
response.Result(101, requestData, "请选择行政组织!", c)
|
|
return
|
|
}
|
|
if requestData.TargetSunTitle == "" {
|
|
response.Result(102, requestData, "请输入子栏目名称!", c)
|
|
return
|
|
}
|
|
if len(requestData.PostId) < 1 {
|
|
response.Result(103, requestData, "请选择岗位!", c)
|
|
return
|
|
}
|
|
if len(requestData.List) < 1 {
|
|
response.Result(104, requestData, "请输入指标细则!", c)
|
|
return
|
|
}
|
|
xiZeIsTrue := 1
|
|
for _, v := range requestData.List {
|
|
if v.Title == "" {
|
|
xiZeIsTrue = 2
|
|
break
|
|
}
|
|
if v.ReferenceScore == "" {
|
|
xiZeIsTrue = 2
|
|
break
|
|
}
|
|
if v.Unit == "" {
|
|
xiZeIsTrue = 2
|
|
break
|
|
}
|
|
}
|
|
|
|
if xiZeIsTrue != 1 {
|
|
response.Result(105, requestData, "请检查你输入的指标细则!其中有不符合标准的细则!", c)
|
|
return
|
|
}
|
|
targetSunIdInt, _ := strconv.ParseInt(requestData.TargetId, 10, 64)
|
|
deartmentIdInt, _ := strconv.ParseInt(requestData.DepartmentId, 10, 64)
|
|
//指标子栏目
|
|
var sunTargetCont assessmentmodel.PostSunTarget
|
|
sunErr := sunTargetCont.GetCont(map[string]interface{}{"`title`": requestData.TargetSunTitle, "`parent_id`": requestData.TargetId, "depart": requestData.DepartmentId}, "`id`")
|
|
if sunErr != nil {
|
|
sunTargetCont.Title = requestData.TargetSunTitle //标题"`
|
|
|
|
sunTargetCont.ParentId = targetSunIdInt //归属指标"`
|
|
sunTargetCont.Time = time.Now().Unix() //创建时间"`
|
|
sunTargetCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
sunTargetCont.Depart = deartmentIdInt //关联部门"`
|
|
sunTargetCont.DepartPost = strings.Join(requestData.PostId, ",")
|
|
sunTargetErr := global.GVA_DB_Performanceappraisal.Create(&sunTargetCont).Error
|
|
if sunTargetErr != nil {
|
|
response.Result(108, sunTargetCont, "数据写入失败!", c)
|
|
return
|
|
}
|
|
}
|
|
if sunTargetCont.Id == 0 {
|
|
response.Result(109, sunErr, "数据写入失败!", c)
|
|
return
|
|
}
|
|
var saveData []assessmentmodel.PostTargetDetails
|
|
for _, lv := range requestData.List {
|
|
|
|
if lv.Class == 0 {
|
|
lv.Class = 1
|
|
}
|
|
if len(lv.Inspect) == 0 {
|
|
lv.Inspect = append(lv.Inspect, "1")
|
|
}
|
|
if lv.Cycle == 0 {
|
|
lv.Cycle = 4
|
|
}
|
|
if lv.CycleAttr == 0 {
|
|
lv.CycleAttr = 1
|
|
}
|
|
|
|
var minScoreInt int64
|
|
var maxScoreInt int64
|
|
scoreAry := strings.Split(lv.ReferenceScore, "-")
|
|
scoreLen := len(scoreAry)
|
|
// fmt.Printf("ScoreAry:%v----------->%v------------>%v------------>%v\n", ReferenceScore, scoreLen, scoreAry[0], scoreAry)
|
|
if scoreLen > 0 {
|
|
if scoreLen == 1 {
|
|
maxScore, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
// zhhh := maxScore * 100
|
|
// zhuanStr := strconv.FormatFloat(zhhh, 'f', -1, 64)
|
|
maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64)
|
|
minScoreInt = 0
|
|
} else {
|
|
minScore, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
maxScore, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64)
|
|
minScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64)
|
|
maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64)
|
|
}
|
|
} else {
|
|
minScoreInt = 0
|
|
maxScoreInt = 0
|
|
}
|
|
|
|
var minMoney int64 //罚款或奖励最高金额
|
|
var maxMoney int64 //罚款或奖励最新金额
|
|
moneyAry := strings.Split(lv.CashStandard, "-")
|
|
moneyAryLen := len(moneyAry)
|
|
if moneyAryLen > 0 {
|
|
if moneyAryLen == 1 {
|
|
maxMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64)
|
|
maxMoney, _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
minMoney = 0
|
|
} else {
|
|
maxMoneyEs, _ := strconv.ParseFloat(moneyAry[moneyAryLen-1], 64)
|
|
maxMoney, _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
minMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64)
|
|
minMoney, _ = strconv.ParseInt(strconv.FormatFloat(minMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
}
|
|
} else {
|
|
minMoney = 0
|
|
maxMoney = 0
|
|
}
|
|
|
|
var saveCont assessmentmodel.PostTargetDetails
|
|
saveCont.Title = lv.Title //指标细则"`
|
|
saveCont.Content = lv.Explain //备注说明"`
|
|
saveCont.ParentId = targetSunIdInt //归属指标栏目"`
|
|
saveCont.ParentIdSun = sunTargetCont.Id //归属指标子栏目"`
|
|
saveCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
saveCont.AddTime = time.Now().Unix() //制定时间"`
|
|
saveCont.MinScore = minScoreInt //最小分*100保存"`
|
|
saveCont.MaxScore = maxScoreInt //最大分*100保存"`
|
|
saveCont.Company = lv.Unit //单位"`
|
|
saveCont.AddReduce = lv.Class //1:减少;2:增加;3:无属性,现场确认加或减"`
|
|
saveCont.CensorType = strings.Join(lv.Inspect, ",") //检查方式"`
|
|
saveCont.CensorCont = lv.Evidence //客观证据"`
|
|
saveCont.CensorRate = lv.Cycle //检查频次"`
|
|
saveCont.Cycles = lv.CycleAttr //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
saveCont.CycleAttres = lv.CycleAttr //辅助计数"`
|
|
saveCont.Paretment = deartmentIdInt //接受考核的部门"`
|
|
saveCont.ParetmentPost = strings.Join(requestData.PostId, ",") //接受考核的部门岗位"`
|
|
saveCont.Reportary = strings.Join(lv.ReportAry, ",") //接受考核的部门岗位"`
|
|
|
|
saveCont.Punishmode = lv.PunishMode //处罚或奖励方式 1:分数;2:现金;3:分数加现金
|
|
saveCont.Minmoney = minMoney //最高罚款*100保存"`
|
|
saveCont.Maxmoney = maxMoney //最低罚款*100保存"`
|
|
|
|
saveData = append(saveData, saveCont)
|
|
}
|
|
if len(saveData) < 1 {
|
|
response.Result(106, sunErr, "数据写入失败!", c)
|
|
return
|
|
}
|
|
saveErr := global.GVA_DB_Performanceappraisal.Create(&saveData).Error
|
|
if saveErr != nil {
|
|
response.Result(107, sunErr, "数据写入失败!", c)
|
|
return
|
|
}
|
|
//获取该子栏目关联到的岗位
|
|
var tarPostDetaList []assessmentmodel.PostTargetDetails
|
|
tarErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PostTargetDetails{}).Select("paretment_post").Where("`state` = 1 AND `parentid` = ? AND `parentid_sun` = ? AND `paretment` =?", requestData.TargetId, targetSunIdInt, deartmentIdInt).Find(&tarPostDetaList).Error
|
|
if tarErr == nil {
|
|
var postIdStr []string
|
|
for _, tarv := range tarPostDetaList {
|
|
if tarv.ParetmentPost != "" {
|
|
detPost := strings.Split(tarv.ParetmentPost, ",")
|
|
if len(detPost) > 0 {
|
|
for _, detv := range detPost {
|
|
if commonus.IsInTrue[string](detv, postIdStr) == false {
|
|
postIdStr = append(postIdStr, detv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(postIdStr) > 0 {
|
|
var sunTargetContInfo assessmentmodel.PostSunTarget
|
|
sunTargetContInfo.EditCont(map[string]interface{}{"`id`": sunTargetCont.Id}, map[string]interface{}{"depart_post": strings.Join(postIdStr, ",")})
|
|
}
|
|
}
|
|
response.Result(0, saveErr, "数据写入成功!", c)
|
|
}
|
|
|
|
// 岗位定性考核列表
|
|
func (a *ApiMethod) PostTargetSunList(c *gin.Context) {
|
|
var requestData lookPostTargetDeta
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Page == 0 {
|
|
requestData.Page = 1
|
|
}
|
|
if requestData.PageSize == 0 {
|
|
requestData.Page = 10
|
|
}
|
|
var postDetails []assessmentmodel.PostTargetDetails
|
|
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PostTargetDetails{}).Where("`state` BETWEEN 1 AND 2")
|
|
if requestData.Title != "" {
|
|
gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%")
|
|
}
|
|
if requestData.DepartmentId != "" {
|
|
gormDb = gormDb.Where("`paretment` = ?", requestData.DepartmentId)
|
|
}
|
|
if requestData.TargetId != "" {
|
|
gormDb = gormDb.Where("`parentid` = ?", requestData.TargetId)
|
|
}
|
|
if requestData.Cycle != 0 {
|
|
gormDb = gormDb.Where("`cycle` = ?", requestData.Cycle)
|
|
}
|
|
if len(requestData.PostId) > 0 {
|
|
var findInSet []string
|
|
for _, ctv := range requestData.PostId {
|
|
findWher := fmt.Sprintf("FIND_IN_SET(%v,`paretment_post`)", ctv)
|
|
if commonus.IsItTrueString(findWher, findInSet) == false {
|
|
findInSet = append(findInSet, findWher)
|
|
}
|
|
}
|
|
if len(findInSet) > 0 {
|
|
gormDb = gormDb.Where(strings.Join(findInSet, " OR "))
|
|
}
|
|
}
|
|
|
|
if len(requestData.PostId) > 0 {
|
|
var findInSetType []string
|
|
for _, ctvt := range requestData.Inspect {
|
|
findWherType := fmt.Sprintf("FIND_IN_SET(%v,`censor_type`)", ctvt)
|
|
if commonus.IsItTrueString(findWherType, findInSetType) == false {
|
|
findInSetType = append(findInSetType, findWherType)
|
|
}
|
|
}
|
|
if len(findInSetType) > 0 {
|
|
gormDb = gormDb.Where(strings.Join(findInSetType, " OR "))
|
|
}
|
|
}
|
|
|
|
var total int64
|
|
totalErr := gormDb.Count(&total).Error
|
|
if totalErr != nil {
|
|
total = 0
|
|
}
|
|
|
|
err := gormDb.Order("`parentid_sun` asc").Order("`id` desc").Limit(requestData.PageSize).Offset(commonus.CalculatePages(requestData.Page, requestData.PageSize)).Find(&postDetails).Error
|
|
if err != nil {
|
|
response.Result(103, err.Error(), "没有数据!", c)
|
|
return
|
|
}
|
|
|
|
countSum := len(postDetails)
|
|
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, postDetails)
|
|
response.Result(0, printData, "查询成功!", c)
|
|
}
|
|
|
|
// 获取岗位定性指标关联岗位列表
|
|
func (a *ApiMethod) GetPostTargetPost(c *gin.Context) {
|
|
var requestData idType
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(100, err, "您的请求数据不合法", c)
|
|
}
|
|
var postTargetCont assessmentmodel.PostTarget
|
|
postErr := postTargetCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`rele_depart`", "`departments_post`", "`key`")
|
|
if postErr != nil {
|
|
response.Result(100, postErr, "没有该数据!", c)
|
|
}
|
|
var outData getTargetPost
|
|
outData.Id = requestData.Id
|
|
outData.DepartmentId = strconv.FormatInt(postTargetCont.ReleDepart, 10)
|
|
postId := strings.Split(postTargetCont.DepartmentsPost, ",")
|
|
if len(postId) < 1 {
|
|
response.Result(0, outData, "查询成功!", c)
|
|
return
|
|
}
|
|
for _, v := range postId {
|
|
if commonus.IsInTrue[string](v, outData.PostId) == false {
|
|
var postContAry hrsystem.Position
|
|
posErr := postContAry.GetCont(map[string]interface{}{"`id`": v}, "`name`")
|
|
if posErr == nil {
|
|
outData.PostId = append(outData.PostId, v)
|
|
var ordPostCont departmentmap
|
|
ordPostCont.Parentid = v
|
|
ordPostCont.Parentname = postContAry.Name
|
|
outData.Departmentmap = append(outData.Departmentmap, ordPostCont)
|
|
}
|
|
}
|
|
}
|
|
response.Result(0, outData, "查询成功!", c)
|
|
}
|
|
|
|
// 修改定性指标关联岗位
|
|
func (a *ApiMethod) EditPostTargetQual(c *gin.Context) {
|
|
var requestData editTargetPostData
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(100, err, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
response.Result(101, err, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
if len(requestData.PostId) < 1 {
|
|
response.Result(102, err, "请指定要关联的岗位", c)
|
|
return
|
|
}
|
|
postAryStr := strings.Join(requestData.PostId, ",")
|
|
where := commonus.MapOut()
|
|
where["`id`"] = requestData.Id
|
|
var postTargetInfo assessmentmodel.PostTarget
|
|
postTarErr := postTargetInfo.EditCont(where, map[string]interface{}{"departments_post": postAryStr})
|
|
if postTarErr == nil {
|
|
var sunPostTerget assessmentmodel.PostSunTarget
|
|
sunPostTerget.EditCont(map[string]interface{}{"parent_id": requestData.Id}, map[string]interface{}{"depart_post": postAryStr})
|
|
var postTarDeta assessmentmodel.PostTargetDetails
|
|
postTarDeta.EditCont(map[string]interface{}{"parentid": requestData.Id}, map[string]interface{}{"paretment_post": postAryStr})
|
|
} else {
|
|
response.Result(103, err, "修改失败!", c)
|
|
return
|
|
}
|
|
response.Result(0, err, "修改完成", c)
|
|
}
|
|
|
|
// 获取子栏目内容
|
|
func (a *ApiMethod) GetSunTargetInfo(c *gin.Context) {
|
|
var requestData idType
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(100, err, "数据格式不正确!", c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
response.Result(101, err, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
var sunTargetCont sunPostTergetCont
|
|
getErr := sunTargetCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
if getErr != nil {
|
|
response.Result(102, err, "此栏目不存在!请检查数据!", c)
|
|
return
|
|
}
|
|
sunTargetCont.DepartmentId = strconv.FormatInt(sunTargetCont.Depart, 10)
|
|
sunTargetCont.PostId = strings.Split(sunTargetCont.DepartPost, ",")
|
|
|
|
var reporManList []string
|
|
manListErr := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.PostTargetDetails{}).Select("`reportary` ").Where("`parentid` = ? AND `parentid_sun` = ? AND `paretment` = ?").First(&reporManList).Error
|
|
if manListErr == nil {
|
|
var manList []string
|
|
if len(reporManList) > 0 {
|
|
for _, v := range reporManList {
|
|
detMan := strings.Split(v, ",")
|
|
if len(detMan) > 0 {
|
|
for _, mv := range detMan {
|
|
if commonus.IsInTrue[string](mv, manList) == false {
|
|
manList = append(manList, mv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(manList) > 0 {
|
|
var manContList []hrsystem.PersonArchives
|
|
manErr := global.GVA_DB_HrDataBase.Model(&hrsystem.PersonArchives{}).Select("`key`,`name`").Where("`key` IN ?", manList).Find(&manContList).Error
|
|
if manErr == nil {
|
|
for _, mcv := range manContList {
|
|
var manInfo departmentmap
|
|
manInfo.Parentid = strconv.FormatInt(mcv.Key, 10)
|
|
manInfo.Parentname = mcv.Name
|
|
sunTargetCont.Departmentmap = append(sunTargetCont.Departmentmap, manInfo)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
response.Result(102, sunTargetCont, "此栏目不存在!请检查数据!", c)
|
|
}
|
|
|
|
// 编辑定性考核子栏目
|
|
func (a *ApiMethod) EidtSunTargetPost(c *gin.Context) {
|
|
var requestData getDingXingSunTaget
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Id == "" || requestData.DepartmentId == "" || requestData.Title == "" {
|
|
response.Result(101, requestData, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
if len(requestData.PostId) < 1 {
|
|
response.Result(101, requestData, "请选择关联岗位", c)
|
|
return
|
|
}
|
|
if len(requestData.ReportAry) < 1 {
|
|
response.Result(101, requestData, "请选择关联上报人", c)
|
|
return
|
|
}
|
|
where := commonus.MapOut()
|
|
where["`id`"] = requestData.Id
|
|
var sunTarCont assessmentmodel.PostSunTarget
|
|
err := sunTarCont.GetCont(where)
|
|
if err != nil {
|
|
response.Result(101, requestData, "没有该子栏目!", c)
|
|
return
|
|
}
|
|
saveData := commonus.MapOut()
|
|
if requestData.Title != sunTarCont.Title {
|
|
saveData["title"] = requestData.Title
|
|
}
|
|
saveData["depart"] = requestData.DepartmentId
|
|
saveData["depart_post"] = strings.Join(requestData.PostId, ",")
|
|
saveData["time"] = time.Now().Unix()
|
|
saveErr := sunTarCont.EditCont(where, saveData)
|
|
if saveErr != nil {
|
|
response.Result(101, saveErr, "编辑失败!", c)
|
|
return
|
|
}
|
|
detaWher := commonus.MapOut()
|
|
detaWher["parentid"] = sunTarCont.ParentId
|
|
detaWher["parentid_sun"] = sunTarCont.Id
|
|
detaWher["paretment"] = sunTarCont.Depart
|
|
saveDetaCont := commonus.MapOut()
|
|
saveDetaCont["paretment_post"] = strings.Join(requestData.PostId, ",")
|
|
saveDetaCont["reportary"] = strings.Join(requestData.ReportAry, ",")
|
|
saveDetaCont["time"] = time.Now().Unix()
|
|
var saveDetaInfo assessmentmodel.PostTargetDetails
|
|
saveDetaInfo.EditCont(detaWher, saveDetaCont)
|
|
response.Result(0, saveErr, "编辑成功!", c)
|
|
}
|
|
|
|
// 删除指标
|
|
func (a *ApiMethod) DelSunTarget(c *gin.Context) {
|
|
var requestData editState
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(100, err, "数据格式不正确!", c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
response.Result(101, requestData, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
if requestData.State == 0 {
|
|
requestData.State = 1
|
|
}
|
|
if requestData.IsTrue == 0 {
|
|
requestData.IsTrue = 2
|
|
}
|
|
where := commonus.MapOut()
|
|
where["`id`"] = requestData.Id
|
|
var sunTarCont assessmentmodel.PostSunTarget
|
|
sunErr := sunTarCont.GetCont(where)
|
|
if sunErr != nil {
|
|
response.Result(101, sunErr, "没有查询到数据!", c)
|
|
return
|
|
}
|
|
if requestData.State != 3 {
|
|
eidtDingXing(sunTarCont.Id, requestData.State)
|
|
} else {
|
|
if requestData.IsTrue != 1 {
|
|
eidtDingXing(sunTarCont.Id, requestData.State)
|
|
} else {
|
|
var postSunTargetInfo assessmentmodel.PostSunTarget
|
|
postSunTargetInfo.DelCont(map[string]interface{}{"`parent_id`": sunTarCont.Id})
|
|
var postDetailsInfo assessmentmodel.PostTargetDetails
|
|
postDetailsInfo.DelCont(map[string]interface{}{"`parent_id`": sunTarCont.Id})
|
|
}
|
|
}
|
|
}
|
|
|
|
// 添加单条定性指标细则
|
|
func (a *ApiMethod) AddPostDetaCont(c *gin.Context) {
|
|
var requestData oneAddDetails
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.SunTargetId == "" {
|
|
response.Result(101, requestData, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
var sunTarCont assessmentmodel.PostSunTarget
|
|
sunErr := sunTarCont.GetCont(map[string]interface{}{"`id`": requestData.SunTargetId}, "`parent_id`", "`depart`", "`depart_post`")
|
|
if sunErr != nil {
|
|
response.Result(101, requestData, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
|
|
if requestData.Title == "" {
|
|
response.Result(101, requestData, "请输入细则名称", c)
|
|
return
|
|
}
|
|
switch requestData.PunishMode {
|
|
case 2:
|
|
if requestData.CashStandard == "" {
|
|
response.Result(101, requestData, "请输入考核现金标准", c)
|
|
return
|
|
}
|
|
case 3:
|
|
if requestData.ReferenceScore == "" {
|
|
response.Result(101, requestData, "请输入考核标准", c)
|
|
return
|
|
}
|
|
if requestData.CashStandard == "" {
|
|
response.Result(101, requestData, "请输入考核现金标准", c)
|
|
return
|
|
}
|
|
if requestData.Unit == "" {
|
|
response.Result(101, requestData, "请输入考核单位", c)
|
|
return
|
|
}
|
|
default:
|
|
requestData.PunishMode = 1
|
|
if requestData.ReferenceScore == "" {
|
|
response.Result(101, requestData, "请输入考核标准", c)
|
|
return
|
|
}
|
|
if requestData.Unit == "" {
|
|
response.Result(101, requestData, "请输入考核单位", c)
|
|
return
|
|
}
|
|
}
|
|
if requestData.Class == 0 {
|
|
requestData.Class = 1
|
|
}
|
|
if len(requestData.Inspect) < 1 {
|
|
requestData.Inspect = append(requestData.Inspect, "1")
|
|
}
|
|
if requestData.Cycle == 0 {
|
|
requestData.Cycle = 4
|
|
}
|
|
if requestData.CycleAttr == 0 {
|
|
requestData.CycleAttr = 1
|
|
}
|
|
var tarGerCont assessmentmodel.PostTarget
|
|
tarGerCont.GetCont(map[string]interface{}{"`id`": sunTarCont.ParentId})
|
|
var tiBaoRen string
|
|
if len(requestData.ReportAry) < 1 {
|
|
if tarGerCont.Report == "" {
|
|
response.Result(101, requestData, "请选择提报人!", c)
|
|
return
|
|
}
|
|
tiBaoRen = tarGerCont.Report
|
|
} else {
|
|
tiBaoRen = strings.Join(requestData.ReportAry, ",")
|
|
}
|
|
|
|
var minScoreInt int64
|
|
var maxScoreInt int64
|
|
scoreAry := strings.Split(requestData.ReferenceScore, "-")
|
|
scoreLen := len(scoreAry)
|
|
// fmt.Printf("ScoreAry:%v----------->%v------------>%v------------>%v\n", ReferenceScore, scoreLen, scoreAry[0], scoreAry)
|
|
if scoreLen > 0 {
|
|
if scoreLen == 1 {
|
|
maxScore, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
// zhhh := maxScore * 100
|
|
// zhuanStr := strconv.FormatFloat(zhhh, 'f', -1, 64)
|
|
maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64)
|
|
minScoreInt = 0
|
|
} else {
|
|
minScore, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
maxScore, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64)
|
|
minScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64)
|
|
maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64)
|
|
}
|
|
} else {
|
|
minScoreInt = 0
|
|
maxScoreInt = 0
|
|
}
|
|
|
|
var minMoney int64 //罚款或奖励最高金额
|
|
var maxMoney int64 //罚款或奖励最新金额
|
|
moneyAry := strings.Split(requestData.CashStandard, "-")
|
|
moneyAryLen := len(moneyAry)
|
|
if moneyAryLen > 0 {
|
|
if moneyAryLen == 1 {
|
|
maxMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64)
|
|
maxMoney, _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
minMoney = 0
|
|
} else {
|
|
maxMoneyEs, _ := strconv.ParseFloat(moneyAry[moneyAryLen-1], 64)
|
|
maxMoney, _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
minMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64)
|
|
minMoney, _ = strconv.ParseInt(strconv.FormatFloat(minMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
}
|
|
} else {
|
|
minMoney = 0
|
|
maxMoney = 0
|
|
}
|
|
|
|
var saveCont assessmentmodel.PostTargetDetails
|
|
saveCont.Title = requestData.Title //指标细则"`
|
|
saveCont.Content = requestData.Explain //备注说明"`
|
|
saveCont.ParentId = sunTarCont.ParentId //归属指标栏目"`
|
|
saveCont.ParentIdSun = sunTarCont.Id //归属指标子栏目"`
|
|
saveCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
saveCont.AddTime = time.Now().Unix() //制定时间"`
|
|
saveCont.MinScore = minScoreInt //最小分*100保存"`
|
|
saveCont.MaxScore = maxScoreInt //最大分*100保存"`
|
|
saveCont.Company = requestData.Unit //单位"`
|
|
saveCont.AddReduce = requestData.Class //1:减少;2:增加;3:无属性,现场确认加或减"`
|
|
saveCont.CensorType = strings.Join(requestData.Inspect, ",") //检查方式"`
|
|
saveCont.CensorCont = requestData.Evidence //客观证据"`
|
|
saveCont.CensorRate = requestData.Cycle //检查频次"`
|
|
saveCont.Cycles = requestData.CycleAttr //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
saveCont.CycleAttres = requestData.CycleAttr //辅助计数"`
|
|
saveCont.Paretment = sunTarCont.Depart //接受考核的部门"`
|
|
saveCont.ParetmentPost = strings.Join(requestData.PostId, ",") //接受考核的部门岗位"`
|
|
saveCont.Reportary = tiBaoRen //提报人"`
|
|
saveCont.Punishmode = requestData.PunishMode //处罚或奖励方式 1:分数;2:现金;3:分数加现金
|
|
saveCont.Minmoney = minMoney //最高罚款*100保存"`
|
|
saveCont.Maxmoney = maxMoney //最低罚款*100保存"`
|
|
saveErr := global.GVA_DB_Performanceappraisal.Create(&saveCont).Error
|
|
if saveErr != nil {
|
|
response.Result(101, saveErr, "数据写入失败!请重新写入!", c)
|
|
return
|
|
}
|
|
response.Result(0, saveErr, "数据写入成功!", c)
|
|
}
|
|
|
|
// 获取指标细则内容
|
|
func (a *ApiMethod) GetDetailsCont(c *gin.Context) {
|
|
var requestData idType
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
response.Result(100, err, "数据格式不正确!", c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
response.Result(101, err, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
var detaCont outDetailsCont
|
|
detaErr := detaCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
if detaErr != nil {
|
|
response.Result(101, detaErr, "该指标细则不存在!", c)
|
|
return
|
|
}
|
|
if detaCont.MinScore != 0 {
|
|
detaCont.ScoreStandard = fmt.Sprintf("%v-%v", commonus.DecimalEs(float64(detaCont.MinScore)/100, 2), commonus.DecimalEs(float64(detaCont.MaxScore)/100, 2))
|
|
} else {
|
|
detaCont.ScoreStandard = fmt.Sprintf("%v", commonus.DecimalEs(float64(detaCont.MaxScore)/100, 2))
|
|
}
|
|
if detaCont.Minmoney != 0 {
|
|
detaCont.CashStandard = fmt.Sprintf("%v-%v", commonus.DecimalEs(float64(detaCont.Minmoney)/100, 2), commonus.DecimalEs(float64(detaCont.Maxmoney)/100, 2))
|
|
} else {
|
|
detaCont.CashStandard = fmt.Sprintf("%v", commonus.DecimalEs(float64(detaCont.Maxmoney)/100, 2))
|
|
}
|
|
detaCont.InspMethod = strings.Split(detaCont.CensorType, ",")
|
|
//关联岗位
|
|
postAry := strings.Split(detaCont.ParetmentPost, ",")
|
|
var inAryPost []string
|
|
if len(postAry) > 0 {
|
|
for _, pv := range postAry {
|
|
if commonus.IsInTrue[string](pv, inAryPost) == false {
|
|
inAryPost = append(inAryPost, pv)
|
|
var postCont hrsystem.Position
|
|
postConErr := postCont.GetCont(map[string]interface{}{"`id`": pv}, "`name`")
|
|
if postConErr == nil {
|
|
var postContL idAndName
|
|
postContL.Id = pv
|
|
postContL.Name = postCont.Name
|
|
detaCont.PostAry = append(detaCont.PostAry, postContL)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//提报人
|
|
repalyMan := strings.Split(detaCont.Reportary, ",")
|
|
var reply []string
|
|
if len(repalyMan) > 0 {
|
|
for _, mv := range repalyMan {
|
|
if commonus.IsInTrue[string](mv, reply) == false {
|
|
reply = append(reply, mv)
|
|
var manCont hrsystem.PersonArchives
|
|
manErr := manCont.GetCont(map[string]interface{}{"`key`": mv}, "`name`", "`icon`", `number`)
|
|
if manErr == nil {
|
|
var reporContMan reportUser
|
|
reporContMan.Id = mv
|
|
reporContMan.Name = manCont.Name
|
|
reporContMan.Icon = manCont.Icon
|
|
reporContMan.Number = manCont.Number
|
|
detaCont.ReportAry = append(detaCont.ReportAry, reporContMan)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
response.Result(0, detaCont, "数据获取成功!", c)
|
|
}
|
|
|
|
// 修改定性考核指标细则
|
|
func (a *ApiMethod) EditDeatilsCont(c *gin.Context) {
|
|
var requestData editPostDetails
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Id == "" {
|
|
response.Result(101, requestData, "您的请求数据不合法", c)
|
|
return
|
|
}
|
|
where := commonus.MapOut()
|
|
where["`id`"] = requestData.Id
|
|
var detaCont assessmentmodel.PostTargetDetails
|
|
detaErr := detaCont.GetCont(where)
|
|
if detaErr != nil {
|
|
response.Result(101, detaErr, "该指标细则不存在!", c)
|
|
return
|
|
}
|
|
saveData := commonus.MapOut()
|
|
if requestData.Title != "" && requestData.Title != detaCont.Title {
|
|
saveData["title"] = requestData.Title
|
|
}
|
|
|
|
if requestData.ReferenceScore != "" {
|
|
referStr := ""
|
|
if detaCont.MinScore != 0 {
|
|
referStr = fmt.Sprintf("%v-%v", commonus.DecimalEs(float64(detaCont.MinScore)/100, 2), commonus.DecimalEs(float64(detaCont.MaxScore)/100, 2))
|
|
} else {
|
|
referStr = fmt.Sprintf("%v", commonus.DecimalEs(float64(detaCont.MaxScore)/100, 2))
|
|
}
|
|
if requestData.ReferenceScore != referStr {
|
|
|
|
scoreAry := strings.Split(requestData.ReferenceScore, "-")
|
|
scoreLen := len(scoreAry)
|
|
if scoreLen > 0 {
|
|
if scoreLen == 1 {
|
|
maxScore, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
saveData["max_score"], _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64)
|
|
saveData["min_score"] = 0
|
|
} else {
|
|
minScore, _ := strconv.ParseFloat(scoreAry[0], 64)
|
|
maxScore, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64)
|
|
saveData["min_score"], _ = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64)
|
|
saveData["max_score"], _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64)
|
|
}
|
|
} else {
|
|
saveData["min_score"] = 0
|
|
saveData["max_score"] = 0
|
|
}
|
|
}
|
|
}
|
|
if requestData.Unit != "" && requestData.Unit != detaCont.Company {
|
|
saveData["company"] = requestData.Unit
|
|
}
|
|
if requestData.Class != 0 && requestData.Class != detaCont.AddReduce {
|
|
saveData["add_reduce"] = requestData.Class
|
|
}
|
|
if len(requestData.Inspect) > 0 {
|
|
insStr := strings.Join(requestData.Inspect, ",")
|
|
if insStr != detaCont.CensorType {
|
|
saveData["censor_type"] = insStr
|
|
}
|
|
}
|
|
if requestData.Cycle != 0 && requestData.Cycle != detaCont.Cycles {
|
|
saveData["cycle"] = requestData.Cycle
|
|
}
|
|
if requestData.CycleAttr != 0 && requestData.CycleAttr != detaCont.CycleAttres {
|
|
saveData["cycleattr"] = requestData.CycleAttr
|
|
}
|
|
if requestData.Evidence != "" && requestData.Evidence != detaCont.Company {
|
|
saveData["censor_cont"] = requestData.Evidence
|
|
}
|
|
if requestData.Explain != "" && requestData.Explain != detaCont.Company {
|
|
saveData["Content"] = requestData.Explain
|
|
}
|
|
if len(requestData.ReportAry) > 0 {
|
|
repInsStr := strings.Join(requestData.ReportAry, ",")
|
|
if repInsStr != detaCont.CensorType {
|
|
saveData["reportary"] = repInsStr
|
|
}
|
|
}
|
|
if requestData.PunishMode != 0 && requestData.PunishMode != detaCont.Punishmode {
|
|
saveData["punishmode"] = requestData.PunishMode
|
|
}
|
|
|
|
if requestData.CashStandard != "" {
|
|
referMoneryStr := ""
|
|
if detaCont.MinScore != 0 {
|
|
referMoneryStr = fmt.Sprintf("%v-%v", commonus.DecimalEs(float64(detaCont.MinScore)/100, 2), commonus.DecimalEs(float64(detaCont.MaxScore)/100, 2))
|
|
} else {
|
|
referMoneryStr = fmt.Sprintf("%v", commonus.DecimalEs(float64(detaCont.MaxScore)/100, 2))
|
|
}
|
|
if requestData.CashStandard != referMoneryStr {
|
|
|
|
moneyAry := strings.Split(requestData.CashStandard, "-")
|
|
moneyAryLen := len(moneyAry)
|
|
if moneyAryLen > 0 {
|
|
if moneyAryLen == 1 {
|
|
maxMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64)
|
|
saveData["maxmoney"], _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
saveData["minmoney"] = 0
|
|
} else {
|
|
maxMoneyEs, _ := strconv.ParseFloat(moneyAry[moneyAryLen-1], 64)
|
|
saveData["maxmoney"], _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
minMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64)
|
|
saveData["minmoney"], _ = strconv.ParseInt(strconv.FormatFloat(minMoneyEs*100, 'f', -1, 64), 10, 64)
|
|
}
|
|
} else {
|
|
saveData["maxmoney"] = 0
|
|
saveData["minmoney"] = 0
|
|
}
|
|
}
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["time"] = time.Now().Unix()
|
|
saveErr := detaCont.EditCont(where, saveData)
|
|
if saveErr != nil {
|
|
response.Result(101, saveErr, "编辑失败!", c)
|
|
return
|
|
}
|
|
}
|
|
response.Result(0, saveData, "编辑成功!", c)
|
|
}
|
|
|
|
// 删除指标细则
|
|
func (a *ApiMethod) EidtPostTarDetailsStrte(c *gin.Context) {
|
|
var requestData editState
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Id == "" {
|
|
response.Result(100, requestData, "请输入指标名称!", c)
|
|
return
|
|
}
|
|
if requestData.State == 0 {
|
|
requestData.State = 1
|
|
}
|
|
if requestData.IsTrue == 0 {
|
|
requestData.IsTrue = 2
|
|
}
|
|
where := commonus.MapOut()
|
|
where["`id`"] = requestData.Id
|
|
var detaCont assessmentmodel.PostTargetDetails
|
|
detaErr := detaCont.GetCont(where)
|
|
if detaErr != nil {
|
|
response.Result(101, detaErr, "该指标细则不存在!", c)
|
|
return
|
|
}
|
|
if requestData.State != 3 {
|
|
saveData := commonus.MapOut()
|
|
saveData["state"] = requestData.State
|
|
saveData["time"] = time.Now().Unix()
|
|
saveErr := detaCont.EditCont(where, saveData)
|
|
if saveErr != nil {
|
|
response.Result(101, saveErr, "编辑失败!", c)
|
|
return
|
|
}
|
|
} else {
|
|
if requestData.IsTrue != 1 {
|
|
saveData := commonus.MapOut()
|
|
saveData["state"] = requestData.State
|
|
saveData["time"] = time.Now().Unix()
|
|
saveErr := detaCont.EditCont(where, saveData)
|
|
if saveErr != nil {
|
|
response.Result(101, saveErr, "编辑失败!", c)
|
|
return
|
|
}
|
|
} else {
|
|
saveErr := detaCont.DelCont(where)
|
|
if saveErr != nil {
|
|
response.Result(101, saveErr, "编辑失败!", c)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
response.Result(0, detaCont, "编辑成功!", c)
|
|
}
|
|
|