|
@ -100,22 +100,42 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
String filePath = RuoYiConfig.getUploadPath() + newFileUrl; |
|
|
String filePath = RuoYiConfig.getUploadPath() + newFileUrl; |
|
|
|
|
|
|
|
|
ExcelUtil<DcSdhsEvent> util = new ExcelUtil<DcSdhsEvent>(DcSdhsEvent.class); |
|
|
ExcelUtil<DcSdhsEvent> util = new ExcelUtil<DcSdhsEvent>(DcSdhsEvent.class); |
|
|
importData = util.importExcel(new FileInputStream(filePath)); |
|
|
InputStream inputStream = new FileInputStream(filePath); |
|
|
|
|
|
importData = util.importExcel(inputStream); |
|
|
|
|
|
inputStream.close(); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
return AjaxResult.error("导入失败,请检查数据是否有误"); |
|
|
return AjaxResult.error("导入失败,请检查数据是否有误"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
redisCache.deleteObject(RedisKeyConstants.SDHS_EVENT); |
|
|
//redisCache.deleteObject(RedisKeyConstants.SDHS_EVENT);
|
|
|
|
|
|
|
|
|
|
|
|
//根据开始事件验重,如果有时间重复的则本次不导入
|
|
|
|
|
|
List<DcSdhsEvent> eventCache = redisCache.getCacheList(RedisKeyConstants.SDHS_EVENT); |
|
|
|
|
|
if (eventCache != null && eventCache.size() > 0){ |
|
|
|
|
|
Set<Date> oldStartTime = new HashSet<>(); |
|
|
|
|
|
eventCache.forEach(item -> { |
|
|
|
|
|
oldStartTime.add(item.getStartTime()); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (importData != null && importData.size() > 0) { |
|
|
|
|
|
|
|
|
|
|
|
List<Date> duplicateData = new ArrayList<>(); |
|
|
|
|
|
for (DcSdhsEvent importDatum : importData) { |
|
|
|
|
|
if (oldStartTime.contains(importDatum.getStartTime())){ |
|
|
|
|
|
duplicateData.add(importDatum.getStartTime()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (duplicateData.size() > 0){ |
|
|
|
|
|
return AjaxResult.error("本次导入含有重复数据",duplicateData); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
List<DcSdhsEvent> eventList = new ArrayList<>(); |
|
|
List<DcSdhsEvent> eventList = new ArrayList<>(); |
|
|
if (importData != null && importData.size() > 0) { |
|
|
if (importData != null && importData.size() > 0) { |
|
|
int id = 1; |
|
|
|
|
|
for (DcSdhsEvent dcSdhsEvent : importData) { |
|
|
for (DcSdhsEvent dcSdhsEvent : importData) { |
|
|
|
|
|
|
|
|
//插入id备用
|
|
|
|
|
|
dcSdhsEvent.setId(id); |
|
|
|
|
|
|
|
|
|
|
|
//是否多车事故
|
|
|
//是否多车事故
|
|
|
String carNum = dcSdhsEvent.getCarNum(); |
|
|
String carNum = dcSdhsEvent.getCarNum(); |
|
|
if (StringUtils.isNotEmpty(carNum)) { |
|
|
if (StringUtils.isNotEmpty(carNum)) { |
|
@ -164,13 +184,15 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
eventList.add(dcSdhsEvent); |
|
|
eventList.add(dcSdhsEvent); |
|
|
id++; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//不入数据库, 放入缓存
|
|
|
//不入数据库, 放入缓存
|
|
|
|
|
|
if (eventList.size() > 0) { |
|
|
redisCache.setCacheList(RedisKeyConstants.SDHS_EVENT, eventList); |
|
|
redisCache.setCacheList(RedisKeyConstants.SDHS_EVENT, eventList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Map<String, Object> fileInfo = new HashMap<>(); |
|
|
Map<String, Object> fileInfo = new HashMap<>(); |
|
|
fileInfo.put("fileName", fileName); |
|
|
fileInfo.put("fileName", fileName); |
|
|