1.完善模板解析功能
2.调整直连设备接入流程
This commit is contained in:
@@ -20,7 +20,7 @@ public class ClDevDto implements Serializable {
|
|||||||
|
|
||||||
@SerializedName("Cldid")
|
@SerializedName("Cldid")
|
||||||
@NotEmpty(message = "逻辑子设备ID,不可为空")
|
@NotEmpty(message = "逻辑子设备ID,不可为空")
|
||||||
private String clDid;
|
private Integer clDid;
|
||||||
|
|
||||||
@SerializedName("DevType")
|
@SerializedName("DevType")
|
||||||
@ApiModelProperty(value = "逻辑子设备型号")
|
@ApiModelProperty(value = "逻辑子设备型号")
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||||
import com.njcn.db.bo.BaseEntity;
|
import com.njcn.db.bo.BaseEntity;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@@ -16,8 +18,7 @@ import lombok.Setter;
|
|||||||
* @author xuyang
|
* @author xuyang
|
||||||
* @since 2023-05-23
|
* @since 2023-05-23
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@TableName("cs_data_array")
|
@TableName("cs_data_array")
|
||||||
public class CsDataArrayPO extends BaseEntity {
|
public class CsDataArrayPO extends BaseEntity {
|
||||||
|
|
||||||
|
|||||||
@@ -67,5 +67,20 @@ public class CsDataSetPO extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Integer storeFlag;
|
private Integer storeFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逻辑子设备id(从模板获取,主设备此字段没有值)
|
||||||
|
*/
|
||||||
|
private Integer clDev;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据集类型(0:主设备 1:模块 2:监测设备)
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据模型
|
||||||
|
*/
|
||||||
|
private String dataList;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.njcn.access.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||||
|
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||||
|
import com.njcn.access.service.ICsDataArrayService;
|
||||||
|
import com.njcn.access.service.ICsDataSetService;
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 数据集表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-08-01
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/csDataArray")
|
||||||
|
@Api(tags = "终端详细数据集")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CsDataArrayController extends BaseController {
|
||||||
|
|
||||||
|
private final ICsDataArrayService csDataArrayService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation("新增详细数据集")
|
||||||
|
@ApiImplicitParam(name = "csDataArrayPo", value = "数据集", required = true)
|
||||||
|
public HttpResult<String> add(@RequestBody CsDataArrayPO csDataArrayPo){
|
||||||
|
String methodDescribe = getMethodDescribe("add");
|
||||||
|
csDataArrayService.add(csDataArrayPo);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/addList")
|
||||||
|
@ApiOperation("批量新增详细数据集")
|
||||||
|
@ApiImplicitParam(name = "list", value = "数据集集合", required = true)
|
||||||
|
public HttpResult<String> addList(@RequestBody List<CsDataArrayPO> list){
|
||||||
|
String methodDescribe = getMethodDescribe("addList");
|
||||||
|
csDataArrayService.addList(list);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.njcn.access.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||||
|
import com.njcn.access.service.ICsDataSetService;
|
||||||
|
import com.njcn.access.service.ICsDevModelService;
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 数据集表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-08-01
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/csDataSet")
|
||||||
|
@Api(tags = "终端数据集")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CsDataSetController extends BaseController {
|
||||||
|
|
||||||
|
private final ICsDataSetService csDataSetService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation("新增数据集")
|
||||||
|
@ApiImplicitParam(name = "csDataSetPo", value = "数据集", required = true)
|
||||||
|
public HttpResult<String> add(@RequestBody CsDataSetPO csDataSetPo){
|
||||||
|
String methodDescribe = getMethodDescribe("add");
|
||||||
|
csDataSetService.add(csDataSetPo);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/addList")
|
||||||
|
@ApiOperation("批量新增数据集")
|
||||||
|
@ApiImplicitParam(name = "list", value = "数据集集合", required = true)
|
||||||
|
public HttpResult<String> addList(@RequestBody List<CsDataSetPO> list){
|
||||||
|
String methodDescribe = getMethodDescribe("addList");
|
||||||
|
csDataSetService.addList(list);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,9 @@ public class CsDevModelController extends BaseController {
|
|||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public HttpResult<String> addModel(@RequestPart("file") @Validated MultipartFile file){
|
public HttpResult<String> addModel(@RequestPart("file") @Validated MultipartFile file){
|
||||||
String methodDescribe = getMethodDescribe("addModel");
|
String methodDescribe = getMethodDescribe("addModel");
|
||||||
|
//1.录入通用字典
|
||||||
csDevModelService.addDict(file);
|
csDevModelService.addDict(file);
|
||||||
|
//2.解析模板数据
|
||||||
csDevModelService.addModel(file);
|
csDevModelService.addModel(file);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
package com.njcn.access.controller;
|
package com.njcn.access.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.access.pojo.po.CsLineModel;
|
||||||
|
import com.njcn.access.service.ICsLineModelService;
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -24,7 +36,27 @@ import com.njcn.web.controller.BaseController;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class CsLineModelController extends BaseController {
|
public class CsLineModelController extends BaseController {
|
||||||
|
|
||||||
|
private final ICsLineModelService csLineModelService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation("新增模板监测点")
|
||||||
|
@ApiImplicitParam(name = "csLineModel", value = "监测点信息", required = true)
|
||||||
|
public HttpResult<String> add(@RequestBody CsLineModel csLineModel){
|
||||||
|
String methodDescribe = getMethodDescribe("add");
|
||||||
|
csLineModelService.add(csLineModel);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/addList")
|
||||||
|
@ApiOperation("批量新增模板监测点")
|
||||||
|
@ApiImplicitParam(name = "list", value = "监测点集合", required = true)
|
||||||
|
public HttpResult<String> addList(@RequestBody List<CsLineModel> list){
|
||||||
|
String methodDescribe = getMethodDescribe("addList");
|
||||||
|
csLineModelService.addList(list);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class MqttMessageHandler {
|
|||||||
* @param message
|
* @param message
|
||||||
* @param payload
|
* @param payload
|
||||||
*/
|
*/
|
||||||
@MqttSubscribe(value = "/Dev/Reg/{edgeId}",qos = 1)
|
@MqttSubscribe(value = "/Dev/DevReg/{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);
|
log.info("收到注册应答响应--->" + nDid);
|
||||||
@@ -143,21 +143,20 @@ public class MqttMessageHandler {
|
|||||||
throw new BusinessException(AccessResponseEnum.MODEL_VERSION_ERROR);
|
throw new BusinessException(AccessResponseEnum.MODEL_VERSION_ERROR);
|
||||||
}
|
}
|
||||||
//校验前置传递的装置模板库中是否存在
|
//校验前置传递的装置模板库中是否存在
|
||||||
|
List<String> modelId = new ArrayList<>();
|
||||||
list.forEach(item->{
|
list.forEach(item->{
|
||||||
CsDevModelPO po = devModelFeignClient.findModel(item.getDevType(),item.getVersionNo(),item.getVersionDate()).getData();
|
CsDevModelPO po = devModelFeignClient.findModel(item.getDevType(),item.getVersionNo(),item.getVersionDate()).getData();
|
||||||
if (Objects.isNull(po)){
|
if (Objects.isNull(po)){
|
||||||
log.error(AccessResponseEnum.MODEL_NO_FIND.getMessage());
|
log.error(AccessResponseEnum.MODEL_NO_FIND.getMessage());
|
||||||
throw new BusinessException(AccessResponseEnum.MODEL_NO_FIND);
|
throw new BusinessException(AccessResponseEnum.MODEL_NO_FIND);
|
||||||
}
|
}
|
||||||
|
modelId.add(po.getId());
|
||||||
});
|
});
|
||||||
//fixme 这边先写死模板id,后期要选择电能质量的模板来确定监测点个数
|
|
||||||
String modelId = "1";
|
|
||||||
List<CsLineModel> lineList = csLineModelService.getMonitorNumByModelId(modelId);
|
List<CsLineModel> lineList = csLineModelService.getMonitorNumByModelId(modelId);
|
||||||
String key = "LINE" + nDid;
|
String key = "LINE" + nDid;
|
||||||
//存储监测点模板信息,用于界面回显
|
//存储监测点模板信息,用于界面回显
|
||||||
redisUtil.saveByKeyWithExpire(key,lineList,600L);
|
redisUtil.saveByKeyWithExpire(key,lineList,600L);
|
||||||
//存储模板id
|
//存储模板id
|
||||||
//todo 这边也是要调整的
|
|
||||||
String key2 = "MODEL" + nDid;
|
String key2 = "MODEL" + nDid;
|
||||||
redisUtil.saveByKeyWithExpire(key2,modelId,600L);
|
redisUtil.saveByKeyWithExpire(key2,modelId,600L);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.access.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 数据集表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-08-01
|
||||||
|
*/
|
||||||
|
public interface CsDataArrayMapper extends BaseMapper<CsDataArrayPO> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.access.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 数据集表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-08-01
|
||||||
|
*/
|
||||||
|
public interface CsDataSetMapper extends BaseMapper<CsDataSetPO> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.njcn.access.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
|
||||||
|
import com.njcn.csdevice.pojo.param.CsDevModelQueryListParm;
|
||||||
|
import com.njcn.csdevice.pojo.param.CsDevModelQueryParm;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.CsDevModelPageVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||||
|
* Date: 2023/4/10 11:28【需求编号】
|
||||||
|
*
|
||||||
|
* @author clam
|
||||||
|
* @version V1.0.0
|
||||||
|
*/
|
||||||
|
public interface CsDevModelMapper extends BaseMapper<CsDevModelPO> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.njcn.access.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||||
|
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 数据集表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-08-01
|
||||||
|
*/
|
||||||
|
public interface ICsDataArrayService extends IService<CsDataArrayPO> {
|
||||||
|
/**
|
||||||
|
* 新增详细数据集
|
||||||
|
* @param csDataArrayPo
|
||||||
|
*/
|
||||||
|
void add(CsDataArrayPO csDataArrayPo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增数据集
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
void addList(List<CsDataArrayPO> list);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.njcn.access.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 数据集表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-08-01
|
||||||
|
*/
|
||||||
|
public interface ICsDataSetService extends IService<CsDataSetPO> {
|
||||||
|
/**
|
||||||
|
* 新增数据集
|
||||||
|
* @param csDataSetPo
|
||||||
|
*/
|
||||||
|
void add(CsDataSetPO csDataSetPo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增数据集
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
void addList(List<CsDataSetPO> list);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,8 +17,20 @@ public interface ICsLineModelService extends IService<CsLineModel> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模板下监测点个数
|
* 获取模板下监测点个数
|
||||||
* @param id 模板Id
|
* @param list 模板Id集合
|
||||||
*/
|
*/
|
||||||
List<CsLineModel> getMonitorNumByModelId(String id);
|
List<CsLineModel> getMonitorNumByModelId(List<String> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增模板监测点信息
|
||||||
|
* @param csLineModel
|
||||||
|
*/
|
||||||
|
void add(CsLineModel csLineModel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增模板监测点信息
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
void addList(List<CsLineModel> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
|
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-08-01
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDataArrayPO> implements ICsDataArrayService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(CsDataArrayPO csDataArrayPo) {
|
||||||
|
this.save(csDataArrayPo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addList(List<CsDataArrayPO> list) {
|
||||||
|
this.saveBatch(list,1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 数据集表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-08-01
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSetPO> implements ICsDataSetService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(CsDataSetPO csDataSetPo) {
|
||||||
|
this.save(csDataSetPo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addList(List<CsDataSetPO> list) {
|
||||||
|
this.saveBatch(list,1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,22 @@
|
|||||||
package com.njcn.access.service.impl;
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.njcn.access.enums.AccessResponseEnum;
|
import com.njcn.access.enums.AccessResponseEnum;
|
||||||
import com.njcn.access.enums.DataModel;
|
import com.njcn.access.enums.DataModel;
|
||||||
import com.njcn.access.enums.TypeEnum;
|
import com.njcn.access.enums.TypeEnum;
|
||||||
|
import com.njcn.access.mapper.CsDevModelMapper;
|
||||||
import com.njcn.access.pojo.dto.data.*;
|
import com.njcn.access.pojo.dto.data.*;
|
||||||
import com.njcn.access.pojo.dto.devModel.ApfDto;
|
import com.njcn.access.pojo.dto.devModel.*;
|
||||||
import com.njcn.access.pojo.dto.devModel.ClDevDto;
|
import com.njcn.access.pojo.po.CsDataArrayPO;
|
||||||
import com.njcn.access.pojo.dto.devModel.TemplateDto;
|
import com.njcn.access.pojo.po.CsDataSetPO;
|
||||||
|
import com.njcn.access.pojo.po.CsLineModel;
|
||||||
|
import com.njcn.access.service.ICsDataArrayService;
|
||||||
|
import com.njcn.access.service.ICsDataSetService;
|
||||||
import com.njcn.access.service.ICsDevModelService;
|
import com.njcn.access.service.ICsDevModelService;
|
||||||
|
import com.njcn.access.service.ICsLineModelService;
|
||||||
import com.njcn.access.utils.JsonUtil;
|
import com.njcn.access.utils.JsonUtil;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
@@ -22,6 +28,7 @@ import com.njcn.system.api.DicDataFeignClient;
|
|||||||
import com.njcn.system.api.DictTreeFeignClient;
|
import com.njcn.system.api.DictTreeFeignClient;
|
||||||
import com.njcn.system.api.EleEvtFeignClient;
|
import com.njcn.system.api.EleEvtFeignClient;
|
||||||
import com.njcn.system.api.EpdFeignClient;
|
import com.njcn.system.api.EpdFeignClient;
|
||||||
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||||
import com.njcn.system.pojo.param.EleEvtParam;
|
import com.njcn.system.pojo.param.EleEvtParam;
|
||||||
import com.njcn.system.pojo.po.Dic;
|
import com.njcn.system.pojo.po.Dic;
|
||||||
@@ -66,6 +73,14 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
|
|
||||||
private final EleEvtFeignClient eleEvtFeignClient;
|
private final EleEvtFeignClient eleEvtFeignClient;
|
||||||
|
|
||||||
|
private final ICsDataSetService csDataSetService;
|
||||||
|
|
||||||
|
private final ICsDataArrayService csDataArrayService;
|
||||||
|
|
||||||
|
private final CsDevModelMapper csDevModelMapper;
|
||||||
|
|
||||||
|
private final ICsLineModelService csLineModelService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void addModel(MultipartFile file) {
|
public void addModel(MultipartFile file) {
|
||||||
@@ -79,12 +94,18 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
String filePath = "";
|
String filePath = "";
|
||||||
//1.录入cs_dev_model表,记录装置型号和模板记录
|
//1.录入cs_dev_model表,记录装置型号和模板记录
|
||||||
CsDevModelPO csDevModelPo = addCsDevModel(templateDto,filePath);
|
CsDevModelPO csDevModelPo = addCsDevModel(templateDto,filePath);
|
||||||
|
//2.录入数据集、详细数据(主设备、模块、监测设备)
|
||||||
|
analysisDataSet(templateDto,csDevModelPo.getId());
|
||||||
|
//3.录入监测点模板表(记录当前模板有几个监测点,治理类型的模板目前规定1个监测点,电能质量模板根据逻辑子设备来)
|
||||||
|
addCsLineModel(templateDto,csDevModelPo.getId());
|
||||||
|
//todo 这边软件信息和监测点信息需要接入后询问设备,然后记录
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void addDict(MultipartFile file) {
|
public void addDict(MultipartFile file) {
|
||||||
String json = null;
|
String json = null;
|
||||||
try {
|
try {
|
||||||
@@ -105,13 +126,21 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
if (!Objects.isNull(po)){
|
if (!Objects.isNull(po)){
|
||||||
throw new BusinessException(AccessResponseEnum.MODEL_REPEAT);
|
throw new BusinessException(AccessResponseEnum.MODEL_REPEAT);
|
||||||
}
|
}
|
||||||
CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm();
|
CsDevModelPO model = new CsDevModelPO();
|
||||||
csDevModelAddParm.setDevTypeName(templateDto.getDevType());
|
model.setDevTypeName(templateDto.getDevType());
|
||||||
csDevModelAddParm.setName(templateDto.getDevType());
|
model.setName(templateDto.getDevType());
|
||||||
csDevModelAddParm.setVersionNo(templateDto.getVersion());
|
model.setVersionNo(templateDto.getVersion());
|
||||||
csDevModelAddParm.setTime(templateDto.getTime());
|
model.setVersionDate(Date.valueOf(templateDto.getTime()));
|
||||||
csDevModelAddParm.setFilePath(filePath);
|
model.setFilePath(filePath);
|
||||||
return devModelFeignClient.addDevModel(csDevModelAddParm).getData();
|
model.setStatus ("1");
|
||||||
|
//fixme 先用数据类型来区分模板的类型
|
||||||
|
if (templateDto.getDataList().contains("Apf") || templateDto.getDataList().contains("Dvr")){
|
||||||
|
model.setType(0);
|
||||||
|
} else {
|
||||||
|
model.setType(1);
|
||||||
|
}
|
||||||
|
csDevModelMapper.insert(model);
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -516,5 +545,289 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析数据集、详细数据
|
||||||
|
*/
|
||||||
|
private void analysisDataSet(TemplateDto templateDto,String pId){
|
||||||
|
List<CsDataSetPO> setList = new ArrayList<>();
|
||||||
|
List<CsDataArrayPO> arrayList = new ArrayList<>();
|
||||||
|
List<DataSetDto> dataSetList = templateDto.getDataSet();
|
||||||
|
//逻辑设备录入
|
||||||
|
if (CollectionUtil.isNotEmpty(dataSetList)){
|
||||||
|
dataSetList.forEach(item1->{
|
||||||
|
String id = IdUtil.fastSimpleUUID();
|
||||||
|
CsDataSetPO csDataSetPo = new CsDataSetPO();
|
||||||
|
csDataSetPo.setId(id);
|
||||||
|
csDataSetPo.setPid(pId);
|
||||||
|
csDataSetPo.setName(item1.getName());
|
||||||
|
csDataSetPo.setAnotherName(item1.getName());
|
||||||
|
csDataSetPo.setIdx(item1.getIdx());
|
||||||
|
csDataSetPo.setPeriod(item1.getPeriod());
|
||||||
|
csDataSetPo.setStoreFlag(item1.getStoreFlag());
|
||||||
|
csDataSetPo.setDataList(String.join(",",templateDto.getDataList()));
|
||||||
|
csDataSetPo.setType(0);
|
||||||
|
setList.add(csDataSetPo);
|
||||||
|
List<DataArrayDto> list = item1.getDataArrayDtoList();
|
||||||
|
if(CollectionUtil.isNotEmpty(list)) {
|
||||||
|
int i = 0;
|
||||||
|
for (DataArrayDto item2 : list) {
|
||||||
|
List<CsDataArrayPO> po = findDict(id,templateDto,item2.getType(),item2.getIdx());
|
||||||
|
for (CsDataArrayPO p : po) {
|
||||||
|
p.setIdx(item2.getIdx());
|
||||||
|
p.setSort(i);
|
||||||
|
i++;
|
||||||
|
arrayList.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//逻辑子设备数据录入
|
||||||
|
List<ClDevDto> clDevList = templateDto.getClDevDtoList();
|
||||||
|
if (CollectionUtil.isNotEmpty(clDevList)){
|
||||||
|
clDevList.forEach(item3->{
|
||||||
|
List<DataSetDto> clDataSetList = item3.getDataSet();
|
||||||
|
if (CollectionUtil.isNotEmpty(clDataSetList)){
|
||||||
|
clDataSetList.forEach(item4->{
|
||||||
|
String id = IdUtil.fastSimpleUUID();
|
||||||
|
CsDataSetPO csDataSetPo = new CsDataSetPO();
|
||||||
|
csDataSetPo.setId(id);
|
||||||
|
csDataSetPo.setPid(pId);
|
||||||
|
csDataSetPo.setName(item4.getName());
|
||||||
|
csDataSetPo.setAnotherName(item4.getName());
|
||||||
|
csDataSetPo.setIdx(item4.getIdx());
|
||||||
|
csDataSetPo.setPeriod(item4.getPeriod());
|
||||||
|
csDataSetPo.setStoreFlag(item4.getStoreFlag());
|
||||||
|
csDataSetPo.setDataList(String.join(",",item3.getDataList()));
|
||||||
|
//fixme 先用数据类型来区分模板的类型
|
||||||
|
if (item3.getDataList().contains("Apf") || item3.getDataList().contains("Dvr")){
|
||||||
|
csDataSetPo.setType(1);
|
||||||
|
} else {
|
||||||
|
csDataSetPo.setType(2);
|
||||||
|
}
|
||||||
|
csDataSetPo.setClDev(item3.getClDid());
|
||||||
|
setList.add(csDataSetPo);
|
||||||
|
|
||||||
|
List<DataArrayDto> list = item4.getDataArrayDtoList();
|
||||||
|
if(CollectionUtil.isNotEmpty(list)) {
|
||||||
|
int i = 0;
|
||||||
|
for (DataArrayDto item2 : list) {
|
||||||
|
List<CsDataArrayPO> po = findDict(id,templateDto,item2.getType(),item2.getIdx());
|
||||||
|
for (CsDataArrayPO p : po) {
|
||||||
|
p.setIdx(item2.getIdx());
|
||||||
|
p.setSort(i);
|
||||||
|
i++;
|
||||||
|
arrayList.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(CollectionUtil.isNotEmpty(setList)) {
|
||||||
|
csDataSetService.addList(setList);
|
||||||
|
}
|
||||||
|
if(CollectionUtil.isNotEmpty(arrayList)) {
|
||||||
|
csDataArrayService.addList(arrayList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据DataArray获取详细数据
|
||||||
|
* @param templateDto
|
||||||
|
* @param type
|
||||||
|
* @param idx
|
||||||
|
*/
|
||||||
|
private List<CsDataArrayPO> findDict(String pid, TemplateDto templateDto, String type, Integer idx) {
|
||||||
|
List<CsDataArrayPO> list = new ArrayList<>();
|
||||||
|
String id = dicDataFeignClient.getDicDataByCode(type).getData().getId();
|
||||||
|
String name = null,phase = null;
|
||||||
|
switch (type) {
|
||||||
|
case DataModel.APF:
|
||||||
|
log.info("查询apf字典数据");
|
||||||
|
List<ApfDto> apfList = templateDto.getApfDto();
|
||||||
|
ApfDto apfDto = apfList.get(idx);
|
||||||
|
name = apfDto.getName();
|
||||||
|
phase = apfDto.getPhase() == null ? "M":apfDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.EVT:
|
||||||
|
log.info("查询evt字典数据");
|
||||||
|
List<EvtDto> evtList = templateDto.getEvtDto();
|
||||||
|
EvtDto evtDto = evtList.get(idx);
|
||||||
|
name = evtDto.getName();
|
||||||
|
phase = evtDto.getPhase() == null ? "M":evtDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.ALM:
|
||||||
|
log.info("查询alm字典数据");
|
||||||
|
List<AlmDto> almList = templateDto.getAlmDto();
|
||||||
|
AlmDto almDto = almList.get(idx);
|
||||||
|
name = almDto.getName();
|
||||||
|
phase = almDto.getPhase() == null ? "M":almDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.STS:
|
||||||
|
log.info("查询sts字典数据");
|
||||||
|
List<StsDto> stsList = templateDto.getStsDto();
|
||||||
|
StsDto stsDto = stsList.get(idx);
|
||||||
|
name = stsDto.getName();
|
||||||
|
phase = stsDto.getPhase() == null ? "M":stsDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.PARM:
|
||||||
|
log.info("查询parm字典数据");
|
||||||
|
List<ParmDto> parmList = templateDto.getParmDto();
|
||||||
|
ParmDto parmDto = parmList.get(idx);
|
||||||
|
name = parmDto.getName();
|
||||||
|
phase = parmDto.getPhase() == null ? "M":parmDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.SET:
|
||||||
|
log.info("查询set字典数据");
|
||||||
|
List<SetDto> setList = templateDto.getSetDto();
|
||||||
|
SetDto setDto = setList.get(idx);
|
||||||
|
name = setDto.getName();
|
||||||
|
phase = setDto.getPhase() == null ? "M":setDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.CTRL:
|
||||||
|
log.info("查询ctrl字典数据");
|
||||||
|
List<CtrlDto> ctrlList = templateDto.getCtrlDto();
|
||||||
|
CtrlDto ctrlDto = ctrlList.get(idx);
|
||||||
|
name = ctrlDto.getName();
|
||||||
|
phase = ctrlDto.getPhase() == null ? "M":ctrlDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.EPD:
|
||||||
|
log.info("查询epd字典数据");
|
||||||
|
List<EpdPqdDto> epdList = templateDto.getEpdDto();
|
||||||
|
EpdPqdDto epdDto = epdList.get(idx);
|
||||||
|
name = epdDto.getName();
|
||||||
|
phase = epdDto.getPhase() == null ? "M":epdDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.PQD:
|
||||||
|
log.info("查询pqd字典数据");
|
||||||
|
List<EpdPqdDto> pqdList = templateDto.getPqdDto();
|
||||||
|
EpdPqdDto pqdDto = pqdList.get(idx);
|
||||||
|
name = pqdDto.getName();
|
||||||
|
phase = pqdDto.getPhase() == null ? "M":pqdDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.BMD:
|
||||||
|
log.info("查询bmd字典数据");
|
||||||
|
List<BmdDto> bmdList = templateDto.getBmdDto();
|
||||||
|
BmdDto bmdDto = bmdList.get(idx);
|
||||||
|
name = bmdDto.getName();
|
||||||
|
phase = bmdDto.getPhase() == null ? "M":bmdDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.DI:
|
||||||
|
log.info("查询di字典数据");
|
||||||
|
List<DiDto> diList = templateDto.getDiDto();
|
||||||
|
DiDto diDto = diList.get(idx);
|
||||||
|
name = diDto.getName();
|
||||||
|
phase = diDto.getPhase() == null ? "M":diDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.DO:
|
||||||
|
log.info("查询do字典数据");
|
||||||
|
List<DoDto> doList = templateDto.getDoDto();
|
||||||
|
DoDto doDto = doList.get(idx);
|
||||||
|
name = doDto.getName();
|
||||||
|
phase = doDto.getPhase() == null ? "M":doDto.getPhase();
|
||||||
|
break;
|
||||||
|
case DataModel.INSET:
|
||||||
|
log.info("查询inset字典数据");
|
||||||
|
List<InSetDto> inSetList = templateDto.getInSetDto();
|
||||||
|
InSetDto inSetDto = inSetList.get(idx);
|
||||||
|
name = inSetDto.getName();
|
||||||
|
phase = inSetDto.getPhase() == null ? "M":inSetDto.getPhase();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EleEpdPqd eleEpdPqd = epdFeignClient.findByParam(name,id,phase).getData();
|
||||||
|
if (Objects.isNull(eleEpdPqd)){
|
||||||
|
throw new BusinessException(AccessResponseEnum.DICT_MISSING);
|
||||||
|
}
|
||||||
|
if (!Objects.isNull(eleEpdPqd.getHarmStart()) && !Objects.isNull(eleEpdPqd.getHarmEnd())){
|
||||||
|
for (int i = eleEpdPqd.getHarmStart(); i <= eleEpdPqd.getHarmEnd(); i++) {
|
||||||
|
if (!Objects.isNull(eleEpdPqd.getStatMethod())){
|
||||||
|
String[] statMethodList = eleEpdPqd.getStatMethod().split(",");
|
||||||
|
for (String stat : statMethodList) {
|
||||||
|
CsDataArrayPO csDataArrayPo = new CsDataArrayPO();
|
||||||
|
csDataArrayPo.setPid(pid);
|
||||||
|
csDataArrayPo.setDataId(eleEpdPqd.getId());
|
||||||
|
csDataArrayPo.setName(eleEpdPqd.getName() + "_" + i);
|
||||||
|
csDataArrayPo.setAnotherName(i + "次" +eleEpdPqd.getShowName());
|
||||||
|
csDataArrayPo.setStatMethod(stat);
|
||||||
|
csDataArrayPo.setDataType(eleEpdPqd.getDataType());
|
||||||
|
csDataArrayPo.setPhase(eleEpdPqd.getPhase());
|
||||||
|
list.add(csDataArrayPo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CsDataArrayPO csDataArrayPo = new CsDataArrayPO();
|
||||||
|
csDataArrayPo.setPid(pid);
|
||||||
|
csDataArrayPo.setDataId(eleEpdPqd.getId());
|
||||||
|
csDataArrayPo.setName(eleEpdPqd.getName() + "_" + i);
|
||||||
|
csDataArrayPo.setAnotherName(i + "次" +eleEpdPqd.getShowName());
|
||||||
|
csDataArrayPo.setStatMethod(eleEpdPqd.getStatMethod());
|
||||||
|
csDataArrayPo.setDataType(eleEpdPqd.getDataType());
|
||||||
|
csDataArrayPo.setPhase(eleEpdPqd.getPhase());
|
||||||
|
list.add(csDataArrayPo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!Objects.isNull(eleEpdPqd.getStatMethod())){
|
||||||
|
List<String> statMethodList = Arrays.asList(eleEpdPqd.getStatMethod().split(","));
|
||||||
|
statMethodList.forEach(stat->{
|
||||||
|
CsDataArrayPO csDataArrayPo = new CsDataArrayPO();
|
||||||
|
csDataArrayPo.setPid(pid);
|
||||||
|
csDataArrayPo.setDataId(eleEpdPqd.getId());
|
||||||
|
csDataArrayPo.setName(eleEpdPqd.getName());
|
||||||
|
csDataArrayPo.setAnotherName(eleEpdPqd.getShowName());
|
||||||
|
csDataArrayPo.setStatMethod(stat);
|
||||||
|
csDataArrayPo.setDataType(eleEpdPqd.getDataType());
|
||||||
|
csDataArrayPo.setPhase(eleEpdPqd.getPhase());
|
||||||
|
list.add(csDataArrayPo);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
CsDataArrayPO csDataArrayPo = new CsDataArrayPO();
|
||||||
|
csDataArrayPo.setPid(pid);
|
||||||
|
csDataArrayPo.setDataId(eleEpdPqd.getId());
|
||||||
|
csDataArrayPo.setName(eleEpdPqd.getName());
|
||||||
|
csDataArrayPo.setAnotherName(eleEpdPqd.getShowName());
|
||||||
|
csDataArrayPo.setStatMethod(eleEpdPqd.getStatMethod());
|
||||||
|
csDataArrayPo.setDataType(eleEpdPqd.getDataType());
|
||||||
|
csDataArrayPo.setPhase(eleEpdPqd.getPhase());
|
||||||
|
list.add(csDataArrayPo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据模板文件来录入监测点模板
|
||||||
|
*/
|
||||||
|
private void addCsLineModel(TemplateDto templateDto,String pId) {
|
||||||
|
List<CsLineModel> result = new ArrayList<>();
|
||||||
|
//fixme 先用数据类型来区分模板的类型
|
||||||
|
if (templateDto.getDataList().contains("Apf") || templateDto.getDataList().contains("Dvr")){
|
||||||
|
CsLineModel csLineModel = new CsLineModel();
|
||||||
|
csLineModel.setLineId(IdUtil.fastSimpleUUID());
|
||||||
|
csLineModel.setPid(pId);
|
||||||
|
csLineModel.setName("治理监测点");
|
||||||
|
csLineModel.setPosition(dicDataFeignClient.getDicDataByCode(DicDataEnum.OUTPUT_SIDE.getCode()).getData().getId());
|
||||||
|
result.add(csLineModel);
|
||||||
|
} else {
|
||||||
|
List<ClDevDto> list = templateDto.getClDevDtoList();
|
||||||
|
list.forEach(item->{
|
||||||
|
CsLineModel csLineModel = new CsLineModel();
|
||||||
|
csLineModel.setLineId(IdUtil.fastSimpleUUID());
|
||||||
|
csLineModel.setPid(pId);
|
||||||
|
//fixme 默认第一个监测点是负载侧,第二个是电网测
|
||||||
|
if (Objects.equals(item.getClDid(),1)){
|
||||||
|
csLineModel.setName("负载侧监测点");
|
||||||
|
csLineModel.setPosition(dicDataFeignClient.getDicDataByCode(DicDataEnum.LOAD_SIDE.getCode()).getData().getId());
|
||||||
|
} else if (Objects.equals(item.getClDid(),2)){
|
||||||
|
csLineModel.setName("电网侧监测点");
|
||||||
|
csLineModel.setPosition(dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData().getId());
|
||||||
|
}
|
||||||
|
result.add(csLineModel);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
csLineModelService.addList(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.njcn.access.service.impl;
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
import com.njcn.access.enums.AccessEnum;
|
import com.njcn.access.enums.AccessEnum;
|
||||||
import com.njcn.access.enums.AccessResponseEnum;
|
import com.njcn.access.enums.AccessResponseEnum;
|
||||||
@@ -142,8 +145,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
po.setPosition(item.getPosition());
|
po.setPosition(item.getPosition());
|
||||||
po.setVolGrade(item.getVolGrade());
|
po.setVolGrade(item.getVolGrade());
|
||||||
//todo 目前ct、pt数据不确定 后期补
|
//todo 目前ct、pt数据不确定 后期补
|
||||||
//po.setPtRatio(item.getPtRatio());
|
// po.setPtRatio(item.getPtRatio());
|
||||||
//po.setCtRatio(item.getCtRatio());
|
// po.setCtRatio(item.getCtRatio());
|
||||||
po.setStatus(1);
|
po.setStatus(1);
|
||||||
csLinePoList.add(po);
|
csLinePoList.add(po);
|
||||||
CsLedgerParam param = new CsLedgerParam();
|
CsLedgerParam param = new CsLedgerParam();
|
||||||
@@ -165,16 +168,19 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
//3.监测点拓扑图表录入关系
|
//3.监测点拓扑图表录入关系
|
||||||
csLineTopologyFeignClient.addList(appLineTopologyDiagramPoList);
|
csLineTopologyFeignClient.addList(appLineTopologyDiagramPoList);
|
||||||
//4.新增装置-模板关系
|
//4.新增装置-模板关系
|
||||||
String modelId = redisUtil.getObjectByKey("MODEL" + devAccessParam.getNDid()).toString();
|
List<String> modelId = objectToList(redisUtil.getObjectByKey("MODEL" + devAccessParam.getNDid()));
|
||||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
modelId.forEach(item->{
|
||||||
csDevModelRelationAddParm.setDevId(vo.getId());
|
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||||
csDevModelRelationAddParm.setModelId(modelId);
|
csDevModelRelationAddParm.setDevId(vo.getId());
|
||||||
devModelRelationFeignClient.addDevModelRelation(csDevModelRelationAddParm);
|
csDevModelRelationAddParm.setModelId(item);
|
||||||
|
devModelRelationFeignClient.addDevModelRelation(csDevModelRelationAddParm);
|
||||||
|
});
|
||||||
redisUtil.delete("MODEL" + devAccessParam.getNDid());
|
redisUtil.delete("MODEL" + devAccessParam.getNDid());
|
||||||
//5.修改装置状态
|
//5.修改装置状态
|
||||||
equipmentFeignClient.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.REGISTERED.getCode());
|
equipmentFeignClient.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.REGISTERED.getCode());
|
||||||
//6.装置接入之后再设置心跳时间,超时改为掉线
|
//6.装置接入之后再设置心跳时间,超时改为掉线
|
||||||
//redisUtil.saveByKeyWithExpire("MQTT:" + devAccessParam.getNDid(), Instant.now().toEpochMilli(),180L);
|
//redisUtil.saveByKeyWithExpire("MQTT:" + devAccessParam.getNDid(), Instant.now().toEpochMilli(),180L);
|
||||||
|
//todo 需要将设备运行状态改为在线
|
||||||
//7.绑定装置和人的关系
|
//7.绑定装置和人的关系
|
||||||
CsDeviceUserPO po = new CsDeviceUserPO();
|
CsDeviceUserPO po = new CsDeviceUserPO();
|
||||||
po.setPrimaryUserId(RequestUtil.getUserIndex());
|
po.setPrimaryUserId(RequestUtil.getUserIndex());
|
||||||
@@ -201,7 +207,19 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
accessDto.setNDid(nDid);
|
accessDto.setNDid(nDid);
|
||||||
accessDto.setDevType(devType);
|
accessDto.setDevType(devType);
|
||||||
reqAndResParam.setMsg(accessDto);
|
reqAndResParam.setMsg(accessDto);
|
||||||
publisher.send("/Pfm/Reg/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
publisher.send("/Pfm/DevReg/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> objectToList(Object object) {
|
||||||
|
List<String> urlList = new ArrayList<>();
|
||||||
|
if (object != null) {
|
||||||
|
if (object instanceof ArrayList<?>) {
|
||||||
|
for (Object o : (List<?>) object) {
|
||||||
|
urlList.add((String) o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return urlList;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,18 @@ import java.util.List;
|
|||||||
public class CsLineModelServiceImpl extends ServiceImpl<CsLineModelMapper, CsLineModel> implements ICsLineModelService {
|
public class CsLineModelServiceImpl extends ServiceImpl<CsLineModelMapper, CsLineModel> implements ICsLineModelService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CsLineModel> getMonitorNumByModelId(String id) {
|
public List<CsLineModel> getMonitorNumByModelId(List<String> list) {
|
||||||
return this.lambdaQuery().eq(CsLineModel::getPid,id).list();
|
return this.lambdaQuery().in(CsLineModel::getPid,list).list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(CsLineModel csLineModel) {
|
||||||
|
this.save(csLineModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addList(List<CsLineModel> list) {
|
||||||
|
this.saveBatch(list,1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user