This commit is contained in:
houwei 2024-10-28 13:09:38 +08:00
commit 53b95f748f
22 changed files with 699 additions and 496 deletions

View File

@ -109,6 +109,9 @@ public class EquipmentController {
*/ */
@PostMapping("/list") @PostMapping("/list")
public R<List<SysEquipmentVo>> queryAllSysEquipmentList(@RequestBody SysEquipmentDto sysEquipmentDto) { public R<List<SysEquipmentVo>> queryAllSysEquipmentList(@RequestBody SysEquipmentDto sysEquipmentDto) {
if (sysEquipmentDto.getObjectType() == null) {
throw new ServiceException("参数缺失");
}
return R.success(sysEquipmentService.queryAllSysEquipmentList(sysEquipmentDto)); return R.success(sysEquipmentService.queryAllSysEquipmentList(sysEquipmentDto));
} }

View File

@ -93,7 +93,10 @@ public class SysIotModelController {
/** 获取物模型属性列表 */ /** 获取物模型属性列表 */
@PostMapping("/attribute/list") @PostMapping("/attribute/list")
public PageDataInfo<SysIotModelFieldVo> querySysIotModelField(@RequestBody SysIotModelFieldDto sysIotModelFieldDto) { public PageDataInfo<SysIotModelFieldVo> querySysIotModelField(@RequestBody SysIotModelFieldDto sysIotModelFieldDto) {
if (sysIotModelFieldDto.getPageNum() == null && sysIotModelFieldDto.getPageSize() == null){
List<SysIotModelFieldVo> sysIotModelFieldVos = sysIotModelService.queryAllModelField(sysIotModelFieldDto);
return PageDataInfo.build(sysIotModelFieldVos,sysIotModelFieldVos.size());
}
return sysIotModelService.querySysIotModelField(sysIotModelFieldDto); return sysIotModelService.querySysIotModelField(sysIotModelFieldDto);
} }

View File

@ -18,6 +18,8 @@ public interface SysIotModelFieldMapper extends BaseMapperPlus<SysIotModelField,
Long querySysIotModelFieldByModelId(Long id); Long querySysIotModelFieldByModelId(Long id);
List<SysIotModelFieldVo> querySysIotModelFieldList(@Param("info") SysIotModelFieldDto sysIotModelFieldDto);
SysIotModelFieldVo selectByAttributeCode(Long iotModelId, String code); SysIotModelFieldVo selectByAttributeCode(Long iotModelId, String code);
List<String> queryAllFiledNames(@Param("deviceId") Long deviceId); List<String> queryAllFiledNames(@Param("deviceId") Long deviceId);

View File

@ -25,6 +25,8 @@ public interface SysIotModelService {
PageDataInfo<SysIotModelFieldVo> querySysIotModelField(SysIotModelFieldDto sysIotModelFieldDto); PageDataInfo<SysIotModelFieldVo> querySysIotModelField(SysIotModelFieldDto sysIotModelFieldDto);
List<SysIotModelFieldVo> queryAllModelField(SysIotModelFieldDto sysIotModelFieldDto);
SysIotModelFieldVo creatSysIotModelField(SysIotModelFieldDto sysIotModelFieldDto); SysIotModelFieldVo creatSysIotModelField(SysIotModelFieldDto sysIotModelFieldDto);
SysIotModelFieldVo updateSysIotModelField(SysIotModelFieldDto sysIotModelFieldDto); SysIotModelFieldVo updateSysIotModelField(SysIotModelFieldDto sysIotModelFieldDto);

View File

@ -125,8 +125,12 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
public List<SysEquipmentVo> queryAllSysEquipmentList(SysEquipmentDto sysEquipmentDto) { public List<SysEquipmentVo> queryAllSysEquipmentList(SysEquipmentDto sysEquipmentDto) {
// 查询当前账号机构下的子机构和子设备 // 查询当前账号机构下的子机构和子设备
QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>(); QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();
if (sysEquipmentDto.getOrgId() !=null){
queryWrapper.eq("org_id", sysEquipmentDto.getOrgId()); queryWrapper.eq("org_id", sysEquipmentDto.getOrgId());
}
if (sysEquipmentDto.getParentEquipmentId() !=null){
queryWrapper.eq("parent_equipment_id", sysEquipmentDto.getParentEquipmentId()); queryWrapper.eq("parent_equipment_id", sysEquipmentDto.getParentEquipmentId());
}
queryWrapper.eq("object_type", sysEquipmentDto.getObjectType()); queryWrapper.eq("object_type", sysEquipmentDto.getObjectType());
queryWrapper.orderByAsc("name"); queryWrapper.orderByAsc("name");
List<SysEquipment> sysEquipmentList = sysEquipmentMapper.selectList(queryWrapper); List<SysEquipment> sysEquipmentList = sysEquipmentMapper.selectList(queryWrapper);

View File

@ -38,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Service @Service
@ -143,6 +144,11 @@ public class SysIotModelServiceImpl implements SysIotModelService {
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal()); return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
} }
@Override
public List<SysIotModelFieldVo> queryAllModelField(SysIotModelFieldDto sysIotModelFieldDto) {
return sysIotModelFieldMapper.querySysIotModelFieldList(sysIotModelFieldDto);
}
@Override @Override
public SysIotModelFieldVo creatSysIotModelField(SysIotModelFieldDto sysIotModelFieldDto) { public SysIotModelFieldVo creatSysIotModelField(SysIotModelFieldDto sysIotModelFieldDto) {
SysIotModelField sysIotModelField = new SysIotModelField(); SysIotModelField sysIotModelField = new SysIotModelField();
@ -333,9 +339,11 @@ public class SysIotModelServiceImpl implements SysIotModelService {
} }
} catch (Exception e) { } catch (Exception e) {
log.error("导入物模型异常:" + e.getMessage()); log.error("导入物模型异常:" + e.getMessage());
throw new ServiceException("导入物模型异常:" + e.getMessage());
} }
} }
private void saveIotModelServiceInfo(String iotModelId, List<List<Object>> list) { private void saveIotModelServiceInfo(String iotModelId, List<List<Object>> list) {
List<SysIotModelServices> sysIotModelServiceList = new ArrayList<>(); List<SysIotModelServices> sysIotModelServiceList = new ArrayList<>();
List<SysIotModelServices> updateSysIotModelServiceList = new ArrayList<>(); List<SysIotModelServices> updateSysIotModelServiceList = new ArrayList<>();
@ -417,47 +425,76 @@ public class SysIotModelServiceImpl implements SysIotModelService {
} }
} }
if (CollectionUtils.isNotEmpty(sysIotModelFieldList)) { if (CollectionUtils.isNotEmpty(sysIotModelFieldList)) {
//创建td表结构
//分为高频低频两个list创建
List<SysIotModelField> lowCreateList = sysIotModelFieldList.stream().filter(item -> item.getHighSpeed() == 0).collect(Collectors.toList());
List<SysIotModelField> highCreateList = sysIotModelFieldList.stream().filter(item -> item.getHighSpeed() == 1).collect(Collectors.toList());
for (int i = 0; i < lowCreateList.size(); i++) {
if (i == 0) {
createTdStableOrColumn(lowCreateList.get(i));
} else {
SysIotModelField sysIotModelField = lowCreateList.get(i);
//stable已经存在,新增stable列
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
Map<String, String> map = new HashMap<>();
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建低频超级表
tdEngineService.addStableColumn(sysIotModel.getIotModelCode(), "l_", map);
}
}
for (int i = 0; i < highCreateList.size(); i++) {
if (i == 0) {
createTdStableOrColumn(highCreateList.get(i));
} else {
SysIotModelField sysIotModelField = highCreateList.get(i);
//stable已经存在,新增stable列
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
Map<String, String> map = new HashMap<>();
map.put(sysIotModelField.getAttributeCode(), sysIotModelField.getDataType());
//创建高频超级表
tdEngineService.addStableColumn(sysIotModel.getIotModelCode(), "h_", map);
}
}
//新增pg数据库
sysIotModelFieldMapper.insertBatch(sysIotModelFieldList); sysIotModelFieldMapper.insertBatch(sysIotModelFieldList);
// ListUtil.page(sysIotModelFieldList, COMMIT_COUNT, create -> {
// for (SysIotModelField item : create){
// createTdStableOrColumn(item);
// }
// });
} }
if (CollectionUtils.isNotEmpty(updateSysIotModelFieldList)) { if (CollectionUtils.isNotEmpty(updateSysIotModelFieldList)) {
// ListUtil.page(updateSysIotModelFieldList, COMMIT_COUNT, update -> { for (SysIotModelField item : updateSysIotModelFieldList) {
// for (SysIotModelField item : update){ SysIotModelField oldSysIotField = sysIotModelFieldMapper.selectById(item.getId());
// SysIotModelField oldSysIotField = sysIotModelFieldMapper.selectById(item.getId()); if (oldSysIotField != null) {
// if (oldSysIotField != null){ if (!oldSysIotField.getAttributeCode().equals(item.getAttributeCode()) && oldSysIotField.getDataType().equals(item.getDataType()) && Objects.equals(oldSysIotField.getHighSpeed(), item.getHighSpeed())) {
// if (!oldSysIotField.getAttributeCode().equals(item.getAttributeCode()) && oldSysIotField.getDataType().equals(item.getDataType()) && Objects.equals(oldSysIotField.getHighSpeed(), item.getHighSpeed())){ //更新td表结构
// //更新td表结构 updateTDStableOrColumn(item, oldSysIotField);
// updateTDStableOrColumn(item,oldSysIotField); }
// } }
// } }
// }
// });
sysIotModelFieldMapper.updateBatchById(updateSysIotModelFieldList); sysIotModelFieldMapper.updateBatchById(updateSysIotModelFieldList);
} }
if (CollectionUtils.isNotEmpty(delSysIotModelFieldList)) { if (CollectionUtils.isNotEmpty(delSysIotModelFieldList)) {
// ListUtil.page(updateSysIotModelFieldList, COMMIT_COUNT, delete -> { //循环删除td表结构
// for (SysIotModelField item : delete){ //分为高频低频两个list创建
// deleteTDStableOrColumn(item); for (SysIotModelField item : delSysIotModelFieldList) {
// } deleteTDStableOrColumn(item);
// }); sysIotModelFieldMapper.deleteById(item);
sysIotModelFieldMapper.deleteBatchIds(delSysIotModelFieldList); }
} }
} }
private static void buildFieldInfo(String iotModelId, List<Object> row, SysIotModelField field) { private static void buildFieldInfo(String iotModelId, List<Object> row, SysIotModelField field) {
if (row.get(3).equals("") || row.get(4).equals("") || row.get(5).equals("") || row.get(7).equals("") || row.get(9).equals("") || row.get(11).equals("")) {
throw new ServiceException("字段不可为空请检查excel文件{}" + row);
}
field.setAttributeCode(row.get(3).toString().toLowerCase()); field.setAttributeCode(row.get(3).toString().toLowerCase());
field.setAttributeName(row.get(4).toString()); field.setAttributeName(row.get(4).toString());
field.setAttributeType(Integer.valueOf(row.get(5).toString())); field.setAttributeType(Integer.valueOf(row.get(5).toString()));
field.setUnit(row.get(6).toString()); field.setUnit(row.get(6).equals("") ? null : row.get(6).toString());
field.setPorder(Integer.valueOf(row.get(7).toString())); field.setPorder(Integer.valueOf(row.get(7).toString()));
field.setSubSystem(row.get(8).toString()); field.setSubSystem(row.get(8).equals("") ? null : row.get(8).toString());
field.setDataType(row.get(9).toString()); field.setDataType(row.get(9).toString());
field.setVisible(Integer.valueOf(row.get(10).toString())); field.setVisible(row.get(10).equals("") ? null : Integer.valueOf(row.get(10).toString()));
field.setHighSpeed(Integer.valueOf(row.get(11).toString())); field.setHighSpeed(Integer.valueOf(row.get(11).toString()));
field.setIotModelId(Long.valueOf(iotModelId)); field.setIotModelId(Long.valueOf(iotModelId));
} }

