diff --git a/api/version1/departmentseting/departmentpc/qualitativekpi.go b/api/version1/departmentseting/departmentpc/qualitativekpi.go index 42e76a3..c157af9 100644 --- a/api/version1/departmentseting/departmentpc/qualitativekpi.go +++ b/api/version1/departmentseting/departmentpc/qualitativekpi.go @@ -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) +} diff --git a/api/version1/departmentseting/departmentpc/type.go b/api/version1/departmentseting/departmentpc/type.go index 0530f7f..fa4f8a1 100644 --- a/api/version1/departmentseting/departmentpc/type.go +++ b/api/version1/departmentseting/departmentpc/type.go @@ -184,3 +184,15 @@ type printOneTargetCont struct { publicmethod.PublicId addTargetContDepart } + +// 部门指标关联岗位 +type depTarAboutPost struct { + publicmethod.PublicId + OrgList []loopStruct `json:"orglist"` +} + +// 循环体 +type loopStruct struct { + publicmethod.PublicId + Child []loopStruct `json:"child"` +} diff --git a/api/version1/postseting/postpc/scheme.go b/api/version1/postseting/postpc/scheme.go index 5b159bc..b472e3d 100644 --- a/api/version1/postseting/postpc/scheme.go +++ b/api/version1/postseting/postpc/scheme.go @@ -1,6 +1,7 @@ package postpc import ( + "encoding/json" "fmt" "key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelskpi" @@ -76,11 +77,11 @@ func (p *postDimeTarSync) GetPostTargent(position modelshr.Position, dutyClass m var targetCont postAboutTarget 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) //标准分 - targetCont.Unit = v.Unit //单位 - targetCont.IsTrue = 2 //是否允许修改 1:不允许;2:允许 - targetCont.State = 1 //状态 1:启用;2:禁用;3:观察 + targetCont.Content = "" //指标描述 + targetCont.StandardScore = getPostDimeTarWeight(position.AdministrativeOrganization, position.Id, dutyClass.Id, v.Id, 1, 1) //标准分 + targetCont.Unit = v.Unit //单位 + targetCont.IsTrue = 2 //是否允许修改 1:不允许;2:允许 + targetCont.State = 1 //状态 1:启用;2:禁用;3:观察 planCont.Child = append(planCont.Child, targetCont) } @@ -96,16 +97,179 @@ func (p *postDimeTarSync) GetPostTargent(position modelshr.Position, dutyClass m @dimensionid 维度 @targetid 指标 @hierarchy 1:维度;2:指标 +@isQuote 1:不是引用;2:引用部门 +getPostDimeTarWeight(orgid, postid, dimensionid, targetid int64, hierarchy, isQuote int) */ -func getPostDimeTarWeight(orgid, postid, dimensionid, targetid int64, hierarchy int) int64 { +func getPostDimeTarWeight(orgid, postid, dimensionid, targetid int64, hierarchy, isQuote int) int64 { if hierarchy == 0 { hierarchy = 2 } + where := publicmethod.MapOut[string]() + where["orgid"] = orgid + where["postid"] = postid + where["dimension"] = dimensionid var ddpwCont modelskpi.DepartDimePostWeight if hierarchy == 1 { - ddpwCont.GetCont(map[string]interface{}{"orgid": orgid, "postid": postid, "dimension": dimensionid, "hierarchy": 1}, "`weight`") + where["hierarchy"] = 1 + // ddpwCont.GetCont(map[string]interface{}{"orgid": orgid, "postid": postid, "dimension": dimensionid, "hierarchy": 1}, "`weight`") + ddpwCont.GetCont(where, "`weight`") } else { - ddpwCont.GetCont(map[string]interface{}{"orgid": orgid, "postid": postid, "dimension": dimensionid, "target": targetid, "hierarchy": 2}, "`weight`") + where["target"] = targetid + where["hierarchy"] = 2 + // ddpwCont.GetCont(map[string]interface{}{"orgid": orgid, "postid": postid, "dimension": dimensionid, "target": targetid, "hierarchy": 2}, "`weight`") + ddpwCont.GetCont(where, "`weight`") } return ddpwCont.Weight } + +// 引用指标部门指标 +func (a *ApiMethod) QuoteDepartmentTarget(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, err, c) + return + } + //获取维度 + var dimenId []int64 + err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`dimension_id`").Where("`state` = 1 AND `level` = 2 AND `post_id` = ?", receivedValue.Id).Find(&dimenId).Error + if err != nil || len(dimenId) < 1 { + publicmethod.Result(107, err, c) + return + } + var targetlist postDimeTarSync + //获取指标列表 + for _, v := range dimenId { + syncSeting.Add(1) + go targetlist.getPostQuoteDepartmentTarget(v, receivedValue.Id) + } + syncSeting.Wait() + planAry := targetlist.readDataLock() //读取线程通道数据 + if len(planAry) < 1 { + publicmethod.Result(1, planAry, c, "该岗位没有设定部门指标引入项!") + return + } + //根据维度序号排序 + sort.Slice(planAry, func(i, j int) bool { + return planAry[i].Sort < planAry[j].Sort + }) + publicmethod.Result(0, planAry, c) +} + +/* +获取岗位引入部门指标的列表 +@dimensionId 维度 +@postId 岗位 +*/ +func (p *postDimeTarSync) getPostQuoteDepartmentTarget(dimensionId int64, postId string) { + p.mutext.Lock() + defer p.mutext.Unlock() + + var listCont postAboutDimeTar + //获取维度信息 + var dimenCont modelskpi.DutyClass + dimenCont.GetCont(map[string]interface{}{"`id`": dimensionId}, "`title`", `sort`) + listCont.Id = strconv.FormatInt(dimensionId, 10) + listCont.Name = dimenCont.Title + listCont.Sort = dimenCont.Sort + //获取岗位信息 + var postCont modelshr.Position + postCont.GetCont(map[string]interface{}{"`id`": postId}, "`id`", "`administrative_organization`") + + var targetId []int64 + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`target_id`").Where("`state` = 1 AND `level` = 2 AND `dimension_id` = ? AND `post_id` = ?", dimensionId, postId).Find(&targetId) + if len(targetId) > 0 { + //获取指标信息 + var targetList []modelskpi.EvaluationTarget + overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationTarget{}).Where("`et_state` = 1 AND `et_id` IN ?", targetId).Find(&targetList) + if len(targetList) > 0 { + for _, v := range targetList { + var targetCont postAboutTarget + targetCont.Id = strconv.FormatInt(v.Id, 10) + targetCont.Name = v.Title + targetCont.Content = "" //指标描述 + targetCont.StandardScore = getPostDimeTarWeight(postCont.AdministrativeOrganization, postCont.Id, dimensionId, v.Id, 2, 2) //标准分 + targetCont.Unit = v.Uniteing //单位 + targetCont.IsTrue = 2 //是否允许修改 1:不允许;2:允许 + targetCont.State = 1 //状态 1:启用;2:禁用;3:观察 + targetCont.Type = v.Type + if v.Type == 1 { + detaildList := getQuoteTargetDepartList(dimensionId, v.Id, postCont.Id) + if len(detaildList) > 0 { + targetCont.Child = detaildList + listCont.Child = append(listCont.Child, targetCont) + } + } else { + listCont.Child = append(listCont.Child, targetCont) + } + + } + + } + + } + if len(listCont.Child) > 0 { + p.planList = append(p.planList, listCont) + } + + jsonStr, _ := json.Marshal(listCont) + fmt.Printf("jsonStr------->%v\n", string(jsonStr)) + syncSeting.Done() +} + +// 获取部门引用关联指标细则 +func getQuoteTargetDepartList(dimensionId, targetId, postId int64) (listCont []quoteDeatinDeparment) { + var detaildId []int64 + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`target_bylaws`").Where("`state` = 1 AND `level` = 2 AND `dimension_id` = ? AND `target_id` = ? AND `post_id` = ? AND `target_bylaws` <> 0", dimensionId, targetId, postId).Find(&detaildId) + if len(detaildId) < 1 { + return + } + var detaildList []modelskpi.DetailedTarget + overall.CONSTANT_DB_KPI.Model(&modelskpi.DetailedTarget{}).Select("`dt_id`,`dt_title`,`dt_content`,`dt_min_score`,`dt_max_score`").Where("`dt_state` = 1 AND `dt_id` IN ?", detaildId).Find(&detaildList) + if len(detaildList) < 1 { + return + } + for _, v := range detaildList { + var contList quoteDeatinDeparment + contList.Id = strconv.FormatInt(v.Id, 10) + contList.Name = v.Title + biaoZhun := "" + if v.MinScore != 0 { + biaoZhun = fmt.Sprintf("%v-%v", v.MinScore, v.MaxScore) + } else { + biaoZhun = fmt.Sprintf("%v", v.MaxScore) + } + contList.ReferenceScore = biaoZhun + listCont = append(listCont, contList) + } + fmt.Println("----------------->") + return +} + +// 提交岗位考核方案 +func (a *ApiMethod) SubmitPostScheme(c *gin.Context) { + var receivedValue postScheme + c.ShouldBindJSON(&receivedValue) + if receivedValue.OrgId == "" { + publicmethod.Result(101, receivedValue.OrgId, c, "请指定行政组织ID") + return + } + if receivedValue.PostId == "" { + publicmethod.Result(101, receivedValue.PostId, c, "请指定行政组织ID") + return + } + if receivedValue.Year == "" { + publicmethod.Result(101, receivedValue.Year, c, "请指定方案属于哪一年的?") + return + } + if len(receivedValue.PostChild) < 1 && len(receivedValue.DepartmentChild) < 1 { + publicmethod.Result(1, receivedValue, c, "考核项目不能为空!") + return + } + jsonCont, _ := json.Marshal(receivedValue) + publicmethod.Result(0, string(jsonCont), c) +} diff --git a/api/version1/postseting/postpc/type.go b/api/version1/postseting/postpc/type.go index 953fffc..a458242 100644 --- a/api/version1/postseting/postpc/type.go +++ b/api/version1/postseting/postpc/type.go @@ -35,12 +35,14 @@ func (a *ApiMethod) Index(c *gin.Context) { // 获取岗位相关指标 type postAboutTarget struct { publicmethod.PublicId - publicmethod.PublicName //指标名称 - Content string `json:"content"` //指标描述 - StandardScore int64 `json:"standardscore"` //标准分 - Unit string `json:"unit"` //单位 - IsTrue int `json:"istrue"` //是否允许修改 1:不允许;2:允许 - State int `json:"state"` //状态 1:启用;2:禁用;3:观察 + publicmethod.PublicName //指标名称 + Content string `json:"content"` //指标描述 + StandardScore int64 `json:"standardscore"` //标准分 + Unit string `json:"unit"` //单位 + IsTrue int `json:"istrue"` //是否允许修改 1:不允许;2:允许 + State int `json:"state"` //状态 1:启用;2:禁用;3:观察 + Type int `json:"type"` //1:定性考核;2:定量考核 + Child []quoteDeatinDeparment `json:"child"` //指标细则列表 } // 岗位相关维度指标列表 @@ -50,3 +52,46 @@ type postAboutDimeTar struct { Sort int `json:"sort"` //排序 Child []postAboutTarget `json:"child"` //指标列表 } + +// 引用部门定性考核细则列表 +type quoteDeatinDeparment struct { + publicmethod.PublicId + publicmethod.PublicName //细则 + ReferenceScore string `json:"referencescore"` //考核标准 +} + +// 岗位考核方案 +type postScheme struct { + OrgId string `json:"orgid"` //行政组织ID + PostId string `json:"postid"` //岗位 + Year string `json:"year"` //年 + PostChild []schemeStructure `json:"postchild"` //岗位指标 + DepartmentChild []schemeStructure `json:"departmentchild"` //引用部门指标 +} + +// 方案结构体 维度 +type schemeStructure struct { + publicmethod.PublicId //id + publicmethod.PublicName //名称 + Score float64 `json:"score"` //分数 + Child []schemeTargetStructure `json:"child"` //指标列表 +} + +// 方案中的指标 +type schemeTargetStructure struct { + publicmethod.PublicId //id + publicmethod.PublicName //名称 + Content string `json:"content"` //说明 + Score float64 `json:"score"` //分数 + State int `json:"state"` //状态:1:启用;2:禁用;3:观察 + Type int `json:"type"` //1、定性指标;2、定量指标 + Child []schemeDetailedStructure `json:"child"` //指标细则列表 +} + +// 方案中的定性指标细则 +type schemeDetailedStructure struct { + publicmethod.PublicId //id + publicmethod.PublicName //名称 + ReferenceScore string `json:"referencescore"` //考核标准 + State int `json:"state"` //状态:1:启用;2:禁用;3:观察 +} diff --git a/apirouter/v1/departmentseting/pc.go b/apirouter/v1/departmentseting/pc.go index 35eaa9b..35365a7 100644 --- a/apirouter/v1/departmentseting/pc.go +++ b/apirouter/v1/departmentseting/pc.go @@ -36,5 +36,10 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("add_department_target", methodBinding.AddDepartmentTarget) //添加部门指标 apiRouter.POST("get_one_terget_info", methodBinding.GetOneTergetInfo) //获取单一指标详细内容 + apiRouter.POST("edit_one_target", methodBinding.EditOneTarget) //编辑单一部门指标 + + apiRouter.POST("deparment_target_about_post", methodBinding.DeparmentTargetAboutPost) //指标关联岗位 + apiRouter.POST("depar_son_target_about_post", methodBinding.DeparSonTargetAboutPost) //子栏目关联部门岗位 + apiRouter.POST("depar_detaile_about_post", methodBinding.DeparDetaileAboutPost) //指标细则关联部门岗位 } } diff --git a/apirouter/v1/postseting/pc.go b/apirouter/v1/postseting/pc.go index b44db95..6a31f72 100644 --- a/apirouter/v1/postseting/pc.go +++ b/apirouter/v1/postseting/pc.go @@ -12,9 +12,10 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { var methodBinding = version1.AppApiEntry.PostPcApi { - apiRouter.GET("", methodBinding.Index) //入口 - apiRouter.POST("", methodBinding.Index) //入口 - apiRouter.POST("getpostabouttarget", methodBinding.GetPostAboutTarget) //获取岗位相关指标 - + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + apiRouter.POST("getpostabouttarget", methodBinding.GetPostAboutTarget) //获取岗位相关指标 + apiRouter.POST("quote_department_target", methodBinding.QuoteDepartmentTarget) //引用指标部门指标 + apiRouter.POST("submit_post_scheme", methodBinding.SubmitPostScheme) //提交岗位考核方案 } } diff --git a/models/modelskpi/depart_dime_post_weight.go b/models/modelskpi/depart_dime_post_weight.go index 72036f8..aa66e4e 100644 --- a/models/modelskpi/depart_dime_post_weight.go +++ b/models/modelskpi/depart_dime_post_weight.go @@ -16,6 +16,7 @@ type DepartDimePostWeight struct { Weight int64 `json:"weight" gorm:"column:weight;type:int(6) unsigned;default:0;not null;comment:权重"` Addtime int64 `json:"addtime" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:添加时间"` Hierarchy int64 `json:"hierarchy" gorm:"column:hierarchy;type:bigint(20) unsigned;default:0;not null;comment:维度;2:指标"` + Quote int64 `json:"quote" gorm:"column:is_quote;type:bigint(20) unsigned;default:0;not null;comment:1:不是引用;2:引用部门"` } func (DepartDimePostWeight *DepartDimePostWeight) TableName() string { diff --git a/models/modelskpi/target_department.go b/models/modelskpi/target_department.go index 07472ca..5a13724 100644 --- a/models/modelskpi/target_department.go +++ b/models/modelskpi/target_department.go @@ -8,6 +8,7 @@ import ( // 指标、栏目、细则关联部门 type TargetDepartment struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"` + Dimension int64 `json:"dimension" gorm:"column:dimension_id;type:bigint(20) unsigned;default:0;not null;comment:维度"` TargetId int64 `json:"targetid" gorm:"column:target_id;type:bigint(20) unsigned;default:0;not null;comment:指标ID"` TargetSunId int64 `json:"targetsunid" gorm:"column:target_sun_id;type:bigint(20) unsigned;default:0;not null;comment:子目标"` TargetBylaws int64 `json:"targetbylaws" gorm:"column:target_bylaws;type:bigint(20) unsigned;default:0;not null;comment:指标细则"` @@ -16,7 +17,7 @@ type TargetDepartment struct { PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:岗位ID"` State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` - Class int `json:"class" gorm:"column:type;class:tinyint(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` + Class int `json:"class" gorm:"column:class;type:tinyint(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` Level int `json:"level" gorm:"column:level;type:tinyint(1) unsigned;default:1;not null;comment:级别(1:部门级;2:岗位级)"` } diff --git a/models/modelskpi/target_report.go b/models/modelskpi/target_report.go index 9492892..6fbcc41 100644 --- a/models/modelskpi/target_report.go +++ b/models/modelskpi/target_report.go @@ -8,6 +8,7 @@ import ( // 指标部门、岗位上报人对照表 type TargetReport struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"` + Dimension int64 `json:"dimension" gorm:"column:dimension_id;type:bigint(20) unsigned;default:0;not null;comment:维度"` TargetId int64 `json:"targetid" gorm:"column:target_id;type:bigint(20) unsigned;default:0;not null;comment:指标ID"` TargetSunId int64 `json:"targetsunid" gorm:"column:target_sun_id;type:bigint(20) unsigned;default:0;not null;comment:子目标"` TargetBylaws int64 `json:"targetbylaws" gorm:"column:target_bylaws;type:bigint(20) unsigned;default:0;not null;comment:指标细则"` @@ -18,7 +19,7 @@ type TargetReport struct { ReportPerson int64 `json:"reportperson" gorm:"column:man_key;type:bigint(20) unsigned;default:0;not null;comment:上报人"` ManDepartment int64 `json:"mandepartment" gorm:"column:man_department;type:bigint(20) unsigned;default:0;not null;comment:提报人所在部门"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` - Class int `json:"class" gorm:"column:type;class:tinyint(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` + Class int `json:"class" gorm:"column:class;type:tinyint(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` Level int `json:"level" gorm:"column:type_level;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:指标;2:子目标;3:细则)"` } diff --git a/overall/publicmethod/formatOutput.go b/overall/publicmethod/formatOutput.go index e2f5d67..d37ef88 100644 --- a/overall/publicmethod/formatOutput.go +++ b/overall/publicmethod/formatOutput.go @@ -19,7 +19,12 @@ func Result(code int, data interface{}, c *gin.Context, msgAry ...string) { } if len(msgAry) > 0 { for _, v := range msgAry { - msg = fmt.Sprintf("%v。%v", msg, v) + if msg == "" { + msg = fmt.Sprintf("%v", v) + } else { + msg = fmt.Sprintf("%v。%v", msg, v) + } + } } c.JSON(http.StatusOK, Reply{code, msg, data}) //输出json格式数据