@ -7,6 +7,7 @@ import (
"key_performance_indicators/models/modelskpi"
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
"sort"
"strconv"
"strings"
"time"
@ -365,10 +366,10 @@ func (a *ApiMethod) CreateSchemeForDeparment(c *gin.Context) {
publicmethod . Result ( 100 , err , c )
return
}
if receivedValue . Group == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
}
// if receivedValue.Group == "" {
// publicmethod.Result(101, receivedValue, c)
// return
// }
if receivedValue . DepartmentId == "" {
publicmethod . Result ( 101 , receivedValue , c )
return
@ -383,11 +384,13 @@ func (a *ApiMethod) CreateSchemeForDeparment(c *gin.Context) {
}
departId , _ := strconv . ParseInt ( receivedValue . DepartmentId , 10 , 64 ) //部门ID
yearInt , _ := strconv . ParseInt ( receivedValue . Year , 10 , 64 ) //年
//获取编号首字母
groupId , groupErr := strconv . ParseInt ( receivedValue . Group , 10 , 64 ) //集团ID
if groupErr != nil {
groupId = 0
}
_ , groupId , _ , _ , _ := publicmethod . GetOrgStructurees ( departId )
// groupId, groupErr := strconv.ParseInt(receivedValue.Group, 10, 64) //集团ID
// if groupErr != nil {
// groupId = 0
// }
var groupCont modelshr . AdministrativeOrganization
groupCont . GetCont ( map [ string ] interface { } { "`id`" : groupId } , "`id`" , "`name`" , "`abbreviation`" )
nameCont := groupCont . Abbreviation
@ -805,3 +808,805 @@ func AddWeight(group, dimension, derpatment, target string, score, class int64)
}
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 14 16 : 01 : 02
@ 功能 : 查看部门考核方案详情
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) LookSchemeForDeparment ( 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 ( 1 , err , c , "未知方案编号!不可操作" )
return
}
var schemeCont modelskpi . PlanVersio
err = schemeCont . GetCont ( map [ string ] interface { } { "`key`" : receivedValue . Id } )
if err != nil {
publicmethod . Result ( 1 , err , c , "未知方案编号!不可操作" )
return
}
var planVersioInfo [ ] AddDutyNewCont
jsonErr := json . Unmarshal ( [ ] byte ( schemeCont . Content ) , & planVersioInfo )
if jsonErr != nil {
publicmethod . Result ( 1 , err , c , "未知方案!不可操作" )
return
}
var sendContList [ ] SchemeCont
for _ , dv := range planVersioInfo {
for _ , v := range dv . Child {
if v . Status == 1 || v . Status == 3 {
var sendCont SchemeCont
sendCont . DimensionId = dv . Id //维度Id
sendCont . DimensionName = dv . Name //维度名称
sendCont . DimensionStandard = float64 ( dv . ZhiFraction ) //维度标准
sendCont . TargetId = v . Id //指标Id
sendCont . TargetName = v . Name //指标名称
sendCont . TargetStandard = float64 ( v . ReferenceScore ) //指标标准
sendCont . Content = v . Content //指标说明
sendCont . Unit = v . Unit //单位
var targetCont modelskpi . EvaluationTarget
targetCont . GetCont ( map [ string ] interface { } { "et_id" : v . Id } , "et_type" )
sendCont . Attribute = targetCont . Type //指标性质 1:定量;2:定性
sendCont . State = v . Status //状态 1:使用;2:禁用;3:观察
sendCont . Cycle = v . Cycles //1:班;2:天;3:周;4:月;5:季度;6:年;7:半年
sendCont . Frequency = v . CycleAttres //频率
sendCont . PlantVersion = schemeCont . Key
sendCont . OrgId = strconv . FormatInt ( schemeCont . Department , 10 )
sendContList = append ( sendContList , sendCont )
}
}
}
publicmethod . Result ( 0 , sendContList , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 17 10 : 46 : 18
@ 功能 : 获取部门考核指标关联得细则
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) LookSchemeBylaws ( c * gin . Context ) {
var receivedValue LookTargetToBylaws
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 1 , receivedValue , c , "未知指标!不可操作" )
return
}
if receivedValue . OrgId == "" {
publicmethod . Result ( 1 , receivedValue , c , "未知行政组织!不可操作" )
return
}
if receivedValue . Type == 0 {
receivedValue . Type = 1
}
if receivedValue . Level == 2 {
if receivedValue . PosId == "" {
publicmethod . Result ( 1 , receivedValue , c , "未知岗位!不可操作" )
return
}
} else {
receivedValue . Level = 1
}
var detailedList [ ] modelskpi . TargetDetailedRelationDepartment
gormDb := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDetailedRelationDepartment { } ) . Where ( "dt_state = 1 AND dt_parentid = ? AND tddepartment = ? AND tdtype = ? AND `level` = ?" , receivedValue . Id , receivedValue . OrgId , receivedValue . Type , receivedValue . Level )
if receivedValue . Level == 2 && receivedValue . PosId != "" {
gormDb = gormDb . Where ( "postid = ?" , receivedValue . PosId )
}
err := gormDb . Find ( & detailedList ) . Error
if err != nil || len ( detailedList ) < 1 {
publicmethod . Result ( 105 , err , c )
return
}
var sendList [ ] SendTargetToBylaws
for _ , v := range detailedList {
var sendCont SendTargetToBylaws
sendCont . TableId = v . ParentIdSun //
var tableCont modelskpi . QualitativeTarget
tableCont . GetCont ( map [ string ] interface { } { "q_id" : v . ParentIdSun } , "q_title" )
sendCont . TableName = tableCont . Title //
sendCont . TargetId = strconv . FormatInt ( v . Id , 10 ) //
sendCont . TargetName = v . Title //
maxVal := publicmethod . DecimalEs ( float64 ( v . MaxScore ) / 100 , 2 ) //最大分
minVal := publicmethod . DecimalEs ( float64 ( v . MinScore ) / 100 , 2 ) //最小分
if minVal != 0 && maxVal != 0 {
sendCont . Criterion = fmt . Sprintf ( "%v-%v" , minVal , maxVal )
} else if minVal != 0 && maxVal == 0 {
sendCont . Criterion = fmt . Sprintf ( "%v" , minVal )
} else if minVal == 0 && maxVal != 0 {
sendCont . Criterion = fmt . Sprintf ( "%v" , maxVal )
} else {
sendCont . Criterion = ""
}
sendCont . MaxScore = maxVal
sendCont . MinScore = minVal //最小分
sendCont . Unit = v . Company //单位
sendCont . Content = v . Content //指标说明
sendList = append ( sendList , sendCont )
}
//根据维度序号排序
sort . Slice ( sendList , func ( i , j int ) bool {
return sendList [ i ] . TableId < sendList [ j ] . TableId
} )
publicmethod . Result ( 0 , sendList , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 17 11 : 0 9 : 23
@ 功能 : 查看执行人
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GetRunManScheme ( c * gin . Context ) {
var receivedValue LookTargetToBylaws
c . ShouldBindJSON ( & receivedValue )
if receivedValue . Id == "" {
publicmethod . Result ( 1 , receivedValue , c , "未知指标!不可操作" )
return
}
if receivedValue . OrgId == "" {
publicmethod . Result ( 1 , receivedValue , c , "未知行政组织!不可操作" )
return
}
if receivedValue . Type == 0 {
receivedValue . Type = 1
}
if receivedValue . Level == 2 {
if receivedValue . PosId == "" {
publicmethod . Result ( 1 , receivedValue , c , "未知岗位!不可操作" )
return
}
} else {
receivedValue . Level = 1
}
var userKey [ ] int64
gormDb := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetReport { } ) . Distinct ( "man_key" ) . Where ( "`state` = 1 AND `target_id` = ? AND `department_id` = ? AND `type` = ?" , receivedValue . Id , receivedValue . OrgId , receivedValue . Type )
if receivedValue . Level == 2 && receivedValue . PosId != "" {
gormDb = gormDb . Where ( "`post_id` = ?" , receivedValue . PosId )
}
err := gormDb . Find ( & userKey ) . Error
if err != nil || len ( userKey ) < 1 {
publicmethod . Result ( 105 , err , c )
return
}
var userListCont [ ] modelshr . PersonArchives
err = overall . CONSTANT_DB_HR . Model ( & modelshr . PersonArchives { } ) . Select ( "`key`,`name`,`number`,`company`,`maindeparment`,`icon`,`icon_photo`" ) . Where ( "`emp_type` BETWEEN 1 AND 10 AND `key` IN ?" , userKey ) . Find ( & userListCont ) . Error
if err != nil || len ( userListCont ) < 1 {
publicmethod . Result ( 105 , err , c )
return
}
var userListInfo [ ] RunManCont
for _ , v := range userListCont {
var userInfo RunManCont
userInfo . Id = strconv . FormatInt ( v . Key , 10 )
userInfo . Name = v . Name
userInfo . Number = v . Number
var comCont modelshr . AdministrativeOrganization
comCont . GetCont ( map [ string ] interface { } { "`id`" : v . Company } , "`name`" )
userInfo . Company = comCont . Name
var demperCont modelshr . AdministrativeOrganization
demperCont . GetCont ( map [ string ] interface { } { "`id`" : v . MainDeparment } , "`name`" )
userInfo . Department = demperCont . Name
userInfo . Icon = v . Icon
userInfo . IconBase64 = v . IconPhoto
userListInfo = append ( userListInfo , userInfo )
}
publicmethod . Result ( 0 , userListInfo , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 17 16 : 03 : 16
@ 功能 : 编辑方案指标内容
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) EditSchemeTargetCont ( c * gin . Context ) {
var receivedValue EditSchemeContTarget
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if receivedValue . PlanVersionKey == "" {
publicmethod . Result ( 1 , err , c , "请输入版本号!" )
return
}
if receivedValue . TargetId == "" {
publicmethod . Result ( 1 , err , c , "请输入指标号!" )
return
}
if receivedValue . OrgId == "" {
publicmethod . Result ( 1 , err , c , "请输入行政组织!" )
return
}
eiteData := publicmethod . MapOut [ string ] ( )
eiteData [ "qe_eitetime" ] = time . Now ( ) . Unix ( )
eiteData [ "qe_content" ] = receivedValue . Content
if receivedValue . State > 0 {
// eiteData["qe_state"] = requestData.State
eiteData [ "observer" ] = receivedValue . State
} else {
eiteData [ "qe_state" ] = 2
eiteData [ "observer" ] = 2
}
if len ( receivedValue . Operator ) > 0 {
eiteData [ "qe_operator" ] = strings . Join ( receivedValue . Operator , "," )
}
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . QualitativeEvaluation { } ) . Where ( "`qe_state` = 1 AND `qe_qual_eval_id` = ? AND `qe_accept_evaluation` = ? AND `qe_target` = ?" , receivedValue . PlanVersionKey , receivedValue . OrgId , receivedValue . TargetId ) . Updates ( eiteData ) . Error
if err != nil {
publicmethod . Result ( 1 , err , c , "数据处理失败!" )
return
} else {
if receivedValue . State != 0 {
eitePlanVersion ( receivedValue . PlanVersionKey , receivedValue . TargetId , receivedValue . State , receivedValue . Content )
}
if len ( receivedValue . Operator ) > 0 {
eiteOperatorPlanVersion ( receivedValue . OrgId , receivedValue . TargetId , receivedValue . Operator )
}
publicmethod . Result ( 0 , err , c )
}
}
// 处理关联人
func eiteOperatorPlanVersion ( orgId , targetId string , operator [ ] string ) {
overTime := time . Now ( ) . Unix ( )
delWher := publicmethod . MapOut [ string ] ( )
delWher [ "target_id" ] = targetId
delWher [ "department_id" ] = orgId
delWher [ "type" ] = 1
var targetReportCont modelskpi . TargetReport
err := targetReportCont . DelCont ( delWher )
if err == nil {
var tarReportContList [ ] modelskpi . TargetReport
var targetDeparcContList [ ] modelskpi . TargetDepartment
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Where ( "`level` = 1 AND `target_id` = ? AND `department_id` = ?" ) . Find ( & targetDeparcContList ) . Error
if err == nil {
for _ , v := range targetDeparcContList {
dimensId := v . Dimension
if dimensId == 0 && v . TargetId != 0 {
var targetCont modelskpi . EvaluationTarget
targetCont . GetCont ( map [ string ] interface { } { "et_id" : v . TargetId } , "et_dimension" )
dimensId = targetCont . Dimension
}
for _ , opev := range operator {
var tarReportCont modelskpi . TargetReport
tarReportCont . Dimension = dimensId //维度"`
tarReportCont . TargetId = v . TargetId //指标ID"`
tarReportCont . TargetSunId = v . TargetSunId //子目标"`
tarReportCont . TargetBylaws = v . TargetBylaws //指标细则"`
tarReportCont . DepartmentId = v . DepartmentId //部门ID"`
tarReportCont . PostId = v . PostId //岗位ID"`
tarReportCont . Type = v . Level //类型(1:公司级;2:部门级)"`
tarReportCont . State = 1 //状态(1:启用;2:禁用;3:删除)"`
opevInt , _ := strconv . ParseInt ( opev , 10 , 64 )
tarReportCont . ReportPerson = opevInt //上报人"`
if opev != "" {
var userCont modelshr . PersonArchives
userCont . GetCont ( map [ string ] interface { } { "`key`" : opev } , "maindeparment" )
tarReportCont . ManDepartment = userCont . MainDeparment //提报人所在部门"`
}
tarReportCont . Time = overTime //写入时间"`
tarReportCont . Class = v . Class //1:定性考核;2:定量考核"`
tarReportCont . Level = v . Type //类型(1:指标;2:子目标;3:细则)"`
tarReportContList = append ( tarReportContList , tarReportCont )
}
}
}
if len ( tarReportContList ) > 0 {
overall . CONSTANT_DB_KPI . Create ( & tarReportContList )
}
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 17 16 : 42 : 39
@ 功能 : 处理方案主体
@ 参数
# key 方案编号
# tarId 指标
# state 状态
# contStr 指标说明
@ 返回值
#
@ 方法原型
#
* /
func eitePlanVersion ( key string , tarId string , state int , contStr string ) {
var planVersioCont modelskpi . PlanVersio
err := planVersioCont . GetCont ( map [ string ] interface { } { "`key`" : key } )
var planContSave [ ] AddDutyNewCont
// fmt.Printf("Plan--------1----------->%v\n", planErr)
if err == nil {
if planVersioCont . Content != "" {
// fmt.Printf("Plan--------2----------->%v\n", planVersioCont)
var planCont [ ] AddDutyNewCont
jsonErrPlan := json . Unmarshal ( [ ] byte ( planVersioCont . Content ) , & planCont )
// fmt.Printf("Plan--------3----------->%v\n", jsonErrPlan)
if jsonErrPlan == nil {
for _ , v := range planCont {
var saveCont AddDutyNewCont
saveCont . Id = v . Id
saveCont . Name = v . Name
saveCont . ZhiFraction = v . ZhiFraction
for _ , cv := range v . Child {
var chidCont EvaluPross
if cv . Id == tarId {
chidCont . Id = cv . Id
chidCont . Name = cv . Name // `json:"name"`
chidCont . Content = contStr // `json:"content"` //指标说明
chidCont . Unit = cv . Unit // `json:"unit"` //单位"`
chidCont . ReferenceScore = cv . ReferenceScore // `json:"referencescore"` //标准分值"`
chidCont . Cycles = cv . Cycles // `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年"`
chidCont . CycleAttres = cv . CycleAttres // `json:"cycleattr"` //辅助计数"`
chidCont . State = state // `json:"state"`
chidCont . Score = cv . Score // `json:"score"` //分数
chidCont . QualEvalId = cv . QualEvalId // `json:"qeid"`
chidCont . Status = state // `json:"status"`
} else {
chidCont . Id = cv . Id
chidCont . Name = cv . Name // `json:"name"`
chidCont . Content = cv . Content // `json:"content"` //指标说明
chidCont . Unit = cv . Unit // `json:"unit"` //单位"`
chidCont . ReferenceScore = cv . ReferenceScore // `json:"referencescore"` //标准分值"`
chidCont . Cycles = cv . Cycles // `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年"`
chidCont . CycleAttres = cv . CycleAttres // `json:"cycleattr"` //辅助计数"`
chidCont . State = cv . State // `json:"state"`
chidCont . Score = cv . Score // `json:"score"` //分数
chidCont . QualEvalId = cv . QualEvalId // `json:"qeid"`
chidCont . Status = cv . Status // `json:"status"`
}
saveCont . Child = append ( saveCont . Child , chidCont )
}
planContSave = append ( planContSave , saveCont )
}
}
}
}
// fmt.Printf("Plan--------4----------->%v\n", len(planContSave))
if len ( planContSave ) > 0 {
planContInfo , planJsonErr := json . Marshal ( planContSave )
if planJsonErr == nil {
eitaData := publicmethod . MapOut [ string ] ( )
eitaData [ "content" ] = string ( planContInfo )
eitaData [ "eitetime" ] = time . Now ( ) . Unix ( )
overall . CONSTANT_DB_KPI . Model ( & modelskpi . PlanVersio { } ) . Where ( "`key` = ?" , key ) . Updates ( eitaData )
}
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 19 0 9 : 18 : 39
@ 功能 : 删除考核方案指标
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) DelSchemeTargetCont ( c * gin . Context ) {
var receivedValue DelSchemeContTarget
err := c . ShouldBindJSON ( & receivedValue )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if receivedValue . PlanVersionKey == "" {
publicmethod . Result ( 1 , err , c , "请输入版本号!" )
return
}
if receivedValue . TargetId == "" {
publicmethod . Result ( 1 , err , c , "请输入指标号!" )
return
}
if receivedValue . OrgId == "" {
publicmethod . Result ( 1 , err , c , "请输入行政组织!" )
return
}
eiteData := publicmethod . MapOut [ string ] ( )
eiteData [ "qe_eitetime" ] = time . Now ( ) . Unix ( )
eiteData [ "qe_state" ] = 3
err = overall . CONSTANT_DB_KPI . Model ( & modelskpi . QualitativeEvaluation { } ) . Where ( "`qe_state` = 1 AND `qe_qual_eval_id` = ? AND `qe_accept_evaluation` = ? AND `qe_target` = ?" , receivedValue . PlanVersionKey , receivedValue . OrgId , receivedValue . TargetId ) . Updates ( eiteData ) . Error
if err != nil {
publicmethod . Result ( 1 , err , c , "数据处理失败!" )
return
} else {
delPlanVersion ( receivedValue . PlanVersionKey , receivedValue . TargetId )
delOperatorPlanVersion ( receivedValue . OrgId , receivedValue . TargetId )
}
}
/ * *
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 19 0 9 : 27 : 02
@ 功能 : 软删除关联人
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
// 处理关联人
func delOperatorPlanVersion ( orgId , targetId string ) {
delWher := publicmethod . MapOut [ string ] ( )
delWher [ "target_id" ] = targetId
delWher [ "department_id" ] = orgId
delWher [ "type" ] = 1
var targetReportCont modelskpi . TargetReport
targetReportCont . DelCont ( delWher )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 19 0 9 : 24 : 21
@ 功能 : 删除方案指标
@ 参数
# key 方案编号
# tarId 指标
@ 返回值
#
@ 方法原型
#
* /
func delPlanVersion ( key string , tarId string ) {
var planVersioCont modelskpi . PlanVersio
err := planVersioCont . GetCont ( map [ string ] interface { } { "`key`" : key } )
var planContSave [ ] AddDutyNewCont
// fmt.Printf("Plan--------1----------->%v\n", planErr)
if err == nil {
if planVersioCont . Content != "" {
// fmt.Printf("Plan--------2----------->%v\n", planVersioCont)
var planCont [ ] AddDutyNewCont
jsonErrPlan := json . Unmarshal ( [ ] byte ( planVersioCont . Content ) , & planCont )
// fmt.Printf("Plan--------3----------->%v\n", jsonErrPlan)
if jsonErrPlan == nil {
for _ , v := range planCont {
var saveCont AddDutyNewCont
saveCont . Id = v . Id
saveCont . Name = v . Name
saveCont . ZhiFraction = v . ZhiFraction
for _ , cv := range v . Child {
var chidCont EvaluPross
if cv . Id != tarId {
chidCont . Id = cv . Id
chidCont . Name = cv . Name // `json:"name"`
chidCont . Content = cv . Content // `json:"content"` //指标说明
chidCont . Unit = cv . Unit // `json:"unit"` //单位"`
chidCont . ReferenceScore = cv . ReferenceScore // `json:"referencescore"` //标准分值"`
chidCont . Cycles = cv . Cycles // `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年"`
chidCont . CycleAttres = cv . CycleAttres // `json:"cycleattr"` //辅助计数"`
chidCont . State = cv . State // `json:"state"`
chidCont . Score = cv . Score // `json:"score"` //分数
chidCont . QualEvalId = cv . QualEvalId // `json:"qeid"`
chidCont . Status = cv . Status // `json:"status"`
}
saveCont . Child = append ( saveCont . Child , chidCont )
}
planContSave = append ( planContSave , saveCont )
}
}
}
}
// fmt.Printf("Plan--------4----------->%v\n", len(planContSave))
if len ( planContSave ) > 0 {
planContInfo , planJsonErr := json . Marshal ( planContSave )
if planJsonErr == nil {
eitaData := publicmethod . MapOut [ string ] ( )
eitaData [ "content" ] = string ( planContInfo )
eitaData [ "eitetime" ] = time . Now ( ) . Unix ( )
overall . CONSTANT_DB_KPI . Model ( & modelskpi . PlanVersio { } ) . Where ( "`key` = ?" , key ) . Updates ( eitaData )
}
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 19 10 : 15 : 39
@ 功能 : 获取复制方案详情
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GetCopySchemeCont ( 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 ( 1 , err , c , "未知版本号!" )
return
}
var oldSchemeCont modelskpi . PlanVersio
err = oldSchemeCont . GetCont ( map [ string ] interface { } { "`key`" : receivedValue . Id } )
if err != nil {
publicmethod . Result ( 105 , err , c )
return
}
var copyCont CopySchemeCont
copyCont . OrgId = strconv . FormatInt ( oldSchemeCont . Department , 10 )
copyCont . Year = fmt . Sprintf ( "%v" , oldSchemeCont . Year )
if oldSchemeCont . Content != "" {
var planCont [ ] AddDutyNewCont
jsonErrPlan := json . Unmarshal ( [ ] byte ( oldSchemeCont . Content ) , & planCont )
if jsonErrPlan == nil {
var copyInfoAry [ ] CopyDutyNewCont
for _ , v := range planCont {
var copyInfoXonr CopyDutyNewCont
copyInfoXonr . Id = v . Id //维度ID
copyInfoXonr . Name = v . Name
copyInfoXonr . ZhiFraction = v . ZhiFraction
var displayTargetId [ ] string
for _ , cv := range v . Child {
var copyEvalCont CopyEvaluPross
copyEvalCont . Id = cv . Id //`json:"id"` //指标ID
if publicmethod . IsInTrue [ string ] ( cv . Id , displayTargetId ) == false {
displayTargetId = append ( displayTargetId , cv . Id )
}
var tarGetContent modelskpi . EvaluationTarget
tarGetContentErr := tarGetContent . GetCont ( map [ string ] interface { } { "et_id" : cv . Id } , "et_title" )
if tarGetContentErr == nil {
copyEvalCont . Name = tarGetContent . Title
} else {
copyEvalCont . Name = cv . Name //`json:"name"`
}
copyEvalCont . Content = cv . Content //`json:"content"` //指标说明
copyEvalCont . Unit = cv . Unit //`json:"unit"` //单位"`
copyEvalCont . ReferenceScore = cv . ReferenceScore //`json:"referencescore"` //标准分值"`
if cv . Status == 0 {
copyEvalCont . State = 2
} else {
copyEvalCont . State = cv . Status //`json:"state"`
}
copyEvalCont . Istrue = 2 //`json:"istrue"` //是否允许修改
copyInfoXonr . Child = append ( copyInfoXonr . Child , copyEvalCont )
}
byTargetList , _ := HaveDepartBaseTarget ( displayTargetId , oldSchemeCont . Department , 1 )
if len ( byTargetList ) > 0 {
for _ , cecfv := range byTargetList {
var copyEvalCont CopyEvaluPross
copyEvalCont . Id = cecfv . Id
copyEvalCont . Name = cecfv . Name
copyEvalCont . Content = cecfv . Content
copyEvalCont . Unit = cecfv . Unit
copyEvalCont . ReferenceScore = 0
copyEvalCont . State = cecfv . State
copyEvalCont . Istrue = cecfv . IsTrue
copyInfoXonr . Child = append ( copyInfoXonr . Child , copyEvalCont )
}
}
copyInfoAry = append ( copyInfoAry , copyInfoXonr )
}
copyCont . Child = copyInfoAry
}
}
publicmethod . Result ( 0 , copyCont , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 19 13 : 23 : 59
@ 功能 : 获取部门管理的指标
@ 参数
# targetId 指标ID
# orgId 行政组织
# attribute 类型 ( 1 : 指标 ; 2 : 子目标 ; 3 : 细则 )
# level 级别 ( 1 : 部门级 ; 2 : 岗位级 )
@ 返回值
#
@ 方法原型
#
* /
func HaveDepartBaseTarget ( targetId [ ] string , orgId int64 , level int ) ( contAry [ ] DepartTargetList , err error ) {
var targetIdList [ ] int64
gormDb := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`target_id`" ) . Where ( "`state` = 1 AND `level` = ? AND `department_id` = ?" , level , orgId )
if len ( targetId ) > 0 {
gormDb = gormDb . Not ( map [ string ] interface { } { "target_id" : targetId } )
}
err = gormDb . Find ( & targetIdList ) . Error
if err != nil || len ( targetIdList ) < 1 {
return
}
var targetListCont [ ] modelskpi . EvaluationTarget
err = overall . CONSTANT_DB_KPI . Where ( "`et_state` = 1 AND `et_id` IN ?" , targetIdList ) . Find ( & targetListCont ) . Error
if err != nil || len ( targetListCont ) < 1 {
return
}
for _ , e_v := range targetListCont {
var cont DepartTargetList
cont . Id = strconv . FormatInt ( e_v . Id , 10 )
cont . Name = e_v . Title
cont . Content = ""
cont . Unit = e_v . Uniteing
cont . State = e_v . State
cont . ReferenceScore = 0
cont . IsTrue = 2
contAry = append ( contAry , cont )
}
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 04 - 19 15 : 12 : 26
@ 功能 : 获取新增方案内容方案详情
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) GetAddSchemeCont ( 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 ( 1 , err , c , "未知行政组织!" )
return
}
var targetIdList [ ] int64
gormDb := overall . CONSTANT_DB_KPI . Model ( & modelskpi . TargetDepartment { } ) . Distinct ( "`target_id`" ) . Where ( "`state` = 1 AND `level` = 1 AND `department_id` = ?" , receivedValue . Id )
err = gormDb . Find ( & targetIdList ) . Error
if err != nil || len ( targetIdList ) < 1 {
return
}
var targetListCont [ ] modelskpi . EvaluationTarget
err = overall . CONSTANT_DB_KPI . Where ( "`et_state` = 1 AND `et_id` IN ?" , targetIdList ) . Find ( & targetListCont ) . Error
if err != nil || len ( targetListCont ) < 1 {
return
}
var dimensionId [ ] int64
var dimListInfo [ ] dimListCont
var tagetList [ ] targetListInfo
for _ , e_v := range targetListCont {
if ! publicmethod . IsInTrue [ int64 ] ( e_v . Dimension , dimensionId ) {
dimensionId = append ( dimensionId , e_v . Dimension )
var dimInfo modelskpi . DutyClass
dimInfo . GetCont ( map [ string ] interface { } { "`id`" : e_v . Dimension } , "`title`" )
var dimCont dimListCont
dimCont . Id = strconv . FormatInt ( e_v . Dimension , 10 )
dimCont . Name = dimInfo . Title
dimListInfo = append ( dimListInfo , dimCont )
}
var tarCont targetListInfo
tarCont . Id = strconv . FormatInt ( e_v . Id , 10 )
tarCont . Name = e_v . Title
tarCont . Dimension = strconv . FormatInt ( e_v . Dimension , 10 )
tagetList = append ( tagetList , tarCont )
}
if len ( dimListInfo ) < 1 {
publicmethod . Result ( 105 , err , c )
return
}
var schemeInfo [ ] outNewScheme
for _ , v := range dimListInfo {
var schemeCont outNewScheme
schemeCont . Id = v . Id
schemeCont . Name = v . Name
if len ( tagetList ) > 0 {
var sunCont [ ] outNewSchemeTar
for _ , sv := range tagetList {
if sv . Dimension == v . Id {
var sunInfo outNewSchemeTar
sunInfo . Id = sv . Id
sunInfo . Name = sv . Name
sunCont = append ( sunCont , sunInfo )
}
}
if len ( sunCont ) > 0 {
schemeCont . Child = sunCont
}
}
schemeInfo = append ( schemeInfo , schemeCont )
}
publicmethod . Result ( 0 , schemeInfo , c )
}