package com.ims.eval.controller; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ims.common.utils.StringUtils; import com.ims.eval.config.CustomException; import com.ims.eval.entity.DeptAssessmentDeclaration; import com.ims.eval.entity.DeptAssessmentDeclarationComplete; import com.ims.eval.entity.DeptAssessmentDeclarationContent; import com.ims.eval.entity.EvaluationDept; import com.ims.eval.entity.dto.request.*; import com.ims.eval.entity.dto.result.R; import com.ims.eval.service.*; import com.ims.eval.service.custom.PostService; import com.ims.eval.service.custom.PostUserService; import com.ims.eval.util.ExcelUtil; import com.ims.eval.util.ExcelUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.net.URLEncoder; import java.util.*; import java.util.stream.Collectors; /** * 绩效结果考核申报 * * @author hlf * @date 2023/5/29 15:15 * 文件说明: */ @Slf4j @RestController @RequestMapping("//evaluation-dept-ad") public class DeptAssessmentDeclarationController { @Autowired private IDeptAssessmentDeclarationService deptAssessmentDeclarationService; @Autowired private IDeptAssessmentDeclarationContentService deptAssessmentDeclarationContentService; @Autowired private IDeptAssessmentDeclarationCompleteService deptAssessmentDeclarationCompleteService; @Autowired private IEvaluationDeptService evaluationDeptService; @Autowired private IUserService userService; @Autowired private PostService postService; @Autowired private PostUserService postUserService; @Autowired private HttpServletRequest request; /** * 绩效结果考核申报列表信息(分页) * * @param pageNum 当前记录起始索引 * @param pageSize 每页显示记录数 * @param orderNumber 单号 * @param deptName 部门名称 * @param annual 年度 * @param declarationMonth 申报月份 * @return 结果 */ @GetMapping(value = "/list") public R list( @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize, @RequestParam(value = "deptId") String deptId, @RequestParam(value = "orderNumber", required = false) String orderNumber, @RequestParam(value = "deptName", required = false) String deptName, @RequestParam(value = "annual", required = false) Integer annual, @RequestParam(value = "declarationMonth", required = false) Integer declarationMonth) { IPage list = deptAssessmentDeclarationService.listPage(pageNum, pageSize, deptId, orderNumber, deptName, annual, declarationMonth,request); return R.ok().data(list); } /** * 绩效结果考核申报信息 * * @return 结果 */ @GetMapping(value = "/listAll") public R listAll() { List list = deptAssessmentDeclarationService.list(); return R.ok().data(list); } /** * 新增绩效结果考核申报信息 * * @param deptAssessmentDeclaration 绩效结果考核申报实体 * @return 结果 */ @PostMapping(value = "/save") public R addAll(@RequestBody DeptAssessmentDeclaration deptAssessmentDeclaration, HttpServletRequest request) { try { QueryWrapper qw = new QueryWrapper<>(); if (StringUtils.isNotEmpty(deptAssessmentDeclaration.getDeptId())) { qw.lambda().eq(DeptAssessmentDeclaration::getDeptId, deptAssessmentDeclaration.getDeptId()); } if (null != deptAssessmentDeclaration.getAnnual()) { qw.lambda().eq(DeptAssessmentDeclaration::getAnnual, deptAssessmentDeclaration.getAnnual()); } if (null != deptAssessmentDeclaration.getDeclarationMonth()) { qw.lambda().eq(DeptAssessmentDeclaration::getDeclarationMonth, deptAssessmentDeclaration.getDeclarationMonth()); } DeptAssessmentDeclaration assessmentDeclaration = deptAssessmentDeclarationService.getOne(qw); if (ObjectUtil.isNotNull(assessmentDeclaration)) { return R.error(deptAssessmentDeclaration.getDeptName() + deptAssessmentDeclaration.getAnnual() + "年" + deptAssessmentDeclaration.getDeclarationMonth() + "月绩效结果考核申报已存在!"); } boolean b = deptAssessmentDeclarationService.save(deptAssessmentDeclaration, request); if (b) { return R.ok().data(b); } else { return R.error("保存失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 获取部门领导 * * @return 结果 */ @GetMapping(value = "/getDepartmentLeader/{id}") public R getDepartmentLeader(@PathVariable String id) { QueryWrapper qw = new QueryWrapper<>(); if (StringUtils.isNotEmpty(id)) { qw.lambda().like(EvaluationDept::getDeptId, id); } EvaluationDept evaluationDept = evaluationDeptService.getOne(qw); return R.ok().data(evaluationDept); } /** * 修改绩效结果考核申报信息 * * @param deptAssessmentDeclaration 绩效结果考核申报实体 * @return 结果 */ @PostMapping(value = "/modify") public R modify(@RequestBody DeptAssessmentDeclaration deptAssessmentDeclaration) { try { boolean b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration); if (b) { return R.ok().data(b); } else { return R.error("修改失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 批量删除绩效结果考核申报信息 * * @param ids 主键s * @return 结果 */ @PostMapping(value = "/removeAll/{ids}") public R deleteAll(@PathVariable("ids") String ids) { try { String[] strings = ids.split(","); boolean b = deptAssessmentDeclarationService.removeByIds(Arrays.asList(strings)); if (b) { return R.ok().data(b); } else { return R.error("删除失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 详情-头部信息 * * @param id 业务主键 * @return 结果 */ @GetMapping(value = "/detailsHead/{id}") public R detailsHead(@PathVariable("id") String id) { DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id); return R.ok().data(deptAssessmentDeclaration); } /** * 详情 * * @param id 业务主键 * @return 结果 */ @GetMapping(value = "/details/{id}") public R details(@PathVariable("id") String id) { Map> map = new HashMap<>(); List contentList = deptAssessmentDeclarationContentService.detailsList(id); map.put("ygydkhxs", Collections.singletonList(contentList)); List completeList = deptAssessmentDeclarationCompleteService.detailsList(id); map.put("byzygzwcqk", Collections.singletonList(completeList)); return R.ok().data(map); } /** * 左侧详情-修改/新增 * * @param deptAssessmentDeclarationContentList 修改内容 * @return 结果 */ @PostMapping(value = "/updateContent") public R updateContent(@RequestBody List deptAssessmentDeclarationContentList) { try { boolean b = deptAssessmentDeclarationContentService.saveOrUpdateBatch(deptAssessmentDeclarationContentList); if (b) { return R.ok().data(b); } else { return R.error("保存失败,人员重复或人员信息不完善!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 右侧详情-修改/新增 * * @param deptAssessmentDeclarationCompleteList 修改内容 * @return 结果 */ @PostMapping(value = "/updateComplete") public R updateComplete(@RequestBody List deptAssessmentDeclarationCompleteList) { try { boolean b = deptAssessmentDeclarationCompleteService.saveOrUpdateBatch(deptAssessmentDeclarationCompleteList); if (b) { return R.ok().data(b); } else { return R.error("新增/修改失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 左侧详情-批量删除 * * @param ids 主键 * @return 结果 */ @GetMapping(value = "/deleteContent/{ids}") public R deleteContent(@PathVariable String ids) { try { String[] strings = ids.split(","); boolean b = deptAssessmentDeclarationContentService.removeByIds(Arrays.asList(strings)); if (b) { return R.ok().data(b); } else { return R.error("删除失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 右侧详情-批量删除 * * @param ids 主键 * @return 结果 */ @GetMapping(value = "/deleteComplete/{ids}") public R deleteComplete(@PathVariable String ids) { try { String[] strings = ids.split(","); boolean b = deptAssessmentDeclarationCompleteService.removeByIds(Arrays.asList(strings)); if (b) { return R.ok().data(b); } else { return R.error("删除失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 导入 * * @param file 文件 * @return 结果 */ @PostMapping(value = "/import") public R importData(@RequestParam("file") MultipartFile file, @RequestParam("id") String id) { if (!file.isEmpty()) { try { //成功条数 int successCount = 0; //更新条数 int renewalCount = 0; //失败条数 int loseCount = 0; //获取原始的文件名 String originalFilename = file.getOriginalFilename(); //获取文件类型 String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length()); //默认从第一行开始读取 int startRows = 1; //获取输入流 InputStream is = file.getInputStream(); //Excel导入导出的单元类 List strings = ExcelUtil.readData(fileType, startRows, true, is); //遍历Excel表每一行的数据 for (String[] str : strings) { DeptAssessmentDeclarationContent deptAssessmentDeclarationContent = new DeptAssessmentDeclarationContent(); deptAssessmentDeclarationContent.setAssessmentDeclarationId(id); deptAssessmentDeclarationContent.setEmployeeNo(str[0]); JSONObject jsonArr = userService.getLoginNameByUserInfo(str[0], request); if ("操作成功".equals(String.valueOf(jsonArr.get("msg")))){ JSONObject data = (JSONObject) jsonArr.get("data"); deptAssessmentDeclarationContent.setEmployeeId(String.valueOf(data.get("id"))); deptAssessmentDeclarationContent.setEmployeeName(String.valueOf(data.get("name"))); } deptAssessmentDeclarationContent.setSuggestedValue(str[2]); deptAssessmentDeclarationContent.setSerialNumber(Convert.toInt(str[3])); QueryWrapper qw = new QueryWrapper<>(); if (StringUtils.isNotEmpty(deptAssessmentDeclarationContent.getAssessmentDeclarationId())) { qw.lambda().like(DeptAssessmentDeclarationContent::getAssessmentDeclarationId, deptAssessmentDeclarationContent.getAssessmentDeclarationId()); } if (StringUtils.isNotEmpty(deptAssessmentDeclarationContent.getEmployeeNo())) { qw.lambda().like(DeptAssessmentDeclarationContent::getEmployeeNo, deptAssessmentDeclarationContent.getEmployeeNo()); } if (StringUtils.isNotEmpty(deptAssessmentDeclarationContent.getEmployeeId())) { qw.lambda().like(DeptAssessmentDeclarationContent::getEmployeeId, deptAssessmentDeclarationContent.getEmployeeId()); } List objList = deptAssessmentDeclarationContentService.list(qw); if (objList.size() == 1) {//修改 deptAssessmentDeclarationContent.setId(objList.get(0).getId()); deptAssessmentDeclarationContentService.updateById(deptAssessmentDeclarationContent); renewalCount++; } else if (objList.size() == 0) {//新增 deptAssessmentDeclarationContentService.save(deptAssessmentDeclarationContent); successCount++; } else { loseCount++; } } String msg = "导入成功,本次新增" + successCount + "条,更新" + renewalCount + "条,失败" + loseCount + "条数据。"; return R.ok().message(msg); } catch (Exception e) { log.error("错误", e); return R.customError(e.getMessage()).data("失败!"); } } return R.error("上传文件为空!"); } /** * 修改状态 * * @param id 主键 * @param stage 状态 * @return 结果 */ @PostMapping(value = "/targetStart") public R targetStart(@RequestParam(value = "id") String id, @RequestParam(value = "stage") String stage) { try { DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id); deptAssessmentDeclaration.setStage(stage); boolean b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration); if (b) { return R.ok().data(b); } else { return R.error("失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 生成报表 * * @param id 主键 * @param response response * @throws Exception 异常 */ @GetMapping(value = "/generateReport/{id}") public void generateReport(@PathVariable("id") String id, HttpServletResponse response) throws Exception { response.setContentType("application/vnd.ms-excel;charset=UTF-8"); response.setHeader("Content-disposition", "attachment; filename=".concat(URLEncoder.encode("公司本部部门及员工月度绩效考核结果申报表.xlsx", "UTF-8"))); response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); List employeeDTOList = new ArrayList<>(); // 添加员工信息 QueryWrapper qw = new QueryWrapper<>(); if (StringUtils.isNotEmpty(id)) { qw.lambda().like(DeptAssessmentDeclarationContent::getAssessmentDeclarationId, id); } List deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.list(qw); for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) { EmployeeDTO employeeDTO = new EmployeeDTO(); employeeDTO.setName(deptAssessmentDeclarationContent.getEmployeeName()); employeeDTO.setCoefficient(deptAssessmentDeclarationContent.getSuggestedValue()); employeeDTOList.add(employeeDTO); } DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id); String departmentName = deptAssessmentDeclaration.getDeptName(); String month = String.valueOf(deptAssessmentDeclaration.getDeclarationMonth()); String level = deptAssessmentDeclaration.getRatingGrade(); String leader = deptAssessmentDeclaration.getDeptLeaderName(); String declarationReason = deptAssessmentDeclaration.getDeclarationReason(); ExcelUtils.createExcel(employeeDTOList, departmentName, month, level, leader, declarationReason, response.getOutputStream()); } /** * 统计汇总数据 * * @param startTime 开始时间 * @param endTime 结束时间 * @param deptId 部门主键 * @param employeeNo 人员编号 */ @GetMapping(value = "/statisticalSummary") public R statisticalSummary(@RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime, @RequestParam(value = "deptId") String deptId, @RequestParam(value = "employeeNo") String employeeNo) { List summaryInformationDTOList = new ArrayList<>(); String[] startTimeArr = new String[2]; String[] endTimeArr = new String[2]; if (startTime.length() > 0) { startTimeArr = startTime.split("-"); } if (endTime.length() > 0) { endTimeArr = endTime.split("-"); } QueryWrapper qw = new QueryWrapper<>(); if (StringUtils.isNotEmpty(startTimeArr) && StringUtils.isNotEmpty(endTimeArr)) { qw.lambda().between(DeptAssessmentDeclaration::getAnnual, Integer.parseInt(startTimeArr[0]), Integer.parseInt(endTimeArr[0])); qw.lambda().between(DeptAssessmentDeclaration::getDeclarationMonth, Integer.parseInt(startTimeArr[1]), Integer.parseInt(endTimeArr[1])); } if (StringUtils.isNotEmpty(deptId)) { qw.lambda().eq(DeptAssessmentDeclaration::getDeptId, deptId); } List deptAssessmentDeclarationList = deptAssessmentDeclarationService.list(qw); for (DeptAssessmentDeclaration deptAssessmentDeclaration : deptAssessmentDeclarationList) { QueryWrapper qwDept = new QueryWrapper<>(); if (StringUtils.isNotEmpty(deptAssessmentDeclaration.getDeptId())) { qwDept.lambda().eq(EvaluationDept::getDeptId, deptAssessmentDeclaration.getDeptId()); } EvaluationDept evaluationDept = evaluationDeptService.getOne(qwDept); List deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.detailsList(deptAssessmentDeclaration.getId()); for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) { if (StringUtils.isNotEmpty(employeeNo)) { if (employeeNo.equals(deptAssessmentDeclarationContent.getEmployeeNo())) { SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO(); summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo()); summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName()); summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue()); summaryInformationDTO.setDeclarationMonth(deptAssessmentDeclaration.getDeclarationMonth()); summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName()); summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade()); if (null != evaluationDept) { summaryInformationDTO.setSerialNumber(evaluationDept.getSerialNumber()); } summaryInformationDTOList.add(summaryInformationDTO); } } else { SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO(); summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo()); summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName()); summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue()); summaryInformationDTO.setDeclarationMonth(deptAssessmentDeclaration.getDeclarationMonth()); summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName()); summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade()); if (null != evaluationDept) { summaryInformationDTO.setSerialNumber(evaluationDept.getSerialNumber()); } summaryInformationDTOList.add(summaryInformationDTO); } } } List list = new ArrayList<>(); Map> map = summaryInformationDTOList.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getEmployeeNo)); map.forEach((key, value) -> { Map> map1 = value.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getDeclarationMonth)); map1.forEach((key1, value1) -> { for (SummaryInformationDTO summaryInformationDTO : value1) { summaryInformationDTO.setDeclarationsNumber(String.valueOf(value1.size())); } list.addAll(value1); }); }); list.sort(Comparator.comparing(SummaryInformationDTO::getSerialNumber, Comparator.nullsLast(Integer::compareTo))); return R.ok().data(list); } /** * 生成统计汇总报表 * * @param startTime 开始时间 * @param endTime 结束时间 * @param deptId 部门主键 * @param employeeNo 人员编号 * @param response response * @throws Exception 异常 */ @GetMapping(value = "/generateStatisticalSummaryReports") public void generateStatisticalSummaryReports(@RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime, @RequestParam(value = "deptId") String deptId, @RequestParam(value = "employeeNo") String employeeNo, HttpServletResponse response) throws Exception { response.setContentType("application/vnd.ms-excel;charset=UTF-8"); response.setHeader("Content-disposition", "attachment; filename=".concat(URLEncoder.encode("绩效结果考核申报汇总表.xlsx", "UTF-8"))); response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); List summaryInformationDTOList = new ArrayList<>(); String[] startTimeArr = new String[2]; String[] endTimeArr = new String[2]; if (startTime.length() > 0) { startTimeArr = startTime.split("-"); } if (endTime.length() > 0) { endTimeArr = endTime.split("-"); } QueryWrapper qw = new QueryWrapper<>(); if (StringUtils.isNotEmpty(startTimeArr) && StringUtils.isNotEmpty(endTimeArr)) { qw.lambda().between(DeptAssessmentDeclaration::getAnnual, Integer.parseInt(startTimeArr[0]), Integer.parseInt(endTimeArr[0])); qw.lambda().between(DeptAssessmentDeclaration::getDeclarationMonth, Integer.parseInt(startTimeArr[1]), Integer.parseInt(endTimeArr[1])); } if (StringUtils.isNotEmpty(deptId)) { qw.lambda().eq(DeptAssessmentDeclaration::getDeptId, deptId); } List deptAssessmentDeclarationList = deptAssessmentDeclarationService.list(qw); for (DeptAssessmentDeclaration deptAssessmentDeclaration : deptAssessmentDeclarationList) { QueryWrapper qwDept = new QueryWrapper<>(); if (StringUtils.isNotEmpty(deptAssessmentDeclaration.getDeptId())) { qwDept.lambda().eq(EvaluationDept::getDeptId, deptAssessmentDeclaration.getDeptId()); } EvaluationDept evaluationDept = evaluationDeptService.getOne(qwDept); List deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.detailsList(deptAssessmentDeclaration.getId()); for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) { if (StringUtils.isNotEmpty(employeeNo)) { if (employeeNo.equals(deptAssessmentDeclarationContent.getEmployeeNo())) { SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO(); summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo()); summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName()); summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue()); summaryInformationDTO.setDeclarationMonth(deptAssessmentDeclaration.getDeclarationMonth()); summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName()); summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade()); if (null != evaluationDept) { summaryInformationDTO.setSerialNumber(evaluationDept.getSerialNumber()); } summaryInformationDTOList.add(summaryInformationDTO); } } else { SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO(); summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo()); summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName()); summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue()); summaryInformationDTO.setDeclarationMonth(deptAssessmentDeclaration.getDeclarationMonth()); summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName()); summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade()); if (null != evaluationDept) { summaryInformationDTO.setSerialNumber(evaluationDept.getSerialNumber()); } summaryInformationDTOList.add(summaryInformationDTO); } } } List list = new ArrayList<>(); Map> map = summaryInformationDTOList.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getEmployeeNo)); map.forEach((key, value) -> { Map> map1 = value.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getDeclarationMonth)); map1.forEach((key1, value1) -> { for (SummaryInformationDTO summaryInformationDTO : value1) { summaryInformationDTO.setDeclarationsNumber(String.valueOf(value1.size())); } list.addAll(value1); }); }); list.sort(Comparator.comparing(SummaryInformationDTO::getSerialNumber, Comparator.nullsLast(Integer::compareTo))); ExcelUtils.createCollectExcel(list, startTimeArr[0], startTimeArr[1], endTimeArr[0], endTimeArr[1], response.getOutputStream()); } /** * 参与考核人数 * * @param id 主键 * @return 结果 */ @GetMapping(value = "/participantsNumber/{id}") public R participantsNumber(@PathVariable String id) { QueryWrapper qwComplete = new QueryWrapper<>(); if (StringUtils.isNotEmpty(id)) { qwComplete.lambda().eq(DeptAssessmentDeclarationComplete::getAssessmentDeclarationId, id); } int countComplete = deptAssessmentDeclarationCompleteService.list(qwComplete).size(); if (countComplete > 0) { QueryWrapper qwContent = new QueryWrapper<>(); if (StringUtils.isNotEmpty(id)) { qwContent.lambda().eq(DeptAssessmentDeclarationContent::getAssessmentDeclarationId, id); } int countContent = deptAssessmentDeclarationContentService.list(qwContent).size(); return R.ok().data(countContent); } else { return R.error("未添加工作完成情况!"); } } /** * 添加审批领导 * * @param id 主键 * @param employeeNo 用户编号 * @return 结果 */ @PostMapping(value = "/addApprovalLeader") public R addApprovalLeader(@RequestParam(value = "id") String id, @RequestParam(value = "employeeNo") String employeeNo) { boolean b = false; JSONObject jsonArr = userService.getLoginNameByUserInfo(employeeNo, request); JSONObject data = (JSONObject) jsonArr.get("data"); if (data.toJSONString().length()>0){ DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id); if (null != deptAssessmentDeclaration) { deptAssessmentDeclaration.setDeptLeaderId(String.valueOf(data.get("id"))); deptAssessmentDeclaration.setDeptLeaderNo(String.valueOf(data.get("no"))); deptAssessmentDeclaration.setDeptLeaderName(String.valueOf(data.get("name"))); b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration); } } if (b) { return R.ok().data(b); } else { return R.error("添加审批领导失败!"); } } /** * 添加复批领导 * * @param id 主键 * @param employeeNo 用户编号 * @return 结果 */ @PostMapping(value = "/addRepeatBatchLeader") public R addRepeatBatchLeader(@RequestParam(value = "id") String id, @RequestParam(value = "employeeNo") String employeeNo) { boolean b = false; JSONObject jsonArr = userService.getLoginNameByUserInfo(employeeNo, request); JSONObject data = (JSONObject) jsonArr.get("data"); if ("操作成功".equals(String.valueOf(data.get("msg")))){ DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id); if (null != deptAssessmentDeclaration) { deptAssessmentDeclaration.setSeconderId(String.valueOf(data.get("id"))); deptAssessmentDeclaration.setSeconderNo(String.valueOf(data.get("no"))); deptAssessmentDeclaration.setSeconderName(String.valueOf(data.get("name"))); b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration); } } if (b) { return R.ok().data(b); } else { return R.error("添加复批领导失败!"); } } /** * 获取审批领导 * * @param id 部门主键 * @return 结果 */ @GetMapping(value = "/obtainApprovalLeader/{id}") public R obtainApprovalLeader(@PathVariable String id) { List list = new ArrayList<>(); Object postList = postService.getPostList(1, 500, id, request); if (null != postList) { JSONObject postJsonArr = (JSONObject) postList; JSONArray postArray = JSONUtil.parseArray(postJsonArr.get("records")); List postArrList = JSONUtil.toList(postArray, PostDTO.class); for (PostDTO post : postArrList) { if (post.getName().contains("主任")) { Object postPersonnelList = postUserService.getPostUserList(1, 500, post.getId(), request); if (null != postPersonnelList) { JSONObject postPersonnelJsonArr = (JSONObject) postPersonnelList; JSONArray postPersonnelArray = JSONUtil.parseArray(postPersonnelJsonArr.get("records")); List userArrList = JSONUtil.toList(postPersonnelArray, PostUserDTO.class); if (userArrList.size() > 0) { list.addAll(userArrList); } } } } } return R.ok().data(list); } /** * 获取流程详情 * * @param instId 实例ID * @return 结果 */ @GetMapping(value = "processInformation/{instId}") public R processInformation(@PathVariable String instId) { Object obj = null; try { obj = deptAssessmentDeclarationService.processInformation(instId, request); } catch (Exception e) { log.error("错误", e); return null; } return R.ok().data(obj); } }