| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | 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 =DateUtils.setHours(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<>()); |
| | | } |
| | | //筛选time大于Start时间的数据 |
| | | listByParam = listByParam.stream().filter(info -> info.getTime().after(start)).collect(Collectors.toList()); |
| | | |
| | | //获取所有的库区信息 |
| | | 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())).collect(Collectors.toList()); |
| | | if (!collect.isEmpty()) { |
| | | //根据时间排序并找到最新一条数据 |
| | | latestEvent = collect.stream().sorted(Comparator.comparing(EventInfo::getTime).reversed()).findFirst().get(); |
| | | } |
| | | if (latestEvent != null) { |
| | | resultList.add(latestEvent); |
| | | } |
| | | } |
| | | if (null != resultList && !resultList.isEmpty()) { |
| | | //判断文件是否存在 |
| | | for (EventInfo record : resultList) { |
| | | record.setImgName(commonManager.isImgExit(record.getImgName(), null)); |
| | | } |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, resultList); |
| | | } |
| | | } |