Explorar el Código

修改绩效结果考核申报导入返回msg

hlf hace 1 año
padre
commit
274cc34ff9

+ 4 - 6
ims-service/ims-eval/src/main/java/com/ims/eval/component/NextApproverImpl.java

@@ -19,11 +19,10 @@ public class NextApproverImpl {
 	/**
 	 * 申报等级有变化
 	 *
-	 * @param id 业务主键
 	 * @return 结果
 	 */
-	public boolean submitTask1(String id) {
-		DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
+	public boolean submitTask1(String a1, String a2, String a3) {
+		DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(a1);
 		boolean flag = !deptAssessmentDeclaration.getDeclarationLevel().equals(deptAssessmentDeclaration.getRatingGrade());
 		return flag;
 	}
@@ -31,11 +30,10 @@ public class NextApproverImpl {
 	/**
 	 * 申报等级无变化
 	 *
-	 * @param id 业务主键
 	 * @return 结果
 	 */
-	public boolean submitTask2(String id) {
-		DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(id);
+	public boolean submitTask2(String a1, String a2, String a3) {
+		DeptAssessmentDeclaration deptAssessmentDeclaration = deptAssessmentDeclarationService.getById(a1);
 		boolean flag = deptAssessmentDeclaration.getDeclarationLevel().equals(deptAssessmentDeclaration.getRatingGrade());
 		return flag;
 	}

+ 16 - 11
ims-service/ims-eval/src/main/java/com/ims/eval/controller/DeptAssessmentDeclarationController.java

@@ -261,6 +261,12 @@ public class DeptAssessmentDeclarationController {
 	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();
 				//获取文件类型
@@ -269,7 +275,6 @@ public class DeptAssessmentDeclarationController {
 				int startRows = 1;
 				//获取输入流
 				InputStream is = file.getInputStream();
-				List<DeptAssessmentDeclarationContent> deptAssessmentDeclarationContentList = new ArrayList<>();
 				//Excel导入导出的单元类
 				List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
 				//遍历Excel表每一行的数据
@@ -300,17 +305,17 @@ public class DeptAssessmentDeclarationController {
 					List<DeptAssessmentDeclarationContent> objList = deptAssessmentDeclarationContentService.list(qw);
 					if (objList.size() == 1) {//修改
 						deptAssessmentDeclarationContent.setId(objList.get(0).getId());
-						deptAssessmentDeclarationContentList.add(deptAssessmentDeclarationContent);
+						deptAssessmentDeclarationContentService.updateById(deptAssessmentDeclarationContent);
+						renewalCount++;
 					} else if (objList.size() == 0) {//新增
-						deptAssessmentDeclarationContentList.add(deptAssessmentDeclarationContent);
+						deptAssessmentDeclarationContentService.save(deptAssessmentDeclarationContent);
+						successCount++;
+					} else {
+						loseCount++;
 					}
 				}
-				boolean b = deptAssessmentDeclarationContentService.saveOrUpdateBatch(deptAssessmentDeclarationContentList);
-				if (b) {
-					return R.ok().data(b);
-				} else {
-					return R.error("导入失败!");
-				}
+				String msg = "导入成功,本次新增" + successCount + "条,更新" + renewalCount + "条,失败" + loseCount + "条数据。";
+				return R.ok().data(msg);
 			} catch (Exception e) {
 				log.error("错误", e);
 				return R.customError(e.getMessage()).data("失败!");
@@ -420,7 +425,7 @@ public class DeptAssessmentDeclarationController {
 			}
 			list.addAll(value);
 		});
-		list.stream().sorted(Comparator.comparing(SummaryInformationDTO::getSerialNumber,Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
+		list.stream().sorted(Comparator.comparing(SummaryInformationDTO::getSerialNumber, Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
 		return R.ok().data(list);
 	}
 
@@ -468,7 +473,7 @@ public class DeptAssessmentDeclarationController {
 			}
 			list.addAll(value);
 		});
-		list.stream().sorted(Comparator.comparing(SummaryInformationDTO::getSerialNumber,Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
+		list.stream().sorted(Comparator.comparing(SummaryInformationDTO::getSerialNumber, Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
 		ExcelUtils.createCollectExcel(list, annual, month, response.getOutputStream());
 	}