fuliqi
2024-08-31 6221c8b5df5eb0ee62dce79048c9c3f0dc3d0fc1
ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
@@ -248,10 +248,10 @@
    }
    @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) {
@@ -269,7 +269,7 @@
     * @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("导入数据不能为空");
        }
@@ -277,11 +277,19 @@
            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;
@@ -290,19 +298,17 @@
    }
    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();