Merge remote-tracking branch 'origin/breach-zhy'

# Conflicts:
#	ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/PlcDeviceController.java
#	ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/PlcDeviceService.java
#	ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/PlcDeviceServiceImpl.java
#	ruoyi-ui/src/views/plc/plcEquipment/index.vue
#	ruoyi-ui/src/views/plc/plcModel/index.vue
master
xs 6 months ago
commit 2716401586

@ -20,4 +20,10 @@ public interface RemoteBusinessService {
*/
@GetMapping("/device/computeOnlineDevicecCount/{days}")
public R<?> computeOnlineDevicecCount(@PathVariable("days") int days, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@GetMapping("/plcDevice/modbusDataProcess")
public R<?> modbusDataProcess(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@GetMapping("/plcDevice/mcDataProcess")
public R<?> mcDataProcess(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

@ -32,7 +32,9 @@ public class TdEngineConstants {
// public static final String DEFAULT_DB_NAME_PREFIX = "db_scene_";//数据库名称前缀
public static final String DEFAULT_SUPER_TABLE_NAME_PREFIX = "st_devicemode_";//超级表名称前缀
public static final String PLC_SUPER_TABLE_NAME_PREFIX = "plc_";//plc超级表名称前缀
public static final String DEFAULT_TABLE_NAME_PREFIX = "t_device_";//数据表名称前缀
public static final String PLC_TABLE_NAME_PREFIX = "plc_device_";//plc数据表名称前缀
public static final String DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME= "st_ds";//设备状态超级表名称
public static final String DEFAULT_DEVICE_STATUS_TABLE_NAME_PREFIX = "t_ds_";//设备状态数据表名称前缀
@ -43,6 +45,14 @@ public class TdEngineConstants {
public static final int ST_TAG_DEVICECODE_TYPE = 10;
public static final int ST_TAG_DEVICECODE_SIZE=50;
public static final String PLC_TAG_IP = "IP";
public static final int PLC_TAG_IP_TYPE = 10;
public static final int PLC_TAG_IP_SIZE=100;
public static final String PLC_TAG_LOCATION = "dlocation";
public static final int PLC_TAG_LOCATION_TYPE = 10;
public static final int PLC_TAG_LOCATION_SIZE=50;
public static final String ST_TAG_DEVICENAME = "devicename";
public static final String ST_TAG_DEVICETYPE = "devicetype";
@ -53,6 +63,9 @@ public class TdEngineConstants {
public static final String ST_TAG_DEVICEID = "deviceid";
public static final int ST_TAG_DEVICEID_TYPE = 2;
public static final String PLC_TAG_PORT = "PORT1";
public static final int PLC_TAG_PORT_TYPE = 2;
public static final String ST_TAG_DEVICEMODEID = "devicemodeid";
public static final int ST_TAG_DEVICEMODEID_TYPE = 2;

@ -83,6 +83,13 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datascope</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.plc4x/plc4j-protocol-ethernetip -->
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-driver-ethernet-ip</artifactId>
<version>0.6.0</version>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
@ -105,6 +112,11 @@
<groupId>com.ruoyi</groupId>
<artifactId>hw-api-tdengine</artifactId>
</dependency>
<dependency>
<groupId>com.github.dathlin</groupId>
<artifactId>HslCommunication</artifactId>
<version>3.3.1</version>
</dependency>
<!-- RuoYi Common International Language -->
<dependency>

@ -10,6 +10,7 @@ import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
@ -19,6 +20,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
* plc(PlcDevice)
@ -120,9 +122,9 @@ public class PlcDeviceController extends BaseController {
public AjaxResult aeDataProcess() throws JsonProcessingException {
return AjaxResult.success(plcDeviceService.aeDataProcess());
}
@GetMapping("/linkDataProcess")
public AjaxResult linkDataProcess() throws JsonProcessingException {
return AjaxResult.success(plcDeviceService.linkDataProcess());
@GetMapping("/ehternetDataProcess")
public AjaxResult ehternetDataProcess() throws JsonProcessingException{
return AjaxResult.success(plcDeviceService.ehternetDataProcess());
}
@GetMapping("/list")
public TableDataInfo list(PlcDevice hwDevice) {

@ -0,0 +1,91 @@
package com.ruoyi.business.mapper;
import com.ruoyi.business.domain.PlcDevice;
import com.ruoyi.business.domain.PlcDeviceMode;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* plc(PlcDevice)访
*
* @author makejava
* @since 2024-12-19 16:22:43
*/
public interface PlcDeviceDao {
/**
* ID
*
* @param deviceId
* @return
*/
List<PlcDevice> queryById();
List<PlcDevice> queryPlcDevices(@Param("accessProtocol") int accessProtocol);
/**
*
*
* @param plcDevice
* @param pageable
* @return
*/
List<PlcDevice> queryAllByLimit(PlcDevice plcDevice, @Param("pageable") Pageable pageable);
/**
*
*
* @param plcDevice
* @return
*/
long count(PlcDevice plcDevice);
/**
*
*
* @param plcDevice
* @return
*/
int insert(PlcDevice plcDevice);
/**
* MyBatisforeach
*
* @param entities List<PlcDevice>
* @return
*/
int insertBatch(@Param("entities") List<PlcDevice> entities);
/**
* MyBatisforeach
*
* @param entities List<PlcDevice>
* @return
* @throws org.springframework.jdbc.BadSqlGrammarException ListSQL
*/
int insertOrUpdateBatch(@Param("entities") List<PlcDevice> entities);
/**
*
*
* @param plcDevice
* @return
*/
int update(PlcDevice plcDevice);
/**
*
*
* @param deviceId
* @return
*/
int deleteById(Long deviceId);
List<PlcDevice> selectHwDeviceJoinList(PlcDevice hwDevice);
List<PlcDeviceMode> selectPlcDeviceMode(PlcDeviceMode queryDeviceMode);
PlcDevice selectHwDeviceByDeviceId(Long deviceId);
}

@ -0,0 +1,88 @@
package com.ruoyi.business.mapper;
import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.domain.PlcDeviceMode;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* plc(PlcDeviceMode)访
*
* @author makejava
* @since 2024-12-19 16:23:27
*/
public interface PlcDeviceModeDao {
/**
* ID
*
* @param deviceModeId
* @return
*/
PlcDeviceMode queryById(Long deviceModeId);
/**
*
*
* @param plcDeviceMode
* @param pageable
* @return
*/
List<PlcDeviceMode> queryAllByLimit(PlcDeviceMode plcDeviceMode, @Param("pageable") Pageable pageable);
/**
*
*
* @param plcDeviceMode
* @return
*/
long count(PlcDeviceMode plcDeviceMode);
/**
*
*
* @param plcDeviceMode
* @return
*/
int insert(PlcDeviceMode plcDeviceMode);
/**
* MyBatisforeach
*
* @param entities List<PlcDeviceMode>
* @return
*/
int insertBatch(@Param("entities") List<PlcDeviceMode> entities);
/**
* MyBatisforeach
*
* @param entities List<PlcDeviceMode>
* @return
* @throws org.springframework.jdbc.BadSqlGrammarException ListSQL
*/
int insertOrUpdateBatch(@Param("entities") List<PlcDeviceMode> entities);
/**
*
*
* @param plcDeviceMode
* @return
*/
int update(PlcDeviceMode plcDeviceMode);
/**
*
*
* @param deviceModeId
* @return
*/
int deleteById(Long deviceModeId);
List<PlcDeviceMode> selectList(PlcDeviceMode hwDeviceMode);
int deleteHwDeviceModeByDeviceModeIds(Long[] deviceModeIds);
}

@ -0,0 +1,94 @@
package com.ruoyi.business.mapper;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.PlcDeviceModeFunction;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* plc(PlcDeviceModeFunction)访
*
* @author makejava
* @since 2024-12-19 16:23:52
*/
public interface PlcDeviceModeFunctionDao {
/**
* ID
*
* @param modeFunctionId
* @return
*/
PlcDeviceModeFunction queryById(Long modeFunctionId);
/**
*
*
* @param plcDeviceModeFunction
* @param pageable
* @return
*/
List<PlcDeviceModeFunction> queryAllByLimit(PlcDeviceModeFunction plcDeviceModeFunction, @Param("pageable") Pageable pageable);
/**
*
*
* @param plcDeviceModeFunction
* @return
*/
long count(PlcDeviceModeFunction plcDeviceModeFunction);
/**
*
*
* @param plcDeviceModeFunction
* @return
*/
int insert(PlcDeviceModeFunction plcDeviceModeFunction);
/**
* MyBatisforeach
*
* @param entities List<PlcDeviceModeFunction>
* @return
*/
int insertBatch(@Param("entities") List<PlcDeviceModeFunction> entities);
/**
* MyBatisforeach
*
* @param entities List<PlcDeviceModeFunction>
* @return
* @throws org.springframework.jdbc.BadSqlGrammarException ListSQL
*/
int insertOrUpdateBatch(@Param("entities") List<PlcDeviceModeFunction> entities);
/**
*
*
* @param plcDeviceModeFunction
* @return
*/
int update(PlcDeviceModeFunction plcDeviceModeFunction);
/**
*
*
* @param modeFunctionId
* @return
*/
int deleteById(Long modeFunctionId);
List<PlcDeviceModeFunction> selectFunctions(Long deviceModeId);
List<PlcDeviceModeFunction> selectFunctionList(Long deviceModeId);
List<HwDeviceModeFunction> selectHwDeviceModeFunctionList(HwDeviceModeFunction queryDeviceModeFunction);
int deleteHwDeviceModeParameterByModeFunctionId(Long modeFunctionId);
int deleteHwDeviceModeFunctionByDeviceModeIds(Long[] deviceModeIds);
}

@ -5,10 +5,12 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.domain.PlcDevice;
import com.ruoyi.business.domain.PlcDeviceMode;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
* plc(PlcDevice)
@ -73,5 +75,5 @@ public interface PlcDeviceService {
String aeDataProcess() throws JsonProcessingException;
String linkDataProcess();
String ehternetDataProcess() throws JsonProcessingException;
}

@ -1,8 +1,10 @@
package com.ruoyi.business.service.impl;
import HslCommunication.Core.Transfer.DataFormat;
import HslCommunication.Core.Types.OperateResult;
import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.ModBus.ModbusTcpNet;
import HslCommunication.Profinet.AllenBradley.AllenBradleyNet;
import HslCommunication.Profinet.Melsec.MelsecA1ENet;
import HslCommunication.Profinet.Melsec.MelsecFxSerialOverTcp;
import HslCommunication.Profinet.Melsec.MelsecHelper;
@ -28,6 +30,13 @@ import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.AlterTagVo;
import com.ruoyi.tdengine.api.domain.TdField;
import com.ruoyi.tdengine.api.domain.TdTableVo;
import org.apache.plc4x.java.PlcDriverManager;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.messages.PlcReadRequest;
import org.apache.plc4x.java.api.messages.PlcReadResponse;
import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
import org.apache.plc4x.java.ethernetip.EtherNetIpPlcDriver;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -41,6 +50,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
/**
* plc(PlcDevice)
@ -316,60 +326,70 @@ public class PlcDeviceServiceImpl implements PlcDeviceService {
}
return null;
}
//link数据读取
//EtherNet协议数据读取
@Override
public String linkDataProcess() {
// List<PlcDevice> plcDevices = this.plcDeviceDao.queryPlcDevices(1);
// for (PlcDevice plcDevice : plcDevices) {
// int station = plcDevice.getStation();
// byte a = (byte)station;
// int length = plcDevice.getLength();
// short b = (short)length;
// // ModbusTcpNet tcpNet = new ModbusTcpNet(plcDevice.getIp(),plcDevice.getPort1(), a);
// // tcpNet.getByteTransform().setDataFormat(DataFormat.CDAB);
// MelsecA1ENet net = new MelsecA1ENet(plcDevice.getIp(),plcDevice.getPort1());
// MelsecFxSerialOverTcp melsecFxSerialOverTcp = new MelsecFxSerialOverTcp();
// TdTableVo tdTableVo = new TdTableVo();
// List<TdField> schemaFields = new ArrayList<>();
// TdField firstTdField = new TdField();
// firstTdField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
// long currentTimeMillis = System.currentTimeMillis();
// firstTdField.setFieldValue(currentTimeMillis);
// String databaseName = TdEngineConstants.getDatabaseName();
// String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX + plcDevice.getDeviceId();
// // firstTdField.setFieldValue(ts);
// schemaFields.add(firstTdField);
// List<PlcDeviceModeFunction> list = plcDeviceModeFunctionDao.selectFunctions(plcDevice.getDeviceModeId());
// if (plcDevice.getDataType().equals("10")){
// OperateResultExOne<String> resultExOne = net.ReadString(plcDevice.getLocation(),b, StandardCharsets.UTF_8);
// String content = resultExOne.Content;
// ObjectMapper objectMapper = new ObjectMapper();
// Map map = objectMapper.readValue(content, Map.class);
// for (PlcDeviceModeFunction function : list) {
// Object value = map.get(function.getFunctionIdentifier());
// TdField tdField = new TdField();
// tdField.setFieldName(function.getFunctionIdentifier());
// tdField.setFieldValue(value);
// schemaFields.add(tdField);
// }
// }else if (plcDevice.getDataType().equals("2")){
// OperateResultExOne<Integer> exOne = net.ReadInt32(plcDevice.getLocation());
// TdField tdField = new TdField();
// tdField.setFieldName(list.get(0).getFunctionIdentifier());
// tdField.setFieldValue(exOne.Content);
// schemaFields.add(tdField);
// }else if (plcDevice.getDataType().equals("4")){
// OperateResultExOne<Float> floatOperateResultExOne = net.ReadFloat(plcDevice.getLocation());
// TdField tdField = new TdField();
// tdField.setFieldName(list.get(0).getFunctionIdentifier());
// tdField.setFieldValue(floatOperateResultExOne.Content);
// schemaFields.add(tdField);
// }
// tdTableVo.setDatabaseName(databaseName);
// tdTableVo.setTableName(tableName);
// tdTableVo.setSchemaFields(schemaFields);
// final R<?> insertResult = this.remoteTdEngineService.insertTable(tdTableVo , SecurityConstants.INNER);
// }
public String ehternetDataProcess() throws JsonProcessingException {
// AllenBradleyNet plc = new AllenBradleyNet("127.0.0.1",44818);
// OperateResult operateResult = plc.ConnectServer();
// OperateResultExOne<String> f = plc.ReadString("F");
// String content = f.Content;
// return null;
List<PlcDevice> plcDevices = this.plcDeviceDao.queryPlcDevices(4);
for (PlcDevice plcDevice : plcDevices) {
int station = plcDevice.getStation();
byte a = (byte)station;
int length = plcDevice.getLength();
short b = (short)length;
// ModbusTcpNet tcpNet = new ModbusTcpNet(plcDevice.getIp(),plcDevice.getPort1(), a);
// tcpNet.getByteTransform().setDataFormat(DataFormat.CDAB);
AllenBradleyNet ethernet = new AllenBradleyNet(plcDevice.getIp(),plcDevice.getPort1());
TdTableVo tdTableVo = new TdTableVo();
List<TdField> schemaFields = new ArrayList<>();
TdField firstTdField = new TdField();
firstTdField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
long currentTimeMillis = System.currentTimeMillis();
firstTdField.setFieldValue(currentTimeMillis);
String databaseName = TdEngineConstants.getDatabaseName();
String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX + plcDevice.getDeviceId();
// firstTdField.setFieldValue(ts);
schemaFields.add(firstTdField);
List<PlcDeviceModeFunction> list = plcDeviceModeFunctionDao.selectFunctions(plcDevice.getDeviceModeId());
if (plcDevice.getDataType().equals("10")){
OperateResultExOne<String> resultExOne = ethernet.ReadString(plcDevice.getLocation(),b, StandardCharsets.UTF_8);
String content = resultExOne.Content;
ObjectMapper objectMapper = new ObjectMapper();
Map map = objectMapper.readValue(content, Map.class);
for (PlcDeviceModeFunction function : list) {
Object value = map.get(function.getFunctionIdentifier());
TdField tdField = new TdField();
tdField.setFieldName(function.getFunctionIdentifier());
tdField.setFieldValue(value);
schemaFields.add(tdField);
}
}else if (plcDevice.getDataType().equals("2")||plcDevice.getDataType().equals("9")){
OperateResultExOne<Integer> exOne = ethernet.ReadInt32(plcDevice.getLocation());
TdField tdField = new TdField();
tdField.setFieldName(list.get(0).getFunctionIdentifier());
tdField.setFieldValue(exOne.Content);
schemaFields.add(tdField);
}else if (plcDevice.getDataType().equals("4")){
OperateResultExOne<Float> floatOperateResultExOne = ethernet.ReadFloat(plcDevice.getLocation());
TdField tdField = new TdField();
tdField.setFieldName(list.get(0).getFunctionIdentifier());
tdField.setFieldValue(floatOperateResultExOne.Content);
schemaFields.add(tdField);
}else if (plcDevice.getDataType().equals("5")){
OperateResultExOne<Double> doubleOperateResultExOne = ethernet.ReadDouble(plcDevice.getLocation());
TdField tdField = new TdField();
tdField.setFieldName(list.get(0).getFunctionIdentifier());
tdField.setFieldValue(doubleOperateResultExOne.Content);
schemaFields.add(tdField);
}
tdTableVo.setDatabaseName(databaseName);
tdTableVo.setTableName(tableName);
tdTableVo.setSchemaFields(schemaFields);
final R<?> insertResult = this.remoteTdEngineService.insertTable(tdTableVo , SecurityConstants.INNER);
}
return null;
}

@ -0,0 +1,129 @@
import request from '@/utils/request'
import {parseStrEmpty} from "@/utils/ruoyi";
// 查询设备信息列表
export function listDevice(query) {
return request({
url: '/business/plcDevice/list',
method: 'get',
params: query
})
}
// 查询设备信息详细
export function getDevice(deviceId) {
return request({
url: '/business/plcDevice/' + deviceId,
method: 'get'
})
}
// 新增设备信息
export function addDevice(data) {
return request({
url: '/business/plcDevice',
method: 'post',
data: data
})
}
// 修改设备信息
export function updateDevice(data) {
return request({
url: '/business/plcDevice',
method: 'put',
data: data
})
}
// 删除设备信息
export function delDevice(deviceId) {
return request({
url: '/business/plcDevice/' + deviceId,
method: 'delete'
})
}
// 查询场景信息列表供查询页面选择使用(例如下拉列表)
export function getScenes(query) {
return request({
url: '/business/device/getScenes',
method: 'get',
params: query
})
}
// 查询场景信息列表供编辑页面选择使用(例如下拉列表)
export function getEditedScenes(query) {
return request({
url: '/business/device/getEditedScenes',
method: 'get',
params: query
})
}
export function getProtocols() {
return request({
url: '/business/plcDevice/getProtocols',
method: 'get'
})
}
// 查询监控单元树
export function getMonitorTree(sceneId) {
return request({
url: '/business/device/monitorUnitTree/' + parseStrEmpty(sceneId),
method: 'get'
})
}
// 查询设备模型
export function getDeviceModes(sceneId) {
return request({
url: '/business/plcDevice/getDeviceModes/' + parseStrEmpty(sceneId),
method: 'get'
})
}
// 查询网关设备
export function getGatewayDevices(sceneId) {
return request({
url: '/business/device/getGatewayDevices/' + parseStrEmpty(sceneId),
method: 'get'
})
}
// 设备状态修改
export function changeDeviceStatus(deviceId, deviceStatus) {
const data = {
deviceId,
deviceStatus
}
return request({
url: '/business/plcDevice/changeDeviceStatus',
method: 'put',
data: data
})
}
export function publishControlCommand(deviceId, type) {
const data = {
deviceId,
type
}
return request({
url: '/business/device/publishControlCommand',
method: 'put',
data: data
})
}
// 重新生成tdengine所有表
export function rebuildTdTables() {
return request({
url: '/business/device/rebuildTdTables',
method: 'get'
})
}

@ -0,0 +1,89 @@
import request from '@/utils/request'
// 查询设备模型列表
export function listDeviceMode(query) {
return request({
url: '/business/plcDeviceMode/list',
method: 'get',
params: query
})
}
export function addDeviceModeFunction(data) {
return request({
url: '/business/plcDeviceModeFunction',
method: 'post',
data: data
})
}
export function updateDeviceModeFunction(data) {
return request({
url: '/business/plcDeviceModeFunction',
method: 'put',
data: data
})
}
export function delDeviceModeFunction(modeFunctionId) {
return request({
url: '/business/plcDeviceModeFunction/' + modeFunctionId,
method: 'delete'
})
}
// 查询设备模型详细
export function getDeviceMode(deviceModeId) {
return request({
url: '/business/plcDeviceMode/' + deviceModeId,
method: 'get'
})
}
// 新增设备模型
export function addDeviceMode(data) {
return request({
url: '/business/plcDeviceMode',
method: 'post',
data: data
})
}
// 修改设备模型
export function updateDeviceMode(data) {
return request({
url: '/business/plcDeviceMode',
method: 'put',
data: data
})
}
// 删除设备模型
export function delDeviceMode(deviceModeId) {
return request({
url: '/business/plcDeviceMode/' + deviceModeId,
method: 'delete'
})
}
// 查询场景信息列表供插叙页面选择使用(例如下拉列表)
export function getScenes(query) {
return request({
url: '/business/deviceMode/getScenes',
method: 'get',
params: query
})
}
// 查询场景信息列表供编辑页面选择使用(例如下拉列表)
export function getEditedScenes(query) {
return request({
url: '/business/deviceMode/getEditedScenes',
method: 'get',
params: query
})
}
// 重新生成tdengine所有超级表
export function rebuildTdSuperTables() {
return request({
url: '/business/deviceMode/rebuildTdSuperTables',
method: 'get'
})
}

@ -231,6 +231,20 @@ export const dynamicRoutes = [
}
]
},
{
path: '/plcDeviceMode/mode-add',
component: Layout,
hidden: true,
permissions: ['business:deviceMode:add'],
children: [
{
path: 'index',
component: () => import('@/views/plc/plcModel/editDeviceMode'),
name: 'ModeAdd',
meta: { title: '添加设备模型', activeMenu: '/plc/plcModel' }
}
]
},
{
path: '/deviceMode/mode-edit',
component: Layout,
@ -245,6 +259,20 @@ export const dynamicRoutes = [
}
]
},
{
path: '/plcDeviceMode/mode-edit',
component: Layout,
hidden: true,
permissions: ['business:deviceMode:edit'],
children: [
{
path: 'index/:deviceModeId(\\d+)',
component: () => import('@/views/plc/plcModel/editDeviceMode'),
name: 'ModeEdit',
meta: { title: '修改设备模型', activeMenu: '/plc/plcModel' }
}
]
},
{
path: '/electronicFence/fence-add',
component: Layout,

File diff suppressed because it is too large Load Diff

@ -0,0 +1,885 @@
<template>
<div class="app-container">
<el-form ref="basicInfoForm" :model="info" :rules="rules" label-width="150px">
<el-form-item label="通用标识" prop="commonFlag" v-if="false">
<el-input placeholder="请选择通用标识" v-model="info.commonFlag"/>
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="模型名称" prop="deviceModeName">
<el-input placeholder="请输入模型名称" v-model="info.deviceModeName"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="info.sceneId" placeholder="请选择" :disabled="disabled">
<el-option
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
:disabled="scene.selectedDisable && scene.selectedDisable == 1"
></el-option>
</el-select>
</el-form-item>
</el-col>
<!-- <el-col :span="12">-->
<!-- <el-form-item label="定位标识" prop="gpsFlag">-->
<!-- <el-radio-group v-model="info.gpsFlag" @input="gpsFlagRadioChange" :disabled="disabled">-->
<!-- <el-radio-->
<!-- v-for="dict in dict.type.hw_device_mode_gps_flag"-->
<!-- :key="dict.value"-->
<!-- :label="dict.value"-->
<!-- v-model="gps_flag"-->
<!-- >{{ dict.label }}-->
<!-- </el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- <el-col :span="12">-->
<!-- <el-form-item label="模型分类" prop="modeClassfication">-->
<!-- <el-select v-model="info.modeClassfication" placeholder="请选择数据类型">-->
<!-- <el-option-->
<!-- v-for="dict in dict.type.hw_mode_function_mode_classfication"-->
<!-- :key="dict.value"-->
<!-- :label="dict.label"-->
<!-- :value="parseInt(dict.value)"-->
<!-- ></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="24">
<el-form-item label="语言" prop="language_code" v-if="false">
<el-select v-model="info.languageCode" placeholder="请选择">
<el-option
v-for="(language, index) in languages"
:key="index"
:label="language.languageName"
:value="language.languageCode"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="设备模型图片" prop="deviceModePic">
<el-upload
single
:action="uploadImgUrl"
list-type="picture-card"
:limit="limit"
:on-success="handleUploadSuccess"
:before-upload="handleBeforeUpload"
:on-error="handleUploadError"
:on-exceed="handleExceed"
ref="imageUpload"
:on-remove="handleDeletePicture"
:show-file-list="true"
:headers="headers"
:file-list="fileList"
:on-preview="handlePictureCardPreview"
:class="{hide: this.fileList.length >= 1}"
>
<i class="el-icon-plus"></i>
</el-upload>
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip">
请上传
<template v-if="fileSize"> <b style="color: #f56c6c">{{ fileSize }}MB</b></template>
<template v-if="fileType"> <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
的文件
</div>
<el-dialog
:visible.sync="dialogVisible"
title="预览"
width="800"
append-to-body
>
<img
:src="dialogImageUrl"
style="display: block; max-width: 100%; margin: 0 auto"
/>
</el-dialog>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-card>
<el-tabs v-model="activeName">
<el-tab-pane label="属性" name="attributesInfo">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增
</el-button>
</el-col>
</el-row>
<el-table ref="attributesTable" :data="attributesData" row-key="columnId">
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
<!-- <el-table-column-->
<!-- label="功能模式"-->
<!-- prop="functionMode"-->
<!-- v-if="false"-->
<!-- />-->
<!-- <el-table-column-->
<!-- label="定位坐标标识"-->
<!-- prop="coordinate"-->
<!-- v-if="false"-->
<!-- />-->
<el-table-column
label="描述"
prop="remark"
v-if="false"
/>
<!-- <el-table-column-->
<!-- label="功能类型"-->
<!-- prop="functionType"-->
<!-- min-width="10%">-->
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.hw_mode_function_function_type" :value="scope.row.functionType"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column
label="功能名称"
prop="functionName"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column
label="标识符"
prop="functionIdentifier"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column prop="dataType" label="数据类型" min-width="10%">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_mode_function_data_type" :value="scope.row.dataType"/>
</template>
</el-table-column>
<el-table-column
label="数据定义"
prop="dataDefinition"
min-width="10%"
:show-overflow-tooltip="true"
v-if="false"
/>
<el-table-column
label="单位"
prop="propertyUnit"
min-width="10%"
:show-overflow-tooltip="true"
/>
<!-- <el-table-column-->
<!-- label="读写权限"-->
<!-- prop="rwFlag"-->
<!-- min-width="10%"-->
<!-- :show-overflow-tooltip="true"-->
<!-- >-->
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.hw_mode_function_rw_flag" :value="scope.row.rwFlag"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column-->
<!-- label="显示"-->
<!-- prop="displayFlag"-->
<!-- min-width="10%"-->
<!-- :show-overflow-tooltip="true"-->
<!-- >-->
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.hw_mode_function_display_flag" :value="scope.row.displayFlag"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="操作" align="center" min-width="10%">
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
v-if="scope.row.coordinate==null"
@click="handleUpdateAttribute(scope.row)"
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
v-if="scope.row.coordinate==null"
@click="handleDeleteAttribute(scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改设备模型功能对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="modeFunctionForm" :model="form" :rules="modeFunctionRules" label-width="80px">
<!-- <el-form-item label="功能模式" prop="functionMode" v-show="false">-->
<!-- <el-input v-model="form.functionMode" placeholder="请输入功能模式"/>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="功能类型" prop="functionType">-->
<!-- <el-select v-model="form.functionType" placeholder="请选择功能类型">-->
<!-- <el-option-->
<!-- v-for="dict in dict.type.hw_mode_function_function_type"-->
<!-- :key="dict.value"-->
<!-- :label="dict.label"-->
<!-- :value="dict.value"-->
<!-- ></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="功能名称" prop="functionName">
<el-input v-model="form.functionName" placeholder="请输入功能名称" maxlength="30"/>
</el-form-item>
<el-form-item label="标识符" prop="functionIdentifier">
<el-input v-model="form.functionIdentifier" placeholder="请输入标识符" maxlength="30"
:disabled="editDisable"/>
</el-form-item>
<el-form-item label="数据类型" prop="dataType">
<el-select v-model="form.dataType" placeholder="请选择数据类型" :disabled="editDisable">
<el-option
v-for="dict in dict.type.hw_mode_function_data_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="取值范围" prop="dataDefinition" v-show="false">
<el-input v-model="form.minValue" placeholder="请输入最小值" style="width:150px;"/>
<el-input v-model="form.maxValue" placeholder="请输入最大值" style="width:150px;"/>
</el-form-item>
<el-form-item label="布尔值" prop="dataDefinition" v-show="form.dataType == '8'">
0
<el-input v-model="form.boolFalse" placeholder="请输入值" style="width:150px;"/>
</el-form-item>
<el-form-item label="" prop="dataDefinition" v-show="form.dataType == '8'">
1
<el-input v-model="form.boolTrue" placeholder="请输入值" style="width:150px;"/>
</el-form-item>
<el-form-item label="长度" prop="dataDefinition" v-show="form.dataType == '10'">
<el-input-number v-model="form.dataDefinition" placeholder="请输入最大长度" :min="10" :max="1000"
style="width:150px;"/>
</el-form-item>
<el-form-item label="单位" prop="propertyUnit">
<el-input v-model="form.propertyUnit" placeholder="请输入单位"/>
</el-form-item>
<!-- <el-form-item label="显示标识" prop="displayFlag">-->
<!-- <el-radio-group v-model="form.displayFlag">-->
<!-- <el-radio-->
<!-- v-for="dict in dict.type.hw_mode_function_display_flag"-->
<!-- :key="dict.value"-->
<!-- :label="dict.value"-->
<!-- >{{ dict.label }}-->
<!-- </el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="读写标识" prop="rwFlag">-->
<!-- <el-radio-group v-model="form.rwFlag">-->
<!-- <el-radio-->
<!-- v-for="dict in dict.type.hw_mode_function_rw_flag"-->
<!-- :key="dict.value"-->
<!-- :label="dict.value"-->
<!-- >{{ dict.label }}-->
<!-- </el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<el-form-item label="描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitDeviceModeFunctionForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</el-tab-pane>
<!-- <el-tab-pane label="服务" name="servicesInfo">-->
<!-- <device-mode-service ref="servicesTable" :servicesData="servicesData" :deviceModeId="deviceModeId"/>-->
<!-- </el-tab-pane>-->
<!-- <el-tab-pane label="事件" name="eventsInfo">-->
<!-- <device-mode-event ref="eventInfo" :eventsData="eventsData" :deviceModeId="deviceModeId"/>-->
<!-- </el-tab-pane>-->
</el-tabs>
<el-form label-width="100px">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
<el-button type="primary" @click="submitForm()"></el-button>
<el-button @click="close()"></el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</template>
<script>
import {addDeviceMode, getDeviceMode, updateDeviceMode, getEditedScenes,addDeviceModeFunction,delDeviceModeFunction,
updateDeviceModeFunction} from "@/api/plc/plcDeviceMode";
import {getToken} from "@/utils/auth";
export default {
dicts: ['hw_device_mode_gps_flag', 'hw_mode_function_mode_classfication', 'hw_mode_function_function_type', 'hw_mode_function_function_type', 'hw_mode_function_data_type', 'hw_mode_function_display_flag', 'hw_mode_function_rw_flag'],
components: {
},
props: {
value: [String, Object, Array],
//
limit: {
type: Number,
default: 1,
},
// (MB)
fileSize: {
type: Number,
default: 5,
},
// , ['png', 'jpg', 'jpeg']
fileType: {
type: Array,
default: () => ["png", "jpg", "jpeg"],
},
//
isShowTip: {
type: Boolean,
default: true
}
},
data() {
return {
info: {},
//
title: "",
//
form: {},
editedForm: {},
gps_flag: '',
//
open: false,
disabled: true,
rules: {
deviceModeName: [{
required: true,
message: '请输入模型名称',
trigger: 'blur'
}],
sceneId: [
{required: true, message: "请选择场景", trigger: "change"}
],
gpsFlag: [
{required: true, message: "请选择定位标识", trigger: "change"}
],
},
modeFunctionRules: {
functionType: [
{required: true, message: "请选择功能类型", trigger: "blur"},
],
functionName: [
{required: true, message: "请输入功能名称", trigger: "blur"}
],
functionIdentifier: [
{required: true, message: "请输入标识符", trigger: "blur"},
{
pattern: /^[a-z][a-z0-9_]+$/,
message: "2-30个字符由小写字母、数字或下划线组成开头必须为小写字母",
trigger: "blur"
}
],
dataType: [
{required: true, message: "请选择数据类型", trigger: "change"}
],
displayFlag: [
{required: true, message: "请选择显示标识", trigger: "change"}
],
rwFlag: [
{required: true, message: "请选择读写标识", trigger: "change"}
],
},
// name
activeName: "attributesInfo",
//
scenes: [],
//
languages: [],
//
IDENTIFIER_LONGITUDE: 'longitude',
//
IDENTIFIER_LATITUDE: 'latitude',
editDisable: true,
//ID
deviceModeId: '',
//
attributesData: [],
attributeDataIndex: -1,//index
//
servicesData: [],
//
eventsData: [],
//
tableHeight: document.documentElement.scrollHeight - 245 + "px",
number: 0,
uploadList: [],
dialogImageUrl: "",
dialogVisible: false,
hideUpload: false,
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", //
headers: {
Authorization: "Bearer " + getToken(),
},
fileList: [],
}
},
created() {
this.getConfigKey("hw.gps.longitude").then(response => {//
this.IDENTIFIER_LONGITUDE = response.msg;
});
this.getConfigKey("hw.gps.latitude").then(response => {//
this.IDENTIFIER_LATITUDE = response.msg;
});
// getLanguages().then(response => {
// this.languages = response.data;
// });
getEditedScenes().then(response => {
this.scenes = response.data;
});
this.eventsData = [];
this.servicesData = [];
this.attributesData = [];
const deviceModeId = this.$route.params && this.$route.params.deviceModeId;
if (deviceModeId) {
//
getDeviceMode(deviceModeId).then(res => {
console.log(deviceModeId)
this.info = res.data.deviceMode;
console.log(this.info)
this.attributesData = res.data.deviceModeFunctionMap;
const servicesData = (res.data.deviceModeFunctionMap)['2'];
const eventsData = (res.data.deviceModeFunctionMap)['3'];
if(servicesData != null && servicesData!==''){
this.servicesData =servicesData;
}
if(servicesData != null && eventsData!==''){
this.eventsData =eventsData;
}
this.deviceModeId = deviceModeId;
if (res.data.deviceMode.deviceModePic != null) {
let previewFile = {};
previewFile.url = res.data.deviceMode.deviceModePic
this.fileList.push(previewFile);
}
// this.columns = res.data.rows;
});
/** 查询字典下拉列表 */
// getDictOptionselect().then(response => {
// this.dictOptions = response.data;
// });
} else {
//
this.info = {
gpsFlag: "0",
commonFlag: "0"
};
this.gps_flag = "0"
this.disabled = false;
}
},
computed: {},
watch: {},
mounted() {
},
methods: {
//
gpsFlagRadioChange(value) {
if (parseInt(value) === 1) {//
let attributesData = this.attributesData;
if (attributesData.length > 0) {
this.$modal.confirm('修改定位标识会删除所有属性,确定修改定位标识么?').then(function () {
attributesData.splice(0, attributesData.length);
}).then(() => {
this.addGpsAttribute();
});
} else {
this.addGpsAttribute();
}
} else {
let attributesData = this.attributesData;
if (attributesData.length > 0) {
this.$modal.confirm('修改定位标识会删除所有属性,确定修改定位标识么?').then(function () {
attributesData.splice(0, attributesData.length);
});
}
}
},
addGpsAttribute() {
this.reset();
this.form.coordinate = "1"
this.form.functionIdentifier = this.IDENTIFIER_LONGITUDE;
this.form.functionName = "经度";
this.form.dataType = 5;
this.attributesData.push(this.form);
this.reset();
this.form.coordinate = "2"
this.form.functionIdentifier = this.IDENTIFIER_LATITUDE;
this.form.functionName = "纬度";
this.form.dataType = 5;
this.attributesData.push(this.form);
},
/** 新增属性按钮操作 */
handleAdd() {
this.reset();
this.editDisable = false;
this.open = true;
this.title = "添加设备模型属性";
},
//
reset() {
this.form = {
functionMode: '1',
modeFunctionId: null,
deviceModeId: null,
coordinate: null,
functionName: null,
functionIdentifier: null,
functionType: "1",//
dataType: "2",//int
dataDefinition: null,
functionFormula: null,
propertyUnit: null,
displayFlag: "1",//
rwFlag: "2",//
boolFalse: '',
boolTrue: '',
minValue: '',
maxValue: '',
invokeMethod: null,
eventType: null,
remark: null,
};
//this.resetForm("modeFunctionForm");
},
handleUpdateAttribute(row) {
// this.reset();
this.editDisable = true;
this.attributeDataIndex = this.attributesData.indexOf(row);
this.convertParameterDefinition(row);
this.form = JSON.parse(JSON.stringify(row));//
this.open = true;
this.title = "修改设备模型属性";
},
convertParameterDefinition(row) {
let dataType = row.dataType;
if (parseInt(dataType) === 8) {
let dataDefinitionJson = JSON.parse(row.dataDefinition)
row.boolFalse = dataDefinitionJson["0"];
row.boolTrue = dataDefinitionJson["1"];
}
row.dataType = dataType.toString();
},
handleDeleteAttribute(row) {
console.log(row.modeFunctionId)
if (row.modeFunctionId !== null) {
if (this.attributesData.length <= 1) {
this.$modal.msgWarning("最少一个属性");
return;
}
this.$modal.confirm('删除属性之前上报此属性的数据会清除,确认要删除么?').then(() => {
delDeviceModeFunction(row.modeFunctionId).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.attributesData.splice(this.attributesData.indexOf(row), 1);
}
});
})
} else {
console.log(row.modeFunctionId)
this.attributesData.splice(this.attributesData.indexOf(row), 1);
}
},
/** 关闭按钮 */
close() {
// alert(this.$route.query.pageNum);
const obj = {path: "/plc/model", query: {t: Date.now(), pageNum: this.$route.query.pageNum}};
this.$tab.closeOpenPage(obj);
},
submitDeviceModeFunctionForm() {
this.$refs['modeFunctionForm'].validate(valid => {
if (valid) {
/** 设备模型添加后在list中添加 */
//alert(this.minValue+"--"+this.maxValue)
if (this.form.dataType === "8") {
let boolFalse = this.form.boolFalse;
let boolTrue = this.form.boolTrue;
if (boolFalse === '' || boolTrue === '') {
this.$modal.msgError("请输入布尔值");
return;
} else {
this.form.dataDefinition = '{"0":"' + boolFalse + '","1":"' + boolTrue + '"}';
}
}
if (this.deviceModeId && this.deviceModeId !== '') {
let modeFunctionId = this.form.modeFunctionId;
this.form.deviceModeId = this.deviceModeId;
if (modeFunctionId !== undefined && modeFunctionId != null) {
let attributeDataIndex = this.attributeDataIndex;
let oldForm = this.attributesData[attributeDataIndex];
if (oldForm.functionIdentifier != this.form.functionIdentifier
|| oldForm.dataType != this.form.dataType) {
this.$modal.confirm('修改标识符或数据类型,之前上报数据会清除,确认要修改么?').then(() => {
return this.doUpdateDeviceModeFunction();
}
)
} else {
// console.log(res)
this.doUpdateDeviceModeFunction();
}
} else {
console.log(1)
addDeviceModeFunction(this.form).then(res => {
console.log(res)
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.open = false;
this.form.modeFunctionId = res.data;
this.pushData();
}
});
}
} else {
this.open = false;
this.pushData();
}
}
})
},
doUpdateDeviceModeFunction() {
updateDeviceModeFunction(this.form).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.open = false;
this.pushData();
}
});
},
pushData() {
let attributeDataIndex = this.attributeDataIndex;
if (attributeDataIndex > -1) {
this.attributeDataIndex = -1;
this.attributesData.splice(attributeDataIndex, 1, this.form);
} else {
this.attributesData.push(this.form)
}
},
//
cancel() {
this.open = false;
this.reset();
},
submitForm() {
this.$refs['basicInfoForm'].validate(valid => {
if (valid) {
if (this.info.deviceModeId != undefined) {
updateDeviceMode(this.info).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.close();
}
});
} else {
if (this.attributesData.length <= 0) {
this.$modal.msgError("请添加属性");
return;
}
let functionData = this.servicesData.concat(this.attributesData);
functionData = functionData.concat(this.eventsData)
console.log(functionData)
this.info.functionList = functionData;
addDeviceMode(this.info).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.close();
}
});
}
}
})
},
/**上传图片处理*/
// loading
handleBeforeUpload(file) {
let isImg = false;
if (this.fileType.length) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
}
isImg = this.fileType.some(type => {
if (file.type.indexOf(type) > -1) return true;
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
return false;
});
} else {
isImg = file.type.indexOf("image") > -1;
}
if (!isImg) {
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`);
return false;
}
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$modal.msgError(`上传头像图片大小不能超过 ${this.fileSize} MB!`);
return false;
}
}
this.$modal.loading("正在上传图片,请稍候...");
this.number++;
},
checkPicture(file) {
},
//
handleExceed() {
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} !`);
},
//
handleUploadSuccess(res, file) {
if (res.code === 200) {
this.uploadList.push(res.data.url);
this.uploadedSuccessfully();
} else {
this.number--;
this.$modal.closeLoading();
this.$modal.msgError(res.msg);
this.$refs.imageUpload.handleRemove(file);
this.uploadedSuccessfully();
}
},
//
uploadedSuccessfully() {
if (this.number > 0 && this.uploadList.length === this.number) {
this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = [];
this.number = 0;
this.info.deviceModePic = this.fileList[0];
// this.$emit("input", this.listToString(this.fileList));
this.$modal.closeLoading();
}
},
//
handleDeletePicture(file) {
const findex = this.fileList.map(f => f.name).indexOf(file.name);
if (findex > -1) {
this.fileList.splice(findex, 1);
// this.$emit("input", this.listToString(this.fileList));
}
this.info.deviceModePic = '';
},
//
handleUploadError() {
this.$modal.msgError("上传图片失败,请重试");
this.$modal.closeLoading();
},
//
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
//
listToString(list, separator) {
let strs = "";
separator = separator || ",";
for (let i in list) {
if (list[i].url) {
strs += list[i].url.replace(this.baseUrl, "") + separator;
}
}
return strs != '' ? strs.substr(0, strs.length - 1) : '';
},
},
}
</script>

