From 17efddc6a667670dca682bf36b51a43e99615e6d Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 16 十月 2024 15:59:38 +0800
Subject: [PATCH] 代码初始化

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java
index 5ccb79f..168b829 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java
@@ -9,10 +9,7 @@
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.Utils;
-import com.doumee.dao.business.DeviceMapper;
-import com.doumee.dao.business.PlatformDeviceMapper;
-import com.doumee.dao.business.PlatformJobMapper;
-import com.doumee.dao.business.PlatformMapper;
+import com.doumee.dao.business.*;
 import com.doumee.dao.business.join.PlatformJobJoinMapper;
 import com.doumee.dao.business.join.PlatformJoinMapper;
 import com.doumee.dao.business.model.*;
@@ -47,6 +44,8 @@
     @Autowired
     private PlatformMapper platformMapper;
     @Autowired
+    private PlatformGroupMapper platformGroupMapper;
+    @Autowired
     private PlatformJoinMapper platformJoinMapper;
     @Autowired
     private PlatformDeviceMapper platformDeviceMapper;
@@ -79,6 +78,7 @@
                 platformDevice.setType(Constants.ZERO);
                 platformDevice.setDeviceId(ledId.toString());
                 platformDevice.setHkId(device.getHkId());
+                platformDevice.setHkNo(device.getNo());
                 platformDevice.setName(device.getName());
                 platformDeviceList.add(platformDevice);
             }
@@ -100,6 +100,7 @@
                 platformDevice.setType(Constants.TWO);
                 platformDevice.setDeviceId(broadcastId.toString());
                 platformDevice.setHkId(device.getHkId());
+                platformDevice.setHkNo(device.getNo());
                 platformDevice.setName(device.getName());
                 platformDeviceList.add(platformDevice);
             }
