ソースを参照

财务管理、支出管理导入修改。如果有一条数据有误那么所有的记录都不处理

zouxuan 4 年 前
コミット
2676e8546b

+ 16 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/FinancialExpenditureServiceImpl.java

@@ -56,7 +56,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
 		List<FinancialExpenditure> financialExpenditures = new ArrayList<>();
 		Map<String, Integer> organMap = getMap("organization", "name_", "id_", true, String.class, Integer.class);
 		Map<String, Integer> cooperationOrganMap = getMap("cooperation_organ", "name_", "id_", true, String.class, Integer.class);
-//		Map<String, Integer> phoneMap = getMap("sys_user", "phone_", "id_", true, String.class, Integer.class);
+		StringBuffer sb = new StringBuffer();
 		for (String e : sheetsListMap.keySet()) {
 			List<Map<String, Object>> sheet = sheetsListMap.get(e);
 			List<Object> collect = sheet.stream().map(m -> m.get("钉钉流程编号")).collect(Collectors.toList());
@@ -68,9 +68,10 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
 				throw new BizException("导入数据错误  重复的钉钉流程编号:{}",list.get(0));
 			}
 
-			valueIsNull: for (Map<String, Object> row : sheet) {
-
-				if (row.size() == 0){
+			valueIsNull: for (int j = 0; j < sheet.size(); j++) {
+				int rowNum = j + 2;
+				Map<String, Object> row = sheet.get(j);
+				if (row.size() == 0) {
 					continue;
 				}
 				JSONObject objectMap = new JSONObject();
@@ -89,9 +90,11 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
 						continue;
 					}
 					if (columnValue.equals("dingtalkProcessNo")) {
-						if(StringUtils.isEmpty(row.get(s).toString())){
-							LOGGER.error("支出记录导入异常:钉钉流程编号不可为空 param:{}",objectMap);
+						if (StringUtils.isEmpty(row.get(s).toString())) {
+							sb.append("第" + rowNum).append("行数据导入失败:钉钉流程编号不可为空;");
 							continue valueIsNull;
+						} else {
+							objectMap.put("incomeType", row.get(s));
 						}
 					}
 					if (columnValue.equals("feeProject")) {
@@ -105,7 +108,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
 					}
 					if (columnValue.equals("amount")) {
 						if(StringUtils.isEmpty(row.get(s).toString())){
-							LOGGER.error("支出记录导入异常:费用不可为空 param:{}",objectMap);
+							sb.append("第" + rowNum).append("行数据导入失败:费用不可为空;");
 							continue valueIsNull;
 						}else {
 							objectMap.put("amount", row.get(s));
@@ -115,7 +118,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
 					if (columnValue.equals("organName") && StringUtils.isNotEmpty(row.get(s).toString())) {
 						Integer integer = organMap.get(row.get(s));
 						if(integer == null){
-							LOGGER.error("支出记录导入异常:分部校验失败 param:{}",objectMap);
+							sb.append("第" + rowNum).append("行数据导入失败:分部校验失败;");
 							continue valueIsNull;
 						}else {
 							objectMap.put("organId", integer);
@@ -125,7 +128,8 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
 					if (columnValue.equals("cooperationOrganName") && StringUtils.isNotEmpty(row.get(s).toString())) {
 						Integer integer = cooperationOrganMap.get(row.get(s));
 						if(integer == null){
-							LOGGER.error("支出记录导入异常:合作单位校验失败 param:{}",objectMap);
+							sb.append("第" + rowNum).append("行数据导入失败:合作单位校验失败;");
+							continue valueIsNull;
 						}else {
 							objectMap.put("cooperationOrganId", integer);
 						}
@@ -154,6 +158,9 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
 				}
 			}
 		}
+		if(sb.length() > 0){
+			throw new BizException(sb.toString());
+		}
 		if(financialExpenditures.size() != 0){
 			financialExpenditureDao.batchInsert(financialExpenditures);
 		}

+ 0 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -199,7 +199,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
 		Map<String,String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.GOODS.getMsg());
 		List<Goods> goodsList = new ArrayList<>();
-//		Map<String, Integer> map = MapUtil.convertIntegerMap(goodsCategoryDao.queryCategotyMap());
 		Map<String, Integer> map = getMap("goods_category","name_","id_",true,String.class,Integer.class);
 		for (String e : sheetsListMap.keySet()) {
 			List<Map<String, Object>> sheet = sheetsListMap.get(e);

+ 3 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -379,10 +379,6 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
             if (collect == null || collect.size() == 0) {
                 continue;
             }
-//            List<String> list = studentPaymentRouteOrderDao.countByTransNo(collect);
-//            if (list != null && list.size() > 0) {
-//                throw new BizException("导入数据错误  重复的交易流水号:{}", list.get(0));
-//            }
             Date nowDate = new Date();
 
             List<Object> calenderIds = sheet.stream().map(m -> m.get("缴费单号")).collect(Collectors.toList());
@@ -538,11 +534,10 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
                 studentPaymentRouteOrders.add(studentPaymentRouteOrder);
             }
         }
+        if(sb.length() > 0){
+            throw new BizException(sb.toString());
+        }
         if (studentPaymentRouteOrders.size() > 0) {
-//            Map<String, List<StudentPaymentRouteOrder>> stringListMap = studentPaymentRouteOrders.stream().collect(Collectors.groupingBy(StudentPaymentRouteOrder::getTransNo));
-//            if (stringListMap.size() != studentPaymentRouteOrders.size()) {
-//                throw new BizException("导入失败:请勿录入重复的交易流水号");
-//            }
             studentPaymentRouteOrderDao.batchAdd(studentPaymentRouteOrders);
         } else {
             throw new BizException(sb.length() > 0 ? sb.toString() : "导入失败:没有可以录入的数据");