xiangpei
2024-09-04 3486499f56e487cd6df88a8fa2448ff72d72a1e0
ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
@@ -213,6 +213,9 @@
        List<YwPoint> list = new LambdaQueryChainWrapper<>(baseMapper)
                .eq(YwPoint::getUnitId, unitId)
                .like(YwPoint::getPointName, keyword)
                .or()
                .eq(YwPoint::getUnitId, unitId)
                .like(YwPoint::getSerialNumber, keyword)
                .list();
        List data = list.stream().map(item -> {
            Map map = new HashMap<String, Object>();
@@ -248,10 +251,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 +272,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 +280,19 @@
            YwPoint point = new YwPoint();
            point.setImportantCommandImageTag("是".equals(item.getImportantCommandImageTagString()));
            point.setProvinceTag("是".equals(item.getProvinceTagString()));
            if (Objects.nonNull(unitId)) {
                point.setUnitId(Long.valueOf(unitId));
            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.setStartTime(startTime);
            point.setEndTime(endTime);
            point.setPointName(item.getPointName());
            point.setSerialNumber(item.getSerialNumber());
            return point;
@@ -290,19 +301,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();