From 0178205be3ffce33af631658de35e3805641d5d3 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 23 九月 2024 18:35:21 +0800
Subject: [PATCH] 代码初始化

---
 server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/BookingsServiceImpl.java         |    6 
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Platform.java                        |    5 
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java       |   36 ++++++--
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/PlatformJob.java                     |    4 
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/web/reqeust/SignInDTO.java                          |    2 
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformServiceImpl.java          |  148 +++++++++++++++++++++++++++++++++++-
 server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/PlatformJobCloudController.java               |    9 ++
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/openapi/response/PlatformWarnEventListResponse.java |    4 +
 server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/RoomsServiceImpl.java            |    2 
 9 files changed, 190 insertions(+), 26 deletions(-)

diff --git a/server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/BookingsServiceImpl.java b/server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/BookingsServiceImpl.java
index 094c42a..2c39a98 100644
--- a/server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/BookingsServiceImpl.java
+++ b/server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/BookingsServiceImpl.java
@@ -1133,7 +1133,7 @@
                     .eq(Bookings::getRoomId,bookings.getRoomId())
                     .ne(Bookings::getId,bookings.getId())
             )>Constants.ZERO){
-                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪鏈紑鍚細璁紝鏃犳硶杩涜寮�濮嬩細璁�");
+                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪鏈紑鍚細璁紝鏃犳硶寮�濮嬩細璁�");
             };
 
             if(bookingsMapper.selectCount(new QueryWrapper<Bookings>()
@@ -1144,11 +1144,11 @@
                     .eq(Bookings::getStatus,Constants.ZERO)
                     .eq(Bookings::getRoomId,bookings.getRoomId())
             )>Constants.ZERO){
-                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠寮�鍚椂闂翠笌鍏朵粬浼氳瀛樺湪鍐茬獊锛屾棤娉曡繘琛屽紑濮嬩細璁�");
+                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠寮�鍚椂闂翠笌鍏朵粬浼氳瀛樺湪鍐茬獊锛屾棤娉曞紑濮嬩細璁�");
             };
         }else{
             if(bookings.getStartTime().getTime() > System.currentTimeMillis()){
-                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈埌浼氳鐢宠寮�濮嬫椂闂达紝鏃犳硶杩涜寮�濮�");
+                throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈埌浼氳鐢宠寮�濮嬫椂闂达紝鏃犳硶寮�濮�");
             }
         }
         bookings.setStartTimeReal(new Date());
diff --git a/server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/RoomsServiceImpl.java b/server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/RoomsServiceImpl.java
index 8ef920e..5a28dcf 100644
--- a/server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/RoomsServiceImpl.java
+++ b/server/meeting/meeting_service/src/main/java/com/doumee/service/business/impl/RoomsServiceImpl.java
@@ -370,7 +370,7 @@
         Integer re = recordisExist(rooms.getId());
         if (Constants.equalsInteger(re, Constants.ONE)) {
             //瀛樹笅棰勭害璁板綍涓嶅厑璁告洿鏂板紑鏀炬椂闂村拰绮掑害鍒嗛挓
-           // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "浼氳瀹ゅ瓨鍦ㄩ绾︿腑鐨勮褰曪紝涓嶅厑璁镐慨鏀�");
+//            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "浼氳瀹ゅ瓨鍦ㄩ绾︿腑鐨勮褰曪紝涓嶅厑璁镐慨鏀�");
             rooms.setStartTime(null);
             rooms.setEndTime(null);
             rooms.setIntervalTime(null);
diff --git a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/PlatformJobCloudController.java b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/PlatformJobCloudController.java
index f71d7c1..d115d50 100644
--- a/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/PlatformJobCloudController.java
+++ b/server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/admin/PlatformJobCloudController.java
@@ -10,6 +10,7 @@
 import com.doumee.core.utils.Constants;
 import com.doumee.dao.business.model.PlatformJob;
 import com.doumee.dao.web.reqeust.JobDetailDTO;
+import com.doumee.dao.web.reqeust.SignInDTO;
 import com.doumee.service.business.PlatformJobService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -89,4 +90,12 @@
     public ApiResponse<PlatformJob>  jobDetail (@RequestBody JobDetailDTO jobDetailDTO, @RequestHeader(Constants.HEADER_USER_TOKEN) String token){
         return ApiResponse.success(platformJobService.getDetail(jobDetailDTO));
     }
+
+    @ApiOperation("浠诲姟绛惧埌")
+    @PostMapping("/signIn")
+    public ApiResponse  signIn (@RequestBody SignInDTO signInDTO, @RequestHeader(Constants.HEADER_USER_TOKEN) String token){
+        signInDTO.setLoginUserInfo(getLoginUser(token));
+        platformJobService.signIn(signInDTO);
+        return ApiResponse.success("鎿嶄綔鎴愬姛");
+    }
 }
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Platform.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Platform.java
index fafc0aa..256a013 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Platform.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Platform.java
@@ -102,7 +102,6 @@
 
     @ApiModelProperty(value = "鏈�鍚庝簨浠舵帹閫佹椂闂�")
     @ExcelColumn(name="鏈�鍚庝簨浠舵帹閫佹椂闂�")
