@ -134,6 +134,35 @@ func (a *ApiMethod) Shiyan(c *gin.Context) {
}
fmt . Printf ( "jieshu---->%v\n" , len ( dimeTargetList ) )
//校正维度
// xiaoZehgnWeiDu()
}
// 校正关联维度
func xiaoZehgnWeiDu ( ) {
//校正部门维度
var zhiBiaoId [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`target_id`" ) . Find ( & zhiBiaoId )
if len ( zhiBiaoId ) > 0 {
for _ , dv := range zhiBiaoId {
var zhiBiaoCont modelskpi . EvaluationTarget
zhiBiaoCont . GetCont ( map [ string ] interface { } { "`et_id`" : dv } , "`et_dimension`" )
var tarDepCont modelskpi . TargetDepartment
tarDepCont . EiteCont ( map [ string ] interface { } { "`target_id`" : dv } , map [ string ] interface { } { "`dimension_id`" : zhiBiaoCont . Dimension } )
}
}
//校正提交人维度
var zhiBiaoReportId [ ] int64
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`target_id`" ) . Find ( & zhiBiaoReportId )
if len ( zhiBiaoReportId ) > 0 {
for _ , rv := range zhiBiaoReportId {
var zhiBiaoRenCont modelskpi . EvaluationTarget
zhiBiaoRenCont . GetCont ( map [ string ] interface { } { "`et_id`" : rv } , "`et_dimension`" )
var tarDepRenCont modelskpi . TargetReport
tarDepRenCont . EiteCont ( map [ string ] interface { } { "`target_id`" : rv } , map [ string ] interface { } { "`dimension_id`" : zhiBiaoRenCont . Dimension } )
}
}
}
// 校正部门定性考核关联关系
@ -489,9 +518,9 @@ func addDetaInfo(targetId, sunTargetId int64, qualEvalCont QualEvalSunList, depa
err = overall . CONSTANT_DB_KPI . Create ( & detaildeTarInfo ) . Error
if err == nil {
syncSeting . Add ( 1 )
go handleDetarildTargetDepart ( targetId , sunTargetId , detaildeTarInfo . Id , departmentAry , 1 )
go handleDetarildTargetDepart ( targetId , sunTargetId , detaildeTarInfo . Id , departmentAry , 1 , 1 )
syncSeting . Add ( 1 )
go handleDetarildTargetRepart ( targetId , sunTargetId , detaildeTarInfo . Id , operatorList , 1 )
go handleDetarildTargetRepart ( targetId , sunTargetId , detaildeTarInfo . Id , operatorList , 1 , 1 )
syncSeting . Wait ( )
}
return nil
@ -582,9 +611,9 @@ func editDetaAdd(targetId, sunTargetId int64, qualEvalCont QualEvalSunList, deta
err = editCont . EiteCont ( map [ string ] interface { } { "`dt_id`" : detailInfof . Id } , saveData )
}
syncSeting . Add ( 1 )
go handleDetarildTargetDepart ( targetId , sunTargetId , detailInfof . Id , departmentAry , 1 )
go handleDetarildTargetDepart ( targetId , sunTargetId , detailInfof . Id , departmentAry , 1 , 1 )
syncSeting . Add ( 1 )
go handleDetarildTargetRepart ( targetId , sunTargetId , detailInfof . Id , qualEvalCont . Operator , 1 )
go handleDetarildTargetRepart ( targetId , sunTargetId , detailInfof . Id , qualEvalCont . Operator , 1 , 1 )
syncSeting . Wait ( )
return nil
}
@ -596,9 +625,13 @@ func editDetaAdd(targetId, sunTargetId int64, qualEvalCont QualEvalSunList, deta
@ bylawsId 指标细则
@ department 接受考核部门
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func handleDetarildTargetDepart ( targetId , targetSunId , bylawsId int64 , department [ ] string , class int ) {
func handleDetarildTargetDepart ( targetId , targetSunId , bylawsId int64 , department [ ] string , class , nature int ) {
defer syncSeting . Done ( )
if nature == 0 {
nature = 1
}
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
@ -628,7 +661,7 @@ func handleDetarildTargetDepart(targetId, targetSunId, bylawsId int64, departmen
tarDepartCont . PostId = 0 //岗位ID"`
tarDepartCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
tarDepartCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarDepartCont . Class = 1 //1:定性考核;2:定量考核"`
tarDepartCont . Class = nature //1:定性考核;2:定量考核"`
tarDepartCont . Level = class //级别(1:部门级;2:岗位级)"`
overall . CONSTANT_DB_KPI . Create ( & tarDepartCont )
}
@ -642,9 +675,13 @@ func handleDetarildTargetDepart(targetId, targetSunId, bylawsId int64, departmen
@ bylawsId 指标细则
@ repart 考核提交人
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func handleDetarildTargetRepart ( targetId , targetSunId , bylawsId int64 , repart [ ] string , class int ) {
func handleDetarildTargetRepart ( targetId , targetSunId , bylawsId int64 , repart [ ] string , class , nature int ) {
defer syncSeting . Done ( )
if nature == 0 {
nature = 1
}
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
@ -681,7 +718,7 @@ func handleDetarildTargetRepart(targetId, targetSunId, bylawsId int64, repart []
tarReportCont . ReportPerson = reportId //上报人"`
tarReportCont . ManDepartment = manCont . MainDeparment //提报人所在部门"`
tarReportCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarReportCont . Class = 1 //1:定性考核;2:定量考核"`
tarReportCont . Class = nature //1:定性考核;2:定量考核"`
tarReportCont . Level = xiZe //1:指标;2:子目标;3:细则
overall . CONSTANT_DB_KPI . Create ( & tarReportCont )
}
@ -1021,11 +1058,11 @@ func (a *ApiMethod) EditSonTargetDepartmentReport(c *gin.Context) {
for _ , v := range detaildId {
if len ( departmentAry ) > 0 {
syncSeting . Add ( 1 )
go handleDetarildTargetDepart ( sonTargetCont . ParentId , sonTargetCont . Id , v , departmentAry , 1 )
go handleDetarildTargetDepart ( sonTargetCont . ParentId , sonTargetCont . Id , v , departmentAry , 1 , 1 )
}
if len ( operatorList ) > 0 {
syncSeting . Add ( 1 )
go handleDetarildTargetRepart ( sonTargetCont . ParentId , sonTargetCont . Id , v , operatorList , 1 )
go handleDetarildTargetRepart ( sonTargetCont . ParentId , sonTargetCont . Id , v , operatorList , 1 , 1 )
}
syncSeting . Wait ( )
}
@ -1515,20 +1552,24 @@ func (a *ApiMethod) AddDepartmentTarget(c *gin.Context) {
if len ( receivedValue . AcceptDepartmentId ) > 0 {
syncSeting . Add ( 1 )
go handleDetarildTargetDepart ( saveData . Id , 0 , 0 , receivedValue . AcceptDepartmentId , 1 )
go handleDetarildTargetDepart ( saveData . Id , 0 , 0 , receivedValue . AcceptDepartmentId , 1 , receivedValue . Nature )
}
if len ( receivedValue . Operator ) > 0 {
syncSeting . Add ( 1 )
go handleDetarildTargetRepart ( saveData . Id , 0 , 0 , receivedValue . Operator , 1 )
go handleDetarildTargetRepart ( saveData . Id , 0 , 0 , receivedValue . Operator , 1 , receivedValue . Nature )
}
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
// 获取关联部门
/ *
获取关联部门
@ where 查询条件
@ level 1 : 部门级 ; 2 : 岗位级
* /
func GetAboutDepartment ( where interface { } , level int ) ( departmentId [ ] int64 , departmentIdStr [ ] string , err error ) {
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`department_id`" ) . Where ( where ) . Find ( & departmentId ) . Error
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`department_id`" ) . Where ( where ) . Where ( "`level` = ?" , level ) . Find ( & departmentId ) . Error
if err == nil {
for _ , v := range departmentId {
departmentIdStr = append ( departmentIdStr , strconv . FormatInt ( v , 10 ) )
@ -1537,9 +1578,13 @@ func GetAboutDepartment(where interface{}, level int) (departmentId []int64, dep
return
}
// 获取关联提报人
/ *
获取关联提报人
@ where 查询条件
@ level 1 : 公司级 ; 2 : 部门级
* /
func GetAboutReport ( where interface { } , level int ) ( userKey [ ] int64 , userKeyStr [ ] string , err error ) {
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`man_key`" ) . Where ( where ) . Find ( & userKey ) . Error
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`man_key`" ) . Where ( where ) . Where ( "`type` = ?" , level ) . Find ( & userKey ) . Error
if err == nil {
for _ , v := range userKey {
userKeyStr = append ( userKeyStr , strconv . FormatInt ( v , 10 ) )
@ -1584,3 +1629,644 @@ func (a *ApiMethod) GetOneTergetInfo(c *gin.Context) {
outCont . VisibleRangeDepart = strings . Split ( targetCont . VisibleRange , "," ) //可见范围(分厂)
publicmethod . Result ( 0 , outCont , c )
}
// 编辑单一部门指标
func ( a * ApiMethod ) EditOneTarget ( c * gin . Context ) {
var receivedValue printOneTargetCont
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if receivedValue . Id == "" {
publicmethod . Result ( 101 , err , c , "请输入指标ID!!" )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "et_id" ] = receivedValue . Id
var targetCont modelskpi . EvaluationTarget
err = targetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if receivedValue . Name == "" {
publicmethod . Result ( 101 , err , c , "请输入指标名称!!" )
return
}
if receivedValue . Nature == 0 {
receivedValue . Nature = 1
}
if receivedValue . Share == 0 {
receivedValue . Share = 1
} else {
if receivedValue . Share > 1 {
if len ( receivedValue . AcceptDepartmentId ) < 1 {
publicmethod . Result ( 101 , err , c , "您选择了此指标为指定部门使用!但您未指定具体使用部门!请指定相关使用部门!" )
return
}
}
}
if receivedValue . Unit == "" {
publicmethod . Result ( 101 , err , c , "请输入计量单位!" )
return
}
if receivedValue . Cycles == 0 {
receivedValue . Cycles = 4
}
if receivedValue . CycleAttres == 0 {
receivedValue . CycleAttres = 1
}
if receivedValue . ScoringMethod == 0 {
receivedValue . ScoringMethod = 1
}
saveData := publicmethod . MapOut [ string ] ( )
if receivedValue . Name != targetCont . Title {
JudgeIsTrue := publicmethod . MapOut [ string ] ( )
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . EvaluationTarget { } ) . Select ( "et_title" ) . Where ( "`et_title` = ? AND `et_type` = ? AND `et_dimension` = ?" , receivedValue . Name , receivedValue . Nature , receivedValue . Dimension ) . First ( & JudgeIsTrue ) . Error
if err == nil {
publicmethod . Result ( 101 , err , c , "此考核指标已经存在!请不要重复添加!" )
return
} else {
saveData [ "et_title" ] = receivedValue . Name
}
}
if receivedValue . Share != targetCont . Share {
saveData [ "et_share" ] = receivedValue . Share
}
if receivedValue . Dimension != "" {
dimensionStr , _ := strconv . ParseInt ( receivedValue . Dimension , 10 , 64 )
if dimensionStr != targetCont . Dimension {
saveData [ "et_dimension" ] = dimensionStr
}
}
if receivedValue . Nature != targetCont . Type {
saveData [ "et_type" ] = receivedValue . Nature
}
if receivedValue . Unit != targetCont . Uniteing {
saveData [ "et_unit" ] = receivedValue . Nature
}
if receivedValue . Cycles != targetCont . Cycles {
saveData [ "et_cycle" ] = receivedValue . Cycles
}
if receivedValue . CycleAttres != targetCont . CycleAttres {
saveData [ "et_cycleattr" ] = receivedValue . CycleAttres
}
if receivedValue . ScoringMethod != targetCont . ScoringMethod {
saveData [ "et_scoring_method" ] = receivedValue . ScoringMethod
}
visiblerangegroup := strings . Join ( receivedValue . VisibleRangeGroup , "," )
if visiblerangegroup != targetCont . VisibleRangeGroup {
saveData [ "et_visible_group" ] = visiblerangegroup
}
visiblerange := strings . Join ( receivedValue . VisibleRangeDepart , "," )
if visiblerange != targetCont . VisibleRange {
saveData [ "et_visible_range" ] = visiblerange
}
departIsTreu := false
if len ( receivedValue . AcceptDepartmentId ) > 0 {
departWhere := publicmethod . MapOut [ string ] ( )
departWhere [ "`target_id`" ] = receivedValue . Id
departWhere [ "`state`" ] = 1
_ , departAry , _ := GetAboutDepartment ( departWhere , 1 )
departAryStr := strings . Join ( departAry , "," )
accDepart := strings . Join ( receivedValue . AcceptDepartmentId , "," )
if departAryStr != accDepart {
departIsTreu = true
saveData [ "et_relevant_departments" ] = accDepart
syncSeting . Add ( 1 )
go handleTargetDepart ( targetCont . Id , 0 , 0 , receivedValue . AcceptDepartmentId , 1 , targetCont . Type )
}
}
reportIsTrue := false
if len ( receivedValue . Operator ) > 0 {
reportWhere := publicmethod . MapOut [ string ] ( )
reportWhere [ "`target_id`" ] = receivedValue . Id
reportWhere [ "`state`" ] = 1
_ , report , _ := GetAboutReport ( reportWhere , 1 )
reportStr := strings . Join ( report , "," )
accDepart := strings . Join ( receivedValue . Operator , "," )
if reportStr != accDepart {
reportIsTrue = true
saveData [ "et_report" ] = accDepart
syncSeting . Add ( 1 )
go handleTargetRepart ( targetCont . Id , 0 , 0 , receivedValue . Operator , 1 , targetCont . Type )
}
}
/ *
获取关联部门
@ where 查询条件
@ level 1 : 部门级 ; 2 : 岗位级
func GetAboutDepartment ( where interface { } , level int ) ( departmentId [ ] int64 , departmentIdStr [ ] string , err error ) {
* /
if len ( saveData ) > 0 {
saveData [ "et_time" ] = time . Now ( ) . Unix ( )
err = targetCont . EiteCont ( where , saveData )
}
if err != nil {
publicmethod . Result ( 106 , err , c )
return
}
if reportIsTrue == true || departIsTreu == true {
syncSeting . Wait ( )
}
publicmethod . Result ( 0 , err , c )
}
/ *
处理指标细则关联部门
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ department 接受考核部门
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func handleTargetDepart ( targetId , targetSunId , bylawsId int64 , department [ ] string , class , nature int ) {
defer syncSeting . Done ( )
if nature == 0 {
nature = 1
}
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
where := publicmethod . MapOut [ string ] ( )
where [ "`level`" ] = class
if targetId != 0 {
where [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
where [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
where [ "`target_bylaws`" ] = bylawsId
}
if len ( department ) < 1 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( where ) . Updates ( & otherSaveData )
} else {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( where ) . Not ( map [ string ] interface { } { "department_id" : department } ) . Updates ( & otherSaveData )
for _ , v := range department {
var tarDepartCont modelskpi . TargetDepartment
trWhere := publicmethod . MapOut [ string ] ( )
trWhere [ "`department_id`" ] = v
trWhere [ "`level`" ] = class
if targetId != 0 {
trWhere [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
trWhere [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
trWhere [ "`target_bylaws`" ] = bylawsId
}
saveErr := tarDepartCont . GetCont ( trWhere , "`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 {
xiZe := 3
if targetId != 0 && targetSunId != 0 && bylawsId == 0 {
xiZe = 2
} else if targetId != 0 && targetSunId == 0 && bylawsId == 0 {
xiZe = 1
}
tarDepartCont . TargetId = targetId //指标ID"`
tarDepartCont . TargetSunId = targetSunId //子目标"`
tarDepartCont . TargetBylaws = bylawsId //指标细则"`
tarDepartCont . Type = xiZe //类型(1:指标;2:子目标;3:细则)"`
departId , _ := strconv . ParseInt ( v , 10 , 64 )
tarDepartCont . DepartmentId = departId //部门ID"`
tarDepartCont . PostId = 0 //岗位ID"`
tarDepartCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
tarDepartCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarDepartCont . Class = nature //1:定性考核;2:定量考核"`
tarDepartCont . Level = class //级别(1:部门级;2:岗位级)"`
overall . CONSTANT_DB_KPI . Create ( & tarDepartCont )
}
}
}
}
/ *
处理指标细则关联考核提交人
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ repart 考核提交人
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func handleTargetRepart ( targetId , targetSunId , bylawsId int64 , repart [ ] string , class , nature int ) {
defer syncSeting . Done ( )
if nature == 0 {
nature = 1
}
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
where := publicmethod . MapOut [ string ] ( )
where [ "`type`" ] = class
if targetId != 0 {
where [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
where [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
where [ "`target_bylaws`" ] = bylawsId
}
if len ( repart ) < 1 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Where ( where ) . Updates ( & otherSaveData )
} else {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Where ( where ) . Not ( map [ string ] interface { } { "man_key" : repart } ) . Updates ( & otherSaveData )
for _ , v := range repart {
//获取评价人部门
var manCont modelshr . PersonArchives
manCont . GetCont ( map [ string ] interface { } { "`key`" : v } , "`maindeparment`" )
var tarReportCont modelskpi . TargetReport
trWhere := publicmethod . MapOut [ string ] ( )
trWhere [ "`man_key`" ] = v
trWhere [ "`type`" ] = class
if targetId != 0 {
trWhere [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
trWhere [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
trWhere [ "`target_bylaws`" ] = bylawsId
}
saveErr := tarReportCont . GetCont ( trWhere , "`id`" , "`state`" )
if saveErr == nil {
if tarReportCont . State != 1 {
tarReportCont . EiteCont ( map [ string ] interface { } { "`id`" : tarReportCont . Id } , map [ string ] interface { } { "`state`" : 1 , "`man_department`" : manCont . MainDeparment , "`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
}
tarReportCont . TargetId = targetId //指标ID"`
tarReportCont . TargetSunId = targetSunId //子目标"`
tarReportCont . TargetBylaws = bylawsId //指标细则"`
tarReportCont . DepartmentId = 0 //部门ID"`
tarReportCont . PostId = 0 //岗位ID"`
tarReportCont . Type = class //类型(1:公司级;2:部门级)"`
tarReportCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
reportId , _ := strconv . ParseInt ( v , 10 , 64 )
tarReportCont . ReportPerson = reportId //上报人"`
tarReportCont . ManDepartment = manCont . MainDeparment //提报人所在部门"`
tarReportCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarReportCont . Class = nature //1:定性考核;2:定量考核"`
tarReportCont . Level = xiZe //1:指标;2:子目标;3:细则
overall . CONSTANT_DB_KPI . Create ( & tarReportCont )
}
}
}
}
// 指标关联岗位
func ( a * ApiMethod ) DeparmentTargetAboutPost ( c * gin . Context ) {
var receivedValue depTarAboutPost
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c , "请输入指标ID!!" )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "et_id" ] = receivedValue . Id
var targetCont modelskpi . EvaluationTarget
err := targetCont . GetCont ( where )
jsonCont , _ := json . Marshal ( targetCont )
fmt . Printf ( "targetCont--------->%v\n" , string ( jsonCont ) )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if len ( receivedValue . OrgList ) < 1 {
publicmethod . Result ( 101 , receivedValue , c , "请指定部岗位与指标关联关系!" )
return
}
for _ , ov := range receivedValue . OrgList {
if len ( ov . Child ) < 1 {
publicmethod . Result ( 101 , ov , c , "请指定部的对照岗位!" )
return
}
syncSeting . Add ( 1 )
go departmentAboutPostTarget ( targetCont . Dimension , targetCont . Id , 0 , 0 , ov . Id , ov . Child , 2 , targetCont . Type )
}
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
/ *
协程处理
部门指标岗位关联通用函数
@ dimensionId 维度
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ department 接受考核部门
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func departmentAboutPostTarget ( dimensionId , targetId , targetSunId , bylawsId int64 , departmentId string , postList [ ] loopStruct , class , nature int ) {
defer syncSeting . Done ( )
fmt . Printf ( "targetCont-----1---->%v\n" , nature )
if nature == 0 {
nature = 1
}
fmt . Printf ( "targetCont----2----->%v\n" , nature )
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
where := publicmethod . MapOut [ string ] ( )
where [ "`level`" ] = class
if targetId != 0 {
where [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
where [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
where [ "`target_bylaws`" ] = bylawsId
}
if departmentId != "" {
where [ "`department_id`" ] = departmentId
}
if len ( postList ) < 1 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( where ) . Updates ( & otherSaveData )
} else {
//获取提交的岗位
var postIdAry [ ] string
// overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Where(where).Not(map[string]interface{}{"post_id": postList}).Updates(&otherSaveData)
for _ , v := range postList {
if publicmethod . IsInTrue [ string ] ( v . Id , postIdAry ) == false {
postIdAry = append ( postIdAry , v . Id )
//判断该岗位是否已经存在对照
trWhere := publicmethod . MapOut [ string ] ( )
trWhere [ "`post_id`" ] = v . Id
trWhere [ "`level`" ] = class
if targetId != 0 {
trWhere [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
trWhere [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
trWhere [ "`target_bylaws`" ] = bylawsId
}
if departmentId != "" {
trWhere [ "`department_id`" ] = departmentId
}
departId , _ := strconv . ParseInt ( departmentId , 10 , 64 )
postId , _ := strconv . ParseInt ( v . Id , 10 , 64 )
var tarDepartCont modelskpi . TargetDepartment
saveErr := tarDepartCont . GetCont ( trWhere , "`id`" , "`state`" )
if saveErr == nil { //已经存在
if tarDepartCont . State != 1 { //不是启用状态,更改启用状态
tarDepartCont . EiteCont ( map [ string ] interface { } { "`id`" : tarDepartCont . Id } , map [ string ] interface { } { "`state`" : 1 , "`dimension_id`" : dimensionId , "`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
}
tarDepartCont . Dimension = dimensionId
tarDepartCont . TargetId = targetId //指标ID"`
tarDepartCont . TargetSunId = targetSunId //子目标"`
tarDepartCont . TargetBylaws = bylawsId //指标细则"`
tarDepartCont . Type = xiZe //类型(1:指标;2:子目标;3:细则)"`
tarDepartCont . DepartmentId = departId //部门ID"`
tarDepartCont . PostId = postId //岗位ID"`
tarDepartCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
tarDepartCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarDepartCont . Class = nature //1:定性考核;2:定量考核"`
tarDepartCont . Level = class //级别(1:部门级;2:岗位级)"`
jsonCont , _ := json . Marshal ( tarDepartCont )
fmt . Printf ( "targetCont----3----->%v\n" , string ( jsonCont ) )
overall . CONSTANT_DB_KPI . Create ( & tarDepartCont )
}
syncSeting . Add ( 1 )
go departAboutPostTargetReport ( dimensionId , targetId , targetSunId , bylawsId , departId , postId , v . Child , class , nature )
}
}
//把不在进行关联的取消
if len ( postIdAry ) > 0 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( where ) . Not ( map [ string ] interface { } { "post_id" : postIdAry } ) . Updates ( & otherSaveData )
}
}
}
/ *
协程处理
部门指标岗位提报人关联通用函数
@ dimensionId 维度
@ targetId 指标ID
@ targetSunId 栏目ID
@ bylawsId 指标细则
@ departmentId 接受考核部门
@ postId 岗位
@ class 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ nature 1 : 定性考核 ; 2 : 定量考核
* /
func departAboutPostTargetReport ( dimensionId , targetId , targetSunId , bylawsId , departmentId , postId int64 , repart [ ] loopStruct , class , nature int ) {
defer syncSeting . Done ( )
//将不属于该指标细则的部门至禁用
otherSaveData := publicmethod . MapOut [ string ] ( )
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
where := publicmethod . MapOut [ string ] ( )
where [ "`type`" ] = class
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 postId != 0 {
where [ "`post_id`" ] = postId
}
if len ( repart ) < 1 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Where ( where ) . Updates ( & otherSaveData )
} else {
//获取关联的人员
var userKeyAbout [ ] string
for _ , v := range repart {
if publicmethod . IsInTrue [ string ] ( v . Id , userKeyAbout ) == false {
userKeyAbout = append ( userKeyAbout , v . Id )
//获取评价人部门
var manCont modelshr . PersonArchives
manCont . GetCont ( map [ string ] interface { } { "`key`" : v . Id } , "`maindeparment`" )
var tarReportCont modelskpi . TargetReport
trWhere := publicmethod . MapOut [ string ] ( )
trWhere [ "`man_key`" ] = v . Id
trWhere [ "`type`" ] = class
if targetId != 0 {
trWhere [ "`target_id`" ] = targetId
}
if targetSunId != 0 {
trWhere [ "`target_sun_id`" ] = targetSunId
}
if bylawsId != 0 {
trWhere [ "`target_bylaws`" ] = bylawsId
}
if departmentId != 0 {
trWhere [ "`department_id`" ] = departmentId
}
if postId != 0 {
trWhere [ "`post_id`" ] = postId
}
saveErr := tarReportCont . GetCont ( trWhere , "`id`" , "`state`" )
if saveErr == nil {
if tarReportCont . State != 1 {
tarReportCont . EiteCont ( map [ string ] interface { } { "`id`" : tarReportCont . Id } , map [ string ] interface { } { "`state`" : 1 , "`dimension_id`" : dimensionId , "`man_department`" : manCont . MainDeparment , "`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
}
tarReportCont . Dimension = dimensionId
tarReportCont . TargetId = targetId //指标ID"`
tarReportCont . TargetSunId = targetSunId //子目标"`
tarReportCont . TargetBylaws = bylawsId //指标细则"`
tarReportCont . DepartmentId = departmentId //部门ID"`
tarReportCont . PostId = postId //岗位ID"`
tarReportCont . Type = class //类型(1:公司级;2:部门级)"`
tarReportCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
reportId , _ := strconv . ParseInt ( v . Id , 10 , 64 )
tarReportCont . ReportPerson = reportId //上报人"`
tarReportCont . ManDepartment = manCont . MainDeparment //提报人所在部门"`
tarReportCont . Time = time . Now ( ) . Unix ( ) //写入时间"`
tarReportCont . Class = nature //1:定性考核;2:定量考核"`
tarReportCont . Level = xiZe //1:指标;2:子目标;3:细则
overall . CONSTANT_DB_KPI . Create ( & tarReportCont )
}
}
}
//清除不需要提报的人员
if len ( userKeyAbout ) > 0 {
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Where ( where ) . Not ( map [ string ] interface { } { "man_key" : userKeyAbout } ) . Updates ( & otherSaveData )
}
}
}
// 子栏目关联部门岗位
func ( a * ApiMethod ) DeparSonTargetAboutPost ( c * gin . Context ) {
var receivedValue depTarAboutPost
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c , "请输入指标ID!!" )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "q_id" ] = receivedValue . Id
var targetCont modelskpi . QualitativeTarget
err := targetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if len ( receivedValue . OrgList ) < 1 {
publicmethod . Result ( 101 , receivedValue , c , "请指定部岗位与指标关联关系!" )
return
}
var fashTar modelskpi . EvaluationTarget
fashTar . GetCont ( map [ string ] interface { } { "et_id" : targetCont . ParentId } , "et_dimension" , "et_type" )
for _ , ov := range receivedValue . OrgList {
if len ( ov . Child ) < 1 {
publicmethod . Result ( 101 , ov , c , "请指定部的对照岗位!" )
return
}
syncSeting . Add ( 1 )
go departmentAboutPostTarget ( fashTar . Dimension , targetCont . ParentId , targetCont . Id , 0 , ov . Id , ov . Child , 2 , fashTar . Type )
}
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
// 指标细则关联部门岗位
func ( a * ApiMethod ) DeparDetaileAboutPost ( c * gin . Context ) {
var receivedValue depTarAboutPost
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c , "请输入指标ID!!" )
return
}
where := publicmethod . MapOut [ string ] ( )
where [ "dt_id" ] = receivedValue . Id
var targetCont modelskpi . DetailedTarget
err := targetCont . GetCont ( where )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
if len ( receivedValue . OrgList ) < 1 {
publicmethod . Result ( 101 , receivedValue , c , "请指定部岗位与指标关联关系!" )
return
}
var fashTar modelskpi . EvaluationTarget
fashTar . GetCont ( map [ string ] interface { } { "et_id" : targetCont . ParentId } , "et_dimension" , "et_type" )
for _ , ov := range receivedValue . OrgList {
if len ( ov . Child ) < 1 {
publicmethod . Result ( 101 , ov , c , "请指定部的对照岗位!" )
return
}
syncSeting . Add ( 1 )
go departmentAboutPostTarget ( fashTar . Dimension , targetCont . ParentId , targetCont . ParentIdSun , targetCont . Id , ov . Id , ov . Child , 2 , fashTar . Type )
}
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}