Browse Source

修改绩效结果考核申报问题,增加统计汇总报表功能

hlf 1 year ago
parent
commit
8a8337f9b8

+ 110 - 19
ims-service/ims-eval/src/main/java/com/ims/eval/controller/DeptAssessmentDeclarationController.java

@@ -13,6 +13,7 @@ import com.ims.eval.entity.DeptAssessmentDeclaration;
 import com.ims.eval.entity.DeptAssessmentDeclarationContent;
 import com.ims.eval.entity.EvaluationDept;
 import com.ims.eval.entity.dto.request.EmployeeDTO;
+import com.ims.eval.entity.dto.request.SummaryInformationDTO;
 import com.ims.eval.entity.dto.request.UserDTO;
 import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.IDeptAssessmentDeclarationContentService;
@@ -33,6 +34,8 @@ import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 绩效结果考核申报
@@ -67,7 +70,7 @@ public class DeptAssessmentDeclarationController {
 	 * @param pageNum          当前记录起始索引
 	 * @param pageSize         每页显示记录数
 	 * @param orderNumber      单号
-	 * @param deptId           部门主键
+	 * @param deptName         部门名称
 	 * @param annual           年度
 	 * @param declarationMonth 申报月份
 	 * @return 结果
@@ -77,10 +80,10 @@ public class DeptAssessmentDeclarationController {
 		@RequestParam(value = "pageNum") Integer pageNum,
 		@RequestParam(value = "pageSize") Integer pageSize,
 		@RequestParam(value = "orderNumber", required = false) String orderNumber,
-		@RequestParam(value = "deptId", required = false) String deptId,
+		@RequestParam(value = "deptName", required = false) String deptName,
 		@RequestParam(value = "annual", required = false) String annual,
 		@RequestParam(value = "declarationMonth", required = false) String declarationMonth) {
-		IPage<DeptAssessmentDeclaration> list = deptAssessmentDeclarationService.listPage(pageNum, pageSize, orderNumber, deptId, annual, declarationMonth);
+		IPage<DeptAssessmentDeclaration> list = deptAssessmentDeclarationService.listPage(pageNum, pageSize, orderNumber, deptName, annual, declarationMonth);
 		return R.ok().data(list);
 	}
 
@@ -230,15 +233,16 @@ public class DeptAssessmentDeclarationController {
 	}
 
 	/**
-	 * 详情-删除
+	 * 详情-批量删除
 	 *
-	 * @param id 主键
+	 * @param ids 主键
 	 * @return 结果
 	 */
-	@GetMapping(value = "/delete/{id}")
-	public R delete(@PathVariable String id) {
+	@GetMapping(value = "/delete/{ids}")
+	public R delete(@PathVariable String ids) {
 		try {
-			boolean b = deptAssessmentDeclarationContentService.removeById(id);
+			String[] strings = ids.split(",");
+			boolean b = deptAssessmentDeclarationContentService.removeByIds(Arrays.asList(strings));
 			if (b) {
 				return R.ok().data(b);
 			} else {
@@ -275,17 +279,14 @@ public class DeptAssessmentDeclarationController {
 					DeptAssessmentDeclarationContent deptAssessmentDeclarationContent = new DeptAssessmentDeclarationContent();
 					deptAssessmentDeclarationContent.setAssessmentDeclarationId(id);
 					deptAssessmentDeclarationContent.setEmployeeNo(str[0]);
-					DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
-					if (ObjectUtil.isNotNull(deptAssessmentDeclaration)) {
-						JSONObject jsonArr = userService.pageList(1, 1000, deptAssessmentDeclaration.getDeptId(), "", "", "", "", "", request);
-						JSONObject jsonArr1 = (JSONObject) jsonArr.get("data");
-						JSONArray array = JSONUtil.parseArray(jsonArr1.get("records"));
-						List<UserDTO> userList = JSONUtil.toList(array, UserDTO.class);
-						UserDTO user = userList.stream().filter(item -> item.getNo().equals(str[0])).findFirst().orElse(null);
-						if (ObjectUtil.isNotNull(user)) {
-							deptAssessmentDeclarationContent.setEmployeeId(user.getId());
-							deptAssessmentDeclarationContent.setEmployeeName(user.getName());
-						}
+					JSONObject jsonArr = userService.pageList(1, 1000, "", "", "", "", "", "", request);
+					JSONObject jsonArr1 = (JSONObject) jsonArr.get("data");
+					JSONArray array = JSONUtil.parseArray(jsonArr1.get("records"));
+					List<UserDTO> userList = JSONUtil.toList(array, UserDTO.class);
+					UserDTO user = userList.stream().filter(item -> item.getNo().equals(str[0])).findFirst().orElse(null);
+					if (ObjectUtil.isNotNull(user)) {
+						deptAssessmentDeclarationContent.setEmployeeId(user.getId());
+						deptAssessmentDeclarationContent.setEmployeeName(user.getName());
 					}
 					deptAssessmentDeclarationContent.setSuggestedValue(str[2]);
 					deptAssessmentDeclarationContent.setSerialNumber(Convert.toInt(str[3]));
@@ -296,6 +297,9 @@ public class DeptAssessmentDeclarationController {
 					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());
@@ -380,6 +384,93 @@ public class DeptAssessmentDeclarationController {
 	}
 
 	/**
+	 * 统计汇总数据
+	 *
+	 * @param annual 年度
+	 * @param month  月份
+	 */
+	@GetMapping(value = "/statisticalSummary/{annual}/{month}")
+	public R statisticalSummary(@PathVariable("annual") String annual, @PathVariable("month") String month) {
+		List<SummaryInformationDTO> summaryInformationDTOList = new ArrayList<>();
+		QueryWrapper<DeptAssessmentDeclaration> qw = new QueryWrapper<>();
+		if (StringUtils.isNotEmpty(annual)) {
+			qw.lambda().like(DeptAssessmentDeclaration::getAnnual, annual);
+		}
+		if (StringUtils.isNotEmpty(month)) {
+			qw.lambda().like(DeptAssessmentDeclaration::getDeclarationMonth, month);
+		}
+		List<DeptAssessmentDeclaration> deptAssessmentDeclarationList = deptAssessmentDeclarationService.list(qw);
+		for (DeptAssessmentDeclaration deptAssessmentDeclaration : deptAssessmentDeclarationList) {
+			List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.detailsList(deptAssessmentDeclaration.getId());
+			for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) {
+				SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO();
+				summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo());
+				summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName());
+				summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue());
+				summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName());
+				summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade());
+				summaryInformationDTOList.add(summaryInformationDTO);
+			}
+		}
+		List<SummaryInformationDTO> list = new ArrayList<>();
+		Map<String, List<SummaryInformationDTO>> map = summaryInformationDTOList.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getEmployeeNo));
+		map.forEach((key, value) -> {
+			for (SummaryInformationDTO summaryInformationDTO : value) {
+				summaryInformationDTO.setDeclarationsNumber(String.valueOf(value.size()));
+			}
+			list.addAll(value);
+		});
+		return R.ok().data(list);
+	}
+
+	/**
+	 * 生成统计汇总报表
+	 *
+	 * @param annual   年度
+	 * @param month    月份
+	 * @param response response
+	 * @throws Exception 异常
+	 */
+	@GetMapping(value = "/generateStatisticalSummaryReports/{annual}/{month}")
+	public void generateStatisticalSummaryReports(@PathVariable("annual") String annual, @PathVariable("month") String month, 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<>();
+		QueryWrapper<DeptAssessmentDeclaration> qw = new QueryWrapper<>();
+		if (StringUtils.isNotEmpty(annual)) {
+			qw.lambda().like(DeptAssessmentDeclaration::getAnnual, annual);
+		}
+		if (StringUtils.isNotEmpty(month)) {
+			qw.lambda().like(DeptAssessmentDeclaration::getDeclarationMonth, month);
+		}
+		List<DeptAssessmentDeclaration> deptAssessmentDeclarationList = deptAssessmentDeclarationService.list(qw);
+		for (DeptAssessmentDeclaration deptAssessmentDeclaration : deptAssessmentDeclarationList) {
+			List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList = deptAssessmentDeclarationContentService.detailsList(deptAssessmentDeclaration.getId());
+			for (DeptAssessmentDeclarationContent deptAssessmentDeclarationContent : deptAssessmentDeclarationContentList) {
+				SummaryInformationDTO summaryInformationDTO = new SummaryInformationDTO();
+				summaryInformationDTO.setEmployeeNo(deptAssessmentDeclarationContent.getEmployeeNo());
+				summaryInformationDTO.setEmployeeName(deptAssessmentDeclarationContent.getEmployeeName());
+				summaryInformationDTO.setSuggestedValue(deptAssessmentDeclarationContent.getSuggestedValue());
+				summaryInformationDTO.setReportingDepartment(deptAssessmentDeclaration.getDeptName());
+				summaryInformationDTO.setDeclarationLevel(deptAssessmentDeclaration.getRatingGrade());
+				summaryInformationDTOList.add(summaryInformationDTO);
+			}
+		}
+		List<SummaryInformationDTO> list = new ArrayList<>();
+		Map<String, List<SummaryInformationDTO>> map = summaryInformationDTOList.stream().collect(Collectors.groupingBy(SummaryInformationDTO::getEmployeeNo));
+		map.forEach((key, value) -> {
+			for (SummaryInformationDTO summaryInformationDTO : value) {
+				summaryInformationDTO.setDeclarationsNumber(String.valueOf(value.size()));
+			}
+			list.addAll(value);
+		});
+		ExcelUtils.createCollectExcel(list, annual, month, response.getOutputStream());
+	}
+
+	/**
 	 * 参与考核人数
 	 *
 	 * @param id 主键

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/dao/DeptAssessmentDeclarationMapper.java

@@ -13,6 +13,6 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface DeptAssessmentDeclarationMapper extends BaseMapper<DeptAssessmentDeclaration> {
 
-	IPage<DeptAssessmentDeclaration> selectListPage(Page<DeptAssessmentDeclaration> page, @Param("orderNumber") String orderNumber, @Param("deptId") String deptId, @Param("annual") String annual, @Param("declarationMonth") String declarationMonth);
+	IPage<DeptAssessmentDeclaration> selectListPage(Page<DeptAssessmentDeclaration> page, @Param("orderNumber") String orderNumber, @Param("deptName") String deptName, @Param("annual") String annual, @Param("declarationMonth") String declarationMonth);
 
 }

+ 26 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/request/SummaryInformationDTO.java

@@ -0,0 +1,26 @@
+package com.ims.eval.entity.dto.request;
+
+import lombok.Data;
+
+/**
+ * @author hlf
+ * @date 2023/8/10 9:29
+ * 文件说明:绩效结果考核申报统计汇总报表
+ */
+@Data
+public class SummaryInformationDTO {
+
+	//人员编码
+	private String employeeNo;
+	//姓名
+	private String employeeName;
+	//推荐系数
+	private String suggestedValue;
+	//申报次数
+	private String declarationsNumber;
+	//申报部门
+	private String reportingDepartment;
+	//申报级别
+	private String declarationLevel;
+
+}

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/IDeptAssessmentDeclarationService.java

