代码提交

This commit is contained in:
2023-05-12 15:42:33 +08:00
parent 4c29d3869f
commit 78b4513880
72 changed files with 1535 additions and 792 deletions

View File

@@ -0,0 +1,16 @@
package com.njcn.access.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.access.pojo.po.CsBmdPO;
/**
* <p>
* 服务类
* </p>
*
* @author xuyang
* @since 2023-05-11
*/
public interface ICsBmdService extends IService<CsBmdPO> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.access.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.access.pojo.po.CsEpdPqdPO;
/**
* <p>
* 服务类
* </p>
*
* @author xuyang
* @since 2023-05-11
*/
public interface ICsEpdPqdService extends IService<CsEpdPqdPO> {
}

View File

@@ -0,0 +1,22 @@
package com.njcn.access.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.access.pojo.po.CsTopicPO;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xuyang
* @since 2023-05-12
*/
public interface ICsTopicService {
void askDevTopic(String nDid);
boolean addList(List<CsTopicPO> list);
}

View File

@@ -1,19 +1,19 @@
package com.njcn.access.service.serviceImpl;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.access.enums.AccessEnum;
import com.njcn.access.enums.TypeEnum;
import com.njcn.access.pojo.dto.AccessDto;
import com.njcn.access.pojo.dto.PublicDto;
import com.njcn.access.pojo.param.ReqAndResParam;
import com.njcn.access.service.IAccessService;
import com.njcn.algorithm.api.EquipmentFeignClient;
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.PubUtils;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.Objects;
/**
@@ -40,15 +40,16 @@ public class AccessServiceImpl implements IAccessService {
logger.error("平台侧无此网关信息,请先录入!");
return;
}
PublicDto publicDto = new PublicDto();
publicDto.setMid(Long.toString(Instant.now().toEpochMilli()));
publicDto.setNDid(nDid);
publicDto.setTimestamp(Instant.now().toEpochMilli());
publicDto.setType("CMD_DEV_REGISTER");
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
reqAndResParam.setMid(1);
reqAndResParam.setDid("0");
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
reqAndResParam.setType(TypeEnum.TYPE_2.getCode());
reqAndResParam.setExpire(-1);
AccessDto accessDto = new AccessDto();
accessDto.setNDid(nDid);
accessDto.setDevType(vo.getDevModel());
publicDto.setParam(accessDto);
publisher.send("/platform/register/"+nDid,new Gson().toJson(publicDto),1,false);
reqAndResParam.setMsg(accessDto);
publisher.send("/platform/register/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
}
}

View File

@@ -0,0 +1,20 @@
package com.njcn.access.service.serviceImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.access.mapper.CsBmdMapper;
import com.njcn.access.pojo.po.CsBmdPO;
import com.njcn.access.service.ICsBmdService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xuyang
* @since 2023-05-11
*/
@Service
public class CsBmdServiceImpl extends ServiceImpl<CsBmdMapper, CsBmdPO> implements ICsBmdService {
}

View File

@@ -0,0 +1,20 @@
package com.njcn.access.service.serviceImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.access.mapper.CsEpdPqdMapper;
import com.njcn.access.pojo.po.CsEpdPqdPO;
import com.njcn.access.service.ICsEpdPqdService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author xuyang
* @since 2023-05-11
*/
@Service
public class CsEpdPqdServiceImpl extends ServiceImpl<CsEpdPqdMapper, CsEpdPqdPO> implements ICsEpdPqdService {
}

View File