-  
     private Date lastEventTime;
 
     @ApiModelProperty(value = "鐩戞帶鐐瑰悕绉帮紝澶氫釜鐢ㄨ嫳鏂囬�楀彿闅斿紑")
@@ -158,10 +157,10 @@
     private String groupName;
     @ApiModelProperty(value = "鍏宠仈LED缂栫爜闆嗗悎锛岃嫳鏂囬�楀彿闅斿紑", example = "1")
     @TableField(exist = false)
-    private String ledIds;
+    private List<Integer> ledIds;
     @ApiModelProperty(value = "鍏宠仈骞挎挱缂栫爜闆嗗悎锛岃嫳鏂囬�楀彿闅斿紑", example = "1")
     @TableField(exist = false)
-    private String broadcastIds;
+    private List<Integer> broadcastIds;
     @ApiModelProperty(value = "鍏宠仈LED鍚嶇О闆嗗悎锛岃嫳鏂囬�楀彿闅斿紑", example = "1")
     @TableField(exist = false)
     private String ledNames;
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/PlatformJob.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/PlatformJob.java
index 8125540..d9c8c84 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/PlatformJob.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/PlatformJob.java
@@ -95,8 +95,8 @@
     @ExcelColumn(name="绛惧埌鏃堕棿")
     private Date signDate;
 
-    @ApiModelProperty(value = "绛惧埌鏂瑰紡 0app绛惧埌 1鎵爜绛惧埌", example = "1")
-    @ExcelColumn(name="绛惧埌鏂瑰紡 0app绛惧埌 1鎵爜绛惧埌")
+    @ApiModelProperty(value = "绛惧埌鏂瑰紡 0app绛惧埌 1鎵爜绛惧埌 2鍚庡彴绛惧埌", example = "1")
+    @ExcelColumn(name="绛惧埌鏂瑰紡 0app绛惧埌 1鎵爜绛惧埌 2鍚庡彴绛惧埌")
     private Integer singType;
     @ApiModelProperty(value = "閫氱煡WMS浣滀笟缁戝畾鏈堝彴鏃堕棿")
     @ExcelColumn(name="閫氱煡WMS浣滀笟缁戝畾鏈堝彴鏃堕棿")
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/openapi/response/PlatformWarnEventListResponse.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/openapi/response/PlatformWarnEventListResponse.java
index ccff13f..035da66 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/openapi/response/PlatformWarnEventListResponse.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/openapi/response/PlatformWarnEventListResponse.java
@@ -21,4 +21,8 @@
     private Date createDate;
     @ApiModelProperty(value = "浜嬩欢鍐呭璇存槑")
     private String content;
