| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, resultListSnap); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 大屏首页-抓拍跟踪信息-展示AI时间图片 |
| | | * 展示图片的业务逻辑:每个库区展示一张,图片为当天十点以后最新的一张 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<List<EventInfo>> indexEventInfoList(IgdsBaseParam param) { |
| | | // Date start =DateUtils.setHours(DateUtil.getNewByDay(new Date(), -3), 10); |
| | | //param.setStart(start); |
| | | // param.setEnd(DateUtil.getNewByDay(new Date(), -3)); |
| | | Date start =DateUtil.getNewByDay(new Date(), -10); |
| | | param.setStart(start); |
| | | param.setEnd(new Date()); |
| | | |
| | | //获取当日的抓拍信息 |
| | | List<EventInfo> listByParam = eventInfoService.getListByParam(param); |
| | | if (null == listByParam || listByParam.isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, new ArrayList<>()); |
| | | } |
| | | |
| | | //获取所有的库区信息 |
| | | List<Dept> deptList = deptService.getDeptByUserType(null); |
| | | //根据库区从listByParam来获取每一个库区下,最新的一张抓拍图片 |
| | | List<EventInfo> resultList = new ArrayList<>(); |
| | | |
| | | for (Dept dept : deptList) { |
| | | EventInfo latestEvent = null; |
| | | //从listByParam中筛选出与当前id匹配的数据 |
| | | List<EventInfo> collect = listByParam.stream().filter(info -> info.getDeptId().equals(dept.getId())).sorted(Comparator.comparing(EventInfo::getTime).reversed()).collect(Collectors.toList()); |
| | | //每个库区获取最新的3张图片 |
| | | int i = 0; |
| | | for (EventInfo info : collect) { |
| | | if (i > 2) break; |
| | | resultList.add(info); |
| | | i++; |
| | | } |
| | | } |
| | | if (null != resultList && !resultList.isEmpty()) { |
| | | //判断文件是否存在 |
| | | for (EventInfo record : resultList) { |
| | | record.setImgName(commonManager.isImgExit(record.getImgName(), null)); |
| | | } |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, resultList); |
| | | } |
| | | } |