代码提交
This commit is contained in:
@@ -14,7 +14,7 @@ public enum AccessResponseEnum {
|
|||||||
* A0301 ~ A0399 用于用户模块的枚举
|
* A0301 ~ A0399 用于用户模块的枚举
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
DEV_NO_FIND("A0301", "nDid未匹配!"),
|
NDID_NO_FIND("A0301", "与平台nDid匹配错误!"),
|
||||||
|
|
||||||
MODEL_REPEAT("A0302", "模板重复,请勿重复录入!"),
|
MODEL_REPEAT("A0302", "模板重复,请勿重复录入!"),
|
||||||
MODEL_NO_FIND("A0302", "模板不存在,请先录入模板数据!"),
|
MODEL_NO_FIND("A0302", "模板不存在,请先录入模板数据!"),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.access.controller;
|
package com.njcn.access.controller;
|
||||||
|
|
||||||
|
import com.njcn.access.enums.AccessResponseEnum;
|
||||||
import com.njcn.access.service.IAccessService;
|
import com.njcn.access.service.IAccessService;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
@@ -40,7 +41,11 @@ public class AccessController extends BaseController {
|
|||||||
log.info("设备向装置侧发起注册请求,请求的nDid为:" + nDid);
|
log.info("设备向装置侧发起注册请求,请求的nDid为:" + nDid);
|
||||||
String methodDescribe = getMethodDescribe("add");
|
String methodDescribe = getMethodDescribe("add");
|
||||||
LogUtil.njcnDebug(log, "{},设备向装置侧发起注册请求,请求的nDid为:{}", methodDescribe, nDid);
|
LogUtil.njcnDebug(log, "{},设备向装置侧发起注册请求,请求的nDid为:{}", methodDescribe, nDid);
|
||||||
accessService.add(nDid);
|
boolean result = accessService.add(nDid);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
if (result){
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ public class MqttMessageHandler {
|
|||||||
@MqttSubscribe(value = "/Dev/Reg/{edgeId}",qos = 1)
|
@MqttSubscribe(value = "/Dev/Reg/{edgeId}",qos = 1)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void devOperation(String topic, MqttMessage message, @NamedValue("edgeId") String nDid, @Payload String payload){
|
public void devOperation(String topic, MqttMessage message, @NamedValue("edgeId") String nDid, @Payload String payload){
|
||||||
|
log.info("收到注册应答响应--->" + nDid);
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
ReqAndResParam.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class);
|
ReqAndResParam.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class);
|
||||||
//检验传递的参数是否准确
|
//检验传递的参数是否准确
|
||||||
@@ -190,7 +191,7 @@ public class MqttMessageHandler {
|
|||||||
System.out.println("网关设备判断");
|
System.out.println("网关设备判断");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info(AccessResponseEnum.DEV_NO_FIND.getMessage());
|
log.info(AccessResponseEnum.NDID_NO_FIND.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ public interface IAccessService {
|
|||||||
* 3.装置响应则修改装置状态;3分钟未响应则生成告警信息
|
* 3.装置响应则修改装置状态;3分钟未响应则生成告警信息
|
||||||
* @param nDid 网关识别码
|
* @param nDid 网关识别码
|
||||||
*/
|
*/
|
||||||
void add(String nDid);
|
Boolean add(String nDid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,12 @@ import com.njcn.access.enums.TypeEnum;
|
|||||||
import com.njcn.access.pojo.dto.AccessDto;
|
import com.njcn.access.pojo.dto.AccessDto;
|
||||||
import com.njcn.access.pojo.param.ReqAndResParam;
|
import com.njcn.access.pojo.param.ReqAndResParam;
|
||||||
import com.njcn.access.service.IAccessService;
|
import com.njcn.access.service.IAccessService;
|
||||||
|
import com.njcn.algorithm.api.CsEdDataFeignClient;
|
||||||
import com.njcn.algorithm.api.EquipmentFeignClient;
|
import com.njcn.algorithm.api.EquipmentFeignClient;
|
||||||
|
import com.njcn.algorithm.pojo.po.CsEdDataPO;
|
||||||
|
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
||||||
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
|
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -33,13 +37,20 @@ public class AccessServiceImpl implements IAccessService {
|
|||||||
|
|
||||||
private final EquipmentFeignClient equipmentFeignClient;
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
|
|
||||||
|
private final CsEdDataFeignClient csEdDataFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(String nDid) {
|
public Boolean add(String nDid) {
|
||||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||||
if (Objects.isNull(vo)){
|
System.out.println("vo==:" + vo);
|
||||||
|
if (Objects.isNull(vo.getNdid())){
|
||||||
logger.error("平台侧无此网关信息,请先录入!");
|
logger.error("平台侧无此网关信息,请先录入!");
|
||||||
return;
|
return false;
|
||||||
|
} else {
|
||||||
|
HttpResult<CsEdDataVO> result = csEdDataFeignClient.findByDevTypeId(vo.getDevModel());
|
||||||
|
System.out.println("result==:" + result);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
|
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
|
||||||
reqAndResParam.setMid(1);
|
reqAndResParam.setMid(1);
|
||||||
reqAndResParam.setDid("0");
|
reqAndResParam.setDid("0");
|
||||||
@@ -51,5 +62,6 @@ public class AccessServiceImpl implements IAccessService {
|
|||||||
accessDto.setDevType(vo.getDevModel());
|
accessDto.setDevType(vo.getDevModel());
|
||||||
reqAndResParam.setMsg(accessDto);
|
reqAndResParam.setMsg(accessDto);
|
||||||
publisher.send("/platform/register/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
publisher.send("/platform/register/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user