Commit c2eced98 authored by wujiang's avatar wujiang

添加格式转换

parent 860196b7
......@@ -14,12 +14,11 @@ import java.util.Date;
* @date 2023-09-19
*/
@Data
@ApiModel(value="TdHygfJpCollectorHistoryDto", description="户用光伏监盘采集器历史表")
@ApiModel(value = "TdHygfJpCollectorHistoryDto", description = "户用光伏监盘采集器历史表")
public class TdHygfJpCollectorHistoryDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "sn编码")
private String snCode;
......@@ -35,4 +34,6 @@ public class TdHygfJpCollectorHistoryDto {
@ApiModelProperty(value = "第三方厂商标识")
private String thirdCode;
private String timeFormat;
}
......@@ -15,12 +15,11 @@ import java.util.Date;
* @date 2023-09-19
*/
@Data
@ApiModel(value="TdHygfJpInvertorElecHistoryDto", description="户用光伏监盘逆变器电能历史表")
@ApiModel(value = "TdHygfJpInvertorElecHistoryDto", description = "户用光伏监盘逆变器电能历史表")
public class TdHygfJpInvertorElecHistoryDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "sn编码")
private String snCode;
......@@ -53,4 +52,6 @@ public class TdHygfJpInvertorElecHistoryDto {
private Long createdTime;
private String timeFormat;
}
......@@ -30,6 +30,11 @@ public class TimeUtil {
return dateFormat.format(new Date(time));
}
public static String minuteFormat(Long time) {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
return dateFormat.format(new Date(time));
}
public static String longFormat(Long time) {
if (time < 1000) {
return "0" + "秒";
......
......@@ -54,8 +54,14 @@ public class TdHygfJpCollectorHistoryServiceImpl
JpCollector collector = jpCollectorServiceImpl.getById(id);
if (collector != null) {
return this.baseMapper.dayList(collector.getSnCode(), collector.getThirdStationId(),
TimeUtil.getStartTimeOfDay(day), TimeUtil.getEndTimeOfDay(day));
List<TdHygfJpCollectorHistoryDto> list = this.baseMapper.dayList(collector.getSnCode(),
collector.getThirdStationId(), TimeUtil.getStartTimeOfDay(day), TimeUtil.getEndTimeOfDay(day));
if (!list.isEmpty()) {
list.forEach(i -> {
i.setTimeFormat(TimeUtil.minuteFormat(i.getTime()));
});
}
return list;
}
return new ArrayList<>();
}
......
......@@ -53,6 +53,18 @@ public class TdHygfJpInverterWarnServiceImpl
tdHygfJpInverterWarnDto.setStates(Arrays.asList(s));
}
List<TdHygfJpInverterWarnDto> list = this.baseMapper.list(tdHygfJpInverterWarnDto);
if (!list.isEmpty()) {
list.forEach(i -> {
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, i.getThirdStationId()));
if (jpStation != null) {
i.setAddress(jpStation.getAddress());
}
if (i.getStartTime() != null) {
i.setStartTimeFormat(TimeUtil.dateFormat(i.getStartTime()));
}
});
}
PageInfo<TdHygfJpInverterWarnDto> page = new PageInfo(list);
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TdHygfJpInverterWarnDto> pagenew = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<TdHygfJpInverterWarnDto>();
pagenew.setCurrent(pageNum);
......@@ -89,8 +101,10 @@ public class TdHygfJpInverterWarnServiceImpl
tdHygfJpInverterWarnDto.setTimeLongFormat(TimeUtil
.longFormat(tdHygfJpInverterWarnDto.getRecoverTime() - tdHygfJpInverterWarnDto.getStartTime()));
}
if (tdHygfJpInverterWarnDto.getStartTime() != null) {
tdHygfJpInverterWarnDto.setStartTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getStartTime()));
}
}
return tdHygfJpInverterWarnDto;
}
......
......@@ -51,8 +51,14 @@ public class TdHygfJpInvertorElecHistoryServiceImpl extends
public List<TdHygfJpInvertorElecHistoryDto> dayList(long id, Date day) {
JpInverter invertor = jpInvertorServiceImpl.getById(id);
if (invertor != null) {
return this.baseMapper.dayList(invertor.getSnCode(), invertor.getThirdStationId(),
TimeUtil.getStartTimeOfDay(day), TimeUtil.getEndTimeOfDay(day));
List<TdHygfJpInvertorElecHistoryDto> list = this.baseMapper.dayList(invertor.getSnCode(),
invertor.getThirdStationId(), TimeUtil.getStartTimeOfDay(day), TimeUtil.getEndTimeOfDay(day));
if (!list.isEmpty()) {
list.forEach(i -> {
i.setTimeFormat(TimeUtil.minuteFormat(i.getTime()));
});
}
return list;
}
return new ArrayList<>();
}
......@@ -128,7 +134,8 @@ public class TdHygfJpInvertorElecHistoryServiceImpl extends
&& map.get("third_station_id") != null && map.get("sn_code") != null
&& map.get("month") != null && map.get("year") != null
&& dto.getThirdStationId().equals(map.get("third_station_id").toString())
&& dto.getSnCode().equals(map.get("sn_code").toString()) && dto.getYear().equals(map.get("year").toString())
&& dto.getSnCode().equals(map.get("sn_code").toString())
&& dto.getYear().equals(map.get("year").toString())
&& dto.getMonth().equals(map.get("month").toString())) {
time = dto.getCreatedTime();
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment