xiangpei
2024-08-07 369a252bfd68f5c02e285cd06d9bf482401e9d0e
点位时间优化
7个文件已修改
50 ■■■■ 已修改文件
ycl-pojo/src/main/java/com/ycl/platform/domain/entity/YwPoint.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/excel/PointExport.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/vo/YwPointVO.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/controller/YwPointController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/YwPointService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/entity/YwPoint.java
@@ -35,13 +35,13 @@
    @ApiModelProperty("点位开始时间")
    @TableField("start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime startTime;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;
    @ApiModelProperty("点位结束时间")
    @TableField("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime endTime;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;
    @ApiModelProperty("运维单位")
    @TableField(value = "unit_id", updateStrategy = FieldStrategy.IGNORED)
ycl-pojo/src/main/java/com/ycl/platform/domain/excel/PointExport.java
@@ -1,8 +1,11 @@
package com.ycl.platform.domain.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.util.Date;
/**
 * 点位导入导出
@@ -29,4 +32,14 @@
    @ExcelProperty("当前运维单位")
    private String unitName;
    @ColumnWidth(16)
    @DateTimeFormat("yyyy-MM-dd")
    @ExcelProperty("运维开始时间")
    private Date startTime;
    @ColumnWidth(16)
    @DateTimeFormat("yyyy-MM-dd")
    @ExcelProperty("运维结束时间")
    private Date endTime;
}
ycl-pojo/src/main/java/com/ycl/platform/domain/vo/YwPointVO.java
@@ -1,9 +1,11 @@
package com.ycl.platform.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ycl.platform.base.AbsVo;
import com.ycl.platform.domain.entity.YwPoint;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import enumeration.general.ImportantTagEnum;
@@ -26,10 +28,12 @@
    private String pointName;
    /** 点位开始时间 */
    private LocalDateTime startTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date startTime;
    /** 点位结束时间 */
    private LocalDateTime endTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endTime;
    /** 运维单位 */
    private Long unitId;
ycl-server/src/main/java/com/ycl/platform/controller/YwPointController.java
@@ -10,6 +10,7 @@
import lombok.RequiredArgsConstructor;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import org.springframework.validation.annotation.Validated;
import jakarta.validation.constraints.NotEmpty;
@@ -115,8 +116,8 @@
    @PostMapping("/import/{unitId}")
    @ApiOperation(value = "导入数据", notes = "导入数据")
    public Result importData(MultipartFile file, @PathVariable("unitId") Integer unitId) throws IOException {
        return ywPointService.importData(file, unitId);
    public Result importData(MultipartFile file, @PathVariable("unitId") Integer unitId, Date startTime, Date endTime) throws IOException {
        return ywPointService.importData(file, unitId, startTime, endTime);
    }
}
ycl-server/src/main/java/com/ycl/platform/service/YwPointService.java
@@ -10,6 +10,7 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Date;
import java.util.List;
/**
@@ -120,5 +121,5 @@
     * @param unitId 运维单位id
     * @return
     */
    Result importData(MultipartFile file, Integer unitId) throws IOException;
    Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime) throws IOException;
}
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;
@@ -233,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();
@@ -247,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("导入数据不能为空");
        }
@@ -255,6 +256,8 @@
        new LambdaUpdateChainWrapper<>(baseMapper)
                .in(YwPoint::getSerialNumber, pointList)
                .set(YwPoint::getUnitId, unitId)
                .set(YwPoint::getStartTime, startTime)
                .set(YwPoint::getEndTime, endTime)
                .update();
    }
ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml
@@ -81,7 +81,9 @@
               m.name as pointName,
               m.serial_number,
               m.ip,
               yu.unit_name
               yu.unit_name,
               yp.start_time,
               yp.end_time
        FROM
             t_yw_point yp
                 INNER JOIN t_monitor m ON yp.serial_number = m.serial_number