@@ -133,6 +134,28 @@
     public void updateById(Platform platform) {
         platform.setEditor(platform.getLoginUserInfo().getId());
         platform.setEditDate(new Date());
+        Platform model = platformMapper.selectById(platform.getId());
+        if(model ==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        if(model.getGroupId()!= null && platform.getGroupId()!=null && !Constants.equalsInteger(platform.getGroupId(),model.getGroupId())){
+            PlatformGroup group = platformGroupMapper.selectById(platform.getGroupId());
+            if(group ==null || Constants.equalsInteger(group.getIsdeleted(),Constants.ONE)){
+                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝鏈堝彴缁勪俊鎭笉姝g‘锛�");
+            }
+            //濡傛灉鏈堝彴鍒嗙粍鍙戠敓鍙樺寲
+            Long count =  platformJobJoinMapper.selectCount(  new QueryWrapper<PlatformJob>().lambda()
+                    .eq(PlatformJob::getIsdeleted,Constants.ZERO)
+                    .notIn(PlatformJob::getStatus,Constants.PlatformJobStatus.WART_SIGN_IN.getKey()
+                            ,Constants.PlatformJobStatus.WAIT_CONFIRM.getKey()
+                            ,Constants.PlatformJobStatus.DONE.getKey()
+                            ,Constants.PlatformJobStatus.LEAVED.getKey()
+                            ,Constants.PlatformJobStatus.CANCEL.getKey()
+                    ));
+            if(count!=null && count>0){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝褰撳墠鏈堝彴鏈夋鍦ㄤ綔涓氱殑浠诲姟锛屼笉鑳借繘琛屾湀鍙扮粍鍒囨崲鎿嶄綔锛�");
+            }
+        }
         //鍒犻櫎LED/骞挎挱鏁版嵁
         platformDeviceMapper.delete(new QueryWrapper<PlatformDevice>().lambda()
                 .eq(PlatformDevice::getPlatformId,platform.getId())
@@ -154,6 +177,7 @@
                 platformDevice.setType(Constants.ZERO);
                 platformDevice.setDeviceId(ledId.toString());
                 platformDevice.setHkId(device.getHkId());
+                platformDevice.setHkNo(device.getNo());
                 platformDevice.setName(device.getName());
                 platformDeviceList.add(platformDevice);
             }
@@ -177,6 +201,7 @@
                 platformDevice.setType(Constants.TWO);
                 platformDevice.setDeviceId(broadcastId.toString());
                 platformDevice.setHkId(device.getHkId());
+                platformDevice.setHkNo(device.getNo());
                 platformDevice.setName(device.getName());
                 platformDeviceList.add(platformDevice);
             }
@@ -316,6 +341,12 @@
                 .selectAs(PlatformGroup::getName,Platform::getGroupName)
                 .select(" (select ifnull(TIMESTAMPDIFF(HOUR, '2023-01-01 '||pg.start_time||':00', '2023-01-01 '||pg.end_time||':00' ),0) from platform_group pg " +
                         " where t.group_id = pg.id ) as openTime ")
+                .select(" ( select ROUND( ifnull(SUM(pl.PARAM3),0) / 3600 , 2 )   from platform_log pl  where   pl.remark = t.id  " +
+                        " and pl.CREATE_DATE > '"+DateUtil.getFomartDate(platform.getQueryDateStart(),"yyyy-MM-dd")+" 00:00:00'  " +
+                        "and pl.CREATE_DATE <=  '"+DateUtil.getFomartDate(platform.getQueryDateEnd(),"yyyy-MM-dd")+" 23:59:59'  ) as workCountTime ")
+                .select(" ( select count(1)  from platform_log pl  where   pl.remark = t.id  " +
+                        " and pl.CREATE_DATE > '"+DateUtil.getFomartDate(platform.getQueryDateStart(),"yyyy-MM-dd")+" 00:00:00'  " +
+                        "and pl.CREATE_DATE <=  '"+DateUtil.getFomartDate(platform.getQueryDateEnd(),"yyyy-MM-dd")+" 23:59:59' and pl.OBJ_TYPE = 5  ) as stopCount ")
                 .leftJoin(PlatformGroup.class,PlatformGroup::getId,Platform::getGroupId);
         queryWrapper
                 .eq(platform.getGroupId() != null, Platform::getGroupId, platform.getGroupId())
@@ -328,8 +359,6 @@
             List<PlatformJob> platformJobList = platformJobJoinMapper.selectJoinList(PlatformJob.class,
                     new MPJLambdaWrapper<PlatformJob>()
                     .selectAll(PlatformJob.class)
-                    .select(" ( select ROUND( ifnull(SUM(pl.PARAM3),0) / 3600 , 2 )   from platform_log pl  where pl.OBJ_ID = t.id " +
-                            " ) as workTimes ")
                     .in(PlatformJob::getStatus,Constants.PlatformJobStatus.WORKING.getKey(),
                             Constants.PlatformJobStatus.DONE.getKey(),
                             Constants.PlatformJobStatus.TRANSFERING.getKey(),
@@ -342,20 +371,15 @@
                     .le(platform.getQueryDateEnd() != null, PlatformJob::getStartDate, Utils.Date.getEnd(platform.getQueryDateEnd()))
             );
             //鏌ヨ2鏃ユ湡鐩稿樊澶╂暟
-            Integer sumDays = DateUtil.daysBetweenDates(platform.getQueryDateStart(),platform.getQueryDateEnd());
+            Integer sumDays = DateUtil.daysBetweenDates(platform.getQueryDateEnd(),platform.getQueryDateStart())+1;
             for (Platform bean:platformList) {
-                List<PlatformJob> beanJobList = platformJobList.stream().filter(i->Constants.equalsInteger(i.getPlatformId(),bean.getId())).collect(Collectors.toList());
-                bean.setStopCount(beanJobList.size());
-                bean.setWorkCountTime(
-                        beanJobList.stream().map(i->i.getWorkTimes()).reduce(BigDecimal.ZERO,BigDecimal::add)
-                );
                 if(Objects.isNull(bean.getOpenTime())||bean.getOpenTime().compareTo(BigDecimal.ZERO)<=0){
                     bean.setUseRata(BigDecimal.ZERO);
                     continue;
                 }
                 BigDecimal sumTime = BigDecimal.valueOf(sumDays).multiply(bean.getOpenTime());
                 bean.setUseRata(
-                        bean.getWorkCountTime().divide(sumTime,BigDecimal.ROUND_HALF_DOWN,2)
+                        bean.getWorkCountTime().multiply(new BigDecimal(100)).divide(sumTime,BigDecimal.ROUND_HALF_DOWN,2)
                 );
             }
         }
@@ -414,6 +438,7 @@
                 if(Constants.equalsInteger(platform.getPlatformStatus(),Constants.ONE)){
                     response.setCarCode(platform.getWorkCarCode());
                 }
+                platformStatusListResponses.add(response);
             }
         }
         return platformStatusListResponses;

--
Gitblit v1.9.3