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

dev
huangfeng 9 months ago
parent 12594e67cd
commit 7a2deb17ed

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

@ -28,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
@ -93,6 +94,9 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Autowired
UserService userService;
@Value("${photo.address}")
private String photoAddress;
//服务器中的位置
private static final String C_PATH = "/home/xymp/photos/";
@ -1002,16 +1006,24 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
example.setOrderByClause("photo_time desc");
PageHelper.startPage(1, 1);
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));
long lastphoto = list.get(0).getPhotoTime().longValue();
long lastphoto = last.getPhotoTime().longValue();
result.setLastPhotoTime(new Date(lastphoto * 1000));
result.setLastChannelId(last.getChannelId());
result.setLastPhotoPath(photoAddress + last.getPath());
example.setOrderByClause("photo_time asc");
PageHelper.startPage(1, 1);
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.setFirstChannelId(first.getChannelId());
result.setFirstPhotoPath(photoAddress + first.getPath());
long totalDays = DateUtil.getDifferenceInDays(result.getFirstPhotoTime(), result.getLastPhotoTime());
result.setTotalDays(totalDays);

Loading…
Cancel
Save