+    @ApiModelProperty(value = "鏈堝彴鍚嶇О")
+    private String platformName;
+    @ApiModelProperty(value = "鏈堝彴缂栫爜")
+    private String platfromHkId;
 }
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/web/reqeust/SignInDTO.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/web/reqeust/SignInDTO.java
index 3ce2b1c..748f287 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/web/reqeust/SignInDTO.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/web/reqeust/SignInDTO.java
@@ -21,7 +21,7 @@
     @ApiModelProperty(value = "浠诲姟涓婚敭")
     private Integer jobId;
 
-    @ApiModelProperty(value = "绛惧埌绫诲瀷锛� 0=app绛惧埌 1=鎵爜绛惧埌")
+    @ApiModelProperty(value = "绛惧埌绫诲瀷锛� 0=app绛惧埌 1=鎵爜绛惧埌 2=鍚庡彴绛惧埌")
     private Integer signType;
 
     @ApiModelProperty(value = "绛惧埌浜岀淮鐮佸��")
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java
index 0432147..af60a31 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java
@@ -239,8 +239,8 @@
                 .eq(pageWrap.getModel().getPlatformGroupId() != null, PlatformJob::getPlatformGroupId, pageWrap.getModel().getPlatformGroupId())
 
                 .apply(pageWrap.getModel().getQueryStatus() != null, " find_in_set(t.`STATUS`,'"+pageWrap.getModel().getQueryStatus()+"')")
-                .ge(pageWrap.getModel().getBeginWorkDateStart() != null, PlatformJob::getStartDate, Utils.Date.getStart(pageWrap.getModel().getBeginWorkDateStart()))
-                .le(pageWrap.getModel().getBeginWorkDateEnd() != null, PlatformJob::getStartDate, Utils.Date.getEnd(pageWrap.getModel().getBeginWorkDateEnd()))
+                .ge(pageWrap.getModel().getBeginWorkDateStart() != null, PlatformJob::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getBeginWorkDateStart()))
+                .le(pageWrap.getModel().getBeginWorkDateEnd() != null, PlatformJob::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getBeginWorkDateEnd()))
                 .eq(pageWrap.getModel().getJobType() != null && Constants.equalsInteger(Constants.ONE,pageWrap.getModel().getJobType()), PlatformJob::getType, Constants.platformJobType.sgscxh)
                 .ne(pageWrap.getModel().getJobType() != null && Constants.equalsInteger(Constants.ZERO,pageWrap.getModel().getJobType()), PlatformJob::getType, Constants.platformJobType.sgscxh)
         ;
@@ -373,7 +373,8 @@
             }else{
                 platformJob.setWaitTime("绛夊緟鍙彿");
             }
