Browse Source

代码优化;

hlf 1 year ago
parent
commit
a8480074d8

+ 45 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluationRevisionController.java

@@ -13,7 +13,11 @@ import com.ims.eval.service.IOrganizationEvaluationRuleService;
 import com.ims.eval.service.IResponsibilityIndicatorInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
@@ -250,4 +254,45 @@ public class EvaluationRevisionController {
 			return R.customError(e.getMessage()).data("失败!");
 		}
 	}
+
+	/**
+	 * 详情-导出
+	 *
+	 * @param reviseId    业务主键
+	 * @param indicatorId indicatorId
+	 * @param binSection  binSection
+	 * @param binStage    binStage
+	 * @return 结果
+	 * @throws Exception 异常
+	 */
+	@GetMapping("/download-excel")
+	public ResponseEntity<byte[]> downloadExcel(
+		@RequestParam(value = "reviseId", required = false) String reviseId,
+		@RequestParam(value = "indicatorId", required = false) String indicatorId,
+		@RequestParam(value = "binSection", required = false) String binSection,
+		@RequestParam(value = "binStage", required = false) String binStage) throws Exception {
+		byte[] excelBytes = evaluationRevisionService.downloadExcel(reviseId, indicatorId, binSection, binStage, request);
+		HttpHeaders headers = new HttpHeaders();
+		headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
+		headers.setContentDispositionFormData("attachment", "example.xlsx");
+		return ResponseEntity.ok().headers(headers).body(excelBytes);
+	}
+
+	/**
+	 * 详情-导入
+	 *
+	 * @param file    文件
+	 * @param request request
+	 * @return 结果
+	 * @throws Exception 异常
+	 */
+	@PostMapping("/import-excel")
+	public R importExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
+		boolean b = evaluationRevisionService.importExcel(file, request);
+		if (b) {
+			return R.ok().data(b);
+		} else {
+			return R.error().data("上传失败");
+		}
+	}
 }

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

@@ -3,6 +3,7 @@ package com.ims.eval.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ims.eval.entity.EvaluationRevision;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
@@ -23,5 +24,9 @@ public interface IEvaluationRevisionService extends IService<EvaluationRevision>
 
 	boolean editState(String id, String state, String instId);
 
-    Map getResponsibilityIndicatorInfoList(String reviseId, String indicatorId, String organizationShortName, String binSection, String binStage, HttpServletRequest request);
+	Map getResponsibilityIndicatorInfoList(String reviseId, String indicatorId, String organizationShortName, String binSection, String binStage, HttpServletRequest request);
+
+	byte[] downloadExcel(String reviseId, String indicatorId, String binSection, String binStage, HttpServletRequest request) throws Exception;
+
+	boolean importExcel(MultipartFile file, HttpServletRequest request);
 }

+ 437 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationRevisionServiceImpl.java

@@ -19,14 +19,28 @@ import com.ims.eval.entity.dto.response.ResponsibilityIndicatorInfoResDTO;
 import com.ims.eval.service.IEvaluationRevisionService;
 import com.ims.eval.service.IIndicatorService;
 import com.ims.eval.service.IResponsibilityIndicatorInfoService;
