diff --git a/api/shiyan/maptostruct/maptostr.go b/api/shiyan/maptostruct/maptostr.go index 3caa7fd..6986bb4 100644 --- a/api/shiyan/maptostruct/maptostr.go +++ b/api/shiyan/maptostruct/maptostr.go @@ -5,6 +5,7 @@ import ( "fmt" "key_performance_indicators/middleware/wechatapp/wechatcallback" "key_performance_indicators/models/modelshr" + "key_performance_indicators/models/modelskpi" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" "time" @@ -127,3 +128,216 @@ func (a *ApiMethod) SetUpHrSystem(c *gin.Context) { } publicmethod.Result(0, err, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-05 13:25:07 +@ 功能: 审批流规制发生时间 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) EvalProcTime(c *gin.Context) { + var listCont []modelskpi.EvaluationProcess + err := overall.CONSTANT_DB_KPI.Find(&listCont).Error + var dingXingOrd []int64 + var dingLiangOrd []int64 + if err == nil { + for _, v := range listCont { + if v.TypeClass == 1 { + if publicmethod.IsInTrue[int64](v.OrderKey, dingXingOrd) == false { + dingXingOrd = append(dingXingOrd, v.OrderKey) + } + } else { + if publicmethod.IsInTrue[int64](v.OrderKey, dingLiangOrd) == false { + dingLiangOrd = append(dingLiangOrd, v.OrderKey) + } + } + } + } + syncSeting.Add(1) + go DingXingJiaoDui(dingXingOrd) + syncSeting.Add(1) + go DingLiangJiaoDui(dingLiangOrd) + syncSeting.Wait() + outData := publicmethod.MapOut[string]() + outData["err"] = err + outData["dingXingOrd"] = dingXingOrd + outData["dingXingOrdCount"] = len(dingXingOrd) + outData["dingLiangOrd"] = dingLiangOrd + outData["dingLiangOrdCount"] = len(dingLiangOrd) + publicmethod.Result(0, outData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-05 13:40:35 +@ 功能: 定性审批流校对 +@ 参数 + + #ordId 审批单ID + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func DingXingJiaoDui(ordId []int64) { + defer syncSeting.Done() + if len(ordId) > 100 { + var fenPi []int64 + for i, v := range ordId { + if publicmethod.IsInTrue[int64](v, fenPi) == false { + fenPi = append(fenPi, v) + } + if (i+1)%100 == 0 { + syncSetings.Add(1) + go EditEvalProcDingXing(fenPi) + // fmt.Printf("%v--------->%v--------->%v\n", i, len(fenPi), fenPi) + fenPi = []int64{} + } + } + if len(fenPi) > 0 { + syncSetings.Add(1) + go EditEvalProcDingXing(fenPi) + } + syncSetings.Wait() + // fmt.Printf("结束--------->%v--------->%v\n", len(fenPi), fenPi) + } else { + if len(ordId) > 0 { + for _, v := range ordId { + var scoreFlowCont modelskpi.ScoreFlow + err := scoreFlowCont.GetCont(map[string]interface{}{"`sf_key`": v}, "`sf_happen_time`", "`sf_duty_department`") + if err == nil { + saveData := publicmethod.MapOut[string]() + saveData["ep_happen_time"] = scoreFlowCont.HappenTime + saveData["ep_accept_department"] = scoreFlowCont.DutyDepartment + saveData["ep_time"] = time.Now().Unix() + var editEvalProce modelskpi.EvaluationProcess + editEvalProce.EiteCont(map[string]interface{}{"`ep_order_key`": v}, saveData) + } + } + } + } +} +func EditEvalProcDingXing(ordId []int64) { + defer syncSetings.Done() + if len(ordId) > 0 { + for _, v := range ordId { + var scoreFlowCont modelskpi.ScoreFlow + err := scoreFlowCont.GetCont(map[string]interface{}{"`sf_key`": v}, "`sf_happen_time`", "`sf_duty_department`") + if err == nil { + saveData := publicmethod.MapOut[string]() + saveData["ep_happen_time"] = scoreFlowCont.HappenTime + saveData["ep_accept_department"] = scoreFlowCont.DutyDepartment + saveData["ep_time"] = time.Now().Unix() + var editEvalProce modelskpi.EvaluationProcess + editEvalProce.EiteCont(map[string]interface{}{"`ep_order_key`": v}, saveData) + } + } + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-05 13:40:35 +@ 功能: 定量审批流校对 +@ 参数 + + #ordId 审批单ID + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func DingLiangJiaoDui(ordId []int64) { + defer syncSeting.Done() + if len(ordId) > 100 { + var fenPi []int64 + for i, v := range ordId { + if publicmethod.IsInTrue[int64](v, fenPi) == false { + fenPi = append(fenPi, v) + } + if (i+1)%100 == 0 { + syncSetings.Add(1) + go EditEvalProcDingLiang(fenPi) + // fmt.Printf("定量----》%v--------->%v--------->%v\n", i, len(fenPi), fenPi) + fenPi = []int64{} + } + } + if len(fenPi) > 0 { + syncSetings.Add(1) + go EditEvalProcDingLiang(fenPi) + } + syncSetings.Wait() + // fmt.Printf("定量----》结束--------->%v--------->%v\n", len(fenPi), fenPi) + } else { + if len(ordId) > 0 { + for _, v := range ordId { + var flowLogCont modelskpi.FlowLog + err := flowLogCont.GetCont(map[string]interface{}{"`fl_key`": v}, "`fl_year`", "`fl_month`", "`fl_day`", "`fl_duty_department`") + if err == nil { + monthStr := fmt.Sprintf("%v", flowLogCont.Month) + if flowLogCont.Month <= 9 { + monthStr = fmt.Sprintf("0%v", flowLogCont.Month) + } + dayStr := fmt.Sprintf("%v", flowLogCont.ToDay) + if flowLogCont.ToDay <= 9 { + dayStr = fmt.Sprintf("0%v", flowLogCont.ToDay) + } + saveData := publicmethod.MapOut[string]() + saveData["ep_happen_time"] = publicmethod.DateToTimeStampOld(fmt.Sprintf("%v-%v-%v 12:00:00", flowLogCont.Year, monthStr, dayStr)) + saveData["ep_accept_department"] = flowLogCont.DutyDepartment + saveData["ep_time"] = time.Now().Unix() + var editEvalProce modelskpi.EvaluationProcess + editEvalProce.EiteCont(map[string]interface{}{"`ep_order_key`": v}, saveData) + } + } + } + } +} +func EditEvalProcDingLiang(ordId []int64) { + defer syncSetings.Done() + if len(ordId) > 0 { + for _, v := range ordId { + var flowLogCont modelskpi.FlowLog + err := flowLogCont.GetCont(map[string]interface{}{"`fl_key`": v}, "`fl_year`", "`fl_month`", "`fl_day`", "`fl_duty_department`") + if err == nil { + monthStr := fmt.Sprintf("%v", flowLogCont.Month) + if flowLogCont.Month <= 9 { + monthStr = fmt.Sprintf("0%v", flowLogCont.Month) + } + dayStr := fmt.Sprintf("%v", flowLogCont.ToDay) + if flowLogCont.ToDay <= 9 { + dayStr = fmt.Sprintf("0%v", flowLogCont.ToDay) + } + timeString := fmt.Sprintf("%v-%v-%v 12:00:00", flowLogCont.Year, monthStr, dayStr) + fmt.Printf("定量---->%v---------->%v\n", v, timeString) + saveData := publicmethod.MapOut[string]() + saveData["ep_happen_time"] = publicmethod.DateToTimeStampOld(timeString) + saveData["ep_accept_department"] = flowLogCont.DutyDepartment + saveData["ep_time"] = time.Now().Unix() + var editEvalProce modelskpi.EvaluationProcess + editEvalProce.EiteCont(map[string]interface{}{"`ep_order_key`": v}, saveData) + } + } + } +} diff --git a/api/version1/departmentseting/departmentpc/qualitativekpi.go b/api/version1/departmentseting/departmentpc/qualitativekpi.go index a056cb9..30234d2 100644 --- a/api/version1/departmentseting/departmentpc/qualitativekpi.go +++ b/api/version1/departmentseting/departmentpc/qualitativekpi.go @@ -38,7 +38,7 @@ func (a *ApiMethod) DepartmentTargetList(c *gin.Context) { gormDb = gormDb.Where("et_type = ?", receivedValue.Class) } if receivedValue.DepartmentId != "" { //部门ID - gormDb = gormDb.Where("FIND_IN_SET(?,`departments_post`)", receivedValue.DepartmentId) + gormDb = gormDb.Where("FIND_IN_SET(?,`et_relevant_departments`)", receivedValue.DepartmentId) } if receivedValue.DimensionId != "" { //维度ID gormDb = gormDb.Where("et_dimension = ?", receivedValue.DimensionId) @@ -730,7 +730,29 @@ func (a *ApiMethod) AddSunTargetDetailed(c *gin.Context) { 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) + var whistleblower zhuanHuanMan + // judgeSunTarErr := judgeSunTarget.JudgeIsTrue(map[string]interface{}{"q_title": receivedValue.TargetSunTitle, "q_parent_id": receivedValue.Target}, saveSunTarget) + judgeSunTarErr := JudgeSunTargetAbout(receivedValue.Target, receivedValue.TargetSunTitle, saveSunTarget, whistleblower) + /* + * + @ 作者: 秦东 + @ 时间: 2023-01-03 16:13:46 + @ 功能: 判断指标得子栏目是否存在 + @ 参数 + + #targetId 指标ID + #sunTargetTitle 子栏目名称 + #saveData 子栏目数据表 + #whistleblower 提报人 + + @ 返回值 + + #err 返回值 + + @ 方法原型 + + #JudgeSunTargetAbout(targetId, sunTargetTitle string, saveData modelskpi.QualitativeTarget, whistleblower zhuanHuanMan) (err error) + */ if judgeSunTarErr != nil { publicmethod.Result(106, judgeSunTarErr, c) return @@ -929,6 +951,9 @@ func editDetaAdd(targetId, sunTargetId int64, qualEvalCont QualEvalSunList, deta if reportStr != detailInfof.Reportary { saveData["reportary"] = reportStr } + if detailInfof.State != 1 { + saveData["dt_state"] = 1 + } if len(saveData) > 0 { saveData["dt_time"] = time.Now().Unix() var editCont modelskpi.DetailedTarget @@ -1047,6 +1072,20 @@ func handleDetarildTargetRepart(targetId, targetSunId, bylawsId int64, repart [] overall.CONSTANT_DB_KPI.Create(&tarReportCont) } } + var targetInfo modelskpi.QualitativeTarget + saveSunTarget := modelskpi.QualitativeTarget{ + Title: targetInfo.Title, // 指标子栏目名称 + ParentId: targetId, //归属指标 + State: 1, //状态(1:启用;2:禁用;3:删除) + AddTime: time.Now().Unix(), //制定时间"` + Depart: targetInfo.Depart, //关联部门"` + } + var whistleblower zhuanHuanMan + whistleblower.Id = bylawsId + whistleblower.Operator = repart + targetIdStr := strconv.FormatInt(targetId, 10) + targetSunIdStr := strconv.FormatInt(targetSunId, 10) + JudgeSunTargetAbout(targetIdStr, targetSunIdStr, saveSunTarget, whistleblower) } // 获取定性考核指标列表内容 @@ -2651,3 +2690,107 @@ func (a *ApiMethod) DelTarget(c *gin.Context) { } publicmethod.Result(0, err, c) } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-03 16:13:46 +@ 功能: 判断指标得子栏目是否存在 +@ 参数 + + #targetId 指标ID + #sunTargetTitle 子栏目名称 + #saveData 子栏目数据表 + #whistleblower 提报人 + +@ 返回值 + + #err 返回值 + +@ 方法原型 + + #JudgeSunTargetAbout(targetId, sunTargetTitle string, saveData modelskpi.QualitativeTarget, whistleblower zhuanHuanMan) (err error) +*/ +func JudgeSunTargetAbout(targetId, sunTargetTitle string, saveData modelskpi.QualitativeTarget, whistleblower zhuanHuanMan) (err error) { + var sunTargetCont modelskpi.QualitativeTarget + err = sunTargetCont.GetCont(map[string]interface{}{"q_title": sunTargetTitle, "q_parent_id": targetId}) + if err != nil { + err = overall.CONSTANT_DB_KPI.Create(&saveData).Error + } else { + if sunTargetCont.State != 1 { + err = sunTargetCont.EiteCont(map[string]interface{}{"`q_id`": sunTargetCont.Id}, map[string]interface{}{"`q_state`": 1, "`q_time`": time.Now().Unix()}) + } + } + if err == nil { + var dimCont modelskpi.EvaluationTarget + dimCont.GetCont(map[string]interface{}{"`et_id`": targetId}, "`et_dimension`") + var groupId int64 + groupId = 309 + departAry := strings.Split(sunTargetCont.Depart, ",") + if len(departAry) > 0 { + orgId, _ := strconv.ParseInt(departAry[0], 10, 64) + _, groupId, _, _, _ = publicmethod.GetOrgStructure(orgId) + } + //判断关联数据是否是否编写 + var assEssCont modelskpi.Assesstarget + errEs := assEssCont.GetCont(map[string]interface{}{"`targetid`": targetId, "`suntargetid`": sunTargetCont.Id, "`dimension`": dimCont.Id}) + if errEs != nil { + //数据不存在,则新增 + assEssCont.Group = groupId //集团ID"` + assEssCont.Departmentmap = sunTargetCont.Depart //部门ID"` + assEssCont.TargetId = sunTargetCont.ParentId //指标"` + assEssCont.SunTargetId = sunTargetCont.Id //子栏目ID"` + var whistleblowerAry []zhuanHuanMan + whistleblowerAry = append(whistleblowerAry, whistleblower) + whistleblowerStr, _ := json.Marshal(whistleblowerAry) + assEssCont.Content = string(whistleblowerStr) //描述"` + assEssCont.Time = time.Now().Unix() //创建时间"` + assEssCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` + assEssCont.Dimension = dimCont.Id //维度"` + overall.CONSTANT_DB_KPI.Create(&assEssCont) + } else { + oldDepart := strings.Split(assEssCont.Departmentmap, ",") + //数据存在,则修改 + metgrAry := publicmethod.MergeStruct[string](departAry, oldDepart) + metgrAryStr := strings.Join(metgrAry, ",") + editSaveDate := publicmethod.MapOut[string]() + if metgrAryStr != assEssCont.Departmentmap { + editSaveDate["`departmentmap`"] = metgrAryStr + + } + if whistleblower.Id != 0 && len(whistleblower.Operator) > 0 { + var oldWhistle []zhuanHuanMan + errjson := json.Unmarshal([]byte(assEssCont.Content), oldWhistle) + if errjson != nil { + var newPeopleList []zhuanHuanMan + for _, v := range oldWhistle { + if whistleblower.Id == v.Id { + var newPeopleCont zhuanHuanMan + newPeopleCont.Id = whistleblower.Id + metgrPeoleAry := publicmethod.MergeStruct[string](v.Operator, whistleblower.Operator) + newPeopleCont.Operator = metgrPeoleAry + newPeopleList = append(newPeopleList, newPeopleCont) + } else { + newPeopleList = append(newPeopleList, v) + } + } + whistleblowerStr, _ := json.Marshal(newPeopleList) + editSaveDate["`departmentmap`"] = whistleblowerStr + } else { + var whistleblowerAry []zhuanHuanMan + whistleblowerAry = append(whistleblowerAry, whistleblower) + whistleblowerStr, _ := json.Marshal(whistleblowerAry) + editSaveDate["`departmentmap`"] = whistleblowerStr + } + } + if len(editSaveDate) > 0 { + editSaveDate["`state`"] = 1 + editSaveDate["`time`"] = time.Now().Unix() + var editAssEssCont modelskpi.Assesstarget + editAssEssCont.EiteCont(map[string]interface{}{"`at_id`": assEssCont.Id}, editSaveDate) + } + } + } + + return +} diff --git a/api/version1/empower/system_license.go b/api/version1/empower/system_license.go index 8bbdcbf..6d68f1d 100644 --- a/api/version1/empower/system_license.go +++ b/api/version1/empower/system_license.go @@ -25,7 +25,7 @@ func (a *ApiMethod) ObtainAuthorization(c *gin.Context) { publicmethod.Result(1, err, c, "未知身份!不可授权!") return } - // jsonStr, _ := json.Marshal(context) + // jsonStr, _ := json.Marshal(receivedValue) // fmt.Printf("jsonStr------>%v\n", string(jsonStr)) // menuIdAry, menuUrl, err := publicmethod.GetPostPower(context.AdminOrg, context.Position, receivedValue.System) _, pointId, operation, _ := publicmethod.GetNewAccredit(receivedValue.System, context.Role, context.Key, context.AdminOrg, context.Position) diff --git a/api/version1/postseting/postpc/scheme.go b/api/version1/postseting/postpc/scheme.go index 1a188af..c389fab 100644 --- a/api/version1/postseting/postpc/scheme.go +++ b/api/version1/postseting/postpc/scheme.go @@ -155,6 +155,10 @@ func (p *postDimeTarSync) GetPostTargent(position modelshr.Position, classType i //获取相关指标 var postTargetList []modelskpi.PostTarget gormDb := 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) + + jsonposition, _ := json.Marshal(position) + fmt.Printf("获取相关指标%v--------------->%v--------------->%v\n", string(jsonposition), classType, dutyClass) + if classType != 0 { gormDb = gormDb.Where("`type` = ?", classType) } diff --git a/api/version1/postseting/postpc/serpostconfig.go b/api/version1/postseting/postpc/serpostconfig.go index 07c4f6f..356e053 100644 --- a/api/version1/postseting/postpc/serpostconfig.go +++ b/api/version1/postseting/postpc/serpostconfig.go @@ -653,3 +653,595 @@ func (a *ApiMethod) PostConfigListNews(c *gin.Context) { } publicmethod.Result(0, outList, c) } + +// 岗位定量考核目标列表(新版) +func (a *ApiMethod) PeopleConfigList(c *gin.Context) { + var requestData SelectQuantitativeConfig + c.ShouldBindJSON(&requestData) + // if err != nil { + // publicmethod.Result(1, err, c, "数据获取失败!") + // return + // } + // var qualConfigList []assessmentmodel.QuantitativeConfig + var qualConfigList []modelskpi.QuanPeopleConfigTarget + // gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPeopleConfigTarget{}).Distinct("`user_key`,`company_id`,`department_id`,`org_id`,`post_id`,`dimension`,`target`,`title`,`year`,`type`") + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPeopleConfigTarget{}) + if requestData.GroupId != "" { + gormDb = gormDb.Where("`company_id` = ?", requestData.GroupId) + } + if requestData.DepartmentID != "" { + gormDb = gormDb.Where("`org_id` = ?", requestData.DepartmentID) + } + if requestData.PostId != "" { + gormDb = gormDb.Where("`post_id` = ?", requestData.PostId) + } + if requestData.Dimension != "" { + gormDb = gormDb.Where("`dimension` = ?", requestData.Dimension) + } + if requestData.Target != "" { + gormDb = gormDb.Where("`target` = ?", requestData.Target) + } + + if requestData.Year != 0 { + gormDb = gormDb.Where("`year` = ?", requestData.Year) + } + if requestData.State != 0 { + gormDb = gormDb.Where("`state` = ?", requestData.State) + } else { + gormDb = gormDb.Where("`state` = 1") + } + if requestData.Type != 0 { + gormDb = gormDb.Where("`type` = ?", requestData.Type) + } + if requestData.Title != "" { + gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%") + } + if len(requestData.UserKey) > 0 { + gormDb = gormDb.Where("`user_key` IN ?", requestData.UserKey) + } + // gormDb = gormDb.Order("group ASC,departmentid ASC,dimension ASC,target ASC,targetconfig ASC").Order("year DESC").Order("timecopy ASC,id ASC") + gormDb = gormDb.Order("`user_key` ASC").Order("`company_id` ASC").Order("`department_id` ASC").Order("`org_id` ASC").Order("`post_id` ASC").Order("`dimension` ASC").Order("`target` ASC").Order("`year` DESC") + contErr := gormDb.Find(&qualConfigList).Error + if contErr != nil { + publicmethod.Result(1, contErr, c, "没有数据!") + return + } + var outList []OutQuanPeopleConfig + for _, v := range qualConfigList { + var outCont OutQuanPeopleConfig + outCont.Id = v.Id + outCont.Title = v.Title + outCont.CompanyId = v.CompanyId + outCont.DepartmentId = v.DepartmentId + outCont.OrgId = v.OrgId + outCont.PostId = v.PostId + + outCont.Dimension = v.Dimension + outCont.Target = v.Target + + outCont.Type = v.Type + outCont.Year = v.Year + outCont.Timecopy = v.Timecopy + outCont.Zeroprize = v.Zeroprize / 100 + outCont.Allprize = v.Allprize / 100 + outCont.Capping = v.Capping + outCont.CappingVal = v.CappingVal / 100 + outCont.Time = v.Time + outCont.State = v.State + outCont.DimensionId = strconv.FormatInt(v.Dimension, 10) + + var companyCont modelshr.AdministrativeOrganization + companyCont.GetCont(map[string]interface{}{"`id`": v.CompanyId}, "id", "name") + outCont.GroupTitle = companyCont.Name + + var departmenCont modelshr.AdministrativeOrganization + departmenCont.GetCont(map[string]interface{}{"`id`": v.DepartmentId}, "id", "name") + outCont.DepartmentTitle = departmenCont.Name + + var postCont modelshr.Position + postCont.GetCont(map[string]interface{}{"`id`": v.PostId}, "id", "name") + outCont.PostTitle = postCont.Name + + var dimensionCont modelskpi.DutyClass + dimensionCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "id", "title") + outCont.DimensionTitle = dimensionCont.Title + + outCont.TargetTitle = v.Title + // dErr, departmentInfo := commonus.GetBranchFactory(v.DepartmentId) + // if dErr == true { + // outCont.DimensionTitle = departmentInfo.Name + // } + // targetInfo, tErr := commonus.GetTargetInfo(v.Target) + // if tErr == true { + // outCont.TargetTitle = targetInfo.Title + // } + var manCont modelshr.PersonArchives + manCont.GetCont(map[string]interface{}{"`key`": v.UserKey}) + outCont.UserName = manCont.Name + outCont.MyKey = strconv.FormatInt(v.UserKey, 10) + outList = append(outList, outCont) + } + publicmethod.Result(0, outList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-08 09:10:42 +@ 功能: 人员定量目标设定 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) SetEvaluationObjectivMan(c *gin.Context) { + var requestData SetEvaluationObjectivMan + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(1, err, c, "数据获取失败!") + return + } + if requestData.Year == 0 { + publicmethod.Result(1, err, c, "请填写年度") + return + } + if len(requestData.UserKey) < 1 { + publicmethod.Result(1, err, c, "请选择人员") + return + } + if requestData.DepartMent == "" { + publicmethod.Result(1, err, c, "请选择归属行政组织") + return + } + if requestData.PostId == "" { + publicmethod.Result(1, err, c, "请选择归属岗位") + return + } + if requestData.Dimension == "" { + publicmethod.Result(1, err, c, "请选择归属维度") + return + } + if requestData.Target == "" { + publicmethod.Result(1, err, c, "请选择归属指标") + return + } + switch requestData.Cycle { + case 1: + if len(requestData.CycleAdded) != 1 { + publicmethod.Result(1, err, c, "年度只可填写一条!") + return + } + case 2: + if len(requestData.CycleAdded) > 4 { + publicmethod.Result(1, err, c, "季度最多只可填写四条!") + return + } + if len(requestData.CycleAdded) < 1 { + publicmethod.Result(1, err, c, "季度至少填写一条!") + return + } + case 3: + if len(requestData.CycleAdded) > 12 { + publicmethod.Result(1, err, c, "月度最多只可填写十二条!") + return + } + if len(requestData.CycleAdded) < 1 { + publicmethod.Result(1, err, c, "月度至少填写一条!") + return + } + default: + publicmethod.Result(1, err, c, "请选择周期") + return + } + + orgId, _ := strconv.ParseInt(requestData.DepartMent, 10, 64) + _, companyId, departmentId, _, _ := publicmethod.GetOrgStructure(orgId) //公司部门 + + var timecopy []int64 + + gromDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPeopleConfig{}).Select("timecopy").Where("`group` = ? AND `org_id` = ? AND `post_id` = ? AND `dimension` = ? AND `target` = ? AND `year` = ? AND `user_key` IN ? ", companyId, requestData.DepartMent, requestData.PostId, requestData.Dimension, requestData.Target, requestData.Year, requestData.UserKey) + + judgeErr := gromDb.Find(&timecopy).Error + + if judgeErr == nil { + if len(timecopy) > 0 { + publicmethod.Result(1, judgeErr, c, "选中的人员已经设定目标值!不要重复添加!") + return + } + } + + var saveData []modelskpi.QuanPeopleConfig + var eiteAddData []int64 + for _, v := range requestData.CycleAdded { + if judgeErr != nil { + + var saveDataCont modelskpi.QuanPeopleConfig + for _, uv := range requestData.UserKey { + saveDataCont.CompanyId = companyId + saveDataCont.DepartmentId = departmentId + saveDataCont.OrgId = orgId //行政组织 + postIdInt, _ := strconv.ParseInt(requestData.PostId, 10, 64) + saveDataCont.PostId = postIdInt //岗位 + dimensionId, _ := strconv.ParseInt(requestData.Dimension, 10, 64) + saveDataCont.Dimension = dimensionId //维度 + + targetId, _ := strconv.ParseInt(requestData.Target, 10, 64) + saveDataCont.Target = targetId //指标 + + saveDataCont.Type = int64(requestData.Cycle) + saveDataCont.Year = requestData.Year + saveDataCont.Timecopy = v.Id + if v.Zeroprize < 0 { + saveDataCont.Zeroprize = 0 + } else { + saveDataCont.Zeroprize = v.Zeroprize * 100 + } + if v.Allprize < 0 { + saveDataCont.Allprize = 0 + } else { + saveDataCont.Allprize = v.Allprize * 100 + } + if v.Capping > 0 { + saveDataCont.Capping = 1 + saveDataCont.CappingVal = v.Capping * 100 + } else { + saveDataCont.Capping = 2 + saveDataCont.CappingVal = 0 + } + saveDataCont.Time = time.Now().Unix() + saveDataCont.State = 1 + userKeyInt, _ := strconv.ParseInt(uv, 10, 64) + saveDataCont.UserKey = userKeyInt + saveData = append(saveData, saveDataCont) + } + + } else { + if len(timecopy) <= 0 { + var saveDataCont modelskpi.QuanPeopleConfig + // orgId, _ := strconv.ParseInt(requestData.DepartMent, 10, 64) + // _, saveDataCont.CompanyId, saveDataCont.DepartmentId, _, _ = publicmethod.GetOrgStructure(orgId) //公司部门 + for _, uv := range requestData.UserKey { + saveDataCont.CompanyId = companyId + saveDataCont.DepartmentId = departmentId + saveDataCont.OrgId = orgId //行政组织 + postIdInt, _ := strconv.ParseInt(requestData.PostId, 10, 64) + saveDataCont.PostId = postIdInt //岗位 + dimensionId, _ := strconv.ParseInt(requestData.Dimension, 10, 64) + saveDataCont.Dimension = dimensionId //维度 + + targetId, _ := strconv.ParseInt(requestData.Target, 10, 64) + saveDataCont.Target = targetId //指标 + + saveDataCont.Type = int64(requestData.Cycle) + saveDataCont.Year = requestData.Year + saveDataCont.Timecopy = v.Id + if v.Zeroprize < 0 { + saveDataCont.Zeroprize = 0 + } else { + saveDataCont.Zeroprize = v.Zeroprize * 100 + } + if v.Allprize < 0 { + saveDataCont.Allprize = 0 + } else { + saveDataCont.Allprize = v.Allprize * 100 + } + if v.Capping > 0 { + saveDataCont.Capping = 1 + saveDataCont.CappingVal = v.Capping * 100 + } else { + saveDataCont.Capping = 2 + saveDataCont.CappingVal = 0 + } + saveDataCont.Time = time.Now().Unix() + saveDataCont.State = 1 + userKeyInt, _ := strconv.ParseInt(uv, 10, 64) + saveDataCont.UserKey = userKeyInt + saveData = append(saveData, saveDataCont) + } + } else { + for _, s_v := range timecopy { + if s_v != v.Id { + var saveDataCont modelskpi.QuanPeopleConfig + for _, uv := range requestData.UserKey { + saveDataCont.CompanyId = companyId + saveDataCont.DepartmentId = departmentId + saveDataCont.OrgId = orgId //行政组织 + postIdInt, _ := strconv.ParseInt(requestData.PostId, 10, 64) + saveDataCont.PostId = postIdInt //岗位 + dimensionId, _ := strconv.ParseInt(requestData.Dimension, 10, 64) + saveDataCont.Dimension = dimensionId //维度 + + targetId, _ := strconv.ParseInt(requestData.Target, 10, 64) + saveDataCont.Target = targetId //指标 + + saveDataCont.Type = int64(requestData.Cycle) + saveDataCont.Year = requestData.Year + saveDataCont.Timecopy = v.Id + if v.Zeroprize < 0 { + saveDataCont.Zeroprize = 0 + } else { + saveDataCont.Zeroprize = v.Zeroprize * 100 + } + if v.Allprize < 0 { + saveDataCont.Allprize = 0 + } else { + saveDataCont.Allprize = v.Allprize * 100 + } + if v.Capping > 0 { + saveDataCont.Capping = 1 + saveDataCont.CappingVal = v.Capping * 100 + } else { + saveDataCont.Capping = 2 + saveDataCont.CappingVal = 0 + } + saveDataCont.Time = time.Now().Unix() + saveDataCont.State = 1 + userKeyInt, _ := strconv.ParseInt(uv, 10, 64) + saveDataCont.UserKey = userKeyInt + saveData = append(saveData, saveDataCont) + } + } else { + eiteDataMap := publicmethod.MapOut[string]() + eiteDataMap["type"] = requestData.Cycle + eiteDataMap["timecopy"] = v.Id + if v.Zeroprize < 0 { + eiteDataMap["zeroprize"] = 0 + } else { + + eiteDataMap["zeroprize"] = v.Zeroprize * 100 + } + if v.Allprize < 0 { + eiteDataMap["allprize"] = 0 + } else { + + eiteDataMap["allprize"] = v.Allprize * 100 + } + if v.Capping > 0 { + + eiteDataMap["capping"] = 1 + eiteDataMap["capping_val"] = v.Capping * 100 + } else { + eiteDataMap["capping"] = 2 + eiteDataMap["capping_val"] = 0 + } + eiteDataMap["time"] = time.Now().Unix() + + for _, uv := range requestData.UserKey { + gromDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPostConfig{}).Select("Timecopy").Where("`company_id` = ? AND `org_id` = ? AND `post_id` = ? AND `dimension` = ? AND `target` = ? AND `year` = ? AND `type` = ? AND `user_key`", companyId, requestData.DepartMent, requestData.PostId, requestData.Dimension, requestData.Target, requestData.Year, requestData.Cycle, uv) + gromDb.Updates(eiteDataMap) + eiteAddData = append(eiteAddData, 1) + } + + } + } + } + } + } + if len(saveData) <= 0 && len(eiteAddData) <= 0 { + publicmethod.Result(1, err, c, "没有要添加的数据!") + return + } + if len(saveData) > 0 { + saveErr := overall.CONSTANT_DB_KPI.Create(&saveData).Error + if saveErr != nil { + publicmethod.Result(1, err, c, "数据添加失败!") + return + } + } + publicmethod.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-08 10:29:57 +@ 功能: +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) LookPeopleConfig(c *gin.Context) { + var requestData SelectQuantitativeConfigMan + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(1, err, c, "数据获取失败!") + return + } + // var qualConfigList []assessmentmodel.QuantitativeConfig + var qualConfigList []modelskpi.QuanPeopleConfigTarget + gormDb := overall.CONSTANT_DB_KPI + if requestData.GroupId != "" { + gormDb = gormDb.Where("`company_id` = ?", requestData.GroupId) + } + if requestData.DepartmentID != "" { + gormDb = gormDb.Where("`department_id` = ?", requestData.DepartmentID) + } + if requestData.OrgID != "" { + gormDb = gormDb.Where("`org_id` = ?", requestData.OrgID) + } + if requestData.PostId != "" { + gormDb = gormDb.Where("`post_id` = ?", requestData.PostId) + } + if requestData.Dimension != "" { + gormDb = gormDb.Where("`dimension` = ?", requestData.Dimension) + } + if requestData.Target != "" { + gormDb = gormDb.Where("`target` = ?", requestData.Target) + } + + switch requestData.Type { + case 1: + gormDb = gormDb.Where("`type` = ?", requestData.Type) + case 2: + gormDb = gormDb.Where("`type` = ?", requestData.Type) + if requestData.Class != 0 { + gormDb = gormDb.Where("`timecopy` = ?", requestData.Class) + } + case 3: + gormDb = gormDb.Where("`type` = ?", requestData.Type) + if requestData.Class != 0 { + gormDb = gormDb.Where("`timecopy` = ?", requestData.Class) + } + default: + } + if requestData.Year != 0 { + gormDb = gormDb.Where("`year` = ?", requestData.Year) + } + if requestData.State != 0 { + gormDb = gormDb.Where("`state` = ?", requestData.State) + } + if requestData.UserKey != "" { + gormDb = gormDb.Where("`user_key` = ?", requestData.UserKey) + } + if requestData.Title != "" { + gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%") + } + // gormDb = gormDb.Order("group ASC,departmentid ASC,dimension ASC,target ASC,targetconfig ASC").Order("year DESC").Order("timecopy ASC,id ASC") + gormDb = gormDb.Order("`company_id` ASC").Order("`department_id` ASC").Order("`org_id` ASC").Order("`dimension` ASC").Order("`target` ASC").Order("`year` DESC").Order("`timecopy` ASC").Order("`id` ASC") + contErr := gormDb.Find(&qualConfigList).Error + if contErr != nil { + publicmethod.Result(1, err, c, "没有数据!") + return + } + var outList []OutQuanPeopleConfig + for _, v := range qualConfigList { + var outCont OutQuanPeopleConfig + outCont.Id = v.Id + outCont.IdStr = strconv.FormatInt(v.Id, 10) + outCont.DepartmentId = v.DepartmentId + outCont.CompanyId = v.CompanyId + outCont.Dimension = v.Dimension + outCont.PostId = v.PostId + outCont.Target = v.Target + outCont.Type = v.Type + outCont.Year = v.Year + outCont.Timecopy = v.Timecopy + outCont.Zeroprize = v.Zeroprize / 100 + outCont.Allprize = v.Allprize / 100 + outCont.Time = v.Time + outCont.State = v.State + outCont.DimensionId = strconv.FormatInt(v.Dimension, 10) + + var companyCont modelshr.AdministrativeOrganization + companyCont.GetCont(map[string]interface{}{"`id`": v.CompanyId}, "id", "name") + outCont.GroupTitle = companyCont.Name + + var departmenCont modelshr.AdministrativeOrganization + departmenCont.GetCont(map[string]interface{}{"`id`": v.DepartmentId}, "id", "name") + outCont.DepartmentTitle = departmenCont.Name + + var postCont modelshr.Position + postCont.GetCont(map[string]interface{}{"`id`": v.PostId}, "id", "name") + outCont.PostTitle = postCont.Name + + var dimensionCont modelskpi.DutyClass + dimensionCont.GetCont(map[string]interface{}{"`id`": v.Dimension}, "id", "title") + outCont.DimensionTitle = dimensionCont.Title + + outCont.TargetTitle = v.Title + + outCont.Capping = v.Capping + outCont.CappingVal = v.CappingVal / 100 + + var manCont modelshr.PersonArchives + manCont.GetCont(map[string]interface{}{"`key`": v.UserKey}) + outCont.UserName = manCont.Name + outCont.MyKey = strconv.FormatInt(v.UserKey, 10) + + outList = append(outList, outCont) + } + publicmethod.Result(0, outList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-08 10:44:38 +@ 功能: 修改人员考核目标设置 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) EiteQuantitativeManConfig(c *gin.Context) { + var requestData []EiteQuantConfig + err := c.ShouldBindJSON(&requestData) + if err != nil { + publicmethod.Result(1, err, c, "数据获取失败!") + return + } + if len(requestData) < 1 { + publicmethod.Result(1, err, c, "数据获取失败!") + return + } + for _, v := range requestData { + eiteCont := publicmethod.MapOut[string]() + eiteCont["allprize"] = v.Allprize * 100 + eiteCont["zeroprize"] = v.Zeroprize * 100 + eiteCont["capping_val"] = v.Capping * 100 + err = overall.CONSTANT_DB_KPI.Model(&modelskpi.QuanPeopleConfig{}).Where("`id` = ?", v.Id).Updates(eiteCont).Error + } + if err != nil { + publicmethod.Result(104, err, c) + } else { + publicmethod.Result(0, err, c) + } +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-08 10:48:54 +@ 功能: 删除人员考核项目 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) NewDelQuantitativeManConfig(c *gin.Context) { + var receivedValue newDelTargetManConfig + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.OrgID == "" || receivedValue.PostId == "" || receivedValue.Dimension == "" || receivedValue.Target == "" || receivedValue.Type == 0 || receivedValue.Year == 0 || receivedValue.UserKey == "" { + publicmethod.Result(101, receivedValue, c, "数据获取失败!") + return + } + err = overall.CONSTANT_DB_KPI.Where("`org_id` = ? AND `post_id` = ? AND `dimension` = ? AND `target` = ? AND `type` = ? AND `year` = ? AND `user_key` = ?", receivedValue.OrgID, receivedValue.PostId, receivedValue.Dimension, receivedValue.Target, receivedValue.Type, receivedValue.Year, receivedValue.UserKey).Delete(&modelskpi.QuanPostConfig{}).Error + if err != nil { + publicmethod.Result(108, err, c) + } else { + publicmethod.Result(0, err, c) + } +} diff --git a/api/version1/postseting/postpc/teshutype.go b/api/version1/postseting/postpc/teshutype.go new file mode 100644 index 0000000..103d02f --- /dev/null +++ b/api/version1/postseting/postpc/teshutype.go @@ -0,0 +1,32 @@ +package postpc + +import "key_performance_indicators/overall/publicmethod" + +//搜索行政组织岗位 +type SearchOrgPost struct { + OrgId string `json:"orgid"` + publicmethod.PublicName +} + +//输出行政组织岗位 +type SendSearPost struct { + OrgId []int64 `json:"orgid"` //行政组织ID + PostId int64 `json:"postid"` //岗位ID + PostList []PostListCont `json:"postlist"` +} + +type PostListCont struct { + Id int64 `json:"id"` + Name string `json:"name"` +} + +//部门与岗位和提报人关系 +type OrgPostPeople struct { + OrgId int64 `json:"orgid"` + PostPeople []PostPeopleList `json:"postpeople"` +} + +type PostPeopleList struct { + PostId int64 `json:"postid"` + PeopleList []string `json:"peoplelist"` +} diff --git a/api/version1/postseting/postpc/teshuxuqiu.go b/api/version1/postseting/postpc/teshuxuqiu.go new file mode 100644 index 0000000..a4b1156 --- /dev/null +++ b/api/version1/postseting/postpc/teshuxuqiu.go @@ -0,0 +1,370 @@ +package postpc + +import ( + "fmt" + "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" +) + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-12 15:21:20 +@ 功能: 搜索行政组织岗位列表 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) SearchOrgPostList(c *gin.Context) { + var receivedValue SearchOrgPost + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.Name == "" { + publicmethod.Result(1, err, c, "请输入要查询得岗位名称!") + return + } + var companyId int64 = 0 + if receivedValue.OrgId != "" { + orgIdInt, _ := strconv.ParseInt(receivedValue.OrgId, 10, 64) + _, companyId, _, _, _ = publicmethod.GetOrgStructure(orgIdInt) + } + var postList []modelshr.Position + err = overall.CONSTANT_DB_HR.Where("`state` = 1 AND `name` LIKE ?", "%"+receivedValue.Name+"%").Find(&postList).Error + if err != nil { + publicmethod.Result(1, err, c, "没有相关岗位!") + return + } + var sendList []SendSearPost + for _, v := range postList { + _, companyIdPost, minDer, sunDer, workId := publicmethod.GetOrgStructure(v.AdministrativeOrganization) + var orgAry []int64 + // if companyIdPost != 0 && publicmethod.IsInTrue[int64](companyIdPost, orgAry) == false { + // orgAry = append(orgAry, companyIdPost) + // } + if minDer != 0 && publicmethod.IsInTrue[int64](minDer, orgAry) == false { + orgAry = append(orgAry, minDer) + } + if sunDer != 0 && publicmethod.IsInTrue[int64](sunDer, orgAry) == false { + orgAry = append(orgAry, sunDer) + } + if workId != 0 && publicmethod.IsInTrue[int64](workId, orgAry) == false { + orgAry = append(orgAry, workId) + } + if v.AdministrativeOrganization != 0 && publicmethod.IsInTrue[int64](v.AdministrativeOrganization, orgAry) == false { + orgAry = append(orgAry, v.AdministrativeOrganization) + } + if companyId != 0 { + + if companyIdPost == companyId { + var sendCont SendSearPost + sendCont.OrgId = orgAry + sendCont.PostId = v.Id + sendCont.PostList = GetWithOrgList(v.AdministrativeOrganization) + sendList = append(sendList, sendCont) + } + } else { + var sendCont SendSearPost + sendCont.OrgId = orgAry + sendCont.PostId = v.Id + sendCont.PostList = GetWithOrgList(v.AdministrativeOrganization) + sendList = append(sendList, sendCont) + } + + } + // fmt.Printf("总数--->%v\n", len(sendList)) + publicmethod.Result(0, sendList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-12 15:21:30 +@ 功能: 获取同行政组织岗位 +@ 参数 + + #orgId 行政组织ID + +@ 返回值 + + #postList 岗位列表 + +@ 方法原型 + + #func GetWithOrgList(orgId int64) (postList []PostListCont) +*/ +func GetWithOrgList(orgId int64) (postList []PostListCont) { + var postListCont []modelshr.Position + err := overall.CONSTANT_DB_HR.Model(&modelshr.Position{}).Select("`id`,`name`").Where("`state` = 1 AND `administrative_organization` = ?", orgId).Find(&postListCont).Error + if err != nil { + return + } + for _, v := range postListCont { + var postCont PostListCont + postCont.Id = v.Id + postCont.Name = v.Name + postList = append(postList, postCont) + } + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-13 10:44:16 +@ 功能: 获取行政组织级联数组 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) GetOrgAry(c *gin.Context) { + var receivedValue publicmethod.PublicId + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.Id == "" { + publicmethod.Result(1, err, c, "参数错误!") + return + } + idInt, _ := strconv.ParseInt(receivedValue.Id, 10, 64) + _, _, minDer, sunDer, workId := publicmethod.GetOrgStructure(idInt) + var orgAry []int64 + if minDer != 0 && publicmethod.IsInTrue[int64](minDer, orgAry) == false { + orgAry = append(orgAry, minDer) + } + if sunDer != 0 && publicmethod.IsInTrue[int64](sunDer, orgAry) == false { + orgAry = append(orgAry, sunDer) + } + if workId != 0 && publicmethod.IsInTrue[int64](workId, orgAry) == false { + orgAry = append(orgAry, workId) + } + if idInt != 0 && publicmethod.IsInTrue[int64](idInt, orgAry) == false { + orgAry = append(orgAry, idInt) + } + publicmethod.Result(0, orgAry, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-13 11:00:48 +@ 功能: 添加岗位指标 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiMethod) NewAddPostTarget(c *gin.Context) { + var receivedValue addPostTarget + c.ShouldBindJSON(&receivedValue) + if receivedValue.Title == "" { + publicmethod.Result(1, receivedValue, c, "请输入指标名称!") + return + } + if receivedValue.Type == 0 { + receivedValue.Type = 2 + } + if receivedValue.ScoringMethod == 0 { + receivedValue.ScoringMethod = 1 + } + // if receivedValue.RelevantDepartments == "" { + // publicmethod.Result(1, receivedValue, c, "请选择该指标归属部门!") + // return + // } + if len(receivedValue.OtherPostTarget) < 1 { + publicmethod.Result(1, receivedValue, c, "请选择该指标归属岗位!") + return + } + if receivedValue.Dimension == "" { + publicmethod.Result(1, receivedValue, c, "请选择指标归属维度!") + return + } + if receivedValue.Unit == "" { + publicmethod.Result(1, receivedValue, c, "请输入该指标计算单位!") + return + } + if receivedValue.Cycle == 0 { + receivedValue.Cycle = 1 + } + if receivedValue.CycleAttr == 0 { + receivedValue.CycleAttr = 1 + } + + orgPostManList := HandlingRelations(receivedValue.OtherPostTarget) + if len(orgPostManList) < 1 { + publicmethod.Result(1, receivedValue, c, "请选择该指标归属岗位!") + return + } + + for _, v := range orgPostManList { + var saveData modelskpi.PostTarget + saveData.Title = receivedValue.Title //标题"` + saveData.Type = receivedValue.Type //1:定性考核;2:定量考核"` + saveData.State = 1 //状态(1:启用;2:禁用;3:删除)"` + saveData.Time = time.Now().Unix() //创建时间"` + saveData.Share = 2 //1:共用;2:私用"` + dimensionId, _ := strconv.ParseInt(receivedValue.Dimension, 10, 64) + saveData.Dimension = dimensionId //维度"` + saveData.Key = publicmethod.GetUUid(1) //UUID"` + saveData.Unit = receivedValue.Unit //单位"` + saveData.Cycle = receivedValue.Cycle //1:班;2:天;3:周;4:月;5:季度;6:年"` + saveData.Cycleattr = receivedValue.CycleAttr //辅助计数"` + saveData.ScoringMethod = receivedValue.ScoringMethod //计分方式(1:自动;2:手动)"` + saveData.VisibleRange = strings.Join(receivedValue.VisibleRange, ",") //可见范围"` + saveData.VisibleGroup = strings.Join(receivedValue.VisibleGroup, ",") //可见范围(集团)"` + saveData.ReleDepart = v.OrgId //相关部门"` + var postList []string + var manList []string + for _, vp := range v.PostPeople { + postId := strconv.FormatInt(vp.PostId, 10) + if publicmethod.IsInTrue[string](postId, postList) == false { + postList = append(postList, postId) + } + for _, vm := range vp.PeopleList { + if publicmethod.IsInTrue[string](vm, manList) == false { + manList = append(manList, vm) + } + } + + } + saveData.DepartmentsPost = strings.Join(postList, ",") //相关岗位"` + saveData.Report = strings.Join(manList, ",") //上报人"` + overall.CONSTANT_DB_KPI.Create(&saveData) + for _, vps := range v.PostPeople { + syncSetinges.Add(1) + go DepartAboutPostTargetReport(dimensionId, saveData.Id, 0, 0, v.OrgId, vps.PostId, vps.PeopleList, 2, receivedValue.Type) + } + //关联部门岗位 + if len(postList) > 0 { + syncSetinges.Add(1) + go EditTargetTableDimenAboutPostOfDepart(dimensionId, saveData.Id, 0, 0, v.OrgId, postList, 2, receivedValue.Type) + } + + } + syncSetinges.Wait() + publicmethod.Result(0, orgPostManList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-13 13:40:21 +@ 功能: 判断岗位指标是否存在 +@ 参数 + + #targetTitle 指标名称 + #Attribute 1:定性考核;2:定量考核 + #dimId 维度Key + #departId 部门ID + #postId 岗位ID + +@ 返回值 + + #targetCont 岗位指标 + #err 状态 + +@ 方法原型 + + #JudgePostTargetIsTrue(targetTitle string, Attribute int, dimId, departId, postId int64) (targetCont modelskpi.PostTarget, err error) +*/ +func JudgePostTargetIsTrue(targetTitle string, Attribute int, dimId, departId, postId int64) (targetCont modelskpi.PostTarget, err error) { + err = overall.CONSTANT_DB_KPI.Model(targetCont).Select("`id`").Where("`rele_depart` = ? AND `dimension` = ? AND `type` = ? AND `title` = ? AND FIND_IN_SET(?,`departments_post`)", departId, dimId, Attribute, targetTitle, postId).First(&targetCont).Error + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-13 11:10:25 +@ 功能: 处理行政组织与岗位和相关提报人关系 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func HandlingRelations(orgPostPeo []OtherPostTargetCont) (orgHandPost []OrgPostPeople) { + fmt.Printf("orgPostPeo---->%v\n", orgPostPeo) + if len(orgPostPeo) < 1 { + return + } + for _, ov := range orgPostPeo { //循环提交得行政组织与岗位和提报人 + isInAry := false + for hi, hv := range orgHandPost { //循环已经处理得数据 + if ov.OrgId == hv.OrgId { //判断此行政组织是否已经存在 + isInAry = true + for hvpi, hvp := range hv.PostPeople { //循环已经处理后的岗位及提报人 + if hvp.PostId == ov.PostId { //判断岗位数据是否已经处理过类是得岗位 + var manList []string + for _, hvpm := range hvp.PeopleList { //已经添加了的岗位提报人 + manList = append(manList, hvpm) + } + for _, ovm := range ov.Operator { + if publicmethod.IsInTrue[string](ovm, manList) == false { + manList = append(manList, ovm) + } + } //新提报人 + + orgHandPost[hi].PostPeople[hvpi].PeopleList = manList + } else { //此行政组织为处理过相关岗位则新增 + var postAndMan PostPeopleList + postAndMan.PostId = ov.PostId + postAndMan.PeopleList = ov.Operator + orgHandPost[hi].PostPeople = append(orgHandPost[hi].PostPeople, postAndMan) + } + } + } + } + //次行政组织不存在,执行新增操作 + if isInAry == false { + var orgHandPostCont OrgPostPeople + orgHandPostCont.OrgId = ov.OrgId + var postAndMan PostPeopleList + postAndMan.PostId = ov.PostId + postAndMan.PeopleList = ov.Operator + orgHandPostCont.PostPeople = append(orgHandPostCont.PostPeople, postAndMan) + orgHandPost = append(orgHandPost, orgHandPostCont) + } + } + return +} diff --git a/api/version1/postseting/postpc/type.go b/api/version1/postseting/postpc/type.go index 6fb597d..611eaf6 100644 --- a/api/version1/postseting/postpc/type.go +++ b/api/version1/postseting/postpc/type.go @@ -172,17 +172,24 @@ type postPeople struct { // 添加岗位指标 type addPostTarget struct { - Title string `json:"title"` //名称 - Type int `json:"type"` //1:定性考核;2:定量考核 - ScoringMethod int `json:"scoringMethod"` //计分方式(1:自动;2:手动) - RelevantDepartments string `json:"relevantDepartments"` //相关部门 - Dimension string `json:"dimension"` //维度 - Unit string `json:"unit"` //单位 - Cycle int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年 - CycleAttr int `json:"cycleattr"` //辅助计数 - VisibleRange []string `json:"visibleRange"` //可见范围 - VisibleGroup []string `json:"visibleGroup"` //可见范围(集团) - RelevantPostsMan []postPeople `json:"relevantpostsman"` //相关岗位与提报人 + Title string `json:"title"` //名称 + Type int `json:"type"` //1:定性考核;2:定量考核 + ScoringMethod int `json:"scoringMethod"` //计分方式(1:自动;2:手动) + RelevantDepartments string `json:"relevantDepartments"` //相关部门 + Dimension string `json:"dimension"` //维度 + Unit string `json:"unit"` //单位 + Cycle int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年 + CycleAttr int `json:"cycleattr"` //辅助计数 + VisibleRange []string `json:"visibleRange"` //可见范围 + VisibleGroup []string `json:"visibleGroup"` //可见范围(集团) + RelevantPostsMan []postPeople `json:"relevantpostsman"` //相关岗位与提报人 + OtherPostTarget []OtherPostTargetCont `json:"otherposttarget"` //其他部门相关岗位提报 +} + +type OtherPostTargetCont struct { + OrgId int64 `json:"orgid"` //行政组织Id + PostId int64 `json:"postid"` //岗位Id + Operator []string `json:"operator"` //考核执行人 } // 编辑岗位指标 @@ -304,17 +311,18 @@ type CycleAddedType struct { // 定量考核目标设定查询 type SelectQuantitativeConfig struct { - Title string `json:"title"` //指标标题 - GroupId string `json:"groupid"` - DepartmentID string `json:"departmentid"` - OrgID string `json:"orgid"` //行政组织 - PostId string `json:"postid"` //岗位 - Dimension string `json:"dimension"` //维度 - Target string `json:"target"` //指标 - Type int `json:"type"` //1、年度;2、季度;3、月度 - Year int `json:"year"` //年度 - Class int `json:"class"` //季度与月度辅助值 - State int `json:"state"` //状态(1、启用;2、禁用;3、删除) + Title string `json:"title"` //指标标题 + GroupId string `json:"groupid"` + DepartmentID string `json:"departmentid"` + OrgID string `json:"orgid"` //行政组织 + PostId string `json:"postid"` //岗位 + Dimension string `json:"dimension"` //维度 + Target string `json:"target"` //指标 + Type int `json:"type"` //1、年度;2、季度;3、月度 + Year int `json:"year"` //年度 + Class int `json:"class"` //季度与月度辅助值 + State int `json:"state"` //状态(1、启用;2、禁用;3、删除) + UserKey []string `json:"userkey"` //人员 } // 输出 @@ -358,3 +366,56 @@ type newDelTargetConfig struct { Type int `json:"type"` //1、年度;2、季度;3、月度 Year int `json:"year"` //年度 } + +type OutQuanPeopleConfig struct { + modelskpi.QuanPeopleConfigTarget + GroupTitle string `json:"grouptitle"` //公司 + DepartmentTitle string `json:"departmenttitle"` //部门 + PostTitle string `json:"posttitle"` //岗位 + DimensionTitle string `json:"dimensiontitle"` //维度 + DimensionId string `json:"dimensionid"` //维度 + TargetTitle string `json:"targettitle"` //指标 + DetailedTargetTitle string `json:"detailedtargenttitle"` //指标明细 + IdStr string `json:"idstr"` //字符型Id + UserName string `json:"username"` //姓名 + MyKey string `json:"mykey"` // +} + +// 设定人员指标结算周期 +type SetEvaluationObjectivMan struct { + UserKey []string `json:"userkey"` //人员key列表 + Year int64 `json:"year"` //年度 + // Group string `json:"group"` //集团 + DepartMent string `json:"department"` //部门 + PostId string `json:"postid"` + Dimension string `json:"dimension"` //维度 + Target string `json:"target"` //指标 + Cycle int `json:"cycle"` //周期 + CycleAdded []CycleAddedType `json:"cycleadded"` +} + +type SelectQuantitativeConfigMan struct { + Title string `json:"title"` //指标标题 + GroupId string `json:"groupid"` + DepartmentID string `json:"departmentid"` + OrgID string `json:"orgid"` //行政组织 + PostId string `json:"postid"` //岗位 + Dimension string `json:"dimension"` //维度 + Target string `json:"target"` //指标 + Type int `json:"type"` //1、年度;2、季度;3、月度 + Year int `json:"year"` //年度 + Class int `json:"class"` //季度与月度辅助值 + State int `json:"state"` //状态(1、启用;2、禁用;3、删除) + UserKey string `json:"userkey"` //人员 +} + +// 删除人员指标设定的目标值 +type newDelTargetManConfig struct { + OrgID string `json:"orgid"` //行政组织 + PostId string `json:"postid"` //岗位 + Dimension string `json:"dimension"` //维度 + Target string `json:"target"` //指标 + Type int `json:"type"` //1、年度;2、季度;3、月度 + Year int `json:"year"` //年度 + UserKey string `json:"userkey"` //人员 +} diff --git a/api/version1/postseting/postweb/appflowlog.go b/api/version1/postseting/postweb/appflowlog.go index 0726682..6035c67 100644 --- a/api/version1/postseting/postweb/appflowlog.go +++ b/api/version1/postseting/postweb/appflowlog.go @@ -52,6 +52,23 @@ func (a *ApiMethod) GetPostFlowLog(c *gin.Context) { startTime, endTime := publicmethod.GetAppointMonthStarAndEndTime(receivedValue.DayTime) gormDb = gormDb.Where("`start_time` BETWEEN ? AND ?", startTime, endTime) } + + if receivedValue.Years != 0 { + if receivedValue.Month != 0 { + timeDay := fmt.Sprintf("%v-%v-01", receivedValue.Years, receivedValue.Month) + if receivedValue.Month <= 9 { + timeDay = fmt.Sprintf("%v-0%v-01", receivedValue.Years, receivedValue.Month) + } + startTime, endTime := publicmethod.GetAppointMonthStarAndEndTimeEs(timeDay) + gormDb = gormDb.Where("start_time BETWEEN ? AND ?", startTime, endTime) + + } else { + startTime, _ := publicmethod.DateToTimeStamp(fmt.Sprintf("%v-01-01 00:00:00", receivedValue.Years)) + endTime, _ := publicmethod.DateToTimeStamp(fmt.Sprintf("%v-12-31 23:59:59", receivedValue.Years)) + gormDb = gormDb.Where("start_time BETWEEN ? AND ?", startTime, endTime) + } + } + if receivedValue.State != 0 { gormDb = gormDb.Where("`state` = ?", receivedValue.State) } else { diff --git a/api/version1/postseting/postweb/type.go b/api/version1/postseting/postweb/type.go index 2824364..031f713 100644 --- a/api/version1/postseting/postweb/type.go +++ b/api/version1/postseting/postweb/type.go @@ -243,6 +243,8 @@ type postFlowLog struct { DayTime string `json:"daytime"` //时间 State int `json:"state"` //状态:0:全部;1:起草;2:审批中;3:通过;4:驳回 ApprovalState int `json:"approvalstate" ` //审批:0:全部;1:已处理;2:未处理 + Years int `json:"years"` //年 + Month int `json:"month"` //月 } // 输出岗位审批记录表 diff --git a/apirouter/apishiyan/maptostruct.go b/apirouter/apishiyan/maptostruct.go index 1fe9274..f85371d 100644 --- a/apirouter/apishiyan/maptostruct.go +++ b/apirouter/apishiyan/maptostruct.go @@ -22,5 +22,9 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter.POST("cang_chu_three", methodBinding.CangChuThree) //实验仓储数据读取 apiRouter.GET("cang_chu_three", methodBinding.CangChuThree) //实验仓储数据读取 + + apiRouter.GET("evalproctime", methodBinding.EvalProcTime) //审批流规制发生时间 + apiRouter.POST("evalproctime", methodBinding.EvalProcTime) //审批流规制发生时间 + } } diff --git a/apirouter/v1/postseting/pc.go b/apirouter/v1/postseting/pc.go index 847e11a..b0cb8c0 100644 --- a/apirouter/v1/postseting/pc.go +++ b/apirouter/v1/postseting/pc.go @@ -31,6 +31,12 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("new_del_quantitative_config", methodBinding.NewDelQuantitativeConfig) //删除考核目标设置(新版) + apiRouter.POST("post_people_list", methodBinding.PeopleConfigList) //个人定量考核目标列表 + apiRouter.POST("set_eval_object_man", methodBinding.SetEvaluationObjectivMan) //人员定量目标设定 + apiRouter.POST("lookpeopleconfig", methodBinding.LookPeopleConfig) // 查看人员定量考核目标设定 + apiRouter.POST("eite_quant_man_config", methodBinding.EiteQuantitativeManConfig) //修改人员考核目标设置 + apiRouter.POST("new_del_quantman_config", methodBinding.NewDelQuantitativeManConfig) //删除人员考核目标设置(新版) + /* 岗位定性指标 */ @@ -57,5 +63,12 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("editdeatilscont", methodBinding.EditDeatilsCont) //编辑定性指标细则内容 apiRouter.POST("getdetailscont", methodBinding.GetDetailsCont) //获取指标细则内容 + /* + 针对岗位指标特殊要求API + */ + apiRouter.POST("search_orgpost_list", methodBinding.SearchOrgPostList) //搜索岗位列表 + apiRouter.POST("get_orgary", methodBinding.GetOrgAry) //获取行政组织级联数组 + apiRouter.POST("new_add_posttarget", methodBinding.NewAddPostTarget) //添加岗位指标(新) + } } diff --git a/models/modelskpi/evaluation_process.go b/models/modelskpi/evaluation_process.go index 31c026c..8cc624c 100644 --- a/models/modelskpi/evaluation_process.go +++ b/models/modelskpi/evaluation_process.go @@ -25,6 +25,7 @@ type EvaluationProcess struct { Target string `json:"target" gorm:"column:ep_target;type:mediumtext;comment:指标"` DetailedTarget string `json:"detailedtarget" gorm:"column:ep_detailedtarget;type:mediumtext;comment:指标细则"` AcceptDepartment int64 `json:"acceptdepartment" gorm:"column:ep_accept_department;type:bigint(20) unsigned;default:0;not null;comment:接受考核部门"` + HappenTime int64 `json:"happentime" gorm:"column:ep_happen_time;type:bigint(20) unsigned;default:0;not null;comment:发生时间"` } func (EvaluationProcess *EvaluationProcess) TableName() string { diff --git a/models/modelskpi/quan_people_config.go b/models/modelskpi/quan_people_config.go new file mode 100644 index 0000000..11d77ad --- /dev/null +++ b/models/modelskpi/quan_people_config.go @@ -0,0 +1,73 @@ +package modelskpi + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 岗位定量考核目标设定 +type QuanPeopleConfig struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + UserKey int64 `json:"userkey" gorm:"column:user_key;type:bigint(20) unsigned;default:0;not null;comment:人员key"` + 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:部门ID"` + 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:岗位"` + 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:指标"` + Detailed int64 `json:"detailed" gorm:"column:detailed;type:bigint(20) unsigned;default:0;not null;comment:指标细则"` + Type int64 `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:0;not null;comment:1、年度;2、季度;3、月度"` + Year int64 `json:"year" gorm:"column:year;type:bigint(20) unsigned;default:0;not null;comment:年度"` + Timecopy int64 `json:"timecopy" gorm:"column:timecopy;type:int(3) unsigned;default:0;not null;comment:季度与月度辅助值"` + Zeroprize float64 `json:"zeroprize" gorm:"column:zeroprize;type:int(7) unsigned;default:0;not null;comment:零奖值"` + Allprize float64 `json:"allprize" gorm:"column:allprize;type:int(7) unsigned;default:0;not null;comment:全奖值"` + Capping int `json:"capping" gorm:"column:capping;type:int(1) unsigned;default:2;not null;comment:是否封顶(1、是;2:否)"` + CappingVal float64 `json:"cappingval" gorm:"column:capping_val;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:删除)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` +} + +func (QuanPeopleConfig *QuanPeopleConfig) TableName() string { + return "quan_people_config" +} + +// 编辑内容 +func (cont *QuanPeopleConfig) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *QuanPeopleConfig) 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 *QuanPeopleConfig) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *QuanPeopleConfig) ContMap(whereMap interface{}, field ...string) (countAry []QuanPeopleConfig, 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 *QuanPeopleConfig) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/modelskpi/quan_people_config_target.go b/models/modelskpi/quan_people_config_target.go new file mode 100644 index 0000000..776b7f5 --- /dev/null +++ b/models/modelskpi/quan_people_config_target.go @@ -0,0 +1,76 @@ +package modelskpi + +// + +import ( + "key_performance_indicators/overall" + "strings" +) + +// 岗位定量考核目标设定 +type QuanPeopleConfigTarget 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:标题"` + UserKey int64 `json:"userkey" gorm:"column:user_key;type:bigint(20) unsigned;default:0;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:部门ID"` + 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:岗位"` + 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:指标"` + Detailed int64 `json:"detailed" gorm:"column:detailed;type:bigint(20) unsigned;default:0;not null;comment:指标细则"` + Type int64 `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:0;not null;comment:1、年度;2、季度;3、月度"` + Year int64 `json:"year" gorm:"column:year;type:bigint(20) unsigned;default:0;not null;comment:年度"` + Timecopy int64 `json:"timecopy" gorm:"column:timecopy;type:int(3) unsigned;default:0;not null;comment:季度与月度辅助值"` + Zeroprize float64 `json:"zeroprize" gorm:"column:zeroprize;type:int(7) unsigned;default:0;not null;comment:零奖值"` + Allprize float64 `json:"allprize" gorm:"column:allprize;type:int(7) unsigned;default:0;not null;comment:全奖值"` + Capping int `json:"capping" gorm:"column:capping;type:int(1) unsigned;default:2;not null;comment:是否封顶(1、是;2:否)"` + CappingVal float64 `json:"cappingval" gorm:"column:capping_val;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:删除)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` +} + +func (QuanPeopleConfigTarget *QuanPeopleConfigTarget) TableName() string { + return "quan_people_config_target" +} + +// 编辑内容 +func (cont *QuanPeopleConfigTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *QuanPeopleConfigTarget) 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 *QuanPeopleConfigTarget) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *QuanPeopleConfigTarget) ContMap(whereMap interface{}, field ...string) (countAry []QuanPeopleConfigTarget, 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 *QuanPeopleConfigTarget) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 905fbc0..f3a5185 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -1448,6 +1448,18 @@ func GetAppointMonthStarAndEndTime(dayTime string) (startTime, endTime int64) { return } +// 获取指定月的起止时间副本 +func GetAppointMonthStarAndEndTimeEs(dayTime string) (startTime, endTime int64) { + dataTypeAll := "2006-01-02" + firstToTime := StringToTimeIng("d", dayTime) + startTimeStr := fmt.Sprintf("%v 00:00:00", firstToTime.AddDate(0, 0, 0).Format(dataTypeAll)) + endTimeStr := fmt.Sprintf("%v 23:59:59", firstToTime.AddDate(0, 1, -1).Format(dataTypeAll)) + // startTime = dayTime + startTime, _ = DateToTimeStamp(startTimeStr) + endTime, _ = DateToTimeStamp(endTimeStr) + return +} + // 日期字符串转换成time格式 func StringToTimeIng(unit, str string) (res time.Time) { loc, _ := time.LoadLocation("Local") @@ -1519,3 +1531,39 @@ func MenuOperationPeiQuan(jurisd int, menuId string, oper []string) (isTrue bool // fmt.Printf("ApiUrl---%v--->%v--->%v--->%v\n", menuId, isTrue, operErr, operList) return } + +/* +* +@ 作者: 秦东 +@ 时间: 2023-01-03 16:41:19 +@ 功能: 合并数组 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func MergeStruct[T GenericityVariable](aryOen, aryTwo []T) (structAry []T) { + if len(aryOen) >= len(aryTwo) { + structAry = aryOen + for i := 0; i < len(aryTwo); i++ { + if IsInTrue[T](aryTwo[i], structAry) == false { + structAry = append(structAry, aryTwo[i]) + } + } + } else { + structAry = aryTwo + for i := 0; i < len(aryOen); i++ { + if IsInTrue[T](aryOen[i], structAry) == false { + structAry = append(structAry, aryOen[i]) + } + } + } + return +}