From 7dd6f64910238eca447d2bbc797f2817275963e6 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 24 九月 2024 16:43:53 +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/PlatformServiceImpl.java | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 172 insertions(+), 6 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 4acdb01..589330c 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,28 @@
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.dao.openapi.response.PlatformStatusListResponse;
+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 +44,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 +123,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 +269,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
@@ -197,6 +334,35 @@
+ @Override
+ public List<PlatformStatusListResponse> getPlatformStatusList(){
+ List<Platform> platformList = platformJoinMapper.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 ")
+ .select(" ( select pj.CAR_CODE_FRONT from platform_job pj where t.id = pj.PLATFORM_ID and pj.STATUS = "+Constants.PlatformJobStatus.WORKING.getKey()+" limit 1 ) as workCarCode ")
+ .eq(Platform::getIsdeleted,Constants.ZERO)
+ );
+ List<PlatformStatusListResponse> platformStatusListResponses = new ArrayList<>();
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformList)){
+ for (Platform platform:platformList) {
+ PlatformStatusListResponse response = new PlatformStatusListResponse();
+ response.setPlatformHkId(platform.getHkId());
+ response.setPlatformName(platform.getName());
+ response.setStatus(platform.getPlatformStatus());
+ if(Constants.equalsInteger(platform.getPlatformStatus(),Constants.ONE)){
+ response.setCarCode(platform.getWorkCarCode());
+ }
+
+
+
+ }
+ }
+
+
+ return platformStatusListResponses;
+
+ }
+
}
--
Gitblit v1.9.3