代码调整
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package com.njcn.algorithm.api;
|
||||||
|
|
||||||
|
import com.njcn.algorithm.api.fallback.CsEdDataFeignClientFallbackFactory;
|
||||||
|
import com.njcn.algorithm.pojo.po.CsEdDataPO;
|
||||||
|
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.ALGORITHM_BOOT, path = "/edData", fallbackFactory = CsEdDataFeignClientFallbackFactory.class,contextId = "edData")
|
||||||
|
public interface CsEdDataFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/findByDevTypeId")
|
||||||
|
HttpResult<CsEdDataVO> findByDevTypeId(@RequestParam("devType") String devType);
|
||||||
|
|
||||||
|
@PostMapping("/getAll")
|
||||||
|
HttpResult<List<CsEdDataPO>> getAll(@RequestParam("devType") String devType);
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.njcn.algorithm.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.algorithm.api.CsEdDataFeignClient;
|
||||||
|
import com.njcn.algorithm.pojo.po.CsEdDataPO;
|
||||||
|
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CsEdDataFeignClientFallbackFactory implements FallbackFactory<CsEdDataFeignClient> {
|
||||||
|
@Override
|
||||||
|
public CsEdDataFeignClient create(Throwable cause) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (cause.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) cause.getCause();
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new CsEdDataFeignClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<CsEdDataVO> findByDevTypeId(String devType) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","根据装置型号获取装置类型",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<List<CsEdDataPO>> getAll(String devType) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","根据装置型号获取装置类型",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.njcn.db.bo.BaseEntity;
|
import com.njcn.db.bo.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +25,7 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName(value = "cs_ed_data")
|
@TableName(value = "cs_ed_data")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class CsEdDataPO extends BaseEntity {
|
public class CsEdDataPO extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
@@ -78,4 +81,10 @@ public class CsEdDataPO extends BaseEntity {
|
|||||||
@TableField(value = "file_path")
|
@TableField(value = "file_path")
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置类型
|
||||||
|
*/
|
||||||
|
@TableField(value = "type")
|
||||||
|
private String type;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -68,4 +68,7 @@ public class CsEdDataVO extends BaseEntity {
|
|||||||
@ApiModelProperty(value = ".bin文件")
|
@ApiModelProperty(value = ".bin文件")
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "type")
|
||||||
|
private String type;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -74,8 +74,8 @@ public class EquipmentDeliveryController extends BaseController {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/queryEquipmentByndid")
|
@PostMapping("/queryEquipmentByndid")
|
||||||
@ApiOperation("通过ndid查询出厂设备")
|
@ApiOperation("通过ndid查询出厂设备")
|
||||||
@ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
|
@ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
|
||||||
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid")String ndid){
|
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid")String ndid){
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.njcn.algorithm.pojo.param.CsEdDataAddParm;
|
import com.njcn.algorithm.pojo.param.CsEdDataAddParm;
|
||||||
import com.njcn.algorithm.pojo.param.CsEdDataAuditParm;
|
import com.njcn.algorithm.pojo.param.CsEdDataAuditParm;
|
||||||
import com.njcn.algorithm.pojo.param.CsEdDataQueryParm;
|
import com.njcn.algorithm.pojo.param.CsEdDataQueryParm;
|
||||||
|
import com.njcn.algorithm.pojo.po.CsDictPO;
|
||||||
|
import com.njcn.algorithm.pojo.po.CsEdDataPO;
|
||||||
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
||||||
import com.njcn.algorithm.service.CsEdDataService;
|
import com.njcn.algorithm.service.CsEdDataService;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
@@ -18,10 +20,10 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description:
|
* Description:
|
||||||
@@ -72,4 +74,14 @@ public class CsEdDataController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/findByDevTypeId")
|
||||||
|
@ApiOperation("根据装置型号获取装置类型")
|
||||||
|
@ApiImplicitParam(name = "devType", value = "装置型号", required = true)
|
||||||
|
public HttpResult<CsEdDataVO> findByDevTypeId(@Validated @RequestParam("devType") String devType){
|
||||||
|
String methodDescribe = getMethodDescribe("findByDevTypeId");
|
||||||
|
CsEdDataVO vo = csEdDataService.findByDevTypeId(devType);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import com.njcn.algorithm.pojo.po.CsEdDataPO;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description:
|
* Description:
|
||||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||||
@@ -42,5 +44,11 @@ public interface CsEdDataService extends IService<CsEdDataPO> {
|
|||||||
* @Date: 2023/4/7
|
* @Date: 2023/4/7
|
||||||
*/
|
*/
|
||||||
IPage<CsEdDataVO> queryEdDataPage(CsEdDataQueryParm csEdDataQueryParm);
|
IPage<CsEdDataVO> queryEdDataPage(CsEdDataQueryParm csEdDataQueryParm);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 根据装置型号获取装置类型
|
||||||
|
* @author: xuyang
|
||||||
|
*/
|
||||||
|
CsEdDataVO findByDevTypeId(String devType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.algorithm.service.impl;
|
package com.njcn.algorithm.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -16,7 +17,10 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,5 +70,20 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
|
|||||||
returnpage = this.getBaseMapper ().getPage(returnpage,csEdDataQueryParm);
|
returnpage = this.getBaseMapper ().getPage(returnpage,csEdDataQueryParm);
|
||||||
return returnpage;
|
return returnpage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CsEdDataVO findByDevTypeId(String devType) {
|
||||||
|
CsEdDataPO csEdDataPo = new CsEdDataPO();
|
||||||
|
LambdaQueryWrapper<CsEdDataPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(CsEdDataPO::getDevType,devType);
|
||||||
|
lambdaQueryWrapper.eq(CsEdDataPO::getStatus,1);
|
||||||
|
List<CsEdDataPO> list = this.baseMapper.selectList(lambdaQueryWrapper);
|
||||||
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
|
csEdDataPo = list.get(0);
|
||||||
|
}
|
||||||
|
CsEdDataVO csEdDataVo = new CsEdDataVO();
|
||||||
|
BeanUtils.copyProperties(csEdDataPo,csEdDataVo);
|
||||||
|
return csEdDataVo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
public CsEquipmentDeliveryPO queryEquipmentPOByndid(String ndid) {
|
public CsEquipmentDeliveryPO queryEquipmentPOByndid(String ndid) {
|
||||||
QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper();
|
QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper();
|
||||||
wrapper.eq ("ndid", ndid);
|
wrapper.eq ("ndid", ndid);
|
||||||
wrapper.eq("status",2);
|
wrapper.eq("status",1);
|
||||||
CsEquipmentDeliveryPO csEquipmentDeliveryPO = this.baseMapper.selectOne (wrapper);
|
CsEquipmentDeliveryPO csEquipmentDeliveryPO = this.baseMapper.selectOne (wrapper);
|
||||||
return csEquipmentDeliveryPO;
|
return csEquipmentDeliveryPO;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user