feat: 设备删除、设备解绑/绑定客户

master
李小林 9 months ago
parent 31f7b0850c
commit dd565dabf9
  1. 3
      src/main/java/com/bellmann/common/result/ResultCode.java
  2. 7
      src/main/java/com/bellmann/common/util/FTPUtils.java
  3. 12
      src/main/java/com/bellmann/controller/DeviceStaticController.java
  4. 7
      src/main/java/com/bellmann/controller/FileOptionController.java
  5. 4
      src/main/java/com/bellmann/manger/CustomerManager.java
  6. 8
      src/main/java/com/bellmann/manger/impl/CustomerManagerImpl.java
  7. 2
      src/main/java/com/bellmann/mapper/DeviceStaticMapper.java
  8. 5
      src/main/java/com/bellmann/service/DeviceStaticService.java
  9. 40
      src/main/java/com/bellmann/service/impl/DeviceStaticServiceImpl.java
  10. 12
      src/main/resources/mapper/DeviceStaticMapper.xml

@ -98,7 +98,8 @@ public enum ResultCode implements IResultCode, Serializable {
DEVICE_TYPE_VER("F0008","存在该设备类型的软件版本或设备"), DEVICE_TYPE_VER("F0008","存在该设备类型的软件版本或设备"),
TR069_BINDING_SERVICE("F0009","TR069数据模型已经和业务绑定"), TR069_BINDING_SERVICE("F0009","TR069数据模型已经和业务绑定"),
; CUSTOM_NOT_FIND("F0010", "客户不存在"),
DEV_DOMAIN_MAP_NOT_FOUNT("F0011", "传入的设备软件版本和系统管理域映射不存在");
@Override @Override
public String getCode() { public String getCode() {
return code; return code;

@ -4,16 +4,17 @@ package com.bellmann.common.util;
import com.bellmann.common.exception.BusinessException; import com.bellmann.common.exception.BusinessException;
import com.bellmann.common.result.ResultCode; import com.bellmann.common.result.ResultCode;
import com.bellmann.model.entity.FileServer; import com.bellmann.model.entity.FileServer;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply; import org.apache.commons.net.ftp.FTPReply;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; 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.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;

@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map; import java.util.Map;
@Tag(name = "16.设备管理") @Tag(name = "16.设备管理")
@ -62,6 +63,15 @@ public class DeviceStaticController {
public Result<String> bindingCustom(@PathVariable Long customId, @PathVariable Long devId){ public Result<String> bindingCustom(@PathVariable Long customId, @PathVariable Long devId){
return deviceStaticService.bindingCustom(customId,devId); return deviceStaticService.bindingCustom(customId,devId);
} }
@PostMapping("delete-dev")
@Operation(summary = "资源管理-删除设备")
public Result<String> deleteDev(@RequestBody List<Long> ids){
return deviceStaticService.deleteDev(ids);
}
@PutMapping("unbinding-custom/{devId}")
@Operation(summary = "资源管理-设备详细信息-解除用户绑定")
public Result<String> unbindingCustom(@PathVariable Long devId){
return deviceStaticService.unbindingCustom(devId);
}
//--------------资源管理API结束-------------------- //--------------资源管理API结束--------------------
} }

@ -1,22 +1,16 @@
package com.bellmann.controller; package com.bellmann.controller;
import com.bellmann.common.model.Tr069Xml;
import com.bellmann.common.result.Result; import com.bellmann.common.result.Result;
import com.bellmann.common.util.Tr069XmlUtils;
import com.bellmann.plugin.dupsubmit.annotation.PreventDuplicateSubmit; import com.bellmann.plugin.dupsubmit.annotation.PreventDuplicateSubmit;
import com.bellmann.service.FileOptionService; import com.bellmann.service.FileOptionService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.io.InputStream;
@Tag(name = "09.文件操作接口") @Tag(name = "09.文件操作接口")
@RestController @RestController
@ -54,5 +48,4 @@ public class FileOptionController {
return Result.success(fileOptionService.removeFile(fileUrl,fileName)); return Result.success(fileOptionService.removeFile(fileUrl,fileName));
} }
} }

@ -1,7 +1,11 @@
package com.bellmann.manger; package com.bellmann.manger;
import com.bellmann.model.entity.Customer;
import com.bellmann.model.vo.EquipmentCustomerVO; import com.bellmann.model.vo.EquipmentCustomerVO;
public interface CustomerManager { public interface CustomerManager {
EquipmentCustomerVO equipmentCustomer(Long customId); EquipmentCustomerVO equipmentCustomer(Long customId);
Customer findByCustomId(Long customId);
} }

@ -41,4 +41,12 @@ public class CustomerManagerImpl implements CustomerManager {
customer.getRegionAreaId().toString())); customer.getRegionAreaId().toString()));
return customerVO; return customerVO;
} }
@Override
public Customer findByCustomId(Long customId) {
return customerMapper.selectOne(new LambdaQueryWrapper<Customer>()
.eq(Customer::getCustId,customId)
);
}
} }

@ -15,4 +15,6 @@ public interface DeviceStaticMapper extends BaseMapper<DeviceStatic> {
List<EquipmentBO> resourcePage(Page<EquipmentBO> page, @Param("column") String column, @Param("value") String value); List<EquipmentBO> resourcePage(Page<EquipmentBO> page, @Param("column") String column, @Param("value") String value);
EquipmentDetailVO detailInfo(@Param("devId") Long devId); EquipmentDetailVO detailInfo(@Param("devId") Long devId);
Long countJoinDevVerDomain(@Param("devId") Long devId, @Param("regionAreaId") Long regionAreaId);
} }