View File

@ -61,7 +61,6 @@ public class TDEngineService {
/** /**
* 创建超级表 * 创建超级表
*/ */
@Async
public void createStable(String iotModelCode, String stableType, Map<String, String> fieldNameTypeMap) { public void createStable(String iotModelCode, String stableType, Map<String, String> fieldNameTypeMap) {
try (Connection conn = hikariDataSource.getConnection(); try (Connection conn = hikariDataSource.getConnection();
Statement pstmt = conn.createStatement()) { Statement pstmt = conn.createStatement()) {
@ -95,7 +94,6 @@ public class TDEngineService {
/** /**
* 新增超级表列 * 新增超级表列
*/ */
@Async
public void addStableColumn(String iotModelCode, String stableType, Map<String, String> fieldNameTypeMap) { public void addStableColumn(String iotModelCode, String stableType, Map<String, String> fieldNameTypeMap) {
try (Connection conn = hikariDataSource.getConnection(); try (Connection conn = hikariDataSource.getConnection();
Statement pstmt = conn.createStatement()) { Statement pstmt = conn.createStatement()) {
@ -126,7 +124,6 @@ public class TDEngineService {
/** /**
* 删除超级表列 * 删除超级表列
*/ */
@Async
public void deleteColumn(String stableName, String fieldCode) { public void deleteColumn(String stableName, String fieldCode) {
try (Connection conn = hikariDataSource.getConnection(); try (Connection conn = hikariDataSource.getConnection();
Statement pstmt = conn.createStatement()) { Statement pstmt = conn.createStatement()) {
@ -152,7 +149,6 @@ public class TDEngineService {
/** /**
* 删除超级表 * 删除超级表
*/ */
@Async
public void deleteStable(String stableName) { public void deleteStable(String stableName) {
try (Connection conn = hikariDataSource.getConnection(); try (Connection conn = hikariDataSource.getConnection();
Statement pstmt = conn.createStatement()) { Statement pstmt = conn.createStatement()) {

View File

@ -235,7 +235,6 @@ public class DataServiceImpl implements DataService {
@Override @Override
public void handleData(TerminalMessage data) { public void handleData(TerminalMessage data) {
// 先从redis里面获取设备的初始化数据
JsonNode jsonNode = data.getData(); JsonNode jsonNode = data.getData();
String deviceId = jsonNode.get("deviceId").asText(); String deviceId = jsonNode.get("deviceId").asText();
JsonNode values = jsonNode.get("values"); JsonNode values = jsonNode.get("values");
@ -249,25 +248,6 @@ public class DataServiceImpl implements DataService {
keyValueMap.put(key,values.get(fieldName)); keyValueMap.put(key,values.get(fieldName));
} }
adminRedisTemplate.mSet(keyValueMap); adminRedisTemplate.mSet(keyValueMap);
// Long dataTime = data.getTime();
//
// // 存入td库
// List<RTData> highList = new ArrayList<>();
// List<RTData> lowList = new ArrayList<>();
// RTData rtHighData = RTData.builder()
// .dataTime(dataTime)
// .deviceId(Long.valueOf(deviceId))
// .values(highFieldMap)
// .build();
// RTData rtLowData = RTData.builder()
// .dataTime(dataTime)
// .deviceId(Long.valueOf(deviceId))
// .values(highFieldMap)
// .build();
// highList.add(rtHighData);
// lowList.add(rtLowData);
// tdEngineService.updateYCHighValues(highList, iotModelCode);
// tdEngineService.updateYCLowValues(lowList, iotModelCode);
} }
@Override @Override

View File

@ -2,8 +2,10 @@ package com.das.modules.node.service.impl;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.das.common.config.SessionUtil; import com.das.common.config.SessionUtil;
import com.das.common.exceptions.ServiceException;
import com.das.common.utils.BeanCopyUtils; import com.das.common.utils.BeanCopyUtils;
import com.das.common.utils.PageDataInfo; import com.das.common.utils.PageDataInfo;
import com.das.common.utils.PageQuery; import com.das.common.utils.PageQuery;
@ -448,13 +450,14 @@ public class SysNodeServiceImpl implements SysNodeService {
ObjectNode jsonNode = JSON_MAPPER.convertValue(map, ObjectNode.class); ObjectNode jsonNode = JSON_MAPPER.convertValue(map, ObjectNode.class);
TerminalMessage configUpdate = TerminalMessage.builder() TerminalMessage configUpdate = TerminalMessage.builder()
.cmd(cmd) .cmd(cmd)
.cmdId(String.valueOf(device.getDeviceId())) .cmdId(IdUtil.nanoId())
.time(time) .time(time)
.data(jsonNode) .data(jsonNode)
.build(); .build();
terminalMessageEventHandler.sendTerminalMessageWithResult(activeNodeId, configUpdate); terminalMessageEventHandler.sendTerminalMessageWithResult(activeNodeId, configUpdate);
} catch (Exception e) { } catch (Exception e) {
log.error("设备控制失败 ", e); log.error("设备控制失败 ", e);
throw new ServiceException("设备控制失败 "+ e);
} }
} }
@ -479,7 +482,7 @@ public class SysNodeServiceImpl implements SysNodeService {
ObjectNode jsonNode = JSON_MAPPER.convertValue(map, ObjectNode.class); ObjectNode jsonNode = JSON_MAPPER.convertValue(map, ObjectNode.class);
TerminalMessage configUpdate = TerminalMessage.builder() TerminalMessage configUpdate = TerminalMessage.builder()
.cmd(cmd) .cmd(cmd)
.cmdId(String.valueOf(device.getDeviceId())) .cmdId(IdUtil.nanoId())
.time(time) .time(time)
.data(jsonNode) .data(jsonNode)
.build(); .build();

View File

@ -1,5 +1,7 @@
package com.das.modules.page.domian; package com.das.modules.page.domian;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data; import lombok.Data;
import java.util.Map; import java.util.Map;
@ -7,10 +9,14 @@ import java.util.Map;
@Data @Data
public class WindTurbinesPageVo { public class WindTurbinesPageVo {
@JsonSerialize(using = ToStringSerializer.class)
private Long irn; private Long irn;
private String name; private String name;
@JsonSerialize(using = ToStringSerializer.class)
private Long modelId;
private String model; private String model;
private String belongLine; private String belongLine;

View File

@ -1,5 +1,6 @@
package com.das.modules.page.service; package com.das.modules.page.service;
import com.das.common.exceptions.ServiceException;
import com.das.modules.data.domain.SnapshotValueQueryParam; import com.das.modules.data.domain.SnapshotValueQueryParam;
import com.das.modules.data.service.DataService; import com.das.modules.data.service.DataService;
import com.das.modules.equipment.mapper.SysEquipmentMapper; import com.das.modules.equipment.mapper.SysEquipmentMapper;
@ -77,7 +78,13 @@ public class WindTurbinesPageService {
public void windTurbinesControl(List<DeviceCommandDto> controlList){ public void windTurbinesControl(List<DeviceCommandDto> controlList){
for (DeviceCommandDto item : controlList){ for (DeviceCommandDto item : controlList){
try {
sysNodeService.deviceCommand(item); sysNodeService.deviceCommand(item);
}catch (Exception e){
log.error("下控失败",e);
throw new ServiceException("下控失败"+e);
}
} }
} }
} }

View File

@ -166,7 +166,7 @@
select distinct belong_line as name from sys_equipment t where t.object_type = 10002 and belong_line !=''; select distinct belong_line as name from sys_equipment t where t.object_type = 10002 and belong_line !='';
</select> </select>
<select id="queryAllWindList" resultType="com.das.modules.page.domian.WindTurbinesPageVo"> <select id="queryAllWindList" resultType="com.das.modules.page.domian.WindTurbinesPageVo">
select se.id as irn,se.name,se.model,se.belong_line as belongLine from sys_equipment se where se.object_type = #{objectType} select se.id as irn,se.name,se.model,se.belong_line as belongLine, se.iot_model_id as modelId from sys_equipment se where se.object_type = #{objectType} order by se.name
</select> </select>

View File

@ -28,6 +28,10 @@
<if test="info.orderColumn != null and info.orderType != ''"> <if test="info.orderColumn != null and info.orderType != ''">
order by ${info.orderColumn} ${info.orderType} order by ${info.orderColumn} ${info.orderType}
</if> </if>
<if test="info.attributeType != null and info.attributeType != ''">
and t.attribute_type = #{info.attributeType}
</if>
<if test="info.orderColumn == null or info.orderColumn == '' or info.orderType == null or info.orderType == ''"> <if test="info.orderColumn == null or info.orderColumn == '' or info.orderType == null or info.orderType == ''">
order by t.porder asc order by t.porder asc
</if> </if>

View File

@ -5,7 +5,7 @@
- [节点管理接口](api/node.md) - [节点管理接口](api/node.md)
- [数据访问接口](api/data.md) - [数据访问接口](api/data.md)
- [页面访问接口](api/pages/) - [页面访问接口](api/pages/)
- [首页](api/pages/home.md) - [首页接口](api/pages/home.md)
- [数据采集](datacollect/) - [数据采集](datacollect/)
- [系统部署](deploy/) - [系统部署](deploy/)
- [Linux系统部署](deploy/linux.md) - [Linux系统部署](deploy/linux.md)

View File

@ -245,15 +245,22 @@ POST 请求接口
```json ```json
{ {
"iotModelId":"123" "iotModelId":"123",
"pageNum":1,
"pageSize": 30
} }
``` ```
入参描述 入参描述
| 参数名 | 参数类型 | 可选 | 描述 | | 参数名 | 参数类型 | 可选 | 描述 |
| ---------- | -------- | ---- | -------- | | ---------- | -------- |-----|-------|
| iotModelId | String | No | 物模型ID | | iotModelId | String | yes | 物模型ID |
| attributeName | String | yes | 属性名称 |
| attributeCode | String | yes | 属性编码 |
| attributeType | String | yes | 量测类型 |
| pageSize | 数值 | No | 每页显示条数 |
| pageNum | 数值 | No | 页码 |
返回报文 返回报文
@ -672,10 +679,10 @@ POST请求接口
入参描述 入参描述
| 参数名 | 参数类型 | 可选 | 描述 | | 参数名 | 参数类型 | 可选 | 描述 |
| ----------- | -------- | ---- | -------------------------- | | ----------- | -------- |-----| -------------------------- |
| orgId | 数值 | No | 所属机构ID | | orgId | 数值 | yes | 所属机构ID |
| parentEquipmentId | 数值 | No | 上级设备ID | | parentEquipmentId | 数值 | yes | 上级设备ID |
| iotModelId | 字符串 | No | 所属物模型ID | | iotModelId | 字符串 | yes | 所属物模型ID |
| pageSize | 数值 | No | 每页显示条数 | | pageSize | 数值 | No | 每页显示条数 |
| pageNum | 数值 | No | 页码 | | pageNum | 数值 | No | 页码 |

View File

@ -295,3 +295,47 @@ PS: 同一节点只允许建立一条连接。
"opValue": 1 "opValue": 1
} }
``` ```
### 事件上报命令
采集程序向系统上报变位、越限事件
?> 方向: `采集程序` -> `系统`
**命令:** `deviceEvent`
**数据体:**
```json
[
{
//设备ID
"deviceId": "112345123546",
//设备属性编码
"attrCode": "stop",
//属性值
"attrValue": 0,
//事件类型 ( 0-遥信变位 1-越上限 2-越下限)
"eventType": 0,
//事件发生时刻
"eventTime": 12321351235123,
//限值
"limitValue": null
},
{
//设备ID
"deviceId": "112345123546",
//设备属性编码
"attrCode": "Ia",
//属性值
"attrValue": 12350,
//事件类型 ( 0-遥信变位 1-越上限 2-越下限)
"eventType": 0,
//事件发生时刻
"eventTime": 12321351235123,
//限值
"limitValue": 50
}
]
```

View File

@ -20,7 +20,7 @@ export const runAirBlowerReq = (data: {
opValue: 1 | 0 opValue: 1 | 0
}[]) => { }[]) => {
return createAxios({ return createAxios({
url: '/windTurbinesControl', url: '/api/page/turbines/windTurbinesControl',
method: 'post', method: 'post',
data: data data: data
}) })

View File

@ -120,7 +120,7 @@ export const saveMappingListReq = (data: any) => {
export const bindDeviceMeasReq = (data: any) => { export const bindDeviceMeasReq = (data: any) => {
return createAxios({ return createAxios({
url: '/api/node/link/bindDeviceMeas', url: '/api/node/link/bindDevices',
method: 'post', method: 'post',
data: data, data: data,
}) })

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,14 @@
</div> </div>
</el-header> </el-header>
<el-main class="mainPart"> <el-main class="mainPart">
<el-table :column="tableColumn" :data="tableData" :header-row-style="tableHaderStyle" @selectionChange="selectTable" height="100%"> <el-table
ref="tableRef"
:column="tableColumn"
:data="tableData"
:header-row-style="tableHaderStyle"
@selectionChange="selectTable"
height="100%"
>
<el-table-column type="selection" width="55"></el-table-column> <el-table-column type="selection" width="55"></el-table-column>
<template v-for="item in tableColumn" :key="item.prop"> <template v-for="item in tableColumn" :key="item.prop">
<el-table-column <el-table-column
@ -101,7 +108,7 @@
<div>{{ scope.row[item.prop] }}</div> <div>{{ scope.row[item.prop] }}</div>
</template> </template>
<template v-if="item.prop === 'name'" #default="scope"> <template v-if="item.prop === 'name'" #default="scope">
<div class="tableColumnClick">{{ scope.row[item.prop] }}</div> <div class="tableColumnClick" @click="openWindTurbine(scope.row)">{{ scope.row[item.prop] }}</div>
</template> </template>
</el-table-column> </el-table-column>
</template> </template>
@ -113,10 +120,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { SelectTypeObjType, SelectTypeKeyUnionType, TableDataObjType, TableColumnType } from './type' import { SelectTypeObjType, SelectTypeKeyUnionType, TableDataObjType, TableColumnType } from './type'
import { reactive, ref, watch } from 'vue' import { onUnmounted, reactive, ref, watch, nextTick } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { getAirBlowerListReq, getBelongLineListReq, runAirBlowerReq } from '/@/api/backend/airBlower/request' import { getAirBlowerListReq, getBelongLineListReq, runAirBlowerReq } from '/@/api/backend/airBlower/request'
import { ElMessage } from 'element-plus' import { ElMessage, TableInstance } from 'element-plus'
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()
const { t } = useI18n() const { t } = useI18n()
@ -297,6 +307,7 @@ const tableColumn: TableColumnType[] = [
}, },
] ]
const tableRef = ref<TableInstance>()
const tableData = ref<TableDataObjType[]>([]) const tableData = ref<TableDataObjType[]>([])
const originTableData = ref<TableDataObjType[]>([]) const originTableData = ref<TableDataObjType[]>([])
const getTableData = () => { const getTableData = () => {
@ -350,6 +361,14 @@ const getTableData = () => {
}) })
tableData.value = result tableData.value = result
} }
if (selectList.value.length) {
const selected = tableData.value.filter((item) => selectList.value.includes(item.irn))
selected.forEach((item) => {
nextTick(() => {
tableRef.value?.toggleRowSelection(item, true)
})
})
}
}) })
.catch((err: any) => { .catch((err: any) => {
console.log(err) console.log(err)
@ -394,6 +413,33 @@ watch(autoUpdate, (newVal: boolean) => {
} }
}) })
const openWindTurbine = (row: TableDataObjType) => {
if (!router.hasRoute('windTurbine')) {
router.addRoute('admin', {
path: '/windTurbine',
name: 'windTurbine',
component: () => import('/@/views/backend/WindBlower/index.vue'),
meta: {
title: '单风机详情',
menuDesc: '单风机详情',
addtab: true,
},
})
}
console.log(router.getRoutes())
router.push({
name: 'windTurbine',
query: {
irn: row.irn,
},
})
}
onUnmounted(() => {
autoUpdateInterval.value && clearInterval(autoUpdateInterval.value)
autoUpdateInterval.value = null
})
getTableData() getTableData()
getBlongLineList() getBlongLineList()
</script> </script>

View File

@ -155,8 +155,10 @@ const getCompleteData = () => {
return getRealValueList({ deviceId: props.deviceId, attributes: codeList }, data) return getRealValueList({ deviceId: props.deviceId, attributes: codeList }, data)
}) })
.then((realData: any) => { .then((realData: any) => {
console.log(realData)
const data = realData.list.map((item: any) => { const data = realData.list.map((item: any) => {
const realValItem = realData.realVal[props.deviceId]?.[item.attributeCode] const realValItem = realData.realVal[props.deviceId]?.[item.attributeCode?.toLowerCase()]
return { return {
...item, ...item,
realTimeValue: realValItem ? (realValItem % 1 === 0 ? realValItem : realValItem.toFixed(3)) : '-', realTimeValue: realValItem ? (realValItem % 1 === 0 ? realValItem : realValItem.toFixed(3)) : '-',
@ -205,25 +207,30 @@ const openChart = (data: any) => {}
watch( watch(
() => props.show, () => props.show,
(newVal) => { (newVal) => {
newVal && getCompleteData() if (newVal) {
getCompleteData()
} else {
autoUpdateTimer.value && clearInterval(autoUpdateTimer.value)
autoUpdateTimer.value = null
}
}, },
{ {
immediate: true, immediate: true,
} }
) )
let autoUpdateTimer: any = null const autoUpdateTimer: any = ref(null)
watch( watch(
() => props.autoUpdate, () => props.autoUpdate,
(newVal) => { (newVal) => {
if (newVal) { if (newVal) {
if (!autoUpdateTimer) { if (!autoUpdateTimer.value) {
autoUpdateTimer = setInterval(() => { autoUpdateTimer.value = setInterval(() => {
getCompleteData() getCompleteData()
}, 2000) }, 2000)
} }
} else { } else {
clearInterval(autoUpdateTimer) clearInterval(autoUpdateTimer.value)
autoUpdateTimer = null autoUpdateTimer.value = null
} }
} }
) )

View File

@ -334,13 +334,14 @@ const okEdit = (data: any) => {
const submitcorrectionDevice = () => { const submitcorrectionDevice = () => {
const bindDevice = correctionDevice.value.map((item: any, index) => { const bindDevice = correctionDevice.value.map((item: any, index) => {
return { return {
equipmentId: item.id, id: item.id,
iotAddr: item.iotAddr, iotAddr: item.iotAddr,
porder: index + 1, name: item.name,
iotModelId: item.iotModelId,
} }
}) })
bindDeviceMeasReq({ equipmentId: bindDevice, linkId: route.query.id }).then((res) => { bindDeviceMeasReq({ equipmentList: bindDevice, linkId: route.query.id }).then((res) => {
ElMessage.success('关联成功!') ElMessage.success('关联成功!')
closecorrectionDevice() closecorrectionDevice()
resetExcel() resetExcel()
@ -379,10 +380,10 @@ const getBindDeviceTree = () => {
if (res.data) { if (res.data) {
correctionDevice.value = res.data.map((item: any) => { correctionDevice.value = res.data.map((item: any) => {
return { return {
id: item.equipmentId, id: item.id,
name: item.equipmentName, name: item.name,
iotAddr: item.iotAddr, iotAddr: item.iotAddr,
porder: item.porder, iotModelId: item.iotModelId,
} }
}) })
} }