设备流程判断

This commit is contained in:
2023-09-14 14:08:17 +08:00
parent 090286d25a
commit f52835ab68
4 changed files with 22 additions and 8 deletions

View File

@@ -61,8 +61,10 @@ public enum AccessResponseEnum {
LDEVINFO_IS_NULL("A0309","逻辑设备信息为空"), LDEVINFO_IS_NULL("A0309","逻辑设备信息为空"),
SOFTINFO_IS_NULL("A0309","软件信息为空"), SOFTINFO_IS_NULL("A0309","软件信息为空"),
LINE_POSITION_REPEAT("A0310","监测点位置重复") LINE_POSITION_REPEAT("A0310","监测点位置重复"),
PROCESS_SAME_ERROR("A0311","当前调试已完成,请勿重复调试"),
PROCESS_MISSING_ERROR("A0311","调试流程缺失,请核查功能调试、出厂调试"),
; ;
private final String code; private final String code;

View File

@@ -11,6 +11,7 @@ import com.njcn.web.annotation.ReturnMsg;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -37,10 +38,13 @@ public class CsDeviceController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/register") @PostMapping("/register")
@ApiOperation("直连设备状态判断") @ApiOperation("直连设备状态判断")
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true) @ApiImplicitParams({
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true),
@ApiImplicitParam(name = "type", value = "流程标识", required = true)
})
@ReturnMsg @ReturnMsg
public HttpResult<String> devRegister(@RequestParam String nDid){ public HttpResult<String> devRegister(@RequestParam String nDid,@RequestParam Integer type){
csDeviceService.devRegister(nDid); csDeviceService.devRegister(nDid,type);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, "设备MQTT通讯状态!"); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, "设备MQTT通讯状态!");
} }

View File

@@ -15,8 +15,9 @@ public interface ICsDeviceService {
/** /**
* 直连设备注册 * 直连设备注册
* @param nDid 设备识别码 * @param nDid 设备识别码
* @param type 流程标识
*/ */
void devRegister(String nDid); void devRegister(String nDid,Integer type);
/** /**
* MQTT连接成功获取装置所用的模板信息 * MQTT连接成功获取装置所用的模板信息

View File

@@ -101,7 +101,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public void devRegister(String nDid) { public void devRegister(String nDid,Integer type) {
//日志实体 //日志实体
DeviceLogDTO logDto = new DeviceLogDTO(); DeviceLogDTO logDto = new DeviceLogDTO();
logDto.setUserName(RequestUtil.getUserNickname()); logDto.setUserName(RequestUtil.getUserNickname());
@@ -140,10 +140,16 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
csLogsFeignClient.addUserLog(logDto); csLogsFeignClient.addUserLog(logDto);
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT); throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
} }
//4.询问设备支持的主题信息 //4.判断当前流程是否是合法的
if (csEquipmentDeliveryVO.getProcess() > type){
throw new BusinessException(AccessResponseEnum.PROCESS_SAME_ERROR);
} else if (csEquipmentDeliveryVO.getProcess() < type){
throw new BusinessException(AccessResponseEnum.PROCESS_MISSING_ERROR);
}
//5.询问设备支持的主题信息
//将支持的主题入库 //将支持的主题入库
askTopic(nDid); askTopic(nDid);
//5.MQTT询问装置用的模板并判断库中是否存在模板 //6.MQTT询问装置用的模板并判断库中是否存在模板
//存在则建立关系;不存在则告警出来 //存在则建立关系;不存在则告警出来
SysDicTreePO dictData = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevModel()).getData(); SysDicTreePO dictData = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevModel()).getData();
if (Objects.isNull(dictData)){ if (Objects.isNull(dictData)){
@@ -364,6 +370,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode()); reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_5.getCode())); reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_5.getCode()));
reqAndResParam.setExpire(-1); reqAndResParam.setExpire(-1);
logger.info("设备接入报文为:" + new Gson().toJson(reqAndResParam));
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(reqAndResParam),1,false); publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(reqAndResParam),1,false);
} }