2 Commitit ed8bf99678 ... 7ca8ab64f5

Tekijä SHA1 Viesti Päivämäärä
  hlf 7ca8ab64f5 Merge branch 'master' of http://124.70.43.205:3000/wangchangsheng/evaluation 5 kuukautta sitten
  hlf 73bf6b4b56 功能完善 5 kuukautta sitten

+ 4 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluateRuleController.java

@@ -146,7 +146,9 @@ public class EvaluateRuleController {
 	 * 导入
 	 */
 	@PostMapping(value = "/importExcel")
-	public R importExcel(@RequestParam("file") MultipartFile file) {
-		return evaluateRuleService.importExcel(file);
+	public R importExcel(@RequestParam("file") MultipartFile file,
+						 @RequestParam("userId") String userId,
+						 @RequestParam("userName") String userName) {
+		return evaluateRuleService.importExcel(file, userId, userName);
 	}
 }

+ 2 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IBinSectionService.java

@@ -18,4 +18,6 @@ public interface IBinSectionService extends IService<BinSection> {
 	List<BinSection> list(String id, String sectionName, String sectionCode);
 
     BinSection getBinSectionBySectionName(String sectionName);
+
+	BinSection getBinSectionBySectionCode(String sectionCode);
 }

+ 2 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IBinStageService.java

@@ -18,4 +18,6 @@ public interface IBinStageService extends IService<BinStage> {
 	List<BinStage> list(String id, String stageName, String stageCode);
 
 	BinStage getBinStageByStageName(String stageName);
+
+    BinStage getBinStageByStageCode(String stageCode);
 }

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

@@ -44,7 +44,7 @@ public interface IEvaluateRuleService extends IService<EvaluateRule> {
 
 	void importTemplate(HttpServletResponse response) throws IOException;
 
-	R importExcel(MultipartFile file);
+	R importExcel(MultipartFile file, String userId, String userName);
 
 	EvaluateRule checkForExistence(String ruleName, String checkCycle, String binStage, String binSection, String year);
 }

+ 10 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/BinSectionServiceImpl.java

@@ -41,13 +41,22 @@ public class BinSectionServiceImpl extends ServiceImpl<BinSectionMapper, BinSect
 
 	@Override
 	public BinSection getBinSectionBySectionName(String sectionName) {
-		QueryWrapper<BinSection> qw = new QueryWrapper();
+		QueryWrapper<BinSection> qw = new QueryWrapper<>();
 		if (StringUtils.isNotEmpty(sectionName)) {
 			qw.lambda().eq(BinSection::getSectionName, sectionName);
 		}
 		return baseMapper.selectOne(qw);
 	}
 
+	@Override
+	public BinSection getBinSectionBySectionCode(String sectionCode) {
+		QueryWrapper<BinSection> qw = new QueryWrapper<>();
+		if (StringUtils.isNotEmpty(sectionCode)) {
+			qw.lambda().eq(BinSection::getSectionCode, sectionCode);
+		}
+		return baseMapper.selectOne(qw);
+	}
+
 	@Transactional
 	@Override
 	public boolean saveOrUpdate(BinSection entity) {

+ 10 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/BinStageServiceImpl.java

@@ -38,13 +38,22 @@ public class BinStageServiceImpl extends ServiceImpl<BinStageMapper, BinStage> i
 
 	@Override
 	public BinStage getBinStageByStageName(String stageName) {
-		QueryWrapper<BinStage> qw = new QueryWrapper();
+		QueryWrapper<BinStage> qw = new QueryWrapper<>();
 		if (StringUtils.isNotEmpty(stageName)) {
 			qw.lambda().eq(BinStage::getStageName, stageName);
 		}
 		return baseMapper.selectOne(qw);
 	}
 
+	@Override
+	public BinStage getBinStageByStageCode(String stageCode) {
+		QueryWrapper<BinStage> qw = new QueryWrapper<>();
+		if (StringUtils.isNotEmpty(stageCode)) {
+			qw.lambda().eq(BinStage::getStageCode, stageCode);
+		}
+		return baseMapper.selectOne(qw);
+	}
+
 	@Transactional
 	@Override
 	public boolean saveOrUpdate(BinStage entity) {

+ 3 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluateRuleServiceImpl.java

@@ -338,7 +338,7 @@ public class EvaluateRuleServiceImpl extends ServiceImpl<EvaluateRuleMapper, Eva
 	}
 
 	@Override
-	public R importExcel(MultipartFile file) {
+	public R importExcel(MultipartFile file, String userId, String userName) {
 		if (!file.isEmpty()) {
 			try {
 				//获取原始的文件名
@@ -380,6 +380,8 @@ public class EvaluateRuleServiceImpl extends ServiceImpl<EvaluateRuleMapper, Eva
 							evaluateRule.setCheckCycle(checkCycle);
 							evaluateRule.setYear(str[4]);
 							evaluateRule.setDes(str[5]);
+							evaluateRule.setCreateBy(userId);
+							evaluateRule.setCreateName(userName);
 							evaluateRule.setCreateTime(new Date());
 							evaluateRuleList.add(evaluateRule);
 						}

+ 82 - 39
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationRuleServiceImpl.java

@@ -58,6 +58,12 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 	@Autowired
 	private IOrganizationStructureService organizationStructureService;
 
+	@Autowired
+	private IBinSectionService binSectionService;
+
+	@Autowired
+	private IBinStageService binStageService;
+
 	@Override
 	public IPage<OrganizationEvaluationRule> list(Integer pageNum, Integer pageSize, String id, String organizationName, String organizationId, String organizationType, String binSection, String binStage, String evaluationCycle, String year) {
 		QueryWrapper<OrganizationEvaluationRule> qw = new QueryWrapper<>();
@@ -320,7 +326,7 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 
 		// 创建表头
 		Row headerRow = sheet.createRow(0);
-		List<String> headers = Arrays.asList("单位编码", "单位名称", "考评周期", "考评规则", "是否考评", "考评年份", "生产经营权重", "前期权重", "基建权重");
+		List<String> headers = Arrays.asList("单位编码", "单位名称", "业务属性编码", "业务属性", "业务阶段编码", "业务阶段", "考评周期", "考评规则", "是否考评", "考评年份", "生产经营权重", "前期权重", "基建权重");
 		for (int i = 0; i < headers.size(); i++) {
 			Cell cell = headerRow.createCell(i);
 			cell.setCellValue(headers.get(i));
@@ -347,6 +353,34 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 			// 设置其数据
 			row.createCell(0).setCellValue(organizationEvaluationRule.getOrganizationId());
 			row.createCell(1).setCellValue(organizationEvaluationRule.getOrganizationShortName());
+			if (null != organizationEvaluationRule.getBinSection()) {
+				String[] binSectionStr = organizationEvaluationRule.getBinSection().split(",");
+				StringBuilder binSectionCode = new StringBuilder();
+				StringBuilder binSectionName = new StringBuilder();
+				for (String str : binSectionStr) {
+					BinSection bse = binSectionService.getById(str);
+					if (null != bse) {
+						binSectionCode.append(bse.getSectionCode()).append(",");
+						binSectionName.append(bse.getSectionName()).append(",");
+					}
+				}
+				row.createCell(2).setCellValue(binSectionCode.toString().length() > 0 ? binSectionCode.toString().substring(0, binSectionCode.toString().length() - 1) : "");
+				row.createCell(3).setCellValue(binSectionName.toString().length() > 0 ? binSectionName.toString().substring(0, binSectionName.toString().length() - 1) : "");
+			}
+			if (null != organizationEvaluationRule.getBinStage()) {
+				String[] binStageStr = organizationEvaluationRule.getBinStage().split(",");
+				StringBuilder binStageCode = new StringBuilder();
+				StringBuilder binStageName = new StringBuilder();
+				for (String str : binStageStr) {
+					BinStage bst = binStageService.getById(str);
+					if (null != bst) {
+						binStageCode.append(bst.getStageCode()).append(",");
+						binStageName.append(bst.getStageName()).append(",");
+					}
+				}
+				row.createCell(4).setCellValue(binStageCode.toString().length() > 0 ? binStageCode.toString().substring(0, binStageCode.toString().length() - 1) : "");
+				row.createCell(5).setCellValue(binStageName.toString().length() > 0 ? binStageName.toString().substring(0, binStageName.toString().length() - 1) : "");
+			}
 			if (null != organizationEvaluationRule.getEvaluationCycle()) {
 				if ("NDKP".equals(organizationEvaluationRule.getEvaluationCycle())) {
 					evaluationCycle = "年度考评";
@@ -355,9 +389,9 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 				} else if ("YDKP".equals(organizationEvaluationRule.getEvaluationCycle())) {
 					evaluationCycle = "月度考评";
 				}
-				row.createCell(2).setCellValue(evaluationCycle);
+				row.createCell(6).setCellValue(evaluationCycle);
 			}
-			row.createCell(3).setCellValue(organizationEvaluationRule.getEvaluateRuleName());
+			row.createCell(7).setCellValue(organizationEvaluationRule.getEvaluateRuleName());
 			if (null != organizationEvaluationRule.getIsCheck()) {
 				String isCheck;
 				if (organizationEvaluationRule.getIsCheck()) {
@@ -365,12 +399,12 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 				} else {
 					isCheck = "否";
 				}
-				row.createCell(4).setCellValue(isCheck);
+				row.createCell(8).setCellValue(isCheck);
 			}
-			row.createCell(5).setCellValue(organizationEvaluationRule.getYear());
-			row.createCell(6).setCellValue(organizationEvaluationRule.getScjyWeight());
-			row.createCell(7).setCellValue(organizationEvaluationRule.getQqWeight());
-			row.createCell(8).setCellValue(organizationEvaluationRule.getJjWeight());
+			row.createCell(9).setCellValue(organizationEvaluationRule.getYear());
+			row.createCell(10).setCellValue(organizationEvaluationRule.getScjyWeight());
+			row.createCell(11).setCellValue(organizationEvaluationRule.getQqWeight());
+			row.createCell(12).setCellValue(organizationEvaluationRule.getJjWeight());
 		}
 
 		// 自动调整列宽
@@ -403,7 +437,7 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 
 		// 创建表头
 		Row headerRow = sheet.createRow(0);
-		List<String> headers = Arrays.asList("单位编码", "单位名称", "考评周期", "考评规则", "是否考评", "考评年份", "生产经营权重", "前期权重", "基建权重");
+		List<String> headers = Arrays.asList("单位编码", "单位名称", "业务属性编码", "业务属性", "业务阶段编码", "业务阶段", "考评周期", "考评规则", "是否考评", "考评年份", "生产经营权重", "前期权重", "基建权重");
 		for (int i = 0; i < headers.size(); i++) {
 			Cell cell = headerRow.createCell(i);
 			cell.setCellValue(headers.get(i));
@@ -432,33 +466,35 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 				int startRows = 1;
 				//获取输入流
 				InputStream is = file.getInputStream();
-				List<OrganizationEvaluationRule> organizationEvaluationRuleListUp = new ArrayList<>();
-				List<OrganizationEvaluationRule> organizationEvaluationRuleListSa = new ArrayList<>();
+				List<OrganizationEvaluationRule> organizationEvaluationRuleList = new ArrayList<>();
 				//Excel导入导出的单元类
 				List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
 				//遍历Excel表每一行的数据
 				for (String[] str : strings) {
 					OrganizationEvaluationRule organizationEvaluationRule = new OrganizationEvaluationRule();
-					String evaluateRuleNameStr = str[3].replaceAll(",", ",");
-					String[] evaluateRuleNames = evaluateRuleNameStr.split(",");
-					StringBuilder evaluateRuleIds = new StringBuilder();
+					String[] binSectionStr = str[2].split(",");
 					StringBuilder binSections = new StringBuilder();
+					for (String string : binSectionStr) {
+						BinSection bse = binSectionService.getBinSectionBySectionCode(string);
+						if (null != bse) {
+							binSections.append(bse.getId()).append(",");
+						}
+					}
+					String[] binStagesStr = str[4].split(",");
 					StringBuilder binStages = new StringBuilder();
-					for (String evaluateRuleName : evaluateRuleNames) {
-						EvaluateRule evaluateRule = evaluateRuleService.getEvaluateRuleByRuleName(evaluateRuleName, str[5]);
-						if (null != evaluateRule) {
-							evaluateRuleIds.append(evaluateRule.getId());
-							binSections.append(evaluateRule.getBinSection());
-							binStages.append(evaluateRule.getBinStage());
+					for (String string : binStagesStr) {
+						BinStage bst = binStageService.getBinStageByStageCode(string);
+						if (null != bst) {
+							binStages.append(bst.getId()).append(",");
 						}
 					}
-					OrganizationEvaluationRule obj = this.checkForExistence(str[0], toFullSpell(str[2]), binStages.toString(), binSections.toString(), str[5]);
+					OrganizationEvaluationRule obj = this.checkForExistence(str[0], toFullSpell(str[6]), binStages.toString(), binSections.toString(), str[9]);
 					if (null != obj) {
 						organizationEvaluationRule.setId(obj.getId());
-						organizationEvaluationRule.setScjyWeight(Double.parseDouble(str[6]));
-						organizationEvaluationRule.setQqWeight(Double.parseDouble(str[7]));
-						organizationEvaluationRule.setJjWeight(Double.parseDouble(str[8]));
-						organizationEvaluationRuleListUp.add(organizationEvaluationRule);
+						organizationEvaluationRule.setScjyWeight(Double.parseDouble(str[10]));
+						organizationEvaluationRule.setQqWeight(Double.parseDouble(str[11]));
+						organizationEvaluationRule.setJjWeight(Double.parseDouble(str[12]));
+						organizationEvaluationRuleList.add(organizationEvaluationRule);
 					} else {
 						List<OrganizationStructure> organizationStructureList = organizationStructureService.getList2("", null, "");
 						OrganizationStructure organizationStructure = organizationStructureList.stream().filter(item -> item.getId().equals(str[0])).findFirst().orElse(null);
@@ -468,27 +504,34 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 							organizationEvaluationRule.setOrganizationShortName(organizationStructure.getShortName());
 							organizationEvaluationRule.setBusinessType(organizationStructure.getBusinessType());
 							organizationEvaluationRule.setOrganizationType("DWKP");
-							organizationEvaluationRule.setEvaluationCycle(toFullSpell(str[2]));
-							organizationEvaluationRule.setEvaluateRuleId(evaluateRuleIds.toString());
-							organizationEvaluationRule.setBinSection(binSections.toString());
-							organizationEvaluationRule.setBinStage(binStages.toString());
+							organizationEvaluationRule.setEvaluationCycle(toFullSpell(str[6]));
+							String[] evaluateRuleNames = str[7].split(",");
+							StringBuilder evaluateRuleIds = new StringBuilder();
+							for (String evaluateRuleName : evaluateRuleNames) {
+								EvaluateRule evaluateRule = evaluateRuleService.getEvaluateRuleByRuleName(evaluateRuleName, str[9]);
+								if (null != evaluateRule) {
+									evaluateRuleIds.append(evaluateRule.getId()).append(",");
+								}
+							}
+							organizationEvaluationRule.setEvaluateRuleId(evaluateRuleIds.toString().length() > 0 ? evaluateRuleIds.toString().substring(0, evaluateRuleIds.toString().length() - 1) : "");
+							organizationEvaluationRule.setBinSection(binSections.toString().length() > 0 ? binSections.toString().substring(0, binSections.toString().length() - 1) : "");
+							organizationEvaluationRule.setBinStage(binStages.toString().length() > 0 ? binStages.toString().substring(0, binStages.toString().length() - 1) : "");
 							organizationEvaluationRule.setDelFlag(false);
-							if ("是".equals(str[4])) {
+							if ("是".equals(str[8])) {
 								organizationEvaluationRule.setIsCheck(true);
-							} else if ("否".equals(str[4])) {
+							} else if ("否".equals(str[8])) {
 								organizationEvaluationRule.setIsCheck(false);
 							}
-							organizationEvaluationRule.setScjyWeight(Double.parseDouble(str[6]));
-							organizationEvaluationRule.setQqWeight(Double.parseDouble(str[7]));
-							organizationEvaluationRule.setJjWeight(Double.parseDouble(str[8]));
-							organizationEvaluationRule.setYear(str[5]);
-							organizationEvaluationRuleListSa.add(organizationEvaluationRule);
+							organizationEvaluationRule.setScjyWeight(Double.parseDouble(str[10]));
+							organizationEvaluationRule.setQqWeight(Double.parseDouble(str[11]));
+							organizationEvaluationRule.setJjWeight(Double.parseDouble(str[12]));
+							organizationEvaluationRule.setYear(str[9]);
+							organizationEvaluationRuleList.add(organizationEvaluationRule);
 						}
 					}
 				}
-				boolean a = super.updateBatchById(organizationEvaluationRuleListUp);
-				boolean b = super.saveBatch(organizationEvaluationRuleListSa);
-				if (a || b) {
+				boolean b = super.saveOrUpdateBatch(organizationEvaluationRuleList);
+				if (b) {
 					return R.ok().data(b);
 				} else {
 					return R.error("导入失败!");