diff --git a/README.md b/README.md index df391cf..1996066 100644 --- a/README.md +++ b/README.md @@ -55,3 +55,104 @@ md5(md5(md5(CodeString)+md5(AppKey))+AppKey) ``` +<<<<<<< HEAD +======= + +## 开发日志 + +``` +Time:2022-08-10 +绩效考核数据库添加数据表 + +CREATE TABLE `depart_dime_post_weight` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `orgid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '行政组织', + `postid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '岗位', + `dimension` bigint(20) NOT NULL COMMENT '维度', + `target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标', + `weight` bigint(6) unsigned NOT NULL DEFAULT '0' COMMENT '权重', + `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '时间', + `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '1:定性考核;2:定量考核', + `hierarchy` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '1:维度;2:指标', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=MyISAM AUTO_INCREMENT=424 DEFAULT CHARSET=utf8mb4 COMMENT='岗位考核指标权重'; + +添加 model 文件 +路径 models->modelskpi depart_dime_post_weight.go + +``` + +``` +Time:2022-08-10 +绩效考核数据库添加<指标、栏目、细则关联部门>数据表 + +CREATE TABLE `target_department` ( + `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 DEFAULT '0' COMMENT '子目标', + `target_bylaws` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标细则', + `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '类型(1:指标;2:子目标)', + `department_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '部门ID', + `post_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '岗位ID', + `report_person` longtext COMMENT '上报人', + `state` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用;2:禁用;3:删除)', + `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '写入时间', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='指标、栏目、细则关联部门'; + + +添加 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 行 + +预留判断该指标是否在使用中 + +``` +>>>>>>> v1_dev diff --git a/api/base/loginVerify/login.go b/api/base/loginVerify/login.go index 7a72e9d..22db03f 100644 --- a/api/base/loginVerify/login.go +++ b/api/base/loginVerify/login.go @@ -3,7 +3,8 @@ package loginVerify import ( "fmt" "key_performance_indicators/middleware/grocerystore" - "key_performance_indicators/models" + "key_performance_indicators/models/modelshr" + "key_performance_indicators/models/modelsschool" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" @@ -45,14 +46,14 @@ func (a *ApiMethod) ScanCodeLogin(c *gin.Context) { // } //新的登录认证方式 - var userCont models.ManCont + var userCont modelshr.ManCont userErr := userCont.GetCont(map[string]interface{}{"number": requestData.Username, "password": md5TokenPwd}) if userErr != nil { publicmethod.Result(2000, userErr, c) return } if requestData.OpenId != "" { - var userInfo models.PersonArchives + var userInfo modelshr.PersonArchives userInfo.EiteCont(map[string]interface{}{"id": userCont.Id}, map[string]interface{}{"work_wechat": requestData.OpenId}) } if userCont.State == 2 { @@ -152,9 +153,9 @@ func (a *ApiMethod) ScanCodeLogin(c *gin.Context) { publicmethod.Result(0, saveData, c) } -//获取权限点位 +// 获取权限点位 func getRoleSeat(roleId string) (menuStr, buttonStr string) { - var roleInfo models.SystemRole + var roleInfo modelsschool.SystemRole err := roleInfo.GetCont(map[string]interface{}{"r_id": roleId}, "r_menu_oper", "r_jurisdiction") if err != nil { return @@ -164,7 +165,7 @@ func getRoleSeat(roleId string) (menuStr, buttonStr string) { return } -//退出登录 +// 退出登录 func (a *ApiMethod) SignOut(c *gin.Context) { userKey := c.Request.Header.Get("user-key") redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey) diff --git a/api/base/loginVerify/type.go b/api/base/loginVerify/type.go index 01e534b..531d3cd 100644 --- a/api/base/loginVerify/type.go +++ b/api/base/loginVerify/type.go @@ -1,7 +1,7 @@ package loginVerify import ( - "key_performance_indicators/models" + "key_performance_indicators/models/modelsschool" "key_performance_indicators/overall/publicmethod" "github.com/gin-gonic/gin" @@ -9,20 +9,20 @@ import ( type ApiMethod struct{} -//系统登录入口 +// 系统登录入口 func (a *ApiMethod) Index(c *gin.Context) { outputCont := publicmethod.MapOut[string]() outputCont["index"] = "系统登录入口" publicmethod.Result(0, outputCont, c) } -//验证码输出 +// 验证码输出 type SysCaptchaResponse struct { CaptchaId string `json:"captchaid"` PicPath string `json:"picPath"` } -//登录相关 +// 登录相关 type Login struct { Username string `json:"username"` // 用户名 Password string `json:"password"` // 密码 @@ -31,8 +31,8 @@ type Login struct { OpenId string `json:"openid"` //企业微信ID } -//原知行学院管理员表 +// 原知行学院管理员表 type OldSchollAdmin struct { - models.SystemUser - models.SystemUserAttribute + modelsschool.SystemUser + modelsschool.SystemUserAttribute } diff --git a/api/empower/authorize/empower.go b/api/empower/authorize/empower.go index 18b4026..b0bca28 100644 --- a/api/empower/authorize/empower.go +++ b/api/empower/authorize/empower.go @@ -2,17 +2,17 @@ package authorize import ( "fmt" + "key_performance_indicators/models/modelshr" "key_performance_indicators/overall" "strconv" "github.com/gin-gonic/gin" "key_performance_indicators/middleware/grocerystore" - "key_performance_indicators/models" "key_performance_indicators/overall/publicmethod" ) -//授权 +// 授权 func (e *EmpowerApi) GainToken(c *gin.Context) { ContentType := c.Request.Header.Get("Content-Type") Origin := c.Request.Header.Get("Origin") @@ -38,7 +38,7 @@ func (e *EmpowerApi) GainToken(c *gin.Context) { var passwordMd5 publicmethod.Md5Encryption passwordMd5.Md5EncryptionInit(requestData.Password) passwordMd5Str := passwordMd5.Md5EncryptionAlgorithm() - var empowerUser models.EmpowerUser + var empowerUser modelshr.EmpowerUser userErr := empowerUser.GetCont(map[string]interface{}{"userkey": requestData.UserNumber, "password": passwordMd5Str}, "verification_code") if userErr != nil { publicmethod.Result(2000, passwordMd5Str, c) @@ -124,7 +124,7 @@ func (e *EmpowerApi) GainToken(c *gin.Context) { publicmethod.Result(0, sendToken, c) } -//加密验证 +// 加密验证 func (e *EmpowerApi) Encryption(c *gin.Context) { var requestData EncryptionData err := c.ShouldBindJSON(&requestData) diff --git a/api/version1/departmentseting/departmentpc/qualitativekpi.go b/api/version1/departmentseting/departmentpc/qualitativekpi.go new file mode 100644 index 0000000..3c8fd15 --- /dev/null +++ b/api/version1/departmentseting/departmentpc/qualitativekpi.go @@ -0,0 +1,2279 @@ +package departmentpc + +import ( + "encoding/json" + "fmt" + "key_performance_indicators/middleware/snowflake" + "key_performance_indicators/models/modelshr" + "key_performance_indicators/models/modelskpi" + "key_performance_indicators/overall" + "key_performance_indicators/overall/publicmethod" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +// 部门指标列表 +func (a *ApiMethod) DepartmentTargetList(c *gin.Context) { + var receivedValue departListQuery + c.ShouldBindJSON(&receivedValue) + if receivedValue.Page == 0 { + receivedValue.Page = 1 + } + if receivedValue.PageSize == 0 { + receivedValue.PageSize = 20 + } + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationTarget{}) + if receivedValue.State != 0 { //状态(1:启用;2:禁用;3:删除) + gormDb = gormDb.Where("et_state = ?", receivedValue.State) + } else { + gormDb = gormDb.Where("et_state BETWEEN ? AND ?", 1, 2) + } + if receivedValue.Title != "" { //指标名称 + gormDb = gormDb.Where("et_state LIKE ?", "%"+receivedValue.Title+"%") + } + if receivedValue.Class != 0 { //1:定性考核;2:定量考核 + gormDb = gormDb.Where("et_type = ?", receivedValue.Class) + } + if receivedValue.DepartmentId != "" { //部门ID + gormDb = gormDb.Where("FIND_IN_SET(?,`departments_post`)", receivedValue.DepartmentId) + } + if receivedValue.DimensionId != "" { //维度ID + gormDb = gormDb.Where("et_dimension = ?", receivedValue.DimensionId) + } + if receivedValue.ReportPerson != "" { //上报人 + gormDb = gormDb.Where("FIND_IN_SET(?,`et_report`)", receivedValue.ReportPerson) + } + if receivedValue.ScoringMethod != 0 { //计分方式(1:自动;2:手动) + gormDb = gormDb.Where("et_scoring_method = ?", receivedValue.ScoringMethod) + } + if receivedValue.Cycle != 0 { //1:班;2:天;3:周;4:月;5:季度;6:年 + gormDb = gormDb.Where("et_cycle = ?", receivedValue.Cycle) + } + + var total int64 + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + var departmentTargetList []modelskpi.EvaluationTarget + gormDb = publicmethod.PageTurningSettings(gormDb, receivedValue.Page, receivedValue.PageSize) + err := gormDb.Order("`et_id` DESC").Find(&departmentTargetList).Error + if err != nil { + publicmethod.Result(105, err, c) + return + } + var targetList []printDepartmentTarget + for _, v := range departmentTargetList { + var targetCont printDepartmentTarget + targetCont.Id = v.Id + targetCont.Title = v.Title //指标名称"` + targetCont.Type = v.Type //1:定性考核;2:定量考核"` + targetCont.State = v.State //状态(1:启用;2:禁用;3:删除)"` + targetCont.AddTime = v.AddTime //制定时间"` + targetCont.Share = v.Share //1:共用;2:私用"` + targetCont.RelevantDepartments = v.RelevantDepartments //相关部门"` + targetCont.Dimension = v.Dimension //维度"` + targetCont.Key = v.Key //UUID"` + targetCont.Report = v.Report //上报人"` + targetCont.Uniteing = v.Uniteing //计量单位"` + targetCont.Cycles = v.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年"` + targetCont.CycleAttres = v.CycleAttres //辅助计数"` + targetCont.VisibleRange = v.VisibleRange //可见范围"` + targetCont.VisibleRangeGroup = v.VisibleRangeGroup //可见范围(集团)"` + targetCont.ScoringMethod = v.ScoringMethod //计分方式(1:自动;2:手动)"` + var dutyClassCont modelskpi.DutyClass + dutyClassCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "`title`") + targetCont.DimensionTitle = dutyClassCont.Title + targetList = append(targetList, targetCont) + } + publicmethod.ResultList(0, receivedValue.Page, receivedValue.PageSize, total, int64(len(targetList)), targetList, c) +} + +// 实验查询 +func (a *ApiMethod) Shiyan(c *gin.Context) { + // var receivedValue departListQuery + // c.ShouldBindJSON(&receivedValue) + + // if receivedValue.DepartmentId == "" { + // receivedValue.DepartmentId = "316" + // } + // if receivedValue.DimensionId == "" { + // receivedValue.DimensionId = "1" + // } + + // var evalCont []modelskpi.EvaluationTarget + + // // gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.EvaluationTarget{}).Select("evaluationtarget.*,(?) AS tdm", overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Select("id").Where("department_id = ? AND target_id = et_id ", receivedValue.DepartmentId).Find(&modelskpi.TargetDepartment{})).Having("tdm IS NOT NULL").Find(&evalCont).Error + // // fmt.Printf("gormDb----->%v----->%v\n", gormDb, evalCont) + // err := overall.CONSTANT_DB_KPI.Raw("SELECT e.*,(SELECT id FROM target_department td WHERE td.department_id = ? AND td.post_id = ? AND td.target_id = e.et_id) as tdm FROM evaluationtarget e HAVING tdm IS NOT NULL", receivedValue.DepartmentId, receivedValue.DimensionId).Scan(&evalCont).Error + // fmt.Printf("gormDb----->%v----->%v\n", err, evalCont) + //校正部门级考核 + var dimeTargetList []modelskpi.DetailedTarget + err := overall.CONSTANT_DB_KPI.Where("dt_state = 1").Find(&dimeTargetList).Error + if err != nil || len(dimeTargetList) < 1 { + publicmethod.Result(107, err, c) + return + } + // fmt.Printf("总数---->%v\n", len(dimeTargetList)) + // var xieChengChuli []modelskpi.DetailedTarget + // for i, v := range dimeTargetList { + // if (i+1)%100 == 0 { + // xieChengChuli = append(xieChengChuli, v) + // fmt.Printf("循环--%v-->%v\n", i, len(xieChengChuli)) + // xieChengChuli = []modelskpi.DetailedTarget{} + // } else { + // xieChengChuli = append(xieChengChuli, v) + // } + // } + + for _, v := range dimeTargetList { + xiaoZhengBuMen(v) + } + + 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}) + } + } +} + +// 校正部门定性考核关联关系 +func xiaoZhengBuMen(detaTar modelskpi.DetailedTarget) { + if detaTar.Paretment != "" { + bumenAry := strings.Split(detaTar.Paretment, ",") + if len(bumenAry) > 0 { + for _, v := range bumenAry { + 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) + } +} + +//编辑指标、栏目、细则关联部门 +/* +@tarId 指标 +@sunId 栏目 +@lawsId 细则 +@class 类型(1:指标;2:子目标;3:细则) +@bumenId 部门 +*/ +func zbLmXzBm(tarId, sunId, lawsId int64, class int, bumenId string) { + var tarDepCont modelskpi.TargetDepartment + where := publicmethod.MapOut[string]() + where["`target_id`"] = tarId + where["`target_sun_id`"] = sunId + where["`target_bylaws`"] = lawsId + where["`department_id`"] = bumenId + err := tarDepCont.GetCont(where, "`id`", "`state`") + if err == nil { + //存在,判断状态 + if tarDepCont.State != 1 { //不是启用状态,改为启用 + eidtWher := publicmethod.MapOut[string]() + eidtWher["``id``"] = tarDepCont.Id + saveErr := tarDepCont.EiteCont(eidtWher, 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, bumenId, saveErr) + } + } else { + tarDepCont.TargetId = tarId //指标ID"` + tarDepCont.TargetSunId = sunId //子目标"` + tarDepCont.TargetBylaws = lawsId //指标细则"` + tarDepCont.Type = class //类型(1:指标;2:子目标;3:细则)"` + bumenIdInt, _ := strconv.ParseInt(bumenId, 10, 64) + tarDepCont.DepartmentId = bumenIdInt //部门ID"` + tarDepCont.PostId = 0 //岗位ID"` + 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) + } +} + +// 获取部门定性考核部门关联列表 +func (a *ApiMethod) GetDepartAboutTarget(c *gin.Context) { + var receivedValue publicmethod.PublicId + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + var targetDepartmentID []int64 + 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 + } + var departmentList []modelshr.AdministrativeOrganization + departErr := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`,`superior`,`ispower`").Where("`id` IN ?", targetDepartmentID).Find(&departmentList).Error + if departErr != nil || len(departmentList) < 1 { + publicmethod.Result(107, err, c) + return + } + var outList []departOutcome + for _, v := range departmentList { + var outCont departOutcome + outCont.Id = strconv.FormatInt(v.Id, 10) + outCont.Name = v.Name + outCont.Superior = strconv.FormatInt(v.Superior, 10) + outCont.Ispower = v.IsPower + outList = append(outList, outCont) + } + 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`,`key`,`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.Key = strconv.FormatInt(v.Key, 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, 1) + syncSeting.Add(1) + go handleDetarildTargetRepart(targetId, sunTargetId, detaildeTarInfo.Id, operatorList, 1, 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, 1) + syncSeting.Add(1) + go handleDetarildTargetRepart(targetId, sunTargetId, detailInfof.Id, qualEvalCont.Operator, 1, 1) + syncSeting.Wait() + return nil +} + +/* +处理指标细则关联部门 +@targetId 指标ID +@targetSunId 栏目ID +@bylawsId 指标细则 +@department 接受考核部门 +@class 级别(1:部门级;2:岗位级) +@nature 1:定性考核;2:定量考核 +*/ +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 + 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 = 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 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 + 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 { + 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) 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 + //子栏目信息 + var sonTargetInfo modelskpi.QualitativeTarget + sonTargetInfo.GetCont(map[string]interface{}{"`q_id`": v.ParentIdSun}, "q_title") + outCont.SonTargetName = sonTargetInfo.Title + 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, 1) + } + if len(operatorList) > 0 { + syncSeting.Add(1) + go handleDetarildTargetRepart(sonTargetCont.ParentId, sonTargetCont.Id, v, operatorList, 1, 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(map[string]interface{}{"target_id": sonTargetCont.ParentId, "target_sun_id": sonTargetCont.Id, "`state`": 1}, delTime) + //软删除所有此子栏目相关联的提报人 + syncSeting.Add(1) + go softDelTargetReport(map[string]interface{}{"`target_id`": sonTargetCont.ParentId, "`target_sun_id`": sonTargetCont.Id, "`state`": 1}, 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(where interface{}, delTime int64) { + defer syncSeting.Done() + var delTargetReport modelskpi.TargetReport + delTargetReport.EiteCont(where, map[string]interface{}{"`state`": 3, "`time`": delTime}) +} + +// 软删除所有此子栏目相关的联部门 +func softDelTargetDepartment(where interface{}, delTime int64) { + defer syncSeting.Done() + var delTargetDepartment modelskpi.TargetDepartment + delTargetDepartment.EiteCont(where, 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 + } + var outDataCont NewOutPutDetailedTarget + outDataCont.Id = strconv.FormatInt(detailedTargetCont.Id, 10) + outDataCont.Title = detailedTargetCont.Title //考核内容 + outDataCont.Content = detailedTargetCont.Content //备注说明 + outDataCont.Unit = detailedTargetCont.Company //单位 + biaoZhun := "" + if detailedTargetCont.MinScore != 0 { + biaoZhun = fmt.Sprintf("%v-%v", detailedTargetCont.MinScore, detailedTargetCont.MaxScore) + } else { + biaoZhun = fmt.Sprintf("%v", detailedTargetCont.MaxScore) + } + outDataCont.ReferenceScore = biaoZhun //考核标准 + outDataCont.Cycles = detailedTargetCont.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 + outDataCont.CycleAttres = detailedTargetCont.CycleAttres //辅助计数 + outDataCont.Operator, outDataCont.ReportManList, _ = getDetailedReport(detailedTargetCont.ParentId, detailedTargetCont.ParentIdSun, detailedTargetCont.Id, 1) //考核执行人 + outDataCont.AddOrReduce = detailedTargetCont.AddReduce //操作类型 1:减少;2:增加;3:用户自定义 + outDataCont.CensorType = strings.Split(detailedTargetCont.CensorType, ",") //检查方式(1:现场检查;2:资料检查;3:事件触发) + outDataCont.CensorCont = detailedTargetCont.CensorCont //客观证据 + outDataCont.CensorRate = detailedTargetCont.CensorRate //检查频次 + outDataCont.DepartmentList, _, _ = getDetailedDepartment(detailedTargetCont.ParentId, detailedTargetCont.ParentIdSun, detailedTargetCont.Id, 1) //接受考核的部门 + publicmethod.Result(0, outDataCont, c) +} + +// 获取指标细则接受考核部门 +func getDetailedDepartment(targetId, targetSunId, bylawsId int64, class int) (departmentStr []string, departmentInfo []departOutcome, err error) { + if class == 0 { + class = 1 + } + var departmentId []int64 + err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetDepartment{}).Distinct("`department_id`").Where("`state` = 1 AND `level` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?", class, targetId, targetSunId, bylawsId).Find(&departmentId).Error + if err != nil || len(departmentId) < 1 { + return + } + var orgList []modelshr.AdministrativeOrganization + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`,`name`,`superior`,`ispower`") + if len(departmentId) > 1 { + gormDb = gormDb.Where("`id` IN ?", departmentId) + } else { + gormDb = gormDb.Where("`id` = ?", departmentId) + } + + err = gormDb.Find(&orgList).Error + if err != nil || len(orgList) < 1 { + return + } + for _, v := range orgList { + departIdStr := strconv.FormatInt(v.Id, 10) + if publicmethod.IsInTrue[string](departIdStr, departmentStr) == false { + var departCont departOutcome + departCont.Id = departIdStr + departCont.Name = v.Name + departCont.Superior = strconv.FormatInt(v.Superior, 10) //上级 + departCont.Ispower = v.IsPower //是否为主部门 + departmentStr = append(departmentStr, departIdStr) + departmentInfo = append(departmentInfo, departCont) + } + } + return +} + +// 获取指标细则执行人 +func getDetailedReport(targetId, targetSunId, bylawsId int64, class int) (userKey []string, userCont []printReportCont, err error) { + if class == 0 { + class = 1 + } + var userKeyInt []int64 + err = overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("`man_key`").Where("`state` = 1 AND `type` = ? AND `target_id` = ? AND `target_sun_id` = ? AND `target_bylaws` = ?", class, targetId, targetSunId, bylawsId).Find(&userKeyInt).Error + if err != nil || len(userKeyInt) < 1 { + return + } + var userContList []modelshr.PersonArchives + gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.PersonArchives{}).Select("`id`,`number`,`name`,`icon`,`company`,`maindeparment`") + if len(userKeyInt) > 1 { + gormDb = gormDb.Where("`key` IN ?", userKeyInt) + } else { + gormDb = gormDb.Where("`key` = ?", userKeyInt) + } + err = gormDb.Find(&userContList).Error + if err != nil || len(userContList) < 1 { + return + } + for _, v := range userContList { + userKeyStr := strconv.FormatInt(v.Id, 10) + if publicmethod.IsInTrue[string](userKeyStr, userKey) == false { + var userInfo printReportCont + userInfo.Id = userKeyStr + userInfo.Name = v.Name + var groupCont modelshr.AdministrativeOrganization + groupCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") + userInfo.GroupName = groupCont.Name + var deparHrCont modelshr.AdministrativeOrganization + deparHrCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`") + userInfo.DepartmentName = deparHrCont.Name + userInfo.Icon = v.Icon + userInfo.Number = v.Number + userKey = append(userKey, userKeyStr) + userCont = append(userCont, userInfo) + } + + } + return +} + +// 编辑单一指标细则内容 +func (a *ApiMethod) EditOneDetailedTarget(c *gin.Context) { + var receivedValue editOneDetailedTargetInfo + c.ShouldBindJSON(&receivedValue) + + var judgeDetaCont modelskpi.DetailedTarget + judgeDetaErr := judgeDetaCont.GetCont(map[string]interface{}{"`dt_id`": receivedValue.Id}) + if judgeDetaErr != nil { + publicmethod.Result(107, receivedValue, 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 + } + } + } + if len(receivedValue.DepartmentList) < 1 { + //获取子栏目接受考核部门 + 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` = ?", judgeDetaCont.ParentId, judgeDetaCont.ParentIdSun).Find(&aboutTarDepList).Error + if aboutTDErr == nil { + for _, atdv := range aboutTarDepList { + receivedValue.DepartmentList = append(receivedValue.DepartmentList, strconv.FormatInt(atdv, 10)) + } + } + } + if len(receivedValue.QualEvalSunList.Operator) < 1 { + var aboutTarDepRepList []int64 + aboutReTDErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.TargetReport{}).Distinct("`man_key`").Where("`state` = 1 AND `type` = 1 AND `target_id` = ? AND `target_sun_id` = ?", judgeDetaCont.ParentId, judgeDetaCont.ParentIdSun).Find(&aboutTarDepRepList).Error + if aboutReTDErr == nil { + for _, atdv := range aboutTarDepRepList { + receivedValue.QualEvalSunList.Operator = append(receivedValue.QualEvalSunList.Operator, strconv.FormatInt(atdv, 10)) + } + } + } + err := editDetaAdd(judgeDetaCont.ParentId, judgeDetaCont.ParentIdSun, receivedValue.QualEvalSunList, judgeDetaCont, receivedValue.DepartmentList) + if err != nil { + publicmethod.Result(106, receivedValue, c) + return + } + publicmethod.Result(0, err, c) +} + +// 删除单一指标细则 +func (a *ApiMethod) DelOneDetailedTarget(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 + } + delTime := time.Now().Unix() + err = detailedTargetCont.EiteCont(where, map[string]interface{}{"dt_state": 3, "dt_time": delTime}) + if err != nil { + publicmethod.Result(106, err, c) + return + } + + //软删除所有此子栏目相关的联部门 + syncSeting.Add(1) + go softDelTargetDepartment(map[string]interface{}{"target_id": detailedTargetCont.ParentId, "`target_sun_id`": detailedTargetCont.ParentIdSun, "target_bylaws": detailedTargetCont.Id, "`state`": 1}, delTime) + //软删除所有此子栏目相关联的提报人 + syncSeting.Add(1) + go softDelTargetReport(map[string]interface{}{"`target_id`": detailedTargetCont.ParentId, "`target_sun_id`": detailedTargetCont.ParentIdSun, "target_bylaws": detailedTargetCont.Id, "`state`": 1}, delTime) + syncSeting.Wait() + publicmethod.Result(0, err, c) +} + +// 添加部门指标 +func (a *ApiMethod) AddDepartmentTarget(c *gin.Context) { + var receivedValue addTargetContDepart + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, 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 + } + 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 + } + var uuId int64 = 0 + snowflakeId, snowflakeErr := snowflake.NewWorker(1) + if snowflakeErr != nil { + uuId = publicmethod.TableNumber() + } else { + uuId = snowflakeId.GetId() + } + + var saveData modelskpi.EvaluationTarget + saveData.Title = receivedValue.Name //指标名称"` + saveData.Type = receivedValue.Nature //1:定性考核;2:定量考核"` + saveData.State = 1 //状态(1:启用;2:禁用;3:删除)"` + saveData.AddTime = time.Now().Unix() //制定时间"` + saveData.Share = 1 //1:共用;2:私用"` + saveData.RelevantDepartments = strings.Join(receivedValue.AcceptDepartmentId, ",") //相关部门"` + dimensionId, _ := strconv.ParseInt(receivedValue.Dimension, 10, 64) + saveData.Dimension = dimensionId //维度"` + saveData.Key = uuId //UUID"` + saveData.Report = strings.Join(receivedValue.Operator, ",") //上报人"` + saveData.Uniteing = receivedValue.Unit //计量单位"` + saveData.Cycles = receivedValue.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年"` + saveData.CycleAttres = receivedValue.CycleAttres //辅助计数"` + saveData.VisibleRange = strings.Join(receivedValue.VisibleRangeDepart, ",") //可见范围"` + saveData.VisibleRangeGroup = strings.Join(receivedValue.VisibleRangeGroup, ",") //可见范围(集团)"` + saveData.ScoringMethod = receivedValue.ScoringMethod //计分方式(1:自动;2:手动)"` + err = overall.CONSTANT_DB_KPI.Create(&saveData).Error + if err != nil { + publicmethod.Result(104, err, c) + return + } + + if len(receivedValue.AcceptDepartmentId) > 0 { + syncSeting.Add(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, 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).Where("`level` = ?", level).Find(&departmentId).Error + if err == nil { + for _, v := range departmentId { + departmentIdStr = append(departmentIdStr, strconv.FormatInt(v, 10)) + } + } + 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).Where("`type` = ?", level).Find(&userKey).Error + if err == nil { + for _, v := range userKey { + userKeyStr = append(userKeyStr, strconv.FormatInt(v, 10)) + } + } + return +} + +// 获取单一指标详细内容 +func (a *ApiMethod) GetOneTergetInfo(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["et_id"] = receivedValue.Id + var targetCont modelskpi.EvaluationTarget + err = targetCont.GetCont(where) + if err != nil { + publicmethod.Result(107, err, c) + return + } + var outCont printOneTargetCont + outCont.Id = strconv.FormatInt(targetCont.Id, 10) + outCont.Name = targetCont.Title + outCont.Share = targetCont.Share //1:共用;2:私用 + outCont.AcceptDepartmentId = strings.Split(targetCont.RelevantDepartments, ",") //接受考核部门 + outCont.Operator = strings.Split(targetCont.Report, ",") //考核执行人 + outCont.Dimension = strconv.FormatInt(targetCont.Dimension, 10) //维度 + outCont.Nature = targetCont.Type //性质 1:定性考核;2:定量考核 + outCont.Unit = targetCont.Uniteing //单位 + outCont.Cycles = targetCont.Cycles //1:班;2:天;3:周;4:月;5:季度;6:年 + outCont.CycleAttres = targetCont.CycleAttres //辅助计数 + outCont.ScoringMethod = targetCont.ScoringMethod //计分方式(1:自动;2:手动)' + outCont.VisibleRangeGroup = strings.Split(targetCont.VisibleRangeGroup, ",") //可见范围(集团) + 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 岗位 +@repart 提报人 +@class 级别(1:部门级;2:岗位级) +@nature 1:定性考核;2:定量考核 +func departAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []loopStruct, class, nature int) +*/ +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 new file mode 100644 index 0000000..408b771 --- /dev/null +++ b/api/version1/departmentseting/departmentpc/type.go @@ -0,0 +1,200 @@ +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]() + outputCont["index"] = "部门考核PC端入口" + publicmethod.Result(0, outputCont, c) +} + +// 查询部门考核列表 +type departListQuery struct { + publicmethod.PagesTurn + Title string `json:"title"` //指标名称 + Class int `json:"class"` //1:定性考核;2:定量考核 + State int `json:"state"` //状态(1:启用;2:禁用;3:删除) + DepartmentId string `json:"departmentid"` //部门ID + DimensionId string `json:"dimensionid"` //维度ID + ReportPerson string `json:"reportperson"` //上报人 + ScoringMethod int `json:"scoringmethod"` //计分方式(1:自动;2:手动) + Cycle int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年 +} + +// 输出部门指标列表 +type printDepartmentTarget struct { + modelskpi.EvaluationTarget + DimensionTitle string `json:"dimensiontitle"` //维度名称 +} + +// 输出指标已经关联的部门 +type departOutcome struct { + publicmethod.PublicId //部门id + publicmethod.PublicName //部门名称 + 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"` + Key string `json:"key"` + 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:事件触发) + SonTargetName string `json:"sontargetname"` //子栏目名称 +} + +// 根据指标栏目新增指标细则 +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 +} + +// 输出新版指标细则详细内容 +type NewOutPutDetailedTarget struct { + publicmethod.PublicId + QualEvalSunList + ReportManList []printReportCont `json:"reportmanlist"` //上报人 + DepartmentList []string `json:"departmentlist"` //接受考核的部门 +} + +// 修改单一指标细则内容提交参数 +type editOneDetailedTargetInfo struct { + basisSonTargetAddDet + DepartmentList []string `json:"departmentlist"` //接受考核的部门 +} + +// 添加部门指标参数 +type addTargetContDepart struct { + publicmethod.PublicName + Share int `json:"share"` //1:共用;2:私用 + AcceptDepartmentId []string `json:"acceptdepartmentid"` //接受考核部门 + Operator []string `json:"userlist"` //考核执行人 + Dimension string `json:"dimension"` //维度 + Nature int `json:"nature"` //性质 1:定性考核;2:定量考核 + Unit string `json:"unit"` //单位 + Cycles int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年 + CycleAttres int `json:"cycleattr"` //辅助计数 + ScoringMethod int `json:"scoringmethod"` //计分方式(1:自动;2:手动)' + VisibleRangeGroup []string `json:"visiblerangegroup"` //可见范围(集团) + VisibleRangeDepart []string `json:"visiblerangedepart"` //可见范围(分厂) +} + +// 输出单一指标详细内容 +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/departmentseting/departmentweb/type.go b/api/version1/departmentseting/departmentweb/type.go new file mode 100644 index 0000000..93517db --- /dev/null +++ b/api/version1/departmentseting/departmentweb/type.go @@ -0,0 +1,16 @@ +package departmentweb + +import ( + "key_performance_indicators/overall/publicmethod" + + "github.com/gin-gonic/gin" +) + +type ApiMethod struct{} + +// 部门考核WEB端入口 +func (a *ApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["index"] = "部门考核WEB端入口" + publicmethod.Result(0, outputCont, c) +} diff --git a/api/version1/entry.go b/api/version1/entry.go index c13609d..cef8218 100644 --- a/api/version1/entry.go +++ b/api/version1/entry.go @@ -1,9 +1,19 @@ package version1 -import "key_performance_indicators/api/version1/honoraryArchives" +import ( + "key_performance_indicators/api/version1/departmentseting/departmentpc" + "key_performance_indicators/api/version1/departmentseting/departmentweb" + "key_performance_indicators/api/version1/honoraryArchives" + "key_performance_indicators/api/version1/postseting/postpc" + "key_performance_indicators/api/version1/postseting/postweb" +) type ApiEntry struct { - HonorsApi honoraryArchives.ApiMethod + HonorsApi honoraryArchives.ApiMethod + PostPcApi postpc.ApiMethod + PostWebApi postweb.ApiMethod + DeparmentPcApi departmentpc.ApiMethod + DeparmentWebApi departmentweb.ApiMethod } var AppApiEntry = new(ApiEntry) diff --git a/api/version1/honoraryArchives/carriertype.go b/api/version1/honoraryArchives/carriertype.go index b77da1d..7cca4d1 100644 --- a/api/version1/honoraryArchives/carriertype.go +++ b/api/version1/honoraryArchives/carriertype.go @@ -1,7 +1,7 @@ package honoraryArchives import ( - "key_performance_indicators/models" + "key_performance_indicators/models/modelshonory" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" "time" @@ -11,7 +11,7 @@ import ( //档案载体 -//列表 +// 列表 func (a *ApiMethod) CarrierList(c *gin.Context) { var requestData carrierListKey errs := c.ShouldBindJSON(&requestData) @@ -19,8 +19,8 @@ func (a *ApiMethod) CarrierList(c *gin.Context) { publicmethod.Result(100, errs, c) return } - var carrierList []models.CarrierType - gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&models.CarrierType{}).Where("`state` BETWEEN ? AND ?", 1, 2) + var carrierList []modelshonory.CarrierType + gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&modelshonory.CarrierType{}).Where("`state` BETWEEN ? AND ?", 1, 2) if requestData.Name != "" { gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Name+"%") } @@ -38,7 +38,7 @@ func (a *ApiMethod) CarrierList(c *gin.Context) { publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(carrierList)), carrierList, c) } -//添加载体类型 +// 添加载体类型 func (a *ApiMethod) AddCarrier(c *gin.Context) { var requestData addCarrierCont err := c.ShouldBindJSON(&requestData) @@ -50,7 +50,7 @@ func (a *ApiMethod) AddCarrier(c *gin.Context) { publicmethod.Result(101, err, c) return } - var carrierCont models.CarrierType + var carrierCont modelshonory.CarrierType juadgeErr := carrierCont.GetCont(map[string]interface{}{"`name`": requestData.Name}, "`id`") if juadgeErr == nil { if carrierCont.Id != 0 { @@ -68,7 +68,7 @@ func (a *ApiMethod) AddCarrier(c *gin.Context) { } } -//编辑荣誉类型 +// 编辑荣誉类型 func (a *ApiMethod) EidyCarrier(c *gin.Context) { var requestData eidyCarrierCont err := c.ShouldBindJSON(&requestData) @@ -84,14 +84,14 @@ func (a *ApiMethod) EidyCarrier(c *gin.Context) { publicmethod.Result(101, err, c) return } - var carrierCont models.CarrierType + var carrierCont modelshonory.CarrierType conErr := carrierCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`name`") if conErr != nil { publicmethod.Result(107, conErr, c) return } if requestData.Name != carrierCont.Name { - var oldCarrierCont models.CarrierType + var oldCarrierCont modelshonory.CarrierType conErrOld := oldCarrierCont.GetCont(map[string]interface{}{"`name`": requestData.Name}, "`id`") if conErrOld == nil { publicmethod.Result(103, err, c) @@ -111,7 +111,7 @@ func (a *ApiMethod) EidyCarrier(c *gin.Context) { publicmethod.Result(0, err, c) } -//编辑荣誉类型状态 +// 编辑荣誉类型状态 func (a *ApiMethod) EidyCarrierState(c *gin.Context) { var requestData publicmethod.PublicState c.ShouldBindJSON(&requestData) @@ -127,7 +127,7 @@ func (a *ApiMethod) EidyCarrierState(c *gin.Context) { } where := publicmethod.MapOut[string]() where["id"] = requestData.Id - var carrierTypeCont models.CarrierType + var carrierTypeCont modelshonory.CarrierType judgeErr := carrierTypeCont.GetCont(where, "`id`") if judgeErr != nil { publicmethod.Result(107, judgeErr, c) diff --git a/api/version1/honoraryArchives/honors.go b/api/version1/honoraryArchives/honors.go index 8e754d6..71584c9 100644 --- a/api/version1/honoraryArchives/honors.go +++ b/api/version1/honoraryArchives/honors.go @@ -3,7 +3,7 @@ package honoraryArchives import ( "fmt" "key_performance_indicators/middleware/snowflake" - "key_performance_indicators/models" + "key_performance_indicators/models/modelshonory" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" "strconv" @@ -13,12 +13,12 @@ import ( "gorm.io/gorm" ) -//荣誉列表 +// 荣誉列表 func (a *ApiMethod) HonorList(c *gin.Context) { var requestData honorListKey c.ShouldBindJSON(&requestData) - var honorsList []models.HonoraryArchives - gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&models.HonoraryArchives{}).Where("state BETWEEN ? AND ?", 1, 2) + var honorsList []modelshonory.HonoraryArchives + gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&modelshonory.HonoraryArchives{}).Where("state BETWEEN ? AND ?", 1, 2) if requestData.Name != "" { gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Name+"%") } @@ -61,7 +61,7 @@ func (a *ApiMethod) HonorList(c *gin.Context) { publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(honorsList)), honorsList, c) } -//添加荣誉 +// 添加荣誉 func (a *ApiMethod) AddHonorCont(c *gin.Context) { var requestData addHonorCont //添加荣誉字段 c.ShouldBindJSON(&requestData) @@ -80,7 +80,7 @@ func (a *ApiMethod) AddHonorCont(c *gin.Context) { } else { uuId = snowflakeId.GetId() } - var honorCont models.HonoraryArchives + var honorCont modelshonory.HonoraryArchives honorCont.Id = uuId honorCont.Name = requestData.Name //荣誉名称"` honorCont.IssuingUnit = requestData.IssuingAgency //发放单位"` @@ -108,9 +108,13 @@ func (a *ApiMethod) AddHonorCont(c *gin.Context) { honorCont.Time = time.Now().Unix() //创建时间"` honorCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` if len(requestData.ImgUrl) > 0 { +<<<<<<< HEAD var imgList []models.PhotosGallery //图片档案 +======= + var imgList []modelshonory.PhotosGallery +>>>>>>> v1_dev for _, v := range requestData.ImgUrl { - var imgCont models.PhotosGallery + var imgCont modelshonory.PhotosGallery imgCont.Url = v.Url //图片地址"` imgCont.ImgPath = v.Imgpath //物理地址"` imgCont.Name = v.Name //文档名称"` @@ -147,7 +151,7 @@ func (a *ApiMethod) AddHonorCont(c *gin.Context) { } } -//编辑荣誉 +// 编辑荣誉 func (a *ApiMethod) EidyHonorCont(c *gin.Context) { var requestData eidtHonorCont c.ShouldBindJSON(&requestData) @@ -162,7 +166,7 @@ func (a *ApiMethod) EidyHonorCont(c *gin.Context) { where := publicmethod.MapOut[string]() where["id"] = requestData.Id //原信息 - var honContOld models.HonoraryArchives + var honContOld modelshonory.HonoraryArchives err := honContOld.GetCont(where) if err != nil { publicmethod.Result(107, err, c) @@ -213,7 +217,7 @@ func (a *ApiMethod) EidyHonorCont(c *gin.Context) { if requestData.Remark != "" && requestData.Remark != honContOld.Contet { saveData["contet"] = requestData.Remark } - var imgUrlListNoId []models.PhotosGallery + var imgUrlListNoId []modelshonory.PhotosGallery var pldImgId []int64 if len(requestData.ImgUrl) > 0 { for _, v := range requestData.ImgUrl { @@ -223,7 +227,7 @@ func (a *ApiMethod) EidyHonorCont(c *gin.Context) { pldImgId = append(pldImgId, oldIdInt) } } else { - var imgCont models.PhotosGallery + var imgCont modelshonory.PhotosGallery imgCont.Url = v.Url //图片地址"` imgCont.ImgPath = v.Imgpath //物理地址"` imgCont.Name = v.Name //文档名称"` @@ -238,7 +242,7 @@ func (a *ApiMethod) EidyHonorCont(c *gin.Context) { } if len(imgUrlListNoId) > 0 { - var imgList models.PhotosGallery + var imgList modelshonory.PhotosGallery saveErr := overall.CONSTANT_DB_MANAGE_ARCHIVES.Transaction(func(tx *gorm.DB) error { if len(pldImgId) > 0 { if err := tx.Not(map[string]interface{}{"`id`": pldImgId}).Where(map[string]interface{}{"`ascription_id`": requestData.Id, "`ascription_data_sheet`": "honorary_archives"}).Delete(&imgList).Error; err != nil { @@ -252,7 +256,7 @@ func (a *ApiMethod) EidyHonorCont(c *gin.Context) { saveData["time"] = time.Now().Unix() - if err := tx.Model(&models.HonoraryArchives{}).Where(where).Updates(&saveData).Error; err != nil { + if err := tx.Model(&modelshonory.HonoraryArchives{}).Where(where).Updates(&saveData).Error; err != nil { // 返回任何错误都会回滚事务 return err } @@ -274,7 +278,7 @@ func (a *ApiMethod) EidyHonorCont(c *gin.Context) { saveData["time"] = time.Now().Unix() saveErr := honContOld.EiteCont(where, saveData) if saveErr == nil { - var imgList models.PhotosGallery + var imgList modelshonory.PhotosGallery if len(pldImgId) > 0 { overall.CONSTANT_DB_MANAGE_ARCHIVES.Not(map[string]interface{}{"`id`": pldImgId, "`ascription_id`": requestData.Id, "`ascription_data_sheet`": "honorary_archives"}).Delete(&imgList) } else { @@ -287,7 +291,7 @@ func (a *ApiMethod) EidyHonorCont(c *gin.Context) { } } -//编辑状态 +// 编辑状态 func (a *ApiMethod) EidyHonorContState(c *gin.Context) { var requestData publicmethod.PublicState c.ShouldBindJSON(&requestData) @@ -303,7 +307,7 @@ func (a *ApiMethod) EidyHonorContState(c *gin.Context) { } where := publicmethod.MapOut[string]() where["id"] = requestData.Id - var carrierTypeCont models.HonoraryArchives + var carrierTypeCont modelshonory.HonoraryArchives judgeErr := carrierTypeCont.GetCont(where, "`id`") if judgeErr != nil { publicmethod.Result(107, judgeErr, c) diff --git a/api/version1/postseting/postpc/scheme.go b/api/version1/postseting/postpc/scheme.go new file mode 100644 index 0000000..f702d46 --- /dev/null +++ b/api/version1/postseting/postpc/scheme.go @@ -0,0 +1,685 @@ +package postpc + +import ( + "encoding/json" + "fmt" + "key_performance_indicators/models/modelshr" + "key_performance_indicators/models/modelskpi" + "key_performance_indicators/overall" + "key_performance_indicators/overall/publicmethod" + "sort" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +// 获取岗位相关指标 +func (a *ApiMethod) GetPostAboutTarget(c *gin.Context) { + var receivedValue publicmethod.PublicId + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + //获取岗位相关信息 + var postCont modelshr.Position + postContErr := postCont.GetCont(map[string]interface{}{"`id`": receivedValue.Id}, "`id`", "`duties`", "`administrative_organization`", "`superior`", "`department`") + if postContErr != nil { + publicmethod.Result(107, postContErr, c) + return + } + //根据维度生成方案列表 + //1、获取维度 + var dimensionModels modelskpi.DutyClass + dimensionList, dimeErr := dimensionModels.ContMap(map[string]interface{}{"`state`": 1}, "`id`", "`title`", "`sort`") + fmt.Printf("dimensionList--->%v\n", dimensionList) + if dimeErr != nil || len(dimensionList) <= 0 { + publicmethod.Result(107, postContErr, c) + return + } + //2、根据维度获取岗位相关指标 + var postPlanSync postDimeTarSync + for _, v := range dimensionList { + syncSeting.Add(1) + go postPlanSync.GetPostTargent(postCont, v) + } + syncSeting.Wait() + planAry := postPlanSync.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) +} + +// 获取岗位与维度相关的指标 +/* +@position 岗位信息 +@dutyClass 维度信息 +*/ +func (p *postDimeTarSync) GetPostTargent(position modelshr.Position, dutyClass modelskpi.DutyClass) { + p.mutext.Lock() + defer p.mutext.Unlock() + //获取相关指标 + var postTargetList []modelskpi.PostTarget + postTarErr := overall.CONSTANT_DB_KPI.Model(&modelskpi.PostTarget{}).Where("`state` = 1 AND `dimension` = ? AND `rele_depart` = ? AND FIND_IN_SET(?,`departments_post`)", dutyClass.Id, position.AdministrativeOrganization, position.Id).Find(&postTargetList).Error + fmt.Printf("postTargetList---->%v\n", postTargetList) + if postTarErr == nil && len(postTargetList) > 0 { + var planCont postAboutDimeTar + planCont.Id = strconv.FormatInt(dutyClass.Id, 10) + planCont.Name = dutyClass.Title + planCont.Sort = dutyClass.Sort + for _, v := range postTargetList { + 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, 1) //标准分 + targetCont.Unit = v.Unit //单位 + targetCont.IsTrue = 2 //是否允许修改 1:不允许;2:允许 + targetCont.State = 1 //状态 1:启用;2:禁用;3:观察 + + planCont.Child = append(planCont.Child, targetCont) + } + p.planList = append(p.planList, planCont) + } + syncSeting.Done() +} + +/* +获取岗位考核指标或维度标准分 +@orgid 行政组织 +@postid 岗位 +@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, 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 { + where["hierarchy"] = 1 + // ddpwCont.GetCont(map[string]interface{}{"orgid": orgid, "postid": postid, "dimension": dimensionid, "hierarchy": 1}, "`weight`") + ddpwCont.GetCont(where, "`weight`") + } else { + 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 + } + orderIdInt, _ := strconv.ParseInt(receivedValue.OrgId, 10, 64) + //根据行政组织Id获取集团信息,及部门信息 + groupId, companyId, departmentId, sunDepartId, workShopId := publicmethod.GetOrgStructure(orderIdInt) + //获取公司首字母 + var companyCont modelshr.AdministrativeOrganization + companyCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`", "`abbreviation`") + firstNameWord := companyCont.Abbreviation + if firstNameWord == "" { + firstNameWord = companyCont.Name + } + companyFirstWord := publicmethod.ChineseFirstWordCapitalize(firstNameWord) //公司首字母 + //获取部门首字母 + var departmentCont modelshr.AdministrativeOrganization + departmentCont.GetCont(map[string]interface{}{"`id`": departmentId}, "`name`", "`abbreviation`") + firstNameWordDepart := departmentCont.Abbreviation + if firstNameWordDepart == "" { + firstNameWordDepart = departmentCont.Name + } + departmentFirstWord := publicmethod.ChineseFirstWordCapitalize(firstNameWordDepart) //部门首字母 + + judgeState := 1 //方案初始状态 + //判断该岗位是否有生成的考核方案 + var versionState []int + overall.CONSTANT_DB_KPI.Model(&modelskpi.PositionPlanVersio{}).Select("state").Where("`group` = ? AND `department` = ? AND `orgid` = ? AND `position` = ?", companyId, departmentId, orderIdInt, receivedValue.PostId).Find(&versionState) + fmt.Printf("versionState----------->%v------------>%v\n", len(versionState), versionState) + if len(versionState) > 0 { + for _, s_v := range versionState { + if s_v == 1 { + judgeState = 2 + } + } + } + var versioNum string //版本号 + //判断年度是否存在版本 + var sumVerson int64 + judgeVersioNum := overall.CONSTANT_DB_KPI.Model(&modelskpi.PositionPlanVersio{}).Select("`id`").Where("`group` = ? AND `department` = ? AND `years` = ?", companyId, departmentId, receivedValue.Year).Pluck("COALESCE(COUNT(id), 0) as countid", &sumVerson).Error + if judgeVersioNum != nil { + versioNum = "0001" + } else { + if sumVerson == 0 { + versioNum = "0001" + } else { + sumVerson++ + sumVersonStr := strconv.FormatInt(sumVerson, 10) + versioNum = publicmethod.ZeroFillByStr(sumVersonStr, 4, true) + } + } + todyTime := time.Now().Unix() + versionNumber := fmt.Sprintf("%v-%v-%v%v", companyFirstWord, departmentFirstWord, publicmethod.UnixTimeToDay(todyTime, 21), versioNum) + postIdInt, _ := strconv.ParseInt(receivedValue.PostId, 10, 64) //岗位id转成整形 + yearInt, _ := strconv.ParseInt(receivedValue.Year, 10, 64) + + jsonPlanCont, _ := json.Marshal(receivedValue) + //准备写入方案 + var postPlanScheme modelskpi.PositionPlanVersio + + postPlanScheme.Group = companyId //归属集团"` + postPlanScheme.Department = departmentId //归属部门"` + postPlanScheme.OrgId = orderIdInt //行政组织"` + postPlanScheme.Position = postIdInt //归属岗位"` + postPlanScheme.Key = versionNumber //编码"` + postPlanScheme.Versio = versioNum //版本号"` + postPlanScheme.Year = yearInt //年度"` + postPlanScheme.State = judgeState //状态(1:启用;2:禁用;3:删除)"` + postPlanScheme.AddTime = todyTime //创建时间"` + postPlanScheme.EiteTime = todyTime //修改时间"` + postPlanScheme.Content = string(jsonPlanCont) //版本内容"` + + err := overall.CONSTANT_DB_KPI.Create(&postPlanScheme).Error + if err != nil { + publicmethod.Result(104, receivedValue.OrgId, c, "请检查您的数据格式!") + return + } + fmt.Printf("groupId-------->%v---->companyId-------->%v---->departmentId-------->%v---->sunDepartId-------->%v---->workShopId-------->%v---------versionNumber----------->%v---------judgeState----------->%v\n", groupId, companyId, departmentId, sunDepartId, workShopId, versionNumber, judgeState) + + //岗位指标处理 + if len(receivedValue.PostChild) > 0 { + syncSeting.Add(1) + go postSchemeTarget(versionNumber, 1, judgeState, receivedValue.PostChild, companyId, departmentId, orderIdInt, postIdInt) + } + + //引用部门指标处理 + if len(receivedValue.DepartmentChild) > 0 { + syncSeting.Add(1) + go postSchemeTarget(versionNumber, 2, judgeState, receivedValue.DepartmentChild, companyId, departmentId, orderIdInt, postIdInt) + } + syncSeting.Wait() + jsonCont, _ := json.Marshal(postPlanScheme) + publicmethod.Result(0, string(jsonCont), c) +} + +/* +岗位指标写入 +@versionNumber 方案版本号 +@source 来源(1:岗位;2:部门引用) +@judgeState 考核项状态 +@scheme 方案结构体 +@companyId 公司 +@departmentId 部门 +@orgid 行政组织 +@postid 岗位 +*/ +func postSchemeTarget(versionNumber string, source, judgeState int, scheme []schemeStructure, companyId, departmentId, orgid, postid int64) { + defer syncSeting.Done() + timeData := time.Now().Unix() + var saveNewData []modelskpi.QualitativeEvaluationScheme + for _, v := range scheme { //解析维度 + dimensionIdInt64, _ := strconv.ParseInt(v.Id, 10, 64) //转换维度ID + if len(v.Child) > 0 { //判断是否有指标 + for _, cv := range v.Child { //解析指标 + targetIdInt64, _ := strconv.ParseInt(cv.Id, 10, 64) //转换指标ID + var saveData modelskpi.QualitativeEvaluationScheme + scoringMethod := 1 + //判断计分方式 + if source != 1 { //来源于部门引用 + var departTargetInfo modelskpi.EvaluationTarget + departTargetInfo.GetCont(map[string]interface{}{"`et_id`": targetIdInt64}, "`et_scoring_method`") + if departTargetInfo.ScoringMethod != 0 { + scoringMethod = departTargetInfo.ScoringMethod + } + + } else { //来源于岗位考核 + var departPostTargetInfo modelskpi.PostTarget + departPostTargetInfo.GetCont(map[string]interface{}{"`id`": targetIdInt64}, "`scoring_method`") + if departPostTargetInfo.ScoringMethod != 0 { + scoringMethod = departPostTargetInfo.ScoringMethod + } + } + if cv.Type != 1 { //定量考核 + //判断该指标是否存在 + whereLian := publicmethod.MapOut[string]() + whereLian["`version_number`"] = versionNumber + whereLian["`company_id`"] = companyId + whereLian["`department_id`"] = departmentId + whereLian["`org_id`"] = orgid + whereLian["`post_id`"] = postid + whereLian["`dimension_id`"] = dimensionIdInt64 + whereLian["`target_id`"] = targetIdInt64 + judgeLianErr := saveData.GetCont(whereLian, "`id`", "`state`") + if judgeLianErr == nil { + eidtTargetCont := publicmethod.MapOut[string]() + eidtTargetCont["`scoring_method`"] = scoringMethod + eidtTargetCont["`state`"] = judgeState + eidtTargetCont["`source`"] = source + eidtTargetCont["`run_state`"] = cv.State + eidtTargetCont["`eitetime`"] = timeData + saveData.EiteCont(map[string]interface{}{"`id`": saveData.Id}, eidtTargetCont) + } else { //不存在需要新增 + saveData.VersionNumber = versionNumber //版本编号"` + saveData.CompanyId = companyId //归属公司"` + saveData.DepartmentId = departmentId //归属部门"` + saveData.OrgId = orgid //归属行政组织"` + saveData.PostId = postid //归属岗位"` + saveData.Title = cv.Name //考核项名称"` + saveData.DimensionId = dimensionIdInt64 //维度"` + saveData.TargetId = targetIdInt64 //指标"` + saveData.SonTargetId = 0 //子栏目"` + saveData.DetailsId = 0 //细则"` + saveData.Attribute = cv.Type //属性 1:定性考核;2:定量考核"` + saveData.MinScore = 0 //最小分*100保存"` + saveData.MaxScore = 0 //最大分*100保存"` + saveData.ScoringMethod = scoringMethod //计分方式(1:自动;2:手动)"` + saveData.State = judgeState //状态(1:启用;2:禁用;3:删除)"` + saveData.Addtime = timeData //添加时间"` + saveData.Eitetime = timeData //编辑时间"` + saveData.CensorType = "2" //检查方式(1:现场检查;2:资料检查;3:事件触发)"` + saveData.Source = source //来源(1:岗位;2:部门引用)"` + saveData.RunState = cv.State //运行状态(1:启用;2:禁用;3:观察) + saveNewData = append(saveNewData, saveData) + } + + if source != 1 { //来源于部门引用 + // fmt.Printf("启用人员管理--1--->%v--->%v--->%v--->%v\n", source, targetIdInt64, len(cv.Operator), cv.Operator) + if len(cv.Operator) > 0 { + // fmt.Printf("启用人员管理--2--->%v\n", targetIdInt64) + syncSetinges.Add(1) + go DepartAboutPostTargetReport(dimensionIdInt64, targetIdInt64, 0, 0, orgid, postid, cv.Operator, 2, cv.Type) + } + } + } else { //定性考核 + if len(cv.Child) > 0 { //判断是否有定性考核项目 + for _, cvt := range cv.Child { + var sonTargetIdInt64 int64 = 0 + var detailsIdInt64 int64 = 0 + //获取细则内容 + if source != 1 { //来源于部门引用 + var depatrDeatCont modelskpi.DetailedTarget + depatrDeatCont.GetCont(map[string]interface{}{"`dt_id`": cvt.Id}) + sonTargetIdInt64 = depatrDeatCont.ParentIdSun + detailsIdInt64 = depatrDeatCont.Id + } else { //来源于岗位考核 + var depatrDeatCont modelskpi.PostTargetDetails + depatrDeatCont.GetCont(map[string]interface{}{"`id`": cvt.Id}) + sonTargetIdInt64 = depatrDeatCont.ParentIdSun + detailsIdInt64 = depatrDeatCont.Id + } + //判断该细则是否存在 + whereLian := publicmethod.MapOut[string]() + whereLian["`version_number`"] = versionNumber + whereLian["`company_id`"] = companyId + whereLian["`department_id`"] = departmentId + whereLian["`org_id`"] = orgid + whereLian["`post_id`"] = postid + whereLian["`dimension_id`"] = dimensionIdInt64 + whereLian["`target_id`"] = targetIdInt64 + whereLian["`son_target_id`"] = sonTargetIdInt64 + whereLian["`details_id`"] = detailsIdInt64 + judgeLianErr := saveData.GetCont(whereLian, "`id`", "`state`") + if judgeLianErr == nil { + eidtTargetCont := publicmethod.MapOut[string]() + eidtTargetCont["`scoring_method`"] = scoringMethod + eidtTargetCont["`state`"] = judgeState + eidtTargetCont["`source`"] = source + eidtTargetCont["`run_state`"] = cv.State + eidtTargetCont["`eitetime`"] = timeData + saveData.EiteCont(map[string]interface{}{"`id`": saveData.Id}, eidtTargetCont) + } else { //不存在需要新增 + var minScoreInt int64 = 0 + var maxScoreInt int64 = 0 + scoreAry := strings.Split(cvt.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) + } + } + + saveData.VersionNumber = versionNumber //版本编号"` + saveData.CompanyId = companyId //归属公司"` + saveData.DepartmentId = departmentId //归属部门"` + saveData.OrgId = orgid //归属行政组织"` + saveData.PostId = postid //归属岗位"` + saveData.Title = cv.Name //考核项名称"` + saveData.DimensionId = dimensionIdInt64 //维度"` + saveData.TargetId = targetIdInt64 //指标"` + saveData.SonTargetId = sonTargetIdInt64 //子栏目"` + saveData.DetailsId = detailsIdInt64 //细则"` + saveData.Attribute = cv.Type //属性 1:定性考核;2:定量考核"` + saveData.MinScore = minScoreInt //最小分*100保存"` + saveData.MaxScore = maxScoreInt //最大分*100保存"` + saveData.ScoringMethod = scoringMethod //计分方式(1:自动;2:手动)"` + saveData.State = judgeState //状态(1:启用;2:禁用;3:删除)"` + saveData.Addtime = timeData //添加时间"` + saveData.Eitetime = timeData //编辑时间"` + saveData.CensorType = "2" //检查方式(1:现场检查;2:资料检查;3:事件触发)"` + saveData.Source = source //来源(1:岗位;2:部门引用)"` + saveData.RunState = cv.State //运行状态(1:启用;2:禁用;3:观察) + saveNewData = append(saveNewData, saveData) + } + + if source != 1 { //来源于部门引用 + // fmt.Printf("启用人员管理--3--->%v--->%v--->%v--->%v\n", source, targetIdInt64, len(cv.Operator), cv.Operator) + if len(cvt.Operator) > 0 { + // fmt.Printf("启用人员管理--4--->%v--->%v\n", targetIdInt64, detailsIdInt64) + syncSetinges.Add(1) + go DepartAboutPostTargetReport(dimensionIdInt64, targetIdInt64, sonTargetIdInt64, detailsIdInt64, orgid, postid, cvt.Operator, 2, cv.Type) + } + } + + } + } + } + + } + } + + } + if len(saveNewData) > 0 { + overall.CONSTANT_DB_KPI.Create(&saveNewData) + } + syncSetinges.Wait() +} + +/* + 协程处理 + +部门指标岗位提报人关联通用函数 +@dimensionId 维度 +@targetId 指标ID +@targetSunId 栏目ID +@bylawsId 指标细则 +@departmentId 接受考核部门 +@postId 岗位 +@repart 提报人 +@class 级别(1:部门级;2:岗位级) +@nature 1:定性考核;2:定量考核 +func departAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []loopStruct, class, nature int) +*/ +func DepartAboutPostTargetReport(dimensionId, targetId, targetSunId, bylawsId, departmentId, postId int64, repart []string, class, nature int) { + defer syncSetinges.Done() + // fmt.Printf("启用人员管理----->%v\n", targetId) + //将不属于该指标细则的部门至禁用 + 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, userKeyAbout) == false { + userKeyAbout = append(userKeyAbout, v) + + //获取评价人部门 + 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 + } + 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, 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) GetPostScheme(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 schemeCont modelskpi.PositionPlanVersio + err = overall.CONSTANT_DB_KPI.Where("`id` = ?", receivedValue.Id).Find(&schemeCont).Error + if err != nil { + publicmethod.Result(107, err, c) + return + } +} diff --git a/api/version1/postseting/postpc/type.go b/api/version1/postseting/postpc/type.go new file mode 100644 index 0000000..e55fd93 --- /dev/null +++ b/api/version1/postseting/postpc/type.go @@ -0,0 +1,106 @@ +package postpc + +import ( + "key_performance_indicators/overall/publicmethod" + "sync" + + "github.com/gin-gonic/gin" +) + +type ApiMethod struct{} + +// 协程设置 +var syncSeting = sync.WaitGroup{} +var syncSetinges = sync.WaitGroup{} + +// 岗位指标协程操作 +type postDimeTarSync struct { + planList []postAboutDimeTar + mutext sync.RWMutex +} + +// 读取岗位指标协程数据 +func (d *postDimeTarSync) readDataLock() []postAboutDimeTar { + d.mutext.RLock() + defer d.mutext.RUnlock() + return d.planList +} + +// 岗位考核PC端入口 +func (a *ApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["index"] = "岗位考核PC端入口" + publicmethod.Result(0, outputCont, c) +} + +// 获取岗位相关指标 +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:观察 + Type int `json:"type"` //1:定性考核;2:定量考核 + Child []quoteDeatinDeparment `json:"child"` //指标细则列表 +} + +// 岗位相关维度指标列表 +type postAboutDimeTar struct { + publicmethod.PublicId + publicmethod.PublicName //维度名称 + 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"` //指标细则列表 + Operator []string `json:"operator"` //考核执行人 +} + +// 方案中的定性指标细则 +type schemeDetailedStructure struct { + publicmethod.PublicId //id + publicmethod.PublicName //名称 + ReferenceScore string `json:"referencescore"` //考核标准 + State int `json:"state"` //状态:1:启用;2:禁用;3:观察 + Operator []string `json:"operator"` //考核执行人 +} + +// 岗位考核方案列表 +type postSchemeList struct { + publicmethod.PagesTurn + VersionNumber string `json:"versionnumber"` //版本号 +} diff --git a/api/version1/postseting/postweb/type.go b/api/version1/postseting/postweb/type.go new file mode 100644 index 0000000..0557579 --- /dev/null +++ b/api/version1/postseting/postweb/type.go @@ -0,0 +1,16 @@ +package postweb + +import ( + "key_performance_indicators/overall/publicmethod" + + "github.com/gin-gonic/gin" +) + +type ApiMethod struct{} + +// 岗位考核WEB端入口 +func (a *ApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["index"] = "岗位考核WEB端入口" + publicmethod.Result(0, outputCont, c) +} diff --git a/apirouter/entry.go b/apirouter/entry.go index f59c655..a3de109 100644 --- a/apirouter/entry.go +++ b/apirouter/entry.go @@ -3,19 +3,29 @@ package apirouter import ( "key_performance_indicators/apirouter/apishiyan" "key_performance_indicators/apirouter/empower" +<<<<<<< HEAD mytest "key_performance_indicators/apirouter/myTest" +======= + "key_performance_indicators/apirouter/v1/departmentseting" +>>>>>>> v1_dev honorsRoute "key_performance_indicators/apirouter/v1/honorsRoute" + "key_performance_indicators/apirouter/v1/postseting" "key_performance_indicators/apirouter/verifyLogin" // "key_performance_indicators/v1" ) -//路由结构 +// 路由结构 type RouterGroup struct { EmpowerRouter empower.EmpowerApiRouter VerifyLogin verifyLogin.ApiRouter ShiyanApi apishiyan.ApiRouter HonorsSouteRouter honorsRoute.ApiRouter +<<<<<<< HEAD MyTest mytest.TestApi +======= + PostRouter postseting.ApiRouter + DepartmentRouter departmentseting.ApiRouter +>>>>>>> v1_dev } var RouterGroupEntry = new(RouterGroup) diff --git a/apirouter/v1/departmentseting/pc.go b/apirouter/v1/departmentseting/pc.go new file mode 100644 index 0000000..35365a7 --- /dev/null +++ b/apirouter/v1/departmentseting/pc.go @@ -0,0 +1,45 @@ +package departmentseting + +import ( + "key_performance_indicators/api/version1" + + "github.com/gin-gonic/gin" +) + +// 部门考核PC端 +func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { + apiRouter := router.Group("department_pc") + + var methodBinding = version1.AppApiEntry.DeparmentPcApi + { + 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("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) //删除子栏目 + + apiRouter.POST("getonedetailedtarget", methodBinding.GetOneDetailedTarget) //获取单一指标细则内容 + apiRouter.POST("edit_one_detailed_target", methodBinding.EditOneDetailedTarget) //编辑单一指标细则内容 + apiRouter.POST("del_one_detailed_target", methodBinding.DelOneDetailedTarget) //删除单一指标细则 + + 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/departmentseting/type.go b/apirouter/v1/departmentseting/type.go new file mode 100644 index 0000000..a52ad9b --- /dev/null +++ b/apirouter/v1/departmentseting/type.go @@ -0,0 +1,4 @@ +package departmentseting + +//部门考核 +type ApiRouter struct{} diff --git a/apirouter/v1/departmentseting/web.go b/apirouter/v1/departmentseting/web.go new file mode 100644 index 0000000..04b9728 --- /dev/null +++ b/apirouter/v1/departmentseting/web.go @@ -0,0 +1,19 @@ +package departmentseting + +import ( + "key_performance_indicators/api/version1" + + "github.com/gin-gonic/gin" +) + +// 部门考核web端 +func (a *ApiRouter) RouterGroupWeb(router *gin.RouterGroup) { + apiRouter := router.Group("department_web") + + var methodBinding = version1.AppApiEntry.DeparmentWebApi + { + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + + } +} diff --git a/apirouter/v1/postseting/pc.go b/apirouter/v1/postseting/pc.go new file mode 100644 index 0000000..6a31f72 --- /dev/null +++ b/apirouter/v1/postseting/pc.go @@ -0,0 +1,21 @@ +package postseting + +import ( + "key_performance_indicators/api/version1" + + "github.com/gin-gonic/gin" +) + +// 岗位考核PC端 +func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { + apiRouter := router.Group("postpc") + + var methodBinding = version1.AppApiEntry.PostPcApi + { + 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/apirouter/v1/postseting/type.go b/apirouter/v1/postseting/type.go new file mode 100644 index 0000000..1e3f2a6 --- /dev/null +++ b/apirouter/v1/postseting/type.go @@ -0,0 +1,4 @@ +package postseting + +//岗位考核 +type ApiRouter struct{} diff --git a/apirouter/v1/postseting/web.go b/apirouter/v1/postseting/web.go new file mode 100644 index 0000000..6c6dcf2 --- /dev/null +++ b/apirouter/v1/postseting/web.go @@ -0,0 +1,18 @@ +package postseting + +import ( + "key_performance_indicators/api/version1" + + "github.com/gin-gonic/gin" +) + +// 岗位考核web端 +func (a *ApiRouter) RouterGroupWeb(router *gin.RouterGroup) { + apiRouter := router.Group("postweb") + + var methodBinding = version1.AppApiEntry.PostWebApi + { + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + } +} diff --git a/config/configDatabase/database.yaml b/config/configDatabase/database.yaml index 5aacf0f..0ed9103 100644 --- a/config/configDatabase/database.yaml +++ b/config/configDatabase/database.yaml @@ -33,7 +33,7 @@ hrdatabase: charset: 'utf8mb4' #数据库编码方式 parseTime: 'True' #是否自动转换时间 loc: 'Local' #时区 - name: 'human_resources_jindie' #数据库名称 + name: 'hr_new' #数据库名称 username: 'root' #数据库用户民 password: 'root' #数据库密码 max_idle_conns: 100 #最大空闲数量 @@ -156,7 +156,7 @@ kpiDate: charset: 'utf8mb4' #数据库编码方式 parseTime: 'True' #是否自动转换时间 loc: 'Local' #时区 - name: 'performanceappraisal' #数据库名称 + name: 'perform' #数据库名称 username: 'root' #数据库用户民 password: 'root' #数据库密码 max_idle_conns: 100 #最大空闲数量 diff --git a/identification/interceptor/authentication.go b/identification/interceptor/authentication.go index e70810a..dd6d5b5 100644 --- a/identification/interceptor/authentication.go +++ b/identification/interceptor/authentication.go @@ -3,7 +3,7 @@ package interceptor import ( "fmt" "key_performance_indicators/middleware/grocerystore" - "key_performance_indicators/models" + "key_performance_indicators/models/modelshr" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" @@ -11,7 +11,7 @@ import ( "github.com/mitchellh/mapstructure" ) -//身份验证器 +// 身份验证器 func IdentificationToken() gin.HandlerFunc { return func(c *gin.Context) { userToken := c.Request.Header.Get("token") @@ -61,7 +61,7 @@ func IdentificationToken() gin.HandlerFunc { passWordMd5.Md5EncryptionInit(validator.PassWord) passWordMd5Str := passWordMd5.Md5EncryptionAlgorithm() - var empowerUser models.EmpowerUser + var empowerUser modelshr.EmpowerUser userErr := empowerUser.GetCont(map[string]interface{}{"userkey": validator.UserKey, "password": passWordMd5Str}, "verification_code") if userErr != nil { publicmethod.Result(2000, userErr, c) diff --git a/identification/interceptor/identity.go b/identification/interceptor/identity.go index d2d88f1..bdd1176 100644 --- a/identification/interceptor/identity.go +++ b/identification/interceptor/identity.go @@ -10,13 +10,13 @@ import ( "github.com/gin-gonic/gin" ) -//验证用户是否登录 +// 验证用户是否登录 func AuthenticateUser() gin.HandlerFunc { return func(c *gin.Context) { userKey := c.Request.Header.Get("user-key") userToken := c.Request.Header.Get("user-token") userAgent := c.Request.Header.Get("User-Agent") - + // fmt.Printf("userKey---------->%v----------userToken---------->%v--------userAgent---------->%v\n", userKey, userToken, userAgent) if userKey == "" || userToken == "" || userAgent == "" { response.FailWithDetailed(gin.H{"reload": false, "code": 300}, "未登录或非法访问", c) c.Abort() @@ -106,7 +106,7 @@ func AuthenticateUser() gin.HandlerFunc { } } -//验证用户是否具备权限 +// 验证用户是否具备权限 func VerifyUrl() gin.HandlerFunc { return func(c *gin.Context) { systemClass := c.Request.Header.Get("system-class") diff --git a/initialization/route/initRoute.go b/initialization/route/initRoute.go index 68e47e4..5560cb9 100644 --- a/initialization/route/initRoute.go +++ b/initialization/route/initRoute.go @@ -7,7 +7,7 @@ import ( "github.com/gin-gonic/gin" ) -//初始化主路由 +// 初始化主路由 func InitialRouter() *gin.Engine { var router = gin.Default() @@ -53,8 +53,18 @@ func InitialRouter() *gin.Engine { VerifyIdentity.Use(interceptor.AuthenticateUser()).Use(interceptor.VerifyUrl()) { //v1版本接口 - version1Api := apirouter.RouterGroupEntry.HonorsSouteRouter - version1Api.RouterGroup(VerifyIdentity) + + //荣誉墙 + version1HonorsApi := apirouter.RouterGroupEntry.HonorsSouteRouter + version1HonorsApi.RouterGroup(VerifyIdentity) + //岗位考核 + postRouterApi := apirouter.RouterGroupEntry.PostRouter + postRouterApi.RouterGroupPc(VerifyIdentity) //pc端 + postRouterApi.RouterGroupWeb(VerifyIdentity) //web端 + //部门考核 + departmentRouterApi := apirouter.RouterGroupEntry.DepartmentRouter + departmentRouterApi.RouterGroupPc(VerifyIdentity) //pc端 + departmentRouterApi.RouterGroupWeb(VerifyIdentity) //web端 } //Token身份验证 VerifyIdentityToken := router.Group("") diff --git a/key_performance_indicators.exe b/key_performance_indicators.exe new file mode 100644 index 0000000..7423a07 Binary files /dev/null and b/key_performance_indicators.exe differ diff --git a/models/carrier_type.go b/models/modelshonory/carrier_type.go similarity index 92% rename from models/carrier_type.go rename to models/modelshonory/carrier_type.go index bccec69..e98c0a0 100644 --- a/models/carrier_type.go +++ b/models/modelshonory/carrier_type.go @@ -1,11 +1,11 @@ -package models +package modelshonory import ( "key_performance_indicators/overall" "strings" ) -//载体类型 +// 载体类型 type CarrierType struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:荣誉名称"` @@ -17,13 +17,13 @@ func (CarrierType *CarrierType) TableName() string { return "carrier_type" } -//编辑载体类型内容 +// 编辑载体类型内容 func (cont *CarrierType) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取载体类型内容 +// 获取载体类型内容 func (cont *CarrierType) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont) if len(field) > 0 { @@ -35,7 +35,7 @@ func (cont *CarrierType) GetCont(whereMap interface{}, field ...string) (err err return } -//删除内容 +// 删除内容 func (cont *CarrierType) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Where(whereMap).Delete(&cont).Error return diff --git a/models/honorary_archives.go b/models/modelshonory/honorary_archives.go similarity index 95% rename from models/honorary_archives.go rename to models/modelshonory/honorary_archives.go index 7072e06..ee57dc4 100644 --- a/models/honorary_archives.go +++ b/models/modelshonory/honorary_archives.go @@ -1,11 +1,11 @@ -package models +package modelshonory import ( "key_performance_indicators/overall" "strings" ) -//荣誉档案 +// 荣誉档案 type HonoraryArchives struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:荣誉名称"` @@ -24,13 +24,13 @@ func (HonoraryArchives *HonoraryArchives) TableName() string { return "honorary_archives" } -//编辑荣誉档案内容 +// 编辑荣誉档案内容 func (cont *HonoraryArchives) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取荣誉档案内容 +// 获取荣誉档案内容 func (cont *HonoraryArchives) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont) if len(field) > 0 { @@ -42,7 +42,7 @@ func (cont *HonoraryArchives) GetCont(whereMap interface{}, field ...string) (er return } -//删除内容 +// 删除内容 func (cont *HonoraryArchives) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Where(whereMap).Delete(&cont).Error return diff --git a/models/photos_gallery.go b/models/modelshonory/photos_gallery.go similarity index 90% rename from models/photos_gallery.go rename to models/modelshonory/photos_gallery.go index 09d280c..88d1651 100644 --- a/models/photos_gallery.go +++ b/models/modelshonory/photos_gallery.go @@ -1,12 +1,17 @@ -package models +package modelshonory import ( "key_performance_indicators/overall" "strings" ) +<<<<<<< HEAD:models/photos_gallery.go //图片库 type PhotosGallery struct { +======= +// 图片库 +type PhotosGallery struct { +>>>>>>> v1_dev:models/modelshonory/photos_gallery.go Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` Url string `json:"url" gorm:"column:url;type:varchar(255) unsigned;default:'';not null;comment:图片地址"` ImgPath string `json:"imgpath" gorm:"column:img_path;type:varchar(255) unsigned;default:'';not null;comment:物理地址"` @@ -22,13 +27,13 @@ func (PhotosGallery *PhotosGallery) TableName() string { return "photos_gallery" } -//编辑图片库内容 +// 编辑图片库内容 func (cont *PhotosGallery) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取图片库内容 +// 获取图片库内容 func (cont *PhotosGallery) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont) if len(field) > 0 { @@ -40,7 +45,7 @@ func (cont *PhotosGallery) GetCont(whereMap interface{}, field ...string) (err e return } -//删除内容 +// 删除内容 func (cont *PhotosGallery) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Where(whereMap).Delete(&cont).Error return diff --git a/models/administrative_organization.go b/models/modelshr/administrative_organization.go similarity index 87% rename from models/administrative_organization.go rename to models/modelshr/administrative_organization.go index 64913ce..0bfb9b0 100644 --- a/models/administrative_organization.go +++ b/models/modelshr/administrative_organization.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//行政组织 +// 行政组织 type AdministrativeOrganization struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` @@ -26,13 +26,13 @@ func (AdministrativeOrganization *AdministrativeOrganization) TableName() string return "administrative_organization" } -//编辑行政组织内容 +// 编辑行政组织内容 func (cont *AdministrativeOrganization) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取行政组织内容 +// 获取行政组织内容 func (cont *AdministrativeOrganization) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { @@ -44,14 +44,19 @@ func (cont *AdministrativeOrganization) GetCont(whereMap interface{}, field ...s return } -//根据条件获取总数 +// 根据条件获取总数 func (cont *AdministrativeOrganization) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return } -//读取全部信息 -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/administrative_organization_type.go b/models/modelshr/administrative_organization_type.go similarity index 94% rename from models/administrative_organization_type.go rename to models/modelshr/administrative_organization_type.go index c0851f5..07a5901 100644 --- a/models/administrative_organization_type.go +++ b/models/modelshr/administrative_organization_type.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//行政组织类型 +// 行政组织类型 type AdministrativeOrganizationType struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:类型名称"` @@ -19,13 +19,13 @@ func (AdministrativeOrganizationType *AdministrativeOrganizationType) TableName( return "administrative_organization_type" } -//编辑职务分类内容 +// 编辑职务分类内容 func (cont *AdministrativeOrganizationType) EiteCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取详细内容 +// 获取详细内容 func (cont *AdministrativeOrganizationType) GetCont(whereMap map[string]interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/double_worker.go b/models/modelshr/double_worker.go similarity index 95% rename from models/double_worker.go rename to models/modelshr/double_worker.go index 4f15268..9d13a93 100644 --- a/models/double_worker.go +++ b/models/modelshr/double_worker.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//双职工 +// 双职工 type DoubleWorker 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:员工工号;index"` @@ -23,13 +23,13 @@ func (DoubleWorker *DoubleWorker) TableName() string { return "double_worker" } -//编辑双职工内容 +// 编辑双职工内容 func (DoubleWorker *DoubleWorker) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&DoubleWorker).Where(whereMap).Updates(saveData).Error return } -//获取双职工内容 +// 获取双职工内容 func (cont *DoubleWorker) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/duties.go b/models/modelshr/duties.go similarity index 95% rename from models/duties.go rename to models/modelshr/duties.go index 8735bcb..8d3bfbf 100644 --- a/models/duties.go +++ b/models/modelshr/duties.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//职务 +// 职务 type Duties struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` @@ -22,13 +22,13 @@ func (Duties *Duties) TableName() string { return "duties" } -//编辑职务分类内容 +// 编辑职务分类内容 func (Duties *Duties) EiteCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&Duties).Where(whereMap).Updates(saveData).Error return } -//获取详细内容 +// 获取详细内容 func (cont *Duties) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/duties_class_leve.go b/models/modelshr/duties_class_leve.go similarity index 95% rename from models/duties_class_leve.go rename to models/modelshr/duties_class_leve.go index 1f04e17..407386f 100644 --- a/models/duties_class_leve.go +++ b/models/modelshr/duties_class_leve.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//职务信息及类别、等级视图 +// 职务信息及类别、等级视图 type DutiesClassLeve struct { Id int64 `json:"id" gorm:"primaryKey;column:d_id;type:bigint(20) unsigned;not null;comment:Id;index"` Name string `json:"name" gorm:"column:d_name;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` @@ -24,7 +24,7 @@ func (DutiesClassLeve *DutiesClassLeve) TableName() string { return "duties_class_leve" } -//获取详细内容 +// 获取详细内容 func (cont *DutiesClassLeve) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/emergency_contact.go b/models/modelshr/emergency_contact.go similarity index 94% rename from models/emergency_contact.go rename to models/modelshr/emergency_contact.go index fed3dc1..efe6d25 100644 --- a/models/emergency_contact.go +++ b/models/modelshr/emergency_contact.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//紧急联系人 +// 紧急联系人 type EmergencyContact struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` @@ -21,13 +21,13 @@ func (EmergencyContact *EmergencyContact) TableName() string { return "emergency_contact" } -//编辑职务分类内容 +// 编辑职务分类内容 func (EmergencyContact *EmergencyContact) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&EmergencyContact).Where(whereMap).Updates(saveData).Error return } -//获取行政组织内容 +// 获取行政组织内容 func (cont *EmergencyContact) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { @@ -39,7 +39,7 @@ func (cont *EmergencyContact) GetCont(whereMap interface{}, field ...string) (er return } -//根据条件获取总数 +// 根据条件获取总数 func (cont *EmergencyContact) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return diff --git a/models/empoweruser.go b/models/modelshr/empoweruser.go similarity index 94% rename from models/empoweruser.go rename to models/modelshr/empoweruser.go index c513d89..41c7b37 100644 --- a/models/empoweruser.go +++ b/models/modelshr/empoweruser.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//授权账户 +// 授权账户 type EmpowerUser struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` UserKey string `json:"userkey" gorm:"column:userkey;type:varchar(255) unsigned;not null;comment:账户"` @@ -21,13 +21,13 @@ func (Position *EmpowerUser) TableName() string { return "empoweruser" } -//编辑职务分类内容 +// 编辑职务分类内容 func (cont *EmpowerUser) EiteCont(whereMap interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取行政组织内容 +// 获取行政组织内容 func (cont *EmpowerUser) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { @@ -39,7 +39,7 @@ func (cont *EmpowerUser) GetCont(whereMap interface{}, field ...string) (err err return } -//根据条件获取总数 +// 根据条件获取总数 func (cont *EmpowerUser) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return diff --git a/models/family_members.go b/models/modelshr/family_members.go similarity index 96% rename from models/family_members.go rename to models/modelshr/family_members.go index b42e9a8..73a42fd 100644 --- a/models/family_members.go +++ b/models/modelshr/family_members.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//员工家属 +// 员工家属 type FamilyMembers 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:员工工号"` @@ -27,13 +27,13 @@ func (FamilyMembers *FamilyMembers) TableName() string { return "family_members" } -//编辑员工家属内容 +// 编辑员工家属内容 func (FamilyMembers *FamilyMembers) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&FamilyMembers).Where(whereMap).Updates(saveData).Error return } -//获取员工家属内容 +// 获取员工家属内容 func (cont *FamilyMembers) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/inside_work_history.go b/models/modelshr/inside_work_history.go similarity index 96% rename from models/inside_work_history.go rename to models/modelshr/inside_work_history.go index 0690ca6..b6ee2ab 100644 --- a/models/inside_work_history.go +++ b/models/modelshr/inside_work_history.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//集团内部工作经历 +// 集团内部工作经历 type InsideWorkHistory struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Key int64 `json:"key" gorm:"column:key;type:bigint(20) unsigned;default:0;not null;comment:员工识别符"` @@ -29,13 +29,13 @@ func (InsideWorkHistory *InsideWorkHistory) TableName() string { return "inside_work_history" } -//编辑集团内部工作经历内容 +// 编辑集团内部工作经历内容 func (cont *InsideWorkHistory) EditCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取详细内容 +// 获取详细内容 func (cont *InsideWorkHistory) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/inside_work_view.go b/models/modelshr/inside_work_view.go similarity index 98% rename from models/inside_work_view.go rename to models/modelshr/inside_work_view.go index 7d4ef32..7d56a25 100644 --- a/models/inside_work_view.go +++ b/models/modelshr/inside_work_view.go @@ -1,4 +1,4 @@ -package models +package modelshr import ( "key_performance_indicators/overall" @@ -26,7 +26,7 @@ func (InsideWorkView *InsideWorkView) TableName() string { return "inside_work_view" } -//获取详细内容 +// 获取详细内容 func (cont *InsideWorkView) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/job_class.go b/models/modelshr/job_class.go similarity index 94% rename from models/job_class.go rename to models/modelshr/job_class.go index d107378..b660997 100644 --- a/models/job_class.go +++ b/models/modelshr/job_class.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//职务分类 +// 职务分类 type JobClass struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:职务分类名称"` @@ -19,13 +19,13 @@ func (JobClass *JobClass) TableName() string { return "job_class" } -//编辑职务分类内容 +// 编辑职务分类内容 func (JobClass *JobClass) EiteJobClassCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&JobClass).Where(whereMap).Updates(saveData).Error return } -//获取详细内容 +// 获取详细内容 func (cont *JobClass) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/kingdee_log.go b/models/modelshr/kingdee_log.go similarity index 92% rename from models/kingdee_log.go rename to models/modelshr/kingdee_log.go index 3e4a813..721560f 100644 --- a/models/kingdee_log.go +++ b/models/modelshr/kingdee_log.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//金蝶对照记录 +// 金蝶对照记录 type KingdeeLog struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Number string `json:"number" gorm:"column:number;type:varchar(255) unsigned;default:'';not null;comment:工号"` @@ -17,13 +17,13 @@ func (KingdeeLog *KingdeeLog) TableName() string { return "kingdee_log" } -//编辑职务分类内容 +// 编辑职务分类内容 func (KingdeeLog *KingdeeLog) EidtCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&KingdeeLog).Where(whereMap).Updates(saveData).Error return } -//获取详细内容 +// 获取详细内容 func (cont *KingdeeLog) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/man_cont.go b/models/modelshr/man_cont.go similarity index 99% rename from models/man_cont.go rename to models/modelshr/man_cont.go index d79c804..e1b5edb 100644 --- a/models/man_cont.go +++ b/models/modelshr/man_cont.go @@ -1,4 +1,4 @@ -package models +package modelshr import ( "key_performance_indicators/overall" @@ -63,7 +63,7 @@ func (ManCont *ManCont) TableName() string { return "man_cont" } -//获取职务分类内容 +// 获取职务分类内容 func (cont *ManCont) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/org_cont_type.go b/models/modelshr/org_cont_type.go similarity index 94% rename from models/org_cont_type.go rename to models/modelshr/org_cont_type.go index dd6d561..46e7e81 100644 --- a/models/org_cont_type.go +++ b/models/modelshr/org_cont_type.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//职务信息及类别、等级视图 +// 职务信息及类别、等级视图 type OrgContType struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` @@ -21,7 +21,7 @@ func (OrgContType *OrgContType) TableName() string { return "org_cont_type" } -//获取详细内容 +// 获取详细内容 func (cont *OrgContType) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/personarchives.go b/models/modelshr/personarchives.go similarity index 98% rename from models/personarchives.go rename to models/modelshr/personarchives.go index cc80f2f..ab26426 100644 --- a/models/personarchives.go +++ b/models/modelshr/personarchives.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//员工档案(主) +// 员工档案(主) type PersonArchives 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:员工工号"` @@ -42,13 +42,13 @@ func (PersonArchives *PersonArchives) TableName() string { return "person_archives" } -//编辑员工档案 +// 编辑员工档案 func (PersonArchives *PersonArchives) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&PersonArchives).Where(whereMap).Updates(saveData).Error return } -//获取员工档案 +// 获取员工档案 func (cont *PersonArchives) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/personnel.go b/models/modelshr/personnel.go similarity index 97% rename from models/personnel.go rename to models/modelshr/personnel.go index f1ce272..0fbd37e 100644 --- a/models/personnel.go +++ b/models/modelshr/personnel.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//员工档案(主) +// 员工档案(主) type Personnel 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:员工工号"` @@ -35,13 +35,13 @@ func (Personnel *Personnel) TableName() string { return "personnel" } -//编辑员工档案 +// 编辑员工档案 func (Personnel *Personnel) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&Personnel).Where(whereMap).Updates(saveData).Error return } -//获取员工档案 +// 获取员工档案 func (cont *Personnel) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/personnel_change_record.go b/models/modelshr/personnel_change_record.go similarity index 99% rename from models/personnel_change_record.go rename to models/modelshr/personnel_change_record.go index 9ec46f9..8c9a084 100644 --- a/models/personnel_change_record.go +++ b/models/modelshr/personnel_change_record.go @@ -1,4 +1,4 @@ -package models +package modelshr import "key_performance_indicators/overall" diff --git a/models/personnel_content.go b/models/modelshr/personnel_content.go similarity index 98% rename from models/personnel_content.go rename to models/modelshr/personnel_content.go index afed964..0ac6713 100644 --- a/models/personnel_content.go +++ b/models/modelshr/personnel_content.go @@ -1,4 +1,4 @@ -package models +package modelshr import ( "key_performance_indicators/overall" @@ -48,13 +48,13 @@ func (PersonnelContent *PersonnelContent) TableName() string { return "personnel_content" } -//编辑职务分类内容 +// 编辑职务分类内容 func (PersonnelContent *PersonnelContent) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&PersonnelContent).Where(whereMap).Updates(saveData).Error return } -//获取职务分类内容 +// 获取职务分类内容 func (cont *PersonnelContent) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/personnel_education.go b/models/modelshr/personnel_education.go similarity index 97% rename from models/personnel_education.go rename to models/modelshr/personnel_education.go index 7ef997e..0ee4084 100644 --- a/models/personnel_education.go +++ b/models/modelshr/personnel_education.go @@ -1,4 +1,4 @@ -package models +package modelshr import ( "key_performance_indicators/overall" @@ -29,13 +29,13 @@ func (PersonnelEducation *PersonnelEducation) TableName() string { return "personnel_education" } -//编辑教育经历内容 +// 编辑教育经历内容 func (PersonnelEducation *PersonnelEducation) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&PersonnelEducation).Where(whereMap).Updates(saveData).Error return } -//获取教育经历内容 +// 获取教育经历内容 func (cont *PersonnelEducation) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/position.go b/models/modelshr/position.go similarity index 95% rename from models/position.go rename to models/modelshr/position.go index ce3b549..aada05e 100644 --- a/models/position.go +++ b/models/modelshr/position.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//职位(岗位) +// 职位(岗位) type Position struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:职位编码"` @@ -27,13 +27,13 @@ func (Position *Position) TableName() string { return "position" } -//编辑职务分类内容 +// 编辑职务分类内容 func (cont *Position) EiteCont(whereMap interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取行政组织内容 +// 获取行政组织内容 func (cont *Position) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { @@ -45,7 +45,7 @@ func (cont *Position) GetCont(whereMap interface{}, field ...string) (err error) return } -//根据条件获取总数 +// 根据条件获取总数 func (cont *Position) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return diff --git a/models/position_level.go b/models/modelshr/position_level.go similarity index 98% rename from models/position_level.go rename to models/modelshr/position_level.go index c691108..506f11c 100644 --- a/models/position_level.go +++ b/models/modelshr/position_level.go @@ -1,4 +1,4 @@ -package models +package modelshr import "key_performance_indicators/overall" diff --git a/models/post_duties_job.go b/models/modelshr/post_duties_job.go similarity index 98% rename from models/post_duties_job.go rename to models/modelshr/post_duties_job.go index be7d677..7e31d21 100644 --- a/models/post_duties_job.go +++ b/models/modelshr/post_duties_job.go @@ -1,4 +1,4 @@ -package models +package modelshr import ( "key_performance_indicators/overall" @@ -31,7 +31,7 @@ func (PostDutiesJob *PostDutiesJob) TableName() string { return "post_duties_job" } -//获取详细内容 +// 获取详细内容 func (cont *PostDutiesJob) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/teamgroup.go b/models/modelshr/teamgroup.go similarity index 94% rename from models/teamgroup.go rename to models/modelshr/teamgroup.go index f05c3b9..06b56d5 100644 --- a/models/teamgroup.go +++ b/models/modelshr/teamgroup.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//班组 +// 班组 type TeamGroup struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:班组名称"` @@ -17,13 +17,13 @@ func (TeamGroup *TeamGroup) TableName() string { return "teamgroup" } -//编辑班组内容 +// 编辑班组内容 func (TeamGroup *TeamGroup) EiteTeamGroupCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&TeamGroup).Where(whereMap).Updates(saveData).Error return } -//获取详细内容 +// 获取详细内容 func (cont *TeamGroup) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { 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/work_history.go b/models/modelshr/work_history.go similarity index 95% rename from models/work_history.go rename to models/modelshr/work_history.go index 159451e..5357a59 100644 --- a/models/work_history.go +++ b/models/modelshr/work_history.go @@ -1,11 +1,11 @@ -package models +package modelshr import ( "key_performance_indicators/overall" "strings" ) -//工作履历 +// 工作履历 type WorkHistory struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:工号"` @@ -26,13 +26,13 @@ func (WorkHistory *WorkHistory) TableName() string { return "work_history" } -//编辑职务分类内容 +// 编辑职务分类内容 func (cont *WorkHistory) EiteCont(whereMap interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取行政组织内容 +// 获取行政组织内容 func (cont *WorkHistory) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { @@ -44,7 +44,7 @@ func (cont *WorkHistory) GetCont(whereMap interface{}, field ...string) (err err return } -//根据条件获取总数 +// 根据条件获取总数 func (cont *WorkHistory) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) 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/depart_dime_post_weight.go b/models/modelskpi/depart_dime_post_weight.go new file mode 100644 index 0000000..aa66e4e --- /dev/null +++ b/models/modelskpi/depart_dime_post_weight.go @@ -0,0 +1,65 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 部门考核指标权重 +type DepartDimePostWeight struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Type int64 `json:"type" gorm:"column:type;type:bigint(20) unsigned;default:0;not null;comment:1:定性考核;2:定量考核"` + Orgid int64 `json:"orgid" gorm:"column:orgid;type:bigint(20) unsigned;default:0;not null;comment:行政组织"` + Postid int64 `json:"postid" gorm:"column:postid;type:bigint(20) unsigned;default:0;not null;comment:岗位"` + Dimension int64 `json:"dimension" gorm:"column:dimension;type:bigint(20) unsigned;default:0;not null;comment:考核维度"` + Target int64 `json:"target" gorm:"column:target;type:bigint(20) unsigned;default:0;not null;comment:指标"` + 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 { + return "depart_dime_post_weight" +} + +// 编辑内容 +func (cont *DepartDimePostWeight) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *DepartDimePostWeight) 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 *DepartDimePostWeight) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *DepartDimePostWeight) ContMap(whereMap interface{}, field ...string) (countAry []DepartDimePostWeight, 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 *DepartDimePostWeight) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/detailed_target.go b/models/modelskpi/detailed_target.go new file mode 100644 index 0000000..7189daa --- /dev/null +++ b/models/modelskpi/detailed_target.go @@ -0,0 +1,73 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 指标细则 +type DetailedTarget struct { + Id int64 `json:"id" gorm:"primaryKey;column:dt_id;type:bigint(20) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:dt_title;type:text;comment:指标细则"` + Content string `json:"content" gorm:"column:dt_content;type:text;comment:指标说明"` + ParentId int64 `json:"parentid" gorm:"column:dt_parentid;type:bigint(20) unsigned;default:0;not null;comment:归属指标栏目"` + ParentIdSun int64 `json:"parentidsun" gorm:"column:dt_parentid_sun;type:bigint(20) unsigned;default:0;not null;comment:归属指标子栏目"` + State int `json:"state" gorm:"column:dt_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + AddTime int64 `json:"addtime" gorm:"column:dt_time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"` + MinScore int64 `json:"minscore" gorm:"column:dt_min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"` + MaxScore int64 `json:"maxscore" gorm:"column:dt_max_score;type:bigint(20) unsigned;default:0;not null;comment:最大分*100保存"` + Company string `json:"company" gorm:"column:dt_company;type:varchar(20) unsigned;default:0;not null;comment:单位"` + AddReduce int `json:"addreduce" gorm:"column:dt_add_reduce;type:int(1) unsigned;default:1;not null;comment:1:减少;2:增加;3:无属性,现场确认加或减"` + CensorType string `json:"censortype" gorm:"column:dt_censor_type;type:text;comment:检查方式"` + CensorCont string `json:"censorcont" gorm:"column:dt_censor_cont;type:longtext;comment:检查依据"` + CensorRate int `json:"censorrate" gorm:"column:dt_censor_rate;type:int(5) unsigned;default:1;not null;comment:检查频次"` + Cycles int `json:"cycle" gorm:"column:dt_cycle;type:tinyint(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"` + CycleAttres int `json:"cycleattr" gorm:"column:dt_cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"` + Paretment string `json:"paretment" gorm:"column:dt_paretment;type:longtext;comment:接受考核的部门"` + Reportary string `json:"reportary" gorm:"column:reportary;type:longtext;comment:提报人"` +} + +func (DetailedTarget *DetailedTarget) TableName() string { + return "detailed_target" +} + +// 编辑内容 +func (cont *DetailedTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(&saveData).Error + return +} + +// 获取内容 +func (cont *DetailedTarget) 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 *DetailedTarget) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *DetailedTarget) ContMap(whereMap interface{}, field ...string) (countAry []DetailedTarget, 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 *DetailedTarget) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/dutyclass.go b/models/modelskpi/dutyclass.go new file mode 100644 index 0000000..3dcefb4 --- /dev/null +++ b/models/modelskpi/dutyclass.go @@ -0,0 +1,62 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 考核维度 +type DutyClass struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id"` + Title string `json:"title" gorm:"column:title;type:varchar(255);comment:考核维度名称"` + Type int `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:定性考核;2:定量考核)"` + Weight int `json:"weight" gorm:"column:weight;type:int(3) unsigned;default:0;not null;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:tinyint(1) unsigned;default:1;not null;comment:状态"` + Sort int `json:"sort" gorm:"column:sort;type:int(5) unsigned;default:0;not null;comment:排序"` +} + +func (DutyClass *DutyClass) TableName() string { + return "dutyclass" +} + +// 编辑内容 +func (cont *DutyClass) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *DutyClass) 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 *DutyClass) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *DutyClass) ContMap(whereMap interface{}, field ...string) (countAry []DutyClass, 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 *DutyClass) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/evaluationtarget.go b/models/modelskpi/evaluationtarget.go new file mode 100644 index 0000000..b3852f6 --- /dev/null +++ b/models/modelskpi/evaluationtarget.go @@ -0,0 +1,71 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 测评指标 +type EvaluationTarget struct { + Id int64 `json:"id" gorm:"primaryKey;column:et_id;type:bigint(20) unsigned;not null;comment:Id;index"` + Title string `json:"title" 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:定量考核"` + State int `json:"state" gorm:"column:et_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + AddTime int64 `json:"addTime" gorm:"column:et_time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"` + Share int `json:"share" gorm:"column:et_share;type:int(1) unsigned;default:1;not null;comment:1:共用;2:私用"` + RelevantDepartments string `json:"relevantdepartments" gorm:"column:et_relevant_departments;type:text;comment:相关部门"` + 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"` + Report string `json:"report" gorm:"column:et_report;type:text;comment:上报人"` + 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:辅助计数"` + VisibleRange string `json:"visiblerange" gorm:"column:et_visible_range;type:text;comment:可见范围"` + VisibleRangeGroup string `json:"visiblerangegroup" gorm:"column:et_visible_group;type:text;comment:可见范围(集团)"` + ScoringMethod int `json:"scoringmethod" gorm:"column:et_scoring_method;type:tinyint(1) unsigned;default:1;not null;comment:计分方式(1:自动;2:手动)"` +} + +func (EvaluationTarget *EvaluationTarget) TableName() string { + return "evaluationtarget" +} + +// 编辑内容 +func (cont *EvaluationTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *EvaluationTarget) 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 *EvaluationTarget) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *EvaluationTarget) ContMap(whereMap interface{}, field ...string) (countAry []EvaluationTarget, 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 *EvaluationTarget) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/position_plan_version.go b/models/modelskpi/position_plan_version.go new file mode 100644 index 0000000..c7aa7ff --- /dev/null +++ b/models/modelskpi/position_plan_version.go @@ -0,0 +1,67 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 岗位考核方案版本管理 +type PositionPlanVersio struct { + Id int64 `json:"id" gorm:"primaryKey;column: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:归属集团"` + Department int64 `json:"department" gorm:"column:department;type:bigint(20) unsigned;default:0;comment:归属部门"` + OrgId int64 `json:"orgid" gorm:"column:orgid;type:bigint(20) unsigned;default:0;comment:行政组织"` + Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;comment:归属岗位"` + Key string `json:"key" gorm:"column:key;type:varchar(200) unsigned;default:0;not null;comment:编码"` + Versio string `json:"versio" gorm:"column:version;type:varchar(20) unsigned;default:0;not null;comment:版本号"` + Year int64 `json:"year" gorm:"column:years;type:int(5) 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:删除)"` + AddTime int64 `json:"addtime" gorm:"column:addtime;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` + EiteTime int64 `json:"eitetime" gorm:"column:eitetime;type:bigint(20) unsigned;default:0;not null;comment:修改时间"` + Content string `json:"content" gorm:"column:content;type:longtext;comment:版本内容"` +} + +func (PositionPlanVersio *PositionPlanVersio) TableName() string { + return "position_plan_version" +} + +// 编辑内容 +func (cont *PositionPlanVersio) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *PositionPlanVersio) 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 *PositionPlanVersio) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *PositionPlanVersio) ContMap(whereMap interface{}, field ...string) (countAry []PositionPlanVersio, 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 *PositionPlanVersio) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/post_target.go b/models/modelskpi/post_target.go new file mode 100644 index 0000000..56917de --- /dev/null +++ b/models/modelskpi/post_target.go @@ -0,0 +1,72 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 岗位指标 +type PostTarget struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"` + Type int `json:"type" gorm:"column:type;type:int(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` + State int `json:"state" gorm:"column:state;type:int(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:创建时间"` + Share int `json:"share" gorm:"column:share;type:int(1) unsigned;default:1;not null;comment:1:共用;2:私用"` + ReleDepart int64 `json:"reledepart" gorm:"column:rele_depart;type:bigint(20) unsigned;default:0;not null;comment:相关部门"` + DepartmentsPost string `json:"departmentspost" gorm:"column:departments_post;type:text ;default:'';comment:相关岗位"` + Dimension int64 `json:"dimension" gorm:"column:dimension;type:bigint(20) unsigned;default:0;not null;comment:维度"` + Key int64 `json:"key" gorm:"column:key;type:bigint(20) unsigned;default:0;not null;comment:UUID"` + Report string `json:"report" gorm:"column:report;type:text ;default:'';comment:上报人"` + Unit string `json:"unit" gorm:"column:unit;type:varchar(255) unsigned;default:'';not null;comment:单位"` + Cycle int `json:"cycle" gorm:"column:cycle;type:int(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"` + Cycleattr int `json:"cycleattr" gorm:"column:cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"` + ScoringMethod int `json:"scoringmethod" gorm:"column:scoring_method;type:int(1) unsigned;default:0;not null;comment:计分方式(1:自动;2:手动)"` + VisibleRange string `json:"visiblerange" gorm:"column:visible_range;type:text ;default:'';comment:可见范围"` + VisibleGroup string `json:"visiblegroup" gorm:"column:visible_group;type:text ;default:'';comment:可见范围(集团)"` +} + +func (PostTarget *PostTarget) TableName() string { + return "post_target" +} + +// 编辑内容 +func (cont *PostTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *PostTarget) 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 *PostTarget) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *PostTarget) ContMap(whereMap interface{}, field ...string) (countAry []PostTarget, 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 *PostTarget) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/post_target_details.go b/models/modelskpi/post_target_details.go new file mode 100644 index 0000000..3df9d61 --- /dev/null +++ b/models/modelskpi/post_target_details.go @@ -0,0 +1,77 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 指标细则 +type PostTargetDetails struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + Title string `json:"title" gorm:"column:title;type:text;comment:指标细则"` + Content string `json:"content" gorm:"column:content;type:text;comment:指标说明"` + ParentId int64 `json:"parentid" gorm:"column:parentid;type:bigint(20) unsigned;default:0;not null;comment:归属指标栏目"` + ParentIdSun int64 `json:"parentidsun" gorm:"column:parentid_sun;type:bigint(20) unsigned;default:0;not null;comment:归属指标子栏目"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + AddTime int64 `json:"addtime" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"` + MinScore int64 `json:"minscore" gorm:"column:min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"` + MaxScore int64 `json:"maxscore" gorm:"column:max_score;type:bigint(20) unsigned;default:0;not null;comment:最大分*100保存"` + Company string `json:"company" gorm:"column:company;type:varchar(20) unsigned;default:0;not null;comment:单位"` + AddReduce int `json:"addreduce" gorm:"column:add_reduce;type:int(1) unsigned;default:1;not null;comment:1:减少;2:增加;3:无属性,现场确认加或减"` + CensorType string `json:"censortype" gorm:"column:censor_type;type:text;comment:检查方式"` + CensorCont string `json:"censorcont" gorm:"column:censor_cont;type:longtext;comment:检查依据"` + CensorRate int `json:"censorrate" gorm:"column:censor_rate;type:int(5) unsigned;default:1;not null;comment:检查频次"` + Cycles int `json:"cycle" gorm:"column:cycle;type:tinyint(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"` + CycleAttres int `json:"cycleattr" gorm:"column:cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"` + Paretment int64 `json:"paretment" gorm:"column:paretment;type:bigint(20);comment:接受考核的部门"` + ParetmentPost string `json:"paretmentpost" gorm:"column:paretment_post;type:longtext;comment:接受考核的部门岗位"` + Reportary string `json:"reportary" gorm:"column:reportary;type:longtext;comment:提报人"` + Punishmode int `json:"punishmode" gorm:"column:punishmode;type:tinyint(1) unsigned;default:1;not null;comment:处罚方式 1:扣分;2:现金处罚;3:扣分加现金"` + Maxmoney int64 `json:"maxmoney" gorm:"column:maxmoney;type:bigint(20) unsigned;default:0;not null;comment:最高罚款"` + Minmoney int64 `json:"minmoney" gorm:"column:minmoney;type:bigint(20) unsigned;default:0;not null;comment:最低罚款"` +} + +func (PostTargetDetails *PostTargetDetails) TableName() string { + return "post_target_details" +} + +// 编辑内容 +func (cont *PostTargetDetails) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *PostTargetDetails) 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 *PostTargetDetails) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *PostTargetDetails) ContMap(whereMap interface{}, field ...string) (countAry []PostTargetDetails, 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 *PostTargetDetails) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/qualitative_evaluation_scheme.go b/models/modelskpi/qualitative_evaluation_scheme.go new file mode 100644 index 0000000..adfc1bb --- /dev/null +++ b/models/modelskpi/qualitative_evaluation_scheme.go @@ -0,0 +1,76 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 岗位评估方案 +type QualitativeEvaluationScheme struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + VersionNumber string `json:"versionnumber" gorm:"column:version_number;type:varchar(255) unsigned;not null;comment:版本编号"` + CompanyId int64 `json:"companyid" gorm:"column:company_id;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:归属部门"` + OrgId int64 `json:"orgid" gorm:"column:org_id;type:bigint(20) unsigned;default:0;not null;comment:归属行政组织"` + PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:归属岗位"` + Title string `json:"title" gorm:"column:title;type:varchar(255) ;default:'';comment:考核项名称"` + DimensionId int64 `json:"dimensionid" 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:指标"` + SonTargetId int64 `json:"sontargetid" gorm:"column:son_target_id;type:bigint(20) unsigned;default:0;not null;comment:子栏目"` + DetailsId int64 `json:"detailsid" gorm:"column:details_id;type:bigint(20) unsigned;default:0;not null;comment:细则"` + Attribute int `json:"attribute" gorm:"column:attribute;type:tinyint(1) unsigned;default:1;not null;comment:属性 1:定性考核;2:定量考核"` + MinScore int64 `json:"minscore" gorm:"column:min_score;type:bigint(20) unsigned;default:0;not null;comment:最小分*100保存"` + MaxScore int64 `json:"maxscore" gorm:"column:max_score;type:bigint(20) unsigned;default:0;not null;comment:最大分*100保存"` + ScoringMethod int `json:"scoringmethod" gorm:"column:scoring_method;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:删除)"` + Addtime int64 `json:"addtime" gorm:"column:addtime;type:bigint(20) unsigned;default:0;not null;comment:添加时间"` + Eitetime int64 `json:"eitetime" gorm:"column:eitetime;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` + CensorType string `json:"censortype" gorm:"column:censor_type;type:tinytext;comment:检查方式(1:现场检查;2:资料检查;3:事件触发)"` + Source int `json:"source" gorm:"column:source;type:tinyint(1) unsigned;default:1;not null;comment:来源(1:岗位;2:部门引用)"` + RunState int `json:"run_state" gorm:"column:run_state;type:tinyint(1) unsigned;default:1;not null;comment:运行状态(1:启用;2:禁用;3:观察)"` +} + +func (QualitativeEvaluationScheme *QualitativeEvaluationScheme) TableName() string { + return "qualitative_evaluation_scheme" +} + +// 编辑内容 +func (cont *QualitativeEvaluationScheme) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *QualitativeEvaluationScheme) 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 *QualitativeEvaluationScheme) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *QualitativeEvaluationScheme) ContMap(whereMap interface{}, field ...string) (countAry []QualitativeEvaluationScheme, 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 *QualitativeEvaluationScheme) 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 new file mode 100644 index 0000000..5a13724 --- /dev/null +++ b/models/modelskpi/target_department.go @@ -0,0 +1,67 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 指标、栏目、细则关联部门 +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:指标细则"` + 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: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:岗位级)"` +} + +func (TargetDepartment *TargetDepartment) TableName() string { + return "target_department" +} + +// 编辑内容 +func (cont *TargetDepartment) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *TargetDepartment) 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 *TargetDepartment) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *TargetDepartment) ContMap(whereMap interface{}, field ...string) (countAry []TargetDepartment, 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 *TargetDepartment) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/target_report.go b/models/modelskpi/target_report.go new file mode 100644 index 0000000..6fbcc41 --- /dev/null +++ b/models/modelskpi/target_report.go @@ -0,0 +1,69 @@ +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"` + 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:指标细则"` + 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: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:细则)"` +} + +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/models/menu_operation.go b/models/modelsschool/menu_operation.go similarity index 95% rename from models/menu_operation.go rename to models/modelsschool/menu_operation.go index 369eadb..bc3dcd4 100644 --- a/models/menu_operation.go +++ b/models/modelsschool/menu_operation.go @@ -1,4 +1,4 @@ -package models +package modelsschool //菜单功能 type MenuOperation struct { diff --git a/models/step_role_group.go b/models/modelsschool/step_role_group.go similarity index 98% rename from models/step_role_group.go rename to models/modelsschool/step_role_group.go index 7196554..54dd410 100644 --- a/models/step_role_group.go +++ b/models/modelsschool/step_role_group.go @@ -1,4 +1,4 @@ -package models +package modelsschool import "key_performance_indicators/overall" diff --git a/models/system_nenu.go b/models/modelsschool/system_nenu.go similarity index 94% rename from models/system_nenu.go rename to models/modelsschool/system_nenu.go index 04315e7..be33325 100644 --- a/models/system_nenu.go +++ b/models/modelsschool/system_nenu.go @@ -1,11 +1,11 @@ -package models +package modelsschool import ( "key_performance_indicators/overall" "strings" ) -//菜单 +// 菜单 type SystemMenu struct { Id int64 `json:"id" gorm:"primaryKey;column:m_id;type:bigint(20) unsigned;not null;comment:ID"` Title string `json:"title" gorm:"column:m_title;type:varchar(255);not null;comment:菜单名称"` @@ -22,19 +22,19 @@ func (SystemMenu *SystemMenu) TableName() string { return "system_menu" } -//菜单管理 +// 菜单管理 type SystemMenuOperation struct { SystemMenu MenuPermit []MenuOperation `json:"menupermit"` } -//根据条件获取总数 +// 根据条件获取总数 func (cont *SystemMenu) CountCont(whereMap map[string]interface{}) (countId int64) { overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Count(&countId) return } -//获取行政组织内容 +// 获取行政组织内容 func (cont *SystemMenu) GetCont(whereMap map[string]interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_Master.Model(&cont) if len(field) > 0 { diff --git a/models/system_role.go b/models/modelsschool/system_role.go similarity index 98% rename from models/system_role.go rename to models/modelsschool/system_role.go index 493e7d0..7db4331 100644 --- a/models/system_role.go +++ b/models/modelsschool/system_role.go @@ -1,4 +1,4 @@ -package models +package modelsschool import "key_performance_indicators/overall" diff --git a/models/system_user.go b/models/modelsschool/system_user.go similarity index 98% rename from models/system_user.go rename to models/modelsschool/system_user.go index deca05b..3a8a172 100644 --- a/models/system_user.go +++ b/models/modelsschool/system_user.go @@ -1,4 +1,4 @@ -package models +package modelsschool import "key_performance_indicators/overall" diff --git a/models/system_user_attribute.go b/models/modelsschool/system_user_attribute.go similarity index 98% rename from models/system_user_attribute.go rename to models/modelsschool/system_user_attribute.go index 969b3c3..d915475 100644 --- a/models/system_user_attribute.go +++ b/models/modelsschool/system_user_attribute.go @@ -1,4 +1,4 @@ -package models +package modelsschool import "key_performance_indicators/overall" diff --git a/models/wechatUsers.go b/models/modelswechat/wechatUsers.go similarity index 99% rename from models/wechatUsers.go rename to models/modelswechat/wechatUsers.go index 85b6a4a..a1a1058 100644 --- a/models/wechatUsers.go +++ b/models/modelswechat/wechatUsers.go @@ -1,4 +1,4 @@ -package models +package modelswechat //企业微信人员架构 type WechatUsers struct { diff --git a/overall/publicmethod/formatOutput.go b/overall/publicmethod/formatOutput.go index 2018f13..d37ef88 100644 --- a/overall/publicmethod/formatOutput.go +++ b/overall/publicmethod/formatOutput.go @@ -4,14 +4,14 @@ import ( "encoding/json" "errors" "fmt" - "key_performance_indicators/models" + "key_performance_indicators/models/modelshr" "key_performance_indicators/overall" "net/http" "github.com/gin-gonic/gin" ) -//格式化输出 +// 格式化输出 func Result(code int, data interface{}, c *gin.Context, msgAry ...string) { var msg string if _, isTrue := ErrorCodeMsg[code]; isTrue { @@ -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格式数据 @@ -45,8 +50,8 @@ func ResultList(code, page, pageSize int, total, count int64, data interface{}, return } -//登录信息转换 -func LoginMyCont(c *gin.Context) (myCont models.ManCont, err error) { +// 登录信息转换 +func LoginMyCont(c *gin.Context) (myCont modelshr.ManCont, err error) { context, exi := c.Get(overall.MyContJwt) if exi != true { err = errors.New("对不起!你没有该功能的操作权限!1") diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 97336e5..af02e42 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -9,7 +9,7 @@ import ( "errors" "fmt" "key_performance_indicators/middleware/grocerystore" - "key_performance_indicators/models" + "key_performance_indicators/models/modelshr" "key_performance_indicators/overall" "math" "math/big" @@ -21,8 +21,8 @@ import ( "gorm.io/gorm" ) -//全局函数处理 -//编号,纯数字 +// 全局函数处理 +// 编号,纯数字 func TableNumber(class ...string) (number int64) { result, _ := rand.Int(rand.Reader, big.NewInt(8999)) numberTeam := result.Int64() + 1000 @@ -36,7 +36,7 @@ func TableNumber(class ...string) (number int64) { return } -//初始化map(泛型) +// 初始化map(泛型) func MapOut[T GenericityVariable]() (data map[T]interface{}) { data = make(map[T]interface{}) //必可不少,分配内存 return data @@ -118,7 +118,7 @@ func DateToTimeStamp(dataStr string) (timeStamp int64, isTrue bool) { return } -//数据库查询翻页 +// 数据库查询翻页 func LimitPage(page, pageSize int) (offSet int) { if page < 1 { page = 1 @@ -130,7 +130,7 @@ func LimitPage(page, pageSize int) (offSet int) { return } -//中文首字母大写 +// 中文首字母大写 func ChineseFirstWordCapitalize(wordStr string) (firstWord string) { pinYinSub := pinyin.NewArgs() rows := pinyin.Pinyin(wordStr, pinYinSub) @@ -144,13 +144,12 @@ func ChineseFirstWordCapitalize(wordStr string) (firstWord string) { return } -// ZeroFillByStr -// @Description: 字符串补零 -// @param str :需要操作的字符串 -// @param resultLen 结果字符串的长度 -// @param reverse true 为前置补零,false 为后置补零 -// @return string -// +// ZeroFillByStr +// @Description: 字符串补零 +// @param str :需要操作的字符串 +// @param resultLen 结果字符串的长度 +// @param reverse true 为前置补零,false 为后置补零 +// @return string func ZeroFillByStr(str string, resultLen int, reverse bool) string { if len(str) > resultLen || resultLen <= 0 { return str @@ -272,13 +271,13 @@ func (m *Md5Encryption) Md5EncryptionAlgorithmFj() (md5Val string, outlog []stri return } -//初始化程序 +// 初始化程序 func (m *Md5Encryption) Md5EncryptionInit(code string) { m.AppKey = overall.CONSTANT_CONFIG.Appsetup.AppKey m.Code = code } -//sha1算法 +// sha1算法 func Sha1Encryption(str string) string { sha1 := sha1.New() sha1.Write([]byte(str)) @@ -306,7 +305,7 @@ func GetFutureMonthTime(timeStamp int64, futureTime, class int) (dateStr int64) return } -//判断字符串是否在切片中 泛型 +// 判断字符串是否在切片中 泛型 func IsInTrue[T GenericityVariable](key T, keyAry []T) (isTrue bool) { isTrue = false for _, v := range keyAry { @@ -317,7 +316,7 @@ func IsInTrue[T GenericityVariable](key T, keyAry []T) (isTrue bool) { return } -//获取两个切片得差集 +// 获取两个切片得差集 func DifferenceSet[T GenericityVariable](one, two []T) []T { var three []T temp := map[T]struct{}{} @@ -367,8 +366,8 @@ func StringToInt64(val interface{}) (int64, error) { return 0, nil } -//获取人员TokenRedis 信息 -func GetUserRedisToken(number string) (manCont models.ManCont, err error) { +// 获取人员TokenRedis 信息 +func GetUserRedisToken(number string) (manCont modelshr.ManCont, err error) { redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, number) redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) useMap, isTrue := redisClient.HashGetAll(redisMyContKey) @@ -381,8 +380,8 @@ func GetUserRedisToken(number string) (manCont models.ManCont, err error) { return } -//获取人员Redis信息 -func GetUserRedisCont(number string) (manCont models.ManCont, err error) { +// 获取人员Redis信息 +func GetUserRedisCont(number string) (manCont modelshr.ManCont, err error) { redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, number) redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) useMap, isTrue := redisClient.HashGetAll(redisMyContKey) @@ -397,8 +396,8 @@ func GetUserRedisCont(number string) (manCont models.ManCont, err error) { return } -//获取人员Redis信息返回指针 -func GetUserRedisContPointer(number string) (manCont models.ManCont, err error) { +// 获取人员Redis信息返回指针 +func GetUserRedisContPointer(number string) (manCont modelshr.ManCont, err error) { redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, number) redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) useMap, isTrue := redisClient.HashGetAll(redisMyContKey) @@ -475,7 +474,7 @@ func MapToStruct(mapString map[string]string, structInterface interface{}, tag s return } -//翻页设置 +// 翻页设置 func PageTurningSettings(gormDb *gorm.DB, page, pageSize int) *gorm.DB { if page < 0 { page = 1 @@ -486,3 +485,122 @@ 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 +} + +// 递归查找 +func RecursionOrgLeve(superior int64, leve int64) (groupId int64) { + if leve == 0 { + leve = 1 + } + var orgMap modelshr.OrgContType + err := orgMap.GetCont(map[string]interface{}{"`id`": superior, "`state`": 1}, "`id`", "`superior`", "`level`") + if err != nil { + return + } + if orgMap.Level <= leve { + groupId = orgMap.Id + return + } else { + groupId = RecursionOrgLeve(orgMap.Superior, leve) + } + return +} + +// 获取集团、公司、部门、二级部门、工段 +func GetOrgStructure(orgId int64) (groupId, companyId, departmentId, sunDepartId, workShopId int64) { + var orgContTypeInfo modelshr.OrgContType + err := orgContTypeInfo.GetCont(map[string]interface{}{"`id`": orgId}) + if err != nil { + return + } + switch orgContTypeInfo.Level { + case 1: + groupId = orgContTypeInfo.Id + case 2: + groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 1) + workShopId = orgContTypeInfo.Id + case 3: + groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 2) + companyId = orgContTypeInfo.Id + case 4: + groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 2) + companyId = RecursionOrgLeve(orgContTypeInfo.Superior, 3) + departmentId = orgContTypeInfo.Id + case 5: + groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 2) + companyId = RecursionOrgLeve(orgContTypeInfo.Superior, 3) + departmentId = RecursionOrgLeve(orgContTypeInfo.Superior, 4) + sunDepartId = orgContTypeInfo.Id + case 6: + groupId = RecursionOrgLeve(orgContTypeInfo.Superior, 2) + companyId = RecursionOrgLeve(orgContTypeInfo.Superior, 3) + departmentId = RecursionOrgLeve(orgContTypeInfo.Superior, 4) + sunDepartId = RecursionOrgLeve(orgContTypeInfo.Superior, 5) + workShopId = orgContTypeInfo.Id + default: + groupId = orgContTypeInfo.Id + companyId = orgContTypeInfo.Id + workShopId = orgContTypeInfo.Id + } + return +} + +// 获取指定行政组织id,所有子类 +func GetDepartmentSun(superior int64, idary []int64) (orgIdAry []int64) { + var orgAry []modelshr.AdministrativeOrganization + err := overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1 AND `superior` = ?", superior).Find(&orgAry).Error + if err != nil { + return + } + for _, v := range orgAry { + if IsInTrue[int64](v.Id, orgIdAry) == false { + orgIdAry = append(orgIdAry, v.Id) + GetDepartmentSun(v.Id, orgIdAry) + } else { + GetDepartmentSun(v.Id, orgIdAry) + } + } + return +} + +// 获取集团或第一实权部门 +func GetGroupOrDepartPower(parentId int64, departId ...int64) int64 { + var orgCont modelshr.AdministrativeOrganization + err := orgCont.GetCont(map[string]interface{}{"id": parentId}, "id", "organization_type", "superior", "ispower") + if err != nil { + return parentId + } + if len(departId) > 0 { + if orgCont.IsPower == 1 { + return orgCont.Id + } + return GetGroupOrDepartPower(orgCont.Superior, 1) + } else { + if orgCont.OrganizationType <= 2 { + return orgCont.Id + } + return GetGroupOrDepartPower(orgCont.Superior) + } + return orgCont.Id +} diff --git a/overall/publicmethod/type.go b/overall/publicmethod/type.go index 962375a..149d417 100644 --- a/overall/publicmethod/type.go +++ b/overall/publicmethod/type.go @@ -23,6 +23,11 @@ type PublicId struct { Id string `json:"id"` } +//通用name结构体 +type PublicName struct { + Name string `json:"name"` +} + //通用编辑状态结构体 type PublicState struct { PublicId