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.
653 lines
24 KiB
653 lines
24 KiB
package postpc
|
|
|
|
import (
|
|
"fmt"
|
|
"key_performance_indicators/models/modelskpi"
|
|
"key_performance_indicators/overall"
|
|
"key_performance_indicators/overall/publicmethod"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
//岗位指标相关操作
|
|
|
|
// 获取岗位指标详情
|
|
func (a *ApiMethod) GetPostTarget(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, receivedValue, c)
|
|
return
|
|
}
|
|
var postTargetCont modelskpi.PostTarget
|
|
err = postTargetCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id})
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
var sendData getPostOneTarget
|
|
sendData.Id = postTargetCont.Id
|
|
sendData.Title = postTargetCont.Title //标题"`
|
|
sendData.Type = postTargetCont.Type //1:定性考核;2:定量考核"`
|
|
sendData.State = postTargetCont.State //:状态(1:启用;2:禁用;3:删除)"`
|
|
sendData.Time = postTargetCont.Time //创建时间"`
|
|
sendData.Share = postTargetCont.Share //1:共用;2:私用"`
|
|
sendData.ReleDepart = postTargetCont.ReleDepart //相关部门"`
|
|
sendData.DepartmentsPost = postTargetCont.DepartmentsPost //相关岗位"`
|
|
sendData.Dimension = postTargetCont.Dimension //维度"`
|
|
sendData.Key = postTargetCont.Key //UUID"`
|
|
sendData.Report = postTargetCont.Report //上报人"`
|
|
sendData.Unit = postTargetCont.Unit //单位"`
|
|
sendData.Cycle = postTargetCont.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
sendData.Cycleattr = postTargetCont.Cycleattr //辅助计数"`
|
|
sendData.ScoringMethod = postTargetCont.ScoringMethod //计分方式(1:自动;2:手动)"`
|
|
sendData.VisibleRange = postTargetCont.VisibleRange //可见范围"`
|
|
sendData.VisibleGroup = postTargetCont.VisibleGroup //可见范围(集团)"`
|
|
_, sendData.RelevantPostsMan, _ = getTargetAboutPost(postTargetCont.ReleDepart, postTargetCont.Dimension, postTargetCont.Id, 2)
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
获取岗位指标相关岗位
|
|
@departmentId 部门Id
|
|
@dimensionId 维度
|
|
@targetId 指标
|
|
@level 级别(1:部门级;2:岗位级)
|
|
func getTargetAboutPost(departmentId, dimensionId, targetId int64, level int) (postId []int64, postPeopleList []postPeople, err error)
|
|
*/
|
|
func getTargetAboutPost(departmentId, dimensionId, targetId 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` = ?", level, departmentId, dimensionId, targetId).Find(&postId).Error
|
|
if len(postId) > 0 {
|
|
for i := 0; i < len(postId); i++ {
|
|
var postmanCont postPeople
|
|
postmanCont.Id = strconv.FormatInt(postId[i], 10)
|
|
_, postmanCont.Operator, _ = getTargetAboutPostMan(departmentId, postId[i], dimensionId, targetId, level)
|
|
postPeopleList = append(postPeopleList, postmanCont)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
获取岗位指标相关岗位提报人
|
|
@departmentId 部门Id
|
|
@postid 岗位
|
|
@dimensionId 维度
|
|
@targetId 指标
|
|
@level 级别(1:部门级;2:岗位级)
|
|
*/
|
|
func getTargetAboutPostMan(departmentId, postid, dimensionId, targetId 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` = ?", level, departmentId, postid, dimensionId, targetId).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) AddPostTarget(c *gin.Context) {
|
|
var receivedValue addPostTarget
|
|
c.ShouldBindJSON(&receivedValue)
|
|
if receivedValue.Title == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请输入指标名称!")
|
|
return
|
|
}
|
|
if receivedValue.Type == 0 {
|
|
receivedValue.Type = 2
|
|
}
|
|
if receivedValue.ScoringMethod == 0 {
|
|
receivedValue.ScoringMethod = 1
|
|
}
|
|
if receivedValue.RelevantDepartments == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请选择该指标归属部门!")
|
|
return
|
|
}
|
|
if len(receivedValue.RelevantPostsMan) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "请选择该指标归属岗位!")
|
|
return
|
|
}
|
|
if receivedValue.Dimension == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请选择指标归属维度!")
|
|
return
|
|
}
|
|
if receivedValue.Unit == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请输入该指标计算单位!")
|
|
return
|
|
}
|
|
if receivedValue.Cycle == 0 {
|
|
receivedValue.Cycle = 1
|
|
}
|
|
if receivedValue.CycleAttr == 0 {
|
|
receivedValue.CycleAttr = 1
|
|
}
|
|
|
|
var saveData modelskpi.PostTarget
|
|
saveData.Title = receivedValue.Title //标题"`
|
|
saveData.Type = receivedValue.Type //1:定性考核;2:定量考核"`
|
|
saveData.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
saveData.Time = time.Now().Unix() //创建时间"`
|
|
saveData.Share = 2 //1:共用;2:私用"`
|
|
departmentId, _ := strconv.ParseInt(receivedValue.RelevantDepartments, 10, 64)
|
|
saveData.ReleDepart = departmentId //相关部门"`
|
|
// saveData.DepartmentsPost = strings.Join(receivedValue.DepartmentsPost, ",") //相关岗位"`
|
|
dimensionId, _ := strconv.ParseInt(receivedValue.Dimension, 10, 64)
|
|
saveData.Dimension = dimensionId //维度"`
|
|
saveData.Key = publicmethod.GetUUid(1) //UUID"`
|
|
// saveData.Report = strings.Join(receivedValue.Report, ",") //上报人"`
|
|
saveData.Unit = receivedValue.Unit //单位"`
|
|
saveData.Cycle = receivedValue.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
saveData.Cycleattr = receivedValue.CycleAttr //辅助计数"`
|
|
saveData.ScoringMethod = receivedValue.ScoringMethod //计分方式(1:自动;2:手动)"`
|
|
saveData.VisibleRange = strings.Join(receivedValue.VisibleRange, ",") //可见范围"`
|
|
saveData.VisibleGroup = strings.Join(receivedValue.VisibleGroup, ",") //可见范围(集团)"`
|
|
|
|
//获取岗位与提报人
|
|
var departAny []string
|
|
var peopletAny []string
|
|
for _, v := range receivedValue.RelevantPostsMan {
|
|
if publicmethod.IsInTrue[string](v.Id, departAny) == false {
|
|
departAny = append(departAny, v.Id)
|
|
}
|
|
if len(v.Operator) > 0 {
|
|
for _, ov := range v.Operator {
|
|
if publicmethod.IsInTrue[string](ov, peopletAny) == false {
|
|
peopletAny = append(peopletAny, ov)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
saveData.DepartmentsPost = strings.Join(departAny, ",") //相关岗位"`
|
|
saveData.Report = strings.Join(peopletAny, ",") //上报人"`
|
|
|
|
err := overall.CONSTANT_DB_KPI.Create(&saveData).Error
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
//关联部门岗位
|
|
if len(departAny) > 0 {
|
|
syncSetinges.Add(1)
|
|
go EditTargetTableDimenAboutPostOfDepart(dimensionId, saveData.Id, 0, 0, departmentId, departAny, 2, receivedValue.Type)
|
|
}
|
|
//关联考核岗位和提报人
|
|
for _, dv := range receivedValue.RelevantPostsMan {
|
|
postid, _ := strconv.ParseInt(dv.Id, 10, 64)
|
|
syncSetinges.Add(1)
|
|
go DepartAboutPostTargetReport(dimensionId, saveData.Id, 0, 0, departmentId, postid, dv.Operator, 2, receivedValue.Type)
|
|
|
|
}
|
|
syncSetinges.Wait()
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
编辑指标、栏目、细则关联部门
|
|
|
|
协程处理
|
|
|
|
部门指标岗位提报人关联通用函数
|
|
@dimensionId 维度
|
|
@targetId 指标ID
|
|
@targetSunId 栏目ID
|
|
@bylawsId 指标细则
|
|
@departmentId 接受考核部门
|
|
@postId 岗位
|
|
@class 级别(1:部门级;2:岗位级)
|
|
@nature 1:定性考核;2:定量考核
|
|
EditTargetTableDimenAboutPostOfDepart(dimensionId, targetId, targetSunId, bylawsId, departmentId int64, postId []string, class, nature int)
|
|
*/
|
|
func EditTargetTableDimenAboutPostOfDepart(dimensionId, targetId, targetSunId, bylawsId, departmentId int64, postId []string, class, nature int) {
|
|
defer syncSetinges.Done()
|
|
//将不属于的信息禁用
|
|
otherSaveData := publicmethod.MapOut[string]()
|
|
otherSaveData["`state`"] = 2
|
|
otherSaveData["`time`"] = time.Now().Unix()
|
|
|
|
//判断岗位是否存在
|
|
where := publicmethod.MapOut[string]()
|
|
where["`type`"] = class
|
|
if targetId != 0 {
|
|
where["`dimension_id`"] = dimensionId
|
|
}
|
|
if targetId != 0 {
|
|
where["`target_id`"] = targetId
|
|
}
|
|
if targetSunId != 0 {
|
|
where["`target_sun_id`"] = targetSunId
|
|
}
|
|
if bylawsId != 0 {
|
|
where["`target_bylaws`"] = bylawsId
|
|
}
|
|
if departmentId != 0 {
|
|
where["`department_id`"] = departmentId
|
|
}
|
|
|
|
if len(postId) < 1 {
|
|
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where(where).Updates(&otherSaveData)
|
|
} else {
|
|
//获取关联部门
|
|
var aboutDepartment []string
|
|
for _, v := range postId {
|
|
if publicmethod.IsInTrue[string](v, aboutDepartment) == false {
|
|
aboutDepartment = append(aboutDepartment, v)
|
|
//判断该岗位是否已经关联
|
|
var tarDeparCont modelskpi.TargetDepartment
|
|
judgeAboutErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Select("`id`,`state`").Where(where).Where("`post_id` = ?", v).First(&tarDeparCont).Error
|
|
if judgeAboutErr == nil {
|
|
tarDeparCont.EiteCont(map[string]interface{}{"`id`": tarDeparCont.Id}, map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()})
|
|
} else {
|
|
xiZe := 3
|
|
if targetId != 0 && targetSunId != 0 && bylawsId == 0 {
|
|
xiZe = 2
|
|
} else if targetId != 0 && targetSunId == 0 && bylawsId == 0 {
|
|
xiZe = 1
|
|
}
|
|
|
|
tarDeparCont.Dimension = dimensionId //维度"`
|
|
tarDeparCont.TargetId = targetId //指标ID"`
|
|
tarDeparCont.TargetSunId = targetSunId //子目标"`
|
|
tarDeparCont.TargetBylaws = bylawsId //指标细则"`
|
|
tarDeparCont.Type = xiZe //类型(1:指标;2:子目标;3:细则)"`
|
|
tarDeparCont.DepartmentId = departmentId //部门ID"`
|
|
postIdInt64, _ := strconv.ParseInt(v, 10, 64)
|
|
tarDeparCont.PostId = postIdInt64 //岗位ID"`
|
|
tarDeparCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
tarDeparCont.Time = time.Now().Unix() //写入时间"`
|
|
tarDeparCont.Class = nature //1:定性考核;2:定量考核"`
|
|
tarDeparCont.Level = class //级别(1:部门级;2:岗位级)"`
|
|
overall.CONSTANT_DB_KPI.Create(&tarDeparCont)
|
|
}
|
|
}
|
|
}
|
|
//清除不需要关联的部门
|
|
if len(aboutDepartment) > 0 {
|
|
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Where(where).Not(map[string]interface{}{"`post_id`": aboutDepartment}).Updates(&otherSaveData)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 编辑岗位指标
|
|
func (a *ApiMethod) EditPostTarget(c *gin.Context) {
|
|
var receivedValue editPostTargetCont
|
|
c.ShouldBindJSON(&receivedValue)
|
|
if receivedValue.Id == "" {
|
|
publicmethod.Result(1, receivedValue, c, "参数错误!")
|
|
return
|
|
}
|
|
where := publicmethod.MapOut[string]()
|
|
where["`id`"] = receivedValue.Id
|
|
var postTargetCont modelskpi.PostTarget
|
|
err := postTargetCont.GetCont(where)
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
saveData := publicmethod.MapOut[string]()
|
|
if receivedValue.Title != "" && receivedValue.Title != postTargetCont.Title {
|
|
saveData["title"] = receivedValue.Title
|
|
}
|
|
if receivedValue.Type != 0 && receivedValue.Type != postTargetCont.Type {
|
|
saveData["type"] = receivedValue.Type
|
|
}
|
|
if receivedValue.ScoringMethod != 0 && receivedValue.ScoringMethod != postTargetCont.ScoringMethod {
|
|
saveData["scoring_method"] = receivedValue.ScoringMethod
|
|
}
|
|
if receivedValue.RelevantDepartments != "" {
|
|
departmentId, _ := strconv.ParseInt(receivedValue.RelevantDepartments, 10, 64)
|
|
if departmentId != postTargetCont.ReleDepart {
|
|
saveData["rele_depart"] = departmentId
|
|
}
|
|
|
|
}
|
|
|
|
if receivedValue.Dimension != "" {
|
|
dimensionId, _ := strconv.ParseInt(receivedValue.Dimension, 10, 64)
|
|
if dimensionId != postTargetCont.Dimension {
|
|
saveData["dimension"] = dimensionId
|
|
}
|
|
}
|
|
|
|
if receivedValue.Unit != "" && receivedValue.Unit != postTargetCont.Unit {
|
|
saveData["unit"] = receivedValue.Unit
|
|
}
|
|
if receivedValue.Cycle != 0 && receivedValue.Cycle != postTargetCont.Cycle {
|
|
saveData["cycle"] = receivedValue.Cycle
|
|
}
|
|
if receivedValue.CycleAttr != 0 && receivedValue.CycleAttr != postTargetCont.Cycleattr {
|
|
saveData["cycleattr"] = receivedValue.CycleAttr
|
|
}
|
|
|
|
if len(receivedValue.VisibleRange) > 0 {
|
|
visibleRangeStr := strings.Join(receivedValue.VisibleRange, ",")
|
|
if visibleRangeStr != postTargetCont.VisibleRange {
|
|
saveData["visible_range"] = visibleRangeStr
|
|
}
|
|
}
|
|
if len(receivedValue.VisibleGroup) > 0 {
|
|
visibleGroupStr := strings.Join(receivedValue.VisibleGroup, ",")
|
|
if visibleGroupStr != postTargetCont.VisibleGroup {
|
|
saveData["visible_group"] = visibleGroupStr
|
|
}
|
|
}
|
|
|
|
//获取岗位与提报人
|
|
var departAny []string
|
|
var peopletAny []string
|
|
for _, v := range receivedValue.RelevantPostsMan {
|
|
if publicmethod.IsInTrue[string](v.Id, departAny) == false {
|
|
departAny = append(departAny, v.Id)
|
|
}
|
|
if len(v.Operator) > 0 {
|
|
for _, ov := range v.Operator {
|
|
if publicmethod.IsInTrue[string](ov, peopletAny) == false {
|
|
peopletAny = append(peopletAny, ov)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(departAny) > 0 {
|
|
departPostStr := strings.Join(departAny, ",")
|
|
if departPostStr != postTargetCont.DepartmentsPost {
|
|
saveData["departments_post"] = departPostStr
|
|
//关联部门岗位
|
|
if len(departAny) > 0 {
|
|
syncSetinges.Add(1)
|
|
go EditTargetTableDimenAboutPostOfDepart(postTargetCont.Dimension, postTargetCont.Id, 0, 0, postTargetCont.ReleDepart, departAny, 2, postTargetCont.Type)
|
|
}
|
|
}
|
|
}
|
|
|
|
if len(peopletAny) > 0 {
|
|
reportStr := strings.Join(peopletAny, ",")
|
|
if reportStr != postTargetCont.Report {
|
|
saveData["report"] = reportStr
|
|
//关联考核岗位和提报人
|
|
for _, dv := range receivedValue.RelevantPostsMan {
|
|
postid, _ := strconv.ParseInt(dv.Id, 10, 64)
|
|
syncSetinges.Add(1)
|
|
go DepartAboutPostTargetReport(postTargetCont.Dimension, postTargetCont.Id, 0, 0, postTargetCont.ReleDepart, postid, dv.Operator, 2, postTargetCont.Type)
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
if len(saveData) > 0 {
|
|
saveData["time"] = time.Now().Unix()
|
|
saveErr := postTargetCont.EiteCont(where, saveData)
|
|
if saveErr != nil {
|
|
publicmethod.Result(106, saveErr, c)
|
|
} else {
|
|
publicmethod.Result(0, saveErr, c)
|
|
}
|
|
} else {
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
}
|
|
|
|
// 获取岗位指标关联部门相关岗位及提报人
|
|
func (a *ApiMethod) GetTargetAboutDepartToPostMan(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, receivedValue, c)
|
|
return
|
|
}
|
|
var postTargetCont modelskpi.PostTarget
|
|
err = postTargetCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id})
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
_, outData, _ := getTargetAboutPost(postTargetCont.ReleDepart, postTargetCont.Dimension, postTargetCont.Id, 2)
|
|
publicmethod.Result(0, outData, c)
|
|
}
|
|
|
|
// 根据指标添加岗位细则
|
|
func (a *ApiMethod) AddPostTargetCont(c *gin.Context) {
|
|
var receivedValue addPostContTarget
|
|
c.ShouldBindJSON(&receivedValue)
|
|
if receivedValue.TargetId == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请选择岗位指标!")
|
|
return
|
|
}
|
|
if receivedValue.DepartmentId == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请选择行政组织!")
|
|
return
|
|
}
|
|
if receivedValue.TargetSunTitle == "" {
|
|
publicmethod.Result(1, receivedValue, c, "请输入子栏目名称!")
|
|
return
|
|
}
|
|
if len(receivedValue.PostId) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "请选择岗位!")
|
|
return
|
|
}
|
|
if len(receivedValue.List) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "请输入指标细则!")
|
|
return
|
|
}
|
|
xiZeIsTrue := 1
|
|
for _, v := range receivedValue.List {
|
|
if v.Title == "" {
|
|
xiZeIsTrue = 2
|
|
break
|
|
}
|
|
if v.ReferenceScore == "" {
|
|
xiZeIsTrue = 2
|
|
break
|
|
}
|
|
if v.Unit == "" {
|
|
xiZeIsTrue = 2
|
|
break
|
|
}
|
|
}
|
|
if xiZeIsTrue != 1 {
|
|
publicmethod.Result(1, receivedValue, c, "请检查你输入的指标细则!其中有不符合标准的细则!")
|
|
return
|
|
}
|
|
targetSunIdInt, _ := strconv.ParseInt(receivedValue.TargetId, 10, 64)
|
|
deartmentIdInt, _ := strconv.ParseInt(receivedValue.DepartmentId, 10, 64)
|
|
//获取指标信息
|
|
var getTargetCont modelskpi.PostTarget
|
|
getTargetCont.GetCont(map[string]interface{}{"`id`": receivedValue.TargetId})
|
|
_, postPeople, _ := getTargetAboutPost(deartmentIdInt, getTargetCont.Dimension, getTargetCont.Id, 2)
|
|
|
|
//指标子栏目
|
|
var sunTargetCont modelskpi.PostSonTarget
|
|
sunErr := sunTargetCont.GetCont(map[string]interface{}{"`title`": receivedValue.TargetSunTitle, "`parent_id`": receivedValue.TargetId, "depart": receivedValue.DepartmentId}, "`id`")
|
|
if sunErr != nil {
|
|
sunTargetCont.Title = receivedValue.TargetSunTitle //标题"`
|
|
|
|
sunTargetCont.ParentId = targetSunIdInt //归属指标"`
|
|
sunTargetCont.Time = time.Now().Unix() //创建时间"`
|
|
sunTargetCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
sunTargetCont.Depart = deartmentIdInt //关联部门"`
|
|
sunTargetCont.DepartPost = strings.Join(receivedValue.PostId, ",")
|
|
sunTargetErr := overall.CONSTANT_DB_KPI.Create(&sunTargetCont).Error
|
|
if sunTargetErr != nil {
|
|
publicmethod.Result(104, sunTargetErr, c)
|
|
return
|
|
}
|
|
}
|
|
if sunTargetCont.Id == 0 {
|
|
publicmethod.Result(104, sunTargetCont, c)
|
|
return
|
|
}
|
|
//考核细则写入
|
|
for _, lv := range receivedValue.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 = getTargetCont.Cycle
|
|
}
|
|
if lv.CycleAttr == 0 {
|
|
lv.CycleAttr = getTargetCont.Cycleattr
|
|
}
|
|
if lv.Frequency == 0 {
|
|
lv.Frequency = 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 modelskpi.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.Frequency //检查频次"`
|
|
saveCont.Cycles = lv.Cycle //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保存"`
|
|
syncSeting.Add(1)
|
|
go addDetaonsCont(saveCont, lv.RelevantPostsMan, postPeople, getTargetCont.Dimension)
|
|
}
|
|
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, deartmentIdInt, getTargetCont.Dimension, getTargetCont.Id, sunTargetCont.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)
|
|
}
|
|
sunTargetCont.EiteCont(map[string]interface{}{"`id`": sunTargetCont.Id}, map[string]interface{}{"`depart_post`": strings.Join(postIdStr, ","), "`time`": time.Now().Unix()})
|
|
}
|
|
publicmethod.Result(0, postIdInt64, c)
|
|
}
|
|
|
|
/*
|
|
添加指标细则
|
|
@saveCont 指标细则数据
|
|
@postMan 指标细则岗位提报人键对
|
|
*/
|
|
func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan []postPeople, dimensionId int64) {
|
|
defer syncSeting.Done()
|
|
|
|
//获取岗位与提报人
|
|
var departAny []string
|
|
var peopletAny []string
|
|
for _, v := range postMan {
|
|
if publicmethod.IsInTrue[string](v.Id, departAny) == false {
|
|
departAny = append(departAny, v.Id)
|
|
}
|
|
if len(v.Operator) > 0 {
|
|
for _, ov := range v.Operator {
|
|
if publicmethod.IsInTrue[string](ov, peopletAny) == false {
|
|
peopletAny = append(peopletAny, ov)
|
|
}
|
|
}
|
|
} else {
|
|
for _, tarv := range targetPostMan {
|
|
if tarv.Id == v.Id {
|
|
for _, otv := range tarv.Operator {
|
|
if publicmethod.IsInTrue[string](otv, peopletAny) == false {
|
|
peopletAny = append(peopletAny, otv)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
saveCont.ParetmentPost = strings.Join(departAny, ",") //相关岗位"`
|
|
saveCont.Reportary = strings.Join(peopletAny, ",") //上报人"`
|
|
|
|
overall.CONSTANT_DB_KPI.Create(&saveCont)
|
|
fmt.Printf("postMan------->%v--------targetPostMan------->%v--------departAny------->%v--------peopletAny------->%v\n", postMan, targetPostMan, departAny, peopletAny)
|
|
//关联部门岗位
|
|
if len(departAny) > 0 {
|
|
syncSetinges.Add(1)
|
|
go EditTargetTableDimenAboutPostOfDepart(dimensionId, saveCont.ParentId, saveCont.ParentIdSun, saveCont.Id, saveCont.Paretment, departAny, 2, 1)
|
|
|
|
}
|
|
//关联考核岗位和提报人
|
|
for _, dv := range targetPostMan {
|
|
operatorList := dv.Operator
|
|
if len(operatorList) < 1 {
|
|
for _, tarv := range targetPostMan {
|
|
if tarv.Id == dv.Id {
|
|
operatorList = tarv.Operator
|
|
}
|
|
}
|
|
}
|
|
postid, _ := strconv.ParseInt(dv.Id, 10, 64)
|
|
syncSetinges.Add(1)
|
|
go DepartAboutPostTargetReport(dimensionId, saveCont.ParentId, saveCont.ParentIdSun, saveCont.Id, saveCont.Paretment, postid, operatorList, 2, 1)
|
|
|
|
}
|
|
syncSetinges.Wait()
|
|
}
|
|
|