| | |
| | | } |
| | | |
| | | @Override |
| | | public Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime) throws IOException { |
| | | public Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime, Boolean needUpdateUnit) throws IOException { |
| | | Consumer<List<PointExport>> consumer = (dataList) -> { |
| | | try { |
| | | this.updatePoint(dataList, unitId, startTime, endTime); |
| | | this.updatePoint(dataList, unitId, startTime, endTime, needUpdateUnit); |
| | | } catch (ExecutionException e) { |
| | | e.printStackTrace(); |
| | | } catch (InterruptedException e) { |
| | |
| | | * @param unitId |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updatePoint(List<PointExport> dataList, Integer unitId, Date startTime, Date endTime) throws ExecutionException, InterruptedException { |
| | | public void updatePoint(List<PointExport> dataList, Integer unitId, Date startTime, Date endTime, Boolean needUpdateUnit) throws ExecutionException, InterruptedException { |
| | | if (CollectionUtils.isEmpty(dataList)) { |
| | | throw new RuntimeException("导入数据不能为空"); |
| | | } |
| | |
| | | YwPoint point = new YwPoint(); |
| | | point.setImportantCommandImageTag("是".equals(item.getImportantCommandImageTagString())); |
| | | point.setProvinceTag("是".equals(item.getProvinceTagString())); |
| | | point.setDeptTag("是".equals(item.getDeptTag())); |
| | | if (needUpdateUnit) { |
| | | if (Objects.nonNull(unitId)) { |
| | | point.setUnitId(Long.valueOf(unitId)); |
| | | } |
| | | point.setStartTime(startTime); |
| | | point.setEndTime(endTime); |
| | | } else { |
| | | point.setUnitId(null); |
| | | point.setStartTime(null); |
| | | point.setEndTime(null); |
| | | } |
| | | |
| | | point.setPointName(item.getPointName()); |
| | | point.setSerialNumber(item.getSerialNumber()); |
| | | return point; |
| | |
| | | } |
| | | |
| | | public void waitAllFinishAndGetResult(List<YwPoint> dataList) throws InterruptedException, ExecutionException { |
| | | List<FutureTask<Boolean>> resultList = new ArrayList<>(512); |
| | | List<Boolean> data = new ArrayList<>(512); |
| | | int start = 0; |
| | | Date startTime = new Date(); |
| | | while (true) { |
| | | if (dataList.size() < start + 100) { |
| | | if (dataList.size() < start + 800) { |
| | | List<YwPoint> list = dataList.subList(start, dataList.size() - 1); |
| | | this.baseMapper.updatePoint(list); |
| | | break; |
| | | } else { |
| | | List<YwPoint> list = dataList.subList(start, start + 100); |
| | | List<YwPoint> list = dataList.subList(start, start + 800); |
| | | this.baseMapper.updatePoint(list); |
| | | start += 100; |
| | | start += 800; |
| | | } |
| | | } |
| | | Date endTime = new Date(); |