@@ -0,0 +1,61 @@
package com.njcn.access.service.serviceImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.access.enums.AccessEnum;
import com.njcn.access.enums.TypeEnum;
import com.njcn.access.mapper.CsTopicMapper;
import com.njcn.access.pojo.param.ReqAndResParam;
import com.njcn.access.pojo.po.CsTopicPO;
import com.njcn.access.service.ICsTopicService;
import com.njcn.algorithm.api.EquipmentFeignClient;
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.common.utils.PubUtils;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
* <p>
* 服务实现类
* </p>
*
* @author xuyang
* @since 2023-05-12
*/
@Service
@AllArgsConstructor
public class CsTopicServiceImpl extends ServiceImpl<CsTopicMapper, CsTopicPO> implements ICsTopicService {
private static final Logger logger = LoggerFactory.getLogger(CsTopicServiceImpl.class);
private final MqttPublisher publisher;
private final EquipmentFeignClient equipmentFeignClient;
@Override
public void askDevTopic(String nDid) {
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
if (Objects.isNull(vo)){
logger.error("平台侧无此网关信息,请先录入!");
return;
}
ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req();
reqAndResParam.setMid(1);
reqAndResParam.setDid("0");
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
reqAndResParam.setType(TypeEnum.TYPE_1.getCode());
reqAndResParam.setExpire(-1);
reqAndResParam.setMsg(null);
publisher.send("/Pfm/Topic/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
}
@Override
public boolean addList(List<CsTopicPO> list) {
return this.saveOrUpdateBatch(list,100);
}
}

View File

@@ -53,75 +53,77 @@ public class DevModelServiceImpl implements IDevModelService {
String json = null;
try {
json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream());
Gson gson = new Gson();
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
ParamDto pojo = templateDto.getParam();
//网关模板
NetDevModDto po1 = pojo.getDataArray().get(0).getTemplate().getNetDevModDto();
//装置信息模板
DevCfgDetailDto po2 = pojo.getDataArray().get(0).getTemplate().getDevCfgDetailDto();
//装置数据模板
List<DevModDetailDto> po3 = pojo.getDataArray().get(0).getTemplate().getDevModDetailDto();
String name = po3.get(0).getName();
String version = po3.get(0).getVersion();
String time = po3.get(0).getTime();
String devType = po3.get(0).getDevType();
String devTypeId = "";
DictData dicData = dicDataFeignClient.getDicDataByCode(devType).getData();
if (Objects.isNull(dicData)) {
log.info("新增模板失败,获取装置类型字典数据为空,请先录入装置类型!");
return HttpResultUtil.assembleResult(CommonResponseEnum.NO_DATA.getCode(), null, "获取装置类型字典数据为空!");
} else {
devTypeId = dicData.getId();
}
CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm();
csDevModelQueryListParm.setDevType(devTypeId);
csDevModelQueryListParm.setVersionNo(version);
csDevModelQueryListParm.setVersionDate(time);
csDevModelQueryListParm.setName(name);
CsDevModelPageVO vo = devModelFeignClient.queryDevModelOne(csDevModelQueryListParm).getData();
if (!Objects.isNull(vo)){
log.info("新增模板失败,新增的模板在库中存在!");
return HttpResultUtil.assembleResult(AccessResponseEnum.MODEL_REPEAT.getCode(), null, AccessResponseEnum.MODEL_REPEAT.getMessage());
} else {
CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm();
csDevModelAddParm.setName(name);
csDevModelAddParm.setDevType(devTypeId);
csDevModelAddParm.setVersionNo(version);
csDevModelAddParm.setVersionDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time));
String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_");
log.info("文件路径为:" + filePath);
csDevModelAddParm.setFilePath(filePath);
//新增cs_dev_model表数据
CsDevModelPO csDevModelPO = devModelFeignClient.addDevModel(csDevModelAddParm).getData();
//新增cs_data_set
//新增cs_data_array
}
// ParamDto pojo = templateDto.getParam();
// //网关模板
// NetDevModDto po1 = pojo.getDataArray().get(0).getTemplate().getNetDevModDto();
// //装置信息模板
// DevCfgDetailDto po2 = pojo.getDataArray().get(0).getTemplate().getDevCfgDetailDto();
// //装置数据模板
// List<DevModDetailDto> po3 = pojo.getDataArray().get(0).getTemplate().getDevModDetailDto();
//
// String name = po3.get(0).getName();
// String version = po3.get(0).getVersion();
// String time = po3.get(0).getTime();
// String devType = po3.get(0).getDevType();
// String devTypeId = "";
//
// DictData dicData = dicDataFeignClient.getDicDataByCode(devType).getData();
// if (Objects.isNull(dicData)) {
// log.info("新增模板失败,获取装置类型字典数据为空,请先录入装置类型!");
// return HttpResultUtil.assembleResult(CommonResponseEnum.NO_DATA.getCode(), null, "获取装置类型字典数据为空!");
// } else {
// devTypeId = dicData.getId();
// }
// CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm();
// csDevModelQueryListParm.setDevType(devTypeId);
// csDevModelQueryListParm.setVersionNo(version);
// csDevModelQueryListParm.setVersionDate(time);
// csDevModelQueryListParm.setName(name);
// CsDevModelPageVO vo = devModelFeignClient.queryDevModelOne(csDevModelQueryListParm).getData();
// if (!Objects.isNull(vo)){
// log.info("新增模板失败,新增的模板在库中存在!");
// return HttpResultUtil.assembleResult(AccessResponseEnum.MODEL_REPEAT.getCode(), null, AccessResponseEnum.MODEL_REPEAT.getMessage());
// } else {
// CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm();
// csDevModelAddParm.setName(name);
// csDevModelAddParm.setDevType(devTypeId);
// csDevModelAddParm.setVersionNo(version);
// csDevModelAddParm.setVersionDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time));
// String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_");
// log.info("文件路径为:" + filePath);
// csDevModelAddParm.setFilePath(filePath);
// //新增cs_dev_model表数据
// CsDevModelPO csDevModelPO = devModelFeignClient.addDevModel(csDevModelAddParm).getData();
// //新增cs_data_set
//
// //新增cs_data_array
//
// }
} catch (IOException e) {
log.error("文件转成json出现异常");
e.getMessage();
} catch (ParseException e) {
log.error("时间转换出现异常");
e.getMessage();
}
// catch (ParseException e) {
// log.error("时间转换出现异常");
// e.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();
});
}
// public void insertDataSet(List<DataSetDTO> dataSet,String id){
// dataSet.forEach(item->{
// DataSetDTO dataSetDTO = new DataSetDTO();
//
//
//
// });
// }
}