| | |
| | | import com.fzzy.igds.camera.data.ApiCameraResp; |
| | | import com.fzzy.igds.constant.RespCodeEnum; |
| | | import com.fzzy.igds.data.PageResponse; |
| | | import com.fzzy.igds.data.PatrolSuperData; |
| | | import com.fzzy.igds.domain.Camera; |
| | | import com.fzzy.igds.domain.Dept; |
| | | import com.fzzy.igds.domain.Patrol; |
| | | import com.fzzy.igds.service.CoreDeptService; |
| | | import com.fzzy.igds.service.PatrolService; |
| | | import com.fzzy.igds.service.SecCameraService; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.fzzy.igds.utils.DateUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description |
| | |
| | | private SecCameraService secCameraService; |
| | | @Resource |
| | | private ApiCameraManager apiCameraManager; |
| | | @Resource |
| | | private PatrolService patrolService; |
| | | @Resource |
| | | private CoreDeptService coreDeptService; |
| | | |
| | | /** |
| | | * |
| | |
| | | secCameraService.refreshCache(ContextUtil.getCompanyId()); |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, "执行成功!!"); |
| | | } |
| | | |
| | | /** |
| | | * 巡检统计 |
| | | * @return |
| | | */ |
| | | public PatrolSuperData patrolTrack() { |
| | | PatrolSuperData patrolSuperData = new PatrolSuperData(); |
| | | |
| | | List<Dept> deptList = coreDeptService.getDeptData(); |
| | | if(null == deptList || deptList.isEmpty()){ |
| | | return patrolSuperData; |
| | | } |
| | | |
| | | //库区转换 |
| | | Map<String, Integer> map = new HashMap<>(); |
| | | for (Dept dept : deptList) { |
| | | map.put(dept.getId(), 0); |
| | | } |
| | | |
| | | List<Patrol> weekList = patrolService.getWeekList(); |
| | | |
| | | if(null != weekList && weekList.size() > 0){ |
| | | Date start = DateUtil.getCurZero(DateUtil.getNewByDay(new Date(), -1)); //昨天零点零分 |
| | | Date end = DateUtil.getCurZero(new Date()); //今天零点零分 |
| | | for (Patrol patrol : weekList) { |
| | | //7天内人次 |
| | | patrolSuperData.setWeekSum(patrolSuperData.getWeekSum() + 1); |
| | | |
| | | //昨天人次 |
| | | if(patrol.getCreateTime().after(start) && patrol.getCreateTime().before(end)){ |
| | | patrolSuperData.setYesterdaySum(patrolSuperData.getYesterdaySum() + 1); |
| | | } |
| | | |
| | | //当天统计 |
| | | if(patrol.getCreateTime().after(end)){ |
| | | if(map.get(patrol.getDeptId()) == 0){ |
| | | patrolSuperData.setIsDeptNum(patrolSuperData.getIsDeptNum() + 1); |
| | | map.put(patrol.getDeptId(), map.get(patrol.getDeptId()) + 1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | patrolSuperData.setNoDeptNum(deptList.size() - patrolSuperData.getIsDeptNum()); |
| | | |
| | | return patrolSuperData; |
| | | } |
| | | } |