From dd565dabf917e340d93b500335804a012fa91fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=8F=E6=9E=97?= <320730042@qq.com> Date: Tue, 4 Jun 2024 14:46:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E5=A4=87=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E3=80=81=E8=AE=BE=E5=A4=87=E8=A7=A3=E7=BB=91/=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E5=AE=A2=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bellmann/common/result/ResultCode.java | 3 +- .../com/bellmann/common/util/FTPUtils.java | 7 ++-- .../controller/DeviceStaticController.java | 12 +++++- .../controller/FileOptionController.java | 7 ---- .../com/bellmann/manger/CustomerManager.java | 4 ++ .../manger/impl/CustomerManagerImpl.java | 8 ++++ .../bellmann/mapper/DeviceStaticMapper.java | 2 + .../bellmann/service/DeviceStaticService.java | 5 +++ .../service/impl/DeviceStaticServiceImpl.java | 40 ++++++++++++++++++- .../resources/mapper/DeviceStaticMapper.xml | 12 ++++++ 10 files changed, 87 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/bellmann/common/result/ResultCode.java b/src/main/java/com/bellmann/common/result/ResultCode.java index 262303f..16b6ddf 100644 --- a/src/main/java/com/bellmann/common/result/ResultCode.java +++ b/src/main/java/com/bellmann/common/result/ResultCode.java @@ -98,7 +98,8 @@ public enum ResultCode implements IResultCode, Serializable { DEVICE_TYPE_VER("F0008","存在该设备类型的软件版本或设备"), TR069_BINDING_SERVICE("F0009","TR069数据模型已经和业务绑定"), - ; + CUSTOM_NOT_FIND("F0010", "客户不存在"), + DEV_DOMAIN_MAP_NOT_FOUNT("F0011", "传入的设备软件版本和系统管理域映射不存在"); @Override public String getCode() { return code; diff --git a/src/main/java/com/bellmann/common/util/FTPUtils.java b/src/main/java/com/bellmann/common/util/FTPUtils.java index ad55add..c4a06b9 100644 --- a/src/main/java/com/bellmann/common/util/FTPUtils.java +++ b/src/main/java/com/bellmann/common/util/FTPUtils.java @@ -4,16 +4,17 @@ package com.bellmann.common.util; import com.bellmann.common.exception.BusinessException; import com.bellmann.common.result.ResultCode; import com.bellmann.model.entity.FileServer; -import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Arrays; diff --git a/src/main/java/com/bellmann/controller/DeviceStaticController.java b/src/main/java/com/bellmann/controller/DeviceStaticController.java index 5489d7c..2eb2f70 100644 --- a/src/main/java/com/bellmann/controller/DeviceStaticController.java +++ b/src/main/java/com/bellmann/controller/DeviceStaticController.java @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; @Tag(name = "16.设备管理") @@ -62,6 +63,15 @@ public class DeviceStaticController { public Result bindingCustom(@PathVariable Long customId, @PathVariable Long devId){ return deviceStaticService.bindingCustom(customId,devId); } - + @PostMapping("delete-dev") + @Operation(summary = "资源管理-删除设备") + public Result deleteDev(@RequestBody List ids){ + return deviceStaticService.deleteDev(ids); + } + @PutMapping("unbinding-custom/{devId}") + @Operation(summary = "资源管理-设备详细信息-解除用户绑定") + public Result unbindingCustom(@PathVariable Long devId){ + return deviceStaticService.unbindingCustom(devId); + } //--------------资源管理API结束-------------------- } diff --git a/src/main/java/com/bellmann/controller/FileOptionController.java b/src/main/java/com/bellmann/controller/FileOptionController.java index b5e862c..024b638 100644 --- a/src/main/java/com/bellmann/controller/FileOptionController.java +++ b/src/main/java/com/bellmann/controller/FileOptionController.java @@ -1,22 +1,16 @@ package com.bellmann.controller; -import com.bellmann.common.model.Tr069Xml; import com.bellmann.common.result.Result; -import com.bellmann.common.util.Tr069XmlUtils; import com.bellmann.plugin.dupsubmit.annotation.PreventDuplicateSubmit; import com.bellmann.service.FileOptionService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import java.io.InputStream; @Tag(name = "09.文件操作接口") @RestController @@ -54,5 +48,4 @@ public class FileOptionController { return Result.success(fileOptionService.removeFile(fileUrl,fileName)); } - } diff --git a/src/main/java/com/bellmann/manger/CustomerManager.java b/src/main/java/com/bellmann/manger/CustomerManager.java index 2477f78..9435677 100644 --- a/src/main/java/com/bellmann/manger/CustomerManager.java +++ b/src/main/java/com/bellmann/manger/CustomerManager.java @@ -1,7 +1,11 @@ package com.bellmann.manger; +import com.bellmann.model.entity.Customer; import com.bellmann.model.vo.EquipmentCustomerVO; public interface CustomerManager { EquipmentCustomerVO equipmentCustomer(Long customId); + + Customer findByCustomId(Long customId); + } diff --git a/src/main/java/com/bellmann/manger/impl/CustomerManagerImpl.java b/src/main/java/com/bellmann/manger/impl/CustomerManagerImpl.java index 6494ac1..8ff7a8f 100644 --- a/src/main/java/com/bellmann/manger/impl/CustomerManagerImpl.java +++ b/src/main/java/com/bellmann/manger/impl/CustomerManagerImpl.java @@ -41,4 +41,12 @@ public class CustomerManagerImpl implements CustomerManager { customer.getRegionAreaId().toString())); return customerVO; } + + @Override + public Customer findByCustomId(Long customId) { + return customerMapper.selectOne(new LambdaQueryWrapper() + .eq(Customer::getCustId,customId) + ); + + } } diff --git a/src/main/java/com/bellmann/mapper/DeviceStaticMapper.java b/src/main/java/com/bellmann/mapper/DeviceStaticMapper.java index a73b39d..8a6624f 100644 --- a/src/main/java/com/bellmann/mapper/DeviceStaticMapper.java +++ b/src/main/java/com/bellmann/mapper/DeviceStaticMapper.java @@ -15,4 +15,6 @@ public interface DeviceStaticMapper extends BaseMapper { List resourcePage(Page page, @Param("column") String column, @Param("value") String value); EquipmentDetailVO detailInfo(@Param("devId") Long devId); + + Long countJoinDevVerDomain(@Param("devId") Long devId, @Param("regionAreaId") Long regionAreaId); } diff --git a/src/main/java/com/bellmann/service/DeviceStaticService.java b/src/main/java/com/bellmann/service/DeviceStaticService.java index 5f8fa97..1ca45da 100644 --- a/src/main/java/com/bellmann/service/DeviceStaticService.java +++ b/src/main/java/com/bellmann/service/DeviceStaticService.java @@ -8,6 +8,7 @@ import com.bellmann.model.form.PrivateProfileForm; import com.bellmann.model.query.SelectQuery; import com.bellmann.model.vo.EquipmentVO; +import java.util.List; import java.util.Map; public interface DeviceStaticService { @@ -22,4 +23,8 @@ public interface DeviceStaticService { Result privateProfile(PrivateProfileForm form); Result bindingCustom(Long customId, Long devId); + + Result deleteDev(List ids); + + Result unbindingCustom(Long devId); } diff --git a/src/main/java/com/bellmann/service/impl/DeviceStaticServiceImpl.java b/src/main/java/com/bellmann/service/impl/DeviceStaticServiceImpl.java index 3b4ac09..c94b9e1 100644 --- a/src/main/java/com/bellmann/service/impl/DeviceStaticServiceImpl.java +++ b/src/main/java/com/bellmann/service/impl/DeviceStaticServiceImpl.java @@ -86,7 +86,9 @@ public class DeviceStaticServiceImpl implements DeviceStaticService { EquipmentTypeVO typeVO = deviceTypeManager.findEquipmentType(detailVO.getTypeAndVerId()); EquipmentCustomerVO customerVO = customerManager.equipmentCustomer(detailVO.getCustomId()); - + if (customerVO==null){ + customerVO = new EquipmentCustomerVO(); + } detailVO.setDevOnline(IBaseEnum.getLabelByValue(detailVO.getDevOnline(), DevOnlineEnum.class)); detailVO.setDevStatus(IBaseEnum.getLabelByValue(detailVO.getDevStatus(), DevStatusEnum.class)); String devRemark4 = detailVO.getDevRemark4(); @@ -176,6 +178,7 @@ public class DeviceStaticServiceImpl implements DeviceStaticService { fileRecord.setFileDesc(form.getFileDesc()); fileRecord.setUserName(SecurityUtils.getUsername()); fileRecord.setFileCreateTime(LocalDateTime.now()); + fileRecord.setFileServId(1L); Long fileId = fileRecordManager.addPrivateProfile(fileRecord); FileDevMap fileDevMap = new FileDevMap(); @@ -187,9 +190,44 @@ public class DeviceStaticServiceImpl implements DeviceStaticService { @Override public Result bindingCustom(Long customId, Long devId) { + Customer customer = customerManager.findByCustomId(customId); + if (customer==null){ + return Result.failed(ResultCode.CUSTOM_NOT_FIND); + } +// Long count = deviceStaticMapper.countJoinDevVerDomain(devId,customer.getRegionAreaId()); +// if(count==null || count!=1){ +// return Result.failed(ResultCode.DEV_DOMAIN_MAP_NOT_FOUNT); +// } deviceStaticMapper.update(null,new LambdaUpdateWrapper() .eq(DeviceStatic::getDevId,devId) .set(DeviceStatic::getCustomId,customId) + .set(customer.getCorpAreaId()!=null,DeviceStatic::getCorpAreaId,customer.getCorpAreaId()) + .set(customer.getRegionAreaId()!=null,DeviceStatic::getRegionAreaId,customer.getRegionAreaId()) + ); + return Result.success(); + } + + @Override + public Result deleteDev(List ids) { + if(ids.isEmpty()){ + return Result.failed(ResultCode.IDS_IS_NULL); + } + for (Long devId: ids){ + deviceStaticMapper.update(null,new LambdaUpdateWrapper() + .eq(DeviceStatic::getDevId,devId) + .set(DeviceStatic::getDevStatus,DevStatusEnum.SIGN_OUT.getValue()) + + ); + } + return Result.success(); + } + + @Override + public Result unbindingCustom(Long devId) { + deviceStaticMapper.update(null,new LambdaUpdateWrapper() + .eq(DeviceStatic::getDevId,devId) + .set(DeviceStatic::getDevModifyTime,LocalDateTime.now()) + .set(DeviceStatic::getCustomId,null) ); return Result.success(); } diff --git a/src/main/resources/mapper/DeviceStaticMapper.xml b/src/main/resources/mapper/DeviceStaticMapper.xml index 9bbe933..9c11ab8 100644 --- a/src/main/resources/mapper/DeviceStaticMapper.xml +++ b/src/main/resources/mapper/DeviceStaticMapper.xml @@ -67,4 +67,16 @@ WHERE s.DEV_ID = #{devId}; + +