das接口修改

This commit is contained in:
chenhaojie 2024-08-12 17:07:13 +08:00
parent c71c03bf55
commit 8c259e6551
7 changed files with 72 additions and 35 deletions

View File

@ -25,5 +25,11 @@ public interface SysEquipmentMapper extends BaseMapperPlus<SysEquipment, SysEqui
void updateIotAddr(Long id, String iotAddr);
// 获取设备的属性信息
List<String> getEquipmentAttributeInfo(Long equipmentId);
// 获取设备的动作信息
List<String> getEquipmentServiceInfo(Long equipmentId);
}

View File

@ -12,5 +12,7 @@ public class BindEquipmentInfoDto {
@JsonSerialize(using = ToStringSerializer.class)
private Long equipmentId;
private Integer porder;
private String iotAddr;
}

View File

@ -21,4 +21,6 @@ public class ImptabmappingDto implements Serializable {
private Integer type;
private String params;
private String name;
}

View File

@ -34,9 +34,9 @@ public interface SysImptabmappingMapper extends BaseMapperPlus<SysImptabmapping,
String getIotAddrByEquipmentId(Long equipmentId);
String getAttributeCode(Long equipmentId, Integer type);
String getAttributeCode(Long equipmentId, Integer type, String name);
String getServiceCode(Long equipmentId, Integer type);
String getServiceCode(Long equipmentId, Integer type, String name);
List<SysImptabmappingVo> getMappingInfoList(Long linkId);
}

View File

