设备注册功能优化
This commit is contained in:
@@ -3,6 +3,7 @@ package com.njcn.csdevice.api;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -32,4 +33,7 @@ public interface CsLineFeignClient {
|
||||
|
||||
@PostMapping("/getPositionById")
|
||||
HttpResult<String> getPositionById(@RequestParam("id") String id);
|
||||
|
||||
@PostMapping("/updateLine")
|
||||
HttpResult<String> updateLine(@RequestBody CsLineParam csLineParam);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.DevCapacityClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsDevCapacityPO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/capacity", fallbackFactory = DevCapacityClientFallbackFactory.class,contextId = "capacity")
|
||||
public interface DevCapacityFeignClient {
|
||||
|
||||
@PostMapping("/addList")
|
||||
HttpResult<List<String>> addList(@RequestBody List<CsDevCapacityPO> list);
|
||||
|
||||
}
|
||||
@@ -36,4 +36,18 @@ public interface EquipmentFeignClient {
|
||||
*/
|
||||
@PostMapping("/findDevByNDid")
|
||||
HttpResult<CsEquipmentDeliveryPO> findDevByNDid(@RequestParam("nDid") String nDid);
|
||||
|
||||
/**
|
||||
* 根据nDid更新软件信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateSoftInfo")
|
||||
HttpResult<String> updateSoftInfo(@RequestParam("nDid") String nDid,@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 根据nDid更新模块信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateModuleNumber")
|
||||
HttpResult<String> updateModuleNumber(@RequestParam("nDid") String nDid,@RequestParam("number") Integer number);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -56,6 +57,12 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
|
||||
log.error("{}异常,降级处理,异常为:{}","通过id查询监测点位置",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> updateLine(CsLineParam csLineParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","更新监测点信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.DevCapacityFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsDevCapacityPO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DevCapacityClientFallbackFactory implements FallbackFactory<DevCapacityFeignClient> {
|
||||
@Override
|
||||
public DevCapacityFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DevCapacityFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> addList(List<CsDevCapacityPO> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量新增设备模块容量",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,18 @@ public class EquipmentFeignClientFallbackFactory implements FallbackFactory<Equi
|
||||
log.error("{}异常,降级处理,异常为:{}","通过nDid查询设备信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> updateSoftInfo(String nDid, String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","更新设备软件信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> updateModuleNumber(String nDid, Integer number) {
|
||||
log.error("{}异常,降级处理,异常为:{}","更新设备模块个数",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.csdevice.pojo.param;
|
||||
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/5/18 14:01【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class CsLineParam extends BaseEntity {
|
||||
|
||||
private String lineId;
|
||||
|
||||
/**
|
||||
* 电压等级
|
||||
*/
|
||||
private Double volGrade;
|
||||
|
||||
/**
|
||||
* PT变比
|
||||
*/
|
||||
private Double ptRatio;
|
||||
|
||||
/**
|
||||
* CT变比
|
||||
*/
|
||||
private Double ctRatio;
|
||||
|
||||
/**
|
||||
* 接线方式
|
||||
*/
|
||||
private Integer conType;
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.njcn.csdevice.pojo.param;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/5/18 14:01【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class CsLineParm {
|
||||
|
||||
private String topoId;
|
||||
private String projectId;
|
||||
|
||||
private String devId;
|
||||
/**
|
||||
* 监测点名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字典表:安装位置(负载侧,电网侧, 输出侧)
|
||||
*/
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 电压等级
|
||||
*/
|
||||
private String volGrade;
|
||||
|
||||
/**
|
||||
* PT变比
|
||||
*/
|
||||
private BigDecimal ptRatio;
|
||||
|
||||
/**
|
||||
* CT变比
|
||||
*/
|
||||
private BigDecimal ctRatio;
|
||||
|
||||
private Double lat;
|
||||
private Double lng;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.po.CsDevCapacityPO;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.csdevice.service.CsDevCapacityPOService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -16,6 +15,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
@@ -44,4 +45,14 @@ public class CsDevCapacityController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, limit, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/addList")
|
||||
@ApiOperation("批量新增")
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||
public HttpResult<String> addList(@RequestBody List<CsDevCapacityPO> list){
|
||||
String methodDescribe = getMethodDescribe("addList");
|
||||
csDevCapacityPOService.addList(list);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
@@ -177,6 +178,7 @@ public class EquipmentDeliveryController extends BaseController {
|
||||
@ApiImplicitParam(name = "id", value = "软件信息id", required = true),
|
||||
@ApiImplicitParam(name = "module", value = "模块个数", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<Boolean> updateSoftInfoBynDid(@RequestParam("nDId") String nDid,@RequestParam("id") String id,@RequestParam("module") Integer module){
|
||||
String methodDescribe = getMethodDescribe("updateSoftInfoBynDid");
|
||||
csEquipmentDeliveryService.updateSoftInfoBynDid(nDid,id,module);
|
||||
@@ -237,5 +239,33 @@ public class EquipmentDeliveryController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateSoftInfo")
|
||||
@ApiOperation("更新设备软件信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nDid", value = "网络设备码", required = true),
|
||||
@ApiImplicitParam(name = "id", value = "软件信息id", required = true)
|
||||
})
|
||||
@ApiIgnore
|
||||
public HttpResult<String> updateSoftInfo(@RequestParam("nDid") String nDid,@RequestParam("id") String id){
|
||||
String methodDescribe = getMethodDescribe("updateSoftInfo");
|
||||
csEquipmentDeliveryService.updateSoftInfo(nDid,id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateModuleNumber")
|
||||
@ApiOperation("更新设备模块个数")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nDid", value = "网络设备码", required = true),
|
||||
@ApiImplicitParam(name = "number", value = "模块个数", required = true)
|
||||
})
|
||||
@ApiIgnore
|
||||
public HttpResult<String> updateModuleNumber(@RequestParam("nDid") String nDid,@RequestParam("number") Integer number){
|
||||
String methodDescribe = getMethodDescribe("updateModuleNumber");
|
||||
csEquipmentDeliveryService.updateModuleNumber(nDid,number);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -13,6 +14,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
@@ -95,4 +97,15 @@ public class CslineController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineList, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateLine")
|
||||
@ApiOperation("修改监测点信息")
|
||||
@ApiImplicitParam(name = "csLineParam", value = "监测点信息", required = true)
|
||||
@ApiIgnore
|
||||
public HttpResult<Boolean> updateLine(@RequestBody @Validated CsLineParam csLineParam) {
|
||||
String methodDescribe = getMethodDescribe("updateLine");
|
||||
csLinePOService.updateLine(csLineParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.CsDevCapacityPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsDevCapacityPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
@@ -12,6 +15,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface CsDevCapacityPOService extends IService<CsDevCapacityPO>{
|
||||
|
||||
/**
|
||||
* 批量新增数据
|
||||
* @param list
|
||||
*/
|
||||
void addList(List<CsDevCapacityPO> list);
|
||||
|
||||
|
||||
Double getDevCapacity(String id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -100,4 +100,18 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
|
||||
void testCompletion(String deviceId,Integer type,String remark);
|
||||
|
||||
void deleteTest(String deviceId, Integer type,String remark);
|
||||
|
||||
/**
|
||||
* 更新设备软件信息
|
||||
* @param nDid
|
||||
* @param id
|
||||
*/
|
||||
void updateSoftInfo(String nDid, String id);
|
||||
|
||||
/**
|
||||
* 更新设备模块个数
|
||||
* @param nDid
|
||||
* @param number
|
||||
*/
|
||||
void updateModuleNumber(String nDid, Integer number);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,4 +34,10 @@ public interface CsLinePOService extends IService<CsLinePO>{
|
||||
*/
|
||||
List<CsLinePO> findByNdid(String id);
|
||||
|
||||
/**
|
||||
* 更新监测点信息
|
||||
* @param csLineParam
|
||||
*/
|
||||
void updateLine(CsLineParam csLineParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@ public class CsDevCapacityPOServiceImpl extends ServiceImpl<CsDevCapacityPOMappe
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final DecimalFormat df = new DecimalFormat("#0.000");
|
||||
|
||||
@Override
|
||||
public void addList(List<CsDevCapacityPO> list) {
|
||||
this.saveOrUpdateBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getDevCapacity(String id) {
|
||||
List<CsLinePO> csLinePOS = csLinePOService.queryByDevId(id);
|
||||
|
||||
@@ -518,6 +518,24 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSoftInfo(String nDid, String id) {
|
||||
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid)
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
|
||||
.set(CsEquipmentDeliveryPO::getSoftinfoId,id);
|
||||
this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateModuleNumber(String nDid, Integer number) {
|
||||
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid)
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
|
||||
.set(CsEquipmentDeliveryPO::getModuleNumber,number);
|
||||
this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ndid生成二维码
|
||||
* @param ndid
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||
import com.njcn.csdevice.mapper.CsLinePOMapper;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
@@ -57,6 +59,18 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
return this.baseMapper.findByNdid(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLine(CsLineParam csLineParam) {
|
||||
LambdaUpdateWrapper<CsLinePO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(CsLinePO::getLineId,csLineParam.getLineId())
|
||||
.eq(CsLinePO::getStatus,1)
|
||||
.set(CsLinePO::getVolGrade,csLineParam.getVolGrade())
|
||||
.set(CsLinePO::getPtRatio,csLineParam.getPtRatio())
|
||||
.set(CsLinePO::getCtRatio,csLineParam.getCtRatio())
|
||||
.set(CsLinePO::getConType,csLineParam.getConType());
|
||||
this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 1.平台端默认配置拓扑图模板,包含拓扑图信息(cs_topology_diagram_template)和拓扑图上监测点的点位信息(cs_line_topology_template)
|
||||
// *
|
||||
|
||||
Reference in New Issue
Block a user