|
|
|
@ -71,6 +71,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
Map<String, List> errmap = new HashMap<String, List>();
|
|
|
|
|
List<String> errArea = new ArrayList<String>();
|
|
|
|
|
List<String> errFile = new ArrayList<String>();
|
|
|
|
|
ArrayList<String> rowErr = new ArrayList<String>();
|
|
|
|
|
// 待增加的
|
|
|
|
|
List<PreDataInfo> all2Insert = new ArrayList<PreDataInfo>();
|
|
|
|
|
//excel读出的 所有
|
|
|
|
@ -87,26 +88,42 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
XSSFWorkbook workbook = null;
|
|
|
|
|
File tmpf = new File(filePath + ".temp");
|
|
|
|
|
File f = new File(filePath);
|
|
|
|
|
String errMsg= ",可能版本过低,请使用导出的excel文件,编辑后再导入";
|
|
|
|
|
// file.temp 文件存在
|
|
|
|
|
if (tmpf.exists()) {
|
|
|
|
|
//删除 file
|
|
|
|
|
workbook = new XSSFWorkbook(tmpf);
|
|
|
|
|
try {
|
|
|
|
|
workbook = new XSSFWorkbook(tmpf);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(filePath+ errMsg);
|
|
|
|
|
log.error(e);
|
|
|
|
|
errFile.add(tmpf.getName()+errMsg);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!f.exists()) {
|
|
|
|
|
log.error(filePath + " 文件 不存在! ");
|
|
|
|
|
errFile.add(f.getName());
|
|
|
|
|
log.error(filePath + ",文件 不存在!");
|
|
|
|
|
errFile.add(f.getName()+ ",文件 不存在!");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
workbook = new XSSFWorkbook(f);
|
|
|
|
|
try {
|
|
|
|
|
workbook = new XSSFWorkbook(f);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(filePath+errMsg);
|
|
|
|
|
log.error(e);
|
|
|
|
|
errFile.add(f.getName()+errMsg);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Excel导入
|
|
|
|
|
try {
|
|
|
|
|
PreDataInfo pre = new PreDataInfo();
|
|
|
|
|
//excel数据 --> java bean
|
|
|
|
|
List<PreDataInfo> subPreData = ExcelOperation.readExcel4Update(workbook, Constant.EXCEL_TEMPLATE_INIT_ROW, 0, pre, "id", "dataId", "workRange","sysCode","updateTime","userTablespaceStatus", "checkoutIndicateStatus", "checkoutPayStatus", "userTablespacePath", "checkoutIndicatePath", "checkoutPayPath", "sqlList", "dataVersion", "collectingTime", "collUpdate");
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
List<PreDataInfo> subPreData = ExcelOperation.readExcel4Update(workbook, Constant.EXCEL_TEMPLATE_INIT_ROW, 0, f.getName(), rowErr,pre, "id", "dataId", "workRange","sysCode","updateTime","userTablespaceStatus", "checkoutIndicateStatus", "checkoutPayStatus", "userTablespacePath", "checkoutIndicatePath", "checkoutPayPath", "sqlList", "dataVersion", "collectingTime", "collUpdate");
|
|
|
|
|
if (null != subPreData && subPreData.size() > 0) {
|
|
|
|
|
// 是否是 同一个县区的 系统--是则 加入
|
|
|
|
|
boolean isSameArea = true;
|
|
|
|
@ -115,7 +132,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
if (!areaCode.equals(preDataInfo.getAreaCode())) {
|
|
|
|
|
// TODO 不是同一个地区: isSameArea = false;
|
|
|
|
|
// isSameArea = false;
|
|
|
|
|
errArea.add(areaCode);
|
|
|
|
|
// errArea.add(areaCode);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -134,12 +151,18 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (errFile.size() > 0) {
|
|
|
|
|
errmap.put("fileUnExist",errFile);
|
|
|
|
|
if (rowErr.size() > 0) {
|
|
|
|
|
errmap.put("err",rowErr);
|
|
|
|
|
}
|
|
|
|
|
if (errArea.size() > 0) {
|
|
|
|
|
errmap.put("areaUnImport", errArea);
|
|
|
|
|
if (errFile.size() > 0) {
|
|
|
|
|
if (errmap.containsKey("err")) {
|
|
|
|
|
errFile.addAll(errmap.get("err"));
|
|
|
|
|
}
|
|
|
|
|
errmap.put("err",errFile);
|
|
|
|
|
}
|
|
|
|
|
// if (errArea.size() > 0) {
|
|
|
|
|
// errmap.put("areaUnImport", errArea);
|
|
|
|
|
// }
|
|
|
|
|
//根据 操作 类别 分类(修改, 新增行政区划,新增信息系统)
|
|
|
|
|
if (all.size() > 0) {
|
|
|
|
|
for (PreDataInfo preDataInfo : all) {
|
|
|
|
@ -178,7 +201,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
Map<String, Integer> syscodeMap = new HashMap<String, Integer>();
|
|
|
|
|
// 去掉 已经导入的系统。。(例如 excel反复导入)
|
|
|
|
|
//在 pre_data_info表中 新增 操作为(新增行政区划)的系统
|
|
|
|
|
allAreaInsert = removeRepeat(list4AddArea);
|
|
|
|
|
allAreaInsert = this.removeRepeat(list4AddArea);
|
|
|
|
|
if (allAreaInsert.size() > 0) {
|
|
|
|
|
list4AddSystem.addAll(allAreaInsert);
|
|
|
|
|
}
|
|
|
|
@ -207,7 +230,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
}
|
|
|
|
|
//去掉 已经导入的系统。。(例如 excel反复导入)
|
|
|
|
|
//在 pre_data_info表中 新增 操作为(新增信息系统)的系统
|
|
|
|
|
all2Insert = removeRepeat(all2Insert);
|
|
|
|
|
all2Insert = this.removeRepeat(all2Insert);
|
|
|
|
|
if (all2Insert.size() > 0) {
|
|
|
|
|
insertBatch(all2Insert);
|
|
|
|
|
}
|
|
|
|
@ -328,6 +351,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
List<String> areacodeList = new ArrayList<String>();
|
|
|
|
|
Map<String,RegionalismEntity> areaMap = new HashMap<String, RegionalismEntity>();
|
|
|
|
|
for (PreDataInfo preDataInfo : list4AddArea) {
|
|
|
|
|
// areacodeList 存放 地区code
|
|
|
|
|
areacodeList.add(preDataInfo.getAreaCode().toLowerCase());
|
|
|
|
|
RegionalismEntity region = new RegionalismEntity();
|
|
|
|
|
region.setCode(preDataInfo.getAreaCode().toLowerCase());
|
|
|
|
@ -337,6 +361,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
}
|
|
|
|
|
List<RegionalismEntity> existEntity = regionalismCodeDao.findExistRegionalism(areacodeList);
|
|
|
|
|
for (RegionalismEntity regionalismEntity : existEntity) {
|
|
|
|
|
//去掉重复的地区
|
|
|
|
|
areaMap.remove(regionalismEntity.getCode());
|
|
|
|
|
}
|
|
|
|
|
//新增 地区
|
|
|
|
|