@ -49,7 +49,7 @@ func (a *ApiMethod) GetPostTarget(c *gin.Context) {
sendData . ScoringMethod = postTargetCont . ScoringMethod //计分方式(1:自动;2:手动)"`
sendData . VisibleRange = postTargetCont . VisibleRange //可见范围"`
sendData . VisibleGroup = postTargetCont . VisibleGroup //可见范围(集团)"`
_ , sendData . RelevantPostsMan , _ = getTargetAboutPost ( postTargetCont . ReleDepart , postTargetCont . Dimension , postTargetCont . Id )
_ , sendData . RelevantPostsMan , _ = getTargetAboutPost ( postTargetCont . ReleDepart , postTargetCont . Dimension , postTargetCont . Id , 2 )
publicmethod . Result ( 0 , sendData , c )
}
@ -58,14 +58,17 @@ func (a *ApiMethod) GetPostTarget(c *gin.Context) {
@ 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 ) ( postId [ ] int64 , postPeopleList [ ] postPeople , err error ) {
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`post_id`" ) . Where ( "`state` = 1 AND `level` = 2 AND `department_id` = ? AND `dimension_id` = ? AND `target_id` = ?" ) . Find ( & postId ) . 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 )
_ , postmanCont . Operator , _ = getTargetAboutPostMan ( departmentId , postId [ i ] , dimensionId , targetId , level )
postPeopleList = append ( postPeopleList , postmanCont )
}
}
@ -78,9 +81,10 @@ func getTargetAboutPost(departmentId, dimensionId, targetId int64) (postId []int
@ postid 岗位
@ dimensionId 维度
@ targetId 指标
@ level 级别 ( 1 : 部门级 ; 2 : 岗位级 )
* /
func getTargetAboutPostMan ( departmentId , postid , dimensionId , targetId int64 ) ( peopleId [ ] int64 , postPeople [ ] string , err error ) {
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "`man_key`" ) . Where ( "`state` = 1 AND `type` = 2 AND `department_id` = ? AND `post_id` = ? AND `dimension_id` = ? AND `target_id` = ?" ) . Find ( & peopleId ) . Error
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 ) )
@ -270,3 +274,216 @@ func EditTargetTableDimenAboutPostOfDepart(dimensionId, targetId, targetSunId, b
}
}
}
// 编辑岗位指标
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 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 {
// }
}