-        }else if(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())){
+        }else if(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())
+        || Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.DONE.getKey())){
             //鏌ヨ鏈�鍚庡紑濮嬩换鍔$殑鏈堝彴璁板綍  鏃ュ織琛�  鍥犱负瀛樺湪寮傚父鎸傝捣 杞Щ 绛夐棶棰�
             PlatformLog platformLog = platformLogMapper.selectOne(new QueryWrapper<PlatformLog>().lambda()
                     .eq(PlatformLog::getJobId,platformJob.getId())
@@ -416,7 +417,7 @@
                 .leftJoin(Platform.class,Platform::getId,PlatformJob::getPlatformId)
                 .eq(PlatformJob::getIsdeleted,Constants.ZERO)
                 .eq(PlatformJob::getDrivierPhone,loginUserInfo.getMobile())
-                .like(PlatformJob::getArriveDate,DateUtil.getCurrDate())
+//                .like(PlatformJob::getArriveDate,DateUtil.getCurrDate())
                 .orderByDesc(PlatformJob::getId)
         );
         for (PlatformJob platformJob:platformJobList) {
@@ -462,8 +463,9 @@
 
         PlatformJob oldPlatformJob = new PlatformJob();
         BeanUtils.copyProperties(platformJob,oldPlatformJob);
-
+        platformJob.setConfirmTaskDate(new Date());
         platformJob.setArriveDate(confirmTaskDTO.getArriveDate());
+        platformJob.setCarCodeBack(confirmTaskDTO.getCarCodeBack());
         platformJob.setStatus(Constants.PlatformJobStatus.WART_SIGN_IN.getKey());
         platformJob.setEditDate(new Date());
         platformJobMapper.updateById(platformJob);
@@ -488,19 +490,31 @@
         if(Objects.isNull(platformJob)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
-        if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WART_SIGN_IN.getKey())){
-            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓氬姟鐘舵�佸凡娴佽浆锛岃鍒锋柊鏌ョ湅");
-        }
+
         PlatformJob oldPlatformJob = new PlatformJob();
         BeanUtils.copyProperties(platformJob,oldPlatformJob);
 
         if(Constants.equalsInteger(signInDTO.getSignType(),Constants.ZERO)){
+            if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WART_SIGN_IN.getKey())){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓氬姟鐘舵�佸凡娴佽浆锛岃鍒锋柊鏌ョ湅");
+            }
             this.distanceSignIn(signInDTO,platformJob);
         }else if(Constants.equalsInteger(signInDTO.getSignType(),Constants.ONE)){
+            if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WART_SIGN_IN.getKey())){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓氬姟鐘舵�佸凡娴佽浆锛岃鍒锋柊鏌ョ湅");
+            }
             this.sceneSignIn(signInDTO);
+        }else if(Constants.equalsInteger(signInDTO.getSignType(),Constants.TWO)){
+            if(!(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WAIT_CONFIRM.getKey())||
+                    Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WART_SIGN_IN.getKey()))
+            ){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓氬姟鐘舵�佸凡娴佽浆锛岃鍒锋柊鏌ョ湅");
+            }
+        }else{
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"绛惧埌绫诲瀷閿欒");
         }
         platformJob.setSignDate(new Date());
-        platformJob.setSingType(Constants.ZERO);
+        platformJob.setSingType(signInDTO.getSignType());
         platformJob.setStatus(Constants.PlatformJobStatus.WAIT_CALL.getKey());
         platformJobMapper.updateById(platformJob);
         //瀛樺偍鎿嶄綔鏃ュ織
@@ -508,12 +522,12 @@
                 Constants.PlatformJobLogType.SIGN.getInfo());
     }
 
-
     public void distanceSignIn(SignInDTO signInDTO , PlatformJob platformJob){
         if(Objects.isNull(signInDTO.getLat())
                 || Objects.isNull(signInDTO.getLnt())){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"缁忕含搴︿俊鎭紓甯�");
         }
+
         //鑾峰彇绛惧埌鐐圭殑缁忕含搴�
         Double lat = Double.parseDouble(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.SIGN_IN_PLACE_LAT).getCode());
         Double lnt = Double.parseDouble(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.SIGN_IN_PLACE_LNT).getCode());
