@ -80,7 +80,7 @@ func (p *postDimeTarSync) GetPostTargent(position modelshr.Position, dutyClass m
targetCont . Id = strconv . FormatInt ( v . Id , 10 )
targetCont . Name = v . Title
targetCont . Content = "" //指标描述
targetCont . StandardScore = getPostDimeTarWeight ( position . AdministrativeOrganization , position . Id , dutyClass . Id , v . Id , 1 , 1 ) //标准分
targetCont . StandardScore = getPostDimeTarWeight ( position . AdministrativeOrganization , position . Id , dutyClass . Id , v . Id , 2 , 1 ) //标准分
targetCont . Unit = v . Unit //单位
targetCont . IsTrue = 2 //是否允许修改 1:不允许;2:允许
targetCont . State = 1 //状态 1:启用;2:禁用;3:观察
@ -451,6 +451,12 @@ func postSchemeTargetPost(versionNumber string, source, judgeState int, scheme [
}
}
syncSetinges . Wait ( )
writeData := xizeXiecheng . readDataLock ( )
if len ( writeData ) > 0 {
for _ , wdv := range writeData {
saveNewData = append ( saveNewData , wdv )
}
}
if len ( saveNewData ) > 0 {
overall . CONSTANT_DB_KPI . Create ( & saveNewData )
}
@ -480,31 +486,60 @@ func (p *postShemeListCont) eidtPostSchemeInfo(versionNumber string, companyId,
if len ( postTargetDetailsCont ) > 0 {
for _ , v := range postTargetDetailsCont {
var saveData modelskpi . QualitativeEvaluationScheme //方案内容结构体
saveData . VersionNumber = versionNumber //版本编号"`
saveData . CompanyId = companyId //归属公司"`
saveData . DepartmentId = departmentId //归属部门"`
saveData . OrgId = orgid //归属行政组织"`
saveData . PostId = postid //归属岗位"`
saveData . Title = v . Title //考核项名称"`
saveData . DimensionId = departmentId //维度"`
saveData . TargetId = targetId //指标"`
saveData . SonTargetId = sonTargetId //子栏目"`
saveData . DetailsId = v . Id //细则"`
saveData . Attribute = 1 //属性 1:定性考核;2:定量考核"`
saveData . MinScore = v . MinScore //最小分*100保存"`
saveData . MaxScore = v . MaxScore //最大分*100保存"`
saveData . ScoringMethod = scoringMethod //计分方式(1:自动;2:手动)"`
saveData . State = targetState //状态(1:启用;2:禁用;3:删除)"`
saveData . Addtime = timeData //添加时间"`
saveData . Eitetime = timeData //编辑时间"`
saveData . CensorType = "2" //检查方式(1:现场检查;2:资料检查;3:事件触发)"`
saveData . Source = 1 //来源(1:岗位;2:部门引用)"`
saveData . RunState = runState //运行状态(1:启用;2:禁用;3:观察)
saveData . Punishmode = v . Punishmode //处罚方式 1:扣分;2:现金处罚;3:扣分加现金
saveData . Maxmoney = v . Maxmoney //最高罚款
saveData . Minmoney = v . Minmoney //最低罚款
p . shememList = append ( p . shememList , saveData )
//判断该细则是否存在
whereLian := publicmethod . MapOut [ string ] ( )
whereLian [ "`version_number`" ] = versionNumber
whereLian [ "`company_id`" ] = companyId
whereLian [ "`department_id`" ] = departmentId
whereLian [ "`org_id`" ] = orgid
whereLian [ "`post_id`" ] = postid
whereLian [ "`dimension_id`" ] = dimensionId
whereLian [ "`target_id`" ] = targetId
whereLian [ "`son_target_id`" ] = sonTargetId
whereLian [ "`details_id`" ] = v . Id
judgeLianErr := saveData . GetCont ( whereLian , "`id`" , "`state`" )
if judgeLianErr == nil {
eidtTargetCont := publicmethod . MapOut [ string ] ( )
eidtTargetCont [ "`scoring_method`" ] = scoringMethod
eidtTargetCont [ "`state`" ] = targetState
eidtTargetCont [ "`source`" ] = 1
eidtTargetCont [ "`run_state`" ] = runState
eidtTargetCont [ "`eitetime`" ] = timeData
eidtTargetCont [ "`min_score`" ] = v . MinScore
eidtTargetCont [ "`max_score`" ] = v . MaxScore
eidtTargetCont [ "`punishmode`" ] = v . Punishmode
eidtTargetCont [ "`maxmoney`" ] = v . Maxmoney
eidtTargetCont [ "`minmoney`" ] = v . Minmoney
saveData . EiteCont ( map [ string ] interface { } { "`id`" : saveData . Id } , eidtTargetCont )
} else { //不存在需要新增
var saveData modelskpi . QualitativeEvaluationScheme //方案内容结构体
saveData . VersionNumber = versionNumber //版本编号"`
saveData . CompanyId = companyId //归属公司"`
saveData . DepartmentId = departmentId //归属部门"`
saveData . OrgId = orgid //归属行政组织"`
saveData . PostId = postid //归属岗位"`
saveData . Title = v . Title //考核项名称"`
saveData . DimensionId = departmentId //维度"`
saveData . TargetId = targetId //指标"`
saveData . SonTargetId = sonTargetId //子栏目"`
saveData . DetailsId = v . Id //细则"`
saveData . Attribute = 1 //属性 1:定性考核;2:定量考核"`
saveData . MinScore = v . MinScore //最小分*100保存"`
saveData . MaxScore = v . MaxScore //最大分*100保存"`
saveData . ScoringMethod = scoringMethod //计分方式(1:自动;2:手动)"`
saveData . State = targetState //状态(1:启用;2:禁用;3:删除)"`
saveData . Addtime = timeData //添加时间"`
saveData . Eitetime = timeData //编辑时间"`
saveData . CensorType = "2" //检查方式(1:现场检查;2:资料检查;3:事件触发)"`
saveData . Source = 1 //来源(1:岗位;2:部门引用)"`
saveData . RunState = runState //运行状态(1:启用;2:禁用;3:观察)
saveData . Punishmode = v . Punishmode //处罚方式 1:扣分;2:现金处罚;3:扣分加现金
saveData . Maxmoney = v . Maxmoney //最高罚款
saveData . Minmoney = v . Minmoney //最低罚款
p . shememList = append ( p . shememList , saveData )
}
}
}
@ -896,7 +931,24 @@ func (a *ApiMethod) GetCopyShemeInfor(c *gin.Context) {
}
}
}
if len ( notUsedDimensionId ) > 0 {
for _ , nuduv := range notUsedDimensionId {
syncSeting . Add ( 1 )
go shemePostList . postHandleShemeNot ( schemeCont . OrgId , schemeCont . Position , nuduv )
}
}
syncSeting . Wait ( )
shemeList := shemePostList . readDataLock ( )
if len ( shemeList ) < 1 {
publicmethod . Result ( 1 , shemeList , c , "该岗位没有设定专属指标!您可以从部门指标中引入!" )
return
}
//根据维度序号排序
sort . Slice ( shemeList , func ( i , j int ) bool {
return shemeList [ i ] . Sort < shemeList [ j ] . Sort
} )
shemeInfo . PostChild = shemeList
publicmethod . Result ( 0 , shemeInfo , c )
}
/ *
@ -907,20 +959,81 @@ func (a *ApiMethod) GetCopyShemeInfor(c *gin.Context) {
@ shemeInfo 考核项结构体
* /
func ( s * shemeSync ) postHandleSheme ( orgid , postid , dimensId int64 , shemeInfo schemeStructure ) {
// var targetPostList []schemeTargetStructure
// var idIsTrue []string
// for _, v := range shemeInfo.Child {
// idIsTrue = append(idIsTrue, v.Id)
// var targetCont schemeTargetStructure
// targetCont.Id = v.Id
// targetCont.Name = v.Title
// targetCont.Content = "" //指标描述
// targetCont.StandardScore = getPostDimeTarWeight(orgid, postid, dimensId, v.Id, 1, 1) //标准分
// targetCont.Unit = v.Unit //单位
// targetCont.IsTrue = 2 //是否允许修改 1:不允许;2:允许
// targetCont.State = 1
// targetPostList = append(targetPostList, targetCont)
// }
s . mutext . Lock ( )
defer s . mutext . Unlock ( )
var targetPostList schemeStructure
//获取维度信息
var dimeCont modelskpi . DutyClass
dimeCont . GetCont ( map [ string ] interface { } { "`id`" : dimensId } , "`title`" )
targetPostList . Id = shemeInfo . Id
targetPostList . Name = shemeInfo . Name
targetPostList . Sort = dimeCont . Sort
targetPostList . Score = shemeInfo . Score
var idIsTrue [ ] string
for _ , v := range shemeInfo . Child {
idIsTrue = append ( idIsTrue , v . Id )
targetPostList . Child = append ( targetPostList . Child , v )
}
//获取被指标下的其他
var otherTarget [ ] modelskpi . PostTarget
if len ( idIsTrue ) > 0 {
overall . CONSTANT_DB_KPI . Where ( "`state` = 1 AND `rele_depart` = ? AND `departments_post` AND `dimension` = ?" , orgid , postid , dimensId ) . Not ( map [ string ] interface { } { "`id`" : idIsTrue } ) . Find ( & otherTarget )
}
if len ( otherTarget ) > 0 {
for _ , otv := range otherTarget {
var tarCont schemeTargetStructure
tarCont . Id = strconv . FormatInt ( otv . Id , 10 ) //id
tarCont . Name = otv . Title //名称
tarCont . Content = "" //说明
scorcFloatInt := getPostDimeTarWeight ( orgid , postid , dimensId , otv . Id , 2 , 1 )
tarCont . Score = float64 ( scorcFloatInt ) //`json:"score"` //分数
tarCont . State = 1 //状态:1:启用;2:禁用;3:观察
tarCont . Type = otv . Type // //1、定性指标;2、定量指标
targetPostList . Child = append ( targetPostList . Child , tarCont )
}
}
s . shememList = append ( s . shememList , targetPostList )
syncSeting . Done ( )
}
/ *
协程处理未生成的维度指标是否有新的内容
@ orgid 行政组织ID
@ postid 岗位ID
@ dimensId 维度ID
* /
func ( s * shemeSync ) postHandleShemeNot ( orgid , postid , dimensId int64 ) {
s . mutext . Lock ( )
defer s . mutext . Unlock ( )
var targetPostList schemeStructure
//获取维度信息
var dimeCont modelskpi . DutyClass
dimeCont . GetCont ( map [ string ] interface { } { "`id`" : dimensId } , "`title`" )
targetPostList . Id = strconv . FormatInt ( dimeCont . Id , 10 )
targetPostList . Name = dimeCont . Title
targetPostList . Sort = dimeCont . Sort
targetPostList . Score = 0
//获取维度下的指标
var otherTarget [ ] modelskpi . PostTarget
overall . CONSTANT_DB_KPI . Where ( "`state` = 1 AND `rele_depart` = ? AND `departments_post` AND `dimension` = ?" , orgid , postid , dimensId ) . Find ( & otherTarget )
if len ( otherTarget ) > 0 {
for _ , otv := range otherTarget {
var tarCont schemeTargetStructure
tarCont . Id = strconv . FormatInt ( otv . Id , 10 ) //id
tarCont . Name = otv . Title //名称
tarCont . Content = "" //说明
scorcFloatInt := getPostDimeTarWeight ( orgid , postid , dimensId , otv . Id , 2 , 1 )
tarCont . Score = float64 ( scorcFloatInt ) //`json:"score"` //分数
tarCont . State = 1 //状态:1:启用;2:禁用;3:观察
tarCont . Type = otv . Type // //1、定性指标;2、定量指标
targetPostList . Child = append ( targetPostList . Child , tarCont )
}
}
s . shememList = append ( s . shememList , targetPostList )
syncSeting . Done ( )
}