+import com.ims.eval.util.MathCalculatorUtil;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.CellRangeAddressList;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.ims.eval.util.ExcelUtil.readExcel;
+
 /**
  * @author hlf
  * @date 2023/5/23 10:34
@@ -260,6 +274,364 @@ public class EvaluationRevisionServiceImpl extends ServiceImpl<EvaluationRevisio
 		return data;
 	}
 
+	@Override
+	public byte[] downloadExcel(String reviseId, String indicatorId, String binSection, String binStage, HttpServletRequest request) throws Exception {
+		Map data = new HashMap();
+		//设置数据头
+		//获取指标名称
+		String[] values = new String[]{"不合格", "待确认", "已确认"};
+		boolean titlemark = true;//标记生成标题
+		Map<String, List<Map<String, String>>> title = new LinkedHashMap();//保存所有的指标名
+		List<Map> indicatorMap = getResponsibilityIndicatorList(reviseId, binSection, binStage, request);
+		List<String> idList = indicatorMap.stream()
+			.map(map -> String.valueOf(map.get("id"))) // 提取每个Map中key为"id"的值,并转换成String
+			.collect(Collectors.toList()); // 将提取的值收集到List中
+		if (null == idList || idList.size() <= 0) {
+			throw new CustomException("未查询导数据");
+		}
+		List<IndicatorResDTO> indicatorResDTOS = indicatorService.getGroupChildCodeByIds(idList);
+		if (titlemark) {
+			for (IndicatorResDTO dto : indicatorResDTOS) {
+				Map titlemap = new LinkedHashMap();
+				List<Map<String, String>> titleArray = new ArrayList<>();
+				// 处理每个分组中的元素
+				titlemap.put(dto.getChildCode() + "_" + dto.getOptionCode(), dto.getDeptName());//名称
+				titleArray.add(titlemap);
+				title.put(dto.getChildName(), titleArray);
+			}
+			//状态标题头
+			List<Map<String, String>> titleStateArray = new ArrayList<>();
+			Map titleStateMap = new LinkedHashMap();
+			titleStateMap.put("state", "填报状态");
+			titleStateArray.add(titleStateMap);
+			title.put("状态", titleStateArray);
+			titlemark = false;
+		}
+		//获取数据
+		List<Map> datamapList = new ArrayList<>();
+		List<ResponsibilityIndicatorInfoResDTO> dataList = responsibilityIndicatorInfoMapper.getResponsibilityInfoList("", indicatorId, "", binSection, binStage, "1-1", reviseId);
+		Map<String, List<ResponsibilityIndicatorInfoResDTO>> groupeddataMap = dataList.stream().collect(Collectors.groupingBy(ResponsibilityIndicatorInfoResDTO::getOrganizationId)); // 根据organizationId进行分组
+		// 遍历分组后的Map
+		for (Map.Entry<String, List<ResponsibilityIndicatorInfoResDTO>> entry : groupeddataMap.entrySet()) {
+			List<ResponsibilityIndicatorInfoResDTO> groupedList = entry.getValue(); // 获取分组后的List
+			Map<String, ResponsibilityIndicatorInfoResDTO> resultMap = groupedList.stream()
+				.collect(Collectors.toMap(
+					dto -> dto.getChildCode() + "_" + dto.getOptionCode(),
+					dto -> dto,
+					(oldValue, newValue) -> oldValue)); // 解决键重复的情况
+			LinkedHashMap indicatormap = new LinkedHashMap();
+			// 进一步处理每个分组
+			String state = "不合格";
+			for (IndicatorResDTO d : indicatorResDTOS) {
+				boolean mark = true;//标记给公司名赋值
+				if (mark) {
+					indicatormap.put("organizationShortName", resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getOrganizationShortName());//公司名
+					indicatormap.put("organizationId", resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getOrganizationId());//公司id
+					String state2 = resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getState();//(-1:不合格;0:待确认;1:已确认)
+					state = stateConvert(state2, true);
+					mark = false;
+				}
+				//指标属性
+				indicatormap.put(d.getChildCode() + "_" + d.getOptionCode(), null == resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getNonQuantifiedValue() ? "" : resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getNonQuantifiedValue());
+			}
+			indicatormap.put("state", state);//状态
+			datamapList.add(indicatormap);
+		}
+		//获取主表对象
+		EvaluationRevision evaluationRevision = super.getById(reviseId);
+		//国电电力2023年关键业绩指标一览表(工程公司)
+		StringBuilder sb = new StringBuilder("国电电力").append(evaluationRevision.getYear()).append("年关键业绩指标一览表(");
+		sb.append(CacheContext.bsnIdObject.get(binSection).getSectionName()).append(")");
+		// 创建Workbook对象
+		Workbook workbook = new XSSFWorkbook();
+		// 创建工作表
+		Sheet sheet = workbook.createSheet(CacheContext.bseIdObject.get(binStage).getStageName());
+		// 创建单元格样式
+		CellStyle cellStyle = workbook.createCellStyle();
+		cellStyle.setAlignment(HorizontalAlignment.CENTER);
+		cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+		// 设置边框样式
+		cellStyle.setBorderTop(BorderStyle.THIN);
+		cellStyle.setBorderBottom(BorderStyle.THIN);
+		cellStyle.setBorderLeft(BorderStyle.THIN);
+		cellStyle.setBorderRight(BorderStyle.THIN);
+		// 创建1、2行作为标题行
+		Row headerRow0 = sheet.createRow(0);
+		Row headerRow1 = sheet.createRow(1);
+		Row headerRow2 = sheet.createRow(2);
+		Row headerRow3 = sheet.createRow(3);
+		// 设置首行的单元格值
+		Cell header0Cell0 = headerRow0.createCell(0);
+		header0Cell0.setCellValue(sb.toString());
+		Cell headerCell0 = headerRow1.createCell(0);
+		headerCell0.setCellValue("序号");
+		headerCell0.setCellStyle(cellStyle);
+		headerCell0.setCellStyle(cellStyle);
+		sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
+		Cell headerCell1 = headerRow1.createCell(1);
+		headerCell1.setCellValue("单位名称");
+		headerCell1.setCellStyle(cellStyle);
+		headerCell1.setCellStyle(cellStyle);
+		sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
+		Cell headerCell2 = headerRow1.createCell(2);
+		headerCell2.setCellValue("单位编码");
+		headerCell2.setCellStyle(cellStyle);
+		headerCell2.setCellStyle(cellStyle);
+		sheet.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
+		Cell header3Cell0 = headerRow3.createCell(0);
+		header3Cell0.setCellValue("zhidmap,respId=" + reviseId);
+		Cell header3Cell1 = headerRow3.createCell(1);
+		header3Cell1.setCellValue("organizationShortName");
+		Cell header3Cell2 = headerRow3.createCell(2);
+		header3Cell2.setCellValue("organizationId");
+		Integer colsize = 2;
+		Integer optioncols = 3;
+		for (String key : title.keySet()) {//存在多个标题
+			List<Map<String, String>> titleArray2 = title.get(key);
+			Cell headerCellcolsize = headerRow1.createCell(colsize + 1);
+			headerCellcolsize.setCellValue(key);
+			//设置宽度
+			int contentWidth = headerCellcolsize.getStringCellValue().length() * 310;
+			contentWidth = (contentWidth <= 4000) ? 4000 : 5000;
+			// 设置指定列的宽度为计算得到的宽度值
+			sheet.setColumnWidth(colsize + 1, contentWidth);
+			headerCellcolsize.setCellStyle(cellStyle);
+			headerCellcolsize.setCellStyle(cellStyle);
+			System.out.println("key=" + key);
+			for (Map<String, String> key2 : titleArray2) {
+				if (key2.size() > 1) {
+					sheet.addMergedRegion(new CellRangeAddress(1, 1, colsize + 1, colsize + key2.size()));
+				}
+				colsize = colsize + key2.size();
+				for (String key3 : key2.keySet()) {
+					Cell header3Cell3 = headerRow3.createCell(optioncols);
+					header3Cell3.setCellValue(key3);
+					header3Cell3.setCellStyle(cellStyle);
+					Cell header2Cell2 = headerRow2.createCell(optioncols);
+					header2Cell2.setCellValue(key2.get(key3));
+					header2Cell2.setCellStyle(cellStyle);
+					// 隐藏列
+					if (key3.startsWith("ID_") || key3.startsWith("IS_LH_")) {
+						sheet.setColumnHidden(optioncols, true);
+					}
+					optioncols++;
+				}
+			}
+		}
+		Integer rowdate = 4;
+		for (Map<String, String> datamaps : datamapList) {
+			Integer colsdata = 1;
+			Row headerRowdate = sheet.createRow(rowdate);
+			Cell dataCell0 = headerRowdate.createCell(0);
+			dataCell0.setCellValue(rowdate - 3);
+			dataCell0.setCellStyle(cellStyle);
+			for (String datakey : datamaps.keySet()) {
+				Cell dataCell1 = headerRowdate.createCell(colsdata);
+				dataCell1.setCellValue(datamaps.get(datakey).toString());
+				dataCell1.setCellStyle(cellStyle);
+				if ("state".equals(datakey)) {
+					// 创建一个数据验证对象
+					DataValidationHelper validationHelper = sheet.getDataValidationHelper();
+					DataValidationConstraint constraint = validationHelper.createExplicitListConstraint(values);
+					// 设置下拉列表的位置范围为
+					CellRangeAddressList addressList = new CellRangeAddressList(rowdate, rowdate, colsdata, colsdata); // 行索引和列索引从0开始计数
+					// 创建数据验证对象
+					DataValidation validation = validationHelper.createValidation(constraint, addressList);
+					// 将数据验证对象应用于单元格
+					sheet.addValidationData(validation);
+				}
+				colsdata++;
+			}
+			rowdate++;
+		}
+
+		//隐藏行
+		sheet.getRow(3).setZeroHeight(true);
+		sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, colsize));
+		header0Cell0.setCellStyle(cellStyle);
+
+		// 将Workb
+		// ook写入字节数组输出流
+		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+		workbook.write(outputStream);
+
+		// 将字节数组作为响应体返回,并设置响应头
+		byte[] excelBytes = outputStream.toByteArray();
+		return excelBytes;
+	}
+
+	@Override
+	public boolean importExcel(MultipartFile file, HttpServletRequest request) {
+		List<LinkedHashMap<String, Object>> dataList = new ArrayList<>();
+		try {
+			//获取原始的文件名
+			String originalFilename = file.getOriginalFilename();
+			//获取文件类型
+			String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
+			//获取输入流
+			InputStream is = file.getInputStream();
+			Workbook workbook = readExcel(fileType, is);
+
+			Sheet sheet = workbook.getSheetAt(0);
+			// 获取总列数和起始行索引
+			int totalColumns = sheet.getRow(3).getLastCellNum();
+			int startingRowIndex = 4;
+
+			Row headerRow = sheet.getRow(3);
+
+			// 遍历每一行数据
+			for (int i = startingRowIndex; i <= sheet.getLastRowNum(); i++) {
+				Row row = sheet.getRow(i);
+				LinkedHashMap<String, Object> dataMap = new LinkedHashMap<>();
+
+				// 遍历每一列数据
+				for (int j = 0; j < totalColumns; j++) {
+					Cell headerCell = headerRow.getCell(j);
+					Cell cell = row.getCell(j);
+
+					String columnName = headerCell.getStringCellValue();
+					String cellValue = "";
+
+					// 根据单元格类型读取对应内容
+					if (cell != null) {
+						switch (cell.getCellType()) {
+							case HSSFCell.CELL_TYPE_STRING:
+								cellValue = cell.getStringCellValue();
+								break;
+							case HSSFCell.CELL_TYPE_NUMERIC:
+								cellValue = String.valueOf(cell.getNumericCellValue());
+								break;
+							case HSSFCell.CELL_TYPE_BOOLEAN:
+								cellValue = String.valueOf(cell.getBooleanCellValue());
+								break;
+							case HSSFCell.CELL_TYPE_BLANK:
+								cellValue = "";
+								break;
+						}
+					}
+					dataMap.put(columnName, cellValue);
+				}
+				dataList.add(dataMap);
+			}
+			workbook.close();
+
+			for (Map<String, Object> map : dataList) {
+				Map<String, String> idMap = new HashMap();
+				Map<String, String> valueMap = new HashMap();
+				for (String key : map.keySet()) {
+					String value = String.valueOf(map.get(key));
+					if (key.startsWith("zhidmap")) {
+						String[] zhidmap = key.split(",");
+						idMap.put("respId", zhidmap[1].split("=")[1]);
+						continue;
+					}
+					if (key.startsWith("organization")) {
+						idMap.put(key, value);
+						continue;
+					}
+					if (key.startsWith("state")) {
+						idMap.put(key, value);
+						continue;
+					} else {
+						valueMap.put(key, value);
+						continue;
+					}
+				}
+				for (Map.Entry<String, String> entry : valueMap.entrySet()) {
+					//organizationEvaluationId 考评记录id
+					//organizationId 组织id
+					//childOptionCode 组合子指标和指标项
+					List<ResponsibilityIndicatorInfo> responsibilityInfoList = getResponsibilityInfooByOptionCodeList(idMap.get("respId"), idMap.get("organizationId"), entry.getKey());
+					ResponsibilityIndicatorInfo oriinfo = null;
+					ResponsibilityIndicatorInfo responsibilityInfo = null;
+					if (null != responsibilityInfoList && responsibilityInfoList.size() > 0) {
+						oriinfo = responsibilityInfoList.get(0);//原始数据
+						responsibilityInfo = responsibilityInfoList.get(0);
+					}
+					double quantifiedValue = 0;
+					if (MathCalculatorUtil.isNumber(String.valueOf(entry.getValue()))) {
+						BigDecimal bigDecimal = new BigDecimal(entry.getValue());
+						quantifiedValue = Double.parseDouble(new DecimalFormat("#.00").format(bigDecimal));
+					}
+					String nonQuantifiedValue = entry.getValue();
+					String state = stateConvert(idMap.get("state").toString(), false);
+					if (null != responsibilityInfo && null != oriinfo) {
+						if (oriinfo.getIsQuantified()) {//量化 true
+							if (quantifiedValue != responsibilityInfo.getQuantifiedValue()) {
+								if ("1-1".equals(responsibilityInfo.getDataState())) {
+									responsibilityInfo.setQuantifiedValue(quantifiedValue);
+									responsibilityInfo.setNonQuantifiedValue(nonQuantifiedValue);
+									responsibilityInfo.setState(state);
+									responsibilityIndicatorInfoService.updateById(responsibilityInfo);
+								} else {
+									ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
+									info.setDeptResponsibilityId(responsibilityInfo.getDeptResponsibilityId());
+									info.setOrganizationEvaluationRuleId(responsibilityInfo.getOrganizationEvaluationRuleId());
+									info.setIndicatorId(responsibilityInfo.getIndicatorId());
+									info.setIndicatorDictionaryId(responsibilityInfo.getIndicatorDictionaryId());
+									info.setOptionCode(responsibilityInfo.getOptionCode());
+									info.setIsQuantified(responsibilityInfo.getIsQuantified());
+									info.setQuantifiedValue(quantifiedValue);
+									info.setNonQuantifiedValue(nonQuantifiedValue);
+									info.setCreateTime(new Date());
+									info.setRemark(responsibilityInfo.getRemark());
+									info.setState(state);
+									info.setDataState("1-1");
+									info.setDeptId(responsibilityInfo.getDeptId());
+									info.setChildCode(responsibilityInfo.getChildCode());
+									info.setEvaluateRuleInfoId(responsibilityInfo.getEvaluateRuleInfoId());
+									info.setOrganizationId(responsibilityInfo.getOrganizationId());
+									info.setReviseId(responsibilityInfo.getReviseId());
+									boolean b = responsibilityIndicatorInfoService.save(info);
+									if (b) {
+										responsibilityInfo.setDataState("0-0");
+										responsibilityIndicatorInfoService.updateById(responsibilityInfo);
+									}
+								}
+							}
+						} else {//非量化 false
+							if (!nonQuantifiedValue.equals(responsibilityInfo.getNonQuantifiedValue())) {
+								if ("1-1".equals(responsibilityInfo.getDataState())) {
+									responsibilityInfo.setQuantifiedValue(quantifiedValue);
+									responsibilityInfo.setNonQuantifiedValue(nonQuantifiedValue);
+									responsibilityInfo.setState(state);
+									responsibilityIndicatorInfoService.updateById(responsibilityInfo);
+								} else {
+									ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
+									info.setDeptResponsibilityId(responsibilityInfo.getDeptResponsibilityId());
+									info.setOrganizationEvaluationRuleId(responsibilityInfo.getOrganizationEvaluationRuleId());
+									info.setIndicatorId(responsibilityInfo.getIndicatorId());
+									info.setIndicatorDictionaryId(responsibilityInfo.getIndicatorDictionaryId());
+									info.setOptionCode(responsibilityInfo.getOptionCode());
+									info.setIsQuantified(responsibilityInfo.getIsQuantified());
+									info.setQuantifiedValue(quantifiedValue);
+									info.setNonQuantifiedValue(nonQuantifiedValue);
+									info.setCreateTime(new Date());
+									info.setRemark(responsibilityInfo.getRemark());
+									info.setState(state);
+									info.setDataState("1-1");
+									info.setDeptId(responsibilityInfo.getDeptId());
+									info.setChildCode(responsibilityInfo.getChildCode());
+									info.setEvaluateRuleInfoId(responsibilityInfo.getEvaluateRuleInfoId());
+									info.setOrganizationId(responsibilityInfo.getOrganizationId());
+									info.setReviseId(responsibilityInfo.getReviseId());
+									boolean b = responsibilityIndicatorInfoService.save(info);
+									if (b) {
+										responsibilityInfo.setDataState("0-0");
+										responsibilityIndicatorInfoService.updateById(responsibilityInfo);
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return true;
+	}
+
 	private List<Map> getResponsibilityIndicatorList(String reviseId, String binSection, String binStage, HttpServletRequest request) {
 		//判断是否是(重点专项和管理事项)
 		List<Map> indicatorMap = new ArrayList<>();
@@ -282,4 +654,69 @@ public class EvaluationRevisionServiceImpl extends ServiceImpl<EvaluationRevisio
 		}
 		return indicatorMap;
 	}
+
+	private List<ResponsibilityIndicatorInfo> getResponsibilityInfooByOptionCodeList(String reviseId, String organizationId, String childOptionCode) {
+		QueryWrapper<ResponsibilityIndicatorInfo> qw = new QueryWrapper<>();
+		if (StringUtils.isNotEmpty(reviseId)) {
+			qw.lambda().eq(ResponsibilityIndicatorInfo::getReviseId, reviseId);
+		}
+		if (StringUtils.isNotEmpty(organizationId)) {
+			qw.lambda().eq(ResponsibilityIndicatorInfo::getOrganizationId, organizationId);
+		}
+		if (StringUtils.isNotEmpty(childOptionCode)) {
+			qw.eq("CONCAT(child_code, '_', option_code)", childOptionCode);
+		}
+		List<ResponsibilityIndicatorInfo> list = responsibilityIndicatorInfoService.list(qw);
+		return list;
+	}
+
+	/**
+	 * 状态抓换 (-1:不合格;0:待确认;1:已确认)
+	 *
+	 * @return 结果
+	 */
+	private String stateConvert(String state, boolean flge) {
+		//(-1:不合格;0:待确认;1:已确认)
+		String state2 = "";
+		if (flge) {
+			if (StringUtils.isEmpty(state)) {
+				state2 = "待确认";
+				return state2;
+			}
+			switch (state) {
+				case "-1":
+					state2 = "不合格";
+					break;
+				case "0":
+					state2 = "待确认";
+					break;
+				case "1":
+					state2 = "已确认";
+					break;
+				default:
+					state2 = "待确认";
+					break;
+			}
+		} else {
+			if (StringUtils.isEmpty(state)) {
+				state2 = "0";
+				return state2;
+			}
+			switch (state) {
+				case "不合格":
+					state2 = "-1";
+					break;
+				case "待确认":
+					state2 = "0";
+					break;
+				case "已确认":
+					state2 = "1";
+					break;
+				default:
+					state2 = "0";
+					break;
+			}
+		}
+		return state2;
+	}
 }

