设备注册功能优化
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;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user