@@ -529,6 +543,7 @@
     }
 
     public void sceneSignIn(SignInDTO signInDTO){
+
         if( StringUtils.isNotBlank(signInDTO.getQrCodeKey())){
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
@@ -716,6 +731,7 @@
         || Constants.equalsInteger(platformJob.getType(),Constants.FOUR)){
             //TODO 涓嬪彂鍏ュ洯鏉冮檺
 
+
         }
         //瀛樺偍鎿嶄綔鏃ュ織
         savePlatformLog(Constants.PlatformJobLogType.IN_WAIT.getKey(),oldPlatformJob,platformJob,
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 4acdb01..893331c 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
@@ -1,5 +1,6 @@
 package com.doumee.service.business.impl;
 
+import cn.emay.sdk.util.StringUtil;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.model.LoginUserInfo;
@@ -7,25 +8,27 @@
 import com.doumee.core.model.PageWrap;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.Utils;
+import com.doumee.dao.business.DeviceMapper;
+import com.doumee.dao.business.PlatformDeviceMapper;
 import com.doumee.dao.business.PlatformMapper;
 import com.doumee.dao.business.join.PlatformJoinMapper;
-import com.doumee.dao.business.model.Member;
-import com.doumee.dao.business.model.Platform;
-import com.doumee.dao.business.model.PlatformGroup;
+import com.doumee.dao.business.model.*;
 import com.doumee.dao.openapi.response.PlatformNumByStatusResponse;
+import com.doumee.service.business.PlatformDeviceService;
 import com.doumee.service.business.PlatformService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -40,10 +43,62 @@
     private PlatformMapper platformMapper;
     @Autowired
     private PlatformJoinMapper platformJoinMapper;
+    @Autowired
+    private PlatformDeviceMapper platformDeviceMapper;
+    @Autowired
+    private DeviceMapper deviceMapper;
+
+
 
     @Override
+    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
     public Integer create(Platform platform) {
+        platform.setCreateDate(new Date());
+        platform.setIsdeleted(Constants.ZERO);
+        platform.setCreator(platform.getLoginUserInfo().getId());
         platformMapper.insert(platform);
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platform.getLedIds())){
+            List<PlatformDevice> platformDeviceList = new ArrayList<>();
+            for (Integer ledId:platform.getLedIds()) {
+                Device device = deviceMapper.selectById(ledId);
+                if(Objects.isNull(device)){
+                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏈煡璇㈠埌led璁惧淇℃伅銆�"+ledId+"銆�");
+                }
+                PlatformDevice platformDevice = new PlatformDevice();
+                platformDevice.setIsdeleted(Constants.ZERO);
+                platformDevice.setPlatformId(platform.getId());
+                platformDevice.setCreateDate(new Date());
+                platformDevice.setCreator(platform.getLoginUserInfo().getId());
+                platformDevice.setType(Constants.ZERO);
+                platformDevice.setDeviceId(ledId.toString());
+                platformDevice.setHkId(device.getHkId());
+                platformDevice.setName(device.getName());
+                platformDeviceList.add(platformDevice);
+            }
+            platformDeviceMapper.insert(platformDeviceList);
+        }
+
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platform.getBroadcastIds())){
+            List<PlatformDevice> platformDeviceList = new ArrayList<>();
+            for (Integer broadcastId:platform.getBroadcastIds()) {
+                Device device = deviceMapper.selectById(broadcastId);
+                if(Objects.isNull(device)){
+                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏈煡璇㈠埌骞挎挱璁惧淇℃伅銆�"+broadcastId+"銆�");
+                }
+                PlatformDevice platformDevice = new PlatformDevice();
+                platformDevice.setIsdeleted(Constants.ZERO);
+                platformDevice.setPlatformId(platform.getId());
+                platformDevice.setCreateDate(new Date());
+                platformDevice.setCreator(platform.getLoginUserInfo().getId());
+                platformDevice.setType(Constants.TWO);
+                platformDevice.setDeviceId(broadcastId.toString());
+                platformDevice.setHkId(device.getHkId());
+                platformDevice.setName(device.getName());
+                platformDeviceList.add(platformDevice);
+            }
+            platformDeviceMapper.insert(platformDeviceList);
+        }
+
         return platform.getId();
     }
 
@@ -67,7 +122,60 @@
     }
 
     @Override
