修改链路配置及映射表相关操作
This commit is contained in:
parent
e56a387169
commit
447b19a00d
@ -2,9 +2,10 @@ package com.das.common.constant;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
*
|
||||
* @date 2019/8/26 15:08
|
||||
* @description: 测量类型
|
||||
*/
|
||||
public interface BaseIotModelType {
|
||||
public interface MeasType {
|
||||
|
||||
/**
|
||||
* 遥测量
|
@ -23,4 +23,12 @@ public interface SysIotModelFieldMapper extends BaseMapperPlus<SysIotModelField,
|
||||
List<String> queryAllFiledNames(@Param("deviceId") Long deviceId);
|
||||
|
||||
String queryModelCodeByDeviceId(@Param("deviceId") Long deviceId);
|
||||
|
||||
/**
|
||||
* 根据物模型id查询模型属性列表
|
||||
* @param modelId 物模型id
|
||||
* @return
|
||||
*/
|
||||
List<SysIotModelFieldVo> selectModelFieldListByModelId(@Param("modelId") Long modelId);
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ import com.das.modules.equipment.entity.SysIotModelServices;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysIotModelServiceMapper extends BaseMapperPlus<SysIotModelServices, SysIotModelServices> {
|
||||
|
||||
@ -18,4 +20,11 @@ public interface SysIotModelServiceMapper extends BaseMapperPlus<SysIotModelServ
|
||||
|
||||
SysIotModelServiceVo selectByServiceCode(Long iotModelId, String code);
|
||||
|
||||
/**
|
||||
* 根据物模型id查询模型服务列表
|
||||
* @param modelId 物模型id
|
||||
* @return
|
||||
*/
|
||||
List<SysIotModelServiceVo> selectModelServiceListByModelId(@Param("modelId") Long modelId);
|
||||
|
||||
}
|
||||
|
@ -155,40 +155,48 @@ public class SysNodeController {
|
||||
return R.success(typeVoList);
|
||||
}
|
||||
|
||||
/** 获取映射表信息 */
|
||||
/**
|
||||
* 获取映射表信息
|
||||
* @param queryParam 查询条件(LinkId 和 MeasType)
|
||||
* @return 返回前端呈现表格数据
|
||||
*/
|
||||
@PostMapping("/link/getMappingList")
|
||||
public R<?> getMappingList(@RequestBody SysImptabmappingDto sysImptabmappingDto) {
|
||||
public R<?> getMappingList(@RequestBody QueryTabMappingParamDto queryParam) {
|
||||
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
if(!hasPermission){
|
||||
return R.fail("没有节点管理权限");
|
||||
}
|
||||
if (sysImptabmappingDto.getLinkId() == null) {
|
||||
if (queryParam.getLinkId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
List<ImptabmappingVo> list = sysNodeService.getMappingList(sysImptabmappingDto);
|
||||
List<SysTabMappingVo> list = sysNodeService.getMappingList(queryParam);
|
||||
return R.success(list);
|
||||
}
|
||||
|
||||
/** 获取绑定的设备列表信息 */
|
||||
/**
|
||||
* 获取链路绑定的设备列表
|
||||
* @param queryParam 查询条件 只用到 LinkId
|
||||
* @return 设备列表
|
||||
*/
|
||||
@PostMapping("/link/getBindDeviceTree")
|
||||
public R<?> getBindDeviceTree(@RequestBody SysImptabmappingDto sysImptabmappingDto) {
|
||||
public R<?> getBindDeviceTree(@RequestBody QueryTabMappingParamDto queryParam) {
|
||||
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
if(!hasPermission){
|
||||
return R.fail("没有节点管理权限");
|
||||
}
|
||||
if (sysImptabmappingDto.getLinkId() == null) {
|
||||
if (queryParam.getLinkId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
List<SysImptabmappingVo> list = sysNodeService.getBindDeviceTree(sysImptabmappingDto.getLinkId());
|
||||
List<EquipmentVo> list = sysNodeService.getBindDeviceTree(queryParam.getLinkId());
|
||||
return R.success(list);
|
||||
}
|
||||
|
||||
/** 绑定设备信息 */
|
||||
@PostMapping("/link/bindDeviceMeas")
|
||||
@PostMapping("/link/bindDevices")
|
||||
public R<Void> bindMeas(@RequestBody BindEquipmentDto bindEquipmentDto) {
|
||||
|
||||
//判断是否有权限
|
||||
@ -196,13 +204,13 @@ public class SysNodeController {
|
||||
if(!hasPermission){
|
||||
return R.fail("没有节点管理权限");
|
||||
}
|
||||
sysNodeService.bindDeviceMeas(bindEquipmentDto.getEquipmentId(), bindEquipmentDto.getLinkId());
|
||||
sysNodeService.bindDevices(bindEquipmentDto.getEquipmentList(), bindEquipmentDto.getLinkId());
|
||||
return R.success();
|
||||
}
|
||||
|
||||
/** 保存测点信息 */
|
||||
@PostMapping("/link/saveMappingList")
|
||||
public R<Void> saveMappingList(@RequestBody List<ImptabmappingDto> impList) {
|
||||
public R<Void> saveMappingList(@RequestBody List<SysTabMappingVo> impList) {
|
||||
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_ADMIN.toString());
|
||||
@ -215,10 +223,10 @@ public class SysNodeController {
|
||||
|
||||
/** 导出测点信息成json文件 */
|
||||
@PostMapping("/link/exportMappingList")
|
||||
public void exportMappingList(HttpServletRequest request, HttpServletResponse response, @RequestBody SysImptabmappingDto sysImptabmappingDto) throws IOException {
|
||||
public void exportMappingList(HttpServletRequest request, HttpServletResponse response, @RequestBody QueryTabMappingParamDto queryParam) throws IOException {
|
||||
|
||||
|
||||
sysNodeService.exportMappingList(sysImptabmappingDto,request,response);
|
||||
sysNodeService.exportMappingList(queryParam,request,response);
|
||||
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,20 @@ import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author chenhaojie
|
||||
* @description: 链路绑定设备列表
|
||||
*/
|
||||
@Data
|
||||
public class BindEquipmentDto {
|
||||
|
||||
private List<BindEquipmentInfoDto> equipmentId;
|
||||
|
||||
/**
|
||||
* 链路ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
/**
|
||||
* 设备信息列表(包含设备id和设备地址)
|
||||
*/
|
||||
private List<BindEquipmentInfoDto> equipmentList;
|
||||
}
|
||||
|
@ -4,15 +4,32 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author houwei
|
||||
* @date 2024-10-25
|
||||
* @description: 链路映射表中单条记录,绑定设备信息(设备id,测点序号)
|
||||
*/
|
||||
@Data
|
||||
public class BindEquipmentInfoDto {
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long equipmentId;
|
||||
private Long id;
|
||||
|
||||
private Integer porder;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 设备物模型ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long iotModelId;
|
||||
|
||||
/**
|
||||
* 设备地址
|
||||
*/
|
||||
private String iotAddr;
|
||||
}
|
||||
|
@ -6,21 +6,21 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/*
|
||||
* @author houwei
|
||||
* @date 2024-10-25
|
||||
* @description: 查询链路映射表的 参数对象
|
||||
*/
|
||||
@Data
|
||||
public class ImptabmappingDto implements Serializable {
|
||||
|
||||
public class QueryTabMappingParamDto implements Serializable {
|
||||
/*
|
||||
* 链路id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long equipmentId;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/*
|
||||
* 量测数据类型
|
||||
* 138:模拟量,139:累积量,140:离散量
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
private String params;
|
||||
|
||||
private String name;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.das.modules.node.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SysImptabmappingDto implements Serializable {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
|
||||
private Integer type;
|
||||
}
|
@ -15,11 +15,12 @@ public class ConfigUpdateVo {
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private String nodeId;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long nodeId;
|
||||
|
||||
private List<LinkVo> links;
|
||||
|
||||
private List<EquipmentVo> equipments;
|
||||
private List<EquipmentAndMappingVo> equipments;
|
||||
|
||||
public ConfigUpdateVo() {
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.das.modules.node.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class EquipmentAndMappingVo {
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 设备Iot 地址 对应设备表中的 iot_addr 字段
|
||||
*/
|
||||
private String addr;
|
||||
|
||||
private List<NewIotModelVo> attrs;
|
||||
private List<NewIotModelVo> services;
|
||||
}
|
@ -1,21 +1,35 @@
|
||||
package com.das.modules.node.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绑定的设备信息
|
||||
*/
|
||||
@Data
|
||||
public class EquipmentVo {
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String addr;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
private List<NewIotModelVo> attrs;
|
||||
/**
|
||||
* 对应的物模型ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long iotModelId;
|
||||
|
||||
private List<NewIotModelVo> services;
|
||||
/**
|
||||
* 设备Iot 地址 对应设备表中的 iot_addr 字段
|
||||
*/
|
||||
private String iotAddr;
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
package com.das.modules.node.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.configurationprocessor.json.JSONObject;
|
||||
|
||||
|
||||
/**
|
||||
* 映射表前端回显
|
||||
*
|
||||
* @author guchengwei
|
||||
*/
|
||||
@Data
|
||||
public class ImptabmappingVo {
|
||||
|
||||
private String name;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long equipmentId;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String equipmentName;
|
||||
|
||||
private String equipmentCode;
|
||||
|
||||
private Integer porder;
|
||||
|
||||
private String params;
|
||||
|
||||
private String code;
|
||||
}
|
@ -6,15 +6,25 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LinkVo {
|
||||
|
||||
/**
|
||||
* 链路ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
|
||||
/**
|
||||
* 链路名称
|
||||
*/
|
||||
private String linkName;
|
||||
//协议号
|
||||
/**
|
||||
* 协议号
|
||||
*/
|
||||
private Integer protocol;
|
||||
//协议参数
|
||||
/**
|
||||
* 协议参数
|
||||
*/
|
||||
private Object params;
|
||||
|
||||
/**
|
||||
* 关联的设备列表,设备id字符串列表
|
||||
*/
|
||||
private String[] devices;
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
package com.das.modules.node.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 映射表前端回显
|
||||
*
|
||||
* @author guchengwei
|
||||
*/
|
||||
@Data
|
||||
public class SysImptabmappingVo {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
|
||||
private String linkName;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long equipmentId;
|
||||
|
||||
private String equipmentName;
|
||||
|
||||
private String equipmentAttribute;
|
||||
|
||||
private String equipmentService;
|
||||
|
||||
private Integer porder;
|
||||
|
||||
private String params;
|
||||
|
||||
private String IotAddr;
|
||||
|
||||
private Integer revision;
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.das.modules.node.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author guchengwei
|
||||
* @description: 映射表前端回显
|
||||
*/
|
||||
@Data
|
||||
public class SysTabMappingVo {
|
||||
/**
|
||||
* 映射表记录id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
/**
|
||||
* 链路id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long linkId;
|
||||
/**
|
||||
* 链路名称
|
||||
*/
|
||||
private String linkName;
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long equipmentId;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String equipmentName;
|
||||
/**
|
||||
* 测点类型
|
||||
*/
|
||||
private Integer measPointType;
|
||||
/**
|
||||
* 测点编码
|
||||
*/
|
||||
private String measPointCode;
|
||||
/**
|
||||
* 测点名称
|
||||
*/
|
||||
private String measPointName;
|
||||
/**
|
||||
* 是否高频
|
||||
*/
|
||||
private Integer highSpeed;
|
||||
/**
|
||||
* 测点序号
|
||||
*/
|
||||
private Integer porder;
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private String params;
|
||||
}
|
@ -16,18 +16,15 @@ import java.io.Serial;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 映射表信息
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
* @author houwei
|
||||
* @description: 映射表实例
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_imptabmapping")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysImptabmapping extends BaseEntity {
|
||||
public class SysTabMapping extends BaseEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -53,16 +50,28 @@ public class SysImptabmapping extends BaseEntity {
|
||||
private Long equipmentId;
|
||||
|
||||
/**
|
||||
* 对应设备属性
|
||||
* 测点类型
|
||||
*/
|
||||
@TableField("equipment_attribute")
|
||||
private String equipmentAttribute;
|
||||
@TableField("meas_point_type")
|
||||
private Integer measPointType;
|
||||
|
||||
/**
|
||||
* 对应设备服务
|
||||
* 测点编码
|
||||
*/
|
||||
@TableField("equipment_service")
|
||||
private String equipmentService;
|
||||
@TableField("meas_point_code")
|
||||
private String measPointCode;
|
||||
|
||||
/**
|
||||
* 测点名称
|
||||
*/
|
||||
@TableField("meas_point_name")
|
||||
private String measPointName;
|
||||
|
||||
/**
|
||||
* 是否高频
|
||||
*/
|
||||
@TableField("highspeed")
|
||||
private Integer highSpeed;
|
||||
|
||||
@TableField("porder")
|
||||
private Integer porder;
|
@ -0,0 +1,54 @@
|
||||
package com.das.modules.node.mapper;
|
||||
|
||||
|
||||
import com.das.modules.auth.mapper.BaseMapperPlus;
|
||||
import com.das.modules.node.domain.vo.EquipmentVo;
|
||||
import com.das.modules.node.domain.vo.SysTabMappingVo;
|
||||
import com.das.modules.node.entity.SysTabMapping;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 映射表相关操作Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysImpTabMappingMapper extends BaseMapperPlus<SysTabMapping, SysTabMapping> {
|
||||
/**
|
||||
* 根据linkeId 获取该链路下所有的映射表配置信息
|
||||
* @param linkId 链路id
|
||||
* @return 映射表记录列表
|
||||
*/
|
||||
List<SysTabMappingVo> getMappingInfoListByLinkId(@Param("linkId") Long linkId);
|
||||
|
||||
/**
|
||||
* 获取该链路下 对应类型的映射表配置信息
|
||||
* @param linkId 链路id
|
||||
* @param type 测点类型
|
||||
* @return 映射表记录列表
|
||||
*/
|
||||
List<SysTabMappingVo> getMappingInfoListByLinkIdAndType(@Param("linkId") Long linkId, @Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* 根据linkId 和设备id 获取该链路下 对应类型的映射表配置信息
|
||||
* @param linkId 链路id
|
||||
* @param deviceId 设备id
|
||||
* @return 映射表记录列表
|
||||
*/
|
||||
List<SysTabMappingVo> getMappingInfoListByLinkIdAndDeviceId(@Param("linkId") Long linkId, @Param("deviceId") Long deviceId);
|
||||
|
||||
/**
|
||||
* 根据linkId 获取该链路下绑定的设备信息
|
||||
* @param linkId 链路id
|
||||
* @return 设备列表
|
||||
*/
|
||||
List<EquipmentVo> getBindDeviceByLink(@Param("linkId") Long linkId);
|
||||
|
||||
/**
|
||||
* 根据链路id删除对应的映射表记录
|
||||
* @param linkId 链路id
|
||||
*/
|
||||
void deleteMappingByLinkId(@Param("linkId") Long linkId);
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.das.modules.node.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.mapper.BaseMapperPlus;
|
||||
import com.das.modules.node.domain.dto.SysCommunicationLinkDto;
|
||||
import com.das.modules.node.domain.vo.ImptabmappingVo;
|
||||
import com.das.modules.node.domain.vo.IotModelVo;
|
||||
import com.das.modules.node.domain.vo.SysCommunicationLinkVo;
|
||||
import com.das.modules.node.domain.vo.SysImptabmappingVo;
|
||||
import com.das.modules.node.entity.SysCommunicationLink;
|
||||
import com.das.modules.node.entity.SysImptabmapping;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysImptabmappingMapper extends BaseMapperPlus<SysImptabmapping, SysImptabmapping> {
|
||||
List<ImptabmappingVo> getMappingList(Long linkId, Integer type);
|
||||
|
||||
List<ImptabmappingVo> getMappingControlList(Long linkId, Integer type);
|
||||
|
||||
List<SysImptabmappingVo> getBindDevice(Long linkId);
|
||||
|
||||
void deleteBindDevice(Long linkId);
|
||||
|
||||
List<Long> getEquipmentId(Long linkId);
|
||||
|
||||
List<IotModelVo> getIotModelFieldByDeviceId(@Param("deviceId") Long deviceId);
|
||||
|
||||
List<IotModelVo> getIotModelServiceByDeviceId(@Param("deviceId") Long deviceId);
|
||||
|
||||
List<IotModelVo> getIotModelServiceByEquipmentId(Long equipmentId);
|
||||
|
||||
String getIotAddrByEquipmentId(Long equipmentId);
|
||||
|
||||
String getAttributeCode(Long equipmentId, Integer type, String name);
|
||||
|
||||
String getServiceCode(Long equipmentId, Integer type, String name);
|
||||
|
||||
List<SysImptabmappingVo> getMappingInfoList(Long linkId);
|
||||
}
|
@ -1,18 +1,15 @@
|
||||
package com.das.modules.node.service;
|
||||
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
||||
import com.das.modules.node.domain.dto.*;
|
||||
import com.das.modules.node.domain.vo.ImptabmappingVo;
|
||||
import com.das.modules.node.domain.vo.EquipmentVo;
|
||||
import com.das.modules.node.domain.vo.SysCommunicationLinkVo;
|
||||
import com.das.modules.node.domain.vo.SysImptabmappingVo;
|
||||
import com.das.modules.node.domain.vo.SysNodeVo;
|
||||
import com.das.modules.node.domain.vo.SysTabMappingVo;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
public interface SysNodeService {
|
||||
@ -32,14 +29,29 @@ public interface SysNodeService {
|
||||
|
||||
void deleteSysCommunicationLink(Long id);
|
||||
|
||||
List<ImptabmappingVo> getMappingList(SysImptabmappingDto sysImptabmappingDto);
|
||||
/**
|
||||
* 查询设备映射列表
|
||||
* @param queryParam 查询条件 linkId 链路ID和 type 量测类型
|
||||
* @return
|
||||
*/
|
||||
List<SysTabMappingVo> getMappingList(QueryTabMappingParamDto queryParam);
|
||||
|
||||
List<SysImptabmappingVo> getBindDeviceTree(Long linkId);
|
||||
void bindDeviceMeas(List<BindEquipmentInfoDto> equipmentId, Long linkId);
|
||||
/**
|
||||
* 获取链路已经绑定的设备信息
|
||||
* @param linkId 链路id
|
||||
* @return 绑定的设备信息
|
||||
*/
|
||||
List<EquipmentVo> getBindDeviceTree(Long linkId);
|
||||
|
||||
void saveMappingList(List<ImptabmappingDto> impList);
|
||||
void bindDevices(List<BindEquipmentInfoDto> equipmentList, Long linkId);
|
||||
|
||||
void exportMappingList(SysImptabmappingDto sysImptabmappingDto,HttpServletRequest request, HttpServletResponse response);
|
||||
/**
|
||||
* 保存映射表配置信息
|
||||
* @param impList 配置的表格数据
|
||||
*/
|
||||
void saveMappingList(List<SysTabMappingVo> impList);
|
||||
|
||||
void exportMappingList(QueryTabMappingParamDto sysImptabmappingDto,HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
boolean importMappingList(String linkId, MultipartFile file);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.das.modules.node.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.das.common.constant.BaseIotModelType;
|
||||
import com.das.common.constant.MeasType;
|
||||
import com.das.common.utils.AdminRedisTemplate;
|
||||
import com.das.modules.equipment.domain.vo.IotModelFieldVo;
|
||||
import com.das.modules.equipment.entity.SysIotModelField;
|
||||
@ -13,7 +13,7 @@ import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
import com.das.modules.node.domain.vo.*;
|
||||
import com.das.modules.node.handler.NodeMessageHandler;
|
||||
import com.das.modules.node.mapper.SysCommunicationLinkMapper;
|
||||
import com.das.modules.node.mapper.SysImptabmappingMapper;
|
||||
import com.das.modules.node.mapper.SysImpTabMappingMapper;
|
||||
import com.das.modules.node.service.DataService;
|
||||
import com.das.modules.node.service.TDEngineService;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@ -29,7 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executor;
|
||||
@ -39,6 +38,8 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataServiceImpl implements DataService {
|
||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
|
||||
|
||||
private Disruptor<TerminalMessage> disruptor = null;
|
||||
|
||||
private RingBuffer<TerminalMessage> ringBuffer = null;
|
||||
@ -50,7 +51,7 @@ public class DataServiceImpl implements DataService {
|
||||
SysCommunicationLinkMapper sysCommunicationLinkMapper;
|
||||
|
||||
@Resource
|
||||
SysImptabmappingMapper sysImptabmappingMapper;
|
||||
SysImpTabMappingMapper sysImptabmappingMapper;
|
||||
|
||||
@Resource
|
||||
private NodeMessageHandler nodeMessageHandler;
|
||||
@ -113,14 +114,12 @@ public class DataServiceImpl implements DataService {
|
||||
public JsonNode sendTerminalConfig(Long nodeId) {
|
||||
ConfigUpdateVo configUpdateVo = new ConfigUpdateVo();
|
||||
List<LinkVo> links = new ArrayList<>();
|
||||
List<EquipmentVo> equipments = new ArrayList<>();
|
||||
List<Long> equipmentList = new ArrayList<>();
|
||||
List<EquipmentAndMappingVo> equipments = new ArrayList<>();
|
||||
try {
|
||||
// 获取所有的链路信息
|
||||
List<SysCommunicationLinkVo> sysCommunicationLinkVoList = sysCommunicationLinkMapper.querySysCommunicationLink(nodeId);
|
||||
for (SysCommunicationLinkVo sysCommunicationLinkVo : sysCommunicationLinkVoList) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode jsonNode = objectMapper.readTree(sysCommunicationLinkVo.getParams());
|
||||
JsonNode jsonNode = JSON_MAPPER.readTree(sysCommunicationLinkVo.getParams());
|
||||
LinkVo linkVo = new LinkVo();
|
||||
linkVo.setLinkId(sysCommunicationLinkVo.getId());
|
||||
linkVo.setLinkName(sysCommunicationLinkVo.getLinkName());
|
||||
@ -128,65 +127,64 @@ public class DataServiceImpl implements DataService {
|
||||
linkVo.setProtocol(sysCommunicationLinkVo.getProtocol());
|
||||
List<String> stringList = new ArrayList<>();
|
||||
// 获取关联的设备Id
|
||||
equipmentList = sysImptabmappingMapper.getEquipmentId(sysCommunicationLinkVo.getId());
|
||||
for (Long equipmentId : equipmentList) {
|
||||
stringList.add(String.valueOf(equipmentId));
|
||||
List<EquipmentVo> equipmentList = sysImptabmappingMapper.getBindDeviceByLink(sysCommunicationLinkVo.getId());
|
||||
for (EquipmentVo dev : equipmentList) {
|
||||
stringList.add(String.valueOf(dev.getId()));
|
||||
}
|
||||
String[] stringArray = stringList.toArray(new String[0]);
|
||||
linkVo.setDevices(stringArray);
|
||||
links.add(linkVo);
|
||||
for (Long equipmentId : equipmentList) {
|
||||
|
||||
for (EquipmentVo dev : equipmentList) {
|
||||
|
||||
HashMap map = new HashMap<>();
|
||||
ObjectMapper equipObjectMapper = new ObjectMapper();
|
||||
ObjectNode equipJsonNode = equipObjectMapper.convertValue(map, ObjectNode.class);
|
||||
List<NewIotModelVo> newIotModelFieldList = new ArrayList<>();
|
||||
List<NewIotModelVo> newIotModelServiceList = new ArrayList<>();
|
||||
// 根据设备Id获取对应的物模型属性和动作
|
||||
List<IotModelVo> iotModelFieldList = sysImptabmappingMapper.getIotModelFieldByDeviceId(equipmentId);
|
||||
List<IotModelVo> iotModelServiceList = sysImptabmappingMapper.getIotModelServiceByDeviceId(equipmentId);
|
||||
if (!CollectionUtils.isEmpty(iotModelFieldList)) {
|
||||
for (IotModelVo info : iotModelFieldList) {
|
||||
ObjectNode equipJsonNode = JSON_MAPPER.convertValue(map, ObjectNode.class);
|
||||
|
||||
List<NewIotModelVo> attrs = new ArrayList<>();
|
||||
List<NewIotModelVo> services= new ArrayList<>();
|
||||
|
||||
List<SysTabMappingVo> tabMappingVoList = sysImptabmappingMapper.getMappingInfoListByLinkIdAndDeviceId(sysCommunicationLinkVo.getId(), dev.getId());
|
||||
|
||||
if (!CollectionUtils.isEmpty(tabMappingVoList)) {
|
||||
for (SysTabMappingVo info : tabMappingVoList) {
|
||||
|
||||
NewIotModelVo newIotModelVo = new NewIotModelVo();
|
||||
newIotModelVo.setName(info.getEquipmentAttribute());
|
||||
newIotModelVo.setName(info.getMeasPointCode());
|
||||
if (info.getParams() == null) {
|
||||
newIotModelVo.setParams(equipJsonNode);
|
||||
} else {
|
||||
newIotModelVo.setParams(JSON_MAPPER.readTree(info.getParams().toString()));
|
||||
}
|
||||
|
||||
Integer pointType = info.getMeasPointType();
|
||||
|
||||
if (pointType == MeasType.TYPE_PSR_ANALOG) {
|
||||
newIotModelVo.setHighSpeed(info.getHighSpeed());
|
||||
if (info.getParams() == null) {
|
||||
newIotModelVo.setParams(equipJsonNode);
|
||||
} else {
|
||||
newIotModelVo.setParams(equipObjectMapper.readTree(info.getParams().toString()));
|
||||
}
|
||||
if (info.getAttributeType() == BaseIotModelType.TYPE_PSR_ANALOG) {
|
||||
newIotModelVo.setType("yc");
|
||||
} else if (info.getAttributeType() == BaseIotModelType.TYPE_PSR_ACCUMULATOR) {
|
||||
attrs.add(newIotModelVo);
|
||||
} else if (pointType == MeasType.TYPE_PSR_ACCUMULATOR) {
|
||||
newIotModelVo.setHighSpeed(info.getHighSpeed());
|
||||
newIotModelVo.setType("ym");
|
||||
} else if (info.getAttributeType() == BaseIotModelType.TYPE_PSR_DISCRETE) {
|
||||
attrs.add(newIotModelVo);
|
||||
} else if (pointType == MeasType.TYPE_PSR_DISCRETE) {
|
||||
newIotModelVo.setHighSpeed(info.getHighSpeed());
|
||||
newIotModelVo.setType("yx");
|
||||
}
|
||||
newIotModelFieldList.add(newIotModelVo);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(iotModelServiceList)){
|
||||
for (IotModelVo info : iotModelServiceList) {
|
||||
NewIotModelVo newIotModelVo = new NewIotModelVo();
|
||||
newIotModelVo.setName(info.getEquipmentService());
|
||||
if (info.getParams() == null) {
|
||||
newIotModelVo.setParams(equipJsonNode);
|
||||
} else {
|
||||
newIotModelVo.setParams(equipObjectMapper.readTree(info.getParams().toString()));
|
||||
}
|
||||
if (info.getServiceType() == BaseIotModelType.TYPE_PSR_SETPOINT) {
|
||||
attrs.add(newIotModelVo);
|
||||
}else if (pointType == MeasType.TYPE_PSR_SETPOINT) {
|
||||
newIotModelVo.setType("yt");
|
||||
} else if (info.getServiceType() == BaseIotModelType.TYPE_PSR_CONTROL) {
|
||||
services.add(newIotModelVo);
|
||||
} else if (pointType == MeasType.TYPE_PSR_CONTROL) {
|
||||
newIotModelVo.setType("yk");
|
||||
}
|
||||
newIotModelServiceList.add(newIotModelVo);
|
||||
services.add(newIotModelVo);
|
||||
}
|
||||
}
|
||||
EquipmentVo equipment = new EquipmentVo();
|
||||
equipment.setAddr(iotModelFieldList.get(0).getIotAddr());
|
||||
equipment.setId(equipmentId);
|
||||
equipment.setAttrs(newIotModelFieldList);
|
||||
equipment.setServices(newIotModelServiceList);
|
||||
}
|
||||
|
||||
EquipmentAndMappingVo equipment = new EquipmentAndMappingVo();
|
||||
equipment.setAddr(dev.getIotAddr());
|
||||
equipment.setId(dev.getId());
|
||||
equipment.setAttrs(attrs);
|
||||
equipment.setServices(services);
|
||||
equipments.add(equipment);
|
||||
}
|
||||
}
|
||||
@ -194,12 +192,11 @@ public class DataServiceImpl implements DataService {
|
||||
log.error("获取设备配置信息失败", e);
|
||||
}
|
||||
configUpdateVo.setCreateTime(System.currentTimeMillis());
|
||||
configUpdateVo.setNodeId(String.valueOf(nodeId));
|
||||
configUpdateVo.setNodeId(nodeId);
|
||||
configUpdateVo.setVersion(1);
|
||||
configUpdateVo.setLinks(links);
|
||||
configUpdateVo.setEquipments(equipments);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.valueToTree(configUpdateVo);
|
||||
JsonNode jsonNode = JSON_MAPPER.valueToTree(configUpdateVo);
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
@ -209,7 +206,7 @@ public class DataServiceImpl implements DataService {
|
||||
.time(time)
|
||||
.data(jsonNode)
|
||||
.build();
|
||||
nodeMessageHandler.sendActionMessage(Long.valueOf(nodeId), configUpdate);
|
||||
nodeMessageHandler.sendActionMessage(nodeId, configUpdate);
|
||||
return jsonNode;
|
||||
}
|
||||
|
||||
|
@ -11,22 +11,21 @@ import com.das.common.utils.SequenceUtils;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysOrg;
|
||||
import com.das.modules.auth.mapper.SysOrgMapper;
|
||||
import com.das.modules.equipment.domain.vo.BaseImptabmappingVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelFieldVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelServiceVo;
|
||||
import com.das.modules.equipment.mapper.SysEquipmentMapper;
|
||||
import com.das.modules.equipment.mapper.SysIotModelMapper;
|
||||
import com.das.modules.equipment.mapper.SysIotModelFieldMapper;
|
||||
import com.das.modules.equipment.mapper.SysIotModelServiceMapper;
|
||||
import com.das.modules.node.constant.NodeConstant;
|
||||
import com.das.modules.node.disruptor.TerminalMessageEventHandler;
|
||||
import com.das.modules.node.domain.bo.TerminalMessage;
|
||||
import com.das.modules.node.domain.dto.*;
|
||||
import com.das.modules.node.domain.vo.ImptabmappingVo;
|
||||
import com.das.modules.node.domain.vo.SysCommunicationLinkVo;
|
||||
import com.das.modules.node.domain.vo.SysImptabmappingVo;
|
||||
import com.das.modules.node.domain.vo.SysNodeVo;
|
||||
import com.das.modules.node.domain.vo.*;
|
||||
import com.das.modules.node.entity.SysCommunicationLink;
|
||||
import com.das.modules.node.entity.SysImptabmapping;
|
||||
import com.das.modules.node.entity.SysNode;
|
||||
import com.das.modules.node.entity.SysTabMapping;
|
||||
import com.das.modules.node.mapper.SysCommunicationLinkMapper;
|
||||
import com.das.modules.node.mapper.SysImptabmappingMapper;
|
||||
import com.das.modules.node.mapper.SysImpTabMappingMapper;
|
||||
import com.das.modules.node.mapper.SysNodeMapper;
|
||||
import com.das.modules.node.service.SysNodeService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -35,28 +34,20 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.*;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SysNodeServiceImpl implements SysNodeService {
|
||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
|
||||
|
||||
@Autowired
|
||||
private SysNodeMapper sysNodeMapper;
|
||||
@ -69,11 +60,17 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
private SysOrgMapper sysOrgMapper;
|
||||
|
||||
@Autowired
|
||||
private SysImptabmappingMapper sysImptabmappingMapper;
|
||||
private SysImpTabMappingMapper sysImptabmappingMapper;
|
||||
|
||||
@Autowired
|
||||
private SysEquipmentMapper sysEquipmentMapper;
|
||||
|
||||
@Autowired
|
||||
SysIotModelFieldMapper iotModelFieldMapper;
|
||||
|
||||
@Autowired
|
||||
SysIotModelServiceMapper iotModelServiceMapper;
|
||||
|
||||
@Autowired
|
||||
TerminalMessageEventHandler terminalMessageEventHandler;
|
||||
|
||||
@ -186,96 +183,156 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
sysCommunicationLinkMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物模型列表
|
||||
* @param queryParam 查询条件 linkId 链路ID和 type 量测类型
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ImptabmappingVo> getMappingList(SysImptabmappingDto sysImptabmappingDto) {
|
||||
// 138模拟量 139累积量 140离散量 146遥调 147遥控
|
||||
Integer type = sysImptabmappingDto.getType();
|
||||
List<ImptabmappingVo> list = new ArrayList<>();
|
||||
// 根据类型获取物模型属性或者动作编码
|
||||
if (type == 138 || type == 139 || type == 140) {
|
||||
list = sysImptabmappingMapper.getMappingList(sysImptabmappingDto.getLinkId(), type);
|
||||
} else if (type == 146 || type == 147) {
|
||||
list = sysImptabmappingMapper.getMappingControlList(sysImptabmappingDto.getLinkId(), type);
|
||||
public List<SysTabMappingVo> getMappingList(QueryTabMappingParamDto queryParam) {
|
||||
return sysImptabmappingMapper.getMappingInfoListByLinkIdAndType(queryParam.getLinkId(),queryParam.getType());
|
||||
}
|
||||
|
||||
return list;
|
||||
/**
|
||||
* 获取链路已经绑定的设备信息
|
||||
* @param linkId 链路id
|
||||
* @return 绑定的设备信息
|
||||
*/
|
||||
@Override
|
||||
public List<EquipmentVo> getBindDeviceTree(Long linkId) {
|
||||
return sysImptabmappingMapper.getBindDeviceByLink(linkId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 链路绑定多个设备
|
||||
* @param equipmentList 设备列表
|
||||
* @param linkId 链路id
|
||||
*/
|
||||
@Override
|
||||
public List<SysImptabmappingVo> getBindDeviceTree(Long linkId) {
|
||||
List<SysImptabmappingVo> bindDeviceList = sysImptabmappingMapper.getBindDevice(linkId);
|
||||
return bindDeviceList;
|
||||
}
|
||||
public void bindDevices(List<BindEquipmentInfoDto> equipmentList, Long linkId) {
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
|
||||
@Override
|
||||
public void bindDeviceMeas(List<BindEquipmentInfoDto> equipmentId, Long linkId) {
|
||||
List<SysImptabmapping> addList = new ArrayList<>();
|
||||
List<Long> addList2 = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(equipmentId)) {
|
||||
sysImptabmappingMapper.deleteBindDevice(linkId);
|
||||
// 如果绑定设备列表为空,则清空映射表
|
||||
if (CollectionUtils.isEmpty(equipmentList)) {
|
||||
sysImptabmappingMapper.deleteMappingByLinkId(linkId);
|
||||
}
|
||||
// 先更新设备地址
|
||||
for (BindEquipmentInfoDto info : equipmentId) {
|
||||
for (BindEquipmentInfoDto info : equipmentList) {
|
||||
// 更新设备表里面的设备地址
|
||||
sysEquipmentMapper.updateIotAddr(info.getEquipmentId(), info.getIotAddr());
|
||||
sysEquipmentMapper.updateIotAddr(info.getId(), info.getIotAddr());
|
||||
}
|
||||
|
||||
// 先根据链路Id获取已经配置好的映射表信息列表
|
||||
List<SysTabMappingVo> mappingVoList=sysImptabmappingMapper.getMappingInfoListByLinkId(linkId);
|
||||
//将已经配置好的映射表,按设备id,测点类型,测点code 做一个map;
|
||||
Map<String,SysTabMappingVo> mappingVoMap = new HashMap<>(mappingVoList.size());
|
||||
for (SysTabMappingVo mappingVo : mappingVoList) {
|
||||
String key = mappingVo.getEquipmentId() + "_" + mappingVo.getMeasPointType() + "_" + mappingVo.getMeasPointCode();
|
||||
mappingVoMap.put(key,mappingVo);
|
||||
}
|
||||
// 获取已经绑定的设备
|
||||
List<SysImptabmappingVo> bindDeviceList = sysImptabmappingMapper.getBindDevice(linkId);
|
||||
|
||||
|
||||
//过滤
|
||||
// equipmentId.removeIf(item -> addList2.contains(item.getEquipmentId()));
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
addSysImptabmapping(equipmentId, linkId, sysUserVo, addList);
|
||||
List<SysTabMapping> addList = new ArrayList<>();
|
||||
//过滤已经存在的记录
|
||||
Set<Long> PassedMappingIds = new HashSet<>();
|
||||
|
||||
// 根据绑定的设备列表,获取对应的物模型相关信息
|
||||
for (BindEquipmentInfoDto info : equipmentList) {
|
||||
Long modelId = info.getIotModelId();
|
||||
if(modelId==null||modelId==0){
|
||||
continue;
|
||||
}
|
||||
|
||||
List<SysIotModelFieldVo> iotModelVoList = iotModelFieldMapper.selectModelFieldListByModelId(modelId);
|
||||
for (SysIotModelFieldVo iotModelVo : iotModelVoList) {
|
||||
String key = info.getId() + "_" + iotModelVo.getAttributeType() + "_" + iotModelVo.getAttributeCode();
|
||||
if(mappingVoMap.containsKey(key)){
|
||||
SysTabMappingVo item = mappingVoMap.get(key);
|
||||
PassedMappingIds.add(item.getId());
|
||||
}else{
|
||||
SysTabMapping mapping = new SysTabMapping();
|
||||
mapping.setId(SequenceUtils.generateId());
|
||||
mapping.setLinkId(linkId);
|
||||
mapping.setEquipmentId(info.getId());
|
||||
mapping.setMeasPointType(iotModelVo.getAttributeType());
|
||||
mapping.setMeasPointCode(iotModelVo.getAttributeCode());
|
||||
mapping.setMeasPointName(iotModelVo.getAttributeName());
|
||||
mapping.setHighSpeed(iotModelVo.getHighSpeed());
|
||||
mapping.setPorder(iotModelVo.getPorder());
|
||||
mapping.setCreatedBy(sysUserVo.getAccount());
|
||||
mapping.setRevision(1);
|
||||
addList.add(mapping);
|
||||
}
|
||||
}
|
||||
|
||||
List<SysIotModelServiceVo> iotServiceVoList = iotModelServiceMapper.selectModelServiceListByModelId(modelId);
|
||||
for (SysIotModelServiceVo iotServiceVo : iotServiceVoList) {
|
||||
String key = info.getId() + "_" + iotServiceVo.getServiceType() + "_" + iotServiceVo.getServiceCode();
|
||||
if(mappingVoMap.containsKey(key)){
|
||||
SysTabMappingVo item = mappingVoMap.get(key);
|
||||
PassedMappingIds.add(item.getId());
|
||||
}else{
|
||||
SysTabMapping mapping = new SysTabMapping();
|
||||
mapping.setId(SequenceUtils.generateId());
|
||||
mapping.setLinkId(linkId);
|
||||
mapping.setEquipmentId(info.getId());
|
||||
mapping.setMeasPointType(iotServiceVo.getServiceType());
|
||||
mapping.setMeasPointCode(iotServiceVo.getServiceCode());
|
||||
mapping.setMeasPointName(iotServiceVo.getServiceName());
|
||||
mapping.setPorder(iotServiceVo.getPorder());
|
||||
mapping.setCreatedBy(sysUserVo.getAccount());
|
||||
mapping.setRevision(1);
|
||||
addList.add(mapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
//批量更新
|
||||
if (!CollectionUtils.isEmpty(addList)) {
|
||||
sysImptabmappingMapper.deleteBindDevice(linkId);
|
||||
sysImptabmappingMapper.insertOrUpdateBatch(addList);
|
||||
}
|
||||
|
||||
//删除为匹配的历史配置
|
||||
for(SysTabMappingVo item : mappingVoMap.values()){
|
||||
if(!PassedMappingIds.contains(item.getId())){
|
||||
sysImptabmappingMapper.deleteById(item.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存映射表配置列表
|
||||
* @param impList 配置的表格数据
|
||||
*/
|
||||
@Override
|
||||
public void saveMappingList(List<ImptabmappingDto> impList) {
|
||||
public void saveMappingList(List<SysTabMappingVo> impList) {
|
||||
try {
|
||||
if (!CollectionUtils.isEmpty(impList)) {
|
||||
List<SysImptabmapping> list = new ArrayList<>();
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
for (ImptabmappingDto imp : impList) {
|
||||
SysImptabmapping sysImptabmapping = new SysImptabmapping();
|
||||
// 更新记录
|
||||
sysImptabmapping.setId(imp.getId());
|
||||
List<SysTabMapping> list = new ArrayList<>();
|
||||
|
||||
if (imp.getType() == 138 || imp.getType() == 139 || imp.getType() == 140) {
|
||||
// 获取属性编码
|
||||
String code = sysImptabmappingMapper.getAttributeCode(imp.getEquipmentId(), imp.getType(), imp.getName());
|
||||
sysImptabmapping.setEquipmentAttribute(code);
|
||||
} else if (imp.getType() == 146 || imp.getType() == 147) {
|
||||
// 获取动作编码
|
||||
String code = sysImptabmappingMapper.getServiceCode(imp.getEquipmentId(), imp.getType(), imp.getName());
|
||||
sysImptabmapping.setEquipmentService(code);
|
||||
}
|
||||
sysImptabmapping.setUpdatedTime(new Date());
|
||||
sysImptabmapping.setUpdatedBy(sysUserVo.getAccount());
|
||||
sysImptabmapping.setParams(imp.getParams());
|
||||
list.add(sysImptabmapping);
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
for (SysTabMappingVo imp : impList) {
|
||||
SysTabMapping rec = sysImptabmappingMapper.selectById(imp.getId());
|
||||
rec.setUpdatedTime(new Date());
|
||||
rec.setUpdatedBy(sysUserVo.getAccount());
|
||||
rec.setParams(imp.getParams());
|
||||
rec.setRevision(rec.getRevision() + 1);
|
||||
list.add(rec);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
sysImptabmappingMapper.insertOrUpdateBatch(list);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("删除所有记录失败", e);
|
||||
log.error("保存映射表失败", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportMappingList(SysImptabmappingDto sysImptabmappingDto, HttpServletRequest request, HttpServletResponse response) {
|
||||
public void exportMappingList(QueryTabMappingParamDto sysImptabmappingDto, HttpServletRequest request, HttpServletResponse response) {
|
||||
// 根据链路Id获取映射表信息并导出成json文件
|
||||
List<SysImptabmappingVo> list = sysImptabmappingMapper.getMappingInfoList(sysImptabmappingDto.getLinkId());
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<SysTabMappingVo> list = sysImptabmappingMapper.getMappingInfoListByLinkId(sysImptabmappingDto.getLinkId());
|
||||
try {
|
||||
String jsonContent = mapper.writeValueAsString(list);
|
||||
String jsonContent = JSON_MAPPER.writeValueAsString(list);
|
||||
OutputStream os = null;
|
||||
if (response != null) {
|
||||
response.reset();
|
||||
@ -297,48 +354,81 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
@Override
|
||||
public boolean importMappingList(String linkId, MultipartFile file) {
|
||||
boolean flag = false;
|
||||
|
||||
// 先根据链路Id获取已经配置好的映射表信息列表
|
||||
List<SysTabMappingVo> mappingVoList=sysImptabmappingMapper.getMappingInfoListByLinkId(Long.valueOf(linkId));
|
||||
//将已经配置好的映射表,按设备id,测点类型,测点code 做一个map;
|
||||
Map<String,SysTabMappingVo> mappingVoMap = new HashMap<>(mappingVoList.size());
|
||||
for (SysTabMappingVo mappingVo : mappingVoList) {
|
||||
String key = mappingVo.getEquipmentId() + "_" + mappingVo.getMeasPointType() + "_" + mappingVo.getMeasPointCode();
|
||||
mappingVoMap.put(key,mappingVo);
|
||||
}
|
||||
|
||||
//过滤已经存在的记录
|
||||
Set<Long> PassedMappingIds = new HashSet<>();
|
||||
|
||||
try {
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
List<SysImptabmapping> addList = new ArrayList<>();
|
||||
List<SysTabMapping> addList = new ArrayList<>();
|
||||
String content = new BufferedReader(new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))
|
||||
.lines()
|
||||
.reduce("", (accumulator, _item) -> accumulator + _item);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
List<SysImptabmappingVo> list = objectMapper.readValue(content, objectMapper.getTypeFactory().constructCollectionType(List.class, SysImptabmappingVo.class));
|
||||
for (SysImptabmappingVo info : list) {
|
||||
SysImptabmapping newInfo = new SysImptabmapping();
|
||||
List<SysTabMappingVo> list = JSON_MAPPER.readValue(content, JSON_MAPPER.getTypeFactory().constructCollectionType(List.class, SysTabMappingVo.class));
|
||||
for (SysTabMappingVo info : list) {
|
||||
SysTabMapping newInfo = new SysTabMapping();
|
||||
|
||||
String key = info.getEquipmentId() + "_" + info.getMeasPointType() + "_" + info.getMeasPointCode();
|
||||
if(mappingVoMap.containsKey(key)){
|
||||
SysTabMappingVo item = mappingVoMap.get(key);
|
||||
newInfo.setId(item.getId());
|
||||
PassedMappingIds.add(item.getId());
|
||||
}else{
|
||||
newInfo.setId(SequenceUtils.generateId());
|
||||
}
|
||||
|
||||
newInfo.setLinkId(Long.valueOf(linkId));
|
||||
newInfo.setEquipmentAttribute(info.getEquipmentAttribute());
|
||||
newInfo.setEquipmentId(info.getEquipmentId());
|
||||
newInfo.setEquipmentService(info.getEquipmentService());
|
||||
|
||||
newInfo.setMeasPointType(info.getMeasPointType());
|
||||
newInfo.setMeasPointCode(info.getMeasPointCode());
|
||||
newInfo.setMeasPointName(info.getMeasPointName());
|
||||
newInfo.setHighSpeed(info.getHighSpeed());
|
||||
|
||||
newInfo.setParams(info.getParams());
|
||||
newInfo.setPorder(info.getPorder());
|
||||
newInfo.setRevision(1);
|
||||
newInfo.setCreatedTime(new Date());
|
||||
newInfo.setUpdatedTime(new Date());
|
||||
newInfo.setCreatedBy(sysUserVo.getAccount());
|
||||
newInfo.setUpdatedBy(sysUserVo.getAccount());
|
||||
newInfo.setRevision(1);
|
||||
addList.add(newInfo);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(addList)) {
|
||||
sysImptabmappingMapper.insertBatch(addList);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
//删除为匹配的历史配置
|
||||
for(SysTabMappingVo item : mappingVoMap.values()){
|
||||
if(!PassedMappingIds.contains(item.getId())){
|
||||
sysImptabmappingMapper.deleteById(item.getId());
|
||||
}
|
||||
}
|
||||
|
||||
flag = true;
|
||||
} catch (IOException e) {
|
||||
log.error("导入映射表失败 ", e);
|
||||
flag = false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deviceCommand(DeviceCommandDto device) {
|
||||
try {
|
||||
HashMap map = new HashMap<>();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
String cmd = NodeConstant.DEVICE_CONTROL;
|
||||
Long time = System.currentTimeMillis();
|
||||
|
||||
@ -353,7 +443,7 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
}
|
||||
|
||||
// 将 HashMap 转换为 JsonNode
|
||||
ObjectNode jsonNode = objectMapper.convertValue(map, ObjectNode.class);
|
||||
ObjectNode jsonNode = JSON_MAPPER.convertValue(map, ObjectNode.class);
|
||||
TerminalMessage configUpdate = TerminalMessage.builder()
|
||||
.cmd(cmd)
|
||||
.cmdId(String.valueOf(device.getDeviceId()))
|
||||
@ -370,7 +460,6 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
public void deviceSetPoint(DeviceSetPointDto device) {
|
||||
try {
|
||||
HashMap map = new HashMap<>();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String cmd = NodeConstant.DEVICE_CONTROL;
|
||||
Long time = System.currentTimeMillis();
|
||||
|
||||
@ -385,7 +474,7 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
}
|
||||
|
||||
// 将 HashMap 转换为 JsonNode
|
||||
ObjectNode jsonNode = objectMapper.convertValue(map, ObjectNode.class);
|
||||
ObjectNode jsonNode = JSON_MAPPER.convertValue(map, ObjectNode.class);
|
||||
TerminalMessage configUpdate = TerminalMessage.builder()
|
||||
.cmd(cmd)
|
||||
.cmdId(String.valueOf(device.getDeviceId()))
|
||||
@ -413,72 +502,4 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
}
|
||||
return currentActiveNodeId;
|
||||
}
|
||||
|
||||
// 绑定设备的测点信息,不是绑定设备到映射表
|
||||
private void addSysImptabmapping(List<BindEquipmentInfoDto> equipmentId, Long linkId, SysUserVo sysUserVo, List<SysImptabmapping> addList) {
|
||||
|
||||
// 获取设备的测点信息
|
||||
for (BindEquipmentInfoDto info : equipmentId) {
|
||||
List<BaseImptabmappingVo> fieldList = sysEquipmentMapper.getEquipmentAttributeInfo(info.getEquipmentId());
|
||||
// 获取映射表相关信息
|
||||
List<BaseImptabmappingVo> serviceList = sysEquipmentMapper.getEquipmentServiceInfo(info.getEquipmentId());
|
||||
|
||||
if (!CollectionUtils.isEmpty(fieldList)) {
|
||||
for (BaseImptabmappingVo field : fieldList) {
|
||||
List<BaseImptabmappingVo> fieldImpList = sysEquipmentMapper.getAttributeImpInfo(field.getCode(), info.getEquipmentId(), linkId);
|
||||
if (!CollectionUtils.isEmpty(fieldImpList)) {
|
||||
for (BaseImptabmappingVo fieldImp : fieldImpList) {
|
||||
if(field.getCode().equals(fieldImp.getCode())) {
|
||||
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
|
||||
sysImptabmapping.setEquipmentAttribute(field.getCode());
|
||||
sysImptabmapping.setParams(fieldImp.getParams());
|
||||
addList.add(sysImptabmapping);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
|
||||
sysImptabmapping.setEquipmentAttribute(field.getCode());
|
||||
addList.add(sysImptabmapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(serviceList)) {
|
||||
for (BaseImptabmappingVo service : serviceList) {
|
||||
List<BaseImptabmappingVo> serviceImpList = sysEquipmentMapper.getServiceImpInfo(service.getCode(), info.getEquipmentId(), linkId);
|
||||
|
||||
if (!CollectionUtils.isEmpty(serviceImpList)) {
|
||||
for (BaseImptabmappingVo serviceImp : serviceImpList) {
|
||||
if(service.getCode().equals(serviceImp.getCode())) {
|
||||
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
|
||||
sysImptabmapping.setEquipmentService(service.getCode());
|
||||
sysImptabmapping.setParams(serviceImp.getParams());
|
||||
addList.add(sysImptabmapping);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
|
||||
sysImptabmapping.setEquipmentService(service.getCode());
|
||||
addList.add(sysImptabmapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static SysImptabmapping getSysImptabmapping(Long linkId, SysUserVo sysUserVo, BindEquipmentInfoDto info) {
|
||||
SysImptabmapping sysImptabmapping = new SysImptabmapping();
|
||||
sysImptabmapping.setEquipmentId(info.getEquipmentId());
|
||||
sysImptabmapping.setLinkId(linkId);
|
||||
sysImptabmapping.setId(SequenceUtils.generateId());
|
||||
sysImptabmapping.setCreatedTime(new Date());
|
||||
sysImptabmapping.setUpdatedTime(new Date());
|
||||
sysImptabmapping.setCreatedBy(sysUserVo.getAccount());
|
||||
sysImptabmapping.setUpdatedBy(sysUserVo.getAccount());
|
||||
sysImptabmapping.setRevision(1);
|
||||
sysImptabmapping.setPorder(info.getPorder());
|
||||
return sysImptabmapping;
|
||||
}
|
||||
}
|
||||
|
116
das/src/main/resources/mapper/SysImpTabMappingMapper.xml
Normal file
116
das/src/main/resources/mapper/SysImpTabMappingMapper.xml
Normal file
@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.das.modules.node.mapper.SysImpTabMappingMapper">
|
||||
|
||||
<resultMap type="com.das.modules.node.domain.vo.SysTabMappingVo" id="SysImpTabMappingMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
|
||||
<result property="linkId" column="link_id" jdbcType="BIGINT"/>
|
||||
<result property="linkName" column="link_name" jdbcType="VARCHAR"/>
|
||||
|
||||
<result property="equipmentId" column="equipment_id" jdbcType="BIGINT"/>
|
||||
<result property="equipmentName" column="equipment_name" jdbcType="VARCHAR"/>
|
||||
<result property="equipmentCode" column="equipment_code" jdbcType="VARCHAR"/>
|
||||
|
||||
<result property="measPointType" column="meas_point_type" jdbcType="INTEGER"/>
|
||||
<result property="measPointCode" column="meas_point_code" jdbcType="VARCHAR"/>
|
||||
<result property="measPointName" column="meas_point_name" jdbcType="VARCHAR"/>
|
||||
<result property="highSpeed" column="highspeed" jdbcType="INTEGER"/>
|
||||
|
||||
<result property="params" column="params" jdbcType="VARCHAR"/>
|
||||
<result property="porder" column="porder" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.das.modules.node.domain.vo.EquipmentVo" id="EquipmentMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
|
||||
<result property="iotAddr" column="iot_addr" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getMappingInfoListByLinkId" resultMap="SysImpTabMappingMap">
|
||||
select
|
||||
t1.id,
|
||||
t1.link_id,
|
||||
t2.link_name,
|
||||
t1.equipment_id,
|
||||
t3."name" as equipment_name,
|
||||
t3.code as equipment_code,
|
||||
t1.meas_point_type ,
|
||||
t1.meas_point_code ,
|
||||
t1.meas_point_name,
|
||||
t1.highspeed,
|
||||
t1.params ,
|
||||
t1.porder
|
||||
from
|
||||
sys_imptabmapping t1
|
||||
left join sys_communicationlink t2 on t2.id = t1.link_id
|
||||
left join sys_equipment t3 on t3.id = t1.equipment_id
|
||||
where
|
||||
t1.link_id = #{linkId}
|
||||
order by
|
||||
t1.equipment_id ,
|
||||
t1.meas_point_type,
|
||||
t1.porder
|
||||
</select>
|
||||
|
||||
<select id="getMappingInfoListByLinkIdAndType" resultMap="SysImpTabMappingMap">
|
||||
select
|
||||
t1.id,
|
||||
t1.link_id,
|
||||
t2.link_name,
|
||||
t1.equipment_id,
|
||||
t3."name" as equipment_name,
|
||||
t3.code as equipment_code,
|
||||
t1.meas_point_type ,
|
||||
t1.meas_point_code ,
|
||||
t1.meas_point_name,
|
||||
t1.highspeed,
|
||||
t1.params ,
|
||||
t1.porder
|
||||
from
|
||||
sys_imptabmapping t1
|
||||
left join sys_communicationlink t2 on t2.id = t1.link_id
|
||||
left join sys_equipment t3 on t3.id = t1.equipment_id
|
||||
where
|
||||
t1.link_id = #{linkId} and t1.meas_point_type = #{type}
|
||||
order by
|
||||
t1.equipment_id ,
|
||||
t1.meas_point_type,
|
||||
t1.porder
|
||||
</select>
|
||||
|
||||
<select id="getMappingInfoListByLinkIdAndDeviceId" resultMap="SysImpTabMappingMap">
|
||||
select
|
||||
t1.id,
|
||||
t1.link_id,
|
||||
t2.link_name,
|
||||
t1.equipment_id,
|
||||
t3."name" as equipment_name,
|
||||
t3.code as equipment_code,
|
||||
t1.meas_point_type ,
|
||||
t1.meas_point_code ,
|
||||
t1.meas_point_name,
|
||||
t1.highspeed,
|
||||
t1.params ,
|
||||
t1.porder
|
||||
from
|
||||
sys_imptabmapping t1
|
||||
left join sys_communicationlink t2 on t2.id = t1.link_id
|
||||
left join sys_equipment t3 on t3.id = t1.equipment_id
|
||||
where
|
||||
t1.link_id = #{linkId} and t1.equipment_id = #{deviceId}
|
||||
order by
|
||||
t1.equipment_id ,
|
||||
t1.meas_point_type,
|
||||
t1.porder
|
||||
</select>
|
||||
|
||||
<select id="getBindDeviceByLink" resultMap="EquipmentMap">
|
||||
select t.id ,t."name",t.iot_model_id,t.iot_addr from sys_equipment t where t.id in (select distinct equipment_id from sys_imptabmapping where link_id =#{linkId})
|
||||
</select>
|
||||
|
||||
<delete id="deleteMappingByLinkId">
|
||||
delete from sys_imptabmapping where link_id = #{linkId}
|
||||
</delete>
|
||||
</mapper>
|
@ -1,119 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.das.modules.node.mapper.SysImptabmappingMapper">
|
||||
|
||||
<resultMap type="com.das.modules.node.domain.vo.SysImptabmappingVo" id="SysImptabmappingMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="linkId" column="link_id" jdbcType="BIGINT"/>
|
||||
<result property="linkName" column="linkName" jdbcType="VARCHAR"/>
|
||||
<result property="equipmentId" column="equipment_id" jdbcType="BIGINT"/>
|
||||
<result property="equipmentName" column="equipmentName" jdbcType="VARCHAR"/>
|
||||
<result property="equipmentAttribute" column="equipment_attribute" jdbcType="VARCHAR"/>
|
||||
<result property="equipmentService" column="equipment_service" jdbcType="VARCHAR"/>
|
||||
<result property="params" column="params" jdbcType="VARCHAR"/>
|
||||
<result property="iotAddr" column="iot_addr" jdbcType="VARCHAR"/>
|
||||
<result property="porder" column="porder" jdbcType="INTEGER"/>
|
||||
<result property="revision" column="revision" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.das.modules.node.domain.vo.IotModelVo" id="IotModelMap">
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="type" column="type" jdbcType="VARCHAR"/>
|
||||
<result property="params" column="params" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getMappingList" resultType="com.das.modules.node.domain.vo.ImptabmappingVo">
|
||||
select si.id, se."name" as equipmentName,se.code as equipmentCode, simf.attribute_name as name,si.params,se.id as equipmentId,
|
||||
simf.attribute_code as code from sys_imptabmapping si
|
||||
left join sys_equipment se on si.equipment_id = se.id
|
||||
left join sys_iot_model_field simf on si.equipment_attribute = simf.attribute_code and se.iot_model_id = simf.iot_model_id
|
||||
where si.link_id = #{linkId} and simf.attribute_type = #{type}
|
||||
order by simf.porder
|
||||
</select>
|
||||
|
||||
<select id="getMappingControlList" resultType="com.das.modules.node.domain.vo.ImptabmappingVo">
|
||||
select si.id, se."name" as equipmentName,se.code as equipmentCode, sims.service_name as name,si.params,se.id as equipmentId,
|
||||
sims.service_code as code from sys_imptabmapping si
|
||||
left join sys_equipment se on si.equipment_id = se.id
|
||||
left join sys_iot_model_service sims on si.equipment_service = sims.service_code and se.iot_model_id = sims.iot_model_id
|
||||
where si.link_id = #{linkId} and sims.service_type = #{type}
|
||||
order by sims.porder
|
||||
</select>
|
||||
|
||||
<select id="getBindDevice" resultMap="SysImptabmappingMap">
|
||||
select distinct se.id as equipment_id,se."name" as equipmentName, si.porder, se.iot_addr from sys_equipment se
|
||||
left join sys_imptabmapping si on se.id = si.equipment_id
|
||||
where si.link_id = #{linkId} order by si.porder
|
||||
</select>
|
||||
|
||||
|
||||
<delete id="deleteBindDevice" >
|
||||
delete from sys_imptabmapping where link_id = #{linkId}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="getEquipmentId" resultType="java.lang.Long">
|
||||
select distinct si.equipment_id from sys_imptabmapping si
|
||||
left join sys_communicationlink sc on sc.id = si.link_id
|
||||
where sc.id = #{linkId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getIotModelServiceByEquipmentId" resultType="com.das.modules.node.domain.vo.IotModelVo">
|
||||
select sims.service_code as name ,sims.service_type as type ,si.params from sys_imptabmapping si
|
||||
left join sys_equipment se on si.equipment_id = se.id
|
||||
left join sys_iot_model_service sims on se.iot_model_id = sims.iot_model_id
|
||||
where si.equipment_id = #{equipmentId}
|
||||
</select>
|
||||
|
||||
<select id="getIotAddrByEquipmentId" resultType="java.lang.String">
|
||||
select se.iot_addr from sys_equipment se where se.id = #{equipmentId}
|
||||
</select>
|
||||
|
||||
<select id="getAttributeCode" resultType="java.lang.String">
|
||||
select distinct simf.attribute_code from sys_iot_model_field simf
|
||||
left join sys_equipment se on simf.iot_model_id = se.iot_model_id
|
||||
where se.id = #{equipmentId} and simf.attribute_type = #{type} and simf.attribute_name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="getServiceCode" resultType="java.lang.String">
|
||||
select distinct sims.service_code from sys_iot_model_service sims
|
||||
left join sys_equipment se on sims.iot_model_id = se.iot_model_id
|
||||
where se.id = #{equipmentId} and sims.service_type = #{type} and sims.service_name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="getMappingInfoList" resultMap="SysImptabmappingMap">
|
||||
select si.*,se.iot_addr from sys_imptabmapping si
|
||||
left join sys_equipment se on si.equipment_id = se.id
|
||||
where si.link_id = #{linkId}
|
||||
</select>
|
||||
<select id="getIotModelFieldByDeviceId" resultType="com.das.modules.node.domain.vo.IotModelVo">
|
||||
select
|
||||
field.attribute_type as attributeType,
|
||||
null as serviceType,
|
||||
(select iot_addr from sys_equipment e where e.id=1846101273013739522) as iot_addr,
|
||||
field.attribute_code as equipmentAttribute,
|
||||
null as equipmentService,
|
||||
si.params,
|
||||
field.highspeed
|
||||
from sys_iot_model_field field
|
||||
left join sys_imptabmapping si on (field.attribute_code=si.equipment_attribute)
|
||||
where field.iot_model_id = (select equip.iot_model_id from sys_equipment equip where equip.id = #{deviceId}) and si.equipment_id = #{deviceId}
|
||||
order by field.attribute_type ,field.porder
|
||||
</select>
|
||||
<select id="getIotModelServiceByDeviceId" resultType="com.das.modules.node.domain.vo.IotModelVo">
|
||||
select
|
||||
null as attributeType,
|
||||
service.service_type as serviceType,
|
||||
(select iot_addr from sys_equipment e where e.id=1846101273013739522) as iot_addr,
|
||||
null as equipmentAttribute,
|
||||
service.service_code as equipmentService,
|
||||
si.params,
|
||||
null as highspeed
|
||||
from sys_iot_model_service service
|
||||
left join sys_imptabmapping si on (service.service_code=si.equipment_service)
|
||||
where service.iot_model_id = (select equip.iot_model_id from sys_equipment equip where equip.id = #{deviceId}) and si.equipment_id = #{deviceId}
|
||||
order by service.service_type ,service.porder
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -52,5 +52,7 @@
|
||||
where se.id = #{deviceId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectModelFieldListByModelId" resultMap="SysIotModelFieldMap">
|
||||
select * from sys_iot_model_field where iot_model_id = #{iotModelId} order by porder
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -40,4 +40,8 @@
|
||||
<select id="selectByServiceCode" resultMap="SysIotModelServiceMap">
|
||||
select t.* from sys_iot_model_service t where t.iot_model_id = #{iotModelId} and upper(t.service_code) = upper(#{code})
|
||||
</select>
|
||||
|
||||
<select id="selectModelServiceListByModelId" resultMap="SysIotModelServiceMap">
|
||||
select * from sys_iot_model_service where iot_model_id = #{iotModelId} order by porder
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user