新增物接入流程
This commit is contained in:
@@ -14,7 +14,10 @@ public enum AccessResponseEnum {
|
|||||||
* A0301 ~ A0399 用于用户模块的枚举
|
* A0301 ~ A0399 用于用户模块的枚举
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
MODEL_REPEAT("A0301", "模板重复,请勿重复录入!"),
|
DEV_NO_FIND("A0301", "通过nDid未找到相关装置信息!"),
|
||||||
|
|
||||||
|
MODEL_REPEAT("A0302", "模板重复,请勿重复录入!"),
|
||||||
|
MODEL_NO_FIND("A0302", "模板不存在,请先录入模板数据!"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.njcn.access.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/4/18 9:35
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum AccessStatusEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置出厂状态
|
||||||
|
* 0:删除 1:未注册(默认状态) 2:注册 3:接入
|
||||||
|
*/
|
||||||
|
DELETE(0, "删除"),
|
||||||
|
UNREGISTERED(1, "未注册"),
|
||||||
|
REGISTERED(2, "注册"),
|
||||||
|
ACCESS(3, "接入"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
AccessStatusEnum(int code, String message) {
|
||||||
|
this.code=code;
|
||||||
|
this.message=message;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
|||||||
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
||||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
|
import com.njcn.access.enums.AccessStatusEnum;
|
||||||
import com.njcn.access.pojo.dto.*;
|
import com.njcn.access.pojo.dto.*;
|
||||||
import com.njcn.algorithm.api.DevModelFeignClient;
|
import com.njcn.algorithm.api.DevModelFeignClient;
|
||||||
import com.njcn.algorithm.api.EquipmentFeignClient;
|
import com.njcn.algorithm.api.EquipmentFeignClient;
|
||||||
@@ -58,9 +59,7 @@ public class MqttMessageHandler {
|
|||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
RegisterDTO.RegisterResponse registerDTO = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), RegisterDTO.RegisterResponse.class);
|
RegisterDTO.RegisterResponse registerDTO = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), RegisterDTO.RegisterResponse.class);
|
||||||
if (registerDTO.getCode() == 200){
|
if (registerDTO.getCode() == 200){
|
||||||
//todo 调整装置出厂表状态
|
equipmentFeignClient.updateStatusBynDid(nDid, AccessStatusEnum.REGISTERED.getCode());
|
||||||
|
|
||||||
|
|
||||||
PublicDto publicDto = new PublicDto();
|
PublicDto publicDto = new PublicDto();
|
||||||
publicDto.setMid(Long.toString(Instant.now().toEpochMilli()));
|
publicDto.setMid(Long.toString(Instant.now().toEpochMilli()));
|
||||||
publicDto.setNDid(nDid);
|
publicDto.setNDid(nDid);
|
||||||
@@ -94,7 +93,6 @@ public class MqttMessageHandler {
|
|||||||
if (Objects.equals(devType,"直连设备")){
|
if (Objects.equals(devType,"直连设备")){
|
||||||
List<DevModelDto> list = modelDto.getDevMod();
|
List<DevModelDto> list = modelDto.getDevMod();
|
||||||
list.forEach(item->{
|
list.forEach(item->{
|
||||||
//todo 根据条件查询库中是否有符合条件的数据
|
|
||||||
DictData dicData = dicDataFeignClient.getDicDataByCode(item.getDevType()).getData();
|
DictData dicData = dicDataFeignClient.getDicDataByCode(item.getDevType()).getData();
|
||||||
CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm();
|
CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm();
|
||||||
if (Objects.isNull(dicData)) {
|
if (Objects.isNull(dicData)) {
|
||||||
@@ -108,10 +106,11 @@ public class MqttMessageHandler {
|
|||||||
CsDevModelPageVO csDevModelPageVO = devModelFeignClient.queryDevModelOne(csDevModelQueryListParm).getData();
|
CsDevModelPageVO csDevModelPageVO = devModelFeignClient.queryDevModelOne(csDevModelQueryListParm).getData();
|
||||||
if (Objects.isNull(csDevModelPageVO)){
|
if (Objects.isNull(csDevModelPageVO)){
|
||||||
log.info("模板不存在,请先录入模板数据!");
|
log.info("模板不存在,请先录入模板数据!");
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
|
equipmentFeignClient.updateStatusBynDid(nDid, AccessStatusEnum.ACCESS.getCode());
|
||||||
//todo 录入装置和模板的关系表
|
//todo 录入装置和模板的关系表
|
||||||
System.out.println("录入装置和模板的关系表");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (Objects.equals(devType,"网关")){
|
} else if (Objects.equals(devType,"网关")){
|
||||||
@@ -119,7 +118,7 @@ public class MqttMessageHandler {
|
|||||||
System.out.println("网关设备判断");
|
System.out.println("网关设备判断");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("通过nDid未找到相关装置信息");
|
log.info("通过nDid未找到相关装置信息!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.njcn.access.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
public interface IDataArrayService {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.njcn.access.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
public interface IDataSetService {
|
||||||
|
|
||||||
|
void add();
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.access.service.serviceImpl;
|
||||||
|
|
||||||
|
import com.njcn.access.service.IDataArrayService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/4/18 11:06
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DataArrayServiceImpl implements IDataArrayService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.access.service.serviceImpl;
|
||||||
|
|
||||||
|
import com.njcn.access.service.IDataSetService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/4/18 11:06
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DataSetServiceImpl implements IDataSetService {
|
||||||
|
@Override
|
||||||
|
public void add() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import com.njcn.access.utils.JsonUtil;
|
|||||||
import com.njcn.algorithm.api.DevModelFeignClient;
|
import com.njcn.algorithm.api.DevModelFeignClient;
|
||||||
import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
|
import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
|
||||||
import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm;
|
import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm;
|
||||||
|
import com.njcn.algorithm.pojo.po.CsDevModelPO;
|
||||||
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
|
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
@@ -95,12 +96,11 @@ public class DevModelServiceImpl implements IDevModelService {
|
|||||||
log.info("文件路径为:" + filePath);
|
log.info("文件路径为:" + filePath);
|
||||||
csDevModelAddParm.setFilePath(filePath);
|
csDevModelAddParm.setFilePath(filePath);
|
||||||
//新增cs_dev_model表数据
|
//新增cs_dev_model表数据
|
||||||
devModelFeignClient.addDevModel(csDevModelAddParm);
|
CsDevModelPO csDevModelPO = devModelFeignClient.addDevModel(csDevModelAddParm).getData();
|
||||||
//新增cs_data_set
|
//新增cs_data_set
|
||||||
|
|
||||||
//新增cs_data_array
|
//新增cs_data_array
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("文件转成json出现异常");
|
log.error("文件转成json出现异常");
|
||||||
@@ -111,4 +111,17 @@ public class DevModelServiceImpl implements IDevModelService {
|
|||||||
}
|
}
|
||||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), null, CommonResponseEnum.SUCCESS.getMessage());
|
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), null, CommonResponseEnum.SUCCESS.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增cs_data_set
|
||||||
|
*/
|
||||||
|
public void insertDataSet(List<DataSetDTO> dataSet,String id){
|
||||||
|
dataSet.forEach(item->{
|
||||||
|
DataSetDTO dataSetDTO = new DataSetDTO();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user