@ -1,6 +1,7 @@
package postpc
import (
"fmt"
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
@ -415,7 +416,7 @@ func (a *ApiMethod) GetTargetAboutDepartToPostMan(c *gin.Context) {
publicmethod . Result ( 0 , outData , c )
}
// 添加岗位细则
// 根据指标 添加岗位细则
func ( a * ApiMethod ) AddPostTargetCont ( c * gin . Context ) {
var receivedValue addPostContTarget
c . ShouldBindJSON ( & receivedValue )
@ -460,6 +461,11 @@ func (a *ApiMethod) AddPostTargetCont(c *gin.Context) {
}
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`" )
@ -483,7 +489,165 @@ func (a *ApiMethod) AddPostTargetCont(c *gin.Context) {
return
}
//考核细则写入
// for _, lv := range receivedValue.List {
// }
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 ( )
}