DeptAssessmentDeclarationController.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. package com.ims.eval.controller;
  2. import cn.hutool.core.convert.Convert;
  3. import cn.hutool.core.util.ObjectUtil;
  4. import cn.hutool.json.JSONArray;
  5. import cn.hutool.json.JSONUtil;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  8. import com.baomidou.mybatisplus.core.metadata.IPage;
  9. import com.ims.common.utils.StringUtils;
  10. import com.ims.eval.config.CustomException;
  11. import com.ims.eval.entity.DeptAssessmentDeclaration;
  12. import com.ims.eval.entity.DeptAssessmentDeclarationComplete;
  13. import com.ims.eval.entity.DeptAssessmentDeclarationContent;
  14. import com.ims.eval.entity.EvaluationDept;
  15. import com.ims.eval.entity.dto.request.*;
  16. import com.ims.eval.entity.dto.result.R;
  17. import com.ims.eval.service.*;
  18. import com.ims.eval.service.custom.PostService;
  19. import com.ims.eval.service.custom.PostUserService;
  20. import com.ims.eval.util.ExcelUtil;
  21. import com.ims.eval.util.ExcelUtils;
  22. import lombok.extern.slf4j.Slf4j;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.web.bind.annotation.*;
  25. import org.springframework.web.multipart.MultipartFile;
  26. import javax.servlet.http.HttpServletRequest;
  27. import javax.servlet.http.HttpServletResponse;
  28. import java.io.InputStream;
  29. import java.net.URLEncoder;
  30. import java.util.*;
  31. import java.util.stream.Collectors;
  32. /**
  33. * 绩效结果考核申报
  34. *
  35. * @author hlf
  36. * @date 2023/5/29 15:15
  37. * 文件说明:
  38. */
  39. @Slf4j
  40. @RestController
  41. @RequestMapping("//evaluation-dept-ad")
  42. public class DeptAssessmentDeclarationController {
  43. @Autowired
  44. private IDeptAssessmentDeclarationService deptAssessmentDeclarationService;
  45. @Autowired
  46. private IDeptAssessmentDeclarationContentService deptAssessmentDeclarationContentService;
  47. @Autowired
  48. private IDeptAssessmentDeclarationCompleteService deptAssessmentDeclarationCompleteService;
  49. @Autowired
  50. private IEvaluationDeptService evaluationDeptService;
  51. @Autowired
  52. private IUserService userService;
  53. @Autowired
  54. private PostService postService;
  55. @Autowired
  56. private PostUserService postUserService;
  57. @Autowired
  58. private HttpServletRequest request;
  59. /**
  60. * 绩效结果考核申报列表信息(分页)
  61. *
  62. * @param pageNum 当前记录起始索引
  63. * @param pageSize 每页显示记录数
  64. * @param orderNumber 单号
  65. * @param deptName 部门名称
  66. * @param annual 年度
  67. * @param declarationMonth 申报月份
  68. * @return 结果
  69. */
  70. @GetMapping(value = "/list")
  71. public R list(
  72. @RequestParam(value = "pageNum") Integer pageNum,
  73. @RequestParam(value = "pageSize") Integer pageSize,
  74. @RequestParam(value = "deptId") String deptId,
  75. @RequestParam(value = "orderNumber", required = false) String orderNumber,
  76. @RequestParam(value = "deptName", required = false) String deptName,
  77. @RequestParam(value = "annual", required = false) Integer annual,
  78. @RequestParam(value = "declarationMonth", required = false) Integer declarationMonth) {
  79. IPage<DeptAssessmentDeclaration> list = deptAssessmentDeclarationService.listPage(pageNum, pageSize, deptId, orderNumber, deptName, annual, declarationMonth,request);
  80. return R.ok().data(list);
  81. }
  82. /**
  83. * 绩效结果考核申报信息
  84. *
  85. * @return 结果
  86. */
  87. @GetMapping(value = "/listAll")
  88. public R listAll() {
  89. List<DeptAssessmentDeclaration> list = deptAssessmentDeclarationService.list();
  90. return R.ok().data(list);
  91. }
  92. /**
  93. * 新增绩效结果考核申报信息
  94. *
  95. * @param deptAssessmentDeclaration 绩效结果考核申报实体
  96. * @return 结果
  97. */
  98. @PostMapping(value = "/save")
  99. public R addAll(@RequestBody DeptAssessmentDeclaration deptAssessmentDeclaration, HttpServletRequest request) {
  100. try {
  101. QueryWrapper<DeptAssessmentDeclaration> qw = new QueryWrapper<>();
  102. if (StringUtils.isNotEmpty(deptAssessmentDeclaration.getDeptId())) {
  103. qw.lambda().eq(DeptAssessmentDeclaration::getDeptId, deptAssessmentDeclaration.getDeptId());
  104. }
  105. if (null != deptAssessmentDeclaration.getAnnual()) {
  106. qw.lambda().eq(DeptAssessmentDeclaration::getAnnual, deptAssessmentDeclaration.getAnnual());
  107. }
  108. if (null != deptAssessmentDeclaration.getDeclarationMonth()) {
  109. qw.lambda().eq(DeptAssessmentDeclaration::getDeclarationMonth, deptAssessmentDeclaration.getDeclarationMonth());
  110. }
  111. DeptAssessmentDeclaration assessmentDeclaration = deptAssessmentDeclarationService.getOne(qw);
  112. if (ObjectUtil.isNotNull(assessmentDeclaration)) {
  113. return R.error(deptAssessmentDeclaration.getDeptName() + deptAssessmentDeclaration.getAnnual() + "年" + deptAssessmentDeclaration.getDeclarationMonth() + "月绩效结果考核申报已存在!");
  114. }
  115. boolean b = deptAssessmentDeclarationService.save(deptAssessmentDeclaration, request);
  116. if (b) {
  117. return R.ok().data(b);
  118. } else {
  119. return R.error("保存失败!");
  120. }
  121. } catch (CustomException e) {
  122. return R.customError(e.getMessage()).data("失败!");
  123. }
  124. }
  125. /**
  126. * 获取部门领导
  127. *
  128. * @return 结果
  129. */
  130. @GetMapping(value = "/getDepartmentLeader/{id}")
  131. public R getDepartmentLeader(@PathVariable String id) {
  132. QueryWrapper<EvaluationDept> qw = new QueryWrapper<>();
  133. if (StringUtils.isNotEmpty(id)) {
  134. qw.lambda().like(EvaluationDept::getDeptId, id);
  135. }
  136. EvaluationDept evaluationDept = evaluationDeptService.getOne(qw);
  137. return R.ok().data(evaluationDept);
  138. }
  139. /**
  140. * 修改绩效结果考核申报信息
  141. *
  142. * @param deptAssessmentDeclaration 绩效结果考核申报实体
  143. * @return 结果
  144. */
  145. @PostMapping(value = "/modify")
  146. public R modify(@RequestBody DeptAssessmentDeclaration deptAssessmentDeclaration) {
  147. try {
  148. boolean b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration);
  149. if (b) {
  150. return R.ok().data(b);
  151. } else {
  152. return R.error("修改失败!");
  153. }
  154. } catch (CustomException e) {
  155. return R.customError(e.getMessage()).data("失败!");
  156. }
  157. }
  158. /**
  159. * 批量删除绩效结果考核申报信息
  160. *
  161. * @param ids 主键s
  162. * @return 结果
  163. */
  164. @PostMapping(value = "/removeAll/{ids}")
  165. public R deleteAll(@PathVariable("ids") String ids) {
  166. try {
  167. String[] strings = ids.split(",");
  168. boolean b = deptAssessmentDeclarationService.removeByIds(Arrays.asList(strings));
  169. if (b) {
  170. return R.ok().data(b);
  171. } else {
  172. return R.error("删除失败!");
  173. }
  174. } catch (CustomException e) {
  175. return R.customError(e.getMessage()).data("失败!");
  176. }
  177. }
  178. /**
  179. * 详情-头部信息
  180. *
  181. * @param id 业务主键
  182. * @return 结果
  183. */
  184. @GetMapping(value = "/detailsHead/{id}")
  185. public R detailsHead(@PathVariable("id") String id) {
  186. DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
  187. return R.ok().data(deptAssessmentDeclaration);
  188. }
  189. /**
  190. * 详情
  191. *
  192. * @param id 业务主键
  193. * @return 结果
  194. */
  195. @GetMapping(value = "/details/{id}")
  196. public R details(@PathVariable("id") String id) {
  197. Map<String, List<Object>> map = new HashMap<>();
  198. List<DeptAssessmentDeclarationContent> contentList = deptAssessmentDeclarationContentService.detailsList(id);
  199. map.put("ygydkhxs", Collections.singletonList(contentList));
  200. List<DeptAssessmentDeclarationComplete> completeList = deptAssessmentDeclarationCompleteService.detailsList(id);
  201. map.put("byzygzwcqk", Collections.singletonList(completeList));
  202. return R.ok().data(map);
  203. }
  204. /**
  205. * 左侧详情-修改/新增
  206. *
  207. * @param deptAssessmentDeclarationContentList 修改内容
  208. * @return 结果
  209. */
  210. @PostMapping(value = "/updateContent")
  211. public R updateContent(@RequestBody List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList) {
  212. try {
  213. boolean b = deptAssessmentDeclarationContentService.saveOrUpdateBatch(deptAssessmentDeclarationContentList);
  214. if (b) {
  215. return R.ok().data(b);
  216. } else {
  217. return R.error("保存失败,人员重复或人员信息不完善!");
  218. }
  219. } catch (CustomException e) {
  220. return R.customError(e.getMessage()).data("失败!");
  221. }
  222. }
  223. /**
  224. * 右侧详情-修改/新增
  225. *
  226. * @param deptAssessmentDeclarationCompleteList 修改内容
  227. * @return 结果
  228. */
  229. @PostMapping(value = "/updateComplete")
  230. public R updateComplete(@RequestBody List<DeptAssessmentDeclarationComplete> deptAssessmentDeclarationCompleteList) {
  231. try {
  232. boolean b = deptAssessmentDeclarationCompleteService.saveOrUpdateBatch(deptAssessmentDeclarationCompleteList);
  233. if (b) {
  234. return R.ok().data(b);
  235. } else {
  236. return R.error("新增/修改失败!");
  237. }
  238. } catch (CustomException e) {
  239. return R.customError(e.getMessage()).data("失败!");
  240. }
  241. }
  242. /**
  243. * 左侧详情-批量删除
  244. *
  245. * @param ids 主键
  246. * @return 结果
  247. */
  248. @GetMapping(value = "/deleteContent/{ids}")
  249. public R deleteContent(@PathVariable String ids) {
  250. try {
  251. String[] strings = ids.split(",");
  252. boolean b = deptAssessmentDeclarationContentService.removeByIds(Arrays.asList(strings));
  253. if (b) {
  254. return R.ok().data(b);
  255. } else {
  256. return R.error("删除失败!");
  257. }
  258. } catch (CustomException e) {
  259. return R.customError(e.getMessage()).data("失败!");
  260. }
  261. }
  262. /**
  263. * 右侧详情-批量删除
  264. *
  265. * @param ids 主键
  266. * @return 结果
  267. */
  268. @GetMapping(value = "/deleteComplete/{ids}")
  269. public R deleteComplete(@PathVariable String ids) {
  270. try {
  271. String[] strings = ids.split(",");
  272. boolean b = deptAssessmentDeclarationCompleteService.removeByIds(Arrays.asList(strings));
  273. if (b) {
  274. return R.ok().data(b);
  275. } else {
  276. return R.error("删除失败!");
  277. }
  278. } catch (CustomException e) {
  279. return R.customError(e.getMessage()).data("失败!");
  280. }
  281. }
  282. /**
  283. * 导入
  284. *
  285. * @param file 文件
  286. * @return 结果
  287. */
  288. @PostMapping(value = "/import")
  289. public R importData(@RequestParam("file") MultipartFile file, @RequestParam("id") String id) {
  290. if (!file.isEmpty()) {
  291. try {
  292. //成功条数
  293. int successCount = 0;
  294. //更新条数
  295. int renewalCount = 0;
  296. //失败条数
  297. int loseCount = 0;
  298. //获取原始的文件名
  299. String originalFilename = file.getOriginalFilename();
  300. //获取文件类型
  301. String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
  302. //默认从第一行开始读取
  303. int startRows = 1;
  304. //获取输入流
  305. InputStream is = file.getInputStream();
  306. //Excel导入导出的单元类
  307. List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
  308. //遍历Excel表每一行的数据
  309. for (String[] str : strings) {
  310. DeptAssessmentDeclarationContent deptAssessmentDeclarationContent = new DeptAssessmentDeclarationContent();
  311. deptAssessmentDeclarationContent.setAssessmentDeclarationId(id);
  312. deptAssessmentDeclarationContent.setEmployeeNo(str[0]);
  313. JSONObject jsonArr = userService.getLoginNameByUserInfo(str[0], request);
  314. if ("操作成功".equals(String.valueOf(jsonArr.get("msg")))){
  315. JSONObject data = (JSONObject) jsonArr.get("data");
  316. deptAssessmentDeclarationContent.setEmployeeId(String.valueOf(data.get("id")));
  317. deptAssessmentDeclarationContent.setEmployeeName(String.valueOf(data.get("name")));
  318. }
  319. deptAssessmentDeclarationContent.setSuggestedValue(str[2]);
  320. deptAssessmentDeclarationContent.setSerialNumber(Convert.toInt(str[3]));
  321. QueryWrapper<DeptAssessmentDeclarationContent> qw = new QueryWrapper<>();
  322. if (StringUtils.isNotEmpty(deptAssessmentDeclarationContent.getAssessmentDeclarationId())) {
  323. qw.lambda().like(DeptAssessmentDeclarationContent::getAssessmentDeclarationId, deptAssessmentDeclarationContent.getAssessmentDeclarationId());
  324. }
  325. if (StringUtils.isNotEmpty(deptAssessmentDeclarationContent.getEmployeeNo())) {
  326. qw.lambda().like(DeptAssessmentDeclarationContent::getEmployeeNo, deptAssessmentDeclarationContent.getEmployeeNo());
  327. }
  328. if (StringUtils.isNotEmpty(deptAssessmentDeclarationContent.getEmployeeId())) {
  329. qw.lambda().like(DeptAssessmentDeclarationContent::getEmployeeId, deptAssessmentDeclarationContent.getEmployeeId());
  330. }
  331. List<DeptAssessmentDeclarationContent> objList = deptAssessmentDeclarationContentService.list(qw);
  332. if (objList.size() == 1) {//修改
  333. deptAssessmentDeclarationContent.setId(objList.get(0).getId());
  334. deptAssessmentDeclarationContentService.updateById(deptAssessmentDeclarationContent);
  335. renewalCount++;
  336. } else if (objList.size() == 0) {//新增
  337. deptAssessmentDeclarationContentService.save(deptAssessmentDeclarationContent);
  338. successCount++;
  339. } else {
  340. loseCount++;
  341. }
  342. }
  343. String msg = "导入成功,本次新增" + successCount + "条,更新" + renewalCount + "条,失败" + loseCount + "条数据。";
  344. return R.ok().message(msg);
  345. } catch (Exception e) {
  346. log.error("错误", e);
  347. return R.customError(e.getMessage()).data("失败!");
  348. }
  349. }
  350. return R.error("上传文件为空!");
  351. }
  352. /**
  353. * 修改状态
  354. *
  355. * @param id 主键
  356. * @param stage 状态
  357. * @return 结果
  358. */
  359. @PostMapping(value = "/targetStart")
  360. public R targetStart(@RequestParam(value = "id") String id,
  361. @RequestParam(value = "stage") String stage) {
  362. try {
  363. DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
  364. deptAssessmentDeclaration.setStage(stage);
  365. boolean b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration);
  366. if (b) {
  367. return R.ok().data(b);
  368. } else {
  369. return R.error("失败!");
  370. }
  371. } catch (CustomException e) {
  372. return R.customError(e.getMessage()).data("失败!");
  373. }
  374. }
  375. /**
  376. * 生成报表
  377. *
  378. * @param id 主键
  379. * @param response response
  380. * @throws Exception 异常
  381. */
  382. @GetMapping(value = "/generateReport/{id}")
  383. public void generateReport(@PathVariable("id") String id, HttpServletResponse response) throws Exception {
  384. response.setContentType("application/vnd.ms-excel;charset=UTF-8");
  385. response.setHeader("Content-disposition", "attachment; filename=".concat(URLEncoder.encode("公司本部部门及员工月度绩效考核结果申报表.xlsx", "UTF-8")));
  386. response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  387. response.setHeader("Pragma", "no-cache");
  388. response.setDateHeader("Expires", 0);
  389. List<EmployeeDTO> employeeDTOList = new ArrayList<>();
  390. // 添加员工信息
  391. QueryWrapper<DeptAssessmentDeclarationContent> qw = new QueryWrapper<>();
  392. if (StringUtils.isNotEmpty(id)) {
  393. qw.lambda().like(DeptAssessmentDeclarationContent::getAssessmentDeclarationId, id);
  394. }
  395. List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.list(qw);
  396. for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) {
  397. EmployeeDTO employeeDTO = new EmployeeDTO();
  398. employeeDTO.setName(deptAssessmentDeclarationContent.getEmployeeName());
  399. employeeDTO.setCoefficient(deptAssessmentDeclarationContent.getSuggestedValue());
  400. employeeDTOList.add(employeeDTO);
  401. }
  402. DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
  403. String departmentName = deptAssessmentDeclaration.getDeptName();
  404. String month = String.valueOf(deptAssessmentDeclaration.getDeclarationMonth());
  405. String level = deptAssessmentDeclaration.getRatingGrade();
  406. String leader = deptAssessmentDeclaration.getDeptLeaderName();
  407. String declarationReason = deptAssessmentDeclaration.getDeclarationReason();
  408. ExcelUtils.createExcel(employeeDTOList, departmentName, month, level, leader, declarationReason, response.getOutputStream());
  409. }
  410. /**
  411. * 统计汇总数据
  412. *
  413. * @param startTime 开始时间
  414. * @param endTime 结束时间
  415. * @param deptId 部门主键
  416. * @param employeeNo 人员编号
  417. */
  418. @GetMapping(value = "/statisticalSummary")
  419. public R statisticalSummary(@RequestParam(value = "startTime") String startTime,
  420. @RequestParam(value = "endTime") String endTime,
  421. @RequestParam(value = "deptId") String deptId,
  422. @RequestParam(value = "employeeNo") String employeeNo) {
  423. List<SummaryInformationDTO> summaryInformationDTOList = new ArrayList<>();
  424. String[] startTimeArr = new String[2];
  425. String[] endTimeArr = new String[2];
  426. if (startTime.length() > 0) {
  427. startTimeArr = startTime.split("-");
  428. }
  429. if (endTime.length() > 0) {
  430. endTimeArr = endTime.split("-");
  431. }
  432. QueryWrapper<DeptAssessmentDeclaration> qw = new QueryWrapper<>();
  433. if (StringUtils.isNotEmpty(startTimeArr) && StringUtils.isNotEmpty(endTimeArr)) {
  434. qw.lambda().between(DeptAssessmentDeclaration::getAnnual, Integer.parseInt(startTimeArr[0]), Integer.parseInt(endTimeArr[0]));
  435. qw.lambda().between(DeptAssessmentDeclaration::getDeclarationMonth, Integer.parseInt(startTimeArr[1]), Integer.parseInt(endTimeArr[1]));
  436. }
  437. if (StringUtils.isNotEmpty(deptId)) {
  438. qw.lambda().eq(DeptAssessmentDeclaration::getDeptId, deptId);
  439. }
  440. List<DeptAssessmentDeclaration> deptAssessmentDeclarationList = deptAssessmentDeclarationService.list(qw);
  441. for (DeptAssessmentDeclaration deptAssessmentDeclaration : deptAssessmentDeclarationList) {
  442. QueryWrapper<EvaluationDept> qwDept = new QueryWrapper<>();
  443. if (StringUtils.isNotEmpty(deptAssessmentDeclaration.getDeptId())) {
  444. qwDept.lambda().eq(EvaluationDept::getDeptId, deptAssessmentDeclaration.getDeptId());
  445. }
  446. EvaluationDept evaluationDept = evaluationDeptService.getOne(qwDept);
  447. List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.detailsList(deptAssessmentDeclaration.getId());
  448. for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) {
  449. if (StringUtils.isNotEmpty(employeeNo)) {
  450. if (employeeNo.equals(deptAssessmentDeclarationContent.getEmployeeNo())) {
  451. SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO();
  452. summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo());
  453. summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName());
  454. summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue());
  455. summaryInformationDTO.setDeclarationMonth(deptAssessmentDeclaration.getDeclarationMonth());
  456. summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName());
  457. summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade());
  458. if (null != evaluationDept) {
  459. summaryInformationDTO.setSerialNumber(evaluationDept.getSerialNumber());
  460. }
  461. summaryInformationDTOList.add(summaryInformationDTO);
  462. }
  463. } else {
  464. SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO();
  465. summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo());
  466. summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName());
  467. summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue());
  468. summaryInformationDTO.setDeclarationMonth(deptAssessmentDeclaration.getDeclarationMonth());
  469. summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName());
  470. summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade());
  471. if (null != evaluationDept) {
  472. summaryInformationDTO.setSerialNumber(evaluationDept.getSerialNumber());
  473. }
  474. summaryInformationDTOList.add(summaryInformationDTO);
  475. }
  476. }
  477. }
  478. List<SummaryInformationDTO> list = new ArrayList<>();
  479. Map<String, List<SummaryInformationDTO>> map = summaryInformationDTOList.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getEmployeeNo));
  480. map.forEach((key, value) -> {
  481. Map<Integer, List<SummaryInformationDTO>> map1 = value.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getDeclarationMonth));
  482. map1.forEach((key1, value1) -> {
  483. for (SummaryInformationDTO summaryInformationDTO : value1) {
  484. summaryInformationDTO.setDeclarationsNumber(String.valueOf(value1.size()));
  485. }
  486. list.addAll(value1);
  487. });
  488. });
  489. list.sort(Comparator.comparing(SummaryInformationDTO::getSerialNumber, Comparator.nullsLast(Integer::compareTo)));
  490. return R.ok().data(list);
  491. }
  492. /**
  493. * 生成统计汇总报表
  494. *
  495. * @param startTime 开始时间
  496. * @param endTime 结束时间
  497. * @param deptId 部门主键
  498. * @param employeeNo 人员编号
  499. * @param response response
  500. * @throws Exception 异常
  501. */
  502. @GetMapping(value = "/generateStatisticalSummaryReports")
  503. public void generateStatisticalSummaryReports(@RequestParam(value = "startTime") String startTime,
  504. @RequestParam(value = "endTime") String endTime,
  505. @RequestParam(value = "deptId") String deptId,
  506. @RequestParam(value = "employeeNo") String employeeNo,
  507. HttpServletResponse response) throws Exception {
  508. response.setContentType("application/vnd.ms-excel;charset=UTF-8");
  509. response.setHeader("Content-disposition", "attachment; filename=".concat(URLEncoder.encode("绩效结果考核申报汇总表.xlsx", "UTF-8")));
  510. response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
  511. response.setHeader("Pragma", "no-cache");
  512. response.setDateHeader("Expires", 0);
  513. List<SummaryInformationDTO> summaryInformationDTOList = new ArrayList<>();
  514. String[] startTimeArr = new String[2];
  515. String[] endTimeArr = new String[2];
  516. if (startTime.length() > 0) {
  517. startTimeArr = startTime.split("-");
  518. }
  519. if (endTime.length() > 0) {
  520. endTimeArr = endTime.split("-");
  521. }
  522. QueryWrapper<DeptAssessmentDeclaration> qw = new QueryWrapper<>();
  523. if (StringUtils.isNotEmpty(startTimeArr) && StringUtils.isNotEmpty(endTimeArr)) {
  524. qw.lambda().between(DeptAssessmentDeclaration::getAnnual, Integer.parseInt(startTimeArr[0]), Integer.parseInt(endTimeArr[0]));
  525. qw.lambda().between(DeptAssessmentDeclaration::getDeclarationMonth, Integer.parseInt(startTimeArr[1]), Integer.parseInt(endTimeArr[1]));
  526. }
  527. if (StringUtils.isNotEmpty(deptId)) {
  528. qw.lambda().eq(DeptAssessmentDeclaration::getDeptId, deptId);
  529. }
  530. List<DeptAssessmentDeclaration> deptAssessmentDeclarationList = deptAssessmentDeclarationService.list(qw);
  531. for (DeptAssessmentDeclaration deptAssessmentDeclaration : deptAssessmentDeclarationList) {
  532. QueryWrapper<EvaluationDept> qwDept = new QueryWrapper<>();
  533. if (StringUtils.isNotEmpty(deptAssessmentDeclaration.getDeptId())) {
  534. qwDept.lambda().eq(EvaluationDept::getDeptId, deptAssessmentDeclaration.getDeptId());
  535. }
  536. EvaluationDept evaluationDept = evaluationDeptService.getOne(qwDept);
  537. List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.detailsList(deptAssessmentDeclaration.getId());
  538. for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) {
  539. if (StringUtils.isNotEmpty(employeeNo)) {
  540. if (employeeNo.equals(deptAssessmentDeclarationContent.getEmployeeNo())) {
  541. SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO();
  542. summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo());
  543. summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName());
  544. summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue());
  545. summaryInformationDTO.setDeclarationMonth(deptAssessmentDeclaration.getDeclarationMonth());
  546. summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName());
  547. summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade());
  548. if (null != evaluationDept) {
  549. summaryInformationDTO.setSerialNumber(evaluationDept.getSerialNumber());
  550. }
  551. summaryInformationDTOList.add(summaryInformationDTO);
  552. }
  553. } else {
  554. SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO();
  555. summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo());
  556. summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName());
  557. summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue());
  558. summaryInformationDTO.setDeclarationMonth(deptAssessmentDeclaration.getDeclarationMonth());
  559. summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName());
  560. summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade());
  561. if (null != evaluationDept) {
  562. summaryInformationDTO.setSerialNumber(evaluationDept.getSerialNumber());
  563. }
  564. summaryInformationDTOList.add(summaryInformationDTO);
  565. }
  566. }
  567. }
  568. List<SummaryInformationDTO> list = new ArrayList<>();
  569. Map<String, List<SummaryInformationDTO>> map = summaryInformationDTOList.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getEmployeeNo));
  570. map.forEach((key, value) -> {
  571. Map<Integer, List<SummaryInformationDTO>> map1 = value.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getDeclarationMonth));
  572. map1.forEach((key1, value1) -> {
  573. for (SummaryInformationDTO summaryInformationDTO : value1) {
  574. summaryInformationDTO.setDeclarationsNumber(String.valueOf(value1.size()));
  575. }
  576. list.addAll(value1);
  577. });
  578. });
  579. list.sort(Comparator.comparing(SummaryInformationDTO::getSerialNumber, Comparator.nullsLast(Integer::compareTo)));
  580. ExcelUtils.createCollectExcel(list, startTimeArr[0], startTimeArr[1], endTimeArr[0], endTimeArr[1], response.getOutputStream());
  581. }
  582. /**
  583. * 参与考核人数
  584. *
  585. * @param id 主键
  586. * @return 结果
  587. */
  588. @GetMapping(value = "/participantsNumber/{id}")
  589. public R participantsNumber(@PathVariable String id) {
  590. QueryWrapper<DeptAssessmentDeclarationComplete> qwComplete = new QueryWrapper<>();
  591. if (StringUtils.isNotEmpty(id)) {
  592. qwComplete.lambda().eq(DeptAssessmentDeclarationComplete::getAssessmentDeclarationId, id);
  593. }
  594. int countComplete = deptAssessmentDeclarationCompleteService.list(qwComplete).size();
  595. if (countComplete > 0) {
  596. QueryWrapper<DeptAssessmentDeclarationContent> qwContent = new QueryWrapper<>();
  597. if (StringUtils.isNotEmpty(id)) {
  598. qwContent.lambda().eq(DeptAssessmentDeclarationContent::getAssessmentDeclarationId, id);
  599. }
  600. int countContent = deptAssessmentDeclarationContentService.list(qwContent).size();
  601. return R.ok().data(countContent);
  602. } else {
  603. return R.error("未添加工作完成情况!");
  604. }
  605. }
  606. /**
  607. * 添加审批领导
  608. *
  609. * @param id 主键
  610. * @param employeeNo 用户编号
  611. * @return 结果
  612. */
  613. @PostMapping(value = "/addApprovalLeader")
  614. public R addApprovalLeader(@RequestParam(value = "id") String id,
  615. @RequestParam(value = "employeeNo") String employeeNo) {
  616. boolean b = false;
  617. JSONObject jsonArr = userService.getLoginNameByUserInfo(employeeNo, request);
  618. JSONObject data = (JSONObject) jsonArr.get("data");
  619. if (data.toJSONString().length()>0){
  620. DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
  621. if (null != deptAssessmentDeclaration) {
  622. deptAssessmentDeclaration.setDeptLeaderId(String.valueOf(data.get("id")));
  623. deptAssessmentDeclaration.setDeptLeaderNo(String.valueOf(data.get("no")));
  624. deptAssessmentDeclaration.setDeptLeaderName(String.valueOf(data.get("name")));
  625. b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration);
  626. }
  627. }
  628. if (b) {
  629. return R.ok().data(b);
  630. } else {
  631. return R.error("添加审批领导失败!");
  632. }
  633. }
  634. /**
  635. * 添加复批领导
  636. *
  637. * @param id 主键
  638. * @param employeeNo 用户编号
  639. * @return 结果
  640. */
  641. @PostMapping(value = "/addRepeatBatchLeader")
  642. public R addRepeatBatchLeader(@RequestParam(value = "id") String id,
  643. @RequestParam(value = "employeeNo") String employeeNo) {
  644. boolean b = false;
  645. JSONObject jsonArr = userService.getLoginNameByUserInfo(employeeNo, request);
  646. JSONObject data = (JSONObject) jsonArr.get("data");
  647. if ("操作成功".equals(String.valueOf(data.get("msg")))){
  648. DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
  649. if (null != deptAssessmentDeclaration) {
  650. deptAssessmentDeclaration.setSeconderId(String.valueOf(data.get("id")));
  651. deptAssessmentDeclaration.setSeconderNo(String.valueOf(data.get("no")));
  652. deptAssessmentDeclaration.setSeconderName(String.valueOf(data.get("name")));
  653. b = deptAssessmentDeclarationService.updateById(deptAssessmentDeclaration);
  654. }
  655. }
  656. if (b) {
  657. return R.ok().data(b);
  658. } else {
  659. return R.error("添加复批领导失败!");
  660. }
  661. }
  662. /**
  663. * 获取审批领导
  664. *
  665. * @param id 部门主键
  666. * @return 结果
  667. */
  668. @GetMapping(value = "/obtainApprovalLeader/{id}")
  669. public R obtainApprovalLeader(@PathVariable String id) {
  670. List<PostUserDTO> list = new ArrayList<>();
  671. Object postList = postService.getPostList(1, 500, id, request);
  672. if (null != postList) {
  673. JSONObject postJsonArr = (JSONObject) postList;
  674. JSONArray postArray = JSONUtil.parseArray(postJsonArr.get("records"));
  675. List<PostDTO> postArrList = JSONUtil.toList(postArray, PostDTO.class);
  676. for (PostDTO post : postArrList) {
  677. if (post.getName().contains("主任")) {
  678. Object postPersonnelList = postUserService.getPostUserList(1, 500, post.getId(), request);
  679. if (null != postPersonnelList) {
  680. JSONObject postPersonnelJsonArr = (JSONObject) postPersonnelList;
  681. JSONArray postPersonnelArray = JSONUtil.parseArray(postPersonnelJsonArr.get("records"));
  682. List<PostUserDTO> userArrList = JSONUtil.toList(postPersonnelArray, PostUserDTO.class);
  683. if (userArrList.size() > 0) {
  684. list.addAll(userArrList);
  685. }
  686. }
  687. }
  688. }
  689. }
  690. return R.ok().data(list);
  691. }
  692. /**
  693. * 获取流程详情
  694. *
  695. * @param instId 实例ID
  696. * @return 结果
  697. */
  698. @GetMapping(value = "processInformation/{instId}")
  699. public R processInformation(@PathVariable String instId) {
  700. Object obj = null;
  701. try {
  702. obj = deptAssessmentDeclarationService.processInformation(instId, request);
  703. } catch (Exception e) {
  704. log.error("错误", e);
  705. return null;
  706. }
  707. return R.ok().data(obj);
  708. }
  709. }