From 73f74cbf665a431b0db474be129a03c655e2338a Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期五, 25 八月 2023 13:30:03 +0800
Subject: [PATCH] 更新MODBUS-TCP协议,添加GasModus的配置
---
igds-protocol-modbus/src/main/java/com/ld/igds/modbus/ModbusConstant.java | 2
/dev/null | 118 -------
igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java | 11
igds-protocol-modbus/src/main/java/com/ld/igds/models/GasModbus.java | 60 +++
igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java | 4
igds-protocol-modbus/src/main/java/com/ld/igds/modbus/service/HModbusService.java | 240 +++++++++++++++
igds-protocol-modbus/src/main/java/com/ld/igds/modbus/GasModbus.view.xml | 373 +++++++++++++++++++++++
igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbusPR.java | 13
igds-core/src/main/java/com/ld/igds/view/DepotConf.view.xml | 30 +
igds-protocol-modbus/src/main/java/com/ld/igds/modbus/GasModbusPR.java | 94 +++++
10 files changed, 817 insertions(+), 128 deletions(-)
diff --git a/igds-core/src/main/java/com/ld/igds/view/DepotConf.view.xml b/igds-core/src/main/java/com/ld/igds/view/DepotConf.view.xml
index a3b6099..4aba95d 100644
--- a/igds-core/src/main/java/com/ld/igds/view/DepotConf.view.xml
+++ b/igds-core/src/main/java/com/ld/igds/view/DepotConf.view.xml
@@ -314,6 +314,15 @@
<Property name="property">ph3Max</Property>
<Editor/>
</AutoFormElement>
+ <Button>
+ <ClientEvent name="onClick">var depotId = view.get("#dsMain.data:#").get("depotId");
+var path = "com.ld.igds.modbus.GasModbus.d?depotId="+depotId;
+view.get("#iframModbus").set("path",path);
+view.get("#dialogModbus").show();</ClientEvent>
+ <Property name="caption">Modbus閰嶇疆</Property>
+ <Property name="tip">閽堝Modbus鍗忚鐨勯厤缃�</Property>
+ <Property name="iconClass">fa fa-refresh</Property>
+ </Button>
</AutoForm>
</Children>
</FieldSet>
@@ -346,6 +355,15 @@
<Property name="property">pestMax</Property>
<Editor/>
</AutoFormElement>
+ <Button>
+ <ClientEvent name="onClick">var depotId = view.get("#dsMain.data:#").get("depotId");
+var path = "com.ld.igds.modbus.PestModbus.d?depotId="+depotId;
+view.get("#iframModbus").set("path",path);
+view.get("#dialogModbus").show();</ClientEvent>
+ <Property name="caption">Modbus閰嶇疆</Property>
+ <Property name="tip">閽堝Modbus鍗忚鐨勯厤缃�</Property>
+ <Property name="iconClass">fa fa-refresh</Property>
+ </Button>
</AutoForm>
</Children>
</FieldSet>
@@ -388,5 +406,17 @@
<Property name="service">depotPR#ajaxGetAllCache</Property>
<Property name="executingMessage">鍒濆鍖栨暟鎹�︹��</Property>
</AjaxAction>
+ <Dialog id="dialogModbus">
+ <Property name="width">80%</Property>
+ <Property name="height">95%</Property>
+ <Property name="caption">Modbus-TCP閰嶇疆</Property>
+ <Buttons/>
+ <Children>
+ <IFrame id="iframModbus">
+ <Property name="path">com.ld.igds.modbus.GasModbus.d</Property>
+ </IFrame>
+ </Children>
+ <Tools/>
+ </Dialog>
</View>
</ViewConfig>
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbusPR.java b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbusPR.java
index 500a440..361ee0e 100644
--- a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbusPR.java
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/DeviceModbusPR.java
@@ -3,7 +3,7 @@
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
-import com.ld.igds.modbus.service.HDeviceModbusService;
+import com.ld.igds.modbus.service.HModbusService;
import com.ld.igds.models.DeviceModbus;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.util.ContextUtil;
@@ -20,7 +20,7 @@
public class DeviceModbusPR {
@Resource
- private HDeviceModbusService deviceModbusService;
+ private HModbusService deviceModbusService;
/**
* deviceModbusPR#listAll
@@ -30,7 +30,7 @@
@DataProvider
public List<DeviceModbus> listAll() {
String companyId = ContextUtil.getCompanyId();
- return deviceModbusService.listAll(companyId);
+ return deviceModbusService.listAllDevice(companyId);
}
/**
@@ -41,7 +41,7 @@
@Expose
public void flushCache() {
String companyId = ContextUtil.getCompanyId();
- deviceModbusService.flushCache(companyId);
+ deviceModbusService.flushCacheDevice(companyId);
}
/**
@@ -52,7 +52,7 @@
@Expose
public String delData(DeviceModbus data) {
if (null == data.getId()) return null;
- return deviceModbusService.delData(data);
+ return deviceModbusService.delDataDevice(data);
}
/**
@@ -63,7 +63,7 @@
*/
@DataResolver
public void updateData(List<DeviceModbus> details) {
- deviceModbusService.updateData(details);
+ deviceModbusService.updateDataDevice(details);
}
@@ -87,6 +87,5 @@
list.add(new DicTrigger(ModbusConstant.FUN_99, "鏈厤缃�"));
return list;
}
-
}
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/GasModbus.view.xml b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/GasModbus.view.xml
new file mode 100644
index 0000000..50f26ee
--- /dev/null
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/GasModbus.view.xml
@@ -0,0 +1,373 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ViewConfig>
+ <Arguments/>
+ <Context/>
+ <Model>
+ <DataType name="dtMain">
+ <Property name="creationType">com.ld.igds.models.DeviceModbus</Property>
+ <PropertyDef name="id">
+ <Property></Property>
+ <Property name="label">ID</Property>
+ </PropertyDef>
+ <PropertyDef name="deviceCode">
+ <Property></Property>
+ <Property name="label">浠撳簱缂栫爜</Property>
+ <Property name="mapping">
+ <Property name="mapValues">${dorado.getDataProvider("depotPR#getAllCache").getResult()}</Property>
+ <Property name="keyProperty">id</Property>
+ <Property name="valueProperty">name</Property>
+ </Property>
+ </PropertyDef>
+ <PropertyDef name="open">
+ <Property></Property>
+ <Property name="label">寮�鍦板潃</Property>
+ </PropertyDef>
+ <PropertyDef name="openFun">
+ <Property></Property>
+ <Property name="label">鍔熻兘鍙�</Property>
+ <Property name="mapping">
+ <Property name="mapValues">${dorado.getDataProvider("deviceModbusPR#triggerFun").getResult()}</Property>
+ <Property name="keyProperty">code</Property>
+ <Property name="valueProperty">name</Property>
+ </Property>
+ </PropertyDef>
+ <PropertyDef name="close">
+ <Property></Property>
+ <Property name="label">鍏冲湴鍧�</Property>
+ </PropertyDef>
+ <PropertyDef name="closeFun">
+ <Property></Property>
+ <Property name="label">鍔熻兘鍙�</Property>
+ <Property name="mapping">
+ <Property name="mapValues">${dorado.getDataProvider("deviceModbusPR#triggerFun").getResult()}</Property>
+ <Property name="keyProperty">code</Property>
+ <Property name="valueProperty">name</Property>
+ </Property>
+ </PropertyDef>
+ <PropertyDef name="stop">
+ <Property></Property>
+ <Property name="label">鍋滃湴鍧�</Property>
+ </PropertyDef>
+ <PropertyDef name="stopFun">
+ <Property></Property>
+ <Property name="label">鍔熻兘鍙�</Property>
+ <Property name="mapping">
+ <Property name="mapValues">${dorado.getDataProvider("deviceModbusPR#triggerFun").getResult()}</Property>
+ <Property name="keyProperty">code</Property>
+ <Property name="valueProperty">name</Property>
+ </Property>
+ </PropertyDef>
+ <PropertyDef name="openEnd">
+ <Property></Property>
+ <Property name="label">寮�鍒颁綅</Property>
+ </PropertyDef>
+ <PropertyDef name="openEndFun">
+ <Property></Property>
+ <Property name="label">鍔熻兘鍙�</Property>
+ <Property name="mapping">
+ <Property name="mapValues">${dorado.getDataProvider("deviceModbusPR#triggerFun").getResult()}</Property>
+ <Property name="keyProperty">code</Property>
+ <Property name="valueProperty">name</Property>
+ </Property>
+ </PropertyDef>
+ <PropertyDef name="closeEnd">
+ <Property></Property>
+ <Property name="label">鍏冲埌浣�</Property>
+ </PropertyDef>
+ <PropertyDef name="closeEndFun">
+ <Property></Property>
+ <Property name="label">鍔熻兘鍙�</Property>
+ <Property name="mapping">
+ <Property name="mapValues">${dorado.getDataProvider("deviceModbusPR#triggerFun").getResult()}</Property>
+ <Property name="keyProperty">code</Property>
+ <Property name="valueProperty">name</Property>
+ </Property>
+ </PropertyDef>
+ <PropertyDef name="openError">
+ <Property></Property>
+ <Property name="label">寮�鏁呴殰</Property>
+ </PropertyDef>
+ <PropertyDef name="openErrorFun">
+ <Property></Property>
+ <Property name="label">鍔熻兘鍙�</Property>
+ <Property name="mapping">
+ <Property name="mapValues">${dorado.getDataProvider("deviceModbusPR#triggerFun").getResult()}</Property>
+ <Property name="keyProperty">code</Property>
+ <Property name="valueProperty">name</Property>
+ </Property>
+ </PropertyDef>
+ <PropertyDef name="closeError">
+ <Property></Property>
+ <Property name="label">鍏虫晠闅�</Property>
+ </PropertyDef>
+ <PropertyDef name="closeErrorFun">
+ <Property></Property>
+ <Property name="label">鍔熻兘鍙�</Property>
+ <Property name="mapping">
+ <Property name="mapValues">${dorado.getDataProvider("deviceModbusPR#triggerFun").getResult()}</Property>
+ <Property name="keyProperty">code</Property>
+ <Property name="valueProperty">name</Property>
+ </Property>
+ </PropertyDef>
+ <Reference name="listGas">
+ <Property name="dataType">[dtGas]</Property>
+ <Property name="dataProvider">gasModbusPR#listGasModBus</Property>
+ <Property name="parameter">$${this.deviceCode}</Property>
+ </Reference>
+ </DataType>
+ <DataType name="dtGas">
+ <Property name="creationType">com.ld.igds.models.GasModbus</Property>
+ <PropertyDef name="id">
+ <Property/>
+ <Property name="label">ID</Property>
+ </PropertyDef>
+ <PropertyDef name="depotId">
+ <Property/>
+ <Property name="label">鎵�灞炰粨搴�</Property>
+ </PropertyDef>
+ <PropertyDef name="passcode">
+ <Property name="dataType">int</Property>
+ <Property name="label">閫氶亾</Property>
+ </PropertyDef>
+ <PropertyDef name="co2">
+ <Property/>
+ <Property name="label">浜屾哀鍖栫⒊</Property>
+ </PropertyDef>
+ <PropertyDef name="co2Fun">
+ <Property/>
+ <Property name="label">鍔熻兘鍙�</Property>
+ </PropertyDef>
+ <PropertyDef name="o2">
+ <Property/>
+ <Property name="label">姘ф皵</Property>
+ </PropertyDef>
+ <PropertyDef name="o2Fun">
+ <Property/>
+ <Property name="label">鍔熻兘鍙�</Property>
+ </PropertyDef>
+ <PropertyDef name="ph3">
+ <Property/>
+ <Property name="label">纾峰寲姘�</Property>
+ </PropertyDef>
+ <PropertyDef name="ph3Fun">
+ <Property/>
+ <Property name="label">鍔熻兘鍙�</Property>
+ </PropertyDef>
+ </DataType>
+ </Model>
+ <View layout="padding:5;regionPadding:5">
+ <Property name="packages">font-awesome,css-common</Property>
+ <DataSet id="dsMain">
+ <Property name="loadMode">lazy</Property>
+ <Property name="dataType">dtMain</Property>
+ <Property name="dataProvider">gasModbusPR#getGasData</Property>
+ <Property name="parameter">${request.getParameter('depotId')}</Property>
+ </DataSet>
+ <Container layout="regionPadding:10" layoutConstraint="top">
+ <Property name="exClassName">bg-color</Property>
+ <Property name="contentOverflow">hidden</Property>
+ <Property name="height">55</Property>
+ <Label layoutConstraint="left">
+ <Property name="text">鑿滃崟鏍忥細</Property>
+ </Label>
+ <Button layoutConstraint="left">
+ <ClientEvent name="onClick">var list = view.get("#dsMain.data").get("listGas");
+list.insert({});</ClientEvent>
+ <Property name="caption">鏂板閫氶亾</Property>
+ <Property name="exClassName">btn-default</Property>
+ <Property name="iconClass">fa fa-plus</Property>
+ </Button>
+ <Button>
+ <ClientEvent name="onClick">view.get("#uaAction").execute(); </ClientEvent>
+ <Property name="caption">淇濆瓨鏁版嵁</Property>
+ <Property name="iconClass">fa fa-check</Property>
+ <Property name="exClassName">btn-normal</Property>
+ </Button>
+ <Button layoutConstraint="left">
+ <ClientEvent name="onClick">var data = view.get("#dataGrid1").getCurrentItem();;
+if(!data){
+ return;
+}
+view.get("#ajaxDel").set("parameter",data).execute(function(result){
+ if(result){
+ $alert(result);
+ return;
+ }else{
+ data.remove();
+ }
+}); </ClientEvent>
+ <Property name="caption">鍒犻櫎閫氶亾</Property>
+ <Property name="exClassName">btn-warn</Property>
+ <Property name="iconClass">fa fa-minus</Property>
+ </Button>
+ <Button layoutConstraint="left">
+ <Property name="caption">鍒锋柊缂撳瓨</Property>
+ <Property name="exClassName">btn-default</Property>
+ <Property name="iconClass">fa fa-refresh</Property>
+ <Property name="action">ajaxFlushCache</Property>
+ </Button>
+ </Container>
+ <Container layout="regionPadding:10" layoutConstraint="center">
+ <Property name="exClassName">bg-color</Property>
+ <AutoForm>
+ <Property name="dataSet">dsMain</Property>
+ <Property name="cols">*,*,*,*</Property>
+ <Property name="labelAlign">right</Property>
+ <Property name="labelSeparator">锛�</Property>
+ <Property name="labelWidth">100</Property>
+ <AutoFormElement layoutConstraint="colSpan:2">
+ <Property name="name">deviceCode</Property>
+ <Property name="property">deviceCode</Property>
+ <Property name="label">浠撳簱缂栫爜</Property>
+ <Property name="labelWidth">100</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">open</Property>
+ <Property name="property">open</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">openFun</Property>
+ <Property name="property">openFun</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">close</Property>
+ <Property name="property">close</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">closeFun</Property>
+ <Property name="property">closeFun</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">stop</Property>
+ <Property name="property">stop</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">stopFun</Property>
+ <Property name="property">stopFun</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">openEnd</Property>
+ <Property name="property">openEnd</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">openEndFun</Property>
+ <Property name="property">openEndFun</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">closeEnd</Property>
+ <Property name="property">closeEnd</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">closeEndFun</Property>
+ <Property name="property">closeEndFun</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">openError</Property>
+ <Property name="property">openError</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">openErrorFun</Property>
+ <Property name="property">openErrorFun</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">closeError</Property>
+ <Property name="property">closeError</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">closeErrorFun</Property>
+ <Property name="property">closeErrorFun</Property>
+ <Editor/>
+ </AutoFormElement>
+ </AutoForm>
+ <ToolBar>
+ <ToolBarLabel>
+ <Property name="text">妫�娴嬮�氶亾閰嶇疆</Property>
+ <Property name="style">
+ <Property name="font-weight">bold</Property>
+ </Property>
+ </ToolBarLabel>
+ </ToolBar>
+ <DataGrid id="dataGrid1" layoutConstraint="center padding:5px">
+ <Property name="dataSet">dsMain</Property>
+ <Property name="dataPath">#.listGas</Property>
+ <RowNumColumn/>
+ <DataColumn>
+ <Property name="property">passcode</Property>
+ <Property name="name">passcode</Property>
+ <Editor/>
+ </DataColumn>
+ <ColumnGroup>
+ <Property name="caption">CO2</Property>
+ <DataColumn>
+ <Property name="property">co2</Property>
+ <Property name="caption">鍦板潃</Property>
+ <Property name="name">co2</Property>
+ </DataColumn>
+ <DataColumn>
+ <Property name="property">co2Fun</Property>
+ <Property name="caption">鍔熻兘</Property>
+ <Property name="trigger">autoMappingDropDown1</Property>
+ <Property name="name">co2Fun</Property>
+ </DataColumn>
+ </ColumnGroup>
+ <ColumnGroup>
+ <Property name="caption">O2</Property>
+ <DataColumn>
+ <Property name="property">o2</Property>
+ <Property name="caption">鍦板潃</Property>
+ <Property name="name">o2</Property>
+ </DataColumn>
+ <DataColumn>
+ <Property name="property">o2Fun</Property>
+ <Property name="caption">鍔熻兘</Property>
+ <Property name="trigger">autoMappingDropDown1</Property>
+ <Property name="name">o2Fun</Property>
+ </DataColumn>
+ </ColumnGroup>
+ <ColumnGroup>
+ <Property name="caption">PH3</Property>
+ <DataColumn>
+ <Property name="property">ph3</Property>
+ <Property name="caption">鍦板潃</Property>
+ <Property name="name">ph3</Property>
+ </DataColumn>
+ <DataColumn>
+ <Property name="property">ph3Fun</Property>
+ <Property name="caption">鍔熻兘</Property>
+ <Property name="trigger">autoMappingDropDown1</Property>
+ <Property name="name">ph3Fun</Property>
+ </DataColumn>
+ </ColumnGroup>
+ </DataGrid>
+ </Container>
+ <UpdateAction id="uaAction">
+ <Property name="dataResolver">gasModbusPR#updateData</Property>
+ <UpdateItem>
+ <Property name="dataSet">dsMain</Property>
+ <Property name="dataPath">[#current]</Property>
+ </UpdateItem>
+ </UpdateAction>
+ <AjaxAction id="ajaxDel">
+ <Property name="service">gasModbusPR#delData</Property>
+ <Property name="confirmMessage">纭畾瑕佸垹闄や箞锛�</Property>
+ </AjaxAction>
+ <AjaxAction id="ajaxFlushCache">
+ <Property name="service">gasModbusPR#flushCache</Property>
+ <Property name="successMessage">缂撳瓨鏇存柊鎴愬姛</Property>
+ </AjaxAction>
+ </View>
+</ViewConfig>
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/GasModbusPR.java b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/GasModbusPR.java
new file mode 100644
index 0000000..266c5ac
--- /dev/null
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/GasModbusPR.java
@@ -0,0 +1,94 @@
+package com.ld.igds.modbus;
+
+import com.bstek.dorado.annotation.DataProvider;
+import com.bstek.dorado.annotation.DataResolver;
+import com.bstek.dorado.annotation.Expose;
+import com.ld.igds.constant.BizType;
+import com.ld.igds.modbus.service.HModbusService;
+import com.ld.igds.models.DeviceModbus;
+import com.ld.igds.models.GasModbus;
+import com.ld.igds.util.ContextUtil;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * MOOBUS-TCP璁惧鍙傛暟閰嶇疆
+ */
+@Component
+public class GasModbusPR {
+
+ @Resource
+ private HModbusService modbusService;
+
+ /**
+ * gasModbusPR#getGasData
+ *
+ * @return
+ */
+ @DataProvider
+ public DeviceModbus getGasData(String depotId) {
+ if (null == depotId) return new DeviceModbus();
+
+ String bizType = BizType.GAS.getCode();
+
+ String companyId = ContextUtil.getCompanyId();
+
+ DeviceModbus result = modbusService.getGasData(companyId, depotId, bizType);
+
+ if (null == result) {
+ result = new DeviceModbus();
+ result.setBizType(bizType);
+ result.setDeviceCode(depotId);
+ result.setListGas(new ArrayList<>());
+ }
+
+ return result;
+ }
+
+ /**
+ * gasModbusPR#listGasModBus
+ *
+ * @param depotId
+ * @return
+ */
+ @DataProvider
+ public List<GasModbus> listGasModBus(String depotId) {
+ return modbusService.listGasModBus(depotId);
+ }
+
+
+ /**
+ * gasModbusPR#updateData
+ * @param data
+ */
+ @DataResolver
+ public void updateData(DeviceModbus data){
+ modbusService.updateGasModbus(data);
+ }
+
+ /**
+ * gasModbusPR#flushCache
+ *
+ * @return
+ */
+ @Expose
+ public void flushCache() {
+ String companyId = ContextUtil.getCompanyId();
+ modbusService.flushCacheGas(companyId);
+ }
+
+ /**
+ * deviceModbusPR#delData
+ *
+ * @return
+ */
+ @Expose
+ public String delData(GasModbus data) {
+ if (null == data.getId()) return null;
+ return modbusService.delDataGas(data);
+ }
+
+}
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/ModbusConstant.java b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/ModbusConstant.java
index 9a630ca..299052e 100644
--- a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/ModbusConstant.java
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/ModbusConstant.java
@@ -29,7 +29,7 @@
public static final String MODBUS_DEVICE_CACHE = "MODBUS_DEVICE";
-
+ public static final String MODBUS_GAS_CACHE_LIST = "MODBUS_GAS_LIST";
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/service/HDeviceModbusService.java b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/service/HDeviceModbusService.java
deleted file mode 100644
index a5da293..0000000
--- a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/service/HDeviceModbusService.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package com.ld.igds.modbus.service;
-
-import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
-import com.ld.igds.constant.Constant;
-import com.ld.igds.constant.RedisConst;
-import com.ld.igds.modbus.ModbusConstant;
-import com.ld.igds.models.DeviceModbus;
-import com.ld.igds.util.ContextUtil;
-import com.ld.igds.util.RedisUtil;
-import org.apache.commons.lang3.StringUtils;
-import org.hibernate.Session;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-
-@Component
-public class HDeviceModbusService extends HibernateDao {
-
- @Resource
- private RedisUtil redisUtil;
-
-
- public List<DeviceModbus> listAll(String companyId) {
-
- String hql = " from " + DeviceModbus.class.getName() + " where 1=1 order by deviceCode+0";
-
- return this.query(hql);
- }
-
- public void flushCache(String companyId) {
-
- if (null == companyId) companyId = ContextUtil.getCompanyId();
-
- List<DeviceModbus> listAll = this.listAll(companyId);
-
- if (null == listAll || listAll.isEmpty()) return;
-
-
- String key;
- DeviceModbus entityDevice;
- for (DeviceModbus hibDevice : listAll) {
- entityDevice = new DeviceModbus();
- BeanUtils.copyProperties(hibDevice, entityDevice);
- key = RedisConst.buildKey(companyId, ModbusConstant.MODBUS_DEVICE_CACHE, hibDevice.getDeviceCode());
- redisUtil.set(key, entityDevice);
- }
- }
-
- public DeviceModbus getCacheDeviceModbus(String companyId, String deviceCode) {
- String key = RedisConst.buildKey(companyId, ModbusConstant.MODBUS_DEVICE_CACHE, deviceCode);
- return (DeviceModbus) redisUtil.get(key);
- }
-
- public void updateData(List<DeviceModbus> details) {
- if (null == details || details.isEmpty()) return;
-
- Session session = this.getSessionFactory().openSession();
- try {
- for (DeviceModbus device : details) {
-
- if (StringUtils.isEmpty(device.getOpen())) device.setOpen(Constant.YN_N);
- if (StringUtils.isEmpty(device.getOpenFun())) device.setOpenFun(ModbusConstant.FUN_99);
-
- if (StringUtils.isEmpty(device.getOpenEnd())) device.setOpenEnd(Constant.YN_N);
- if (StringUtils.isEmpty(device.getOpenEndFun())) device.setOpenEndFun(ModbusConstant.FUN_99);
-
- if (StringUtils.isEmpty(device.getOpenError())) device.setOpenError(Constant.YN_N);
- if (StringUtils.isEmpty(device.getOpenErrorFun())) device.setOpenErrorFun(ModbusConstant.FUN_99);
-
- if (StringUtils.isEmpty(device.getClose())) device.setClose(Constant.YN_N);
- if (StringUtils.isEmpty(device.getCloseFun())) device.setCloseFun(ModbusConstant.FUN_99);
-
- if (StringUtils.isEmpty(device.getCloseEnd())) device.setCloseEnd(Constant.YN_N);
- if (StringUtils.isEmpty(device.getCloseEndFun())) device.setCloseEndFun(ModbusConstant.FUN_99);
-
- if (StringUtils.isEmpty(device.getCloseError())) device.setCloseError(Constant.YN_N);
- if (StringUtils.isEmpty(device.getCloseErrorFun())) device.setCloseErrorFun(ModbusConstant.FUN_99);
-
- if (StringUtils.isEmpty(device.getStop())) device.setStop(Constant.YN_N);
- if (StringUtils.isEmpty(device.getStopFun())) device.setStopFun(ModbusConstant.FUN_99);
-
-
- if (null == device.getId()) {
- device.setId(ContextUtil.getUUID());
- session.save(device);
- } else {
- session.update(device);
- }
- }
-
- flushCache(null);
-
- } catch (Exception e) {
-
- } finally {
- session.flush();
- session.close();
- }
- }
-
- public String delData(DeviceModbus data) {
- Session session = this.getSessionFactory().openSession();
- try {
- session.delete(data);
- flushCache(null);
- } catch (Exception e) {
- } finally {
- session.flush();
- session.close();
- }
- return null;
- }
-
-
-}
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/service/HModbusService.java b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/service/HModbusService.java
new file mode 100644
index 0000000..216aad2
--- /dev/null
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/modbus/service/HModbusService.java
@@ -0,0 +1,240 @@
+package com.ld.igds.modbus.service;
+
+import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
+import com.ld.igds.constant.BizType;
+import com.ld.igds.constant.Constant;
+import com.ld.igds.constant.RedisConst;
+import com.ld.igds.modbus.ModbusConstant;
+import com.ld.igds.models.DeviceModbus;
+import com.ld.igds.models.GasModbus;
+import com.ld.igds.util.ContextUtil;
+import com.ld.igds.util.RedisUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.hibernate.Session;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+
+@Component
+public class HModbusService extends HibernateDao {
+
+ @Resource
+ private RedisUtil redisUtil;
+
+
+ public List<DeviceModbus> listAllDevice(String companyId) {
+
+ String hql = " from " + DeviceModbus.class.getName() + " where 1=1 order by deviceCode+0";
+
+ return this.query(hql);
+ }
+
+ public void flushCacheDevice(String companyId) {
+
+ if (null == companyId) companyId = ContextUtil.getDefaultCompanyId();
+
+ List<DeviceModbus> listAll = this.listAllDevice(companyId);
+
+ if (null == listAll || listAll.isEmpty()) return;
+
+
+ String key;
+ DeviceModbus entityDevice;
+ for (DeviceModbus hibDevice : listAll) {
+ entityDevice = new DeviceModbus();
+ BeanUtils.copyProperties(hibDevice, entityDevice);
+ key = RedisConst.buildKey(companyId, ModbusConstant.MODBUS_DEVICE_CACHE, hibDevice.getDeviceCode());
+ redisUtil.set(key, entityDevice);
+ }
+ }
+
+ public DeviceModbus getCacheDeviceModbus(String companyId, String deviceCode) {
+ String key = RedisConst.buildKey(companyId, ModbusConstant.MODBUS_DEVICE_CACHE, deviceCode);
+ return (DeviceModbus) redisUtil.get(key);
+ }
+
+ public void updateDataDevice(List<DeviceModbus> details) {
+ if (null == details || details.isEmpty()) return;
+
+ Session session = this.getSessionFactory().openSession();
+ try {
+ for (DeviceModbus device : details) {
+
+
+ device = updateInitData(device);
+
+ if (null == device.getId()) {
+ device.setId(ContextUtil.getUUID());
+ session.save(device);
+ } else {
+ session.update(device);
+ }
+ }
+
+ flushCacheDevice(null);
+
+ } catch (Exception e) {
+
+ } finally {
+ session.flush();
+ session.close();
+ }
+ }
+
+ private DeviceModbus updateInitData(DeviceModbus device) {
+ if (StringUtils.isEmpty(device.getOpen())) device.setOpen(Constant.YN_N);
+ if (StringUtils.isEmpty(device.getOpenFun())) device.setOpenFun(ModbusConstant.FUN_99);
+
+ if (StringUtils.isEmpty(device.getOpenEnd())) device.setOpenEnd(Constant.YN_N);
+ if (StringUtils.isEmpty(device.getOpenEndFun())) device.setOpenEndFun(ModbusConstant.FUN_99);
+
+ if (StringUtils.isEmpty(device.getOpenError())) device.setOpenError(Constant.YN_N);
+ if (StringUtils.isEmpty(device.getOpenErrorFun())) device.setOpenErrorFun(ModbusConstant.FUN_99);
+
+ if (StringUtils.isEmpty(device.getClose())) device.setClose(Constant.YN_N);
+ if (StringUtils.isEmpty(device.getCloseFun())) device.setCloseFun(ModbusConstant.FUN_99);
+
+ if (StringUtils.isEmpty(device.getCloseEnd())) device.setCloseEnd(Constant.YN_N);
+ if (StringUtils.isEmpty(device.getCloseEndFun())) device.setCloseEndFun(ModbusConstant.FUN_99);
+
+ if (StringUtils.isEmpty(device.getCloseError())) device.setCloseError(Constant.YN_N);
+ if (StringUtils.isEmpty(device.getCloseErrorFun())) device.setCloseErrorFun(ModbusConstant.FUN_99);
+
+ if (StringUtils.isEmpty(device.getStop())) device.setStop(Constant.YN_N);
+ if (StringUtils.isEmpty(device.getStopFun())) device.setStopFun(ModbusConstant.FUN_99);
+
+
+ if (StringUtils.isEmpty(device.getBizType())) device.setBizType(BizType.AREATION.getCode());
+
+ return device;
+ }
+
+ public String delDataDevice(DeviceModbus data) {
+ Session session = this.getSessionFactory().openSession();
+ try {
+ session.delete(data);
+ flushCacheDevice(null);
+ } catch (Exception e) {
+ } finally {
+ session.flush();
+ session.close();
+ }
+ return null;
+ }
+
+
+ public DeviceModbus getGasData(String companyId, String depotId, String bizType) {
+
+ String hql = " from " + DeviceModbus.class.getName() + " where bizType=:bizType and deviceCode =:deviceCode";
+
+ Map<String, Object> param = new HashMap<>();
+ param.put("bizType", bizType);
+ param.put("deviceCode", depotId);
+ List<DeviceModbus> list = this.query(hql, param);
+
+ if (null == list || list.isEmpty()) {
+ return null;
+ }
+ return list.get(0);
+ }
+
+
+ public List<GasModbus> listGasModBus(String depotId) {
+ String hql = " from " + GasModbus.class.getName();
+
+ if (null == depotId) {
+ return this.query(hql);
+ } else {
+ hql += " where depotId=:depotId order by passcode";
+ Map<String, Object> param = new HashMap<>();
+ param.put("depotId", depotId);
+ return this.query(hql, param);
+ }
+ }
+
+ public void updateGasModbus(DeviceModbus data) {
+ Session session = this.getSessionFactory().openSession();
+ try {
+
+ data = updateInitData(data);
+ data.setBizType(BizType.GAS.getCode());
+
+ if (StringUtils.isEmpty(data.getId())) {
+ data.setId(ContextUtil.getUUID());
+ session.save(data);
+ } else {
+ session.update(data);
+ }
+ flushCacheDevice(null);
+
+ this.updateListGas(session, data);
+
+ } catch (Exception e) {
+ } finally {
+ session.flush();
+ session.close();
+ }
+ }
+
+ private void updateListGas(Session session, DeviceModbus data) {
+ List<GasModbus> list = data.getListGas();
+ if (null == list || list.isEmpty()) return;
+ for (GasModbus gas : list) {
+ gas.setDepotId(data.getDeviceCode());
+ if (StringUtils.isEmpty(gas.getId())) {
+ gas.setId(ContextUtil.getUUID());
+ session.save(gas);
+ } else {
+ session.update(gas);
+ }
+ }
+ flushCacheGas(null);
+ }
+
+ public void flushCacheGas(String companyId) {
+
+ List<GasModbus> listAll = this.listGasModBus(null);
+
+ if (null == listAll || listAll.isEmpty()) return;
+
+ if (null == companyId) companyId = ContextUtil.getDefaultCompanyId();
+
+
+ Map<String, List<GasModbus>> collect = listAll.stream().collect(Collectors.groupingBy(GasModbus::getDepotId));
+
+ String key;
+ for (String depotId : collect.keySet()) {
+ key = RedisConst.buildKey(companyId, ModbusConstant.MODBUS_GAS_CACHE_LIST, depotId);
+ redisUtil.set(key, key);
+ }
+ }
+
+
+ public List<GasModbus> getCacheGasModbus(String companyId, String depotId) {
+ if (null == companyId) companyId = ContextUtil.getDefaultCompanyId();
+ String key = RedisConst.buildKey(companyId, ModbusConstant.MODBUS_GAS_CACHE_LIST, depotId);
+ return (List<GasModbus>) redisUtil.get(key);
+ }
+
+
+ public String delDataGas(GasModbus data) {
+ Session session = this.getSessionFactory().openSession();
+ try {
+ session.delete(data);
+
+ flushCacheGas(null);
+ } catch (Exception e) {
+ } finally {
+ session.flush();
+ session.close();
+ }
+ return null;
+ }
+}
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java b/igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java
index e41d581..5d172eb 100644
--- a/igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/models/DeviceModbus.java
@@ -1,11 +1,13 @@
package com.ld.igds.models;
import com.bstek.dorado.annotation.PropertyDef;
+import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
+import java.util.List;
/**
* 鏍规嵁璁惧閰嶇疆鐨凪odbus-TCP鍙傛暟閰嶇疆
@@ -25,10 +27,15 @@
@Column(name = "DEVICE_CODE_", length = 40)
@PropertyDef(label = "璁惧缂栫爜")
private String deviceCode;
+
+ @Column(name = "BIZ_TYEP_", length = 10)
+ @PropertyDef(label = "涓氬姟绫诲瀷")
+ private String bizType = BizType.AREATION.getCode();
@Column(name = "OPEN_", length = 10)
@PropertyDef(label = "寮�鍦板潃")
private String open = Constant.YN_N;
+
@Column(name = "OPEN_FUN", length = 4)
@PropertyDef(label = "鍔熻兘鍙�")
@@ -82,4 +89,8 @@
@PropertyDef(label = "鍔熻兘鍙�")
private String closeErrorFun = "99";
+
+ @Transient
+ private List<GasModbus> listGas;
+
}
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/models/GasModbus.java b/igds-protocol-modbus/src/main/java/com/ld/igds/models/GasModbus.java
new file mode 100644
index 0000000..d7b3872
--- /dev/null
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/models/GasModbus.java
@@ -0,0 +1,60 @@
+package com.ld.igds.models;
+
+import com.bstek.dorado.annotation.PropertyDef;
+import com.ld.igds.constant.Constant;
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * 閰嶇疆娴嬫皵鍜屾祴铏殑MODBUS锛峊CP閰嶇疆淇℃伅
+ */
+@Data
+@Entity
+@Table(name = "D_GAS_MODBUS")
+public class GasModbus implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @Column(name = "ID_", length = 40)
+ @PropertyDef(label = "ID")
+ private String id;
+
+ @Column(name = "DEPOT_ID_", length = 50)
+ @PropertyDef(label = "鎵�灞炰粨搴�")
+ private String depotId;
+
+ @Column(name = "PASS_CODE_")
+ @PropertyDef(label = "閫氶亾")
+ private int passcode;
+
+ @Column(name = "CO2_", length = 10)
+ @PropertyDef(label = "浜屾哀鍖栫⒊")
+ private String co2 = Constant.YN_N;
+
+ @Column(name = "CO2_FUN", length = 4)
+ @PropertyDef(label = "鍔熻兘鍙�")
+ private String co2Fun = "99";
+
+ @Column(name = "O2_", length = 10)
+ @PropertyDef(label = "姘ф皵")
+ private String o2 = Constant.YN_N;
+
+ @Column(name = "O2_FUN", length = 4)
+ @PropertyDef(label = "鍔熻兘鍙�")
+ private String o2Fun = "99";
+
+ @Column(name = "PH3_", length = 10)
+ @PropertyDef(label = "纾峰寲姘�")
+ private String ph3= Constant.YN_N;
+
+ @Column(name = "PH3_FUN", length = 4)
+ @PropertyDef(label = "鍔熻兘鍙�")
+ private String ph3Fun = "99";
+
+}
diff --git a/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java b/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java
index 2bf1d8e..c59a7b2 100644
--- a/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java
+++ b/igds-protocol-modbus/src/main/java/com/ld/igds/protocol/modbus/command/RemoteControlServiceImpl.java
@@ -11,7 +11,7 @@
import com.ld.igds.io.request.ExeDevice;
import com.ld.igds.io.request.TempControlRequest;
import com.ld.igds.io.response.DeviceControlResponse;
-import com.ld.igds.modbus.service.HDeviceModbusService;
+import com.ld.igds.modbus.service.HModbusService;
import com.ld.igds.models.Device;
import com.ld.igds.models.DeviceModbus;
import com.ld.igds.protocol.modbus.ModbusUtil2;
@@ -40,7 +40,7 @@
@Resource
private CoreDeviceService coreDeviceService;
@Resource
- private HDeviceModbusService deviceModbusService;
+ private HModbusService deviceModbusService;
@Resource
private AnalysisService analysisService;
--
Gitblit v1.9.3