模拟直连设备在APP注册接入
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
public interface IAccessService {
|
||||
|
||||
/**
|
||||
* 设备注册(1.判断此装置是否完成出厂设置 2.判断此装置是否能正常通讯)
|
||||
* 1.根据nDid获取装置的信息(设备型号、网关识别码)
|
||||
* 2.发送MQTT信息给装置
|
||||
* 3.装置响应则修改装置状态;3分钟未响应则生成告警信息
|
||||
* @param nDid 网关识别码
|
||||
*/
|
||||
void add(String nDid);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsAlmPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备告警数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsAlmService {
|
||||
|
||||
void saveData(List<CsAlmPO> list);
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.access.pojo.po.CsBmdPO;
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
public interface ICsBmdService {
|
||||
|
||||
void saveData(List<CsBmdPO> list);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsCtrlPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 控制表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsCtrlService {
|
||||
|
||||
void saveData(List<CsCtrlPO> list);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
public interface ICsDataArrayService {
|
||||
|
||||
void saveData(List<CsDataArrayPO> list);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
public interface ICsDataSetService {
|
||||
|
||||
CsDataSetPO addOne(CsDataSetPO csDataSetPo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/3 15:39
|
||||
*/
|
||||
|
||||
public interface ICsDevModelService {
|
||||
|
||||
/**
|
||||
* 解析模板文件->入库
|
||||
* @param devModelParam
|
||||
*/
|
||||
void addModel(DevModelParam devModelParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.param.DevAccessParam;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/4 13:43
|
||||
*/
|
||||
|
||||
public interface ICsDeviceService {
|
||||
|
||||
/**
|
||||
* 直连设备注册
|
||||
* @param nDid 设备识别码
|
||||
*/
|
||||
void devRegister(String nDid);
|
||||
|
||||
/**
|
||||
* MQTT连接成功,获取装置所用的模板信息
|
||||
* @param nDid
|
||||
*/
|
||||
Object getModel(String nDid);
|
||||
|
||||
/**
|
||||
* MQTT连接成功,获取装置所用的模板信息
|
||||
* @param devAccessParam
|
||||
*/
|
||||
void devAccess(DevAccessParam devAccessParam);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsDiPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开入表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsDiService {
|
||||
|
||||
void saveData(List<CsDiPO> list);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsDoPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开出表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsDoService {
|
||||
|
||||
void saveData(List<CsDoPO> list);
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
public interface ICsEpdPqdService {
|
||||
|
||||
void saveData(List<CsEpdPqdPO> list);
|
||||
|
||||
// CsEpdPqdPO findOne(Integer idx);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsEvtParmPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件参数表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsEvtParmService {
|
||||
|
||||
boolean saveData(List<CsEvtParmPO> list);
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsEvtPO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsEvtService {
|
||||
|
||||
Map<String,String> saveData(List<CsEvtPO> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.access.pojo.po.CsLineModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点模板表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-05
|
||||
*/
|
||||
public interface ICsLineModelService extends IService<CsLineModel> {
|
||||
|
||||
/**
|
||||
* 获取模板下监测点个数
|
||||
* @param id 模板Id
|
||||
*/
|
||||
List<CsLineModel> getMonitorNumByModelId(String id);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsNetDevPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsNetDevService {
|
||||
|
||||
boolean saveData(CsNetDevPO csNetDevPo);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsParmPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsParmService {
|
||||
|
||||
void saveData(List<CsParmPO> list);
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsPrjInfoPO;
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsPrjInfoService {
|
||||
|
||||
CsPrjInfoPO saveData(CsPrjInfoPO csPrjInfoPO);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsSetPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备定值数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsSetService {
|
||||
|
||||
void saveData(List<CsSetPO> list);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsSoftInfoService {
|
||||
|
||||
CsSoftInfoPO saveData(CsSoftInfoPO csSoftInfoPo);
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsStsPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 状态表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
public interface ICsStsService {
|
||||
|
||||
void saveData(List<CsStsPO> list);
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
public interface IDataArrayService {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
public interface IDataSetService {
|
||||
|
||||
void add();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
public interface IDevModelService {
|
||||
|
||||
/**
|
||||
* 直连装置录入模板信息
|
||||
* 1.解析模板文件,将数据录入库中
|
||||
* 2.将文件上传至文件服务器保存起来,先以装置型号-版本号-时间作为名称名称
|
||||
* @param devModelParam 模板文件参数
|
||||
*/
|
||||
void add(DevModelParam devModelParam);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.access.service.impl;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.access.pojo.dto.devModel.TemplateDto;
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import com.njcn.access.service.ICsDevModelService;
|
||||
import com.njcn.access.utils.JsonUtil;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/3 15:40
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
@Override
|
||||
public void addModel(DevModelParam devModelParam) {
|
||||
String json = null;
|
||||
try {
|
||||
json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream());
|
||||
Gson gson = new Gson();
|
||||
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
|
||||
//模板文件存入文件服务器
|
||||
//String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_");
|
||||
String filePath = "";
|
||||
System.out.println("templateDto==:" + templateDto);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.njcn.access.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.param.DevAccessParam;
|
||||
import com.njcn.access.pojo.dto.AccessDto;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
import com.njcn.access.service.ICsDeviceService;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.api.*;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelRelationAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/4 13:43
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CsDeviceServiceImpl.class);
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
|
||||
private final CsLineTopologyFeignClient csLineTopologyFeignClient;
|
||||
|
||||
private final DevModelRelationFeignClient devModelRelationFeignClient;
|
||||
|
||||
private final CsDeviceUserFeignClient csDeviceUserFeignClient;
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void devRegister(String nDid) {
|
||||
//1.判断nDid是否存在
|
||||
CsEquipmentDeliveryVO csEquipmentDeliveryVO = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
if (Objects.isNull(csEquipmentDeliveryVO.getNdid())){
|
||||
throw new BusinessException(AccessResponseEnum.NDID_NO_FIND);
|
||||
}
|
||||
//2.判断设备是否是直连设备
|
||||
SysDicTreePO sysDicTreePo = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData();
|
||||
if (Objects.isNull(sysDicTreePo)){
|
||||
throw new BusinessException(AccessResponseEnum.DEV_NOT_FIND);
|
||||
}
|
||||
String code = sysDicTreePo.getCode();
|
||||
if (!Objects.equals(code, DicDataEnum.CONNECT_DEV.getCode())){
|
||||
throw new BusinessException(AccessResponseEnum.DEV_IS_NOT_ZL);
|
||||
}
|
||||
//3.MQTT询问装置用的模板,并判断库中是否存在模板
|
||||
//存在则建立关系;不存在则告警出来
|
||||
SysDicTreePO dictData = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevModel()).getData();
|
||||
if (Objects.isNull(dictData)){
|
||||
throw new BusinessException(AccessResponseEnum.DEV_MODEL_NOT_FIND);
|
||||
}
|
||||
String devModel = dictData.getCode();
|
||||
zhiLianRegister(nDid,devModel);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
//这边使用redis缓存来判断装置是否连接MQTT或者是否出现异常
|
||||
if (Objects.isNull(redisUtil.getObjectByKey(nDid))){
|
||||
logger.error("装置注册失败,请核查!");
|
||||
throw new BusinessException(AccessResponseEnum.REGISTER_ERROR);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModel(String nDid) {
|
||||
Object model = null;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
String key = "LINE" + nDid;
|
||||
model = redisUtil.getObjectByKey(key);
|
||||
if (Objects.isNull(model)){
|
||||
throw new BusinessException(AccessResponseEnum.MODEL_MISS);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void devAccess(DevAccessParam devAccessParam) {
|
||||
try {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(devAccessParam.getNDid()).getData();
|
||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
List<AppLineTopologyDiagramPO> appLineTopologyDiagramPoList = new ArrayList<>();
|
||||
//1.录入装置台账信息
|
||||
CsLedgerParam csLedgerParam = new CsLedgerParam();
|
||||
csLedgerParam.setId(vo.getId());
|
||||
csLedgerParam.setPid(devAccessParam.getProjectId());
|
||||
csLedgerParam.setName(vo.getName());
|
||||
csLedgerParam.setLevel(2);
|
||||
csLedgerParam.setSort(0);
|
||||
csLedgerFeignClient.add(csLedgerParam);
|
||||
//2.监测点表录入关系
|
||||
devAccessParam.getList().forEach(item->{
|
||||
String id = IdUtil.fastSimpleUUID();
|
||||
CsLinePO po = new CsLinePO();
|
||||
po.setLineId(id);
|
||||
po.setName(item.getName());
|
||||
po.setPosition(item.getPosition());
|
||||
po.setVolGrade(item.getVolGrade());
|
||||
//todo 目前ct、pt数据不确定 后期补
|
||||
//po.setPtRatio(item.getPtRatio());
|
||||
//po.setCtRatio(item.getCtRatio());
|
||||
po.setStatus(1);
|
||||
csLinePoList.add(po);
|
||||
CsLedgerParam param = new CsLedgerParam();
|
||||
param.setId(id);
|
||||
param.setPid(vo.getId());
|
||||
param.setName(item.getName());
|
||||
param.setLevel(3);
|
||||
param.setSort(0);
|
||||
csLedgerFeignClient.add(param).getData();
|
||||
AppLineTopologyDiagramPO appLineTopologyDiagramPo = new AppLineTopologyDiagramPO();
|
||||
appLineTopologyDiagramPo.setId(devAccessParam.getTopologyDiagram());
|
||||
appLineTopologyDiagramPo.setLineId(id);
|
||||
appLineTopologyDiagramPo.setLat(item.getLat());
|
||||
appLineTopologyDiagramPo.setLng(item.getLng());
|
||||
appLineTopologyDiagramPo.setStatus("1");
|
||||
appLineTopologyDiagramPoList.add(appLineTopologyDiagramPo);
|
||||
});
|
||||
csLineFeignClient.addLineList(csLinePoList);
|
||||
//3.监测点拓扑图表录入关系
|
||||
csLineTopologyFeignClient.addList(appLineTopologyDiagramPoList);
|
||||
//4.新增装置-模板关系
|
||||
String modelId = redisUtil.getObjectByKey("MODEL" + devAccessParam.getNDid()).toString();
|
||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||
csDevModelRelationAddParm.setDevId(vo.getId());
|
||||
csDevModelRelationAddParm.setModelId(modelId);
|
||||
devModelRelationFeignClient.addDevModelRelation(csDevModelRelationAddParm);
|
||||
redisUtil.delete("MODEL" + devAccessParam.getNDid());
|
||||
//5.修改装置状态
|
||||
equipmentFeignClient.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.ACCESS.getCode());
|
||||
//6.设置心跳时间,超时改为掉线
|
||||
redisUtil.saveByKeyWithExpire("MQTT:" + devAccessParam.getNDid(), Instant.now().toEpochMilli(),180L);
|
||||
//7.绑定装置和人的关系
|
||||
CsDeviceUserPO po = new CsDeviceUserPO();
|
||||
po.setPrimaryUserId(RequestUtil.getUserIndex());
|
||||
po.setSubUserId(RequestUtil.getUserIndex());
|
||||
po.setDeviceId(vo.getId());
|
||||
csDeviceUserFeignClient.add(Collections.singletonList(po));
|
||||
//8.删除redis监测点模板信息
|
||||
redisUtil.delete("LINE" + devAccessParam.getNDid());
|
||||
//todo 9.记录操作日志
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void zhiLianRegister(String nDid,String devType) {
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.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(devType);
|
||||
reqAndResParam.setMsg(accessDto);
|
||||
publisher.send("/Pfm/Reg/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.access.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsLineModelMapper;
|
||||
import com.njcn.access.pojo.po.CsLineModel;
|
||||
import com.njcn.access.service.ICsLineModelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点模板表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-05
|
||||
*/
|
||||
@Service
|
||||
public class CsLineModelServiceImpl extends ServiceImpl<CsLineModelMapper, CsLineModel> implements ICsLineModelService {
|
||||
|
||||
@Override
|
||||
public List<CsLineModel> getMonitorNumByModelId(String id) {
|
||||
return this.lambdaQuery().eq(CsLineModel::getPid,id).list();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.alibaba.csp.sentinel.util.TimeUtil;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.handler.MqttMessageHandler;
|
||||
import com.njcn.access.pojo.dto.AccessDto;
|
||||
import com.njcn.access.pojo.param.ReqAndResParam;
|
||||
import com.njcn.access.service.IAccessService;
|
||||
import com.njcn.algorithm.api.CsEdDataFeignClient;
|
||||
import com.njcn.algorithm.api.EquipmentFeignClient;
|
||||
import com.njcn.algorithm.pojo.vo.CsEdDataVO;
|
||||
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/3/31 9:21
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AccessServiceImpl implements IAccessService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class);
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private final CsEdDataFeignClient csEdDataFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public void add(String nDid) {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
if (Objects.isNull(vo.getNdid())){
|
||||
logger.error("平台侧无此网关信息,请先录入!");
|
||||
throw new BusinessException(AccessResponseEnum.NDID_NO_FIND);
|
||||
} else {
|
||||
HttpResult<CsEdDataVO> result = csEdDataFeignClient.findByDevTypeId(vo.getDevModel());
|
||||
String typeId = result.getData().getType();
|
||||
if(Objects.isNull(typeId)) {
|
||||
logger.error("平台侧无此装置类型,请先录入!");
|
||||
throw new BusinessException(AccessResponseEnum.DEV_TYPE_NOT_FIND);
|
||||
} else {
|
||||
String type = dicDataFeignClient.getDicDataById(typeId).getData().getCode();
|
||||
if (Objects.equals(DicDataEnum.GATEWAY_DEV.getCode(),type)) {
|
||||
//处理网关设备
|
||||
System.out.println("网关");
|
||||
} else if (Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),type)) {
|
||||
//处理直连设备
|
||||
zhiLianRegister(nDid,vo.getDevModel());
|
||||
} else {
|
||||
logger.error("请求注册的装置类型错误(不是网关或者直连设备),请核查!");
|
||||
throw new BusinessException(AccessResponseEnum.DEV_TYPE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
//这边使用redis缓存来判断装置是否连接MQTT
|
||||
if(Objects.isNull(redisUtil.getObjectByKey(nDid))) {
|
||||
logger.error("未收到装置注册响应,请核查!");
|
||||
throw new BusinessException(AccessResponseEnum.NO_RECEIVE_FROM_DEV);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void zhiLianRegister(String nDid,String devType) {
|
||||
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(devType);
|
||||
reqAndResParam.setMsg(accessDto);
|
||||
publisher.send("/platform/register/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsAlmMapper;
|
||||
import com.njcn.access.pojo.po.CsAlmPO;
|
||||
import com.njcn.access.service.ICsAlmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备告警数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsAlmServiceImpl extends MppServiceImpl<CsAlmMapper, CsAlmPO> implements ICsAlmService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsAlmPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsBmdMapper;
|
||||
import com.njcn.access.pojo.po.CsBmdPO;
|
||||
import com.njcn.access.service.ICsBmdService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
@Service
|
||||
public class CsBmdServiceImpl extends MppServiceImpl<CsBmdMapper, CsBmdPO> implements ICsBmdService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsBmdPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsCtrlMapper;
|
||||
import com.njcn.access.pojo.po.CsCtrlPO;
|
||||
import com.njcn.access.service.ICsCtrlService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 控制表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsCtrlServiceImpl extends MppServiceImpl<CsCtrlMapper, CsCtrlPO> implements ICsCtrlService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsCtrlPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsDataArrayMapper;
|
||||
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||
import com.njcn.access.service.ICsDataArrayService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 详细数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
@Service
|
||||
public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDataArrayPO> implements ICsDataArrayService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsDataArrayPO> list) {
|
||||
this.saveBatch(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsDataSetMapper;
|
||||
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||
import com.njcn.access.service.ICsDataSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据集表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-23
|
||||
*/
|
||||
@Service
|
||||
public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSetPO> implements ICsDataSetService {
|
||||
|
||||
@Override
|
||||
public CsDataSetPO addOne(CsDataSetPO csDataSetPo) {
|
||||
this.save(csDataSetPo);
|
||||
return csDataSetPo;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsDiMapper;
|
||||
import com.njcn.access.pojo.po.CsDiPO;
|
||||
import com.njcn.access.service.ICsDiService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开入表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsDiServiceImpl extends MppServiceImpl<CsDiMapper, CsDiPO> implements ICsDiService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsDiPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsDoMapper;
|
||||
import com.njcn.access.pojo.po.CsDoPO;
|
||||
import com.njcn.access.service.ICsDoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 开出表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsDoServiceImpl extends MppServiceImpl<CsDoMapper, CsDoPO> implements ICsDoService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsDoPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.mapper.CsEpdPqdMapper;
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
import com.njcn.access.service.ICsEpdPqdService;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
@Service
|
||||
public class CsEpdPqdServiceImpl extends MppServiceImpl<CsEpdPqdMapper, CsEpdPqdPO> implements ICsEpdPqdService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsEpdPqdPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public CsEpdPqdPO findOne(Integer idx) {
|
||||
// LambdaQueryWrapper<CsEpdPqdPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper.eq(CsEpdPqdPO::getClassId, DataType.POWER_DATA).eq(CsEpdPqdPO::getIdx,idx);
|
||||
// CsEpdPqdPO csEpdPqdPo = this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
// if (Objects.isNull(csEpdPqdPo)) {
|
||||
// throw new BusinessException(AccessResponseEnum.DICT_MISSING);
|
||||
// }
|
||||
// return csEpdPqdPo;
|
||||
// }
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsEvtParmMapper;
|
||||
import com.njcn.access.pojo.po.CsEvtParmPO;
|
||||
import com.njcn.access.service.ICsEvtParmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件参数表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsEvtParmServiceImpl extends MppServiceImpl<CsEvtParmMapper, CsEvtParmPO> implements ICsEvtParmService {
|
||||
|
||||
@Override
|
||||
public boolean saveData(List<CsEvtParmPO> list) {
|
||||
return this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsEvtMapper;
|
||||
import com.njcn.access.pojo.po.CsEvtPO;
|
||||
import com.njcn.access.service.ICsEvtService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsEvtServiceImpl extends MppServiceImpl<CsEvtMapper, CsEvtPO> implements ICsEvtService {
|
||||
|
||||
@Override
|
||||
public Map<String,String> saveData(List<CsEvtPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
List<String> nameList = list.stream().map(CsEvtPO::getName).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<CsEvtPO> lambdaQueryWrapper = new LambdaQueryWrapper<CsEvtPO>();
|
||||
lambdaQueryWrapper.in(CsEvtPO::getName,nameList);
|
||||
List<CsEvtPO> list1 = this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
Map<String,String> map = new HashMap<>();
|
||||
list1.forEach(item->{
|
||||
map.put(item.getName(),item.getId());
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.mapper.CsNetDevMapper;
|
||||
import com.njcn.access.pojo.po.CsNetDevPO;
|
||||
import com.njcn.access.service.ICsNetDevService;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsNetDevServiceImpl extends ServiceImpl<CsNetDevMapper, CsNetDevPO> implements ICsNetDevService {
|
||||
|
||||
@Override
|
||||
public boolean saveData(CsNetDevPO csNetDevPo) {
|
||||
LambdaQueryWrapper<CsNetDevPO> lambdaQueryWrapper = new LambdaQueryWrapper<CsNetDevPO>();
|
||||
lambdaQueryWrapper.eq(CsNetDevPO::getDevType,csNetDevPo.getDevType())
|
||||
.eq(CsNetDevPO::getTime,csNetDevPo.getTime())
|
||||
.eq(CsNetDevPO::getVersion,csNetDevPo.getVersion())
|
||||
.eq(CsNetDevPO::getStatus,1);
|
||||
CsNetDevPO po = this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
if (!Objects.isNull(po)){
|
||||
throw new BusinessException(AccessResponseEnum.MODEL_REPEAT);
|
||||
}
|
||||
return this.save(csNetDevPo);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsParmMapper;
|
||||
import com.njcn.access.pojo.po.CsParmPO;
|
||||
import com.njcn.access.service.ICsParmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsParmServiceImpl extends MppServiceImpl<CsParmMapper, CsParmPO> implements ICsParmService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsParmPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsPrjInfoMapper;
|
||||
import com.njcn.access.pojo.po.CsPrjInfoPO;
|
||||
import com.njcn.access.service.ICsPrjInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsPrjInfoServiceImpl extends ServiceImpl<CsPrjInfoMapper, CsPrjInfoPO> implements ICsPrjInfoService {
|
||||
|
||||
@Override
|
||||
public CsPrjInfoPO saveData(CsPrjInfoPO csPrjInfoPo) {
|
||||
this.save(csPrjInfoPo);
|
||||
return csPrjInfoPo;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsSetMapper;
|
||||
import com.njcn.access.pojo.po.CsSetPO;
|
||||
import com.njcn.access.service.ICsSetService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备定值数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsSetServiceImpl extends MppServiceImpl<CsSetMapper, CsSetPO> implements ICsSetService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsSetPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsSoftInfoMapper;
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
import com.njcn.access.service.ICsSoftInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsSoftInfoServiceImpl extends ServiceImpl<CsSoftInfoMapper, CsSoftInfoPO> implements ICsSoftInfoService {
|
||||
|
||||
@Override
|
||||
public CsSoftInfoPO saveData(CsSoftInfoPO entity) {
|
||||
this.save(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.access.mapper.CsStsMapper;
|
||||
import com.njcn.access.pojo.po.CsStsPO;
|
||||
import com.njcn.access.service.ICsStsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 状态表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-19
|
||||
*/
|
||||
@Service
|
||||
public class CsStsServiceImpl extends MppServiceImpl<CsStsMapper, CsStsPO> implements ICsStsService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsStsPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
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 {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,638 +0,0 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.pojo.dto.data.*;
|
||||
import com.njcn.access.pojo.dto.devModel.*;
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import com.njcn.access.pojo.po.*;
|
||||
import com.njcn.access.service.*;
|
||||
import com.njcn.access.utils.JsonUtil;
|
||||
import com.njcn.algorithm.api.CsDictFeignClient;
|
||||
import com.njcn.algorithm.api.DevModelFeignClient;
|
||||
import com.njcn.algorithm.pojo.dto.CsDictDTO;
|
||||
import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
|
||||
import com.njcn.algorithm.pojo.po.CsDevModelPO;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLOutput;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/10 10:37
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DevModelServiceImpl implements IDevModelService {
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
private final DevModelFeignClient devModelFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final CsDictFeignClient csDictFeignClient;
|
||||
|
||||
private final ICsNetDevService csNetDevService;
|
||||
|
||||
private final ICsSoftInfoService csSoftInfoService;
|
||||
|
||||
private final ICsPrjInfoService csPrjInfoService;
|
||||
|
||||
private final ICsEpdPqdService csEpdPqdService;
|
||||
|
||||
private final ICsBmdService csBmdService;
|
||||
|
||||
private final ICsEvtService csEvtService;
|
||||
|
||||
private final ICsEvtParmService csEvtParmService;
|
||||
|
||||
private final ICsAlmService csAlmService;
|
||||
|
||||
private final ICsStsService csStsService;
|
||||
|
||||
private final ICsDiService csDiService;
|
||||
|
||||
private final ICsDoService csDoService;
|
||||
|
||||
private final ICsParmService csParmService;
|
||||
|
||||
private final ICsCtrlService csCtrlService;
|
||||
|
||||
private final ICsSetService csSetService;
|
||||
|
||||
private final ICsDataSetService csDataSetService;
|
||||
|
||||
private final ICsDataArrayService csDataArrayService;
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(DevModelParam devModelParam) {
|
||||
String json = null;
|
||||
try {
|
||||
json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream());
|
||||
Gson gson = new Gson();
|
||||
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
|
||||
//新增网关信息描述表
|
||||
// insertNetDevMod(templateDto.getNetDevModDto());
|
||||
//模板文件存入文件服务器
|
||||
//String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_");
|
||||
String filePath = "";
|
||||
//新增设备数据模板
|
||||
insertDevMod(templateDto.getDevModDto(),filePath);
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("文件转成json出现异常");
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增直连设备、网关模板信息
|
||||
*/
|
||||
public void insertNetDevMod(NetDevModDto netDevModDto) {
|
||||
SoftInfoDto softInfoDto = netDevModDto.getDataList().get(0).getSoftInfoDto();
|
||||
PrjInfoDto prjInfoDto = netDevModDto.getDataList().get(0).getPrjInfoDto();
|
||||
CsNetDevPO csNetDevPo = new CsNetDevPO();
|
||||
BeanUtils.copyProperties(netDevModDto,csNetDevPo);
|
||||
csNetDevPo.setTime(LocalDate.parse(netDevModDto.getTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
csNetDevPo.setStatus(1);
|
||||
if (!Objects.isNull(softInfoDto)){
|
||||
CsSoftInfoPO csSoftInfoPo = new CsSoftInfoPO();
|
||||
BeanUtils.copyProperties(softInfoDto,csSoftInfoPo);
|
||||
csSoftInfoPo.setAppDate(LocalDateTime.parse(softInfoDto.getAppDate(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
String softInfoId = csSoftInfoService.saveData(csSoftInfoPo).getId();
|
||||
csNetDevPo.setSoftInfoId(softInfoId);
|
||||
}
|
||||
if (!Objects.isNull(prjInfoDto)){
|
||||
CsPrjInfoPO csPrjInfoPo = new CsPrjInfoPO();
|
||||
BeanUtils.copyProperties(prjInfoDto,csPrjInfoPo);
|
||||
String prjInfoId = csPrjInfoService.saveData(csPrjInfoPo).getId();
|
||||
csNetDevPo.setPrjInfoId(prjInfoId);
|
||||
}
|
||||
csNetDevService.saveData(csNetDevPo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据模板(装置类型分类)
|
||||
*/
|
||||
public void insertDevMod(DevModDto devModDto,String filePath) {
|
||||
// String devType = devModDto.getDevType();
|
||||
// String version = devModDto.getVersion();
|
||||
// String time = devModDto.getTime();
|
||||
// CsDevModelPO csDevModelPo = devModelFeignClient.findModel(devType,version,time).getData();
|
||||
// if (!Objects.isNull(csDevModelPo)){
|
||||
// throw new BusinessException(AccessResponseEnum.MODEL_REPEAT);
|
||||
// }
|
||||
// /**录入基础模板数据*/
|
||||
// CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm();
|
||||
// csDevModelAddParm.setDevType(devType);
|
||||
// csDevModelAddParm.setName(devType);
|
||||
// csDevModelAddParm.setVersionNo(version);
|
||||
// csDevModelAddParm.setVersionDate(LocalDateTime.parse(time, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// csDevModelAddParm.setFilePath(filePath);
|
||||
// SoftInfoDto softInfoDto = devModDto.getDataList().get(0).getSoftInfoDto();
|
||||
// //录入系统软件表
|
||||
// if (!Objects.isNull(softInfoDto)){
|
||||
// CsSoftInfoPO csSoftInfoPo = new CsSoftInfoPO();
|
||||
// BeanUtils.copyProperties(softInfoDto,csSoftInfoPo);
|
||||
// csSoftInfoPo.setAppDate(LocalDateTime.parse(softInfoDto.getAppDate(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// String softInfoId = csSoftInfoService.saveData(csSoftInfoPo).getId();
|
||||
// csDevModelAddParm.setSoftInfoId(softInfoId);
|
||||
// }
|
||||
// devModelFeignClient.addDevModel(csDevModelAddParm);
|
||||
// /**录入数据模型列表*/
|
||||
//录入EPD
|
||||
List<EpdPqdDto> epdDto = devModDto.getDataList().get(0).getEpdDto();
|
||||
if (!CollectionUtils.isEmpty(epdDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.EPD.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.EPD_DICT_MISSING);
|
||||
}
|
||||
insertEpdPqd(epdDto,dictData);
|
||||
}
|
||||
//录入PQD
|
||||
List<EpdPqdDto> pqdDto = devModDto.getDataList().get(0).getPqdDto();
|
||||
if (!CollectionUtils.isEmpty(pqdDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.PQD_DICT_MISSING);
|
||||
}
|
||||
insertEpdPqd(pqdDto,dictData);
|
||||
}
|
||||
//录入Bmd
|
||||
List<BmdDto> bmdDto = devModDto.getDataList().get(0).getBmdDto();
|
||||
if (!CollectionUtils.isEmpty(bmdDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.BMD.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.BMD_DICT_MISSING);
|
||||
}
|
||||
insertBmd(bmdDto,dictData);
|
||||
}
|
||||
//录入Evt
|
||||
List<EvtDto> evtDto = devModDto.getDataList().get(0).getEvtDto();
|
||||
if (!CollectionUtils.isEmpty(evtDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.EVT.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.Evt_DICT_MISSING);
|
||||
}
|
||||
insertEvt(evtDto,dictData);
|
||||
}
|
||||
//录入Alm
|
||||
List<AlmDto> almDto = devModDto.getDataList().get(0).getAlmDto();
|
||||
if (!CollectionUtils.isEmpty(almDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.ALM.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.ALM_DICT_MISSING);
|
||||
}
|
||||
insertAlm(almDto,dictData);
|
||||
}
|
||||
//录入Sts
|
||||
List<StsDto> stsDto = devModDto.getDataList().get(0).getStsDto();
|
||||
if (!CollectionUtils.isEmpty(stsDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.STS.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.STS_DICT_MISSING);
|
||||
}
|
||||
insertSts(stsDto,dictData);
|
||||
}
|
||||
//录入Di
|
||||
List<DiDto> diDto = devModDto.getDataList().get(0).getDiDto();
|
||||
if (!CollectionUtils.isEmpty(diDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.DI.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.DI_DICT_MISSING);
|
||||
}
|
||||
insertDi(diDto,dictData);
|
||||
}
|
||||
//录入Do
|
||||
List<DoDto> doDto = devModDto.getDataList().get(0).getDoDto();
|
||||
if (!CollectionUtils.isEmpty(doDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.DO.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.DO_DICT_MISSING);
|
||||
}
|
||||
insertDo(doDto,dictData);
|
||||
}
|
||||
//录入Parm
|
||||
List<ParmDto> parmDto = devModDto.getDataList().get(0).getParmDto();
|
||||
if (!CollectionUtils.isEmpty(parmDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.PARM.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.PARM_DICT_MISSING);
|
||||
}
|
||||
insertParm(parmDto,dictData);
|
||||
}
|
||||
//录入Set
|
||||
List<SetDto> setDto = devModDto.getDataList().get(0).getSetDto();
|
||||
if (!CollectionUtils.isEmpty(setDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SET.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.SET_DICT_MISSING);
|
||||
}
|
||||
insertSet(setDto,dictData);
|
||||
}
|
||||
//录入InSet
|
||||
List<InSetDto> inSetDto = devModDto.getDataList().get(0).getInSetDto();
|
||||
if (!CollectionUtils.isEmpty(inSetDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.INSET.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.INSET_DICT_MISSING);
|
||||
}
|
||||
insertInSet(inSetDto,dictData);
|
||||
}
|
||||
//录入Ctrl
|
||||
List<CtrlDto> ctrlDto = devModDto.getDataList().get(0).getCtrlDto();
|
||||
if (!CollectionUtils.isEmpty(ctrlDto)){
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.CTRL.getCode()).getData();
|
||||
if (StringUtils.isBlank(dictData.getId())){
|
||||
throw new BusinessException(AccessResponseEnum.CTRL_DICT_MISSING);
|
||||
}
|
||||
insertCtrl(ctrlDto,dictData);
|
||||
}
|
||||
|
||||
|
||||
// /**录入数据集*/
|
||||
// List<DataSetDto> dataSetDtoList = devModDto.getDataSetDtoList();
|
||||
// if (!CollectionUtils.isEmpty(dataSetDtoList)){
|
||||
// insertDataSet(dataSetDtoList,"60b55915717c0cfd8935e04633657034");
|
||||
// }
|
||||
// /**录入逻辑子设备序列*/
|
||||
// List<ClDevDto> clDevDtoList = devModDto.getClDevDtoList();
|
||||
}
|
||||
|
||||
/**
|
||||
* EPD、PQD字典录入
|
||||
*/
|
||||
public void insertEpdPqd(List<EpdPqdDto> epdPqdDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = epdPqdDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
if (Objects.isNull(item.getPhase())){
|
||||
param.setPhase("M");
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(item.getStatMethod())){
|
||||
param.setStatMethod(item.getStatMethod().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bmd字典录入
|
||||
*/
|
||||
public void insertBmd(List<BmdDto> bmdDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = bmdDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
if (Objects.isNull(item.getPhase())){
|
||||
param.setPhase("M");
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(item.getStatMethod())){
|
||||
param.setStatMethod(item.getStatMethod().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evt字典录入
|
||||
*/
|
||||
public void insertEvt(List<EvtDto> evtDto,DictData dictData) {
|
||||
Map<String,List<EvtParamDto>> map = new HashMap<>();
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = evtDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
map.put(item.getName(),item.getParam());
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
List<CsEvtParmPO> evtParmList = new ArrayList<>();
|
||||
Map<String,String> map2 = epdFeignClient.addEvt(paramList).getData();
|
||||
paramList.forEach(item->{
|
||||
List<EvtParamDto> list = map.get(item.getName());
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(item2->{
|
||||
CsEvtParmPO csEvtParmPo = new CsEvtParmPO();
|
||||
BeanUtils.copyProperties(item2,csEvtParmPo);
|
||||
csEvtParmPo.setPid(map2.get(item.getName()));
|
||||
evtParmList.add(csEvtParmPo);
|
||||
});
|
||||
}
|
||||
});
|
||||
csEvtParmService.saveData(evtParmList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alm字典录入
|
||||
*/
|
||||
public void insertAlm(List<AlmDto> almDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = almDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sts字典录入
|
||||
*/
|
||||
public void insertSts(List<StsDto> stsDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = stsDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Di字典录入
|
||||
*/
|
||||
public void insertDi(List<DiDto> diDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = diDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do字典录入
|
||||
*/
|
||||
public void insertDo(List<DoDto> doDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = doDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parm字典录入
|
||||
*/
|
||||
public void insertParm(List<ParmDto> parmDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = parmDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
if (!CollectionUtils.isEmpty(item.getSetValue())){
|
||||
param.setSetValue(item.getSetValue().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set字典录入
|
||||
*/
|
||||
public void insertSet(List<SetDto> setDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = setDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* InSet字典录入
|
||||
*/
|
||||
public void insertInSet(List<InSetDto> inSetDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = inSetDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ctrl字典录入
|
||||
*/
|
||||
public void insertCtrl(List<CtrlDto> ctrlDto,DictData dictData) {
|
||||
List<EleEpdPqd> dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
List<EleEpdPqdParam> paramList = ctrlDto.stream().map(item->{
|
||||
EleEpdPqdParam param = new EleEpdPqdParam();
|
||||
BeanUtils.copyProperties(item,param);
|
||||
if (!CollectionUtils.isEmpty(item.getCtlValue())){
|
||||
param.setSetValue(item.getCtlValue().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
param.setPhase("M");
|
||||
param.setShowName(item.getName());
|
||||
param.setDataType(dictData.getId());
|
||||
param.setClassId(dictData.getValue());
|
||||
param.setSort(0);
|
||||
param.setSystemType("");
|
||||
return param;
|
||||
}).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(dictList)){
|
||||
//两个集合取差集
|
||||
paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(paramList)){
|
||||
epdFeignClient.addByModel(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DataSet录入
|
||||
*/
|
||||
public void insertDataSet(List<DataSetDto> dataSetDtoList,String pid) {
|
||||
dataSetDtoList.forEach(item->{
|
||||
CsDataSetPO csDataSetPo = new CsDataSetPO();
|
||||
BeanUtils.copyProperties(item,csDataSetPo);
|
||||
CsDictDTO csDictDTO = csDictFeignClient.getOwnAndFatherData(item.getName()).getData();
|
||||
csDataSetPo.setAnotherName(csDictDTO.getName());
|
||||
if (csDictDTO.getName().contains("Rt")){
|
||||
csDataSetPo.setDataType("实时数据");
|
||||
} else if (csDictDTO.getName().contains("Stat")){
|
||||
csDataSetPo.setDataType("统计数据");
|
||||
}
|
||||
csDataSetPo.setPid(pid);
|
||||
csDataSetService.addOne(csDataSetPo);
|
||||
List<DataArrayDto> dataArrayDto = item.getDataArrayDtoList();
|
||||
if (!CollectionUtils.isEmpty(dataArrayDto)){
|
||||
insertDataArray(dataArrayDto,csDataSetPo.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* DataArray录入
|
||||
*/
|
||||
public void insertDataArray(List<DataArrayDto> dataArrayDto,String pid) {
|
||||
List<CsDataArrayPO> list = new ArrayList<>();
|
||||
dataArrayDto.forEach(item->{
|
||||
int sort = 0;
|
||||
CsDataArrayPO csDataArrayPo = new CsDataArrayPO();
|
||||
csDataArrayPo.setPid(pid);
|
||||
list.add(csDataArrayPo);
|
||||
});
|
||||
csDataArrayService.saveData(list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user