|
|
|
@ -133,7 +133,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
PreDataInfo pre = new PreDataInfo();
|
|
|
|
|
//excel数据 --> java bean
|
|
|
|
|
@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");
|
|
|
|
|
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;
|
|
|
|
@ -160,25 +160,48 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rowErr.size() > 0) {
|
|
|
|
|
errmap.put("err",rowErr);
|
|
|
|
|
}
|
|
|
|
|
if (errFile.size() > 0) {
|
|
|
|
|
if (errmap.containsKey("err")) {
|
|
|
|
|
errFile.addAll( (Collection<? extends HashMap<String, Object>>) errmap.get("err"));
|
|
|
|
|
}
|
|
|
|
|
errmap.put("err",errFile);
|
|
|
|
|
}
|
|
|
|
|
// if (errArea.size() > 0) {
|
|
|
|
|
// errmap.put("areaUnImport", errArea);
|
|
|
|
|
// }
|
|
|
|
|
if (errmap.containsKey("err")) {
|
|
|
|
|
return errmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据 操作 类别 分类(修改, 新增行政区划,新增信息系统)
|
|
|
|
|
if (all.size() > 0) {
|
|
|
|
|
for (PreDataInfo preDataInfo : all) {
|
|
|
|
|
String sysName = preDataInfo.getSysName();
|
|
|
|
|
boolean iserr = false;
|
|
|
|
|
if (null == sysName ) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains("\\")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains("/")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains("?")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains(":")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains("*")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains("<")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains(">")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains("|")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (sysName.contains("\"")) {
|
|
|
|
|
iserr = true;
|
|
|
|
|
}
|
|
|
|
|
if (iserr) {
|
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("value", "系统名称不能使用?*\":<>|/\\");
|
|
|
|
|
map.put("name", preDataInfo.getCityName()+"-"+preDataInfo.getDistrictName()+"-"+preDataInfo.getSysName());
|
|
|
|
|
rowErr.add(map);
|
|
|
|
|
}
|
|
|
|
|
String updateType = preDataInfo.getIsupdate();
|
|
|
|
|
switch (updateType)
|
|
|
|
|
{
|
|
|
|
@ -199,15 +222,26 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查 地区 是否没有-(没有则添加新地区):
|
|
|
|
|
if (list4AddArea.size() > 0) {
|
|
|
|
|
this.addArea(list4AddArea, rowErr);
|
|
|
|
|
}
|
|
|
|
|
if (errFile.size() > 0) {
|
|
|
|
|
rowErr.addAll(errFile);
|
|
|
|
|
// errmap.put("err",errFile);
|
|
|
|
|
}
|
|
|
|
|
if (rowErr.size() > 0) {
|
|
|
|
|
errmap.put("err", rowErr);
|
|
|
|
|
}
|
|
|
|
|
if (errmap.containsKey("err")) {
|
|
|
|
|
return errmap;
|
|
|
|
|
}
|
|
|
|
|
// 记录 操作了 多少条记录
|
|
|
|
|
errmap.put("system", list4AddSystem.size());
|
|
|
|
|
errmap.put("area", list4AddArea.size());
|
|
|
|
|
errmap.put("update", list4Update.size());
|
|
|
|
|
|
|
|
|
|
// 查 地区 是否没有-(没有则添加新地区):
|
|
|
|
|
if (list4AddArea.size() > 0) {
|
|
|
|
|
this.addArea(list4AddArea);
|
|
|
|
|
}
|
|
|
|
|
//在 pre_data_info表中 新增 操作为(新增行政区划)的系统 -- start
|
|
|
|
|
List<PreDataInfo> allAreaInsert = new ArrayList<PreDataInfo>();
|
|
|
|
|
List<String> sysNamesArea = new ArrayList<String>();
|
|
|
|
@ -225,6 +259,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
}
|
|
|
|
|
// 查系统 是否没有-(没有则在 pre_data_info添加新系统):
|
|
|
|
|
if (list4AddSystem.size() > 0) {
|
|
|
|
|
//新增系统
|
|
|
|
|
this.AddSystem(list4AddSystem);
|
|
|
|
|
List<String> sysNames = new ArrayList<String>();
|
|
|
|
|
for (PreDataInfo preDataInfo : list4AddSystem) {
|
|
|
|
@ -241,16 +276,27 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
for ( PreDataInfo systemEntity : list4AddSystem) {
|
|
|
|
|
PreDataInfo systemFull = new PreDataInfo();
|
|
|
|
|
BeanCopy.copyBean(systemEntity, systemFull);
|
|
|
|
|
systemFull.setSysCode(syscodeMap.get(systemFull.getSysName()));
|
|
|
|
|
systemFull.setUpdateTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
|
all2Insert.add(systemFull);
|
|
|
|
|
if (syscodeMap.containsKey(systemFull.getSysName())) {
|
|
|
|
|
systemFull.setSysCode(syscodeMap.get(systemFull.getSysName()));
|
|
|
|
|
systemFull.setUpdateTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
|
all2Insert.add(systemFull);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("value", "无此系统,请新增");
|
|
|
|
|
map.put("name", systemEntity.getCityName()+"-"+systemEntity.getDistrictName()+"-"+systemEntity.getSysName());
|
|
|
|
|
rowErr.add(map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//去掉 已经导入的系统。。(例如 excel反复导入)
|
|
|
|
|
//在 pre_data_info表中 新增 操作为(新增信息系统)的系统
|
|
|
|
|
all2Insert = this.removeRepeat(all2Insert);
|
|
|
|
|
if (all2Insert.size() > 0) {
|
|
|
|
|
insertBatch(all2Insert);
|
|
|
|
|
insertBatch(all2Insert,rowErr);
|
|
|
|
|
if (rowErr.size() > 0) {
|
|
|
|
|
errmap.put("err",rowErr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//在 pre_data_info表中 新增 操作为(新增行政区划)的系统 -- end
|
|
|
|
@ -273,10 +319,17 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
for (PreDataInfo preUpdate : list4Update) {
|
|
|
|
|
PreDataInfo UpdateFull = new PreDataInfo();
|
|
|
|
|
BeanCopy.copyBean(preUpdate, UpdateFull);
|
|
|
|
|
|
|
|
|
|
UpdateFull.setSysCode(syscodeMap.get(UpdateFull.getSysName()));
|
|
|
|
|
UpdateFull.setUpdateTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
|
allUpdate.add(UpdateFull);
|
|
|
|
|
if (syscodeMap.containsKey(UpdateFull.getSysName())) {
|
|
|
|
|
UpdateFull.setSysCode(syscodeMap.get(UpdateFull.getSysName()));
|
|
|
|
|
UpdateFull.setUpdateTime(DateForm.date2StringBysecond(new Date()));
|
|
|
|
|
allUpdate.add(UpdateFull);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("value", "无此系统,请新增");
|
|
|
|
|
map.put("name", preUpdate.getCityName()+"-"+preUpdate.getDistrictName()+"-"+preUpdate.getSysName());
|
|
|
|
|
rowErr.add(map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 更新
|
|
|
|
|
for (PreDataInfo preEntity : allUpdate) {
|
|
|
|
@ -284,10 +337,18 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
preDataInfoDao.update(preEntity);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){
|
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("value", "请检查是否有填写错误,比如:错别字、超出范围等");
|
|
|
|
|
map.put("name", preEntity.getAreaCode()+"-"+preEntity.getCityName()+"-"+preEntity.getDistrictName()+"-"+preEntity.getSysName());
|
|
|
|
|
log.error(preEntity.getAreaCode()+"-"+preEntity.getCityName()+"-"+preEntity.getDistrictName()+"-"+preEntity.getSysName());
|
|
|
|
|
rowErr.add(map);
|
|
|
|
|
log.error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (rowErr.size() > 0 && !errmap.keySet().contains("err")) {
|
|
|
|
|
errmap.put("err",rowErr);
|
|
|
|
|
}
|
|
|
|
|
return errmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -364,7 +425,7 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private int addArea(List<PreDataInfo> list4AddArea)throws Exception {
|
|
|
|
|
private int addArea(List<PreDataInfo> list4AddArea, List<HashMap<String, Object>> err)throws Exception {
|
|
|
|
|
int insertNum = 0;
|
|
|
|
|
List<String> areacodeList = new ArrayList<String>();
|
|
|
|
|
Map<String,RegionalismEntity> areaMap = new HashMap<String, RegionalismEntity>();
|
|
|
|
@ -379,8 +440,16 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
}
|
|
|
|
|
List<RegionalismEntity> existEntity = regionalismCodeDao.findExistRegionalism(areacodeList);
|
|
|
|
|
for (RegionalismEntity regionalismEntity : existEntity) {
|
|
|
|
|
insertNum = -1;
|
|
|
|
|
//去掉重复的地区
|
|
|
|
|
areaMap.remove(regionalismEntity.getCode());
|
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("value", "新增的地区已存在");
|
|
|
|
|
map.put("name", regionalismEntity.getCode()+"-"+regionalismEntity.getCityName()+"-"+regionalismEntity.getDistrictName());
|
|
|
|
|
err.add(map);
|
|
|
|
|
}
|
|
|
|
|
if(-1 == insertNum){
|
|
|
|
|
return insertNum;
|
|
|
|
|
}
|
|
|
|
|
//新增 地区
|
|
|
|
|
if (areaMap.size() > 0) {
|
|
|
|
@ -521,8 +590,9 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
|
|
|
|
|
/** 批量插入--一次限定多少个(将allAreaInsert 分成 设定大小的 集合) 比如 allAreaInsert 有 100个, 按照 11个为一个集合分,可分成 10个集合
|
|
|
|
|
* @param allAreaInsert
|
|
|
|
|
* @param rowErr
|
|
|
|
|
*/
|
|
|
|
|
private void insertBatch(List<PreDataInfo> allAreaInsert) {
|
|
|
|
|
private void insertBatch(List<PreDataInfo> allAreaInsert, List<HashMap<String, Object>> rowErr) {
|
|
|
|
|
if (allAreaInsert.size() > 0) {
|
|
|
|
|
int listSize = allAreaInsert.size();
|
|
|
|
|
int loopSize = listSize/Configs.NUM_ONE_IMPORT_EXCEL;
|
|
|
|
@ -540,7 +610,14 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
|
|
|
|
|
try {
|
|
|
|
|
preDataInfoDao.insertBatch(arrayList);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getStackTrace());
|
|
|
|
|
for (PreDataInfo preDataInfo : arrayList) {
|
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("value", "请检查是否有填写错误,比如:错别字、超出范围等");
|
|
|
|
|
map.put("name", preDataInfo.getAreaCode()+"-"+preDataInfo.getCityName()+"-"+preDataInfo.getDistrictName()+"-"+preDataInfo.getSysName());
|
|
|
|
|
log.error(preDataInfo.getAreaCode()+"-"+preDataInfo.getCityName()+"-"+preDataInfo.getDistrictName()+"-"+preDataInfo.getSysName());
|
|
|
|
|
rowErr.add(map);
|
|
|
|
|
}
|
|
|
|
|
log.error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|