+ 58 - 44
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/ResponsibilityIndicatorInfoServiceImpl.java

@@ -170,54 +170,68 @@ public class ResponsibilityIndicatorInfoServiceImpl extends ServiceImpl<Responsi
 				String nonQuantifiedValue = String.valueOf(valueMap.get(entry.getKey().replace("ID_", "")));
 				if (responsibilityIndicatorInfo.getIsQuantified()) {//量化 true
 					if (quantifiedValue != responsibilityIndicatorInfo.getQuantifiedValue()) {
-						ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
-						info.setDeptResponsibilityId(responsibilityIndicatorInfo.getDeptResponsibilityId());
-						info.setOrganizationEvaluationRuleId(responsibilityIndicatorInfo.getOrganizationEvaluationRuleId());
-						info.setIndicatorId(responsibilityIndicatorInfo.getIndicatorId());
-						info.setIndicatorDictionaryId(responsibilityIndicatorInfo.getIndicatorDictionaryId());
-						info.setOptionCode(responsibilityIndicatorInfo.getOptionCode());
-						info.setIsQuantified(responsibilityIndicatorInfo.getIsQuantified());
-						info.setQuantifiedValue(quantifiedValue);
-						info.setNonQuantifiedValue(nonQuantifiedValue);
-						info.setCreateTime(new Date());
-						info.setRemark(responsibilityIndicatorInfo.getRemark());
-						info.setState("0");
-						info.setDataState("1-1");
-						info.setDeptId(responsibilityIndicatorInfo.getDeptId());
-						info.setChildCode(responsibilityIndicatorInfo.getChildCode());
-						info.setEvaluateRuleInfoId(responsibilityIndicatorInfo.getEvaluateRuleInfoId());
-						info.setOrganizationId(responsibilityIndicatorInfo.getOrganizationId());
-						info.setReviseId(responsibilityIndicatorInfo.getReviseId());
-						boolean b = this.save(info);
-						if (b) {
-							responsibilityIndicatorInfo.setDataState("0-0");
-							this.updateById(responsibilityIndicatorInfo);
+						if ("1-1".equals(responsibilityIndicatorInfo.getDataState())) {
+							responsibilityIndicatorInfo.setQuantifiedValue(quantifiedValue);
+							responsibilityIndicatorInfo.setNonQuantifiedValue(nonQuantifiedValue);
+							responsibilityIndicatorInfo.setState(valueMap.get("state").toString());
+							super.updateById(responsibilityIndicatorInfo);
+						} else {
+							ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
+							info.setDeptResponsibilityId(responsibilityIndicatorInfo.getDeptResponsibilityId());
+							info.setOrganizationEvaluationRuleId(responsibilityIndicatorInfo.getOrganizationEvaluationRuleId());
+							info.setIndicatorId(responsibilityIndicatorInfo.getIndicatorId());
+							info.setIndicatorDictionaryId(responsibilityIndicatorInfo.getIndicatorDictionaryId());
+							info.setOptionCode(responsibilityIndicatorInfo.getOptionCode());
+							info.setIsQuantified(responsibilityIndicatorInfo.getIsQuantified());
+							info.setQuantifiedValue(quantifiedValue);
+							info.setNonQuantifiedValue(nonQuantifiedValue);
+							info.setCreateTime(new Date());
+							info.setRemark(responsibilityIndicatorInfo.getRemark());
+							info.setState("0");
+							info.setDataState("1-1");
+							info.setDeptId(responsibilityIndicatorInfo.getDeptId());
+							info.setChildCode(responsibilityIndicatorInfo.getChildCode());
+							info.setEvaluateRuleInfoId(responsibilityIndicatorInfo.getEvaluateRuleInfoId());
+							info.setOrganizationId(responsibilityIndicatorInfo.getOrganizationId());
+							info.setReviseId(responsibilityIndicatorInfo.getReviseId());
+							boolean b = this.save(info);
+							if (b) {
+								responsibilityIndicatorInfo.setDataState("0-0");
+								this.updateById(responsibilityIndicatorInfo);
+							}
 						}
 					}
 				} else {//非量化 false
 					if (!nonQuantifiedValue.equals(responsibilityIndicatorInfo.getNonQuantifiedValue())) {
-						ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
-						info.setDeptResponsibilityId(responsibilityIndicatorInfo.getDeptResponsibilityId());
-						info.setOrganizationEvaluationRuleId(responsibilityIndicatorInfo.getOrganizationEvaluationRuleId());
-						info.setIndicatorId(responsibilityIndicatorInfo.getIndicatorId());
-						info.setIndicatorDictionaryId(responsibilityIndicatorInfo.getIndicatorDictionaryId());
-						info.setOptionCode(responsibilityIndicatorInfo.getOptionCode());
-						info.setIsQuantified(responsibilityIndicatorInfo.getIsQuantified());
-						info.setQuantifiedValue(quantifiedValue);
-						info.setNonQuantifiedValue(nonQuantifiedValue);
-						info.setCreateTime(new Date());
-						info.setRemark(responsibilityIndicatorInfo.getRemark());
-						info.setState("0");
-						info.setDataState("1-1");
-						info.setDeptId(responsibilityIndicatorInfo.getDeptId());
-						info.setChildCode(responsibilityIndicatorInfo.getChildCode());
-						info.setEvaluateRuleInfoId(responsibilityIndicatorInfo.getEvaluateRuleInfoId());
-						info.setOrganizationId(responsibilityIndicatorInfo.getOrganizationId());
-						info.setReviseId(responsibilityIndicatorInfo.getReviseId());
-						boolean b = this.save(info);
-						if (b) {
-							responsibilityIndicatorInfo.setDataState("0-0");
-							this.updateById(responsibilityIndicatorInfo);
+						if ("1-1".equals(responsibilityIndicatorInfo.getDataState())) {
+							responsibilityIndicatorInfo.setQuantifiedValue(quantifiedValue);
+							responsibilityIndicatorInfo.setNonQuantifiedValue(nonQuantifiedValue);
+							responsibilityIndicatorInfo.setState(valueMap.get("state").toString());
+							super.updateById(responsibilityIndicatorInfo);
+						} else {
+							ResponsibilityIndicatorInfo info = new ResponsibilityIndicatorInfo();
+							info.setDeptResponsibilityId(responsibilityIndicatorInfo.getDeptResponsibilityId());
+							info.setOrganizationEvaluationRuleId(responsibilityIndicatorInfo.getOrganizationEvaluationRuleId());
+							info.setIndicatorId(responsibilityIndicatorInfo.getIndicatorId());
+							info.setIndicatorDictionaryId(responsibilityIndicatorInfo.getIndicatorDictionaryId());
+							info.setOptionCode(responsibilityIndicatorInfo.getOptionCode());
+							info.setIsQuantified(responsibilityIndicatorInfo.getIsQuantified());
+							info.setQuantifiedValue(quantifiedValue);
+							info.setNonQuantifiedValue(nonQuantifiedValue);
+							info.setCreateTime(new Date());
+							info.setRemark(responsibilityIndicatorInfo.getRemark());
+							info.setState("0");
+							info.setDataState("1-1");
+							info.setDeptId(responsibilityIndicatorInfo.getDeptId());
+							info.setChildCode(responsibilityIndicatorInfo.getChildCode());
+							info.setEvaluateRuleInfoId(responsibilityIndicatorInfo.getEvaluateRuleInfoId());
+							info.setOrganizationId(responsibilityIndicatorInfo.getOrganizationId());
+							info.setReviseId(responsibilityIndicatorInfo.getReviseId());
+							boolean b = this.save(info);
+							if (b) {
+								responsibilityIndicatorInfo.setDataState("0-0");
+								this.updateById(responsibilityIndicatorInfo);
+							}
 						}
 					}
 				}