@ -202,6 +202,7 @@ func (a *ApiMethod) GetNewTargetAboutDepartToPostMan(c *gin.Context) {
}
}
var orgPostInfo OrgPostCont
var orgPostInfo OrgPostCont
orgPostInfo . Id = postIdstr
orgPostInfo . Id = postIdstr
orgPostInfo . OrgId = orgIdstr
var postInfo modelshr . Position
var postInfo modelshr . Position
postInfo . GetCont ( map [ string ] interface { } { "`id`" : v . PostId } , "`name`" )
postInfo . GetCont ( map [ string ] interface { } { "`id`" : v . PostId } , "`name`" )
_ , _ , departmentId , sunDepartId , workShopId := publicmethod . GetOrgStructure ( v . DepartmentId )
_ , _ , departmentId , sunDepartId , workShopId := publicmethod . GetOrgStructure ( v . DepartmentId )
@ -634,7 +635,7 @@ func PostDetailsBaseOrgPostMan(dimensionId, targetId, tableId, bylawsId int64, c
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`state`" ] = 2
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
otherSaveData [ "`time`" ] = time . Now ( ) . Unix ( )
for _ , val := range orgManList {
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 , target Id , bylawsId , level , val . OrgId , val . PostId ) . Not ( map [ string ] interface { } { "man_key" : val . ManKey } ) . Updates ( & otherSaveData )
overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Where ( "`type_ level` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ? AND `type` = ? AND `department_id` = ? AND `post_id` = ?" , types , targetId , table Id , bylawsId , level , val . OrgId , val . PostId ) . Not ( map [ string ] interface { } { "man_key" : val . ManKey } ) . Updates ( & otherSaveData )
}
}
//处理指标细则提报人问题
//处理指标细则提报人问题
for _ , v := range orgPostManList {
for _ , v := range orgPostManList {
@ -642,7 +643,7 @@ func PostDetailsBaseOrgPostMan(dimensionId, targetId, tableId, bylawsId int64, c
var manCont modelshr . PersonArchives
var manCont modelshr . PersonArchives
manCont . GetCont ( map [ string ] interface { } { "`key`" : v . ManKey } , "`maindeparment`" )
manCont . GetCont ( map [ string ] interface { } { "`key`" : v . ManKey } , "`maindeparment`" )
var tarDepartCont modelskpi . TargetReport
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`" )
saveErr := tarDepartCont . GetCont ( map [ string ] interface { } { "`type_ 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 saveErr == nil {
if tarDepartCont . State != 1 {
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 ( ) } )
tarDepartCont . EiteCont ( map [ string ] interface { } { "`id`" : tarDepartCont . Id } , map [ string ] interface { } { "`state`" : 1 , "`man_department`" : manCont . MainDeparment , "`time`" : time . Now ( ) . Unix ( ) } )
@ -651,7 +652,7 @@ func PostDetailsBaseOrgPostMan(dimensionId, targetId, tableId, bylawsId int64, c
var tarReportContAdd modelskpi . TargetReport
var tarReportContAdd modelskpi . TargetReport
tarReportContAdd . Dimension = dimensionId //维度
tarReportContAdd . Dimension = dimensionId //维度
tarReportContAdd . TargetId = targetId //指标ID"`
tarReportContAdd . TargetId = targetId //指标ID"`
tarReportContAdd . TargetSunId = targetId //子目标"`
tarReportContAdd . TargetSunId = tableId //子目标"`
tarReportContAdd . TargetBylaws = bylawsId //指标细则"`
tarReportContAdd . TargetBylaws = bylawsId //指标细则"`
tarReportContAdd . DepartmentId = v . OrgId //部门ID"`
tarReportContAdd . DepartmentId = v . OrgId //部门ID"`
tarReportContAdd . PostId = v . PostId //岗位ID"`
tarReportContAdd . PostId = v . PostId //岗位ID"`
@ -887,3 +888,629 @@ func EditPostTableCont(targetId int64, title string) (tableId int64, err error)
}
}
return
return
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 02 - 23 0 8 : 15 : 29
@ 功能 : 修改岗位指标细则 ( 新版 )
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) EditPostDetailsCont ( c * gin . Context ) {
var receivedValue EditDetailsCont
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
if receivedValue . Title == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入考核内容!" )
return
}
if receivedValue . PunishType == 0 {
receivedValue . PunishType = 3
}
switch receivedValue . PunishType {
case 2 :
if receivedValue . CashStandard == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入现金考核标准!" )
return
}
case 3 :
if receivedValue . Standard == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入考核标准!" )
return
}
if receivedValue . Unit == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入计量单位!" )
return
}
if receivedValue . CashStandard == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入现金考核标准!" )
return
}
default :
if receivedValue . Standard == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入考核标准!" )
return
}
if receivedValue . Unit == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入计量单位!" )
return
}
}
if receivedValue . Types == 0 {
receivedValue . Types = 2
}
if len ( receivedValue . Inspemethod ) < 1 {
publicmethod . Result ( 1 , receivedValue , c , "请选择检查方式!" )
return
}
if receivedValue . Cycle == 0 {
receivedValue . Cycle = 4
}
if receivedValue . Frequency == 0 {
receivedValue . Frequency = 1
}
var orgPost [ ] OrgAndPostCont
var orgPostMan [ ] OrgAndPostManCont
var orgList [ ] string
var postList [ ] string
var manList [ ] string
if len ( receivedValue . PostandExport ) < 1 {
publicmethod . Result ( 1 , receivedValue , c , "请设定岗位及提报人!" )
return
} else {
for _ , v := range receivedValue . PostandExport {
var orgPostCont OrgAndPostCont
orgIdInt , _ := strconv . ParseInt ( v . OrgId , 10 , 64 )
orgPostCont . OrgId = orgIdInt
postIdInt , _ := strconv . ParseInt ( v . Id , 10 , 64 )
orgPostCont . PostId = postIdInt
orgPost = append ( orgPost , orgPostCont )
if publicmethod . IsInTrue [ string ] ( v . OrgId , orgList ) == false {
orgList = append ( orgList , v . OrgId )
}
if publicmethod . IsInTrue [ string ] ( v . Id , postList ) == false {
postList = append ( postList , v . Id )
}
if len ( v . Operator ) < 1 {
publicmethod . Result ( 1 , receivedValue , c , "有未设定的岗位提报人!请检查!" )
return
} else {
for _ , mv := range v . Operator {
var orgPostManCont OrgAndPostManCont
orgPostManCont . OrgId = orgIdInt
orgPostManCont . PostId = postIdInt
mvIdInt , _ := strconv . ParseInt ( mv , 10 , 64 )
orgPostManCont . ManKey = mvIdInt
orgPostMan = append ( orgPostMan , orgPostManCont )
if publicmethod . IsInTrue [ string ] ( mv , manList ) == false {
manList = append ( manList , mv )
}
}
}
}
}
wher := publicmethod . MapOut [ string ] ( )
wher [ "`id`" ] = receivedValue . Id
var oldDetailsCont modelskpi . PostTargetDetails
err := oldDetailsCont . GetCont ( wher )
if err != nil {
publicmethod . Result ( 1 , receivedValue , c , "细则不存在!请检查!" )
return
}
editCont := publicmethod . MapOut [ string ] ( )
if receivedValue . Title != oldDetailsCont . Title {
editCont [ "`title`" ] = receivedValue . Title
}
if receivedValue . PunishType != oldDetailsCont . Punishmode {
editCont [ "`punishmode`" ] = receivedValue . PunishType
}
if receivedValue . Standard != "" {
minSecor , MaxSecor := departmentpc . SplitCriteria ( receivedValue . Standard )
if minSecor != oldDetailsCont . MinScore {
editCont [ "`min_score`" ] = minSecor
}
if MaxSecor != oldDetailsCont . MaxScore {
editCont [ "`max_score`" ] = MaxSecor
}
}
if receivedValue . Unit != oldDetailsCont . Company {
editCont [ "`company`" ] = receivedValue . Unit
}
if receivedValue . CashStandard != "" {
minMoneys , MaxMoneys := departmentpc . SplitCriteria ( receivedValue . CashStandard )
if minMoneys != oldDetailsCont . Minmoney {
editCont [ "`minmoney`" ] = minMoneys
}
if MaxMoneys != oldDetailsCont . Maxmoney {
editCont [ "`maxmoney`" ] = MaxMoneys
}
}
if receivedValue . Types != oldDetailsCont . AddReduce {
editCont [ "`add_reduce`" ] = receivedValue . Types
}
if len ( receivedValue . Inspemethod ) > 0 {
insStr := strings . Join ( receivedValue . Inspemethod , "," )
if insStr != oldDetailsCont . CensorType {
editCont [ "`censor_type`" ] = insStr
}
}
if receivedValue . Cycle != oldDetailsCont . Cycles {
editCont [ "`cycle`" ] = receivedValue . Cycle
}
if receivedValue . Frequency != oldDetailsCont . CensorRate {
editCont [ "`censor_rate`" ] = receivedValue . Frequency
}
if receivedValue . Evidence != oldDetailsCont . CensorCont {
editCont [ "`censor_cont`" ] = receivedValue . Evidence
}
if receivedValue . Remarks != oldDetailsCont . Content {
editCont [ "`content`" ] = receivedValue . Remarks
}
editCont [ "`paretment`" ] = strings . Join ( orgList , "," )
editCont [ "`paretment_post`" ] = strings . Join ( postList , "," )
editCont [ "`reportary`" ] = strings . Join ( manList , "," )
if len ( editCont ) > 0 {
editCont [ "`time`" ] = time . Now ( ) . Unix ( )
var editInfoCont modelskpi . PostTargetDetails
err = editInfoCont . EiteCont ( wher , editCont )
if err != nil {
publicmethod . Result ( 106 , err , c )
return
}
}
var targetCont modelskpi . PostTarget
targetCont . GetCont ( map [ string ] interface { } { "`id`" : oldDetailsCont . ParentId } )
syncSeting . Add ( 1 )
go PostDetailsBaseOrgPost ( targetCont . Dimension , targetCont . Id , oldDetailsCont . ParentIdSun , oldDetailsCont . Id , targetCont . Type , 3 , 2 , orgPost )
syncSeting . Add ( 1 )
go PostDetailsBaseOrgPostMan ( targetCont . Dimension , targetCont . Id , oldDetailsCont . ParentIdSun , oldDetailsCont . Id , targetCont . Type , 3 , 2 , orgPostMan )
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 02 - 23 13 : 49 : 06
@ 功能 : 根据栏目添加细则列表
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) AddTableDetailsList ( c * gin . Context ) {
var receivedValue AddTablePostDetails
c . ShouldBindJSON ( & receivedValue )
if receivedValue . TargetId == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
if receivedValue . TableId == "" {
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
// }
tableId , _ := strconv . ParseInt ( receivedValue . TableId , 10 , 64 )
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 - 23 14 : 58 : 36
@ 功能 : 获取岗位栏目关联部门相关岗位及提报人 ( 新版 )
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GetNewTableDepartToPostMan ( 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 . PostSonTarget
err = postTargetCont . GetCont ( map [ string ] interface { } { "`id`" : receivedValue . Id } )
if err != nil {
publicmethod . Result ( 107 , err , c )
return
}
var sendCont OutTableDepatPostMan
sendCont . Name = postTargetCont . Title
var tarDepatContList [ ] modelskpi . TargetDepartment
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Select ( "`department_id`,`post_id`" ) . Where ( "`state` = 1 AND `type` = 2 AND `level` = 2 AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = 0" , postTargetCont . ParentId , 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
orgPostInfo . OrgId = orgIdstr
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 . ParentId , postTargetCont . Id , 0 , 0 , v . PostId , departmentId , 2 , 2 )
sendCont . OrgAndPostList = append ( sendCont . OrgAndPostList , orgPostInfo )
}
publicmethod . Result ( 0 , sendCont , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 02 - 23 15 : 29 : 30
@ 功能 : 编辑岗位子栏目内容 ( 新版 )
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) EditSonTargetContNew ( c * gin . Context ) {
var receivedValue EditTableCont
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
if receivedValue . Title == "" {
publicmethod . Result ( 1 , receivedValue , c , "请输入考核内容!" )
return
}
var orgPost [ ] OrgAndPostCont
var orgPostMan [ ] OrgAndPostManCont
var orgList [ ] string
var postList [ ] string
var manList [ ] string
if len ( receivedValue . PostandExport ) < 1 {
publicmethod . Result ( 1 , receivedValue , c , "请设定岗位及提报人!" )
return
} else {
for _ , v := range receivedValue . PostandExport {
var orgPostCont OrgAndPostCont
orgIdInt , _ := strconv . ParseInt ( v . OrgId , 10 , 64 )
orgPostCont . OrgId = orgIdInt
postIdInt , _ := strconv . ParseInt ( v . Id , 10 , 64 )
orgPostCont . PostId = postIdInt
orgPost = append ( orgPost , orgPostCont )
if publicmethod . IsInTrue [ string ] ( v . OrgId , orgList ) == false {
orgList = append ( orgList , v . OrgId )
}
if publicmethod . IsInTrue [ string ] ( v . Id , postList ) == false {
postList = append ( postList , v . Id )
}
if len ( v . KeyList ) < 1 {
publicmethod . Result ( 1 , receivedValue , c , "有未设定的岗位提报人!请检查!" )
return
} else {
for _ , mv := range v . KeyList {
var orgPostManCont OrgAndPostManCont
orgPostManCont . OrgId = orgIdInt
orgPostManCont . PostId = postIdInt
mvIdInt , _ := strconv . ParseInt ( mv , 10 , 64 )
orgPostManCont . ManKey = mvIdInt
orgPostMan = append ( orgPostMan , orgPostManCont )
if publicmethod . IsInTrue [ string ] ( mv , manList ) == false {
manList = append ( manList , mv )
}
}
}
}
}
wher := publicmethod . MapOut [ string ] ( )
wher [ "`id`" ] = receivedValue . Id
var oldDetailsCont modelskpi . PostSonTarget
err := oldDetailsCont . GetCont ( wher )
if err != nil {
publicmethod . Result ( 1 , receivedValue , c , "细则不存在!请检查!" )
return
}
editCont := publicmethod . MapOut [ string ] ( )
if receivedValue . Title != oldDetailsCont . Title {
editCont [ "`title`" ] = receivedValue . Title
}
orgString := strings . Join ( orgList , "," )
if orgString != oldDetailsCont . Depart {
editCont [ "`depart`" ] = orgString
}
postString := strings . Join ( postList , "," )
if postString != oldDetailsCont . DepartPost {
editCont [ "`depart_post`" ] = postList
}
if oldDetailsCont . State != 1 {
editCont [ "`state`" ] = 1
}
if len ( editCont ) > 0 {
editCont [ "`time`" ] = time . Now ( ) . Unix ( )
var editTabInfo modelskpi . PostSonTarget
err = editTabInfo . EiteCont ( wher , editCont )
}
// sendData := publicmethod.MapOut[string]()
// sendData["orgPost"] = orgPost
// sendData["orgPostMan"] = orgPostMan
// sendData["orgList"] = orgList
// sendData["postList"] = postList
// sendData["manList"] = manList
// sendData["oldDetailsCont"] = oldDetailsCont
var targetCont modelskpi . PostTarget
targetCont . GetCont ( map [ string ] interface { } { "`id`" : oldDetailsCont . ParentId } )
syncSeting . Add ( 1 )
go PostDetailsBaseOrgPost ( targetCont . Dimension , targetCont . Id , oldDetailsCont . Id , 0 , targetCont . Type , 2 , 2 , orgPost )
syncSeting . Add ( 1 )
go PostDetailsBaseOrgPostMan ( targetCont . Dimension , targetCont . Id , oldDetailsCont . Id , 0 , targetCont . Type , 2 , 2 , orgPostMan )
syncSeting . Wait ( )
publicmethod . Result ( 0 , err , c )
}