perf: 查询装置附带更多的图片信息

dev
huangfeng 9 months ago
parent 12594e67cd
commit 7a2deb17ed

@ -12,7 +12,12 @@ public class PhotoDayModel implements Serializable {
private Date firstPhotoTime; private Date firstPhotoTime;
private Date lastPhotoTime; private Date lastPhotoTime;
private Date firstRecvTime;
private Date lastRecvTime; private Date lastRecvTime;
private String firstPhotoPath;
private String lastPhotoPath;
private Integer firstChannelId;
private Integer lastChannelId;
private long totalDays; private long totalDays;
private long photoCount; private long photoCount;

@ -28,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -93,6 +94,9 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Autowired @Autowired
UserService userService; UserService userService;
@Value("${photo.address}")
private String photoAddress;
//服务器中的位置 //服务器中的位置
private static final String C_PATH = "/home/xymp/photos/"; private static final String C_PATH = "/home/xymp/photos/";
@ -206,7 +210,7 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
ArrayList<TerminalPhotoListModel.AlarmItemBean> photoalarmlist = new ArrayList<>(); ArrayList<TerminalPhotoListModel.AlarmItemBean> photoalarmlist = new ArrayList<>();
for (TerminalImgAlarmsDto dto : imgarlarmsList) { for (TerminalImgAlarmsDto dto : imgarlarmsList) {
BigInteger photoOrgId = dto.getPhotoOrgId(); BigInteger photoOrgId = dto.getPhotoOrgId();
if (photoOrgId.longValue() == photoid.longValue() ) { if (photoOrgId.longValue() == photoid.longValue()) {
TerminalPhotoListModel.AlarmItemBean alarmItemBean = new TerminalPhotoListModel.AlarmItemBean(); TerminalPhotoListModel.AlarmItemBean alarmItemBean = new TerminalPhotoListModel.AlarmItemBean();
alarmItemBean.setEnname(dto.getEnname()); alarmItemBean.setEnname(dto.getEnname());
alarmItemBean.setName(dto.getName()); alarmItemBean.setName(dto.getName());
@ -1002,16 +1006,24 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
example.setOrderByClause("photo_time desc"); example.setOrderByClause("photo_time desc");
PageHelper.startPage(1, 1); PageHelper.startPage(1, 1);
List<TerminalPhoto> list = terminalPhotoDao.selectByExample(example); List<TerminalPhoto> list = terminalPhotoDao.selectByExample(example);
long lastrecv = list.get(0).getRecvTime().longValue(); TerminalPhoto last = list.get(0);
long lastrecv = last.getRecvTime().longValue();
result.setLastRecvTime(new Date(lastrecv * 1000)); result.setLastRecvTime(new Date(lastrecv * 1000));
long lastphoto = list.get(0).getPhotoTime().longValue(); long lastphoto = last.getPhotoTime().longValue();
result.setLastPhotoTime(new Date(lastphoto * 1000)); result.setLastPhotoTime(new Date(lastphoto * 1000));
result.setLastChannelId(last.getChannelId());
result.setLastPhotoPath(photoAddress + last.getPath());
example.setOrderByClause("photo_time asc"); example.setOrderByClause("photo_time asc");
PageHelper.startPage(1, 1); PageHelper.startPage(1, 1);
list = terminalPhotoDao.selectByExample(example); list = terminalPhotoDao.selectByExample(example);
long firstphoto = list.get(0).getPhotoTime().longValue(); TerminalPhoto first = list.get(0);
long firstrecv = first.getRecvTime().longValue();
result.setFirstRecvTime(new Date(firstrecv * 1000));
long firstphoto = first.getPhotoTime().longValue();
result.setFirstPhotoTime(new Date(firstphoto * 1000)); result.setFirstPhotoTime(new Date(firstphoto * 1000));
result.setFirstChannelId(first.getChannelId());
result.setFirstPhotoPath(photoAddress + first.getPath());
long totalDays = DateUtil.getDifferenceInDays(result.getFirstPhotoTime(), result.getLastPhotoTime()); long totalDays = DateUtil.getDifferenceInDays(result.getFirstPhotoTime(), result.getLastPhotoTime());
result.setTotalDays(totalDays); result.setTotalDays(totalDays);

Loading…
Cancel
Save