From 51cf25d901d928ee649315076de6d91559817040 Mon Sep 17 00:00:00 2001 From: zty <1048209592@qq.com> Date: Mon, 22 Jul 2024 10:55:19 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AD=A3=E5=BA=A6=E5=AE=A1=E6=A0=B8=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E5=AE=A1=E6=89=B9=E8=8A=82=E7=82=B9=E6=97=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=A4=E6=96=AD=EF=BC=8C=E5=BD=93=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E9=83=A8=E9=97=A8=E4=B8=BB=E4=BB=BB(4)?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=9A=84=E6=97=B6=E5=80=99=E5=B0=86=E6=B5=81?= =?UTF-8?q?=E8=BD=AC=E5=88=B0=E4=B8=8B=E4=B8=80=E4=B8=AA=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E3=80=82=E5=BD=93=E5=9B=9B=E4=B8=AA=E9=83=A8=E9=97=A8=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=B9=8B=E5=90=8E=E7=AE=97=E5=87=BA=E5=B9=B3=E5=9D=87?= =?UTF-8?q?=E5=88=86=E5=B9=B6=E5=AD=98=E5=85=A5json=202.=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=8E=B7=E5=8F=96=E5=AD=A3=E5=BA=A6=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=97=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=AD=A3=E5=BA=A6=E6=8E=92=E5=BA=8F=203.=E5=AD=A3=E5=BA=A6?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E7=AC=AC=E4=B8=80=E4=B8=AA=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E9=A4=90=E5=AE=BF=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xml/ProjectAssessmentIndicatorsMapper.xml | 2 +- ...ProjectAssessmentIndicatorsController.java | 245 ++++++++++++++---- .../ProjectQuarterlyEvaluationController.java | 2 +- 3 files changed, 190 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/xqopen/kehui/mapper/xml/ProjectAssessmentIndicatorsMapper.xml b/src/main/java/com/xqopen/kehui/mapper/xml/ProjectAssessmentIndicatorsMapper.xml index 4a93bf7..2dcdec9 100644 --- a/src/main/java/com/xqopen/kehui/mapper/xml/ProjectAssessmentIndicatorsMapper.xml +++ b/src/main/java/com/xqopen/kehui/mapper/xml/ProjectAssessmentIndicatorsMapper.xml @@ -54,6 +54,6 @@ from project_assessment_indicators WHERE project_id = #{map.projectId} and ext_ ->> 'executor' like CONCAT('%', #{map.userId}, '%') - GROUP BY quarter, project_id) b on a.project_id = b.project_id and a.quarter = b.quarter + GROUP BY quarter, project_id) b on a.project_id = b.project_id and a.quarter = b.quarter ORDER BY b.quarter desc diff --git a/src/main/java/com/xqopen/kehui/project/action/ProjectAssessmentIndicatorsController.java b/src/main/java/com/xqopen/kehui/project/action/ProjectAssessmentIndicatorsController.java index c1c3a59..a7796c6 100644 --- a/src/main/java/com/xqopen/kehui/project/action/ProjectAssessmentIndicatorsController.java +++ b/src/main/java/com/xqopen/kehui/project/action/ProjectAssessmentIndicatorsController.java @@ -60,6 +60,7 @@ public class ProjectAssessmentIndicatorsController implements ProjectAssessmentI /** * 季度审核第二个页面,查看有多少个季度 + * * @param userId * @param map * @return @@ -67,7 +68,7 @@ public class ProjectAssessmentIndicatorsController implements ProjectAssessmentI */ @Override @PostMapping(Api.PROJECT_QUARTERLY_EVALUATION_QUARTER_LIST) - public String quarterList(@RequestHeader Long userId,@RequestBody Map map) throws XQException { + public String quarterList(@RequestHeader Long userId, @RequestBody Map map) throws XQException { try { // ProjectAssessmentIndicators indicators = pageNoUtil.getT(); // EntityWrapper wrapper = new EntityWrapper<>(); @@ -82,11 +83,11 @@ public class ProjectAssessmentIndicatorsController implements ProjectAssessmentI // wrapper.groupBy("ext_->>'taskName'"); // wrapper.setSqlSelect("quarter,AVG((ext_->>'sum')::FLOAT),project_id,ext_->>'taskName' "); // List> maps = indicatorsService.selectMaps(wrapper); - map.put("userId",userId); - map.put("projectId",Long.parseLong(String.valueOf(map.get("projectId")))); + map.put("userId", userId); + map.put("projectId", Long.parseLong(String.valueOf(map.get("projectId")))); List> maps = indicatorsService.getQuarterList(map); - return ApiResponse.fillSuccess(new ResultListReqUtil>(maps,maps.size(),0)); - }catch (Exception e){ + return ApiResponse.fillSuccess(new ResultListReqUtil>(maps, maps.size(), 0)); + } catch (Exception e) { log.error("ProjectAssessmentIndicatorsController.quarterList", e); throw new XQException(ErrorCode.PROJECTINFO_EXCEPTION_ERROR, null); } @@ -97,8 +98,12 @@ public class ProjectAssessmentIndicatorsController implements ProjectAssessmentI public String list(@RequestHeader Long userId, @RequestBody PageNoUtil pageNoUtil) throws XQException { try { Page page = new Page<>(pageNoUtil.getPageNo(), pageNoUtil.getPageSize()); - List indicatorsServiceList = indicatorsService.getList(page, pageNoUtil.getT(),String.valueOf(userId)); - ResultListReqUtil listReqUtil = new ResultListReqUtil<>(indicatorsServiceList, pageNoUtil.getPageNo(), pageNoUtil.getPageSize()); + List indicatorsServiceList = indicatorsService.getList(page, pageNoUtil.getT(), String.valueOf(userId)); + ResultListReqUtil listReqUtil = new ResultListReqUtil<>(); + listReqUtil.setLs(indicatorsServiceList); + ; + listReqUtil.setPages(page.getPages()); + listReqUtil.setTotal(page.getTotal()); return ApiResponse.fillSuccess(listReqUtil); } catch (Exception e) { log.error("ProjectAssessmentIndicatorsController.list", e); @@ -129,32 +134,34 @@ public class ProjectAssessmentIndicatorsController implements ProjectAssessmentI } } //算出每个指标的平均数 - boolean isOffice= (boolean) ext.get("isOffice"); - if(isOffice){ - double sum=0; - if(!StringUtils.isEmpty(sum)){ - double strategyScoring = ext.get("strategyScoring")==null?0:Double.valueOf((String) ext.get("strategyScoring")) ; - double marketScoring = ext.get("marketScoring")==null?0:Double.valueOf((String) ext.get("marketScoring")) ; - double platformScoring = ext.get("platformScoring")==null?0:Double.valueOf((String) ext.get("platformScoring")) ; - double serviceScoring = ext.get("serviceScoring")==null?0:Double.valueOf((String) ext.get("serviceScoring")) ; - ArrayList arrayList = new ArrayList<>(); - arrayList.add(serviceScoring);arrayList.add(strategyScoring);arrayList.add(marketScoring);arrayList.add(platformScoring); - int index=0; - for (int i = 0; i < arrayList.size(); i++) { - if(arrayList.get(i)>0){ - index+=1; - sum+=arrayList.get(i); - } + boolean isOffice = (boolean) ext.get("isOffice"); + if (isOffice) { + double strategyScoring = ext.get("strategyScoring") == null ? 0 : Double.valueOf((String) ext.get("strategyScoring")); + double marketScoring = ext.get("marketScoring") == null ? 0 : Double.valueOf((String) ext.get("marketScoring")); + double platformScoring = ext.get("platformScoring") == null ? 0 : Double.valueOf((String) ext.get("platformScoring")); + double serviceScoring = ext.get("serviceScoring") == null ? 0 : Double.valueOf((String) ext.get("serviceScoring")); + ArrayList arrayList = new ArrayList<>(); + arrayList.add(serviceScoring); + arrayList.add(strategyScoring); + arrayList.add(marketScoring); + arrayList.add(platformScoring); + double sum = 0; + int index = 0; + for (int i = 0; i < arrayList.size(); i++) { + if (arrayList.get(i) > 0) { + index += 1; + sum += arrayList.get(i); } - if(sum>0){ -// sum=arrayList.stream().collect(Collectors.averagingDouble(x -> x)); - sum=sum/index; - DecimalFormat df = new DecimalFormat("#.0"); - String result = df.format(sum); - sum = Double.parseDouble(result); - } - ext.put("sum",sum); } + if (index == 4 && sum > 0) { +// sum=arrayList.stream().collect(Collectors.averagingDouble(x -> x)); + sum = sum / index; + DecimalFormat df = new DecimalFormat("#.0"); + String result = df.format(sum); + sum = Double.parseDouble(result); + ext.put("sum", sum); + } + } } if (indicatorsService.updateById(indicators)) return ApiResponse.fillSuccess("操作成功!"); @@ -173,65 +180,103 @@ public class ProjectAssessmentIndicatorsController implements ProjectAssessmentI public String examine(@RequestHeader Long userId, @RequestBody Map map) throws XQException { try { if (!ObjectUtils.isEmpty(map)) { + //通过项目id、季节拿到要审批的指标列表,前面因为季度列表已经判断了权限,这里就不做权限 String id = String.valueOf(map.get("id"));//项目id - ProjectInfo projectInfo = projectInfoService.selectById(Long.parseLong(id)); - if (!ObjectUtils.isEmpty(projectInfo)) { - JSONObject ext = projectInfo.getExt(); + EntityWrapper indicatorsEntityWrapper = new EntityWrapper<>(); + indicatorsEntityWrapper.eq("is_deleted", "0"); + indicatorsEntityWrapper.eq("project_id", Long.parseLong(String.valueOf(id))); + indicatorsEntityWrapper.eq("quarter", String.valueOf(map.get("quarter"))); + List indicatorsList = indicatorsService.selectList(indicatorsEntityWrapper); + if (!ObjectUtils.isEmpty(indicatorsList)) { + ProjectAssessmentIndicators indicators = indicatorsList.get(0); + JSONObject ext = indicators.getExt(); if (!ObjectUtils.isEmpty(ext)) { String taskName = String.valueOf(ext.get("taskName"));//节点名称 String examine = String.valueOf(map.get("examine"));//通过or驳回 - String isOffice = String.valueOf(ext.get("isOffice"));//项目负责人是否是办公室部门的 + boolean isOffice = (boolean) map.get("isOffice");//项目负责人是否是办公室部门的 + Integer businessNumber = 0;//查看是第几个部门主任评级了 + if (!ObjectUtils.isEmpty(ext.get("businessNumber"))) { + businessNumber = Integer.parseInt(String.valueOf(ext.get("businessNumber"))); + } switch (taskName) { case "季度审核填报": if ("1".equals(examine)) { return ApiResponse.fillFail("季度审核填报无法驳回!"); } else if ("0".equals(examine)) { - if ("0".equals(isOffice)) { - examine(userId, "部门主任评级", ext, "", projectInfo); - } else if ("1".equals(isOffice)) { - examine(userId, "管理员审核", ext, "projectAdmin", projectInfo); + if (isOffice) { + map.put("taskName", "部门主任评级"); +// examine(userId, "部门主任评级", ext, "", projectInfo); + } else { + map.put("taskName", "管理员审核"); + map.put("executor", ext.get("projectAdmin")); +// examine(userId, "管理员审核", ext, "projectAdmin", projectInfo); } } break; case "部门主任评级": if ("0".equals(examine)) { - examine(userId, "管理员审核", ext, "projectAdmin", projectInfo); + map.put("userId", String.valueOf(userId)); + map.put("isBusiness", true);//添加当前是部门主任的标记 + Object o = businessNumber == 3 ? map.put("taskName", "管理员审核") : map.put("taskName", "部门主任评级"); +// map.put("taskName","管理员审核"); + map.put("businessNumber", businessNumber); + map.put("executor", ext.get("projectAdmin")); +// examine(userId, "管理员审核", ext, "projectAdmin", projectInfo); } else if ("1".equals(examine)) { - examine(userId, "季度审核填报", ext, "projectManager", projectInfo); + map.put("taskName", "季度审核填报"); + map.put("executor", ext.get("projectManager")); +// examine(userId, "季度审核填报", ext, "projectManager", projectInfo); } break; case "管理员审核": - ext.put("adminSpyj", map.get("spyj")); +// ext.put("adminSpyj", map.get("spyj")); + map.put("adminSpyj", map.get("spyj")); if ("0".equals(examine)) { - examine(userId, "分管领导审核", ext, "branchLeaders", projectInfo); + map.put("taskName", "分管领导审核"); + map.put("executor", ext.get("branchLeaders")); +// examine(userId, "分管领导审核", ext, "branchLeaders", projectInfo); } else if ("1".equals(examine)) { - if ("0".equals(isOffice)) { - examine(userId, "部门主任评级", ext, "", projectInfo); + if (isOffice) { + map.put("taskName", "部门主任评级"); +// examine(userId, "部门主任评级", ext, "", projectInfo); } else { - examine(userId, "季度审核填报", ext, "projectManager", projectInfo); + map.put("taskName", "季度审核填报"); + map.put("executor", ext.get("projectManager")); +// examine(userId, "季度审核填报", ext, "projectManager", projectInfo); } } break; case "分管领导审核": - ext.put("branchLeadersSpyj", map.get("spyj")); + map.put("branchLeadersSpyj", map.get("spyj")); +// ext.put("branchLeadersSpyj", map.get("spyj")); if ("0".equals(examine)) { - examine(userId, "主要领导审核", ext, "MainLeader", projectInfo); + map.put("taskName", "主要领导审核"); + map.put("executor", ext.get("MainLeader")); +// examine(userId, "主要领导审核", ext, "MainLeader", projectInfo); } else if ("1".equals(examine)) { - examine(userId, "管理员审核", ext, "projectAdmin", projectInfo); + map.put("taskName", "管理员审核"); + map.put("executor", ext.get("projectAdmin")); +// examine(userId, "管理员审核", ext, "projectAdmin", projectInfo); } break; case "主要领导审核": + map.put("MainLeaderSpyj", map.get("spyj")); if ("0".equals(examine)) { - ext.put("MainLeaderSpyj", map.get("spyj")); - examine(userId, "流程结束", ext, "MainLeader", projectInfo); +// ext.put("MainLeaderSpyj", map.get("spyj")); + map.put("executor", " "); + map.put("taskName", "流程结束"); +// examine(userId, "流程结束", ext, "MainLeader", projectInfo); } else if ("1".equals(examine)) { - examine(userId, "分管领导审核", ext, "branchLeaders", projectInfo); + map.put("taskName", "分管领导审核"); +// examine(userId, "分管领导审核", ext, "branchLeaders", projectInfo); } default: break; } + examine(map, indicatorsList); return ApiResponse.fillSuccess("操作成功!"); } + } } } catch (Exception e) { @@ -273,35 +318,121 @@ public class ProjectAssessmentIndicatorsController implements ProjectAssessmentI /** * 根据人事id返回是四个业务部那个部门的主任 + * * @param id * @return * @throws XQException */ @Override @GetMapping(Api.PROJECT_QUARTERLY_EVALUATION_GETBUSINESS) - public String getBusinessByUserInfoId(@PathVariable String id) throws XQException{ + public String getBusinessByUserInfoId(@PathVariable String id) throws XQException { try { EntityWrapper flowsConfigurationEntityWrapper = new EntityWrapper<>(); flowsConfigurationEntityWrapper.eq("approved_role", "business"); flowsConfigurationEntityWrapper.eq("is_deleted", false); flowsConfigurationEntityWrapper.eq("approver_id", Long.parseLong(id)); FlowsConfiguration flowsConfiguration = flowsConfigurationService.selectOne(flowsConfigurationEntityWrapper); - if(!ObjectUtils.isEmpty(flowsConfiguration)){ + if (!ObjectUtils.isEmpty(flowsConfiguration)) { EntityWrapper orgEntityWrapper = new EntityWrapper<>(); orgEntityWrapper.eq("is_deleted", false); - orgEntityWrapper.eq("id_",flowsConfiguration.getOrgId()); + orgEntityWrapper.eq("id_", flowsConfiguration.getOrgId()); SystemOrg systemOrg = orgService.selectOne(orgEntityWrapper); - if(!ObjectUtils.isEmpty(systemOrg)){ + if (!ObjectUtils.isEmpty(systemOrg)) { return ApiResponse.fillSuccess(systemOrg.getOrgName()); } } - }catch (Exception e){ + } catch (Exception e) { log.error("ProjectAssessmentIndicatorsController.getBusinessByUserInfoId", e); throw new XQException(ErrorCode.PROJECTINFO_EXCEPTION_ERROR, null); } return ApiResponse.fillFail(); } + /** + * 审核 + * + * @param map + * @param list + */ + public void examine(Map map, List list) { + if (!ObjectUtils.isEmpty(list)) { + String taskName = String.valueOf(map.get("taskName")); + if (!"部门主任评级".equals(taskName)) { + for (int i = 0; i < list.size(); i++) { + ProjectAssessmentIndicators indicators = list.get(i); + JSONObject ext = indicators.getExt(); + ext.put("executor", map.get("executor")); + ext.put("taskName", taskName); + Object adminSpyj = map.get("adminSpyj") == null ? null : ext.put("adminSpyj", map.get("adminSpyj")); + Object branchLeadersSpyj = map.get("branchLeadersSpyj") == null ? null : ext.put("branchLeadersSpyj", map.get("branchLeadersSpyj")); + Object MainLeaderSpyj = map.get("MainLeaderSpyj") == null ? null : ext.put("MainLeaderSpyj", map.get("MainLeaderSpyj")); +// ext.put("adminSpyj",map.get("adminSpyj")); +// ext.put("branchLeadersSpyj",map.get("branchLeadersSpyj")); +// ext.put("MainLeaderSpyj",map.get("MainLeaderSpyj")); + indicators.setExt(ext); + } + } else { + //如果节点是部门主任评级时,则当前责任人是四个业务部的部门主任 + EntityWrapper orgEntityWrapper = new EntityWrapper<>(); + orgEntityWrapper.andNew().eq("is_deleted", false); + orgEntityWrapper.andNew().eq("org_name", "战略规划部").or() + .eq("org_name", "平台建设部").or() + .eq("org_name", "市场发展部").or() + .eq("org_name", "服务产品部"); + orgEntityWrapper.setSqlSelect("id_"); + List objectList = orgService.selectObjs(orgEntityWrapper);//先拿到部门集合ids + if (!StringUtils.isEmpty(objectList)) { + // 使用Streams将Object集合转换为Long集合 + List longs = objectList.stream() + .map(obj -> (Long) obj) // 强制类型转换 + .collect(Collectors.toList()); + EntityWrapper flowsConfigurationEntityWrapper = new EntityWrapper<>(); + flowsConfigurationEntityWrapper.eq("approved_role", "business"); + flowsConfigurationEntityWrapper.eq("is_deleted", false); + flowsConfigurationEntityWrapper.in("org_id", longs); + flowsConfigurationEntityWrapper.setSqlSelect("approver_id"); + List objectList1 = flowsConfigurationService.selectObjs(flowsConfigurationEntityWrapper);//拿到人事集合ids + longs = objectList1.stream() + .map(obj -> (Long) obj) // 强制类型转换 + .collect(Collectors.toList()); + EntityWrapper userLoginEntityWrapper = new EntityWrapper<>(); + userLoginEntityWrapper.eq("is_deleted", false); + userLoginEntityWrapper.in("userinfo_id", longs); + userLoginEntityWrapper.setSqlSelect("string_agg(id_::text,',')"); + String executor = String.valueOf(userLoginService.selectObj(userLoginEntityWrapper)); + boolean isBusiness = false; + if (!ObjectUtils.isEmpty(map.get("isBusiness"))) { + isBusiness = (boolean) map.get("isBusiness"); + } + Integer businessNumber = (Integer) map.get("businessNumber"); + if (isBusiness) { //如果当前节点是 + //判断是第几个主任评级了 + businessNumber = Integer.parseInt(String.valueOf(map.get("businessNumber"))); + if (!ObjectUtils.isEmpty(businessNumber)) { + businessNumber += 1; + String userId = String.valueOf(map.get("userId")); + if (executor.contains(userId)) { + executor = executor.replace(userId, "");//删掉当前已提交的部门主任id + } + if (businessNumber == 4) { + executor = String.valueOf(map.get("executor")); + } + } + } + for (int i = 0; i < list.size(); i++) { + ProjectAssessmentIndicators indicators = list.get(i); + JSONObject ext = indicators.getExt(); + ext.put("taskName", map.get("taskName")); + ext.put("businessNumber", businessNumber); + ext.put("executor", executor); + indicators.setExt(ext); + } + } + } + indicatorsService.updateAllColumnBatchById(list); + } + } + /** * 审核 * diff --git a/src/main/java/com/xqopen/kehui/project/action/ProjectQuarterlyEvaluationController.java b/src/main/java/com/xqopen/kehui/project/action/ProjectQuarterlyEvaluationController.java index 07a632d..8cebf05 100644 --- a/src/main/java/com/xqopen/kehui/project/action/ProjectQuarterlyEvaluationController.java +++ b/src/main/java/com/xqopen/kehui/project/action/ProjectQuarterlyEvaluationController.java @@ -63,7 +63,7 @@ public class ProjectQuarterlyEvaluationController implements ProjectQuarterlyEva if (!ObjectUtils.isEmpty(evaluationList)) { list = projectInfoService.getListByIds(page, evaluationList); } - ResultListReqUtil listReqUtil = new ResultListReqUtil<>(list, page.getPages(), page.getTotal()); + ResultListReqUtil listReqUtil = new ResultListReqUtil<>(list, page.getTotal(), page.getPages()); return ApiResponse.fillSuccess(listReqUtil); } catch (Exception e) { log.error("ProjectQuarterlyEvaluationController.list", e);