浏览代码

导入导出 处理

wangchangsheng 1 年之前
父节点
当前提交
6eebcdcb79

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

@@ -115,7 +115,7 @@ public class OrganizationEvaluationInfoController {
 	@PostMapping("/import-excel")
 	public R importExcel(@RequestParam("file") MultipartFile file,HttpServletRequest request) throws Exception {
 
-		boolean b = organizationEvaluationInfoService.importExcel(file);
+		boolean b = organizationEvaluationInfoService.importExcel(file,request);
 
 		if (b) {
 			return R.ok().data(b);

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

@@ -45,5 +45,5 @@ public interface IOrganizationEvaluationInfoService extends IService<Organizatio
 
 	byte[] downloadExcel(String organizationEvaluationId, String indicatorId, String binSection, String binStage, HttpServletRequest request)throws Exception;
 
-	boolean importExcel(MultipartFile file) throws IOException;
+	boolean importExcel(MultipartFile file,HttpServletRequest request) throws IOException;
 }

+ 87 - 6
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationInfoServiceImpl.java

@@ -408,7 +408,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 		if(null != user){
 			String deptId = "23031009";
 			if(deptId.equals(user.getDeptId())){
-				deptFlag = false;
+				deptFlag = true;
 			}
 
 		}
@@ -515,6 +515,15 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 	@Override
 	public byte[] downloadExcel(String organizationEvaluationId, String indicatorId, String binSection, String binStage,HttpServletRequest request) throws Exception{
 
+		//获取用户信息 23031009
+		boolean deptFlag = false;
+		MyuserResDTO user = userService.getSysUser(request);
+		if(null != user){
+			String deptId = "23031009";
+			if(deptId.equals(user.getDeptId())){
+				deptFlag = true;
+			}
+		}
 
 		Map<String ,List<Map<String,String>>> title = new LinkedHashMap();//标题
 		List<Map<String,String>> mapList = new ArrayList<>();//数据list
@@ -553,6 +562,10 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 						if (!d.getIsShow()) {
 							continue;
 						}
+
+						if(!deptFlag && d.getOptionCode().contains("DF")){
+							continue;
+						}
 						titlemap.put(d.getChildCode()+"_"+d.getOptionCode(), d.getOptionName());//名称
 						titlemap.put("ID_" +d.getChildCode()+"_"+d.getOptionCode(), "ID隐藏");//id
 						titlemap.put("IS_LH_" +d.getChildCode()+"_"+d.getOptionCode(), "是否量化隐藏");//是否量化
@@ -561,10 +574,17 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 					title.put(childCodeEntry.getKey().split(",")[1], titleArray);
 
 				}
+				//状态标题头
+				List<Map<String,String>> titleStateArray = new ArrayList<>();
+				Map titleStateMap = new LinkedHashMap();
+				titleStateMap.put("state","填报状态");
+				titleStateArray.add(titleStateMap);
+				title.put("状态",titleStateArray);
+
 				titlemark = false;
 			}
 
-
+			String state = "不合格";
 			for (Map.Entry<String, List<IndicatorDictionary>> childCodeEntry : groupedChildCode.entrySet()) {
 
 				for (IndicatorDictionary d : childCodeEntry.getValue()) {
@@ -573,9 +593,14 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 					}
 					if (mark) {
 						indicatormap.put("organizationShortName", resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getOrganizationShortName());//公司名
+
+						String  state2 = resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getState();//(-1:不合格;0:待确认;1:已确认)
+						state = stateConvert(state2,true);
 						mark = false;
 					}
-
+					if(!deptFlag && d.getOptionCode().contains("DF")){
+						continue;
+					}
 					//指标属性
 					indicatormap.put(d.getChildCode() + "_" + d.getOptionCode(), null == resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getNonQuantifiedValue() ? "" : resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getNonQuantifiedValue());
 					//指标id
@@ -584,6 +609,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 					indicatormap.put("IS_LH_" + d.getChildCode() + "_" + d.getOptionCode(), resultMap.get(d.getChildCode() + "_" + d.getOptionCode()).getIsQuantified2()?"1":"2");
 				}
 			}
+			indicatormap.put("state",state);//状态
 			mapList.add(indicatormap);
 		}
 
@@ -642,7 +668,9 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 			System.out.println("key="+key);
 
 			for (Map<String,String>  key2 : titleArray2) {
-				sheet.addMergedRegion(new CellRangeAddress(1, 1, colsize+1, colsize + key2.size()));
+				if(key2.size()>1){
+					sheet.addMergedRegion(new CellRangeAddress(1, 1, colsize+1, colsize + key2.size()));
+				}
 				colsize = colsize + key2.size();
 				for (String  key3 : key2.keySet()) {
 
@@ -681,6 +709,8 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 			rowdate++;
 		}
 
+
+
 		//隐藏行
 		sheet.getRow(3).setZeroHeight(true);
 		sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, colsize));
@@ -697,7 +727,11 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 	}
 
 	@Override
-	public boolean importExcel(MultipartFile file) throws IOException {
+	public boolean importExcel(MultipartFile file,HttpServletRequest request) throws IOException {
+
+//		String organizationEvaluationId = request.getHeader("organizationEvaluationId");
+//
+//		String indicatorId = request.getHeader("indicatorId");
 
 		List<LinkedHashMap<String, Object>> dataList = new ArrayList<>();
 		try {
@@ -717,7 +751,6 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 
 			Row headerRow = sheet.getRow(3);
 
-
 			// 遍历每一行数据
 			for (int i = startingRowIndex; i <= sheet.getLastRowNum(); i++) {
 				Row row = sheet.getRow(i);
@@ -786,6 +819,10 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 					System.out.println(entry.getKey().replace("ID_","")+"="+valueMap.get(entry.getKey().replace("ID_","")).toString());
 
 					info.setNonQuantifiedValue(valueMap.get(entry.getKey().replace("ID_","")).toString());
+
+					String  state2 = valueMap.get("state").toString();
+					String state = stateConvert(state2,false);
+					info.setState(state);
 					evaluationInfos.add(info);
 				}
 				this.saveOrUpdateBatch(evaluationInfos);
@@ -979,5 +1016,49 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 	}
 
 
+	/**
+	 * 状态抓换 (-1:不合格;0:待确认;1:已确认)
+	 * @return
+	 */
+	private String stateConvert(String state,boolean flge) {
+//		(-1:不合格;0:待确认;1:已确认)
+		String state2 = "";
+		if (flge) {
+
+			switch (state) {
+				case "-1":
+					state2 = "不合格";
+					break;
+				case "0":
+					state2 = "待确认";
+					break;
+				case "1":
+					state2 = "已确认";
+					break;
+				default:
+					state2 = "待确认";
+					break;
+			}
+
+		} else {
+
+			switch (state) {
+				case "不合格":
+					state2 = "-1";
+					break;
+				case "待确认":
+					state2 = "0";
+					break;
+				case "已确认":
+					state2 = "1";
+					break;
+				default:
+					state2 = "0";
+					break;
+			}
+		}
+		return state2;
+	}
+
 
 }