RiskAssessmentConvert.java
2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package cn.com.glsx.admin.modules.converter;
import cn.com.glsx.admin.modules.entity.Vehicle;
import cn.com.glsx.admin.modules.model.vo.StayPointListVO;
import cn.com.glsx.admin.modules.utils.DateUtil;
import cn.com.glsx.devicemonitor.api.dto.request.ResidentRequest;
import cn.com.glsx.devicemonitor.api.dto.response.GpsLocation;
import cn.com.glsx.devicemonitor.api.dto.response.StayPointRecordDTO;
import java.util.Optional;
/**
* 风险评估转换
*/
public class RiskAssessmentConvert {
/**
* 风险评估转换
*/
public static StayPointListVO buildStayPointListVO(StayPointRecordDTO stayPointRecordDTO, Vehicle vehicle, String sn, String address) {
StayPointListVO stayPointListVO = new StayPointListVO();
stayPointListVO.setSn(sn);
Optional.ofNullable(vehicle).map(Vehicle::getOwnerName).ifPresent(stayPointListVO::setOwnerName);
Optional.ofNullable(vehicle).map(Vehicle::getVin).ifPresent(stayPointListVO::setVin);
stayPointListVO.setBeginTime(stayPointRecordDTO.getBeginTime());
stayPointListVO.setEndTime(stayPointRecordDTO.getEndTime());
//时长
Optional.ofNullable(stayPointRecordDTO.getDuration()).map(e -> e * 1000).map(Integer::longValue).map(DateUtil::normalFormatDuration).ifPresent(stayPointListVO::setDuration);
stayPointListVO.setLocationType("GPS");
Optional.of(stayPointRecordDTO).map(StayPointRecordDTO::getStayGps).map(GpsLocation::getElat).ifPresent(stayPointListVO::setElat);
Optional.of(stayPointRecordDTO).map(StayPointRecordDTO::getStayGps).map(GpsLocation::getElng).ifPresent(stayPointListVO::setElng);
Optional.of(stayPointRecordDTO).map(StayPointRecordDTO::getStayGps).map(GpsLocation::getBlat).ifPresent(stayPointListVO::setBlat);
Optional.of(stayPointRecordDTO).map(StayPointRecordDTO::getStayGps).map(GpsLocation::getBlng).ifPresent(stayPointListVO::setBlng);
stayPointListVO.setAddress(address);
return stayPointListVO;
}
public static ResidentRequest buildResidentRequest(String sn, String beginTime, String endTime, Integer locInfoType) {
ResidentRequest residentRequest = new ResidentRequest();
residentRequest.setSn(sn);
residentRequest.setBeginTime(beginTime);
residentRequest.setEndTime(endTime);
// 4 表示为截止目前
residentRequest.setTimes(4);
residentRequest.setLocInfoType(locInfoType);
return residentRequest;
}
}