123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742 |
- 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<DeptAssessmentDeclaration> list = deptAssessmentDeclarationService.listPage(pageNum, pageSize, deptId, orderNumber, deptName, annual, declarationMonth,request);
- return R.ok().data(list);
- }
- /**
- * 绩效结果考核申报信息
- *
- * @return 结果
- */
- @GetMapping(value = "/listAll")
- public R listAll() {
- List<DeptAssessmentDeclaration> list = deptAssessmentDeclarationService.list();
- return R.ok().data(list);
- }
- /**
- * 新增绩效结果考核申报信息
- *
- * @param deptAssessmentDeclaration 绩效结果考核申报实体
- * @return 结果
- */
- @PostMapping(value = "/save")
- public R addAll(@RequestBody DeptAssessmentDeclaration deptAssessmentDeclaration, HttpServletRequest request) {
- try {
- QueryWrapper<DeptAssessmentDeclaration> 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<EvaluationDept> 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<String, List<Object>> map = new HashMap<>();
- List<DeptAssessmentDeclarationContent> contentList = deptAssessmentDeclarationContentService.detailsList(id);
- map.put("ygydkhxs", Collections.singletonList(contentList));
- List<DeptAssessmentDeclarationComplete> 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<DeptAssessmentDeclarationContent> 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<DeptAssessmentDeclarationComplete> 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<String[]> 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<DeptAssessmentDeclarationContent> 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<DeptAssessmentDeclarationContent> 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<EmployeeDTO> employeeDTOList = new ArrayList<>();
- // 添加员工信息
- QueryWrapper<DeptAssessmentDeclarationContent> qw = new QueryWrapper<>();
- if (StringUtils.isNotEmpty(id)) {
- qw.lambda().like(DeptAssessmentDeclarationContent::getAssessmentDeclarationId, id);
- }
- List<DeptAssessmentDeclarationContent> 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<SummaryInformationDTO> 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<DeptAssessmentDeclaration> 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<DeptAssessmentDeclaration> deptAssessmentDeclarationList = deptAssessmentDeclarationService.list(qw);
- for (DeptAssessmentDeclaration deptAssessmentDeclaration : deptAssessmentDeclarationList) {
- QueryWrapper<EvaluationDept> qwDept = new QueryWrapper<>();
- if (StringUtils.isNotEmpty(deptAssessmentDeclaration.getDeptId())) {
- qwDept.lambda().eq(EvaluationDept::getDeptId, deptAssessmentDeclaration.getDeptId());
- }
- EvaluationDept evaluationDept = evaluationDeptService.getOne(qwDept);
- List<DeptAssessmentDeclarationContent> 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<SummaryInformationDTO> list = new ArrayList<>();
- Map<String, List<SummaryInformationDTO>> map = summaryInformationDTOList.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getEmployeeNo));
- map.forEach((key, value) -> {
- Map<Integer, List<SummaryInformationDTO>> 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<SummaryInformationDTO> 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<DeptAssessmentDeclaration> 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<DeptAssessmentDeclaration> deptAssessmentDeclarationList = deptAssessmentDeclarationService.list(qw);
- for (DeptAssessmentDeclaration deptAssessmentDeclaration : deptAssessmentDeclarationList) {
- QueryWrapper<EvaluationDept> qwDept = new QueryWrapper<>();
- if (StringUtils.isNotEmpty(deptAssessmentDeclaration.getDeptId())) {
- qwDept.lambda().eq(EvaluationDept::getDeptId, deptAssessmentDeclaration.getDeptId());
- }
- EvaluationDept evaluationDept = evaluationDeptService.getOne(qwDept);
- List<DeptAssessmentDeclarationContent> 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<SummaryInformationDTO> list = new ArrayList<>();
- Map<String, List<SummaryInformationDTO>> map = summaryInformationDTOList.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getEmployeeNo));
- map.forEach((key, value) -> {
- Map<Integer, List<SummaryInformationDTO>> 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<DeptAssessmentDeclarationComplete> qwComplete = new QueryWrapper<>();
- if (StringUtils.isNotEmpty(id)) {
- qwComplete.lambda().eq(DeptAssessmentDeclarationComplete::getAssessmentDeclarationId, id);
- }
- int countComplete = deptAssessmentDeclarationCompleteService.list(qwComplete).size();
- if (countComplete > 0) {
- QueryWrapper<DeptAssessmentDeclarationContent> 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<PostUserDTO> 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<PostDTO> 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<PostUserDTO> 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);
- }
- }
|