Browse Source

岗位基础信息更正完成

master
超级管理员 3 years ago
parent
commit
67ec3206f8
  1. 782
      api/version1/postseting/postpc/targetpost.go
  2. 46
      api/version1/postseting/postpc/type.go
  3. 34
      apirouter/v1/postseting/pc.go

782
api/version1/postseting/postpc/targetpost.go

@ -2,6 +2,7 @@ package postpc
import (
"fmt"
"key_performance_indicators/api/version1/departmentseting/departmentpc"
"key_performance_indicators/models/modelshr"
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall"
@ -488,6 +489,10 @@ func (a *ApiMethod) AddPostTargetCont(c *gin.Context) {
publicmethod.Result(104, sunTargetErr, c)
return
}
} else {
if sunTargetCont.State != 1 {
sunTargetCont.EiteCont(map[string]interface{}{"`id`": sunTargetCont.Id}, map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()})
}
}
if sunTargetCont.Id == 0 {
publicmethod.Result(104, sunTargetCont, c)
@ -599,6 +604,8 @@ func (a *ApiMethod) AddPostTargetCont(c *gin.Context) {
添加指标细则
@saveCont 指标细则数据
@postMan 指标细则岗位提报人键对
@targetPostMan 指标设定提报人
@dimensionId 维度
*/
func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan []postPeople, dimensionId int64) {
defer syncSeting.Done()
@ -606,7 +613,10 @@ func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan
//获取岗位与提报人
var departAny []string
var peopletAny []string
var peoplePost []postDeasiteMan
for _, v := range postMan {
var peoPostCont postDeasiteMan
peoPostCont.Id = v.Id
if publicmethod.IsInTrue[string](v.Id, departAny) == false {
departAny = append(departAny, v.Id)
}
@ -614,6 +624,7 @@ func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan
for _, ov := range v.Operator {
if publicmethod.IsInTrue[string](ov, peopletAny) == false {
peopletAny = append(peopletAny, ov)
peoPostCont.Operator = append(peoPostCont.Operator, ov)
}
}
} else {
@ -622,15 +633,17 @@ func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan
for _, otv := range tarv.Operator {
if publicmethod.IsInTrue[string](otv, peopletAny) == false {
peopletAny = append(peopletAny, otv)
peoPostCont.Operator = append(peoPostCont.Operator, otv)
}
}
}
}
}
peoplePost = append(peoplePost, peoPostCont)
}
saveCont.ParetmentPost = strings.Join(departAny, ",") //相关岗位"`
saveCont.Reportary = strings.Join(peopletAny, ",") //上报人"`
fmt.Printf("postMan------->%v--------targetPostMan------->%v--------departAny------->%v--------peopletAny------->%v\n", postMan, targetPostMan, departAny, peopletAny)
overall.CONSTANT_DB_KPI.Create(&saveCont)
fmt.Printf("postMan------->%v--------targetPostMan------->%v--------departAny------->%v--------peopletAny------->%v\n", postMan, targetPostMan, departAny, peopletAny)
//关联部门岗位
@ -640,7 +653,8 @@ func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan
}
//关联考核岗位和提报人
for _, dv := range targetPostMan {
for _, dv := range peoplePost {
operatorList := dv.Operator
if len(operatorList) < 1 {
for _, tarv := range targetPostMan {
@ -657,6 +671,21 @@ func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan
syncSetinges.Wait()
}
/*
协程处理
部门指标岗位提报人关联通用函数
@dimensionId 维度
@targetId 指标ID
@targetSunId 栏目ID
@bylawsId 指标细则
@departmentId 接受考核部门
@postId 岗位
@repart 提报人
@class 级别1部门级2岗位级
@nature 1定性考核2定量考核
func departAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []loopStruct, class, nature int)
*/
// 根据指标获取岗位定性指标细则列表
func (a *ApiMethod) PostTargetSunList(c *gin.Context) {
var requestData lookPostTargetDeta
@ -759,3 +788,752 @@ func (a *ApiMethod) PostTargetSunList(c *gin.Context) {
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendDataAry)), sendDataAry, c)
}
// 获取岗位子栏目详情
func (a *ApiMethod) GetSunTargetInfo(c *gin.Context) {
var receivedValue publicmethod.PublicId
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, err, c)
return
}
var sonTargetCont modelskpi.PostSonTarget
err = sonTargetCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id})
if err != nil {
publicmethod.Result(107, err, c)
return
}
var sendData sendOneSonTargetCont
sendData.Id = sonTargetCont.Id
sendData.Title = sonTargetCont.Title //标题"`
sendData.ParentId = sonTargetCont.ParentId //归属指标"`
sendData.Time = sonTargetCont.Time //创建时间"`
sendData.State = sonTargetCont.State //状态(1:启用;2:禁用;3:删除)"`
sendData.Depart = sonTargetCont.Depart //关联部门"`
sendData.DepartPost = sonTargetCont.DepartPost //关联部门岗位"`
var departCont modelshr.AdministrativeOrganization
departCont.GetCont(map[string]interface{}{"`id`": sonTargetCont.Depart}, "`name`")
sendData.Department = departCont.Name
sendData.IdStr = strconv.FormatInt(sonTargetCont.Id, 10)
//获取提报岗位
var reportPost []int64
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`post_id`").Where("`state` = 1 AND `level` = 2 AND `department_id` = ? AND `target_id` = ? AND `target_sun_id` = ?", sonTargetCont.Depart, sonTargetCont.ParentId, sonTargetCont.Id).Find(&reportPost).Error
if err == nil && len(reportPost) > 0 {
for i := 0; i < len(reportPost); i++ {
var postOfMan postOperator
postOfMan.Id = strconv.FormatInt(reportPost[i], 10)
var postCont modelshr.Position
postCont.GetCont(map[string]interface{}{"`id`": reportPost[i]}, "`name`")
postOfMan.Name = postCont.Name
var operList operatorList
reportWhere := publicmethod.MapOut[string]()
reportWhere["`target_id`"] = sonTargetCont.ParentId
reportWhere["`target_sun_id`"] = sonTargetCont.Id
reportWhere["`department_id`"] = sonTargetCont.Depart
reportWhere["`post_id`"] = reportPost[i]
reportWhere["`state`"] = 1
_, operList.UserKey, _ = departmentpc.GetAboutReport(reportWhere, 2)
if len(operList.UserKey) > 0 {
for _, uv := range operList.UserKey {
var myCont modelshr.PersonArchives
myCont.GetCont(map[string]interface{}{"`key`": uv}, "`number`", "`name`", "`icon`")
var myInfo UserContList
myInfo.Id = uv
myInfo.Name = myCont.Name
myInfo.Number = myCont.Number
myInfo.Icon = myCont.Icon
operList.UserList = append(operList.UserList, myInfo)
}
}
postOfMan.Operator = operList
sendData.PostOfOperator = append(sendData.PostOfOperator, postOfMan)
}
}
publicmethod.Result(0, sendData, c)
}
// 编辑岗位子栏目
func (a *ApiMethod) EditSonTargetCont(c *gin.Context) {
var receivedValue editSonTargetPost
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(1, receivedValue, c, "您输入的参数不正确!")
return
}
where := map[string]interface{}{"`id`": receivedValue.Id}
var sonTarCont modelskpi.PostSonTarget
err = sonTarCont.GetCont(where)
if err != nil {
publicmethod.Result(107, err, c)
return
}
saveData := publicmethod.MapOut[string]()
if receivedValue.Name != "" && receivedValue.Name != sonTarCont.Title {
saveData["title"] = sonTarCont.Title
}
saveData["time"] = time.Now().Unix()
err = sonTarCont.EiteCont(map[string]interface{}{"`id`": sonTarCont.Id}, saveData)
var postTarCont modelskpi.PostTarget
postTarCont.GetCont(map[string]interface{}{"`id`": sonTarCont.ParentId}, "`dimension`")
if len(receivedValue.PostOfOperator) > 0 {
syncSeting.Add(1)
go postSonTargetAboutOrder(postTarCont.Dimension, sonTarCont.Depart, sonTarCont.ParentId, sonTarCont.Id, receivedValue.PostOfOperator)
}
syncSeting.Wait()
//获取子栏目关联岗位
var postIdInt64 []int64
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`post_id`").Where("`state` = 1 AND `level` = ? AND `department_id` = ? AND `dimension_id` = ? AND `target_id` = ? AND `target_sun_id` = ?", 2, sonTarCont.Depart, postTarCont.Dimension, sonTarCont.ParentId, sonTarCont.Id).Find(&postIdInt64)
if len(postIdInt64) > 0 {
var postIdStr []string
for si := 0; si < len(postIdInt64); si++ {
postIdIntToStr := strconv.FormatInt(postIdInt64[si], 10)
postIdStr = append(postIdStr, postIdIntToStr)
}
sonTarCont.EiteCont(map[string]interface{}{"`id`": sonTarCont.Id}, map[string]interface{}{"`depart_post`": strings.Join(postIdStr, ","), "`time`": time.Now().Unix()})
}
if err != nil {
publicmethod.Result(106, err, c)
return
}
publicmethod.Result(0, err, c)
}
/*
岗位子栏目关联岗位操作
@dimensionId 维度
@departmentId 部门
@targetId 指标
@sonTargetId 子栏目
@postOfOperator 岗位与提报人
*/
func postSonTargetAboutOrder(dimensionId, departmentId, targetId, sonTargetId int64, postOfOperator []postDeasiteMan) {
defer syncSeting.Done()
wherePost := publicmethod.MapOut[string]()
// wherePost["`state`"] = 1
wherePost["`level`"] = 2
wherePost["`department_id`"] = departmentId
wherePost["`target_id`"] = targetId
wherePost["`target_sun_id`"] = sonTargetId
var sonTarDepartAddAry []modelskpi.TargetDepartment
var postIdAry []string
for _, v := range postOfOperator {
if publicmethod.IsInTrue[string](v.Id, postIdAry) == false {
postIdAry = append(postIdAry, v.Id)
}
var tarDepartCont []modelskpi.TargetDepartment
judgeErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Where(wherePost).Where("`post_id` = ?", v.Id).Find(&tarDepartCont).Error
if judgeErr == nil && len(tarDepartCont) > 0 {
for _, tdcv := range tarDepartCont {
if tdcv.State != 1 {
var sonTargetContEdit modelskpi.TargetDepartment
sonTargetContEdit.EiteCont(map[string]interface{}{"`id`": tdcv.Id}, map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()})
}
}
} else {
var sonTarDepartAdd modelskpi.TargetDepartment
sonTarDepartAdd.Dimension = dimensionId // 维度"`
sonTarDepartAdd.TargetId = targetId //指标ID"`
sonTarDepartAdd.TargetSunId = sonTargetId //子目标"`
sonTarDepartAdd.TargetBylaws = 0 //指标细则"`
sonTarDepartAdd.Type = 2 //类型(1:指标;2:子目标;3:细则)"`
sonTarDepartAdd.DepartmentId = departmentId //部门ID"`
idInt64, _ := strconv.ParseInt(v.Id, 10, 64)
sonTarDepartAdd.PostId = idInt64 //岗位ID"`
sonTarDepartAdd.State = 1 //状态(1:启用;2:禁用;3:删除)"`
sonTarDepartAdd.Time = time.Now().Unix() //写入时间"`
sonTarDepartAdd.Class = 1 //1:定性考核;2:定量考核"`
sonTarDepartAdd.Level = 2 //级别(1:部门级;2:岗位级)"`
sonTarDepartAddAry = append(sonTarDepartAddAry, sonTarDepartAdd)
}
//处理提报人
syncSetinges.Add(1)
go sonPostTargetPeople(dimensionId, departmentId, targetId, sonTargetId, v.Id, v.Operator)
}
if len(sonTarDepartAddAry) > 0 {
overall.CONSTANT_DB_KPI.Create(&sonTarDepartAddAry)
}
//其他的岗位禁用
if len(postIdAry) > 0 {
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod.MapOut[string]()
otherSaveData["`state`"] = 2
otherSaveData["`time`"] = time.Now().Unix()
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Where(wherePost).Not(map[string]interface{}{"post_id": postIdAry}).Updates(&otherSaveData)
}
syncSetinges.Wait()
}
/*
子栏目与提报人
@dimensionId 维度
@departmentId 部门
@targetId 指标
@sonTargetId 子栏目
@postId 岗位
*/
func sonPostTargetPeople(dimensionId, departmentId, targetId, sonTargetId int64, postId string, operator []string) {
defer syncSetinges.Done()
var saveTarRepor []modelskpi.TargetReport
if len(operator) > 0 {
wherePost := publicmethod.MapOut[string]()
// wherePost["`state`"] = 1
wherePost["`type`"] = 2
wherePost["`department_id`"] = departmentId
wherePost["`target_id`"] = targetId
wherePost["`target_sun_id`"] = sonTargetId
wherePost["`post_id`"] = postId
for i := 0; i < len(operator); i++ {
var tarReporList []modelskpi.TargetReport
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(wherePost).Where("`man_key` = ?", operator[i]).Find(&tarReporList)
if len(tarReporList) > 0 {
for _, trlv := range tarReporList {
eidtSont := map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()}
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(map[string]interface{}{"`id`": trlv.Id}).Updates(&eidtSont)
}
} else {
var saveData modelskpi.TargetReport
saveData.Dimension = dimensionId //维度"`
saveData.TargetId = targetId //指标ID"`
saveData.TargetSunId = sonTargetId //子目标"`
saveData.TargetBylaws = 0 //指标细则"`
saveData.DepartmentId = departmentId //部门ID"`
postIdInt64, _ := strconv.ParseInt(postId, 10, 64)
saveData.PostId = postIdInt64 //岗位ID"`
saveData.Type = 2 //类型(1:公司级;2:部门级)"`
saveData.State = 1 //状态(1:启用;2:禁用;3:删除)"`
var manCont modelshr.PersonArchives
manCont.GetCont(map[string]interface{}{"`key`": operator[i]}, "`key`", "`admin_org`")
saveData.ReportPerson = manCont.Key //上报人"`
saveData.ManDepartment = manCont.AdminOrg //提报人所在部门"`
saveData.Time = time.Now().Unix() //写入时间"`
saveData.Class = 2 //定性考核;2:定量考核"`
saveData.Level = 2 //类型(1:指标;2:子目标;3:细则)"`
saveTarRepor = append(saveTarRepor, saveData)
}
}
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod.MapOut[string]()
otherSaveData["`state`"] = 2
otherSaveData["`time`"] = time.Now().Unix()
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(wherePost).Not(map[string]interface{}{"man_key": operator}).Updates(&otherSaveData)
}
if len(saveTarRepor) > 0 {
overall.CONSTANT_DB_KPI.Create(&saveTarRepor)
}
}
// 删除子栏目
func (a *ApiMethod) DelSonTargetCont(c *gin.Context) {
var receivedValue publicmethod.PublicId
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(1, receivedValue, c, "您输入的参数不正确!")
return
}
where := map[string]interface{}{"`id`": receivedValue.Id}
var sonTarCont modelskpi.PostSonTarget
err = sonTarCont.GetCont(where)
if err != nil {
publicmethod.Result(107, err, c)
return
}
err = sonTarCont.EiteCont(map[string]interface{}{"`id`": sonTarCont.Id}, map[string]interface{}{"`state`": 3, "`time`": time.Now().Unix()})
if err != nil {
publicmethod.Result(108, err, c)
return
}
//处理指标细则
xiZeWhere := publicmethod.MapOut[string]()
xiZeWhere["`parentid`"] = sonTarCont.ParentId
xiZeWhere["`parentid_sun`"] = sonTarCont.Id
xiZeWhere["`paretment`"] = sonTarCont.Depart
var postTarDetaCont modelskpi.PostTargetDetails
postTarDetaCont.EiteCont(xiZeWhere, map[string]interface{}{"`state`": 3, "`time`": time.Now().Unix()})
publicmethod.Result(0, err, c)
}
// 添加单一定性指标细则
func (a *ApiMethod) AddOneTargetD(c *gin.Context) {
var receivedValue sonTargetAddDieastion
c.ShouldBindJSON(&receivedValue)
if receivedValue.Id == "" {
publicmethod.Result(1, receivedValue, c, "您输入的参数不正确!")
return
}
where := map[string]interface{}{"`id`": receivedValue.Id}
var sonTarCont modelskpi.PostSonTarget
err := sonTarCont.GetCont(where)
if err != nil {
publicmethod.Result(107, err, c)
return
}
if sonTarCont.State != 1 {
sonTarCont.EiteCont(where, map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()})
}
if receivedValue.Title == "" {
publicmethod.Result(101, receivedValue, c, "请输入细则名称")
return
}
if receivedValue.PunishMode == 0 {
receivedValue.PunishMode = 1
}
var minScoreInt int64
var maxScoreInt int64
var minMoney int64 //罚款或奖励最高金额
var maxMoney int64 //罚款或奖励最新金额
switch receivedValue.PunishMode {
case 2:
if receivedValue.CashStandard == "" {
publicmethod.Result(101, receivedValue, c, "请输入考核现金标准")
return
}
minMoney, maxMoney = caiFenStrint(receivedValue.CashStandard)
case 3:
if receivedValue.ReferenceScore == "" {
publicmethod.Result(101, receivedValue, c, "请输入考核标准")
return
}
minScoreInt, maxScoreInt = caiFenStrint(receivedValue.ReferenceScore)
if receivedValue.CashStandard == "" {
publicmethod.Result(101, receivedValue, c, "请输入考核现金标准")
return
}
minMoney, maxMoney = caiFenStrint(receivedValue.CashStandard)
if receivedValue.Unit == "" {
publicmethod.Result(101, receivedValue, c, "请输入考核单位")
return
}
default:
receivedValue.PunishMode = 1
if receivedValue.ReferenceScore == "" {
publicmethod.Result(101, receivedValue, c, "请输入考核标准")
return
}
if receivedValue.Unit == "" {
publicmethod.Result(101, receivedValue, c, "请输入考核单位")
return
}
minScoreInt, maxScoreInt = caiFenStrint(receivedValue.ReferenceScore)
}
if receivedValue.Class == 0 {
receivedValue.Class = 1
}
if len(receivedValue.Inspect) < 1 {
receivedValue.Inspect = append(receivedValue.Inspect, "1")
}
if receivedValue.Cycle == 0 {
receivedValue.Cycle = 4
}
if receivedValue.CycleAttr == 0 {
receivedValue.CycleAttr = 1
}
if receivedValue.Frequency == 0 {
receivedValue.Frequency = 1
}
var saveCont modelskpi.PostTargetDetails
saveCont.Title = receivedValue.Title //指标细则"`
saveCont.Content = receivedValue.Explain //备注说明"`
saveCont.ParentId = sonTarCont.ParentId //归属指标栏目"`
saveCont.ParentIdSun = sonTarCont.Id //归属指标子栏目"`
saveCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
saveCont.AddTime = time.Now().Unix() //制定时间"`
saveCont.MinScore = minScoreInt //最小分*100保存"`
saveCont.MaxScore = maxScoreInt //最大分*100保存"`
saveCont.Company = receivedValue.Unit //单位"`
saveCont.AddReduce = receivedValue.Class //1:减少;2:增加;3:无属性,现场确认加或减"`
saveCont.CensorType = strings.Join(receivedValue.Inspect, ",") //检查方式"`
saveCont.CensorCont = receivedValue.Evidence //客观证据"`
saveCont.CensorRate = receivedValue.Frequency //检查频次"`
saveCont.Cycles = receivedValue.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"`
saveCont.CycleAttres = receivedValue.CycleAttr //辅助计数"`
saveCont.Paretment = sonTarCont.Depart //接受考核的部门"`
// saveCont.ParetmentPost = strings.Join(requestData.PostId, ",") //接受考核的部门岗位"`
// saveCont.Reportary = strings.Join(receivedValue.ReportAry, ",") //接受考核的部门岗位"`
saveCont.Punishmode = receivedValue.PunishMode //处罚或奖励方式 1:分数;2:现金;3:分数加现金
saveCont.Minmoney = minMoney //最高罚款*100保存"`
saveCont.Maxmoney = maxMoney //最低罚款*100保存"`
//获取指标信息
var getTargetCont modelskpi.PostTarget
getTargetCont.GetCont(map[string]interface{}{"`id`": sonTarCont.ParentId})
_, postPeople, _ := getTargetSonAboutPost(sonTarCont.Depart, getTargetCont.Dimension, getTargetCont.Id, sonTarCont.Id, 2)
syncSeting.Add(1)
go addDetaonsCont(saveCont, receivedValue.RelevantPostsMan, postPeople, getTargetCont.Dimension)
syncSeting.Wait()
publicmethod.Result(0, receivedValue, c)
}
// 拆分细则标准或罚款
func caiFenStrint(str string) (minData, maxData int64) {
moneyAry := strings.Split(str, "-")
moneyAryLen := len(moneyAry)
if moneyAryLen > 0 {
if moneyAryLen == 1 {
maxMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64)
maxData, _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64)
minData = 0
} else {
maxMoneyEs, _ := strconv.ParseFloat(moneyAry[moneyAryLen-1], 64)
maxData, _ = strconv.ParseInt(strconv.FormatFloat(maxMoneyEs*100, 'f', -1, 64), 10, 64)
minMoneyEs, _ := strconv.ParseFloat(moneyAry[0], 64)
minData, _ = strconv.ParseInt(strconv.FormatFloat(minMoneyEs*100, 'f', -1, 64), 10, 64)
}
} else {
minData = 0
maxData = 0
}
return
}
/*
获取岗位指标子栏目相关岗位
@departmentId 部门Id
@dimensionId 维度
@targetId 指标
@level 级别1部门级2岗位级
func getTargetAboutPost(departmentId, dimensionId, targetId int64, level int) (postId []int64, postPeopleList []postPeople, err error)
*/
func getTargetSonAboutPost(departmentId, dimensionId, targetId, sonTargetId int64, level int) (postId []int64, postPeopleList []postPeople, err error) {
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`post_id`").Where("`state` = 1 AND `level` = ? AND `department_id` = ? AND `dimension_id` = ? AND `target_id` = ? AND `target_sun_id` = ?", level, departmentId, dimensionId, targetId, sonTargetId).Find(&postId).Error
if len(postId) > 0 {
for i := 0; i < len(postId); i++ {
var postmanCont postPeople
postmanCont.Id = strconv.FormatInt(postId[i], 10)
var postCont modelshr.Position
postCont.GetCont(map[string]interface{}{"`id`": postId[i]}, "`name`")
postmanCont.Name = postCont.Name
_, postmanCont.Operator, _ = getSonTargetAboutPostMan(departmentId, postId[i], dimensionId, targetId, sonTargetId, level)
if len(postmanCont.Operator) < 1 {
_, postmanCont.Operator, _ = getTargetAboutPostMan(departmentId, postId[i], dimensionId, targetId, level)
}
postPeopleList = append(postPeopleList, postmanCont)
}
}
return
}
/*
获取岗位指标子栏目相关岗位提报人
@departmentId 部门Id
@postid 岗位
@dimensionId 维度
@targetId 指标
@level 级别1部门级2岗位级
*/
func getSonTargetAboutPostMan(departmentId, postid, dimensionId, targetId, sonTargetId int64, level int) (peopleId []int64, postPeople []string, err error) {
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("`man_key`").Where("`state` = 1 AND `type` = ? AND `department_id` = ? AND `post_id` = ? AND `dimension_id` = ? AND `target_id` = ? AND `target_sun_id` = ?", level, departmentId, postid, dimensionId, targetId, sonTargetId).Find(&peopleId).Error
if len(peopleId) > 0 {
for i := 0; i < len(peopleId); i++ {
postPeople = append(postPeople, strconv.FormatInt(peopleId[i], 10))
}
}
return
}
// 删除指标细则
func (a *ApiMethod) EidtPostTarDetailsStrte(c *gin.Context) {
var requestData publicmethod.PublicState
c.ShouldBindJSON(&requestData)
if requestData.Id == "" {
publicmethod.Result(1, requestData, c, "请输入指标ID!")
return
}
if requestData.State == 0 {
requestData.State = 1
}
if requestData.IsTrue == 0 {
requestData.IsTrue = 2
}
where := publicmethod.MapOut[string]()
where["`id`"] = requestData.Id
var detaCont modelskpi.PostTargetDetails
detaErr := detaCont.GetCont(where)
if detaErr != nil {
publicmethod.Result(1, detaErr, c, "该指标细则不存在!")
return
}
if requestData.State != 3 {
saveData := publicmethod.MapOut[string]()
saveData["state"] = requestData.State
saveData["time"] = time.Now().Unix()
saveErr := detaCont.EiteCont(where, saveData)
if saveErr != nil {
publicmethod.Result(1, saveErr, c, "编辑失败!")
return
}
} else {
if requestData.IsTrue != 1 {
saveData := publicmethod.MapOut[string]()
saveData["state"] = requestData.State
saveData["time"] = time.Now().Unix()
saveErr := detaCont.EiteCont(where, saveData)
if saveErr != nil {
publicmethod.Result(1, saveErr, c, "编辑失败!")
return
}
} else {
saveErr := detaCont.DelCont(where)
if saveErr != nil {
publicmethod.Result(1, saveErr, c, "编辑失败!")
return
}
}
}
publicmethod.Result(0, detaCont, c)
}
// 编辑定性指标细则内容
func (a *ApiMethod) EditDeatilsCont(c *gin.Context) {
var receivedValue sonTargetAddDieastion
c.ShouldBindJSON(&receivedValue)
if receivedValue.Id == "" {
publicmethod.Result(1, receivedValue, c, "请输入指标ID!")
return
}
where := publicmethod.MapOut[string]()
where["`id`"] = receivedValue.Id
var detaCont modelskpi.PostTargetDetails
detaErr := detaCont.GetCont(where)
if detaErr != nil {
publicmethod.Result(1, detaErr, c, "该指标细则不存在!")
return
}
saveData := publicmethod.MapOut[string]()
if receivedValue.Title != "" && receivedValue.Title != detaCont.Title {
saveData["title"] = receivedValue.Title
}
if receivedValue.PunishMode == 0 {
receivedValue.PunishMode = 1
}
if receivedValue.Class != 0 && receivedValue.Class != detaCont.AddReduce {
saveData["add_reduce"] = receivedValue.Class
}
switch receivedValue.PunishMode {
case 2:
if receivedValue.CashStandard == "" {
minMoney, maxMoney := caiFenStrint(receivedValue.CashStandard)
if minMoney != detaCont.Minmoney {
saveData["minmoney"] = minMoney
}
if maxMoney != detaCont.Maxmoney {
saveData["maxmoney"] = maxMoney
}
}
if receivedValue.PunishMode != detaCont.Punishmode {
saveData["punishmode"] = receivedValue.PunishMode
}
case 3:
if receivedValue.PunishMode != detaCont.Punishmode {
saveData["punishmode"] = receivedValue.PunishMode
}
if receivedValue.ReferenceScore != "" {
minScoreInt, maxScoreInt := caiFenStrint(receivedValue.ReferenceScore)
if minScoreInt != detaCont.MinScore {
saveData["min_score"] = minScoreInt
}
if maxScoreInt != detaCont.MaxScore {
saveData["max_score"] = maxScoreInt
}
}
if receivedValue.CashStandard != "" {
minMoney, maxMoney := caiFenStrint(receivedValue.CashStandard)
if minMoney != detaCont.Minmoney {
saveData["minmoney"] = minMoney
}
if maxMoney != detaCont.Maxmoney {
saveData["maxmoney"] = maxMoney
}
}
if receivedValue.Unit == "" && receivedValue.Unit != detaCont.Company {
saveData["company"] = receivedValue.Unit
}
default:
receivedValue.PunishMode = 1
if receivedValue.ReferenceScore == "" {
minScoreInt, maxScoreInt := caiFenStrint(receivedValue.ReferenceScore)
if minScoreInt != detaCont.MinScore {
saveData["min_score"] = minScoreInt
}
if maxScoreInt != detaCont.MaxScore {
saveData["max_score"] = maxScoreInt
}
}
if receivedValue.Unit == "" && receivedValue.Unit != detaCont.Company {
saveData["company"] = receivedValue.Unit
}
if receivedValue.PunishMode != detaCont.Punishmode {
saveData["punishmode"] = receivedValue.PunishMode
}
}
if len(receivedValue.Inspect) > 0 {
inspectStr := strings.Join(receivedValue.Inspect, ",")
if inspectStr != detaCont.CensorType {
saveData["censor_type"] = inspectStr
}
}
if receivedValue.Cycle != 0 && receivedValue.Cycle != detaCont.Cycles {
saveData["cycle"] = receivedValue.Cycle
}
if receivedValue.CycleAttr != 0 && receivedValue.CycleAttr != detaCont.CycleAttres {
saveData["cycleattr"] = receivedValue.CycleAttr
}
if receivedValue.Frequency != 0 && receivedValue.Frequency != detaCont.CensorRate {
saveData["censor_rate"] = receivedValue.Frequency
}
if receivedValue.Evidence != "" && receivedValue.Evidence != detaCont.CensorCont {
saveData["censor_cont"] = receivedValue.Evidence
}
if receivedValue.Explain != "" && receivedValue.Explain != detaCont.Content {
saveData["content"] = receivedValue.Explain
}
if len(saveData) > 0 {
saveData["time"] = time.Now().Unix()
saveErr := detaCont.EiteCont(where, saveData)
if saveErr != nil {
publicmethod.Result(106, saveErr, c)
return
}
}
var postTarCont modelskpi.PostTarget
postTarCont.GetCont(map[string]interface{}{"`id`": detaCont.ParentId}, "`dimension`")
dimensionId := postTarCont.Dimension
var departAny []string
for _, v := range receivedValue.RelevantPostsMan {
if publicmethod.IsInTrue[string](v.Id, departAny) == false {
departAny = append(departAny, v.Id)
}
postid, _ := strconv.ParseInt(v.Id, 10, 64)
if len(v.Operator) > 0 {
syncSetinges.Add(1)
go DepartAboutPostTargetReport(dimensionId, detaCont.ParentId, detaCont.ParentIdSun, detaCont.Id, detaCont.Paretment, postid, v.Operator, 2, 1)
}
}
//关联部门岗位
if len(departAny) > 0 {
syncSetinges.Add(1)
go EditTargetTableDimenAboutPostOfDepart(dimensionId, detaCont.ParentId, detaCont.ParentIdSun, detaCont.Id, detaCont.Paretment, departAny, 2, 1)
}
syncSetinges.Wait()
publicmethod.Result(0, receivedValue, c)
}
// 获取指标细则内容
func (a *ApiMethod) GetDetailsCont(c *gin.Context) {
var receivedValue publicmethod.PublicId
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Id == "" {
publicmethod.Result(101, err, c)
return
}
where := publicmethod.MapOut[string]()
where["`id`"] = receivedValue.Id
var detaCont modelskpi.PostTargetDetails
detaErr := detaCont.GetCont(where)
if detaErr != nil {
publicmethod.Result(1, detaErr, c, "该指标细则不存在!")
return
}
var sendData sonTargetAddDieastion
sendData.Id = strconv.FormatInt(detaCont.Id, 10)
if detaCont.MinScore != 0 {
sendData.ReferenceScore = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(float64(detaCont.MinScore)/100, 2), publicmethod.DecimalEs(float64(detaCont.MaxScore)/100, 2))
} else {
sendData.ReferenceScore = fmt.Sprintf("%v", publicmethod.DecimalEs(float64(detaCont.MaxScore)/100, 2))
}
if detaCont.Minmoney != 0 {
sendData.CashStandard = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(float64(detaCont.Minmoney)/100, 2), publicmethod.DecimalEs(float64(detaCont.Maxmoney)/100, 2))
} else {
sendData.CashStandard = fmt.Sprintf("%v", publicmethod.DecimalEs(float64(detaCont.Maxmoney)/100, 2))
}
var postTarCont modelskpi.PostTarget
postTarCont.GetCont(map[string]interface{}{"`id`": detaCont.ParentId}, "`dimension`")
dimensionId := postTarCont.Dimension
sendData.Title = detaCont.Title
sendData.Unit = detaCont.Company //单位
sendData.Class = detaCont.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减
sendData.Inspect = strings.Split(detaCont.CensorType, ",") //检查方式(1:现场检查;2:资料检查;3:事件触发)
sendData.Cycle = detaCont.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年
sendData.CycleAttr = detaCont.CycleAttres //辅助计数
sendData.Frequency = detaCont.CensorRate //频次
sendData.Evidence = detaCont.CensorCont //客观证据
sendData.Explain = detaCont.Content //备注说明
_, sendData.RelevantPostsMan, _ = getTargetAboutPostDeta(detaCont.Paretment, dimensionId, detaCont.ParentId, detaCont.ParentIdSun, detaCont.Id, 2) //相关岗位与提报人
sendData.PunishMode = detaCont.Punishmode //处罚方式 1:扣分;2:现金处罚;3:扣分加现金
publicmethod.Result(0, sendData, c)
}
/*
获取岗位指标子细则相关岗位
@departmentId 部门Id
@dimensionId 维度
@targetId 指标
@bylaws 指标细则
@level 级别1部门级2岗位级
func getTargetAboutPost(departmentId, dimensionId, targetId int64, level int) (postId []int64, postPeopleList []postPeople, err error)
*/
func getTargetAboutPostDeta(departmentId, dimensionId, targetId, sonTargetId, bylaws int64, level int) (postId []int64, postPeopleList []postPeople, err error) {
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`post_id`").Where("`state` = 1 AND `level` = ? AND `department_id` = ? AND `dimension_id` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?", level, departmentId, dimensionId, targetId, sonTargetId, bylaws).Find(&postId).Error
if len(postId) > 0 {
for i := 0; i < len(postId); i++ {
var postmanCont postPeople
postmanCont.Id = strconv.FormatInt(postId[i], 10)
var postCont modelshr.Position
postCont.GetCont(map[string]interface{}{"`id`": postId[i]}, "`name`")
postmanCont.Name = postCont.Name
_, postmanCont.Operator, _ = getTargetAboutPostDetalMan(departmentId, postId[i], dimensionId, targetId, sonTargetId, bylaws, level)
postPeopleList = append(postPeopleList, postmanCont)
}
}
return
}
/*
获取岗位指标细则相关岗位提报人
@departmentId 部门Id
@postid 岗位
@dimensionId 维度
@targetId 指标
@level 级别1部门级2岗位级
*/
func getTargetAboutPostDetalMan(departmentId, postid, dimensionId, targetId, sonTargetId, bylaws int64, level int) (peopleId []int64, postPeople []string, err error) {
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("`man_key`").Where("`state` = 1 AND `type` = ? AND `department_id` = ? AND `post_id` = ? AND `dimension_id` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?", level, departmentId, postid, dimensionId, targetId, sonTargetId, bylaws).Find(&peopleId).Error
if len(peopleId) > 0 {
for i := 0; i < len(peopleId); i++ {
postPeople = append(postPeople, strconv.FormatInt(peopleId[i], 10))
}
}
return
}

