diff --git a/README.md b/README.md index 9528316..5ec132b 100644 --- a/README.md +++ b/README.md @@ -102,4 +102,54 @@ CREATE TABLE `target_department` ( 添加 model 文件 路径 models->modelskpi target_department.go +``` + +``` +Time:2022-08-12 +指标部门、岗位上报人对照表 + +CREATE TABLE `target_report` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `target_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标ID', + `target_sun_id` bigint(20) unsigned NOT NULL COMMENT '子目标', + `target_bylaws` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标细则', + `department_id` bigint(20) unsigned DEFAULT '0' COMMENT '部门ID', + `post_id` bigint(20) unsigned DEFAULT '0' COMMENT '岗位ID', + `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '类型(1:公司级;2:部门级)', + `state` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用;2:禁用;3:删除)', + `man_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '提报人ID', + `time` bigint(20) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='指标、子栏目、细则部门、岗位上报人对照表'; + +``` + + +``` +Time:2022-08-16 +创建子栏目关联指标视图 son_target_father + +select `qt`.`q_id` AS `q_id`,`qt`.`q_title` AS `q_title`,`qt`.`q_parent_id` AS `q_parent_id`,`qt`.`q_state` AS `q_state`,`qt`.`q_time` AS `q_time`,`qt`.`q_depart` AS `q_depart`,`et`.`et_title` AS `et_title`,`et`.`et_type` AS `et_type`,`et`.`et_dimension` AS `et_dimension`,`et`.`et_key` AS `et_key`,`et`.`et_unit` AS `et_unit`,`et`.`et_cycle` AS `et_cycle`,`et`.`et_cycleattr` AS `et_cycleattr`,`et`.`et_scoring_method` AS `et_scoring_method` from (`qualitative_target` `qt` left join `evaluationtarget` `et` on((`qt`.`q_parent_id` = `et`.`et_id`))) + +创建用户与职务、岗位关联视图 user_post_duties (HR数据库) + +select `pc`.`mobilephone` AS `mobilephone`,`pc`.`gender` AS `gender`,`ps`.`name` AS `postname`,`ps`.`person_in_charge` AS `leading_cadre`,`ps`.`superior` AS `post_superior`,`ps`.`menu_permit` AS `menu_permit`,`ps`.`button_permit` AS `button_permit`,`pd`.`name` AS `duties_name`,`pa`.`id` AS `id`,`pa`.`number` AS `number`,`pa`.`name` AS `name`,`pa`.`icon` AS `icon`,`pa`.`company` AS `company`,`pa`.`maindeparment` AS `maindeparment`,`pa`.`admin_org` AS `admin_org`,`pa`.`position` AS `position`,`pa`.`job_id` AS `job_id`,`pa`.`job_leve` AS `job_leve`,`pa`.`wechat` AS `wechat`,`pa`.`work_wechat` AS `work_wechat`,`pa`.`is_admin` AS `is_admin`,`pa`.`key` AS `key`,`pa`.`role` AS `role`,`pa`.`password` AS `password`,`pa`.`sun_main_deparment` AS `sun_main_deparment`,`pa`.`teamid` AS `teamid` from (((`person_archives` `pa` join `personnel_content` `pc` on((`pa`.`key` = `pc`.`key`))) join `position` `ps` on((`pa`.`position` = `ps`.`id`))) join `duties` `pd` on((`pa`.`job_id` = `pd`.`id`))) + +``` + + +Time:2022-08-16
+埋坑(1) 待以后编写相应模块 PS:该问题解决后删除此记录 +
+ +``` + +F:\goobject\src\key_performance_indicators\api\version1\departmentseting\departmentpc\qualitativekpi.go + +函数 DelSonTarget + +文件 第 1138 行 + +预留判断该指标是否在使用中 + ``` \ No newline at end of file diff --git a/api/version1/departmentseting/departmentpc/qualitativekpi.go b/api/version1/departmentseting/departmentpc/qualitativekpi.go index 7426d05..ae8e0c5 100644 --- a/api/version1/departmentseting/departmentpc/qualitativekpi.go +++ b/api/version1/departmentseting/departmentpc/qualitativekpi.go @@ -1,6 +1,7 @@ package departmentpc import ( + "encoding/json" "fmt" "key_performance_indicators/models/modelshr" "key_performance_indicators/models/modelskpi" @@ -143,6 +144,61 @@ func xiaoZhengBuMen(detaTar modelskpi.DetailedTarget) { zbLmXzBm(detaTar.ParentId, detaTar.ParentIdSun, detaTar.Id, 3, v) } } + + } + + var assTar modelskpi.Assesstarget + assErr := overall.CONSTANT_DB_KPI.Where("`targetid` = ? AND `suntargetid` = ?", detaTar.ParentId, detaTar.ParentIdSun).First(&assTar).Error + if assErr == nil { + var reportAry []zhuanHuanMan + jsonErr := json.Unmarshal([]byte(assTar.Content), &reportAry) + if jsonErr == nil { + for _, mv := range reportAry { + if mv.Id == detaTar.Id { + if len(mv.Operator) > 0 { + for _, ov := range mv.Operator { + juadgeReport(detaTar.ParentId, detaTar.ParentIdSun, detaTar.Id, 1, ov) + } + } + } + } + } + } +} + +// 判断该指标细则是否已经存在上报人 +/* +@tarId 指标 +@sunId 栏目 +@lawsId 细则 +@class 类型(1:指标;2:子目标;3:细则) +@manKey 上报人 +*/ +func juadgeReport(tarId, sunId, lawsId int64, class int, manKey string) { + if class == 0 { + class = 1 + } + var trCont modelskpi.TargetReport + err := trCont.GetCont(map[string]interface{}{`type`: class, `target_id`: tarId, `target_sun_id`: sunId, `target_bylaws`: lawsId, `man_key`: manKey}) + if err == nil { + if trCont.State != 1 { + saveErr := trCont.EiteCont(map[string]interface{}{"`id`": trCont.Id}, map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()}) + fmt.Printf("编辑---->tarId----%v---->sunId----%v---->lawsId----%v---->class----%v---->bumenId----%v------>saveErr----->%v\n", tarId, sunId, lawsId, class, manKey, saveErr) + } + } else { + trCont.TargetId = tarId //指标ID"` + trCont.TargetSunId = sunId //子目标"` + trCont.TargetBylaws = lawsId //指标细则"` + trCont.DepartmentId = 0 //部门ID"` + trCont.PostId = 0 //岗位ID"` + trCont.Type = class //类型(1:公司级;2:部门级)"` + trCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` + manKeyInt, _ := strconv.ParseInt(manKey, 10, 64) + trCont.ReportPerson = manKeyInt //上报人"` + trCont.Time = time.Now().Unix() + trCont.Class = 1 + addErr := overall.CONSTANT_DB_KPI.Create(&trCont).Error + fmt.Printf("编辑---->tarId----%v---->sunId----%v---->lawsId----%v---->class----%v---->bumenId----%v------>saveErr----->%v\n", tarId, sunId, lawsId, class, manKey, addErr) } } @@ -179,9 +235,9 @@ func zbLmXzBm(tarId, sunId, lawsId int64, class int, bumenId string) { bumenIdInt, _ := strconv.ParseInt(bumenId, 10, 64) tarDepCont.DepartmentId = bumenIdInt //部门ID"` tarDepCont.PostId = 0 //岗位ID"` - tarDepCont.ReportPerson = "" //上报人"` tarDepCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` tarDepCont.Time = time.Now().Unix() //写入时间"` + tarDepCont.Class = 1 addErr := overall.CONSTANT_DB_KPI.Create(&tarDepCont).Error fmt.Printf("编辑---->tarId----%v---->sunId----%v---->lawsId----%v---->class----%v---->bumenId----%v------>saveErr----->%v\n", tarId, sunId, lawsId, class, bumenId, addErr) } @@ -196,7 +252,7 @@ func (a *ApiMethod) GetDepartAboutTarget(c *gin.Context) { return } var targetDepartmentID []int64 - disrErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`department_id`").Where("`state` = 1 AND `target_id` = ?", receivedValue.Id).Find(&targetDepartmentID).Error + disrErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`department_id`").Where("`state` = 1 AND `level` = 1 AND `target_id` = ?", receivedValue.Id).Find(&targetDepartmentID).Error if disrErr != nil { publicmethod.Result(107, err, c) return @@ -218,3 +274,929 @@ func (a *ApiMethod) GetDepartAboutTarget(c *gin.Context) { } publicmethod.Result(0, outList, c) } + +// 获取部门指标相关执行人 +func (a *ApiMethod) GetTargetReport(c *gin.Context) { + var receivedValue getAboutReportTarget + c.ShouldBindJSON(&receivedValue) + if receivedValue.TargetId == "" { + publicmethod.Result(1, receivedValue, c, "指标不能为空!") + return + } + var userKey []int64 + typeClass := 1 + if receivedValue.DepartmentId != "" || receivedValue.PostId != "" { + typeClass = 2 + } + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("`man_key`").Where("`state` = ? AND `type` = ? AND `target_id` = ?", 1, typeClass, receivedValue.TargetId) + + if receivedValue.TargetSunId != "" { + gormDb = gormDb.Where("`target_sun_id` = ?", receivedValue.TargetSunId) + } + if receivedValue.TargetBylaws != "" { + gormDb = gormDb.Where("`target_bylaws` = ?", receivedValue.TargetBylaws) + } + if receivedValue.DepartmentId != "" { + gormDb = gormDb.Where("`department_id` = ?", receivedValue.DepartmentId) + } + if receivedValue.PostId != "" { + gormDb = gormDb.Where("`post_id` = ?", receivedValue.PostId) + } + err := gormDb.Find(&userKey).Error + if err != nil || len(userKey) < 1 { + publicmethod.Result(107, err, c) + return + } + //上报人信息 + var reportManList []modelshr.PersonArchives + rmlErr := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`number`,`name`,`icon`,`company`,`maindeparment`").Where("`key` IN ?", userKey).Find(&reportManList).Error + if rmlErr != nil && len(reportManList) < 1 { + publicmethod.Result(107, err, c) + return + } + var reportListCont []printReportCont + for _, v := range reportManList { + var reportCont printReportCont + reportCont.Id = strconv.FormatInt(v.Id, 10) + reportCont.Name = v.Name + var groupConb modelshr.AdministrativeOrganization + groupConb.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") + reportCont.GroupName = groupConb.Name + var departmentConb modelshr.AdministrativeOrganization + departmentConb.GetCont(map[string]interface{}{"`id`": v.MainDeparment}, "`name`") + reportCont.DepartmentName = departmentConb.Name + reportCont.Icon = v.Icon + reportCont.Number = v.Number + reportListCont = append(reportListCont, reportCont) + } + outData := publicmethod.MapOut[string]() + outData["userlist"] = userKey + outData["userlistary"] = reportListCont + publicmethod.Result(0, outData, c) +} + +// 添加定性考核子栏目及细则 +func (a *ApiMethod) AddSunTargetDetailed(c *gin.Context) { + var receivedValue AddQualEval + c.ShouldBindJSON(&receivedValue) + if len(receivedValue.AcceptDepartmentId) <= 0 { + publicmethod.Result(1, receivedValue, c, "请选择接受考核的部门!") + return + } + if receivedValue.Target == "" { + publicmethod.Result(1, receivedValue, c, "请选择考核指标") + return + } + if receivedValue.TargetSunTitle == "" { + publicmethod.Result(1, receivedValue, c, "请输入栏目名称!") + return + } + if len(receivedValue.EvaluationList) <= 0 { + publicmethod.Result(1, receivedValue, c, "请添加测评详情!") + return + } else { + isWrite := true + for _, jv := range receivedValue.EvaluationList { + if jv.Title == "" || jv.Unit == "" || jv.ReferenceScore == "" { + isWrite = false + } + } + if isWrite == false { + publicmethod.Result(1, receivedValue, c, "指标细则有为填写的内容!请检查!") + return + } + } + tragetId, _ := strconv.ParseInt(receivedValue.Target, 10, 64) + //判断子目标是否存在 + var judgeSunTarget modelskpi.QualitativeTarget + saveSunTarget := modelskpi.QualitativeTarget{ + Title: receivedValue.TargetSunTitle, // 指标子栏目名称 + ParentId: tragetId, //归属指标 + State: 1, //状态(1:启用;2:禁用;3:删除) + AddTime: time.Now().Unix(), //制定时间"` + Depart: strings.Join(receivedValue.AcceptDepartmentId, ","), //关联部门"` + } + judgeSunTarErr := judgeSunTarget.JudgeIsTrue(map[string]interface{}{"q_title": receivedValue.TargetSunTitle, "q_parent_id": receivedValue.Target}, saveSunTarget) + if judgeSunTarErr != nil { + publicmethod.Result(106, judgeSunTarErr, c) + return + } + //子表细则处理 + + for _, v := range receivedValue.EvaluationList { + //判断指标细则是否已经存在 + var judgeDetaCont modelskpi.DetailedTarget + judgeDetaErr := judgeDetaCont.GetCont(map[string]interface{}{"`dt_parentid`": receivedValue.Target, "`dt_parentid_sun`": judgeSunTarget.Id, "`dt_title`": v.Title}) + if judgeDetaErr == nil { + editDetaAdd(judgeDetaCont.ParentId, judgeDetaCont.ParentIdSun, v, judgeDetaCont, receivedValue.AcceptDepartmentId) + } else { + addDetaInfo(tragetId, judgeSunTarget.Id, v, receivedValue.AcceptDepartmentId) + } + } + publicmethod.Result(0, receivedValue, c) +} + +/* +添加指标细则 +@targetId 指标ID +@sunTargetId 栏目ID +@qualEvalCont 提交的参数 +@departmentAry 接受考核部门 +*/ +func addDetaInfo(targetId, sunTargetId int64, qualEvalCont QualEvalSunList, departmentAry []string) (err error) { + + var minScoreInt int64 = 0 + var maxScoreInt int64 = 0 + scoreAry := strings.Split(qualEvalCont.ReferenceScore, "-") + scoreLen := len(scoreAry) + if scoreLen > 0 { + if scoreLen == 1 { + maxScore, _ := strconv.ParseFloat(scoreAry[0], 64) + maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) + minScoreInt = 0 + } else { + minScore, _ := strconv.ParseFloat(scoreAry[0], 64) + maxScore, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64) + minScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64) + maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) + } + } + var targetCont modelskpi.EvaluationTarget + targetCont.GetCont(map[string]interface{}{"et_id": targetId}, "et_unit", "et_cycle") + //单位 + unitName := qualEvalCont.Unit + if unitName == "" { + unitName = targetCont.Uniteing + } + //计分属性 + addOrReduce := qualEvalCont.AddOrReduce + if qualEvalCont.AddOrReduce == 0 { + addOrReduce = 1 + } + //统计周期 + cyclesInt := qualEvalCont.Cycles + if cyclesInt == 0 { + cyclesInt = 4 + } + cycleAttresInt := qualEvalCont.CycleAttres + if cycleAttresInt == 0 { + cycleAttresInt = 1 + } + //接受考核部门 + if len(departmentAry) < 1 { + //获取指标所有关联部门 + var aboutTarDepList []int64 + aboutTDErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`department_id`").Where("`state` = 1 AND `level` = 1 AND `target_id` = ?", targetId).Find(&aboutTarDepList).Error + if aboutTDErr == nil { + for _, atdv := range aboutTarDepList { + departmentAry = append(departmentAry, strconv.FormatInt(atdv, 10)) + } + } + + } + operatorList := qualEvalCont.Operator + //提报人 + if len(operatorList) < 1 { + //获取指标所有关联部门 + var aboutTarReportList []int64 + aboutTDErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("`man_key`").Where("`state` = 1 AND `type` = 1 AND `target_id` = ?", targetId).Find(&aboutTarReportList).Error + if aboutTDErr == nil { + for _, atrv := range aboutTarReportList { + operatorList = append(operatorList, strconv.FormatInt(atrv, 10)) + } + } + + } + var detaildeTarInfo modelskpi.DetailedTarget + detaildeTarInfo.Title = qualEvalCont.Title //指标细则"` + detaildeTarInfo.Content = qualEvalCont.Content //指标说明"` + detaildeTarInfo.ParentId = targetId //归属指标栏目"` + detaildeTarInfo.ParentIdSun = sunTargetId //归属指标子栏目"` + detaildeTarInfo.State = 1 //状态(1:启用;2:禁用;3:删除)"` + detaildeTarInfo.AddTime = time.Now().Unix() //制定时间"` + detaildeTarInfo.MinScore = minScoreInt //最小分*100保存"` + detaildeTarInfo.MaxScore = maxScoreInt //最大分*100保存"` + detaildeTarInfo.Company = unitName //单位"` + detaildeTarInfo.AddReduce = addOrReduce //1:减少;2:增加;3:无属性,现场确认加或减"` + detaildeTarInfo.CensorType = strings.Join(qualEvalCont.CensorType, ",") //检查方式"` + detaildeTarInfo.CensorCont = qualEvalCont.CensorCont //检查依据"` + detaildeTarInfo.CensorRate = qualEvalCont.CensorRate //检查频次"` + detaildeTarInfo.Cycles = cyclesInt //1:班;2:天;3:周;4:月;5:季度;6:年"` + detaildeTarInfo.CycleAttres = cycleAttresInt //辅助计数"` + detaildeTarInfo.Paretment = strings.Join(departmentAry, ",") //接受考核的部门"` + detaildeTarInfo.Reportary = strings.Join(operatorList, ",") //提报人"` + err = overall.CONSTANT_DB_KPI.Create(&detaildeTarInfo).Error + if err == nil { + syncSeting.Add(1) + go handleDetarildTargetDepart(targetId, sunTargetId, detaildeTarInfo.Id, departmentAry, 1) + syncSeting.Add(1) + go handleDetarildTargetRepart(targetId, sunTargetId, detaildeTarInfo.Id, operatorList, 1) + syncSeting.Wait() + } + return nil +} + +/* +编辑已经存在的指标细则 +@targetId 指标ID +@sunTargetId 栏目ID +@qualEvalCont 提交的参数 +@detailInfof 查询到的参数 +@departmentAry 接受考核部门 +*/ +func editDetaAdd(targetId, sunTargetId int64, qualEvalCont QualEvalSunList, detailInfof modelskpi.DetailedTarget, departmentAry []string) (err error) { + saveData := publicmethod.MapOut[string]() + + if targetId != detailInfof.ParentId { + saveData["dt_parentid"] = targetId + } + if sunTargetId != detailInfof.ParentIdSun { + saveData["dt_parentid_sun"] = sunTargetId + } + + if qualEvalCont.Title != "" && qualEvalCont.Title != detailInfof.Title { + saveData["dt_title"] = qualEvalCont.Title + } + if qualEvalCont.Content != "" && qualEvalCont.Content != detailInfof.Content { + saveData["dt_content"] = qualEvalCont.Content + } + if qualEvalCont.Unit != "" && qualEvalCont.Unit != detailInfof.Company { + saveData["dt_company"] = qualEvalCont.Unit + } + if qualEvalCont.Cycles != 0 && qualEvalCont.Cycles != detailInfof.Cycles { + saveData["dt_cycle"] = qualEvalCont.Cycles + } + if qualEvalCont.CycleAttres != 0 && qualEvalCont.CycleAttres != detailInfof.CycleAttres { + saveData["dt_cycleattr"] = qualEvalCont.CycleAttres + } + if qualEvalCont.AddOrReduce != 0 && qualEvalCont.AddOrReduce != detailInfof.AddReduce { + saveData["dt_add_reduce"] = qualEvalCont.AddOrReduce + } + censStr := strings.Join(qualEvalCont.CensorType, ",") + if len(qualEvalCont.CensorType) > 0 { + if censStr != detailInfof.CensorType { + saveData["dt_censor_type"] = censStr + } + } + if qualEvalCont.CensorCont != "" && qualEvalCont.CensorCont != detailInfof.CensorCont { + saveData["dt_censor_cont"] = qualEvalCont.CensorCont + } + if qualEvalCont.CensorRate != 0 && qualEvalCont.CensorRate != detailInfof.CensorRate { + saveData["dt_censor_rate"] = qualEvalCont.CensorRate + } + + var minScoreInt int64 = 0 + var maxScoreInt int64 = 0 + scoreAry := strings.Split(qualEvalCont.ReferenceScore, "-") + scoreLen := len(scoreAry) + if scoreLen > 0 { + if scoreLen == 1 { + maxScore, _ := strconv.ParseFloat(scoreAry[0], 64) + maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) + minScoreInt = 0 + } else { + minScore, _ := strconv.ParseFloat(scoreAry[0], 64) + maxScore, _ := strconv.ParseFloat(scoreAry[scoreLen-1], 64) + minScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64) + maxScoreInt, _ = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) + } + } + if minScoreInt != detailInfof.MinScore { + saveData["dt_min_score"] = minScoreInt + } + if maxScoreInt != detailInfof.MaxScore { + saveData["dt_max_score"] = maxScoreInt + } + departStr := strings.Join(departmentAry, ",") + if departStr != detailInfof.Paretment { + saveData["dt_paretment"] = departStr + } + reportStr := strings.Join(qualEvalCont.Operator, ",") + if reportStr != detailInfof.Reportary { + saveData["reportary"] = reportStr + } + if len(saveData) > 0 { + saveData["dt_time"] = time.Now().Unix() + var editCont modelskpi.DetailedTarget + err = editCont.EiteCont(map[string]interface{}{"`dt_id`": detailInfof.Id}, saveData) + } + syncSeting.Add(1) + go handleDetarildTargetDepart(targetId, sunTargetId, detailInfof.Id, departmentAry, 1) + syncSeting.Add(1) + go handleDetarildTargetRepart(targetId, sunTargetId, detailInfof.Id, qualEvalCont.Operator, 1) + syncSeting.Wait() + return nil +} + +/* +处理指标细则关联部门 +@targetId 指标ID +@targetSunId 栏目ID +@bylawsId 指标细则 +@department 接受考核部门 +@class 级别(1:部门级;2:岗位级) +*/ +func handleDetarildTargetDepart(targetId, targetSunId, bylawsId int64, department []string, class int) { + defer syncSeting.Done() + //将不属于该指标细则的部门至禁用 + otherSaveData := publicmethod.MapOut[string]() + otherSaveData["`state`"] = 2 + otherSaveData["`time`"] = time.Now().Unix() + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Where("`level` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?", class, targetId, targetSunId, bylawsId).Not(map[string]interface{}{"department_id": department}).Updates(&otherSaveData) + for _, v := range department { + var tarDepartCont modelskpi.TargetDepartment + saveErr := tarDepartCont.GetCont(map[string]interface{}{"`level`": class, "`target_id`": targetId, "`target_sun_id`": targetSunId, "`target_bylaws`": bylawsId, "`department_id`": v}, "`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 = 1 //1:定性考核;2:定量考核"` + tarDepartCont.Level = class //级别(1:部门级;2:岗位级)"` + overall.CONSTANT_DB_KPI.Create(&tarDepartCont) + } + } +} + +/* +处理指标细则关联考核提交人 +@targetId 指标ID +@targetSunId 栏目ID +@bylawsId 指标细则 +@repart 考核提交人 +@class 级别(1:部门级;2:岗位级) +*/ +func handleDetarildTargetRepart(targetId, targetSunId, bylawsId int64, repart []string, class int) { + defer syncSeting.Done() + //将不属于该指标细则的部门至禁用 + otherSaveData := publicmethod.MapOut[string]() + otherSaveData["`state`"] = 2 + otherSaveData["`time`"] = time.Now().Unix() + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Where("`type` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?", class, targetId, targetSunId, bylawsId).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 + saveErr := tarReportCont.GetCont(map[string]interface{}{"`type`": class, "`target_id`": targetId, "`target_sun_id`": targetSunId, "`target_bylaws`": bylawsId, "`man_key`": v}, "`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 { + 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 = 1 //1:定性考核;2:定量考核"` + overall.CONSTANT_DB_KPI.Create(&tarReportCont) + } + } +} + +// 获取定性考核指标列表内容 +func (a *ApiMethod) GetDepartmentTragetContList(c *gin.Context) { + var receivedValue getDepartTargetContType + c.ShouldBindJSON(&receivedValue) + if receivedValue.TargetId == "" { + publicmethod.Result(1, receivedValue, c, "未知指标ID!") + return + } + if receivedValue.Page == 0 { + receivedValue.Page = 1 + } + if receivedValue.PageSize == 0 { + receivedValue.PageSize = 20 + } + var detaildeList []modelskpi.DetailedTarget + var detCont modelskpi.DetailedTarget + gormDb := overall.CONSTANT_DB_KPI.Table(fmt.Sprintf("%s dt", detCont.TableName())).Select("dt.*").Where("dt.dt_state = 1 AND dt.dt_parentid = ?", receivedValue.TargetId) + //接受考核的部门 + if receivedValue.DepartmentId != "" { + gormDb = gormDb.Joins("LEFT JOIN `target_department` `td` on td.target_id = dt.dt_parentid AND td.target_sun_id = dt.dt_parentid_sun AND td.target_bylaws = dt.dt_id").Where("td.department_id = ?", receivedValue.DepartmentId) + } + //提报人 + if receivedValue.ReportPerson != "" { + gormDb = gormDb.Joins("LEFT JOIN `target_report` `tr` on tr.target_id = dt.dt_parentid AND tr.target_sun_id = dt.dt_parentid_sun AND tr.target_bylaws = dt.dt_id").Where("tr.man_key = ?", receivedValue.ReportPerson) + } + if receivedValue.Cycle != 0 { + gormDb = gormDb.Where("dt.dt_cycle = ?", receivedValue.Cycle) + } + if receivedValue.TargetSunId != "" { + gormDb = gormDb.Where("dt.dt_parentid_sun = ?", receivedValue.TargetSunId) + } + + err := gormDb.Order("dt.dt_parentid desc, dt.dt_parentid_sun").Find(&detaildeList).Error + if err != nil || len(detaildeList) < 1 { + publicmethod.Result(107, receivedValue, c) + return + } + var total int64 + totalErr := gormDb.Select("dt_id").Count(&total).Error + if totalErr != nil { + total = 0 + } + var outData []printDepartTargetCont + for _, v := range detaildeList { + var outCont printDepartTargetCont + outCont.Id = v.Id + outCont.Title = v.Title //指标细则"` + outCont.Content = v.Content //指标说明"` + outCont.ParentId = v.ParentId //归属指标栏目"` + outCont.ParentIdSun = v.ParentIdSun //归属指标子栏目"` + outCont.State = v.State //状态(1:启用;2:禁用;3:删除)"` + outCont.AddTime = v.AddTime //制定时间"` + outCont.MinScore = v.MinScore //最小分*100保存"` + outCont.MaxScore = v.MaxScore //100保存"` + outCont.Company = v.Company //单位"` + outCont.AddReduce = v.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"` + outCont.CensorType = v.CensorType //检查方式"` + outCont.CensorCont = v.CensorCont //检查依据"` + outCont.CensorRate = v.CensorRate //检查频次"` + outCont.Cycles = v.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年"` + outCont.CycleAttres = v.CycleAttres //辅助计数"` + outCont.Paretment = v.Paretment //接受考核的部门"` + outCont.Reportary = v.Reportary //提报人"` + + standardStr := "" + if v.MinScore != 0 { + standardStr = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(float64(v.MinScore)/100, 2), publicmethod.DecimalEs(float64(v.MaxScore)/100, 2)) + } else { + standardStr = fmt.Sprintf("%v", publicmethod.DecimalEs(float64(v.MaxScore)/100, 2)) + } + outCont.Standard = standardStr + outCont.CensorTypeList = strings.Split(v.CensorType, ",") + + outData = append(outData, outCont) + } + publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(outData)), outData, c) +} + +// 根据指标栏目新增指标细则 +func (a *ApiMethod) BasisSonTargetAddDetailed(c *gin.Context) { + var receivedValue basisSonTargetAddDet + c.ShouldBindJSON(&receivedValue) + // var minScoreInt int64 = 0 //最低分 + // var maxScoreInt int64 = 0 //最高分 + if receivedValue.Id == "" { + publicmethod.Result(1, receivedValue, c, "未知指标子栏目ID!") + return + } + var sonTargetFatherInfo modelskpi.SonTargetFather + err := sonTargetFatherInfo.GetCont(map[string]interface{}{"q_id": receivedValue.Id}) + if err != nil { + publicmethod.Result(1, err, c, "该子栏目不存在!") + return + } + if receivedValue.Title == "" { + publicmethod.Result(1, receivedValue, c, "请输入考核细则名称!") + return + } + //判断指标细则是否符合规则 + if receivedValue.ReferenceScore == "" { + publicmethod.Result(1, receivedValue, c, "请输入考核细则相关考核标准!") + return + } else { + scoreAry := strings.Split(receivedValue.ReferenceScore, "-") + scoreLen := len(scoreAry) + if scoreLen < 1 { + publicmethod.Result(1, receivedValue, c, "考核标准不符合要求!请仔细填写!") + return + } + if scoreLen == 1 { + maxScore, maxErr := strconv.ParseFloat(scoreAry[0], 64) + if maxErr != nil { + publicmethod.Result(1, maxErr, c, "考核标准不符合要求!请仔细填写!") + return + } + var maxIntErr error + _, maxIntErr = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) + if maxIntErr != nil { + publicmethod.Result(1, maxIntErr, c, "考核标准不符合要求!请仔细填写!") + return + } + } else { + minScore, minErr := strconv.ParseFloat(scoreAry[0], 64) + if minErr != nil { + publicmethod.Result(1, minErr, c, "考核标准不符合要求!请仔细填写!") + return + } + maxScore, maxErr := strconv.ParseFloat(scoreAry[scoreLen-1], 64) + if maxErr != nil { + publicmethod.Result(1, maxErr, c, "考核标准不符合要求!请仔细填写!") + return + } + var minIntErr error + _, minIntErr = strconv.ParseInt(strconv.FormatFloat(minScore*100, 'f', -1, 64), 10, 64) + if minIntErr != nil { + publicmethod.Result(1, minIntErr, c, "考核标准不符合要求!请仔细填写!") + return + } + var maxIntErr error + _, maxIntErr = strconv.ParseInt(strconv.FormatFloat(maxScore*100, 'f', -1, 64), 10, 64) + if maxIntErr != nil { + publicmethod.Result(1, maxIntErr, c, "考核标准不符合要求!请仔细填写!") + return + } + } + } + //获取子栏目接受考核部门 + var sonAboutDeparment []string + + var aboutTarDepList []int64 + aboutTDErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`department_id`").Where("`state` = 1 AND `level` = 1 AND `target_id` = ? AND `target_sun_id` = ?", sonTargetFatherInfo.ParentId, sonTargetFatherInfo.Id).Find(&aboutTarDepList).Error + if aboutTDErr == nil { + for _, atdv := range aboutTarDepList { + sonAboutDeparment = append(sonAboutDeparment, strconv.FormatInt(atdv, 10)) + } + } + + var qualEvalCont QualEvalSunList + qualEvalCont.Title = receivedValue.Title //考核内容 + qualEvalCont.Content = receivedValue.Content //备注说明 + qualEvalCont.Unit = receivedValue.Unit //单位 + qualEvalCont.ReferenceScore = receivedValue.ReferenceScore //考核标准 + qualEvalCont.Cycles = receivedValue.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 + qualEvalCont.CycleAttres = receivedValue.CycleAttres //辅助计数 + qualEvalCont.Operator = receivedValue.Operator //考核执行人 + qualEvalCont.AddOrReduce = receivedValue.AddOrReduce //操作类型 1:减少;2:增加;3:用户自定义 + qualEvalCont.CensorType = receivedValue.CensorType //检查方式(1:现场检查;2:资料检查;3:事件触发) + qualEvalCont.CensorCont = receivedValue.CensorCont //客观证据 + qualEvalCont.CensorRate = receivedValue.CensorRate //检查频次 + //判断指标细则是否已经存在 + var judgeDetaCont modelskpi.DetailedTarget + judgeDetaErr := judgeDetaCont.GetCont(map[string]interface{}{"`dt_parentid`": sonTargetFatherInfo.ParentId, "`dt_parentid_sun`": sonTargetFatherInfo.Id, "`dt_title`": receivedValue.Title}) + if judgeDetaErr == nil { + judgeDetaErr = editDetaAdd(sonTargetFatherInfo.ParentId, sonTargetFatherInfo.Id, qualEvalCont, judgeDetaCont, sonAboutDeparment) + } else { + judgeDetaErr = addDetaInfo(sonTargetFatherInfo.ParentId, sonTargetFatherInfo.Id, qualEvalCont, sonAboutDeparment) + } + if judgeDetaErr != nil { + publicmethod.Result(106, judgeDetaErr, c) + return + } + publicmethod.Result(0, judgeDetaErr, c) +} + +// 根据指标和部门获取相关岗位 +func (a *ApiMethod) BasisTargetDearpetmentGetPost(c *gin.Context) { + var receivedValue bgdgp + c.ShouldBindJSON(&receivedValue) + if receivedValue.TargetId == "" { + publicmethod.Result(101, receivedValue, c) + return + } + if receivedValue.DepartmentId == "" { + publicmethod.Result(101, receivedValue, c) + return + } + if receivedValue.Level == 0 { + receivedValue.Level = 2 + } + var postId []int64 + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("post_id").Where("`state` = 1 AND `level` = ? AND `target_id` = ? AND `department_id` = ?", receivedValue.Level, receivedValue.TargetId, receivedValue.DepartmentId) + if receivedValue.TargetSunId != "" { + gormDb = gormDb.Where("`target_sun_id` = ?", receivedValue.TargetSunId) + } + if receivedValue.TargetBylaws != "" { + gormDb = gormDb.Where("`target_bylaws` = ?", receivedValue.TargetBylaws) + } + err := gormDb.Find(&postId).Error + if err != nil || len(postId) < 1 { + publicmethod.Result(107, err, c) + return + } + var postList []modelshr.Position + hrErr := overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`id`,`name`").Where("`id` IN ?", postId).Find(&postList).Error + if hrErr != nil || len(postList) < 1 { + publicmethod.Result(107, hrErr, c) + return + } + outdata := publicmethod.MapOut[string]() + outdata["postid"] = postId + outdata["postlist"] = postList + publicmethod.Result(0, outdata, c) +} + +// 获取部门指标岗位提交人 +func (a *ApiMethod) BasisTaegetDeparmentReport(c *gin.Context) { + var receivedValue btdgr + c.ShouldBindJSON(&receivedValue) + if receivedValue.TargetId == "" { + publicmethod.Result(101, receivedValue, c) + return + } + // if receivedValue.DepartmentId == "" { + // publicmethod.Result(101, receivedValue, c) + // return + // } + if receivedValue.Level == 0 { + receivedValue.Level = 2 + } + var userKey []int64 + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("man_key").Where("`state` = 1 AND `type` = ? AND `target_id` = ?", receivedValue.Level, receivedValue.TargetId) + + if receivedValue.DepartmentId != "" { + gormDb = gormDb.Where("`department_id` = ?", receivedValue.DepartmentId) + } + + if receivedValue.TargetSunId != "" { + gormDb = gormDb.Where("`target_sun_id` = ?", receivedValue.TargetSunId) + } + if receivedValue.TargetBylaws != "" { + gormDb = gormDb.Where("`target_bylaws` = ?", receivedValue.TargetBylaws) + } + if receivedValue.PostId != "" { + gormDb = gormDb.Where("`post_id` = ?", receivedValue.PostId) + } + err := gormDb.Find(&userKey).Error + if err != nil || len(userKey) < 1 { + publicmethod.Result(107, err, c) + return + } + + var peopleList []modelshr.UserPostDuties + hrErr := overall.CONSTANT_DB_HR.Model(&modelshr.UserPostDuties{}).Where("`key` IN ?", userKey).Find(&peopleList).Error + if hrErr != nil || len(peopleList) < 1 { + publicmethod.Result(107, hrErr, c) + return + } + outdata := publicmethod.MapOut[string]() + outdata["postid"] = userKey + outdata["peoplelist"] = peopleList + publicmethod.Result(0, outdata, c) +} + +// 修改子栏目标题名称级考核关联部门及提报人 +func (a *ApiMethod) EditSonTargetDepartmentReport(c *gin.Context) { + var receivedValue editTarDepartReport + c.ShouldBindJSON(&receivedValue) + if receivedValue.TargetSunId == "" { + publicmethod.Result(101, receivedValue, c) + return + } + var sonTargetCont modelskpi.QualitativeTarget + err := sonTargetCont.GetCont(map[string]interface{}{"q_id": receivedValue.TargetSunId}) + if err != nil { + publicmethod.Result(107, receivedValue, c) + return + } + if receivedValue.Title != "" && receivedValue.Title != sonTargetCont.Title { + var judgeIsFalse modelskpi.QualitativeTarget + judgeErr := judgeIsFalse.GetCont(map[string]interface{}{"q_title": sonTargetCont.Id, "q_parent_id": sonTargetCont.ParentId}, "q_id") + if judgeErr == nil { + publicmethod.Result(103, receivedValue, c) + return + } + saveData := publicmethod.MapOut[string]() + saveData["q_title"] = receivedValue.Title + saveData["q_time"] = time.Now().Unix() + err = sonTargetCont.EiteCont(map[string]interface{}{"q_id": receivedValue.TargetSunId}, saveData) + } + if err != nil { + publicmethod.Result(106, receivedValue, c) + return + } + departmentAry := receivedValue.AcceptDepartmentId + operatorList := receivedValue.Operator + + if len(departmentAry) < 1 { + var sonDepartmentAbouttargetId []int64 + deparErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("department_id").Where("`state` = 1 AND `level` = 1 AND `target_id` = ? ", sonTargetCont.ParentId).Find(&sonDepartmentAbouttargetId).Error + if deparErr == nil && len(sonDepartmentAbouttargetId) > 0 { + for _, sdv := range sonDepartmentAbouttargetId { + departmentAry = append(departmentAry, strconv.FormatInt(sdv, 10)) + } + } + } + + if len(operatorList) < 1 { + var sonReportAbouttargetId []int64 + deparErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("man_key").Where("`state` = 1 AND `type` = 1 AND `target_id` = ? ", sonTargetCont.ParentId).Find(&sonReportAbouttargetId).Error + if deparErr == nil && len(sonReportAbouttargetId) > 0 { + for _, srv := range sonReportAbouttargetId { + operatorList = append(operatorList, strconv.FormatInt(srv, 10)) + } + } + } + + //获取该指标下所有细则 + var detaildId []int64 + err = overall.CONSTANT_DB_KPI.Model(&modelskpi.DetailedTarget{}).Select("dt_id").Where("`dt_state` = 1 AND `dt_parentid` = ? AND `dt_parentid_sun` = ?", sonTargetCont.ParentId, sonTargetCont.Id).Find(&detaildId).Error + if err == nil && len(detaildId) > 0 { + for _, v := range detaildId { + if len(departmentAry) > 0 { + syncSeting.Add(1) + go handleDetarildTargetDepart(sonTargetCont.ParentId, sonTargetCont.Id, v, departmentAry, 1) + } + if len(operatorList) > 0 { + syncSeting.Add(1) + go handleDetarildTargetRepart(sonTargetCont.ParentId, sonTargetCont.Id, v, operatorList, 1) + } + syncSeting.Wait() + } + } + //获取该子栏目所有的接受考核部门 + + saveData := publicmethod.MapOut[string]() + saveData["q_depart"] = strings.Join(departmentAry, ",") + saveData["q_time"] = time.Now().Unix() + err = sonTargetCont.EiteCont(map[string]interface{}{"q_id": receivedValue.TargetSunId}, saveData) + //修改指标的关联部门和关联人 + var targetAboutDepartnebt []int64 + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("department_id").Where("`state` = 1 AND `level` = 1 AND `target_id` = ? ", sonTargetCont.ParentId).Find(&targetAboutDepartnebt) + var targetAboutReport []int64 + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("man_key").Where("`state` = 1 AND `type` = 1 AND `target_id` = ? ", sonTargetCont.ParentId).Find(&targetAboutReport) + if len(targetAboutDepartnebt) > 0 || len(targetAboutReport) > 0 { + tarSaveData := publicmethod.MapOut[string]() + if len(targetAboutDepartnebt) > 0 { + var departStr []string + for _, dsv := range targetAboutDepartnebt { + departStr = append(departStr, strconv.FormatInt(dsv, 10)) + } + tarSaveData["et_relevant_departments"] = strings.Join(departStr, ",") + } + if len(targetAboutReport) > 0 { + var reportStr []string + for _, dsvr := range targetAboutReport { + reportStr = append(reportStr, strconv.FormatInt(dsvr, 10)) + } + tarSaveData["et_report"] = strings.Join(reportStr, ",") + } + if len(tarSaveData) > 0 { + tarSaveData["et_time"] = time.Now().Unix() + var evalTarCont modelskpi.EvaluationTarget + evalTarCont.EiteCont(map[string]interface{}{"`et_id`": sonTargetCont.ParentId}, tarSaveData) + } + } + publicmethod.Result(0, err, c) +} + +// 获取子栏目基础信息 +func (a *ApiMethod) GetSonTargetCont(c *gin.Context) { + var receivedValue publicmethod.PublicId + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, receivedValue, c) + return + } + if receivedValue.Id == "" { + publicmethod.Result(101, receivedValue, c) + return + } + where := publicmethod.MapOut[string]() + where["q_id"] = receivedValue.Id + var sonTargetCont modelskpi.QualitativeTarget + err = sonTargetCont.GetCont(where, "q_title", "q_parent_id") + if err != nil { + publicmethod.Result(107, receivedValue, c) + return + } + //获取关联部门 + var targetAboutDepartnebt []int64 + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("department_id").Where("`state` = 1 AND `level` = 1 AND `target_id` = ? AND `target_sun_id` = ?", sonTargetCont.ParentId, receivedValue.Id).Find(&targetAboutDepartnebt) + //获取关联提报人 + var targetAboutReport []int64 + overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("man_key").Where("`state` = 1 AND `type` = 1 AND `target_id` = ? AND `target_sun_id` = ?", sonTargetCont.ParentId, receivedValue.Id).Find(&targetAboutReport) + //部门列表 + var departContList []modelshr.AdministrativeOrganization + overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`").Where("`id` IN ?", targetAboutDepartnebt).Find(&departContList) + //人员列表 + var reportContList []modelshr.PersonArchives + overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`key`,`name`").Where("`key` IN ?", targetAboutReport).Find(&reportContList) + + var departArt []outCont + for _, darv := range departContList { + var departContArt outCont + departContArt.Id = strconv.FormatInt(darv.Id, 10) + departContArt.Name = darv.Name + departArt = append(departArt, departContArt) + } + + var reportArt []outCont + for _, rclv := range reportContList { + var reportContArt outCont + reportContArt.Id = strconv.FormatInt(rclv.Key, 10) + reportContArt.Name = rclv.Name + reportArt = append(reportArt, reportContArt) + } + + outData := publicmethod.MapOut[string]() + outData["title"] = sonTargetCont.Title + outData["departmentid"] = targetAboutDepartnebt + outData["userkey"] = targetAboutReport + outData["departmentcont"] = departArt + outData["usercont"] = reportArt + publicmethod.Result(0, outData, c) +} + +// 删除子栏目 +func (a *ApiMethod) DelSonTarget(c *gin.Context) { + var receivedValue publicmethod.PublicId + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, receivedValue, c) + return + } + if receivedValue.Id == "" { + publicmethod.Result(101, receivedValue, c) + return + } + where := publicmethod.MapOut[string]() + where["q_id"] = receivedValue.Id + var sonTargetCont modelskpi.QualitativeTarget + err = sonTargetCont.GetCont(where, "q_id", "q_parent_id") + if err != nil { + publicmethod.Result(107, err, c) + return + } + //预留判断该指标是否在使用中 + + delTime := time.Now().Unix() + //软删除所有此子栏目下的指标细则 + syncSeting.Add(1) + go softDetaildeCont(sonTargetCont.ParentId, sonTargetCont.Id, delTime) + //软删除所有此子栏目相关的联部门 + syncSeting.Add(1) + go softDelTargetDepartment(sonTargetCont.ParentId, sonTargetCont.Id, delTime) + //软删除所有此子栏目相关联的提报人 + syncSeting.Add(1) + go softDelTargetReport(sonTargetCont.ParentId, sonTargetCont.Id, delTime) + //软删除此栏目 + var delTargetSon modelskpi.QualitativeTarget + err = delTargetSon.EiteCont(map[string]interface{}{"`q_id`": sonTargetCont.Id}, map[string]interface{}{"`q_state`": 3, "`q_time`": delTime}) + syncSeting.Wait() + if err != nil { + publicmethod.Result(106, err, c) + return + } + publicmethod.Result(0, err, c) +} + +// 软删除所有此子栏目下的指标细则 +func softDetaildeCont(targetId, sonTargetId, delTime int64) { + defer syncSeting.Done() + var detaildeCont modelskpi.DetailedTarget + detaildeCont.EiteCont(map[string]interface{}{"dt_parentid": targetId, "dt_parentid_sun": sonTargetId, "dt_state": 1}, map[string]interface{}{"dt_state": 3, "dt_time": delTime}) +} + +// 软删除所有此子栏目相关联的提报人 +func softDelTargetReport(targetId, sonTargetId, delTime int64) { + defer syncSeting.Done() + var delTargetReport modelskpi.TargetReport + delTargetReport.EiteCont(map[string]interface{}{"`target_id`": targetId, "`target_sun_id`": sonTargetId, "`state`": 1}, map[string]interface{}{"`state`": 3, "`time`": delTime}) +} + +// 软删除所有此子栏目相关的联部门 +func softDelTargetDepartment(targetId, sonTargetId, delTime int64) { + defer syncSeting.Done() + var delTargetDepartment modelskpi.TargetDepartment + delTargetDepartment.EiteCont(map[string]interface{}{"target_id": targetId, "target_sun_id": sonTargetId, "`state`": 1}, map[string]interface{}{"`state`": 3, "`time`": delTime}) +} + +// 获取单一指标细则内容 +func (a *ApiMethod) GetOneDetailedTarget(c *gin.Context) { + var receivedValue publicmethod.PublicId + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, receivedValue, c) + return + } + if receivedValue.Id == "" { + publicmethod.Result(101, receivedValue, c) + return + } + where := publicmethod.MapOut[string]() + where["dt_id"] = receivedValue.Id + var detailedTargetCont modelskpi.DetailedTarget + err = detailedTargetCont.GetCont(where) + if err != nil { + publicmethod.Result(107, err, c) + return + } +} diff --git a/api/version1/departmentseting/departmentpc/type.go b/api/version1/departmentseting/departmentpc/type.go index 84e12d1..413f9f5 100644 --- a/api/version1/departmentseting/departmentpc/type.go +++ b/api/version1/departmentseting/departmentpc/type.go @@ -3,12 +3,16 @@ package departmentpc import ( "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall/publicmethod" + "sync" "github.com/gin-gonic/gin" ) type ApiMethod struct{} +// 协程设置 +var syncSeting = sync.WaitGroup{} + // 部门考核WEB端入口 func (a *ApiMethod) Index(c *gin.Context) { outputCont := publicmethod.MapOut[string]() @@ -42,3 +46,105 @@ type departOutcome struct { Superior string `json:"superior"` //上级 Ispower int `json:"ispower"` //是否为主部门 } + +// 转换提报人格式化 +type zhuanHuanMan struct { + Id int64 `json:"id"` + Operator []string `json:"operator"` +} + +// 获取相关提报人 +type getAboutReportTarget struct { + TargetId string `json:"targetid"` + TargetSunId string `json:"targetsunid"` + TargetBylaws string `json:"targetbylaws"` + DepartmentId string `json:"departmentid"` + PostId string `json:"postid"` +} + +// 输出上报人信息 +type printReportCont struct { + Id string `json:"id"` + Name string `json:"name"` + GroupName string `json:"groupname"` + DepartmentName string `json:"departmentname"` + Icon string `json:"icon"` + Number string `json:"number"` +} + +// 添加 定性考核指标关系指定 +type AddQualEval struct { + Group string `json:"group"` //归属集团 + AcceptDepartmentId []string `json:"parentid"` //接受考核部门 + Type int `json:"type"` //1:定性考核;2:定量考核 + Target string `json:"target"` //考核指标 + TargetSunTitle string `json:"targetsuntitle"` //考核指标子栏目 + EvaluationList []QualEvalSunList `json:"evaluationlist"` //测评详情 +} + +// 定性考核内容 +type QualEvalSunList struct { + Title string `json:"title"` //考核内容 + Content string `json:"content"` //备注说明 + Unit string `json:"unit"` //单位 + ReferenceScore string `json:"referencescore"` //考核标准 + Cycles int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年 + CycleAttres int `json:"cycleattr"` //辅助计数 + Operator []string `json:"userlist"` //考核执行人 + AddOrReduce int `json:"addorreduce"` //操作类型 1:减少;2:增加;3:用户自定义 + CensorType []string `json:"censortype"` //检查方式(1:现场检查;2:资料检查;3:事件触发) + CensorCont string `json:"censorcont"` //客观证据 + CensorRate int `json:"censorrate"` //检查频次 +} + +// 获取定性考核指标列表查询参数 +type getDepartTargetContType struct { + publicmethod.PagesTurn + TargetId string `json:"targetid"` //指标ID + DepartmentId string `json:"departmentid"` //部门ID + ReportPerson string `json:"reportperson"` //上报人 + Cycle int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年 + TargetSunId string `json:"targetsunid"` //考核子栏目 +} + +// 输出定性指标详细内容列表 +type printDepartTargetCont struct { + modelskpi.DetailedTarget + Standard string `json:"standard"` //标准 + CensorTypeList []string `json:"censortypelist"` //检查方式(1:现场检查;2:资料检查;3:事件触发) +} + +// 根据指标栏目新增指标细则 +type basisSonTargetAddDet struct { + publicmethod.PublicId + QualEvalSunList +} + +// 根据指标和部门获取相关岗位 +type bgdgp struct { + TargetId string `json:"targetid"` //指标 + TargetSunId string `json:"targetsunid"` //子栏目 + TargetBylaws string `json:"targetbylaws"` //细则 + DepartmentId string `json:"departmentid"` //部门 + Level int `json:"level"` //级别(1:部门级;2:岗位级) +} + +// 根据指标、部门和岗位获取相关提交人 +type btdgr struct { + bgdgp + PostId string `json:"postid"` //岗位 +} + +// 修改子栏目标题名称级考核关联部门及提报人 +type editTarDepartReport struct { + TargetSunId string `json:"targetsunid"` //子栏目 + Title string `json:"title"` //考核内容 + AcceptDepartmentId []string `json:"acceptdepartmentid"` //接受考核部门 + Operator []string `json:"userlist"` //考核执行人 +} + +// 输出 +type outCont struct { + publicmethod.PublicId + publicmethod.PublicName +} diff --git a/apirouter/v1/departmentseting/pc.go b/apirouter/v1/departmentseting/pc.go index 8763cb2..77fda69 100644 --- a/apirouter/v1/departmentseting/pc.go +++ b/apirouter/v1/departmentseting/pc.go @@ -15,8 +15,17 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.GET("", methodBinding.Index) //入口 apiRouter.POST("", methodBinding.Index) //入口 - apiRouter.POST("departmenttargetlist", methodBinding.DepartmentTargetList) //部门指标列表 - apiRouter.POST("shiyan", methodBinding.Shiyan) //实验 - apiRouter.POST("getdepartabouttarget", methodBinding.GetDepartAboutTarget) //获取部门定性考核部门关联列表 + apiRouter.POST("departmenttargetlist", methodBinding.DepartmentTargetList) //部门指标列表 + apiRouter.POST("shiyan", methodBinding.Shiyan) //实验 + apiRouter.POST("getdepartabouttarget", methodBinding.GetDepartAboutTarget) //获取部门定性考核部门关联列表 + apiRouter.POST("gettargetreport", methodBinding.GetTargetReport) //获取部门指标相关执行人 + apiRouter.POST("addsuntargetdetailed", methodBinding.AddSunTargetDetailed) //添加定性考核子栏目及细则 + apiRouter.POST("getdepartmenttragetcontlist", methodBinding.GetDepartmentTragetContList) //获取定性考核指标列表内容 + apiRouter.POST("basissontargetadddetailed", methodBinding.BasisSonTargetAddDetailed) //根据指标栏目新增指标细则 + apiRouter.POST("basistargetdearpetmentgetpost", methodBinding.BasisTargetDearpetmentGetPost) //根据指标和部门获取相关岗位 + apiRouter.POST("basistaegetdeparmentreport", methodBinding.BasisTaegetDeparmentReport) //获取部门指标岗位提交人 + apiRouter.POST("editsontargetdepartmentreport", methodBinding.EditSonTargetDepartmentReport) //修改子栏目标题名称级考核关联部门及提报人 + apiRouter.POST("getsontargetcont", methodBinding.GetSonTargetCont) //获取子栏目基础信息 + apiRouter.POST("delsontarget", methodBinding.DelSonTarget) //删除子栏目 } } diff --git a/models/modelshr/administrative_organization.go b/models/modelshr/administrative_organization.go index e073af7..0bfb9b0 100644 --- a/models/modelshr/administrative_organization.go +++ b/models/modelshr/administrative_organization.go @@ -51,7 +51,12 @@ func (cont *AdministrativeOrganization) CountCont(whereMap interface{}) (countId } // 读取全部信息 -func (cont *AdministrativeOrganization) ContMap(whereMap interface{}) (countAry []AdministrativeOrganization) { - overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Find(&countAry) +func (cont *AdministrativeOrganization) ContMap(whereMap interface{}, field ...string) (countAry []AdministrativeOrganization) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb.Where(whereMap).Find(&countAry) return } diff --git a/models/modelshr/user_post_duties.go b/models/modelshr/user_post_duties.go new file mode 100644 index 0000000..d179d42 --- /dev/null +++ b/models/modelshr/user_post_duties.go @@ -0,0 +1,82 @@ +package modelshr + +import ( + "key_performance_indicators/overall" + "strings" +) + +type UserPostDuties struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` + Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` + Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` + Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"` + Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"` + MainDeparment int64 `json:"maindeparment" gorm:"column:maindeparment;type:bigint(20) unsigned;default:0;not null;comment:主部门"` + AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"` + TeamId int64 `json:"teamid" gorm:"column:teamid;type:bigint(20) unsigned;default:0;not null;comment:班组"` + Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;not null;comment:职位"` + JobId int64 `json:"jobid" gorm:"column:job_id;type:bigint(20) unsigned;default:0;not null;comment:职务"` + JobLeve int64 `json:"jobleve" gorm:"column:job_leve;type:bigint(20) unsigned;default:0;not null;comment:职务等级"` + Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255) unsigned;default:'';not null;comment:微信UserId"` + WorkWechat string `json:"workwechat" gorm:"column:work_wechat;type:varchar(255) unsigned;default:'';not null;comment:企业微信UserId"` + Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` + IsAdmin int `json:"isadmin" gorm:"column:is_admin;type:tinyint(1) unsigned;default:1;not null;comment:是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管` + Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"` + Role string `json:"role" gorm:"column:role;type:longtext;comment:角色"` + SunMainDeparment int64 `json:"sunmaindeparment" gorm:"column:sun_main_deparment;type:bigint(20) unsigned;default:0;not null;comment:主部门"` + + Mobilephone string `json:"mobilephone" gorm:"column:mobilephone;type:varchar(50) unsigned;default:'';not null;comment:手机号码"` + Gender int `json:"gender" gorm:"column:gender;type:tinyint(1) unsigned;default:1;not null;comment:性别(1:男性;2:女性;3:中性)"` + + PostName string `json:"postname" gorm:"column:postname;type:varchar(255) unsigned;default:'';not null;comment:职位名称"` + PersonInCharge int `json:"personincharge" gorm:"column:leading_cadre;type:int(1) unsigned;default:2;not null;comment:是否为本部门负责人(1:是;2:否)"` + Superior int64 `json:"superior" gorm:"column:post_superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` + MenuPermit string `json:"menupermit" gorm:"column:menu_permit;type:longtext;comment:菜单许可证"` + ButtonPermit string `json:"buttonpermit" gorm:"column:button_permit;type:longtext;comment:按钮许可"` + DutiesName string `json:"dutiesname" gorm:"column:duties_name;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` +} + +func (UserPostDuties *UserPostDuties) TableName() string { + return "user_post_duties" +} + +// 编辑内容 +func (cont *UserPostDuties) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *UserPostDuties) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *UserPostDuties) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *UserPostDuties) ContMap(whereMap interface{}, field ...string) (countAry []UserPostDuties, err error) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *UserPostDuties) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/assesstarget.go b/models/modelskpi/assesstarget.go new file mode 100644 index 0000000..49db84c --- /dev/null +++ b/models/modelskpi/assesstarget.go @@ -0,0 +1,64 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 定性考核指标关系指定 +type Assesstarget struct { + Id int64 `json:"id" gorm:"primaryKey;column:at_id;type:bigint(20) unsigned;not null;comment:Id;index"` + Group int64 `json:"group" gorm:"column:group;type:bigint(20) unsigned;default:0;not null;comment:集团ID"` + Departmentmap string `json:"departmentmap" gorm:"column:departmentmap;type:mediumtext unsigned;default:0;comment:部门ID"` + TargetId int64 `json:"targetid" gorm:"column:targetid;type:bigint(20) unsigned;default:0;not null;comment:指标"` + SunTargetId int64 `json:"suntargetid" gorm:"column:suntargetid;type:bigint(20) unsigned;default:0;not null;comment:子栏目ID"` + Content string `json:"content" gorm:"column:content;type:longtext;comment:描述"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Dimension int64 `json:"dimension" gorm:"column:dimension;type:bigint(20) unsigned;default:0;not null;comment:维度"` +} + +func (Assesstarget *Assesstarget) TableName() string { + return "assesstarget" +} + +// 编辑内容 +func (cont *Assesstarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Assesstarget) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *Assesstarget) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Assesstarget) ContMap(whereMap interface{}, field ...string) (countAry []Assesstarget, err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *Assesstarget) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/qualitative_target.go b/models/modelskpi/qualitative_target.go new file mode 100644 index 0000000..b7f8284 --- /dev/null +++ b/models/modelskpi/qualitative_target.go @@ -0,0 +1,75 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" + "time" +) + +// 定性测评指标子栏目 +type QualitativeTarget struct { + Id int64 `json:"id" gorm:"primaryKey;column:q_id;type:bigint(20) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:q_title;type:varchar(255);comment:指标子栏目名称"` + ParentId int64 `json:"parentid" gorm:"column:q_parent_id;type:bigint(20) unsigned;default:0;not null;comment:归属指标"` + State int `json:"state" gorm:"column:q_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + AddTime int64 `json:"addTime" gorm:"column:q_time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"` + Depart string `json:"depart" gorm:"column:q_depart;type:mediumtext;comment:关联部门"` +} + +func (QualitativeTarget *QualitativeTarget) TableName() string { + return "qualitative_target" +} + +// 编辑内容 +func (cont *QualitativeTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *QualitativeTarget) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *QualitativeTarget) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *QualitativeTarget) ContMap(whereMap interface{}, field ...string) (countAry []QualitativeTarget, err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error + return +} + +// 删除内容 +func (cont *QualitativeTarget) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} + +// 判断子目标是否存在 +func (cont *QualitativeTarget) JudgeIsTrue(whereMap interface{}, addCont QualitativeTarget) (err error) { + err = cont.GetCont(whereMap) + if err != nil { + err = overall.CONSTANT_DB_KPI.Create(&addCont).Error + } else { + if cont.State != 1 { + err = cont.EiteCont(map[string]interface{}{"`q_id`": cont.Id}, map[string]interface{}{"`q_state`": 1, "`q_time`": time.Now().Unix()}) + } + } + return nil +} diff --git a/models/modelskpi/son_target_father.go b/models/modelskpi/son_target_father.go new file mode 100644 index 0000000..5a7d24a --- /dev/null +++ b/models/modelskpi/son_target_father.go @@ -0,0 +1,70 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 子栏目关联指标视图 +type SonTargetFather struct { + Id int64 `json:"id" gorm:"primaryKey;column:q_id;type:bigint(20) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:q_title;type:varchar(255);comment:指标子栏目名称"` + ParentId int64 `json:"parentid" gorm:"column:q_parent_id;type:bigint(20) unsigned;default:0;not null;comment:归属指标"` + State int `json:"state" gorm:"column:q_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + AddTime int64 `json:"addTime" gorm:"column:q_time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"` + Depart string `json:"depart" gorm:"column:q_depart;type:mediumtext;comment:关联部门"` + + EtTitle string `json:"ettitle" gorm:"column:et_title;type:varchar(255);comment:指标名称"` + Type int `json:"type" gorm:"column:et_type;type:int(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` + Dimension int64 `json:"dimension" gorm:"column:et_dimension;type:bigint(20) unsigned;default:0;not null;comment:维度"` + Key int64 `json:"key" gorm:"column:et_key;type:bigint(20) unsigned;default:0;not null;comment:UUID"` + Uniteing string `json:"unites" gorm:"column:et_unit;type:varchar(255);comment:计量单位"` + Cycles int `json:"cycle" gorm:"column:et_cycle;type:tinyint(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"` + CycleAttres int `json:"cycleattr" gorm:"column:et_cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"` + ScoringMethod int `json:"scoringmethod" gorm:"column:et_scoring_method;type:tinyint(1) unsigned;default:1;not null;comment:计分方式(1:自动;2:手动)"` +} + +func (SonTargetFather *SonTargetFather) TableName() string { + return "son_target_father" +} + +// 编辑内容 +func (cont *SonTargetFather) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *SonTargetFather) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *SonTargetFather) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *SonTargetFather) ContMap(whereMap interface{}, field ...string) (countAry []SonTargetFather, err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error + return +} + +// 删除内容 +func (cont *SonTargetFather) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/target_department.go b/models/modelskpi/target_department.go index 5e73545..07472ca 100644 --- a/models/modelskpi/target_department.go +++ b/models/modelskpi/target_department.go @@ -5,18 +5,19 @@ import ( "strings" ) -// 考核维度 +// 指标、栏目、细则关联部门 type TargetDepartment struct { - Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"` - 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:指标细则"` - Type int `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:指标;2:子目标;3:细则)"` - DepartmentId int64 `json:"departmentid" gorm:"column:department_id;type:bigint(20) unsigned;default:0;not null;comment:部门ID"` - PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:岗位ID"` - ReportPerson string `json:"reportperson" gorm:"column:report_person;type:longtext;comment:上报人"` - 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:写入时间"` + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"` + 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:指标细则"` + Type int `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:指标;2:子目标;3:细则)"` + DepartmentId int64 `json:"departmentid" gorm:"column:department_id;type:bigint(20) unsigned;default:0;not null;comment:部门ID"` + 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:定量考核"` + Level int `json:"level" gorm:"column:level;type:tinyint(1) unsigned;default:1;not null;comment:级别(1:部门级;2:岗位级)"` } func (TargetDepartment *TargetDepartment) TableName() string { diff --git a/models/modelskpi/target_report.go b/models/modelskpi/target_report.go new file mode 100644 index 0000000..64d4560 --- /dev/null +++ b/models/modelskpi/target_report.go @@ -0,0 +1,67 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 指标部门、岗位上报人对照表 +type TargetReport struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"` + 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:指标细则"` + DepartmentId int64 `json:"departmentid" gorm:"column:department_id;type:bigint(20) unsigned;default:0;not null;comment:部门ID"` + PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:岗位ID"` + Type int `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:公司级;2:部门级)"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + 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:定量考核"` +} + +func (TargetReport *TargetReport) TableName() string { + return "target_report" +} + +// 编辑内容 +func (cont *TargetReport) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *TargetReport) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *TargetReport) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *TargetReport) ContMap(whereMap interface{}, field ...string) (countAry []TargetReport, err error) { + gormDb := overall.CONSTANT_DB_KPI.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error + return +} + +// 删除内容 +func (cont *TargetReport) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index d0c8d85..f44d950 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -485,3 +485,25 @@ func PageTurningSettings(gormDb *gorm.DB, page, pageSize int) *gorm.DB { gormDb = gormDb.Limit(pageSize).Offset(LimitPage(page, pageSize)) return gormDb } + +//浮点数保留小数 +/* +@value 浮点数值 +@weishu 要保留的小数位数 +*/ +func DecimalEs(value float64, weishu int) float64 { + switch weishu { + case 3: + value, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", value), 64) + case 4: + value, _ = strconv.ParseFloat(fmt.Sprintf("%.4f", value), 64) + case 5: + value, _ = strconv.ParseFloat(fmt.Sprintf("%.5f", value), 64) + case 6: + value, _ = strconv.ParseFloat(fmt.Sprintf("%.6f", value), 64) + default: + value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64) + } + + return value +}