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.
889 lines
32 KiB
889 lines
32 KiB
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"
|
|
"key_performance_indicators/overall/publicmethod"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-20 08:46:24
|
|
@ 功能: 根据指标获取细则列表
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GetDetailsList(c *gin.Context) {
|
|
var receivedValue GetPostDetails
|
|
c.ShouldBindJSON(&receivedValue)
|
|
if receivedValue.TargetId == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知指标!请指定!")
|
|
return
|
|
}
|
|
var idList []int64
|
|
var detCont modelskpi.PostTargetDetails
|
|
gormDb := overall.CONSTANT_DB_KPI.Table(fmt.Sprintf("%s dt", detCont.TableName())).Distinct("dt.id").Where("dt.state BETWEEN 1 AND 2 AND dt.parentid = ?", receivedValue.TargetId)
|
|
if receivedValue.Cycle != 0 {
|
|
gormDb = gormDb.Where("dt.`cycle` = ?", receivedValue.Cycle)
|
|
}
|
|
if len(receivedValue.Inspect) > 0 {
|
|
var sqlOrStr string
|
|
for ti, tv := range receivedValue.Inspect {
|
|
if ti == 0 {
|
|
// gormDb = gormDb.Where("FIND_IN_SET(?,`dt_censor_type`)", tv)
|
|
sqlOrStr = fmt.Sprintf("FIND_IN_SET(%v,dt.`censor_type`)", tv)
|
|
} else {
|
|
// gormDb = gormDb.Or("FIND_IN_SET(?,`dt_censor_type`)", tv)
|
|
sqlOrStr = fmt.Sprintf("%v OR FIND_IN_SET(%v,dt.`censor_type`)", sqlOrStr, tv)
|
|
}
|
|
}
|
|
gormDb = gormDb.Where(sqlOrStr)
|
|
}
|
|
if len(receivedValue.PostList) > 0 {
|
|
gormDb = gormDb.Joins("LEFT JOIN `target_department` `td` on td.target_id = dt.parentid AND td.target_sun_id = dt.parentid_sun AND td.target_bylaws = dt.id").Where("td.`type` = 3 AND td.`state` BETWEEN 1 AND 2 AND td.`level` = 2 AND td.post_id IN ?", receivedValue.PostList)
|
|
}
|
|
err := gormDb.Find(&idList).Error
|
|
if err != nil || len(idList) < 1 {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
|
|
var listCont []modelskpi.PostTargetDetails
|
|
err = overall.CONSTANT_DB_KPI.Where("`id` IN ?", idList).Order("parentid desc, parentid_sun").Find(&listCont).Error
|
|
if err != nil || len(listCont) < 1 {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
|
|
var sendContList []OutPostDetailsCont
|
|
var lastSunTable int64
|
|
jishuqi := 1
|
|
for _, v := range listCont {
|
|
|
|
var sendCont OutPostDetailsCont
|
|
sendCont.Id = v.Id
|
|
sendCont.Title = v.Title //指标细则"`
|
|
sendCont.Content = v.Content //指标说明"`
|
|
sendCont.ParentId = v.ParentId //归属指标栏目"`
|
|
if lastSunTable != v.ParentIdSun {
|
|
lastSunTable = v.ParentIdSun
|
|
jishuqi = 1
|
|
} else {
|
|
jishuqi = jishuqi + 1
|
|
}
|
|
sendCont.JiBuQi = jishuqi
|
|
sendCont.ParentIdSun = v.ParentIdSun //归属指标子栏目"`
|
|
sendCont.State = v.State //状态(1:启用;2:禁用;3:删除)"`
|
|
sendCont.AddTime = v.AddTime //制定时间"`
|
|
sendCont.MinScore = v.MinScore //(最小分*100保存"`
|
|
sendCont.MaxScore = v.MaxScore //(最大分*100保存"`
|
|
sendCont.Company = v.Company //单位"`
|
|
sendCont.AddReduce = v.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"`
|
|
sendCont.CensorType = v.CensorType //检查方式"`
|
|
sendCont.CensorCont = v.CensorCont //检查依据"`
|
|
sendCont.CensorRate = v.CensorRate //检查频次"`
|
|
sendCont.Cycles = v.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
sendCont.CycleAttres = v.CycleAttres //辅助计数"`
|
|
sendCont.Paretment = v.Paretment //接受考核的部门"`
|
|
sendCont.ParetmentPost = v.ParetmentPost //接受考核的部门岗位"`
|
|
sendCont.Reportary = v.Reportary //提报人"`
|
|
sendCont.Punishmode = v.Punishmode //(处罚方式 1:扣分;2:现金处罚;3:扣分加现金"`
|
|
sendCont.Maxmoney = v.Maxmoney //最高罚款"`
|
|
sendCont.Minmoney = v.Minmoney //最低罚款"`
|
|
|
|
if v.MinScore != 0 && v.MaxScore != 0 {
|
|
sendCont.Standard = fmt.Sprintf("%v-%v", float64(v.MinScore)/100, float64(v.MaxScore)/100)
|
|
} else if v.MinScore == 0 && v.MaxScore != 0 {
|
|
sendCont.Standard = fmt.Sprintf("%v", float64(v.MaxScore)/100)
|
|
} else if v.MinScore != 0 && v.MaxScore == 0 {
|
|
sendCont.Standard = fmt.Sprintf("%v", float64(v.MinScore)/100)
|
|
} else {
|
|
sendCont.Standard = ""
|
|
}
|
|
|
|
if v.Minmoney != 0 && v.Maxmoney != 0 {
|
|
sendCont.Forfeit = fmt.Sprintf("%v-%v元", float64(v.Minmoney)/100, float64(v.Maxmoney)/100)
|
|
} else if v.Minmoney == 0 && v.Maxmoney != 0 {
|
|
sendCont.Forfeit = fmt.Sprintf("%v元", float64(v.Maxmoney)/100)
|
|
} else if v.Minmoney != 0 && v.Maxmoney == 0 {
|
|
sendCont.Forfeit = fmt.Sprintf("%v元", float64(v.Minmoney)/100)
|
|
} else {
|
|
sendCont.Forfeit = ""
|
|
}
|
|
var sonTargetCont modelskpi.PostSonTarget
|
|
sonTargetCont.GetCont(map[string]interface{}{"id": v.ParentIdSun}, "title")
|
|
sendCont.ColumnName = sonTargetCont.Title
|
|
|
|
sendContList = append(sendContList, sendCont)
|
|
}
|
|
publicmethod.Result(0, sendContList, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-20 14:37:30
|
|
@ 功能: 获取岗位指标关联部门相关岗位及提报人(新版)
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GetNewTargetAboutDepartToPostMan(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 postId []int64
|
|
// err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`post_id`").Where("`state` = 1 AND `type` = 1 AND `level` = 2 AND `target_id` = ? AND `target_sun_id` = 0 AND `target_bylaws` = 0", postTargetCont.Id).Find(&postId).Error
|
|
// if err != nil && len(postId) < 1 {
|
|
// publicmethod.Result(107, err, c)
|
|
// return
|
|
// }
|
|
// var orgId []int64
|
|
// err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`department_id`").Where("`state` = 1 AND `type` = 1 AND `level` = 2 AND `target_id` = ? AND `target_sun_id` = 0 AND `target_bylaws` = 0", postTargetCont.Id).Find(&orgId).Error
|
|
// if err != nil && len(orgId) < 1 {
|
|
// publicmethod.Result(107, err, c)
|
|
// return
|
|
// }
|
|
var sendCont OutTargetDepatPostMan
|
|
var tarDepatContList []modelskpi.TargetDepartment
|
|
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Select("`department_id`,`post_id`").Where("`state` = 1 AND `type` = 1 AND `level` = 2 AND `target_id` = ? AND `target_sun_id` = 0 AND `target_bylaws` = 0", postTargetCont.Id).Find(&tarDepatContList).Error
|
|
if err != nil && len(tarDepatContList) < 1 {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
for _, v := range tarDepatContList {
|
|
orgIdstr := strconv.FormatInt(v.DepartmentId, 10)
|
|
if publicmethod.IsInTrue[string](orgIdstr, sendCont.OrgId) == false {
|
|
sendCont.OrgId = append(sendCont.OrgId, orgIdstr)
|
|
}
|
|
postIdstr := strconv.FormatInt(v.PostId, 10)
|
|
if publicmethod.IsInTrue[string](postIdstr, sendCont.PostId) == false {
|
|
sendCont.PostId = append(sendCont.PostId, postIdstr)
|
|
}
|
|
var orgPostInfo OrgPostCont
|
|
orgPostInfo.Id = postIdstr
|
|
var postInfo modelshr.Position
|
|
postInfo.GetCont(map[string]interface{}{"`id`": v.PostId}, "`name`")
|
|
_, _, departmentId, sunDepartId, workShopId := publicmethod.GetOrgStructure(v.DepartmentId)
|
|
fmt.Printf("%v------->%v------->%v\n", departmentId, sunDepartId, workShopId)
|
|
if departmentId != 0 && sunDepartId != 0 && workShopId != 0 {
|
|
if departmentId != workShopId && sunDepartId != workShopId && departmentId != sunDepartId {
|
|
orgPostInfo.Name = fmt.Sprintf("%v/%v/%v/%v", getOrgCont(departmentId), getOrgCont(sunDepartId), getOrgCont(workShopId), postInfo.Name)
|
|
} else if departmentId != workShopId && sunDepartId != workShopId && departmentId == sunDepartId {
|
|
orgPostInfo.Name = fmt.Sprintf("%v/%v/%v", getOrgCont(departmentId), getOrgCont(sunDepartId), postInfo.Name)
|
|
} else {
|
|
orgPostInfo.Name = fmt.Sprintf("%v/%v", getOrgCont(departmentId), postInfo.Name)
|
|
}
|
|
} else if departmentId != 0 && sunDepartId != 0 && workShopId == 0 {
|
|
if departmentId != sunDepartId {
|
|
orgPostInfo.Name = fmt.Sprintf("%v/%v/%v", getOrgCont(departmentId), getOrgCont(sunDepartId), postInfo.Name)
|
|
} else {
|
|
orgPostInfo.Name = fmt.Sprintf("%v/%v", getOrgCont(departmentId), postInfo.Name)
|
|
}
|
|
} else {
|
|
orgPostInfo.Name = fmt.Sprintf("%v/%v", getOrgCont(departmentId), postInfo.Name)
|
|
}
|
|
orgPostInfo.KeyList, orgPostInfo.Child = GetReportAndAllDepartMan(postTargetCont.Id, 0, 0, 0, v.PostId, departmentId, 2, 1)
|
|
sendCont.OrgAndPostList = append(sendCont.OrgAndPostList, orgPostInfo)
|
|
|
|
}
|
|
|
|
publicmethod.Result(0, sendCont, c)
|
|
}
|
|
|
|
//获取提报人及本部门所有人
|
|
/*
|
|
#targetId 指标
|
|
#tableId 栏目
|
|
#detailsId 细则
|
|
#departId 行政组织
|
|
#postId 岗位
|
|
#mainDepart 主部门
|
|
#types 类型(1:公司级;2:部门级)
|
|
#levels 1:指标;2:子目标;3:细则
|
|
*/
|
|
func GetReportAndAllDepartMan(targetId, tableId, detailsId, departId, postId, mainDepart int64, types, levels int) (repostKey []string, departMan *[]OrgPostCont) {
|
|
gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("`man_key`").Where("`state` = 1 AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?", targetId, tableId, detailsId)
|
|
if departId != 0 {
|
|
gormDb = gormDb.Where("department_id = ?", departId)
|
|
}
|
|
if postId != 0 {
|
|
gormDb = gormDb.Where("post_id = ?", postId)
|
|
}
|
|
err := gormDb.Find(&repostKey).Error
|
|
if err != nil {
|
|
}
|
|
var allOrgId []int64
|
|
allOrgId = publicmethod.GetDepartmentSun(mainDepart, allOrgId)
|
|
if publicmethod.IsInTrue[int64](mainDepart, allOrgId) == false {
|
|
allOrgId = append(allOrgId, mainDepart)
|
|
}
|
|
var manContList []modelshr.PersonArchives
|
|
err = overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`number`,`name`,`key`").Where("`emp_type` BETWEEN 1 AND 10 AND `admin_org` IN ?", allOrgId).Find(&manContList).Error
|
|
if err == nil {
|
|
var allPeople []OrgPostCont
|
|
for _, v := range manContList {
|
|
var manCont OrgPostCont
|
|
manCont.Id = strconv.FormatInt(v.Key, 10)
|
|
manCont.Number = v.Number
|
|
manCont.Name = v.Name
|
|
allPeople = append(allPeople, manCont)
|
|
}
|
|
departMan = &allPeople
|
|
}
|
|
// fmt.Printf("allOrgId------------------->%v\n", manContList)
|
|
return
|
|
}
|
|
|
|
// 获取行政组织信息
|
|
func getOrgCont(id int64) (orgCont string) {
|
|
var orgInfo modelshr.AdministrativeOrganization
|
|
orgInfo.GetCont(map[string]interface{}{"`id`": id})
|
|
orgCont = orgInfo.Name
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-20 16:29:27
|
|
@ 功能: 根据指标获取岗位指标栏目
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) TableBasePostTarget(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}, "`id`", "`title`")
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
|
|
// var tableId []int64
|
|
// var detCont modelskpi.PostSonTarget
|
|
// err = overall.CONSTANT_DB_KPI..Table(fmt.Sprintf("%s dt", detCont.TableName())).Distinct("dt.`id`")
|
|
|
|
var postTableContList []modelskpi.PostSonTarget
|
|
err = overall.CONSTANT_DB_KPI.Where("`state` = 1 AND `parent_id` = ?", receivedValue.Id).Find(&postTableContList).Error
|
|
if err != nil {
|
|
publicmethod.Result(107, err, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, postTableContList, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-21 13:36:36
|
|
@ 功能: 根据指标添加细则列表
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) AddDetailsList(c *gin.Context) {
|
|
var receivedValue AddPostDetails
|
|
c.ShouldBindJSON(&receivedValue)
|
|
if receivedValue.TargetId == "" {
|
|
publicmethod.Result(101, receivedValue, c)
|
|
return
|
|
}
|
|
if receivedValue.TableName == "" {
|
|
publicmethod.Result(1, receivedValue, c, "未知栏目!请选择或输入栏目!")
|
|
return
|
|
}
|
|
iswrite := true
|
|
if len(receivedValue.DetailsList) < 1 {
|
|
publicmethod.Result(1, receivedValue, c, "至少要有一条细则!")
|
|
return
|
|
} else {
|
|
for _, v := range receivedValue.DetailsList {
|
|
if v.Title == "" {
|
|
iswrite = false
|
|
break
|
|
}
|
|
switch v.PunishType {
|
|
case 2:
|
|
if v.CashStandard == "" {
|
|
iswrite = false
|
|
break
|
|
} else {
|
|
testInt := strings.Split(v.CashStandard, "-")
|
|
testLen := len(testInt)
|
|
_, oenErr := strconv.ParseFloat(testInt[0], 10)
|
|
if oenErr != nil {
|
|
iswrite = false
|
|
break
|
|
} else {
|
|
if testLen > 1 {
|
|
_, twoErr := strconv.ParseFloat(testInt[testLen-1], 10)
|
|
if twoErr != nil {
|
|
iswrite = false
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
case 3:
|
|
if v.CashStandard == "" || v.Standard == "" {
|
|
iswrite = false
|
|
break
|
|
} else {
|
|
testInt := strings.Split(v.CashStandard, "-")
|
|
testLen := len(testInt)
|
|
_, oenErr := strconv.ParseFloat(testInt[0], 10)
|
|
if oenErr != nil {
|
|
iswrite = false
|
|
break
|
|
} else {
|
|
if testLen > 1 {
|
|
_, twoErr := strconv.ParseFloat(testInt[testLen-1], 10)
|
|
if twoErr != nil {
|
|
iswrite = false
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
testIntTwo := strings.Split(v.Standard, "-")
|
|
testLenTwo := len(testIntTwo)
|
|
_, oenErrTwo := strconv.ParseFloat(testIntTwo[0], 10)
|
|
if oenErrTwo != nil {
|
|
iswrite = false
|
|
break
|
|
} else {
|
|
if testLenTwo > 1 {
|
|
_, twoErr := strconv.ParseFloat(testIntTwo[testLenTwo-1], 10)
|
|
if twoErr != nil {
|
|
iswrite = false
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
default:
|
|
if v.Standard == "" {
|
|
iswrite = false
|
|
break
|
|
} else {
|
|
testInt := strings.Split(v.Standard, "-")
|
|
testLen := len(testInt)
|
|
_, oenErr := strconv.ParseFloat(testInt[0], 10)
|
|
if oenErr != nil {
|
|
iswrite = false
|
|
break
|
|
} else {
|
|
if testLen > 1 {
|
|
_, twoErr := strconv.ParseFloat(testInt[testLen-1], 10)
|
|
if twoErr != nil {
|
|
iswrite = false
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
if len(v.Inspemethod) < 1 {
|
|
iswrite = false
|
|
break
|
|
}
|
|
}
|
|
}
|
|
if !iswrite {
|
|
publicmethod.Result(1, receivedValue, c, "至少有一条细则内容填写不规范!请检查!")
|
|
return
|
|
}
|
|
var targetCont modelskpi.PostTarget
|
|
err := targetCont.GetCont(map[string]interface{}{"`id`": receivedValue.TargetId})
|
|
if err != nil {
|
|
publicmethod.Result(1, receivedValue, c, "指标不存在!不允许添加细则内容!")
|
|
return
|
|
}
|
|
orgList, postList, manList, orgPost, orgPostMan := GetTargetBaseDepartMan(targetCont.Id)
|
|
tableId, err := EditPostTableCont(targetCont.Id, receivedValue.TableName)
|
|
if err != nil {
|
|
publicmethod.Result(1, receivedValue, c, "没有栏目信息!栏目添加失败!请重新提交!")
|
|
return
|
|
}
|
|
var tableDepartList []string
|
|
var tablePostList []string
|
|
var tableDepartPost []OrgAndPostCont
|
|
var tableDepartPostMan []OrgAndPostManCont
|
|
//处理岗位细则内容
|
|
for _, v := range receivedValue.DetailsList {
|
|
|
|
var targetDetailsInfo modelskpi.PostTargetDetails
|
|
targetDetailsInfo.Title = v.Title //指标细则"`
|
|
targetDetailsInfo.Content = v.Remarks //指标说明"`
|
|
targetDetailsInfo.ParentId = targetCont.Id //归属指标栏目"`
|
|
targetDetailsInfo.ParentIdSun = tableId //归属指标子栏目"`
|
|
targetDetailsInfo.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
targetDetailsInfo.AddTime = time.Now().Unix() //制定时间"`
|
|
targetDetailsInfo.MinScore, targetDetailsInfo.MaxScore = departmentpc.SplitCriteria(v.Standard) //最小分*100保存"` && 最大分*100保存"`
|
|
targetDetailsInfo.Company = v.Unit //单位"`
|
|
targetDetailsInfo.AddReduce = v.Types //1:减少;2:增加;3:无属性,现场确认加或减"`
|
|
targetDetailsInfo.CensorType = strings.Join(v.Inspemethod, ",") //检查方式"`
|
|
targetDetailsInfo.CensorCont = v.Evidence //检查依据"`
|
|
targetDetailsInfo.CensorRate = v.Frequency //检查频次"`
|
|
targetDetailsInfo.Cycles = v.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"`
|
|
targetDetailsInfo.CycleAttres = 1 //辅助计数"`
|
|
if len(v.PostandExport) > 0 {
|
|
orgList, postList, manList, orgPost, orgPostMan = HandleOrgOfPostReportRelation(v.PostandExport)
|
|
// orgListJson, _ := json.Marshal(orgList)
|
|
// postListJson, _ := json.Marshal(postList)
|
|
// manListJson, _ := json.Marshal(manList)
|
|
// orgPostJson, _ := json.Marshal(orgPost)
|
|
// orgPostManJson, _ := json.Marshal(orgPostMan)
|
|
// fmt.Printf("明细表关联关系--->%v--->%v--->%v--->%v--->%v\n", string(orgListJson), string(postListJson), string(manListJson), string(orgPostJson), string(orgPostManJson))
|
|
}
|
|
targetDetailsInfo.Paretment = strings.Join(orgList, ",") //接受考核的部门"`
|
|
targetDetailsInfo.ParetmentPost = strings.Join(postList, ",") //接受考核的部门岗位"`
|
|
targetDetailsInfo.Reportary = strings.Join(manList, ",") //提报人"`
|
|
targetDetailsInfo.Punishmode = v.PunishType //处罚方式 1:扣分;2:现金处罚;3:扣分加现金"`
|
|
targetDetailsInfo.Minmoney, targetDetailsInfo.Maxmoney = departmentpc.SplitCriteria(v.CashStandard) //最高罚款"`&& 最低罚款"`
|
|
addErr := overall.CONSTANT_DB_KPI.Create(&targetDetailsInfo).Error //添加指标
|
|
if addErr == nil {
|
|
syncSeting.Add(1)
|
|
go PostDetailsBaseOrgPost(targetCont.Dimension, targetCont.Id, tableId, targetDetailsInfo.Id, targetCont.Type, 3, 2, orgPost)
|
|
syncSeting.Add(1)
|
|
go PostDetailsBaseOrgPostMan(targetCont.Dimension, targetCont.Id, tableId, targetDetailsInfo.Id, targetCont.Type, 3, 2, orgPostMan)
|
|
}
|
|
|
|
//处理指标关联数据
|
|
for _, ov := range orgList {
|
|
if publicmethod.IsInTrue[string](ov, tableDepartList) == false {
|
|
tableDepartList = append(tableDepartList, ov)
|
|
}
|
|
}
|
|
for _, pv := range postList {
|
|
if publicmethod.IsInTrue[string](pv, tablePostList) == false {
|
|
tablePostList = append(tablePostList, pv)
|
|
}
|
|
}
|
|
for _, opv := range orgPost {
|
|
if JudgeDeparPost(opv, tableDepartPost) == false {
|
|
tableDepartPost = append(tableDepartPost, opv)
|
|
}
|
|
}
|
|
for _, opvm := range orgPostMan {
|
|
if JudgeDeparPostMan(opvm, tableDepartPostMan) == false {
|
|
tableDepartPostMan = append(tableDepartPostMan, opvm)
|
|
}
|
|
}
|
|
}
|
|
|
|
// one, _ := json.Marshal(tableDepartList)
|
|
// two, _ := json.Marshal(tablePostList)
|
|
// three, _ := json.Marshal(tableDepartPost)
|
|
// four, _ := json.Marshal(tableDepartPostMan)
|
|
// fmt.Printf("栏目明细表关联关系--->%v--->%v--->%v--->%v\n", string(one), string(two), string(three), string(four))
|
|
editTabelInfo := publicmethod.MapOut[string]()
|
|
tableDepartStr := strings.Join(tableDepartList, ",")
|
|
editTabelInfo["`depart`"] = tableDepartStr
|
|
tablePostStr := strings.Join(tablePostList, ",")
|
|
editTabelInfo["`depart_post`"] = tablePostStr
|
|
editTabelInfo["`time`"] = time.Now().Unix()
|
|
var editTableCont modelskpi.PostSonTarget
|
|
editTableCont.EiteCont(map[string]interface{}{"`id`": tableId}, editTabelInfo)
|
|
|
|
syncSeting.Add(1)
|
|
go PostDetailsBaseOrgPost(targetCont.Dimension, targetCont.Id, tableId, 0, targetCont.Type, 2, 2, tableDepartPost)
|
|
syncSeting.Add(1)
|
|
go PostDetailsBaseOrgPostMan(targetCont.Dimension, targetCont.Id, tableId, 0, targetCont.Type, 2, 2, tableDepartPostMan)
|
|
syncSeting.Wait()
|
|
publicmethod.Result(0, receivedValue, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-22 09:41:43
|
|
@ 功能: 岗位指标细则关联行政组织及岗位提报人
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#dimensionId 维度
|
|
#targetId 指标
|
|
#tableId 栏目
|
|
#bylawsId 细则
|
|
#types 类型(1:指标;2:子目标;3:细则)
|
|
#class 属性1:定性考核;2:定量考核
|
|
#level 级别(1:部门级;2:岗位级)
|
|
#orgPostManList 行政组织与岗位、提报人组合
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func PostDetailsBaseOrgPostMan(dimensionId, targetId, tableId, bylawsId int64, class, types, level int, orgPostManList []OrgAndPostManCont) {
|
|
defer syncSeting.Done()
|
|
if types == 0 {
|
|
types = 3
|
|
}
|
|
if class == 0 {
|
|
class = 1
|
|
}
|
|
if level == 0 {
|
|
level = 2
|
|
}
|
|
var orgManList []ReportAry
|
|
for _, opmv := range orgPostManList {
|
|
if len(orgManList) < 1 {
|
|
var orgMAnCont ReportAry
|
|
orgMAnCont.OrgId = opmv.OrgId
|
|
orgMAnCont.PostId = opmv.PostId
|
|
orgMAnCont.ManKey = append(orgMAnCont.ManKey, opmv.ManKey)
|
|
orgManList = append(orgManList, orgMAnCont)
|
|
} else {
|
|
isCunz := true
|
|
for i, omlv := range orgManList {
|
|
if omlv.OrgId == opmv.OrgId && omlv.PostId == opmv.PostId {
|
|
if publicmethod.IsInTrue[int64](opmv.ManKey, orgManList[i].ManKey) == false {
|
|
orgManList[i].ManKey = append(orgManList[i].ManKey, opmv.ManKey)
|
|
}
|
|
isCunz = false
|
|
}
|
|
}
|
|
if isCunz {
|
|
var orgMAnCont ReportAry
|
|
orgMAnCont.OrgId = opmv.OrgId
|
|
orgMAnCont.PostId = opmv.PostId
|
|
orgMAnCont.ManKey = append(orgMAnCont.ManKey, opmv.ManKey)
|
|
orgManList = append(orgManList, orgMAnCont)
|
|
}
|
|
}
|
|
|
|
}
|
|
// orgManListJson, _ := json.Marshal(orgManList)
|
|
// fmt.Printf("岗位指标细则关联行政组织及岗位提报人------>%v\n", string(orgManListJson))
|
|
|
|
//将不属于该指标细则的部门岗位提报人至禁用
|
|
otherSaveData := publicmethod.MapOut[string]()
|
|
otherSaveData["`state`"] = 2
|
|
otherSaveData["`time`"] = time.Now().Unix()
|
|
for _, val := range orgManList {
|
|
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where("`level` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ? AND `type` = ? AND `department_id` = ? AND `post_id` = ?", types, targetId, targetId, bylawsId, level, val.OrgId, val.PostId).Not(map[string]interface{}{"man_key": val.ManKey}).Updates(&otherSaveData)
|
|
}
|
|
//处理指标细则提报人问题
|
|
for _, v := range orgPostManList {
|
|
//获取评价人部门
|
|
var manCont modelshr.PersonArchives
|
|
manCont.GetCont(map[string]interface{}{"`key`": v.ManKey}, "`maindeparment`")
|
|
var tarDepartCont modelskpi.TargetReport
|
|
saveErr := tarDepartCont.GetCont(map[string]interface{}{"`level`": types, "`type`": level, "`target_id`": targetId, "`target_sun_id`": tableId, "`target_bylaws`": bylawsId, "`department_id`": v.OrgId, "`post_id`": v.PostId, "`man_key`": v.ManKey}, "`id`", "`state`")
|
|
if saveErr == nil {
|
|
if tarDepartCont.State != 1 {
|
|
tarDepartCont.EiteCont(map[string]interface{}{"`id`": tarDepartCont.Id}, map[string]interface{}{"`state`": 1, "`man_department`": manCont.MainDeparment, "`time`": time.Now().Unix()})
|
|
}
|
|
} else {
|
|
var tarReportContAdd modelskpi.TargetReport
|
|
tarReportContAdd.Dimension = dimensionId //维度
|
|
tarReportContAdd.TargetId = targetId //指标ID"`
|
|
tarReportContAdd.TargetSunId = targetId //子目标"`
|
|
tarReportContAdd.TargetBylaws = bylawsId //指标细则"`
|
|
tarReportContAdd.DepartmentId = v.OrgId //部门ID"`
|
|
tarReportContAdd.PostId = v.PostId //岗位ID"`
|
|
tarReportContAdd.Type = level //类型(1:公司级;2:部门级)"`
|
|
tarReportContAdd.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
tarReportContAdd.ReportPerson = v.ManKey //上报人"`
|
|
tarReportContAdd.ManDepartment = manCont.MainDeparment //提报人所在部门"`
|
|
tarReportContAdd.Time = time.Now().Unix() //写入时间"`
|
|
tarReportContAdd.Class = class //1:定性考核;2:定量考核"`
|
|
tarReportContAdd.Level = types //1:指标;2:子目标;3:细则
|
|
overall.CONSTANT_DB_KPI.Create(&tarReportContAdd)
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-22 08:51:56
|
|
@ 功能: 岗位指标细则关联行政组织及岗位
|
|
@ 参数
|
|
|
|
#dimensionId 维度
|
|
#targetId 指标
|
|
#tableId 栏目
|
|
#bylawsId 细则
|
|
#types 类型(1:指标;2:子目标;3:细则)
|
|
#class 属性1:定性考核;2:定量考核
|
|
#level 级别(1:部门级;2:岗位级)
|
|
#orgPostList 行政组织与岗位组合
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func PostDetailsBaseOrgPost(dimensionId, targetId, tableId, bylawsId int64, class, types, level int, orgPostList []OrgAndPostCont) {
|
|
defer syncSeting.Done()
|
|
if types == 0 {
|
|
types = 3
|
|
}
|
|
if class == 0 {
|
|
class = 1
|
|
}
|
|
if level == 0 {
|
|
level = 2
|
|
}
|
|
orgPostMap := map[int64][]int64{}
|
|
for _, ov := range orgPostList {
|
|
orgPostMap[ov.OrgId] = append(orgPostMap[ov.OrgId], ov.PostId)
|
|
}
|
|
//将不属于该指标细则的部门至禁用
|
|
otherSaveData := publicmethod.MapOut[string]()
|
|
otherSaveData["`state`"] = 2
|
|
otherSaveData["`time`"] = time.Now().Unix()
|
|
for key, val := range orgPostMap {
|
|
overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Where("`level` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ? AND `type` = ? AND `department_id` = ?", level, targetId, targetId, bylawsId, types, key).Not(map[string]interface{}{"post_id": val}).Updates(&otherSaveData)
|
|
}
|
|
//处理新的关联数据
|
|
for _, v := range orgPostList {
|
|
var tarDepartCont modelskpi.TargetDepartment
|
|
saveErr := tarDepartCont.GetCont(map[string]interface{}{"`level`": level, "`type`": types, "`target_id`": targetId, "`target_sun_id`": tableId, "`target_bylaws`": bylawsId, "`department_id`": v.OrgId, "`post_id`": v.PostId}, "`id`", "`state`")
|
|
if saveErr == nil {
|
|
if tarDepartCont.State != 1 {
|
|
tarDepartCont.EiteCont(map[string]interface{}{"`id`": tarDepartCont.Id}, map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()})
|
|
}
|
|
} else {
|
|
var addTarDepartCont modelskpi.TargetDepartment
|
|
addTarDepartCont.Dimension = dimensionId
|
|
addTarDepartCont.TargetId = targetId //指标ID"`
|
|
addTarDepartCont.TargetSunId = tableId //子目标"`
|
|
addTarDepartCont.TargetBylaws = bylawsId //指标细则"`
|
|
addTarDepartCont.Type = types //类型(1:指标;2:子目标;3:细则)"`
|
|
addTarDepartCont.DepartmentId = v.OrgId //部门ID"`
|
|
addTarDepartCont.PostId = v.PostId //岗位ID"`
|
|
addTarDepartCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
addTarDepartCont.Time = time.Now().Unix() //写入时间"`
|
|
addTarDepartCont.Class = class //1:定性考核;2:定量考核"`
|
|
addTarDepartCont.Level = level //级别(1:部门级;2:岗位级)"`
|
|
overall.CONSTANT_DB_KPI.Create(&addTarDepartCont)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 判断岗位是否已经存在
|
|
func JudgeDeparPostMan(orgPostMan OrgAndPostManCont, tableDepartPost []OrgAndPostManCont) (isTrue bool) {
|
|
isTrue = false
|
|
for _, v := range tableDepartPost {
|
|
if orgPostMan.OrgId == v.OrgId && orgPostMan.PostId == v.PostId && orgPostMan.ManKey == v.ManKey {
|
|
isTrue = true
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
func JudgeDeparPost(orgPost OrgAndPostCont, tableDepartPost []OrgAndPostCont) (isTrue bool) {
|
|
isTrue = false
|
|
for _, v := range tableDepartPost {
|
|
if orgPost.OrgId == v.OrgId && orgPost.PostId == v.PostId {
|
|
isTrue = true
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取岗位指标关联得岗位及提报人
|
|
/*
|
|
#targetId 指标
|
|
*/
|
|
func GetTargetBaseDepartMan(targetId int64) (orgList, postList, manList []string, orgPost []OrgAndPostCont, orgPostMan []OrgAndPostManCont) {
|
|
//获取指标关联行政组织及岗位
|
|
var targetDepartList []modelskpi.TargetDepartment
|
|
err := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Select("`department_id`,`post_id`").Where("`state` = 1 AND `type` = 1 AND `level` = 2 AND `target_sun_id` = 0 AND `target_bylaws` = 0 AND `target_id` = ?", targetId).Find(&targetDepartList).Error
|
|
if err != nil {
|
|
for _, v := range targetDepartList {
|
|
var orgPostCont OrgAndPostCont
|
|
orgPostCont.OrgId = v.DepartmentId
|
|
orgPostCont.PostId = v.PostId
|
|
orgPost = append(orgPost, orgPostCont)
|
|
orgStr := strconv.FormatInt(v.DepartmentId, 10)
|
|
if publicmethod.IsInTrue[string](orgStr, orgList) == false {
|
|
orgList = append(orgList, orgStr)
|
|
}
|
|
postStr := strconv.FormatInt(v.PostId, 10)
|
|
if publicmethod.IsInTrue[string](postStr, postList) == false {
|
|
postList = append(postList, postStr)
|
|
}
|
|
}
|
|
}
|
|
//获取指标关联岗位提报人
|
|
var targetReportList []modelskpi.TargetReport
|
|
err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Select("`department_id`,`post_id`,`man_key`").Where("`state` = 1 AND `type_level` = 1 AND `type` = 2 AND `target_sun_id` = 0 AND `target_bylaws` = 0 AND `target_id` = ?", targetId).Find(&targetReportList).Error
|
|
if err != nil {
|
|
for _, v := range targetReportList {
|
|
var orgPostManCont OrgAndPostManCont
|
|
orgPostManCont.OrgId = v.DepartmentId
|
|
orgPostManCont.PostId = v.PostId
|
|
orgPostManCont.ManKey = v.ReportPerson
|
|
orgPostMan = append(orgPostMan, orgPostManCont)
|
|
manStr := strconv.FormatInt(v.ReportPerson, 10)
|
|
if publicmethod.IsInTrue[string](manStr, manList) == false {
|
|
manList = append(manList, manStr)
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 处理指标细则行政组织与岗位及提报人关系
|
|
func HandleOrgOfPostReportRelation(orgPostManList []OrgPostCont) (orgList, postList, manList []string, orgPost []OrgAndPostCont, orgPostMan []OrgAndPostManCont) {
|
|
if len(orgPostManList) < 1 {
|
|
return
|
|
}
|
|
for _, v := range orgPostManList {
|
|
if publicmethod.IsInTrue[string](v.Id, postList) == false {
|
|
var orgPostCont OrgAndPostCont //该细则关联得岗位关系
|
|
postList = append(postList, v.Id)
|
|
var postCont modelshr.Position
|
|
postCont.GetCont(map[string]interface{}{"`id`": v.Id}, "`id`", "administrative_organization")
|
|
|
|
orgPostCont.PostId = postCont.Id
|
|
orgPostCont.OrgId = postCont.AdministrativeOrganization
|
|
|
|
orgStr := strconv.FormatInt(postCont.AdministrativeOrganization, 10)
|
|
if publicmethod.IsInTrue[string](orgStr, orgList) == false {
|
|
orgList = append(orgList, orgStr)
|
|
}
|
|
if len(v.KeyList) > 0 {
|
|
for _, kv := range v.KeyList {
|
|
if publicmethod.IsInTrue[string](kv, manList) == false {
|
|
manList = append(manList, kv)
|
|
}
|
|
var orgPostManCont OrgAndPostManCont
|
|
orgPostManCont.PostId = postCont.Id
|
|
orgPostManCont.OrgId = postCont.AdministrativeOrganization
|
|
kvInt, _ := strconv.ParseInt(kv, 10, 64)
|
|
orgPostManCont.ManKey = kvInt
|
|
orgPostMan = append(orgPostMan, orgPostManCont)
|
|
}
|
|
|
|
}
|
|
orgPost = append(orgPost, orgPostCont)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-02-21 15:12:46
|
|
@ 功能: 处理岗位指标数据
|
|
@ 参数
|
|
|
|
#targetId 指标ID
|
|
#title 栏目名称
|
|
|
|
@ 返回值
|
|
|
|
#tableId 栏目Id
|
|
#err 处理状态
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func EditPostTableCont(targetId int64, title string) (tableId int64, err error) {
|
|
var tableCont modelskpi.PostSonTarget
|
|
err = tableCont.GetCont(map[string]interface{}{"`title`": title, "`parent_id`": targetId})
|
|
if err != nil {
|
|
var sunTargetCont modelskpi.PostSonTarget
|
|
sunTargetCont.Title = title //标题"`
|
|
sunTargetCont.ParentId = targetId //归属指标"`
|
|
sunTargetCont.Time = time.Now().Unix() //创建时间"`
|
|
sunTargetCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
err = overall.CONSTANT_DB_KPI.Create(&sunTargetCont).Error
|
|
tableId = sunTargetCont.Id
|
|
} else {
|
|
tableId = tableCont.Id
|
|
editCont := publicmethod.MapOut[string]()
|
|
if tableCont.State != 1 {
|
|
editCont["state"] = 1
|
|
}
|
|
if len(editCont) > 0 {
|
|
editCont["time"] = time.Now().Unix()
|
|
var editInfo modelskpi.PostSonTarget
|
|
err = editInfo.EiteCont(map[string]interface{}{"`id`": tableCont.Id}, editCont)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|