@ -72,9 +72,6 @@ public class SysNodeServiceImpl implements SysNodeService {
@Autowired
private SysEquipmentMapper sysEquipmentMapper;
@Autowired
private SysIotModelMapper sysIotModelMapper;
@Autowired
TerminalMessageEventHandler terminalMessageEventHandler;
@ -238,22 +235,20 @@ public class SysNodeServiceImpl implements SysNodeService {
if (imp.getType() == 138 || imp.getType() == 139 || imp.getType() == 140) {
// 获取属性编码
String code = sysImptabmappingMapper.getAttributeCode(imp.getEquipmentId(), imp.getType());
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());
String code = sysImptabmappingMapper.getServiceCode(imp.getEquipmentId(), imp.getType(), imp.getName());
sysImptabmapping.setEquipmentService(code);
}
sysImptabmapping.setUpdatedTime(new Date());
sysImptabmapping.setUpdatedBy(sysUserVo.getAccount());
sysImptabmapping.setLinkId(imp.getLinkId());
sysImptabmapping.setEquipmentId(imp.getEquipmentId());
sysImptabmapping.setParams(String.valueOf(imp.getParams()));
sysImptabmapping.setParams(imp.getParams());
list.add(sysImptabmapping);
}
if (!CollectionUtils.isEmpty(list)) {
sysImptabmappingMapper.updateBatchById(list);
sysImptabmappingMapper.insertOrUpdateBatch(list);
}
}
}
@ -287,7 +282,7 @@ public class SysNodeServiceImpl implements SysNodeService {
public boolean importMappingList(String linkId, MultipartFile file) {
boolean flag = false;
try {
// SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
List<SysImptabmapping> addList = new ArrayList<>();
String content = new BufferedReader(new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8))
.lines()
@ -307,10 +302,8 @@ public class SysNodeServiceImpl implements SysNodeService {
newInfo.setRevision(1);
newInfo.setCreatedTime(new Date());
newInfo.setUpdatedTime(new Date());
// newInfo.setCreatedBy(sysUserVo.getAccount());
// newInfo.setUpdatedBy(sysUserVo.getAccount());
newInfo.setCreatedBy("ceshi");
newInfo.setUpdatedBy("ceshi");
newInfo.setCreatedBy(sysUserVo.getAccount());
newInfo.setUpdatedBy(sysUserVo.getAccount());
addList.add(newInfo);
}
if (!CollectionUtils.isEmpty(addList)) {
@ -352,10 +345,35 @@ public class SysNodeServiceImpl implements SysNodeService {
}
// 绑定设备的测点信息不是绑定设备到映射表
private void addSysImptabmapping(List<BindEquipmentInfoDto> equipmentId, Long linkId, SysUserVo sysUserVo, List<SysImptabmapping> addList) {
int index = 0;
// 获取设备的测点信息
for (BindEquipmentInfoDto info : equipmentId) {
index++;
List<String> fieldList = sysEquipmentMapper.getEquipmentAttributeInfo(info.getEquipmentId());
List<String> serviceList = sysEquipmentMapper.getEquipmentServiceInfo(info.getEquipmentId());
if (!CollectionUtils.isEmpty(fieldList)) {
for (String field : fieldList) {
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
sysImptabmapping.setEquipmentAttribute(field);
addList.add(sysImptabmapping);
}
}
if (!CollectionUtils.isEmpty(serviceList)) {
for (String service : serviceList) {
SysImptabmapping sysImptabmapping = getSysImptabmapping(linkId, sysUserVo, info);
sysImptabmapping.setEquipmentService(service);
addList.add(sysImptabmapping);
}
}
// 更新设备表里面的设备地址
sysEquipmentMapper.updateIotAddr(info.getEquipmentId(), info.getIotAddr());
}
}
private static SysImptabmapping getSysImptabmapping(Long linkId, SysUserVo sysUserVo, BindEquipmentInfoDto info) {
SysImptabmapping sysImptabmapping = new SysImptabmapping();
sysImptabmapping.setEquipmentId(info.getEquipmentId());
sysImptabmapping.setLinkId(linkId);
@ -365,10 +383,7 @@ public class SysNodeServiceImpl implements SysNodeService {
sysImptabmapping.setCreatedBy(sysUserVo.getAccount());
sysImptabmapping.setUpdatedBy(sysUserVo.getAccount());
sysImptabmapping.setRevision(1);
sysImptabmapping.setPorder(index);
addList.add(sysImptabmapping);
// 更新设备表里面的设备地址
sysEquipmentMapper.updateIotAddr(info.getEquipmentId(), info.getIotAddr());
}
sysImptabmapping.setPorder(info.getPorder());
return sysImptabmapping;
}
}

View File

@ -116,4 +116,16 @@
</update>
<select id="getEquipmentAttributeInfo" resultType="java.lang.String">
select 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 = #{id}
</select>
<select id="getEquipmentServiceInfo" resultType="java.lang.String">
select 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 = #{id}
</select>
</mapper>

View File

@ -25,7 +25,7 @@
<select id="getMappingList" resultType="com.das.modules.node.domain.vo.ImptabmappingVo">
select si.id, se."name" as equipmentName, simf.attribute_name as name,si.params,se.id as equipmentId from sys_imptabmapping si
left join sys_equipment se on si.equipment_id = se.id
left join sys_iot_model_field simf on se.iot_model_id = simf.iot_model_id
left join sys_iot_model_field simf on si.equipment_attribute = simf.attribute_code
where si.link_id = #{linkId} and simf.attribute_type = #{type}
order by si.porder
</select>
@ -33,14 +33,14 @@
<select id="getMappingControlList" resultType="com.das.modules.node.domain.vo.ImptabmappingVo">
select si.id, se."name" as equipmentName, sims.service_name as name,si.params,se.id as equipmentId 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
left join sys_iot_model_service sims on si.equipment_service = sims.service_code
where si.link_id = #{linkId} and sims.service_type = #{type}
order by si.porder
</select>
<select id="getBindDevice" resultMap="SysImptabmappingMap">
select se.id as equipment_id,se."name" as equipmentName, si.porder, se.iot_addr from sys_imptabmapping si
left join sys_equipment se on se.id = si.equipment_id
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>
@ -79,13 +79,13 @@
<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}
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}
where se.id = #{equipmentId} and sims.service_type = #{type} and sims.service_name = #{name}
</select>
<select id="getMappingInfoList" resultMap="SysImptabmappingMap">