@ -1,37 +1,45 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="88px">
<el-form-item label="模型名称" prop="tenantName">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="模型名称" prop="deviceModeName">
<el-input
v-model="queryParams.tenantName"
v-model="queryParams.deviceModeName"
placeholder="请输入模型名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属租户" prop="tenantType">
<el-select v-model="queryParams.tenantType" placeholder="请选择所属租户" clearable>
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="queryParams.sceneId" placeholder="请选择所属场景">
<el-option
v-for="i in tenants"
:key="i.value"
:label="i.tenantName"
:value="i.tenantId">
</el-option>
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属场景" prop="tenantIndustry">
<el-select v-model="queryParams.tenantIndustry" placeholder="请选择所属场景" clearable>
<el-option
v-for="i in sceneModes"
:key="i.value"
:label="i.sceneModeName"
:value="i.sceneModeId">
</el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="定位标识" prop="gpsFlag">-->
<!-- <el-select v-model="queryParams.gpsFlag" placeholder="请选择定位标识" clearable>-->
<!-- <el-option-->
<!-- v-for="dict in dict.type.hw_device_mode_gps_flag"-->
<!-- :key="dict.value"-->
<!-- :label="dict.label"-->
<!-- :value="dict.value"-->
<!-- ></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="模型分类" prop="modeClassfication">-->
<!-- <el-select v-model="queryParams.modeClassfication" placeholder="请选择模型分类" clearable>-->
<!-- <el-option-->
<!-- v-for="dict in dict.type.hw_mode_function_mode_classfication"-->
<!-- :key="dict.value"-->
<!-- :label="dict.label"-->
<!-- :value="dict.value"-->
<!-- ></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
@ -47,55 +55,70 @@
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['business:deviceMode:add']"
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除
</el-button>
</el-col>
<right-toolbar @queryTable="getList"></right-toolbar>
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- icon="el-icon-edit"-->
<!-- size="mini"-->
<!-- :disabled="single"-->
<!-- @click="handleUpdate"-->
<!-- v-hasPermi="['business:deviceMode:edit']"-->
<!-- >修改-->
<!-- </el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="warning"-->
<!-- plain-->
<!-- icon="el-icon-download"-->
<!-- size="mini"-->
<!-- @click="handleExport"-->
<!-- v-hasPermi="['business:deviceMode:export']"-->
<!-- >导出-->
<!-- </el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="primary"-->
<!-- plain-->
<!-- icon="el-icon-plus"-->
<!-- size="mini"-->
<!-- @click="handleRebuildTdSuperTables"-->
<!-- v-hasPermi="['business:deviceMode:rebuild']"-->
<!-- >重建超级表-->
<!-- </el-button>-->
<!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="模型id" align="center" prop="value"/>
<el-table-column label="模型名称" align="center" prop="value"/>
<el-table-column label="所属租户" align="center" prop="value"/>
<el-table-column label="所属场景" align="center" prop="value"/>
<el-table-column label="操作" width="200px" align="center" class-name="small-padding fixed-width">
<el-table v-loading="loading" :data="deviceModeList" @selection-change="handleSelectionChange">
<el-table-column label="模型ID" align="center" prop="deviceModeId"/>
<el-table-column label="模型名称" align="center" prop="deviceModeName"/>
<el-table-column label="所属租户" align="center" prop="tenantName"/>
<el-table-column label="所属场景" align="center" prop="sceneName"/>
<!-- <el-table-column label="定位标识" align="center" prop="gpsFlag">-->
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.hw_device_mode_gps_flag" :value="scope.row.gpsFlag"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="模型分类" align="center" prop="modeClassfication">-->
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.hw_mode_function_mode_classfication" :value="scope.row.modeClassfication"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="toBind(scope.row)"
>绑定属性
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['business:deviceMode:edit']"
>修改
</el-button>
<el-button
@ -103,6 +126,7 @@
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['business:deviceMode:remove']"
>删除
</el-button>
</template>
@ -117,83 +141,154 @@
@pagination="getList"
/>
<!-- 添加或修改租户信息对话框 -->
<el-dialog :title="title" fullscreen :visible.sync="open" width="30%" append-to-body>
<el-form ref="form" :model="form" label-width="100px">
<el-form-item label="模型名称">
<el-input v-model="form.tenantName" placeholder="请输入模型名称"/>
</el-form-item>
<el-form-item label="所属租户" prop="tenantName">
<el-select v-model="form.tenantType" placeholder="请选择所属租户" clearable>
<el-option
v-for="i in tenants"
:key="i.value"
:label="i.tenantName"
:value="i.tenantId">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="所属场景" prop="contactName">
<el-select v-model="form.tenantIndustry" placeholder="请选择所属场景" clearable>
<el-option
v-for="i in sceneModes"
:key="i.value"
:label="i.sceneModeName"
:value="i.sceneModeId">
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {addScene, delScene, getSceneModes, getTenants, updateScene} from "@/api/business/scene";
import {listDeviceMode, getDeviceMode, delDeviceMode, addDeviceMode, updateDeviceMode,getScenes,rebuildTdSuperTables} from "@/api/plc/plcDeviceMode";
import {getLanguages} from "@/api/basic/language";
export default {
name: "PLCModel",
dicts: ['hw_device_mode_gps_flag', 'hw_mode_function_mode_classfication'],
name: "DeviceMode",
data() {
return {
//
loading: true,
//
ids: [],
//
checkedHwDeviceModeFunction: [],
//
single: true,
//
multiple: true,
queryParams: {},
list: [
{
value: 1
}
],
total: 10,
sceneModes: [],
tenants: [],
form: {},
//
showSearch: true,
//
total: 0,
//
deviceModeList: [],
//
hwDeviceModeFunctionList: [],
//
title: "",
//
open: false,
//
scenes: [],
//
languages: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
deviceModeName: null,
tenantId: null,
sceneId: null,
languageCode: null,
gpsFlag: null,
deviceModeStatus: null,
commonFlag: null,
modeClassfication: null,
deviceModePic: null,
dataVerifyLevel: null,
deviceModeField: null
},
//
form: {},
//
rules: {
deviceModeName: [
{required: true, message: "设备模型名称不能为空", trigger: "blur"}
],
gpsFlag: [
{required: true, message: "定位标识不能为空", trigger: "blur"}
],
deviceModeStatus: [
{required: true, message: "设备模型状态不能为空", trigger: "change"}
],
commonFlag: [
{required: true, message: "是否通用物模型不能为空", trigger: "blur"}
],
}
};
},
mounted() {
this.getTenants();
this.getSceneModes()
created() {
this.getList();
getLanguages().then(response => {
this.languages = response.data;
});
getScenes().then(response => {
this.scenes = response.data;
});
},
methods: {
getTenants() {
getTenants().then(response => {
this.tenants = response.data;
console.log(response.data)
})
computed: {
formatRow() {
return (row) => {
let languages = this.languages;
for (let i = 0; i < languages.length; i++) {
if (languages[i].languageCode === row.languageCode) {
return languages[i].languageName;
}
}
};
},
getSceneModes() {
getSceneModes().then(response => {
this.sceneModes = response.data;
},
activated() {
const time = this.$route.query.t;
if (time != null && time != this.uniqueId) {
this.uniqueId = time;
this.queryParams.pageNum = Number(this.$route.query.pageNum);
this.getList();
}
},
methods: {
/** 查询设备模型列表 */
getList() {
this.loading = true;
listDeviceMode(this.queryParams).then(response => {
this.deviceModeList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
deviceModeId: null,
deviceModeName: null,
tenantId: null,
sceneId: null,
languageCode: null,
gpsFlag: null,
deviceModeStatus: null,
commonFlag: null,
modeClassfication: null,
deviceModePic: null,
dataVerifyLevel: null,
remark: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
deviceModeField: null
};
this.hwDeviceModeFunctionList = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
@ -203,71 +298,120 @@ export default {
this.resetForm("queryForm");
this.handleQuery();
},
getList() {
this.loading = false
},
reset() {
this.form = {};
this.resetForm("form");
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.deviceModeId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加模型";
const params = {pageNum: this.queryParams.pageNum};
this.$tab.openPage("添加设备模型", '/plcDeviceMode/mode-add/index', params);
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const sceneId = row.sceneId || this.ids
this.open = true;
this.title = "修改场景信息";
const deviceModeId = row.deviceModeId || this.ids
const deviceModeName = row.deviceModeName || this.tableNames[0];
const params = {pageNum: this.queryParams.pageNum};
this.$tab.openPage("修改设备模型[" + deviceModeName + "]", '/plcDeviceMode/mode-edit/index/' + deviceModeId, params);
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.form.hwDeviceModeFunctionList = this.hwDeviceModeFunctionList;
if (this.form.deviceModeId != null) {
updateDeviceMode(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDeviceMode(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const sceneIds = row.sceneId || this.ids;
this.$modal.confirm('是否确认删除模型ID为"' + sceneIds + '"的数据项?').then(function () {
return delScene(sceneIds);
const deviceModeIds = row.deviceModeId || this.ids;
this.$modal.confirm('是否确认删除设备模型ID为"' + deviceModeIds + '"的数据项?').then(function () {
return delDeviceMode(deviceModeIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
},
handleSelectionChange(selection) {
this.ids = selection.map(item => item.sceneId)
this.single = selection.length !== 1
this.multiple = !selection.length
/** 设备模型功能序号 */
rowHwDeviceModeFunctionIndex({row, rowIndex}) {
row.index = rowIndex + 1;
},
cancel() {
this.open = false;
this.reset();
/** 设备模型功能添加按钮操作 */
handleAddHwDeviceModeFunction() {
let obj = {};
obj.functionMode = "";
obj.coordinate = "";
obj.functionName = "";
obj.functionIdentifier = "";
obj.functionType = "";
obj.dataType = "";
obj.dataDefinition = "";
obj.functionFormula = "";
obj.propertyUnit = "";
obj.displayFlag = "";
obj.rwFlag = "";
obj.invokeMethod = "";
obj.eventType = "";
obj.remark = "";
obj.acquisitionFormula = "";
obj.orderFlag = "";
obj.deviceRegister = "";
obj.propertyStep = "";
obj.propertyField = "";
this.hwDeviceModeFunctionList.push(obj);
},
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.sceneId != null) {
updateScene(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).catch(() => {
});
} else {
addScene(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).catch(() => {
});
}
} else {
}
/** 设备模型功能删除按钮操作 */
handleDeleteHwDeviceModeFunction() {
if (this.checkedHwDeviceModeFunction.length == 0) {
this.$modal.msgError("请先选择要删除的设备模型功能数据");
} else {
const hwDeviceModeFunctionList = this.hwDeviceModeFunctionList;
const checkedHwDeviceModeFunction = this.checkedHwDeviceModeFunction;
this.hwDeviceModeFunctionList = hwDeviceModeFunctionList.filter(function (item) {
return checkedHwDeviceModeFunction.indexOf(item.index) == -1
});
}
},
/** 复选框选中数据 */
handleHwDeviceModeFunctionSelectionChange(selection) {
this.checkedHwDeviceModeFunction = selection.map(item => item.index)
},
/** 导出按钮操作 */
handleExport() {
this.download('business/deviceMode/export', {
...this.queryParams
}, `deviceMode_${new Date().getTime()}.xlsx`)
this.download('business/deviceMode/exportFunction', {
}, `deviceModeFunction_${new Date().getTime()}.xlsx`)
},
/** 重建超级表按钮操作 */
handleRebuildTdSuperTables() {
this.$modal.confirm('是否确认重建所有设备监测数据超级表?').then(function () {
return rebuildTdSuperTables();
}).then(() => {
this.$modal.msgSuccess("重建成功");
}).catch(() => {
});
},
toBind(){
this.$router.push('bind')
}
}
};
</script>
<style>
</style>

Loading…
Cancel
Save