时区及时间格式bug修复
This commit is contained in:
parent
913e88c3ea
commit
05c20c8502
|
@ -11,9 +11,14 @@ import com.ruoyi.project.outside.service.OutSideService;
|
||||||
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 java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OutSideServiceImpl implements OutSideService {
|
public class OutSideServiceImpl implements OutSideService {
|
||||||
|
@ -104,8 +109,20 @@ public class OutSideServiceImpl implements OutSideService {
|
||||||
sensorData.setDs(node.get("vocRtd").asText());
|
sensorData.setDs(node.get("vocRtd").asText());
|
||||||
sensorData.setDw(getUnitDescription(5));
|
sensorData.setDw(getUnitDescription(5));
|
||||||
// "vocTime":"2024-10-30T07:19:20.000+0000" 转为 yyyy-MM-dd HH:mm:ss
|
// "vocTime":"2024-10-30T07:19:20.000+0000" 转为 yyyy-MM-dd HH:mm:ss
|
||||||
String reportTime = node.get("vocTime").asText().replace("T", " ").substring(0, 19);
|
//String reportTime = node.get("vocTime").asText().replace("T", " ").substring(0, 19);
|
||||||
|
|
||||||
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSSZ");
|
||||||
|
String reportTime = "";
|
||||||
|
try {
|
||||||
|
Date result = df.parse(node.get("vocTime").asText());
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
sdf.setTimeZone(TimeZone.getDefault());
|
||||||
|
reportTime = sdf.format(result);
|
||||||
sensorData.setReportTime(reportTime);
|
sensorData.setReportTime(reportTime);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sensorData.setZt(node.get("vocRtd").asInt() > 5 ? "一级报警" : "正常");
|
sensorData.setZt(node.get("vocRtd").asInt() > 5 ? "一级报警" : "正常");
|
||||||
return sensorData;
|
return sensorData;
|
||||||
|
|
Loading…
Reference in New Issue