fuliqi
2024-08-08 01a30369e55a754c28dec4939a99e59aefecdc60
ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
@@ -36,6 +36,7 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
@@ -110,7 +111,6 @@
        YwPoint entity = baseMapper.selectById(form.getId());
        Assert.notNull(entity, "记录不存在");
        BeanUtils.copyProperties(form, entity);
        entity.setPointTag(form.getPointTag().stream().collect(Collectors.joining(",")));
        baseMapper.updateById(entity);
        return Result.ok("修改成功");
    }
@@ -150,11 +150,6 @@
    public Result page(YwPointQuery query) {
        IPage<YwPointVO> page = PageUtil.getPage(query, YwPointVO.class);
        baseMapper.page(page, query);
        page.getRecords().stream().forEach(point -> {
            if (StringUtils.hasText(point.getPointTagString())) {
                point.setPointTags(point.getPointTagString().split(","));
            }
        });
        return Result.ok().data(page.getRecords()).total(page.getTotal());
    }
@@ -168,9 +163,6 @@
        YwPoint entity = baseMapper.selectById(id);
        Assert.notNull(entity, "记录不存在");
        YwPointVO vo = YwPointVO.getVoByEntity(entity, null);
        if (StringUtils.hasText(entity.getPointTag())) {
            vo.setPointTags(entity.getPointTag().split(","));
        }
        if (Objects.nonNull(entity.getDeptId())) {
            vo.setDeptIds(sysDeptMapper.selectParents(entity.getDeptId()));
        }
@@ -242,9 +234,9 @@
    }
    @Override
    public Result importData(MultipartFile file, Integer unitId) throws IOException {
    public Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime) throws IOException {
        Consumer<List<PointExport>> consumer = (dataList) -> {
            this.updatePoint(dataList, unitId);
            this.updatePoint(dataList, unitId, startTime, endTime);
        };
        EasyExcel.read(file.getInputStream(), PointExport.class , new CurrencyDataListener(consumer)).headRowNumber(1).doReadAll();
        return Result.ok();
@@ -256,7 +248,7 @@
     * @param dataList
     * @param unitId
     */
    private void updatePoint(List<PointExport> dataList, Integer unitId) {
    private void updatePoint(List<PointExport> dataList, Integer unitId, Date startTime, Date endTime) {
        if (CollectionUtils.isEmpty(dataList)) {
            throw new RuntimeException("导入数据不能为空");
        }
@@ -264,6 +256,8 @@
        new LambdaUpdateChainWrapper<>(baseMapper)
                .in(YwPoint::getSerialNumber, pointList)
                .set(YwPoint::getUnitId, unitId)
                .set(YwPoint::getStartTime, startTime)
                .set(YwPoint::getEndTime, endTime)
                .update();
    }