46
api/version1/postseting/postpc/type.go

@ -235,3 +235,49 @@ type sendNaitonTargetDeiment struct {
ReferenceScore string `json:"referencescore"` //考核标准
CashStandard string `json:"cashstandard"` //现金标准
}
// 输出岗位单一子栏目详细
type sendOneSonTargetCont struct {
modelskpi.PostSonTarget
Department string `json:"department"` //行政组织名称
IdStr string `json:"idstr"`
PostOfOperator []postOperator `json:"postoperator"` //岗位与提报人
}
type postOperator struct {
idAndName
Operator operatorList `json:"operator"`
}
type operatorList struct {
UserKey []string `json:"userkey"`
UserList []UserContList `json:"userlist"`
}
type idAndName struct {
publicmethod.PublicId
publicmethod.PublicName
}
type UserContList struct {
idAndName
Icon string `json:"icon"`
Number string `json:"number"`
}
// 岗位细则设定提报人关联
type postDeasiteMan struct {
publicmethod.PublicId
Operator []string `json:"operator"` //考核执行人
}
// 获取岗位考核子栏目修改数据
type editSonTargetPost struct {
publicmethod.PublicId
publicmethod.PublicName
PostOfOperator []postDeasiteMan `json:"postoperator"` //岗位与提报人
}
// 根据子栏目添加指标细则
type sonTargetAddDieastion struct {
publicmethod.PublicId
postContList
}