@@ -14,7 +14,7 @@ import java.util.List;
  */
 public interface IDeptAssessmentDeclarationService extends IService<DeptAssessmentDeclaration> {
 
-	IPage<DeptAssessmentDeclaration> listPage(Integer pageNum, Integer pageSize, String orderNumber, String deptId, String annual, String declarationMonth);
+	IPage<DeptAssessmentDeclaration> listPage(Integer pageNum, Integer pageSize, String orderNumber, String deptName, String annual, String declarationMonth);
 
 	boolean save(DeptAssessmentDeclaration deptAssessmentDeclaration, HttpServletRequest request);
 

+ 5 - 6
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/DeptAssessmentDeclarationServiceImpl.java

@@ -45,13 +45,13 @@ public class DeptAssessmentDeclarationServiceImpl extends ServiceImpl<DeptAssess
 	private IEvaluationDeptService evaluationDeptService;
 
 	@Override
-	public IPage<DeptAssessmentDeclaration> listPage(Integer pageNum, Integer pageSize, String orderNumber, String deptId, String annual, String declarationMonth) {
+	public IPage<DeptAssessmentDeclaration> listPage(Integer pageNum, Integer pageSize, String orderNumber, String deptName, String annual, String declarationMonth) {
 		if (null == pageNum || null == pageSize) {
 			throw new RuntimeException("分页参数为空");
 		}
 		//构造分页构造器
 		Page<DeptAssessmentDeclaration> page = new Page<>(pageNum, pageSize);
-		return baseMapper.selectListPage(page, orderNumber, deptId, annual, declarationMonth);
+		return baseMapper.selectListPage(page, orderNumber, deptName, annual, declarationMonth);
 	}
 
 	@Override
@@ -140,10 +140,9 @@ public class DeptAssessmentDeclarationServiceImpl extends ServiceImpl<DeptAssess
 		for (String id : ids) {
 			DeptAssessmentDeclaration deptAssessmentDeclaration = super.getById(id);
 			if ("流程未启动".equals(deptAssessmentDeclaration.getStage()) || "流程已结束".equals(deptAssessmentDeclaration.getStage())) {
-				b = deptAssessmentDeclarationContentService.removeByAssessmentDeclarationId(id);
-				if (b) {
-					super.removeById(id);
-				}
+				deptAssessmentDeclarationContentService.removeByAssessmentDeclarationId(id);
+				super.removeById(id);
+				b = true;
 			} else {
 				return b;
 			}

+ 88 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/util/ExcelUtils.java

@@ -2,6 +2,7 @@ package com.ims.eval.util;
 
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.ims.eval.entity.dto.request.EmployeeDTO;
+import com.ims.eval.entity.dto.request.SummaryInformationDTO;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -247,6 +248,93 @@ public class ExcelUtils {
 		workbook.close();
 	}
 
+	/**
+	 * 绩效结果考核申报生成报表
+	 *
+	 * @param summaryInformationDTOList 汇总信息类
+	 * @param annual                    年度
+	 * @param month                     月份
+	 * @param outputStream              输出流
+	 * @throws IOException 异常
+	 */
+	public static void createCollectExcel(List<SummaryInformationDTO> summaryInformationDTOList, String annual, String month, OutputStream outputStream) throws IOException {
+		Workbook workbook = new XSSFWorkbook();
+		Sheet sheet = workbook.createSheet("Sheet1");
+
+		// 设置列宽
+		sheet.setColumnWidth(0, 256 * 25);
+
+		//设置合并单元格
+		sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
+
+		// 设置标题
+		Row titleRow = sheet.createRow(0);
+		titleRow.setHeightInPoints(Float.parseFloat("40"));
+		CellStyle titleStyle = createTitleStyle(workbook);
+		Cell titleCell = titleRow.createCell(0);
+		titleCell.setCellValue("绩效结果考核申报汇总表(" + annual + "年" + month + "月)");
+		titleCell.setCellStyle(titleStyle);
+
+		// 设置表格表头
+		Row headerRow = sheet.createRow(1);
+		headerRow.setHeightInPoints(Float.parseFloat("30"));
+		CellStyle headerStyle = createHeaderStyle(workbook, sheet);
+		Cell serialNumberHeader = headerRow.createCell(0);
+		serialNumberHeader.setCellValue("序号");
+		serialNumberHeader.setCellStyle(headerStyle);
+		Cell employeeNoHeader = headerRow.createCell(1);
+		employeeNoHeader.setCellValue("人员编码");
+		employeeNoHeader.setCellStyle(headerStyle);
+		Cell employeeNameHeader = headerRow.createCell(2);
+		employeeNameHeader.setCellValue("姓名");
+		employeeNameHeader.setCellStyle(headerStyle);
+		Cell suggestedValueHeader = headerRow.createCell(3);
+		suggestedValueHeader.setCellValue("推荐系数");
+		suggestedValueHeader.setCellStyle(headerStyle);
+		Cell declarationsNumberHeader = headerRow.createCell(4);
+		declarationsNumberHeader.setCellValue("申报次数");
+		declarationsNumberHeader.setCellStyle(headerStyle);
+		Cell reportingDepartmentHeader = headerRow.createCell(5);
+		reportingDepartmentHeader.setCellValue("申报部门");
+		reportingDepartmentHeader.setCellStyle(headerStyle);
+		Cell declarationLevelHeader = headerRow.createCell(6);
+		declarationLevelHeader.setCellValue("申报级别");
+		declarationLevelHeader.setCellStyle(headerStyle);
+
+		// 设置表格内容数据
+		int rowIndex = 2;
+		for (int i = 0; i < summaryInformationDTOList.size(); i++) {
+			Row row = sheet.createRow(rowIndex);
+			row.setHeightInPoints(Float.parseFloat("30"));
+			CellStyle cellStyle = createContentStyle(workbook, sheet, rowIndex);
+			Cell indexCell = row.createCell(0);
+			indexCell.setCellValue(i + 1);
+			indexCell.setCellStyle(cellStyle);
+			Cell employeeNoCell = row.createCell(1);
+			employeeNoCell.setCellValue(summaryInformationDTOList.get(i).getEmployeeNo());
+			employeeNoCell.setCellStyle(cellStyle);
+			Cell employeeNameCell = row.createCell(2);
+			employeeNameCell.setCellValue(summaryInformationDTOList.get(i).getEmployeeName());
+			employeeNameCell.setCellStyle(cellStyle);
+			Cell suggestedValueCell = row.createCell(3);
+			suggestedValueCell.setCellValue(summaryInformationDTOList.get(i).getSuggestedValue());
+			suggestedValueCell.setCellStyle(cellStyle);
+			Cell declarationsNumberCell = row.createCell(4);
+			declarationsNumberCell.setCellValue(summaryInformationDTOList.get(i).getDeclarationsNumber());
+			declarationsNumberCell.setCellStyle(cellStyle);
+			Cell reportingDepartmentCell = row.createCell(5);
+			reportingDepartmentCell.setCellValue(summaryInformationDTOList.get(i).getReportingDepartment());
+			reportingDepartmentCell.setCellStyle(cellStyle);
+			Cell declarationLevelCell = row.createCell(6);
+			declarationLevelCell.setCellValue(summaryInformationDTOList.get(i).getDeclarationLevel());
+			declarationLevelCell.setCellStyle(cellStyle);
+			rowIndex++;
+		}
+
+		workbook.write(outputStream);
+		workbook.close();
+	}
+
 	private static CellStyle createTitleStyle(Workbook workbook) {
 		CellStyle style = workbook.createCellStyle();
 		style.setAlignment(HorizontalAlignment.CENTER);

+ 2 - 2
ims-service/ims-eval/src/main/resources/mappers/DeptAssessmentDeclarationMapper.xml

@@ -61,8 +61,8 @@
             <if test="orderNumber != null and orderNumber != ''">
                 AND order_number like CONCAT('%',#{orderNumber},'%')
             </if>
-            <if test="deptId != null and deptId != ''">
-                AND dept_id = #{deptId}
+            <if test="deptName != null and deptName != ''">
+                AND dept_name like CONCAT('%',#{deptName},'%')
             </if>
             <if test="annual != null and annual != ''">
                 AND annual = #{annual}