| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl.thrid; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.param.BaseListPageResponse; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.BaseListPageRequest; |
| | | import com.doumee.core.haikang.model.param.request.SensorStatusListRequest; |
| | | import com.doumee.core.haikang.model.param.respose.PageCameraInfoResponse; |
| | | import com.doumee.core.haikang.model.param.respose.PageFireChannelInfoResponse; |
| | | import com.doumee.core.haikang.model.param.respose.PageRegionInfoResponse; |
| | | import com.doumee.core.haikang.model.param.respose.PageSensorStatusResponse; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.PlatformJobMapper; |
| | | import com.doumee.dao.business.PlatformLogMapper; |
| | | import com.doumee.dao.business.PlatformMapper; |
| | | import com.doumee.dao.business.model.Platform; |
| | | import com.doumee.dao.business.model.PlatformJob; |
| | | import com.doumee.dao.web.response.platformReport.CarmeraListVO; |
| | | import com.doumee.dao.web.response.platformReport.OnSitDispatchBoardVO; |
| | | import com.doumee.dao.web.response.platformReport.RegionTreeVO; |
| | | import com.doumee.service.business.third.BoardService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * TMSå¹³å°å¯¹æ¥Serviceå®ç° |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class BoardServiceImpl implements BoardService { |
| | | @Autowired |
| | | private PlatformLogMapper platformLogMapper; |
| | | @Autowired |
| | | private PlatformJobMapper platformJobMapper; |
| | | @Autowired |
| | | private PlatformMapper platformMapper; |
| | | /** |
| | | * è·ååºåæ å½¢ç»ææ°æ® |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PageRegionInfoResponse> getRegionTree(CarmeraListVO req){ |
| | | List<PageRegionInfoResponse> allList = new ArrayList<>(); |
| | | boolean hasNext = true; |
| | | int curTotal = 0; |
| | | int curPage = 1; |
| | | while (hasNext){ |
| | | //å页éåå¾ªç¯æ¥è¯¢ææé¨ç¦è®¾å¤æ°æ® |
| | | BaseListPageRequest param = new BaseListPageRequest(); |
| | | param.setUserId("admin"); |
| | | param.setPageSize(100); |
| | | param.setPageNo(curPage); |
| | | BaseResponse<BaseListPageResponse<PageRegionInfoResponse>> response = HKService.pageRegions(param); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对ä¸èµ·ï¼æµ·åº·åæ¥æ°æ®å¤±è´¥~"); |
| | | } |
| | | BaseListPageResponse<PageRegionInfoResponse> r = response.getData(); |
| | | curTotal += 100; |
| | | if(curTotal >= r.getTotal()){ |
| | | hasNext = false; |
| | | } |
| | | if(r.getList() == null || r.getList().size()==0){ |
| | | hasNext =false; |
| | | }else{ |
| | | allList.addAll(r.getList()); |
| | | } |
| | | curPage++; |
| | | } |
| | | if(Constants.equalsInteger(req.getWithCameras(),Constants.ONE)){ |
| | | initReginCameralList(allList,req.getName());//è·åå
¨é¨çæ§ç¹æ°æ® |
| | | } |
| | | List<PageRegionInfoResponse> data = new RegionTreeVO(allList).buildTree(); |
| | | return data; |
| | | } |
| | | private void initReginCameralList(List<PageRegionInfoResponse> allList,String name) { |
| | | List<CarmeraListVO> carmeraListVOList = cameraList(null); |
| | | if(carmeraListVOList!=null && carmeraListVOList.size()>0){ |
| | | for(PageRegionInfoResponse p : allList){ |
| | | for(CarmeraListVO c : carmeraListVOList){ |
| | | if(StringUtils.equals(p.getRegionIndexCode(),c.getReginCode()) |
| | | && (StringUtils.contains(c.getName(),name) ||StringUtils.isBlank(name))){ |
| | | if(p.getCarmeraList()==null){ |
| | | p.setCarmeraList(new ArrayList<>()); |
| | | } |
| | | p.getCarmeraList().add(c); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * è·ååºåæ å½¢ç»ææ°æ® |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PageRegionInfoResponse> regionList(CarmeraListVO req){ |
| | | List<PageRegionInfoResponse> allList = new ArrayList<>(); |
| | | boolean hasNext = true; |
| | | int curTotal = 0; |
| | | int curPage = 1; |
| | | while (hasNext){ |
| | | //å页éåå¾ªç¯æ¥è¯¢ææé¨ç¦è®¾å¤æ°æ® |
| | | BaseListPageRequest param = new BaseListPageRequest(); |
| | | param.setUserId("admin"); |
| | | param.setPageSize(100); |
| | | param.setPageNo(curPage); |
| | | BaseResponse<BaseListPageResponse<PageRegionInfoResponse>> response = HKService.pageRegions(param); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对ä¸èµ·ï¼æµ·åº·åæ¥æ°æ®å¤±è´¥~"); |
| | | } |
| | | BaseListPageResponse<PageRegionInfoResponse> r = response.getData(); |
| | | curTotal += 100; |
| | | if(curTotal >= r.getTotal()){ |
| | | hasNext = false; |
| | | } |
| | | if(r.getList() == null || r.getList().size()==0){ |
| | | hasNext =false; |
| | | }else{ |
| | | allList.addAll(r.getList()); |
| | | } |
| | | curPage++; |
| | | } |
| | | if(Constants.equalsInteger(req.getWithCameras(),Constants.ONE)){ |
| | | initReginCameralList(allList,req.getName());//è·åå
¨é¨çæ§ç¹æ°æ® |
| | | } |
| | | return allList; |
| | | } |
| | | @Override |
| | | public List<CarmeraListVO> cameraList(CarmeraListVO req){ |
| | | List<PageCameraInfoResponse> allList = new ArrayList<>(); |
| | | boolean hasNext = true; |
| | | int curTotal = 0; |
| | | int curPage = 1; |
| | | while (hasNext){ |
| | | //å页éåå¾ªç¯æ¥è¯¢ææé¨ç¦è®¾å¤æ°æ® |
| | | BaseListPageRequest param = new BaseListPageRequest(); |
| | | param.setUserId("admin"); |
| | | param.setPageSize(100); |
| | | param.setPageNo(curPage); |
| | | BaseResponse<BaseListPageResponse<PageCameraInfoResponse>> response = HKService.pageCameras(param); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对ä¸èµ·ï¼æµ·åº·åæ¥æ°æ®å¤±è´¥~"); |
| | | } |
| | | BaseListPageResponse<PageCameraInfoResponse> r = response.getData(); |
| | | curTotal += 100; |
| | | if(curTotal >= r.getTotal()){ |
| | | hasNext = false; |
| | | } |
| | | if(r.getList() == null || r.getList().size()==0){ |
| | | hasNext =false; |
| | | }else{ |
| | | allList.addAll(r.getList()); |
| | | } |
| | | curPage++; |
| | | } |
| | | |
| | | List<CarmeraListVO> data = new ArrayList<>(); |
| | | for(PageCameraInfoResponse p : allList){ |
| | | CarmeraListVO t = new CarmeraListVO(); |
| | | t.setIndexCode(p.getCameraIndexCode()); |
| | | t.setReginCode(p.getRegionIndexCode()); |
| | | t.setName(p.getCameraName()); |
| | | t.setStatus(p.getStatus()); |
| | | t.setStatusName(p.getStatusName()); |
| | | data.add(t); |
| | | } |
| | | return data; |
| | | } |
| | | @Override |
| | | public List<PageFireChannelInfoResponse> fireChannelList(){ |
| | | List<PageFireChannelInfoResponse> allList = new ArrayList<>(); |
| | | boolean hasNext = true; |
| | | int curTotal = 0; |
| | | int curPage = 1; |
| | | while (hasNext){ |
| | | //å页éåå¾ªç¯æ¥è¯¢ææé¨ç¦è®¾å¤æ°æ® |
| | | BaseListPageRequest param = new BaseListPageRequest(); |
| | | param.setUserId("admin"); |
| | | param.setPageSize(100); |
| | | param.setPageNo(curPage); |
| | | BaseResponse<BaseListPageResponse<PageFireChannelInfoResponse>> response = HKService.pageFireChannel(param); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对ä¸èµ·ï¼æµ·åº·åæ¥æ°æ®å¤±è´¥~"); |
| | | } |
| | | BaseListPageResponse<PageFireChannelInfoResponse> r = response.getData(); |
| | | curTotal += 100; |
| | | if(curTotal >= r.getTotal()){ |
| | | hasNext = false; |
| | | } |
| | | if(r.getList() == null || r.getList().size()==0){ |
| | | hasNext =false; |
| | | }else{ |
| | | allList.addAll(r.getList()); |
| | | } |
| | | curPage++; |
| | | } |
| | | |
| | | return allList; |
| | | } |
| | | @Override |
| | | public List<PageSensorStatusResponse> sensorStatusList(){ |
| | | List<PageSensorStatusResponse> allList = new ArrayList<>(); |
| | | boolean hasNext = true; |
| | | int curTotal = 0; |
| | | int curPage = 1; |
| | | while (hasNext){ |
| | | //å页éåå¾ªç¯æ¥è¯¢ææé¨ç¦è®¾å¤æ°æ® |
| | | SensorStatusListRequest param = new SensorStatusListRequest(); |
| | | param.setPageSize(100); |
| | | param.setPageNo(curPage); |
| | | BaseResponse<BaseListPageResponse<PageSensorStatusResponse>> response = HKService.pageSensorStatus(param); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对ä¸èµ·ï¼æµ·åº·åæ¥æ°æ®å¤±è´¥~"); |
| | | } |
| | | BaseListPageResponse<PageSensorStatusResponse> r = response.getData(); |
| | | curTotal += 100; |
| | | if(curTotal >= r.getTotal()){ |
| | | hasNext = false; |
| | | } |
| | | if(r.getList() == null || r.getList().size()==0){ |
| | | hasNext =false; |
| | | }else{ |
| | | allList.addAll(r.getList()); |
| | | } |
| | | curPage++; |
| | | } |
| | | |
| | | return allList; |
| | | } |
| | | @Override |
| | | public OnSitDispatchBoardVO getCnddCenterData(){ |
| | | OnSitDispatchBoardVO data = new OnSitDispatchBoardVO(); |
| | | //æå°æ»æ° |
| | | List<Platform> list = platformMapper.selectJoinList(Platform.class,new MPJLambdaWrapper<Platform>() |
| | | .selectAll(Platform.class) |
| | | .select(" ( select count(1) from platform_job pj where t.id = pj.PLATFORM_ID and pj.STATUS = "+Constants.PlatformJobStatus.WORKING.getKey()+" ) as workStatus ") |
| | | .eq(Platform::getIsdeleted,Constants.ZERO) |
| | | ); |
| | | data.setPlatformTotal(list==null?0:list.size()); |
| | | //ç©ºé²æå°æ°é |
| | | data.setFreePlatform( |
| | | list.stream().filter(i->Constants.formatIntegerNum(i.getWorkStatus())<=Constants.ZERO).collect(Collectors.toList()).size() |
| | | ); |
| | | //æ¥è¯¢ä»æ¥æå°ä¸ªç¶æä½ä¸æ°é |
| | | List<PlatformJob> jobList = platformJobMapper.selectJoinList(PlatformJob.class,new MPJLambdaWrapper<PlatformJob>() |
| | | .selectAll(PlatformJob.class) |
| | | .select("count(id)" ,PlatformJob::getCountum) |
| | | .eq(PlatformJob::getIsdeleted,Constants.ZERO) |
| | | .apply("to_days(create_data) = to_days(now())" ) |
| | | .groupBy(PlatformJob::getStatus ) |
| | | ); |
| | | if(jobList!=null){ |
| | | |
| | | //-------------TODO----------ãçæ¿ãç±ç¡®è®¤éæ±-------------- |
| | | // * 0å¾
确认 1å¾
ç¾å° 2çå¾
å«å· 3å
¥åçå¾
4å·²å«å· 5ä½ä¸ä¸ 6ä½ä¸å®æ 7è½¬ç§»ä¸ 8å¼å¸¸æèµ· 9å·²ææç¦»å 10已离å 11 å·²è¿å· 12已忶 |
| | | for(PlatformJob model : jobList){ |
| | | //é¢çº¦è½¦è¾ |
| | | if(Constants.equalsInteger(model.getStatus(),Constants.PlatformJobStatus.WAIT_CONFIRM.getKey()) |
| | | ||Constants.equalsInteger(model.getStatus(),Constants.PlatformJobStatus.WART_SIGN_IN.getKey())){ |
| | | data.setReservationCar(data.getReservationCar()+Constants.formatIntegerNum(model.getCountum())); |
| | | } |
| | | // ä½ä¸è½¦è¾ |
| | | if(Constants.equalsInteger(model.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())){ |
| | | data.setWorkingCar(data.getWorkingCar()+Constants.formatIntegerNum(model.getCountum())); |
| | | } |
| | | //æéè½¦è¾ |
| | | if(Constants.equalsInteger(model.getStatus(),Constants.PlatformJobStatus.WAIT_CALL.getKey()) |
| | | ||Constants.equalsInteger(model.getStatus(),Constants.PlatformJobStatus.IN_WAIT.getKey())){ |
| | | data.setLineUpCar(data.getLineUpCar()+Constants.formatIntegerNum(model.getCountum())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | |
| | | } |