diff --git a/src/com/platform/service/impl/PreDataInfoServiceImpl.java b/src/com/platform/service/impl/PreDataInfoServiceImpl.java index 293193a5..79f04f96 100644 --- a/src/com/platform/service/impl/PreDataInfoServiceImpl.java +++ b/src/com/platform/service/impl/PreDataInfoServiceImpl.java @@ -186,6 +186,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService { } //TODO 去掉 已经导入的系统。。(例如 excel反复导入) //在 pre_data_info表中 新增 操作为(新增信息系统)的系统 + all2Insert = removeRepeat(all2Insert); if (all2Insert.size() > 0) { preDataInfoDao.insertBatch(all2Insert); } @@ -217,6 +218,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService { } //TODO 去掉 已经导入的系统。。(例如 excel反复导入) //在 pre_data_info表中 新增 操作为(新增行政区划)的系统 + allAreaInsert = removeRepeat(allAreaInsert); if (allAreaInsert.size() > 0) { preDataInfoDao.insertBatch(allAreaInsert); } @@ -444,4 +446,29 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService { return pathStandard; } + /** 新增系统时,去掉系统已存在的 新增操作里的 + * @param allAreaInsert + * @throws Exception + */ + private List removeRepeat(List allAreaInsert) throws Exception { + Map excelAdd = new HashMap(); + List allResult = new ArrayList(); + //系统已存在的 系统 + List sysInDataBase = preDataInfoDao.findAll(); + Map sysInDataBaseMap = new HashMap(); + for (PreDataInfo preDataInfo : sysInDataBase) { + sysInDataBaseMap.put(preDataInfo.getAreaCode()+"_"+preDataInfo.getSysName().trim(), null); + } + //本次新增的系统 + for (PreDataInfo pre : allAreaInsert) { + excelAdd.put(pre.getAreaCode()+"_"+pre.getSysName().trim(), pre); + } + for (String key : excelAdd.keySet()) { + if (!sysInDataBaseMap.containsKey(key)) { + allResult.add(excelAdd.get(key)); + } + } + return allResult; + } + }