Commit 860196b7 authored by wujiang's avatar wujiang

修改时间转换

parent d473455a
...@@ -53,6 +53,8 @@ public class TdHygfJpInverterWarnDto { ...@@ -53,6 +53,8 @@ public class TdHygfJpInverterWarnDto {
@ApiModelProperty(value = "时间") @ApiModelProperty(value = "时间")
private Long time; private Long time;
private String stationName;
private String stationContact; private String stationContact;
private String userName; private String userName;
...@@ -63,8 +65,16 @@ public class TdHygfJpInverterWarnDto { ...@@ -63,8 +65,16 @@ public class TdHygfJpInverterWarnDto {
private String address; private String address;
private String area;
private Long createdTime; private Long createdTime;
private String timeLongFormat;
private String startTimeFormat;
private String recoverTimeFormat;
private List<String> stationIds; private List<String> stationIds;
private List<String> states; private List<String> states;
......
package com.yeejoin.amos.boot.module.hygf.api.util; package com.yeejoin.amos.boot.module.hygf.api.util;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -23,4 +24,50 @@ public class TimeUtil { ...@@ -23,4 +24,50 @@ public class TimeUtil {
todayEnd.set(Calendar.MILLISECOND, 999); todayEnd.set(Calendar.MILLISECOND, 999);
return todayEnd.getTime().getTime(); return todayEnd.getTime().getTime();
} }
public static String dateFormat(Long time) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return dateFormat.format(new Date(time));
}
public static String longFormat(Long time) {
if (time < 1000) {
return "0" + "秒";
}
long second = time / 1000;
long seconds = second % 60;
long minutes = second / 60;
long hours = 0;
if (minutes >= 60) {
hours = minutes / 60;
minutes = minutes % 60;
}
String timeString = "";
String secondString = "";
String minuteString = "";
String hourString = "";
if (seconds < 10) {
secondString = "0" + seconds + "秒";
} else {
secondString = seconds + "秒";
}
if (minutes < 10 && hours < 1) {
minuteString = minutes + "分";
} else if (minutes < 10) {
minuteString = "0" + minutes + "分";
} else {
minuteString = minutes + "分";
}
if (hours < 10) {
hourString = hours + "时";
} else {
hourString = hours + "" + "时";
}
if (hours != 0) {
timeString = hourString + minuteString + secondString;
} else {
timeString = minuteString + secondString;
}
return timeString;
}
} }
...@@ -6,6 +6,7 @@ import java.util.HashMap; ...@@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
...@@ -23,6 +24,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.JpStation; ...@@ -23,6 +24,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.JpStation;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterWarn; import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterWarn;
import com.yeejoin.amos.boot.module.hygf.api.service.ITdHygfJpInverterWarnService; import com.yeejoin.amos.boot.module.hygf.api.service.ITdHygfJpInverterWarnService;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterWarnMapper; import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterWarnMapper;
import com.yeejoin.amos.boot.module.hygf.api.util.TimeUtil;
/** /**
* 户用光伏监盘逆变器报警表服务实现类 * 户用光伏监盘逆变器报警表服务实现类
...@@ -74,11 +76,20 @@ public class TdHygfJpInverterWarnServiceImpl ...@@ -74,11 +76,20 @@ public class TdHygfJpInverterWarnServiceImpl
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>() JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, tdHygfJpInverterWarnDto.getThirdStationId())); .eq(JpStation::getThirdStationId, tdHygfJpInverterWarnDto.getThirdStationId()));
if (jpStation != null) { if (jpStation != null) {
tdHygfJpInverterWarnDto.setStationName(jpStation.getName());
tdHygfJpInverterWarnDto.setStationContact(jpStation.getStationContact()); tdHygfJpInverterWarnDto.setStationContact(jpStation.getStationContact());
tdHygfJpInverterWarnDto.setUserName(jpStation.getUserName()); tdHygfJpInverterWarnDto.setUserName(jpStation.getUserName());
tdHygfJpInverterWarnDto.setUserPhone(jpStation.getUserPhone()); tdHygfJpInverterWarnDto.setUserPhone(jpStation.getUserPhone());
tdHygfJpInverterWarnDto.setEmail(jpStation.getEmail()); tdHygfJpInverterWarnDto.setEmail(jpStation.getEmail());
tdHygfJpInverterWarnDto.setAddress(jpStation.getAddress()); tdHygfJpInverterWarnDto.setAddress(jpStation.getAddress());
tdHygfJpInverterWarnDto.setArea(jpStation.getArea());
if (tdHygfJpInverterWarnDto.getRecoverTime() != null) {
tdHygfJpInverterWarnDto
.setRecoverTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getRecoverTime()));
tdHygfJpInverterWarnDto.setTimeLongFormat(TimeUtil
.longFormat(tdHygfJpInverterWarnDto.getRecoverTime() - tdHygfJpInverterWarnDto.getStartTime()));
}
tdHygfJpInverterWarnDto.setStartTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getStartTime()));
} }
return tdHygfJpInverterWarnDto; return tdHygfJpInverterWarnDto;
......
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