+    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
     public void updateById(Platform platform) {
+        platform.setEditor(platform.getLoginUserInfo().getId());
+        platform.setEditDate(new Date());
+        //鍒犻櫎LED/骞挎挱鏁版嵁
+        platformDeviceMapper.delete(new QueryWrapper<PlatformDevice>().lambda()
+                .eq(PlatformDevice::getPlatformId,platform.getId())
+                .in(PlatformDevice::getType,Constants.ZERO,Constants.TWO)
+        );
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platform.getLedIds())){
+            List<PlatformDevice> platformDeviceList = new ArrayList<>();
+            String ledNames = "";
+            for (Integer ledId:platform.getLedIds()) {
+                Device device = deviceMapper.selectById(ledId);
+                if(Objects.isNull(device)){
+                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏈煡璇㈠埌led璁惧淇℃伅銆�"+ledId+"銆�");
+                }
+                PlatformDevice platformDevice = new PlatformDevice();
+                platformDevice.setIsdeleted(Constants.ZERO);
+                platformDevice.setPlatformId(platform.getId());
+                platformDevice.setCreateDate(new Date());
+                platformDevice.setCreator(platform.getLoginUserInfo().getId());
+                platformDevice.setType(Constants.ZERO);
+                platformDevice.setDeviceId(ledId.toString());
+                platformDevice.setHkId(device.getHkId());
+                platformDevice.setName(device.getName());
+                platformDeviceList.add(platformDevice);
+            }
+            platformDeviceMapper.insert(platformDeviceList);
+            platform.setLedNames(ledNames);
+        }
+
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platform.getBroadcastIds())){
+            List<PlatformDevice> platformDeviceList = new ArrayList<>();
+            String ledNames = "";
+            for (Integer broadcastId:platform.getBroadcastIds()) {
+                Device device = deviceMapper.selectById(broadcastId);
+                if(Objects.isNull(device)){
+                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鏈煡璇㈠埌骞挎挱璁惧淇℃伅銆�"+broadcastId+"銆�");
+                }
+                PlatformDevice platformDevice = new PlatformDevice();
+                platformDevice.setIsdeleted(Constants.ZERO);
+                platformDevice.setPlatformId(platform.getId());
+                platformDevice.setCreateDate(new Date());
+                platformDevice.setCreator(platform.getLoginUserInfo().getId());
+                platformDevice.setType(Constants.TWO);
+                platformDevice.setDeviceId(broadcastId.toString());
+                platformDevice.setHkId(device.getHkId());
+                platformDevice.setName(device.getName());
+                platformDeviceList.add(platformDevice);
+            }
+            platformDeviceMapper.insert(platformDeviceList);
+        }
+
         platformMapper.updateById(platform);
     }
 
@@ -160,7 +268,35 @@
                 queryWrapper.orderByAsc(sortData.getProperty());
             }
         }
-        return PageData.from(platformMapper.selectJoinPage(page,Platform.class, queryWrapper));
+        PageData<Platform> platformPageData = PageData.from(platformMapper.selectJoinPage(page,Platform.class, queryWrapper));
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformPageData.getRecords())){
+            for (Platform platform:platformPageData.getRecords()) {
+                List<PlatformDevice> ledDevice =  platformDeviceMapper.selectList(new QueryWrapper<PlatformDevice>().lambda()
+                        .eq(PlatformDevice::getPlatformId,platform.getId())
+                        .eq(PlatformDevice::getType,Constants.ZERO)
+                );
+                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ledDevice)){
+                    platform.setLedNames(String.join(",", ledDevice.stream().map(m->m.getName()).collect(Collectors.toList())));
+                    platform.setLedIds(
+                            ledDevice.stream().map(m->Integer.valueOf(m.getDeviceId())).collect(Collectors.toList())
+                    );
+                }
+
+                List<PlatformDevice> broadcastDevice =  platformDeviceMapper.selectList(new QueryWrapper<PlatformDevice>().lambda()
+                        .eq(PlatformDevice::getPlatformId,platform.getId())
+                        .eq(PlatformDevice::getType,Constants.TWO)
+                );
+                if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(broadcastDevice)){
+                    platform.setBroadcastNames(String.join(",", broadcastDevice.stream().map(m->m.getName()).collect(Collectors.toList())));
+                    platform.setBroadcastIds(
+                            broadcastDevice.stream().map(m->Integer.valueOf(m.getDeviceId())).collect(Collectors.toList())
+                    );
+                }
+            }
+
+        }
+
+        return platformPageData;
     }
 
     @Override

--
Gitblit v1.9.3