| | |
| | | |
| | | @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) |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 点位导入导出 |
| | |
| | | @ExcelProperty("当前运维单位") |
| | | private String unitName; |
| | | |
| | | @ColumnWidth(16) |
| | | @DateTimeFormat("yyyy-MM-dd") |
| | | @ExcelProperty("运维开始时间") |
| | | private Date startTime; |
| | | |
| | | @ColumnWidth(16) |
| | | @DateTimeFormat("yyyy-MM-dd") |
| | | @ExcelProperty("运维结束时间") |
| | | private Date endTime; |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | @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); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @param unitId 运维单位id |
| | | * @return |
| | | */ |
| | | Result importData(MultipartFile file, Integer unitId) throws IOException; |
| | | Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime) throws IOException; |
| | | } |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @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(); |
| | |
| | | * @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("导入数据不能为空"); |
| | | } |
| | |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | | .in(YwPoint::getSerialNumber, pointList) |
| | | .set(YwPoint::getUnitId, unitId) |
| | | .set(YwPoint::getStartTime, startTime) |
| | | .set(YwPoint::getEndTime, endTime) |
| | | .update(); |
| | | } |
| | | |
| | |
| | | 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 |