@ -8,6 +8,7 @@ import com.bellmann.model.form.PrivateProfileForm;
import com.bellmann.model.query.SelectQuery; import com.bellmann.model.query.SelectQuery;
import com.bellmann.model.vo.EquipmentVO; import com.bellmann.model.vo.EquipmentVO;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface DeviceStaticService { public interface DeviceStaticService {
@ -22,4 +23,8 @@ public interface DeviceStaticService {
Result<Long> privateProfile(PrivateProfileForm form); Result<Long> privateProfile(PrivateProfileForm form);
Result<String> bindingCustom(Long customId, Long devId); Result<String> bindingCustom(Long customId, Long devId);
Result<String> deleteDev(List<Long> ids);
Result<String> unbindingCustom(Long devId);
} }

@ -86,7 +86,9 @@ public class DeviceStaticServiceImpl implements DeviceStaticService {
EquipmentTypeVO typeVO = deviceTypeManager.findEquipmentType(detailVO.getTypeAndVerId()); EquipmentTypeVO typeVO = deviceTypeManager.findEquipmentType(detailVO.getTypeAndVerId());
EquipmentCustomerVO customerVO = customerManager.equipmentCustomer(detailVO.getCustomId()); EquipmentCustomerVO customerVO = customerManager.equipmentCustomer(detailVO.getCustomId());
if (customerVO==null){
customerVO = new EquipmentCustomerVO();
}
detailVO.setDevOnline(IBaseEnum.getLabelByValue(detailVO.getDevOnline(), DevOnlineEnum.class)); detailVO.setDevOnline(IBaseEnum.getLabelByValue(detailVO.getDevOnline(), DevOnlineEnum.class));
detailVO.setDevStatus(IBaseEnum.getLabelByValue(detailVO.getDevStatus(), DevStatusEnum.class)); detailVO.setDevStatus(IBaseEnum.getLabelByValue(detailVO.getDevStatus(), DevStatusEnum.class));
String devRemark4 = detailVO.getDevRemark4(); String devRemark4 = detailVO.getDevRemark4();
@ -176,6 +178,7 @@ public class DeviceStaticServiceImpl implements DeviceStaticService {
fileRecord.setFileDesc(form.getFileDesc()); fileRecord.setFileDesc(form.getFileDesc());
fileRecord.setUserName(SecurityUtils.getUsername()); fileRecord.setUserName(SecurityUtils.getUsername());
fileRecord.setFileCreateTime(LocalDateTime.now()); fileRecord.setFileCreateTime(LocalDateTime.now());
fileRecord.setFileServId(1L);
Long fileId = fileRecordManager.addPrivateProfile(fileRecord); Long fileId = fileRecordManager.addPrivateProfile(fileRecord);
FileDevMap fileDevMap = new FileDevMap(); FileDevMap fileDevMap = new FileDevMap();
@ -187,9 +190,44 @@ public class DeviceStaticServiceImpl implements DeviceStaticService {
@Override @Override
public Result<String> bindingCustom(Long customId, Long devId) { public Result<String> 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<DeviceStatic>() deviceStaticMapper.update(null,new LambdaUpdateWrapper<DeviceStatic>()
.eq(DeviceStatic::getDevId,devId) .eq(DeviceStatic::getDevId,devId)
.set(DeviceStatic::getCustomId,customId) .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<String> deleteDev(List<Long> ids) {
if(ids.isEmpty()){
return Result.failed(ResultCode.IDS_IS_NULL);
}
for (Long devId: ids){
deviceStaticMapper.update(null,new LambdaUpdateWrapper<DeviceStatic>()
.eq(DeviceStatic::getDevId,devId)
.set(DeviceStatic::getDevStatus,DevStatusEnum.SIGN_OUT.getValue())
);
}
return Result.success();
}
@Override
public Result<String> unbindingCustom(Long devId) {
deviceStaticMapper.update(null,new LambdaUpdateWrapper<DeviceStatic>()
.eq(DeviceStatic::getDevId,devId)
.set(DeviceStatic::getDevModifyTime,LocalDateTime.now())
.set(DeviceStatic::getCustomId,null)
); );
return Result.success(); return Result.success();
} }

@ -67,4 +67,16 @@
WHERE WHERE
s.DEV_ID = #{devId}; s.DEV_ID = #{devId};
</select> </select>
<select id="countJoinDevVerDomain" resultType="java.lang.Long">
SELECT
count( * )
FROM
ITMS_DEVTYPEVER_SYSDOMAIN_MAP,
ITMS_DEVICE_STATIC
WHERE
ITMS_DEVTYPEVER_SYSDOMAIN_MAP.TYPE_AND_VER_ID = ITMS_DEVICE_STATIC.TYPE_AND_VER_ID
AND ITMS_DEVICE_STATIC.DEV_ID = #{devId}
AND ITMS_DEVTYPEVER_SYSDOMAIN_MAP.SYS_DOMAIN_ID = #{regionAreaId}
</select>
</mapper> </mapper>

Loading…
Cancel
Save