34
apirouter/v1/postseting/pc.go

@ -12,22 +12,38 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
var methodBinding = version1.AppApiEntry.PostPcApi
{
apiRouter.GET("", methodBinding.Index) //入口
apiRouter.POST("", methodBinding.Index) //入口
apiRouter.GET("", methodBinding.Index) //入口
apiRouter.POST("", methodBinding.Index) //入口
apiRouter.POST("get_scheme_list", methodBinding.GetSchemeList) //获取岗位考核方案列表
apiRouter.POST("submit_post_scheme", methodBinding.SubmitPostScheme) //提交岗位考核方案
apiRouter.POST("get_post_scheme", methodBinding.GetPostScheme) //获取岗位方案内容列表
apiRouter.POST("get_copy_sheme_infor", methodBinding.GetCopyShemeInfor) //获取复制岗位考核方案
/*
岗位定性指标
*/
apiRouter.POST("getpostabouttarget", methodBinding.GetPostAboutTarget) //获取岗位相关指标
apiRouter.POST("quote_department_target", methodBinding.QuoteDepartmentTarget) //引用指标部门指标
apiRouter.POST("get_scheme_list", methodBinding.GetSchemeList) //获取岗位考核方案列表
apiRouter.POST("submit_post_scheme", methodBinding.SubmitPostScheme) //提交岗位考核方案
apiRouter.POST("get_post_scheme", methodBinding.GetPostScheme) //获取岗位方案内容列表
apiRouter.POST("get_copy_sheme_infor", methodBinding.GetCopyShemeInfor) //获取复制岗位考核方案
apiRouter.POST("get_post_target", methodBinding.GetPostTarget) //获取岗位指标详情
apiRouter.POST("add_post_target", methodBinding.AddPostTarget) //添加岗位指标
apiRouter.POST("dit_post_target", methodBinding.EditPostTarget) //编辑岗位指标
apiRouter.POST("get_target_about_depart_to_post_man", methodBinding.GetTargetAboutDepartToPostMan) //获取岗位指标关联部门相关岗位及提报人
apiRouter.POST("add_post_target_cont", methodBinding.AddPostTargetCont) //根据指标添加岗位细则
apiRouter.POST("edit_scheme_state_of_del", methodBinding.EditSchemeStateOfDel) //编辑方案版本状态或删除
apiRouter.POST("posttargetsunlist", methodBinding.PostTargetSunList) //根据指标获取岗位定性指标细则列表
/*
岗位定性指标子栏目
*/
apiRouter.POST("get_sun_target_info", methodBinding.GetSunTargetInfo) //获取岗位子栏目详情
apiRouter.POST("edit_son_target_cont", methodBinding.EditSonTargetCont) //编辑岗位子栏目内容
apiRouter.POST("del_son_target_cont", methodBinding.DelSonTargetCont) //删除子栏目
/*
定性指标细则
*/
apiRouter.POST("addpostdetacont", methodBinding.AddOneTargetD) //添加单条定性指标细则
apiRouter.POST("eidtposttardetailsstrte", methodBinding.EidtPostTarDetailsStrte) //删除指标细则
apiRouter.POST("editdeatilscont", methodBinding.EditDeatilsCont) //编辑定性指标细则内容
apiRouter.POST("getdetailscont", methodBinding.GetDetailsCont) //获取指标细则内容
apiRouter.POST("edit_scheme_state_of_del", methodBinding.EditSchemeStateOfDel) //编辑方案版本状态或删除
apiRouter.POST("posttargetsunlist", methodBinding.PostTargetSunList) //根据指标获取岗位定性指标细则列表
}
}

Loading…
Cancel
Save