From 50353c2ae43cdddb8433358f4ba66bef30c5d628 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 05 十一月 2024 14:00:12 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/dmvisit

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/thrid/BoardServiceImpl.java |  291 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 291 insertions(+), 0 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/thrid/BoardServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/thrid/BoardServiceImpl.java
new file mode 100644
index 0000000..b88eca5
--- /dev/null
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/thrid/BoardServiceImpl.java
@@ -0,0 +1,291 @@
+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;
+    }
+
+}

--
Gitblit v1.9.3