diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/task/ReadZmRtTask.java b/src/com/szpg/task/ReadZmRtTask.java deleted file mode 100644 index 30c5835..0000000 --- a/src/com/szpg/task/ReadZmRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadZmRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadZmRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READZMRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/task/ReadZmRtTask.java b/src/com/szpg/task/ReadZmRtTask.java deleted file mode 100644 index 30c5835..0000000 --- a/src/com/szpg/task/ReadZmRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadZmRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadZmRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READZMRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ResetDsTask.java b/src/com/szpg/task/ResetDsTask.java deleted file mode 100644 index a9a5a1e..0000000 --- a/src/com/szpg/task/ResetDsTask.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetDsRstBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -/** - * 清除对射报警 - * 0=正常/1=清除 - * - * @author admin - * - */ -public class ResetDsTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public ResetDsTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置解锁位的命令 - SetDsRstBitCommand setRstCmd = new SetDsRstBitCommand(); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".RST"); - if (null != onBlObj) { - setRstCmd.setMessageProducerId(sour); - setRstCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setRstCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setRstCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setRstCmd.setBit(bit); - - // 位数 - setRstCmd.setCount(end - start + 1); - - // 位内容 - setRstCmd.setValue(new byte[] {(byte) SetDsRstBitCommand.DS_RST} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setRstCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setRstCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setRstCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/task/ReadZmRtTask.java b/src/com/szpg/task/ReadZmRtTask.java deleted file mode 100644 index 30c5835..0000000 --- a/src/com/szpg/task/ReadZmRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadZmRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadZmRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READZMRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ResetDsTask.java b/src/com/szpg/task/ResetDsTask.java deleted file mode 100644 index a9a5a1e..0000000 --- a/src/com/szpg/task/ResetDsTask.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetDsRstBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -/** - * 清除对射报警 - * 0=正常/1=清除 - * - * @author admin - * - */ -public class ResetDsTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public ResetDsTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置解锁位的命令 - SetDsRstBitCommand setRstCmd = new SetDsRstBitCommand(); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".RST"); - if (null != onBlObj) { - setRstCmd.setMessageProducerId(sour); - setRstCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setRstCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setRstCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setRstCmd.setBit(bit); - - // 位数 - setRstCmd.setCount(end - start + 1); - - // 位内容 - setRstCmd.setValue(new byte[] {(byte) SetDsRstBitCommand.DS_RST} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setRstCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setRstCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setRstCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetSdThresholdTask.java b/src/com/szpg/task/SetSdThresholdTask.java deleted file mode 100644 index cab2da8..0000000 --- a/src/com/szpg/task/SetSdThresholdTask.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetSdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetSdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetSdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - String acucode = deviceCode.substring(0, deviceCode.indexOf(".", 6)); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetSdThresholdWordCommand setWetThreCmd = new SetSdThresholdWordCommand(); - setWetThreCmd.setThreshold(threshold); - PgHjsbbl wetBlObj = blDao.findBlByBh(deviceCode + ".WetSet"); - if (null != wetBlObj) { - setWetThreCmd.setMessageProducerId(sour); - setWetThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setWetThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = wetBlObj.getKszdz(); - int end = wetBlObj.getJszdz(); - - // 开始字地址 - setWetThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setWetThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setWetThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setWetThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setWetThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setWetThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/task/ReadZmRtTask.java b/src/com/szpg/task/ReadZmRtTask.java deleted file mode 100644 index 30c5835..0000000 --- a/src/com/szpg/task/ReadZmRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadZmRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadZmRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READZMRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ResetDsTask.java b/src/com/szpg/task/ResetDsTask.java deleted file mode 100644 index a9a5a1e..0000000 --- a/src/com/szpg/task/ResetDsTask.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetDsRstBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -/** - * 清除对射报警 - * 0=正常/1=清除 - * - * @author admin - * - */ -public class ResetDsTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public ResetDsTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置解锁位的命令 - SetDsRstBitCommand setRstCmd = new SetDsRstBitCommand(); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".RST"); - if (null != onBlObj) { - setRstCmd.setMessageProducerId(sour); - setRstCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setRstCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setRstCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setRstCmd.setBit(bit); - - // 位数 - setRstCmd.setCount(end - start + 1); - - // 位内容 - setRstCmd.setValue(new byte[] {(byte) SetDsRstBitCommand.DS_RST} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setRstCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setRstCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setRstCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetSdThresholdTask.java b/src/com/szpg/task/SetSdThresholdTask.java deleted file mode 100644 index cab2da8..0000000 --- a/src/com/szpg/task/SetSdThresholdTask.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetSdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetSdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetSdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - String acucode = deviceCode.substring(0, deviceCode.indexOf(".", 6)); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetSdThresholdWordCommand setWetThreCmd = new SetSdThresholdWordCommand(); - setWetThreCmd.setThreshold(threshold); - PgHjsbbl wetBlObj = blDao.findBlByBh(deviceCode + ".WetSet"); - if (null != wetBlObj) { - setWetThreCmd.setMessageProducerId(sour); - setWetThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setWetThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = wetBlObj.getKszdz(); - int end = wetBlObj.getJszdz(); - - // 开始字地址 - setWetThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setWetThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setWetThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setWetThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setWetThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setWetThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetWdThresholdTask.java b/src/com/szpg/task/SetWdThresholdTask.java deleted file mode 100644 index ef2630c..0000000 --- a/src/com/szpg/task/SetWdThresholdTask.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetWdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetWdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetWdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetWdThresholdWordCommand setTemThreCmd = new SetWdThresholdWordCommand(); - setTemThreCmd.setThreshold(threshold); - PgHjsbbl temBlObj = blDao.findBlByBh(deviceCode + ".TemSet"); - if (null != temBlObj) { - setTemThreCmd.setMessageProducerId(sour); - setTemThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setTemThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = temBlObj.getKszdz(); - int end = temBlObj.getJszdz(); - - // 开始字地址 - setTemThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setTemThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setTemThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setTemThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setTemThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setTemThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/task/ReadZmRtTask.java b/src/com/szpg/task/ReadZmRtTask.java deleted file mode 100644 index 30c5835..0000000 --- a/src/com/szpg/task/ReadZmRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadZmRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadZmRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READZMRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ResetDsTask.java b/src/com/szpg/task/ResetDsTask.java deleted file mode 100644 index a9a5a1e..0000000 --- a/src/com/szpg/task/ResetDsTask.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetDsRstBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -/** - * 清除对射报警 - * 0=正常/1=清除 - * - * @author admin - * - */ -public class ResetDsTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public ResetDsTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置解锁位的命令 - SetDsRstBitCommand setRstCmd = new SetDsRstBitCommand(); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".RST"); - if (null != onBlObj) { - setRstCmd.setMessageProducerId(sour); - setRstCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setRstCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setRstCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setRstCmd.setBit(bit); - - // 位数 - setRstCmd.setCount(end - start + 1); - - // 位内容 - setRstCmd.setValue(new byte[] {(byte) SetDsRstBitCommand.DS_RST} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setRstCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setRstCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setRstCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetSdThresholdTask.java b/src/com/szpg/task/SetSdThresholdTask.java deleted file mode 100644 index cab2da8..0000000 --- a/src/com/szpg/task/SetSdThresholdTask.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetSdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetSdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetSdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - String acucode = deviceCode.substring(0, deviceCode.indexOf(".", 6)); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetSdThresholdWordCommand setWetThreCmd = new SetSdThresholdWordCommand(); - setWetThreCmd.setThreshold(threshold); - PgHjsbbl wetBlObj = blDao.findBlByBh(deviceCode + ".WetSet"); - if (null != wetBlObj) { - setWetThreCmd.setMessageProducerId(sour); - setWetThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setWetThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = wetBlObj.getKszdz(); - int end = wetBlObj.getJszdz(); - - // 开始字地址 - setWetThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setWetThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setWetThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setWetThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setWetThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setWetThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetWdThresholdTask.java b/src/com/szpg/task/SetWdThresholdTask.java deleted file mode 100644 index ef2630c..0000000 --- a/src/com/szpg/task/SetWdThresholdTask.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetWdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetWdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetWdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetWdThresholdWordCommand setTemThreCmd = new SetWdThresholdWordCommand(); - setTemThreCmd.setThreshold(threshold); - PgHjsbbl temBlObj = blDao.findBlByBh(deviceCode + ".TemSet"); - if (null != temBlObj) { - setTemThreCmd.setMessageProducerId(sour); - setTemThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setTemThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = temBlObj.getKszdz(); - int end = temBlObj.getJszdz(); - - // 开始字地址 - setTemThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setTemThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setTemThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setTemThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setTemThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setTemThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/TurnOffFjTask.java b/src/com/szpg/task/TurnOffFjTask.java deleted file mode 100644 index 2b45870..0000000 --- a/src/com/szpg/task/TurnOffFjTask.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetFjOffBitCommand; -import com.szpg.plc.message.command.write.SetFjOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOffFjTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOffFjTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将启动位置0 - SetFjOnBitCommand clearOnCmd = new SetFjOnBitCommand(); - clearOnCmd.setFjon(SetFjOnBitCommand.FJ_ON_DISABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - clearOnCmd.setMessageProducerId(sour); - clearOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - clearOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOnCmd.setBit(bit); - - // 位数 - clearOnCmd.setCount(end - start + 1); - - // 位内容 - clearOnCmd.setValue(new byte[] {(byte) clearOnCmd.getFjon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除启动位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetFjOffBitCommand setOffCmd = new SetFjOffBitCommand(); - setOffCmd.setFjoff(SetFjOffBitCommand.FJ_OFF_ENABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - setOffCmd.setMessageProducerId(sour); - setOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - setOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOffCmd.setBit(bit); - - // 位数 - setOffCmd.setCount(end - start + 1); - - // 位内容 - setOffCmd.setValue(new byte[] {(byte) setOffCmd.getFjoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOffCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOffCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/task/ReadZmRtTask.java b/src/com/szpg/task/ReadZmRtTask.java deleted file mode 100644 index 30c5835..0000000 --- a/src/com/szpg/task/ReadZmRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadZmRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadZmRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READZMRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ResetDsTask.java b/src/com/szpg/task/ResetDsTask.java deleted file mode 100644 index a9a5a1e..0000000 --- a/src/com/szpg/task/ResetDsTask.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetDsRstBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -/** - * 清除对射报警 - * 0=正常/1=清除 - * - * @author admin - * - */ -public class ResetDsTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public ResetDsTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置解锁位的命令 - SetDsRstBitCommand setRstCmd = new SetDsRstBitCommand(); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".RST"); - if (null != onBlObj) { - setRstCmd.setMessageProducerId(sour); - setRstCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setRstCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setRstCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setRstCmd.setBit(bit); - - // 位数 - setRstCmd.setCount(end - start + 1); - - // 位内容 - setRstCmd.setValue(new byte[] {(byte) SetDsRstBitCommand.DS_RST} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setRstCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setRstCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setRstCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetSdThresholdTask.java b/src/com/szpg/task/SetSdThresholdTask.java deleted file mode 100644 index cab2da8..0000000 --- a/src/com/szpg/task/SetSdThresholdTask.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetSdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetSdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetSdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - String acucode = deviceCode.substring(0, deviceCode.indexOf(".", 6)); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetSdThresholdWordCommand setWetThreCmd = new SetSdThresholdWordCommand(); - setWetThreCmd.setThreshold(threshold); - PgHjsbbl wetBlObj = blDao.findBlByBh(deviceCode + ".WetSet"); - if (null != wetBlObj) { - setWetThreCmd.setMessageProducerId(sour); - setWetThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setWetThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = wetBlObj.getKszdz(); - int end = wetBlObj.getJszdz(); - - // 开始字地址 - setWetThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setWetThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setWetThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setWetThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setWetThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setWetThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetWdThresholdTask.java b/src/com/szpg/task/SetWdThresholdTask.java deleted file mode 100644 index ef2630c..0000000 --- a/src/com/szpg/task/SetWdThresholdTask.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetWdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetWdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetWdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetWdThresholdWordCommand setTemThreCmd = new SetWdThresholdWordCommand(); - setTemThreCmd.setThreshold(threshold); - PgHjsbbl temBlObj = blDao.findBlByBh(deviceCode + ".TemSet"); - if (null != temBlObj) { - setTemThreCmd.setMessageProducerId(sour); - setTemThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setTemThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = temBlObj.getKszdz(); - int end = temBlObj.getJszdz(); - - // 开始字地址 - setTemThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setTemThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setTemThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setTemThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setTemThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setTemThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/TurnOffFjTask.java b/src/com/szpg/task/TurnOffFjTask.java deleted file mode 100644 index 2b45870..0000000 --- a/src/com/szpg/task/TurnOffFjTask.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetFjOffBitCommand; -import com.szpg.plc.message.command.write.SetFjOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOffFjTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOffFjTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将启动位置0 - SetFjOnBitCommand clearOnCmd = new SetFjOnBitCommand(); - clearOnCmd.setFjon(SetFjOnBitCommand.FJ_ON_DISABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - clearOnCmd.setMessageProducerId(sour); - clearOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - clearOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOnCmd.setBit(bit); - - // 位数 - clearOnCmd.setCount(end - start + 1); - - // 位内容 - clearOnCmd.setValue(new byte[] {(byte) clearOnCmd.getFjon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除启动位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetFjOffBitCommand setOffCmd = new SetFjOffBitCommand(); - setOffCmd.setFjoff(SetFjOffBitCommand.FJ_OFF_ENABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - setOffCmd.setMessageProducerId(sour); - setOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - setOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOffCmd.setBit(bit); - - // 位数 - setOffCmd.setCount(end - start + 1); - - // 位内容 - setOffCmd.setValue(new byte[] {(byte) setOffCmd.getFjoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOffCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOffCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } -} diff --git a/src/com/szpg/task/TurnOffZmTask.java b/src/com/szpg/task/TurnOffZmTask.java deleted file mode 100644 index c46119b..0000000 --- a/src/com/szpg/task/TurnOffZmTask.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetZmOffBitCommand; -import com.szpg.plc.message.command.write.SetZmOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOffZmTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOffZmTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将启动位置0 - SetZmOnBitCommand clearOnCmd = new SetZmOnBitCommand(); - clearOnCmd.setZmon(SetZmOnBitCommand.ZM_ON_DISABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - clearOnCmd.setMessageProducerId(sour); - clearOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - clearOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOnCmd.setBit(bit); - - // 位数 - clearOnCmd.setCount(end - start + 1); - - // 位内容 - clearOnCmd.setValue(new byte[] {(byte) clearOnCmd.getZmon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除启动位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetZmOffBitCommand setOffCmd = new SetZmOffBitCommand(); - setOffCmd.setZmoff(SetZmOffBitCommand.ZM_OFF_ENABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - setOffCmd.setMessageProducerId(sour); - setOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - setOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOffCmd.setBit(bit); - - // 位数 - setOffCmd.setCount(end - start + 1); - - // 位内容 - setOffCmd.setValue(new byte[] {(byte) setOffCmd.getZmoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOffCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOffCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/task/ReadZmRtTask.java b/src/com/szpg/task/ReadZmRtTask.java deleted file mode 100644 index 30c5835..0000000 --- a/src/com/szpg/task/ReadZmRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadZmRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadZmRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READZMRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ResetDsTask.java b/src/com/szpg/task/ResetDsTask.java deleted file mode 100644 index a9a5a1e..0000000 --- a/src/com/szpg/task/ResetDsTask.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetDsRstBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -/** - * 清除对射报警 - * 0=正常/1=清除 - * - * @author admin - * - */ -public class ResetDsTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public ResetDsTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置解锁位的命令 - SetDsRstBitCommand setRstCmd = new SetDsRstBitCommand(); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".RST"); - if (null != onBlObj) { - setRstCmd.setMessageProducerId(sour); - setRstCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setRstCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setRstCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setRstCmd.setBit(bit); - - // 位数 - setRstCmd.setCount(end - start + 1); - - // 位内容 - setRstCmd.setValue(new byte[] {(byte) SetDsRstBitCommand.DS_RST} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setRstCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setRstCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setRstCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetSdThresholdTask.java b/src/com/szpg/task/SetSdThresholdTask.java deleted file mode 100644 index cab2da8..0000000 --- a/src/com/szpg/task/SetSdThresholdTask.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetSdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetSdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetSdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - String acucode = deviceCode.substring(0, deviceCode.indexOf(".", 6)); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetSdThresholdWordCommand setWetThreCmd = new SetSdThresholdWordCommand(); - setWetThreCmd.setThreshold(threshold); - PgHjsbbl wetBlObj = blDao.findBlByBh(deviceCode + ".WetSet"); - if (null != wetBlObj) { - setWetThreCmd.setMessageProducerId(sour); - setWetThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setWetThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = wetBlObj.getKszdz(); - int end = wetBlObj.getJszdz(); - - // 开始字地址 - setWetThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setWetThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setWetThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setWetThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setWetThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setWetThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetWdThresholdTask.java b/src/com/szpg/task/SetWdThresholdTask.java deleted file mode 100644 index ef2630c..0000000 --- a/src/com/szpg/task/SetWdThresholdTask.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetWdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetWdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetWdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetWdThresholdWordCommand setTemThreCmd = new SetWdThresholdWordCommand(); - setTemThreCmd.setThreshold(threshold); - PgHjsbbl temBlObj = blDao.findBlByBh(deviceCode + ".TemSet"); - if (null != temBlObj) { - setTemThreCmd.setMessageProducerId(sour); - setTemThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setTemThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = temBlObj.getKszdz(); - int end = temBlObj.getJszdz(); - - // 开始字地址 - setTemThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setTemThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setTemThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setTemThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setTemThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setTemThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/TurnOffFjTask.java b/src/com/szpg/task/TurnOffFjTask.java deleted file mode 100644 index 2b45870..0000000 --- a/src/com/szpg/task/TurnOffFjTask.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetFjOffBitCommand; -import com.szpg.plc.message.command.write.SetFjOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOffFjTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOffFjTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将启动位置0 - SetFjOnBitCommand clearOnCmd = new SetFjOnBitCommand(); - clearOnCmd.setFjon(SetFjOnBitCommand.FJ_ON_DISABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - clearOnCmd.setMessageProducerId(sour); - clearOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - clearOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOnCmd.setBit(bit); - - // 位数 - clearOnCmd.setCount(end - start + 1); - - // 位内容 - clearOnCmd.setValue(new byte[] {(byte) clearOnCmd.getFjon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除启动位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetFjOffBitCommand setOffCmd = new SetFjOffBitCommand(); - setOffCmd.setFjoff(SetFjOffBitCommand.FJ_OFF_ENABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - setOffCmd.setMessageProducerId(sour); - setOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - setOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOffCmd.setBit(bit); - - // 位数 - setOffCmd.setCount(end - start + 1); - - // 位内容 - setOffCmd.setValue(new byte[] {(byte) setOffCmd.getFjoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOffCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOffCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } -} diff --git a/src/com/szpg/task/TurnOffZmTask.java b/src/com/szpg/task/TurnOffZmTask.java deleted file mode 100644 index c46119b..0000000 --- a/src/com/szpg/task/TurnOffZmTask.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetZmOffBitCommand; -import com.szpg.plc.message.command.write.SetZmOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOffZmTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOffZmTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将启动位置0 - SetZmOnBitCommand clearOnCmd = new SetZmOnBitCommand(); - clearOnCmd.setZmon(SetZmOnBitCommand.ZM_ON_DISABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - clearOnCmd.setMessageProducerId(sour); - clearOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - clearOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOnCmd.setBit(bit); - - // 位数 - clearOnCmd.setCount(end - start + 1); - - // 位内容 - clearOnCmd.setValue(new byte[] {(byte) clearOnCmd.getZmon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除启动位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetZmOffBitCommand setOffCmd = new SetZmOffBitCommand(); - setOffCmd.setZmoff(SetZmOffBitCommand.ZM_OFF_ENABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - setOffCmd.setMessageProducerId(sour); - setOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - setOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOffCmd.setBit(bit); - - // 位数 - setOffCmd.setCount(end - start + 1); - - // 位内容 - setOffCmd.setValue(new byte[] {(byte) setOffCmd.getZmoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOffCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOffCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } -} diff --git a/src/com/szpg/task/TurnOnFjTask.java b/src/com/szpg/task/TurnOnFjTask.java deleted file mode 100644 index d61cded..0000000 --- a/src/com/szpg/task/TurnOnFjTask.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetFjOffBitCommand; -import com.szpg.plc.message.command.write.SetFjOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOnFjTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOnFjTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将停止位置0 - SetFjOffBitCommand clearOffCmd = new SetFjOffBitCommand(); - clearOffCmd.setFjoff(SetFjOffBitCommand.FJ_OFF_DISABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - clearOffCmd.setMessageProducerId(sour); - clearOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - clearOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOffCmd.setBit(bit); - - // 位数 - clearOffCmd.setCount(end - start + 1); - - // 位内容 - clearOffCmd.setValue(new byte[] {(byte) clearOffCmd.getFjoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除停止位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetFjOnBitCommand setOnCmd = new SetFjOnBitCommand(); - setOnCmd.setFjon(SetFjOnBitCommand.FJ_ON_ENABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - setOnCmd.setMessageProducerId(sour); - setOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOnCmd.setBit(bit); - - // 位数 - setOnCmd.setCount(end - start + 1); - - // 位内容 - setOnCmd.setValue(new byte[] {(byte) setOnCmd.getFjon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOnCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOnCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/DSCTest.java b/src/com/szpg/DSCTest.java deleted file mode 100644 index 1173e76..0000000 --- a/src/com/szpg/DSCTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.szpg; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.task.ACUSocketCheckTask; -import com.szpg.task.ReadCH4StatusTask; -import com.szpg.task.ReadCH4ValueTask; -import com.szpg.task.ReadCOStatusTask; -import com.szpg.task.ReadCOValueTask; -import com.szpg.task.ReadDSStatusTask; -import com.szpg.task.ReadFjRtTask; -import com.szpg.task.ReadFjStatTask; -import com.szpg.task.ReadHSStatusTask; -import com.szpg.task.ReadHSValueTask; -import com.szpg.task.ReadJgStatusTask; -import com.szpg.task.ReadO2StatusTask; -import com.szpg.task.ReadO2ValueTask; -import com.szpg.task.ReadSbRtTask; -import com.szpg.task.ReadSbStatTask; -import com.szpg.task.ReadWSStatusTask; -import com.szpg.task.ReadWSValueTask; -import com.szpg.task.ReadYWStatusTask; -import com.szpg.task.ReadZmRtTask; -import com.szpg.task.ReadZmStatTask; -import com.szpg.task.ResetDsTask; -import com.szpg.task.SetCH4ThresholdTask; -import com.szpg.task.SetCOThresholdTask; -import com.szpg.task.SetHSThresholdTask; -import com.szpg.task.SetJgUnlockTask; -import com.szpg.task.SetO2ThresholdTask; -import com.szpg.task.SetSdThresholdTask; -import com.szpg.task.SetWdThresholdTask; -import com.szpg.task.TurnOffFjTask; -import com.szpg.task.TurnOffZmTask; -import com.szpg.task.TurnOnFjTask; -import com.szpg.task.TurnOnZmTask; - -public class DSCTest { - - private static DSCTest dsc = new DSCTest(); - - public static void main(String[] args) { - // PLC设备地址和端口 - ACUClient client = new ACUClient("172.20.10.5", 9600); - - PgAcu acu = new PgAcuDaoImpl().findACUById(14); - client.setAcucode(acu.getAcu_code()); - client.setNet(acu.getAcu_net()); //网络号 - client.setNode(acu.getAcu_node()); //节点号 - client.setUnit(acu.getAcu_unit()); //单元号 - - // 3将ACU的信息加入到map中 - ACUClientUtil.getInstance().addClient(client); - - // 4新建线程启动client - new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(new ACUSocketCheckTask(client), 0, 30, TimeUnit.SECONDS); - - // 甲烷 -// dsc.testSendCH4Command(); -// dsc.testSendCH4StatusCommand(); - - // 温湿度 -// dsc.testSendWSCommand(); -// dsc.testSendWSStatusCommand(); -// dsc.testSendWSThresholdCommand("THXC.ACU016.J.RWS02"); - - // 一氧化碳 -// dsc.testSendCOCommand(); -// dsc.testSendCOStatusCommand(); - - // 氧气 -// dsc.testSendO2Command(); -// dsc.testSendO2StatusCommand(); - - // 硫化氢 -// dsc.testSendHSCommand(); -// dsc.testSendHSStatusCommand(); - - // 爆管液位 -// dsc.testSendYWStatusCommand(); - - // 对射报警 -// dsc.testSendDSStatusCommand(); - - // 井盖 -// dsc.testSendJgStatusCommand(); - - // 风机 - dsc.testSendFjStatCommand(); -// dsc.testSendFjRtCommand(); - - // 水泵 -// dsc.testSendSbRtCommand(); -// dsc.testSendSbStatCommand(); - - // 照明 -// dsc.testSendZmRtCommand(); -// dsc.testSendZmStatCommand(); - - // 照明开关 -// dsc.testSendTurnOnZmCommand("YXL.ACU001.RZM01"); -// dsc.testSendTurnOffZmCommand("YXL.ACU001.RZM01"); - - // 风机开关 -// dsc.testSendTurnOnFjCommand("YXL.ACU001.RFJ01"); -// dsc.testSendTurnOffFjCommand("YXL.ACU001.RFJ01"); - - // 井盖解锁 -// dsc.testSendUnlockJgCommand("YXL.ACU001.RJG01"); - - // 对射报警清除 -// dsc.testSendResetDsCommand("YXL.ACU001.DIR02"); - - // 甲烷报警阈值设定 -// dsc.testSendCH4ThresholdCommand("YXL.ACU001.SCH01"); - - // 硫化氢报警阈值设定 -// dsc.testSendHSThresholdCommand("YXL.ACU001.RHS01"); - - // 温湿度报警阈值设定 -// dsc.testSendWSThresholdCommand("YXL.ACU001.SWS01"); - - // 氧气报警阈值设定 -// dsc.testSendO2ThresholdCommand("YXL.ACU001.SYQ01"); - - // 一氧化碳阈值设定 -// dsc.testSendCOThresholdCommand("YXL.ACU001.RCO01"); - } - - /** - * 发送查询甲烷监测值命令 - * - * @param client - */ - private void testSendCH4Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4ValueTask(), 10, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询甲烷报警状态命令 - * @param client - */ - private void testSendCH4StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCH4StatusTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度监测值命令 - * - * @param client - */ - private void testSendWSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSValueTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询温湿度报警状态命令 - * @param client - */ - private void testSendWSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadWSStatusTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳监测值命令 - * - * @param client - */ - private void testSendCOCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOValueTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendCOStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadCOStatusTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询氧气监测值命令 - * - * @param client - */ - private void testSendO2Command() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2ValueTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询一氧化碳报警状态命令 - * @param client - */ - private void testSendO2StatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadO2StatusTask(), 45, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢监测值命令 - * - * @param client - */ - private void testSendHSCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSValueTask(), 50, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询硫化氢报警状态命令 - * @param client - */ - private void testSendHSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadHSStatusTask(), 55, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询爆管液位报警状态命令 - * @param client - */ - private void testSendYWStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadYWStatusTask(), 10, 300, TimeUnit.SECONDS); - } - - - /** - * 发送查询对射报警状态命令 - * @param client - */ - private void testSendDSStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadDSStatusTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询井盖状态命令 - * @param client - */ - private void testSendJgStatusCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadJgStatusTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行状态命令 - * @param client - */ - private void testSendFjStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjStatTask(), 15, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询风机运行时长命令 - * @param client - */ - private void testSendFjRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadFjRtTask(), 20, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行状态命令 - * @param client - */ - private void testSendSbStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbStatTask(), 25, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询水泵运行时长命令 - * @param client - */ - private void testSendSbRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadSbRtTask(), 30, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行状态命令 - * @param client - */ - private void testSendZmStatCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmStatTask(), 35, 300, TimeUnit.SECONDS); - } - - /** - * 发送查询照明运行时长命令 - * @param client - */ - private void testSendZmRtCommand() { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.scheduleWithFixedDelay(new ReadZmRtTask(), 40, 300, TimeUnit.SECONDS); - } - - /** - * 发送打开照明 - */ - private void testSendTurnOnZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnZmTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭照明 - */ - private void testSendTurnOffZmCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffZmTask(deviceCode), 20, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送打开风机 - */ - private void testSendTurnOnFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOnFjTask(deviceCode), 25, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送关闭风机 - */ - private void testSendTurnOffFjCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new TurnOffFjTask(deviceCode), 30, TimeUnit.SECONDS); - sche.shutdown(); - } - - - /** - * 发送解锁井盖 - */ - private void testSendUnlockJgCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new SetJgUnlockTask(deviceCode, 1), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 清除对射报警 - */ - private void testSendResetDsCommand(String deviceCode) { - ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); - sche.schedule(new ResetDsTask(deviceCode), 15, TimeUnit.SECONDS); - sche.shutdown(); - } - - /** - * 设置甲烷报警阈值 - */ -// private void testSendCH4ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCH4ThresholdTask(deviceCode, 40.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendHSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetHSThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置硫化氢报警阈值 - */ -// private void testSendWSThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetWdThresholdTask(deviceCode, 35.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// -// ScheduledExecutorService sche2 = new ScheduledThreadPoolExecutor(1); -// sche2.schedule(new SetSdThresholdTask(deviceCode, 75.0f), 20, TimeUnit.SECONDS); -// sche2.shutdown(); -// } - - /** - * 设置氧气报警阈值 - */ -// private void testSendO2ThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetO2ThresholdTask(deviceCode, 18.0f), 15, TimeUnit.SECONDS); -// sche.shutdown(); -// } - - /** - * 设置一氧化碳报警阈值 - */ -// private void testSendCOThresholdCommand(String deviceCode) { -// ScheduledExecutorService sche = new ScheduledThreadPoolExecutor(1); -// sche.schedule(new SetCOThresholdTask(deviceCode, 55.0f), 20, TimeUnit.SECONDS); -// sche.shutdown(); -// } -} diff --git a/src/com/szpg/db/dao/PgDsDao.java b/src/com/szpg/db/dao/PgDsDao.java deleted file mode 100644 index 39cfe95..0000000 --- a/src/com/szpg/db/dao/PgDsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.szpg.db.dao; - -import java.util.List; - -import com.szpg.db.data.PgDsAlm; - -/** - * 对射报警相关参数读写的数据库接口 - * @author admin - * - */ -public interface PgDsDao { - - /******** 对射报警状态 ********/ - public List findAllSbjz(); - public PgDsAlm findSbjzById(Integer id); - - public List findSbjzByDevice(Integer deviceid); - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end); - - public int addSbjzRecord(PgDsAlm hsalm); - public int addSbjzRecord(boolean status, String tm, int deviceid); -} diff --git a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java b/src/com/szpg/db/dao/impl/PgDsDaoImpl.java deleted file mode 100644 index d451678..0000000 --- a/src/com/szpg/db/dao/impl/PgDsDaoImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.szpg.db.dao.impl; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.ArrayListHandler; -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgDsDao; -import com.szpg.db.data.PgDsAlm; -import com.szpg.db.util.ConnectionManager; - -public class PgDsDaoImpl implements PgDsDao { - - private final Logger logger = Logger.getLogger(this.getClass().getName()); - - @Override - public List findAllSbjz() { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM"; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("查询所有对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("查询所有对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public PgDsAlm findSbjzById(Integer id) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE ID = ?"; - Object[] param = new Object[1]; - param[0] = id; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); - - if (null != tempList && tempList.size() == 1) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(0); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - logger.debug("根据ID查询对射报警状态成功" + dsalm + "]"); - - return dsalm; - } - else - return null; - } catch (Exception ex) { - logger.error("根据ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDevice(Integer deviceid) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ?"; - Object[] param = new Object[1]; - param[0] = deviceid; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public List findSbjzByDeviceAndTm(Integer deviceid, String start, String end) { - Connection conn = null; - - String queryStr = "SELECT ID, DSALM, LOGTIME, PGDEVICEID FROM PG_DS_ALM WHERE PGDEVICEID = ? AND LOGTIME >= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND LOGTIME <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')"; - Object[] params = new Object[3]; - params[0] = deviceid; - params[1] = start; - params[2] = end; - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); - - if (null != tempList && tempList.isEmpty() == false) { - logger.debug("根据设备ID和时间查询对射报警状态成功[" + tempList.size() + "]"); - - List list = new ArrayList(); - for (int i = 0; i < tempList.size(); i++) { - PgDsAlm dsalm = new PgDsAlm(); - Object[] item = tempList.get(i); - - dsalm.setId(((Number) item[0]).intValue()); - dsalm.setDsalm(Boolean.parseBoolean((String) item[1])); - dsalm.setPgdeviceid(((Number) item[3]).intValue()); - - long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(tmValue); - dsalm.setLogtime(cal.getTime()); - dsalm.setUptime(cal.getTime()); - - list.add(dsalm); - } - return list; - } - else - return null; - } catch (Exception ex) { - logger.error("根据设备ID和时间查询对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return null; - } - - @Override - public int addSbjzRecord(PgDsAlm dsalm) { - return addSbjzRecord(dsalm.getDsalm(), dsalm.getTmStr(), dsalm.getPgdeviceid()); - } - - @Override - public int addSbjzRecord(boolean status, String tm, int deviceid) { - Connection conn = null; - - String insertStr = "INSERT INTO PG_DS_ALM " + - "(DSALM, LOGTIME, UPTIME, PGDEVICEID) " + - "VALUES (?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; - Object[] params = new Object[4]; - params[0] = status; - params[1] = tm; - params[2] = tm; - params[3] = deviceid; - - try { - conn = ConnectionManager.getConnectionFromC3P0(); - conn.setAutoCommit(false); - - QueryRunner runner = new QueryRunner(); - int count = runner.update(conn, insertStr, params); - - if (count > 0) - logger.debug("插入对射报警状态成功[tm=" + tm + ", status=" + status + ", deviceid=" + deviceid + "]"); - else - logger.error("插入对射报警状态失败!"); - - return count; - } catch (Exception ex) { - logger.error("插入对射报警状态异常", ex); - } finally { - try { - DbUtils.commitAndClose(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - return 0; - } - -} diff --git a/src/com/szpg/db/data/PgCOAlm.java b/src/com/szpg/db/data/PgCOAlm.java deleted file mode 100644 index 3b09364..0000000 --- a/src/com/szpg/db/data/PgCOAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 一氧化碳浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCOAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean coalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCoalm() { - return coalm; - } - - public void setCoalm(Boolean ch4alm) { - this.coalm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCOAlm[coalm=" + coalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgCh4Alm.java b/src/com/szpg/db/data/PgCh4Alm.java deleted file mode 100644 index 6c3302c..0000000 --- a/src/com/szpg/db/data/PgCh4Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 甲烷浓度报警状态数据表 - * - * @author admin - * - */ -public class PgCh4Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -109172405679187040L; - - private Integer id; - private Boolean ch4alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getCh4alm() { - return ch4alm; - } - - public void setCh4alm(Boolean ch4alm) { - this.ch4alm = ch4alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgCh4[ch4=" + ch4alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgDsAlm.java b/src/com/szpg/db/data/PgDsAlm.java deleted file mode 100644 index 224d029..0000000 --- a/src/com/szpg/db/data/PgDsAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 对射报警状态数据表 - * - * @author admin - * - */ -public class PgDsAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -8336945265752238748L; - - private Integer id; - private Boolean dsalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getDsalm() { - return dsalm; - } - - public void setDsalm(Boolean dsalm) { - this.dsalm = dsalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgDSAlm[dsalm=" + dsalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgO2Alm.java b/src/com/szpg/db/data/PgO2Alm.java deleted file mode 100644 index 0c067bb..0000000 --- a/src/com/szpg/db/data/PgO2Alm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 氧气浓度报警状态数据表 - * - * @author admin - * - */ -public class PgO2Alm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = -2069351218525911493L; - - private Integer id; - private Boolean o2alm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getO2alm() { - return o2alm; - } - - public void setO2alm(Boolean o2alm) { - this.o2alm = o2alm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgO2Alm[o2alm=" + o2alm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/data/PgSHAlm.java b/src/com/szpg/db/data/PgSHAlm.java deleted file mode 100644 index afeb05a..0000000 --- a/src/com/szpg/db/data/PgSHAlm.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.szpg.db.data; - -import java.util.Date; - -import com.szpg.util.TimeFormat; - -/** - * 硫化氢浓度报警状态数据表 - * - * @author admin - * - */ -public class PgSHAlm implements java.io.Serializable { - - /** - * - */ - private static final long serialVersionUID = 3882791834818808488L; - - private Integer id; - private Boolean shalm; - private Date logtime; - private Date uptime; - private Integer pgdeviceid; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean getShalm() { - return shalm; - } - - public void setShalm(Boolean shalm) { - this.shalm = shalm; - } - - public Date getLogtime() { - return logtime; - } - - public void setLogtime(Date logtime) { - this.logtime = logtime; - } - - public Date getUptime() { - return uptime; - } - - public void setUptime(Date uptime) { - this.uptime = uptime; - } - - public Integer getPgdeviceid() { - return pgdeviceid; - } - - public void setPgdeviceid(Integer pgdeviceid) { - this.pgdeviceid = pgdeviceid; - } - - public void setTm(Date tm) { - this.logtime = tm; - this.uptime = tm; - } - - public String getTmStr() { - if (null != this.logtime) { - return TimeFormat.formatTimestamp(logtime); - } else { - return ""; - } - } - - public String getTmStrGB() { - if (null != this.logtime) { - return TimeFormat.format(logtime, "yyyyMMddHHmmss"); - } else { - return ""; - } - } - - @Override - public String toString() { - return "PgSHAlm[shalm=" + shalm + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; - } -} diff --git a/src/com/szpg/db/test/PgAcuDaoTest.java b/src/com/szpg/db/test/PgAcuDaoTest.java deleted file mode 100644 index 4355707..0000000 --- a/src/com/szpg/db/test/PgAcuDaoTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PgAcuDaoTest { - - private PgAcuDao dao; - - @Before - public void init() { - dao = new PgAcuDaoImpl(); - } - - @Test - public void testFindAllACU() { - assertEquals(1, dao.findAllACU().size()); - } - - @Test - public void testFindById() { - assertEquals("6B", dao.findACUById(1).getAcu_node()); - } -} diff --git a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java b/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java deleted file mode 100644 index 810a976..0000000 --- a/src/com/szpg/db/test/PgAcuRdcmdDaoTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.szpg.db.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.plc.message.AppMessageConstants; - -public class PgAcuRdcmdDaoTest { - - private PgAcuCmdDao dao; - - @Before - public void init() { - dao = new PgAcuCmdDaoImpl(); - } - -// @Test - public void testAdd() { - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE); - cmd.setDest_acu_code("YXL.ACU001"); - - assertEquals(1, dao.addCmdRecord(cmd)); - } - - @Test - public void testFindLatestCmdByDestAndType() { - assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId()); - } - -// @Test - public void testFindAll() { - assertEquals(1, dao.findAll().size()); - } - -// @Test - public void testUpdateTimeout() { - assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5")); - } - -// @Test - public void testDelete() { - assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5")); - } -} diff --git a/src/com/szpg/db/test/PgCH4DaoTest.java b/src/com/szpg/db/test/PgCH4DaoTest.java deleted file mode 100644 index 944616c..0000000 --- a/src/com/szpg/db/test/PgCH4DaoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.szpg.db.test; - -import com.opensymphony.xwork2.interceptor.annotations.Before; -import com.szpg.db.dao.PgCh4Dao; -import com.szpg.db.dao.impl.PgCh4DaoImpl; -import com.szpg.util.TimeFormat; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class PgCH4DaoTest { - - private PgCh4Dao dao; - - @Before - public void setUp() throws Exception { - dao = new PgCh4DaoImpl(); - } - -// @Test - public void testAddParamRecord() { - assertEquals(1, dao.addPblzRecord((float) 35.5, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllParam() { - assertEquals("20180115171555", dao.findAllPblz().get(0).getTmStrGB()); - } - - @Test - public void testFindParamById() { - Assert.assertEquals(dao.findPblzById(2).getTmStrGB(), "20180115171555"); - } - -// @Test - public void testAddStatusRecord() { - assertEquals(2, dao.addSbjzRecord(false, TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), 1)); - } - - @Test - public void testFindAllStatus() { - assertEquals("20180115183307", dao.findAllSbjz().get(0).getTmStrGB()); - } - - @Test - public void testFindStatusById() { - Assert.assertEquals(dao.findSbjzById(1).getTmStrGB(), "20180115183307"); - } - -} diff --git a/src/com/szpg/db/test/PgDeviceTest.java b/src/com/szpg/db/test/PgDeviceTest.java deleted file mode 100644 index 5f18ce9..0000000 --- a/src/com/szpg/db/test/PgDeviceTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.szpg.db.test; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; - -public class PgDeviceTest { - - private PgDeviceDao dao; - - @Before - public void setUp() throws Exception { - dao = new PgDeviceDaoImpl(); - } - - @Test - public void testFindDeviceIdByCode() { - Assert.assertEquals(1, dao.findDeviceIdByCode("YXL.ACU001.DCH01").intValue()); - } - -} diff --git a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java b/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java deleted file mode 100644 index 460ef69..0000000 --- a/src/com/szpg/db/test/ReadAssetInSpectionTaskTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgAssetInSpectionDao; -import com.szpg.db.dao.impl.PgAssetInSpectionImpl; -import com.szpg.task.ReadAssetInSpectionTask; -import org.junit.Test; - -public class ReadAssetInSpectionTaskTest { - @Test - public void insertDB() { - String jsonStr="{\n" + - "\t\"total\": 333,\n" + - "\t\"totalRecords\": 3321,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"problems\": 1,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"6B1BA2FD-A835-439E-9EC3-B268FB02DE06\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_888\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"A5254143-BE91-4284-AB2A-1B8BD88EACE3\",\n" + - "\t\t\"PLAN_ID\": \"a28285cd-c023-4caf-81e5-3d186fcf5898\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"sunchenglei\",\n" + - "\t\t\"PLAN_NAME\": \"一标燃气舱巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180305_334\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wangrui\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-05\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"ceb11e1c-6565-4423-ab80-3713f7a1813e\",\n" + - "\t\t\"PLAN_ID\": \"\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": null,\n" + - "\t\t\"RECORD_NO\": \"XR_180615_889\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"02D994A2-9466-4E77-8026-EAECFAB7DA4C\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180729_004\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-29\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"wangshen-王申,\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"DB57F8D2-077C-4DC1-90E4-B8DF8F637CD4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180730_002\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"liangqingsong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-30\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \",D,R,Z\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"tianyun-田云,\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f1701fc9-9e7a-4155-bff3-cf6b106f484b\",\n" + - "\t\t\"PLAN_ID\": \"87daf7b1-336f-4b41-9684-b0d6436255df\",\n" + - "\t\t\"CREATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"sundoudou\",\n" + - "\t\t\"PLAN_NAME\": \"日常巡检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180615_604\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"zousheng\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-06-15\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": \"R\",\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"f793de99-c58d-4787-b489-863320e78924\",\n" + - "\t\t\"PLAN_ID\": \"054bce38-374a-45b6-ade3-cfc1e44846b7\",\n" + - "\t\t\"CREATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"admin\",\n" + - "\t\t\"PLAN_NAME\": \"风机启动数量点检\",\n" + - "\t\t\"RECORD_NO\": \"XR_180524_666\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"baiwenzhong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-05-24\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"problems\": 2,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"457C0017-5F6B-4026-96D3-9BA439723AA5\",\n" + - "\t\t\"PLAN_ID\": \"1d1800d5-0050-4d38-846e-67d81e337387\",\n" + - "\t\t\"CREATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"STATE\": null,\n" + - "\t\t\"CREATOR\": \"wangrui\",\n" + - "\t\t\"PLAN_NAME\": \"四五标施工进度巡查\",\n" + - "\t\t\"RECORD_NO\": \"XR_180313_130\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \" dujiannan\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-03-13\",\n" + - "\t\t\"REMARK\": null,\n" + - "\t\t\"BUILD_CABIN\": null,\n" + - "\t\t\"PROJECT\": null,\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": null,\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AA605983-6F73-41F0-B1FA-FDA2565F15F4\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180727_005\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"wudong\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-27\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"luxingxing-陆杏兴, \",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"problems\": 0,\n" + - "\t\t\"finish\": 0,\n" + - "\t\t\"KEY_ID\": \"AB88779D-02D6-4419-AD0A-147DEE3EC18F\",\n" + - "\t\t\"PLAN_ID\": \"feea9e81-fe9a-4b73-b528-4b7a09381b68\",\n" + - "\t\t\"CREATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"STATE\": 0,\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"PLAN_NAME\": \"吴中太湖新城内部巡检计划-一期\",\n" + - "\t\t\"RECORD_NO\": \"XR_180725_006\",\n" + - "\t\t\"PLAN_NO\": null,\n" + - "\t\t\"RESPONSIBLE_DEPT\": null,\n" + - "\t\t\"INSPECTION_PERSON\": null,\n" + - "\t\t\"PATROL_MAN\": \"caoshixiang\",\n" + - "\t\t\"OPERATE_DATE\": \"2018-07-25\",\n" + - "\t\t\"REMARK\": \"\",\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"THXC\",\n" + - "\t\t\"START_PILE_NO\": null,\n" + - "\t\t\"END_PILE_NO\": null,\n" + - "\t\t\"INSPECTION_PRACE\": null,\n" + - "\t\t\"OTHER_PATROL_MAN\": \"liangcang-梁仓, \",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - PgAssetInSpectionDao pgAssetInSpectionDao=new PgAssetInSpectionImpl(); - new ReadAssetInSpectionTask().insertDB(pgAssetInSpectionDao,jsonStr); - - } - - -} diff --git a/src/com/szpg/db/test/ReadMaintanceTaskTest.java b/src/com/szpg/db/test/ReadMaintanceTaskTest.java deleted file mode 100644 index c7f7022..0000000 --- a/src/com/szpg/db/test/ReadMaintanceTaskTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.szpg.db.test; - -import com.szpg.db.dao.PgMaintanceDao; -import com.szpg.db.dao.impl.PgMaintanceDaoImpl; -import com.szpg.task.ReadMaintanceTask; -import org.junit.Test; - -public class ReadMaintanceTaskTest { - @Test - public void insertDB() { - - String jsonStr="{\n" + - "\t\"total\": 20,\n" + - "\t\"totalRecords\": 199,\n" + - "\t\"page\": 1,\n" + - "\t\"records\": 10,\n" + - "\t\"rows\": [{\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0567B2C1-CEAC-4C3B-AD34-9A9BC61E5F80\",\n" + - "\t\t\"PLAN_KEY_ID\": \"afec56e0-8db7-4a78-a1c8-a255d2e10fbf\",\n" + - "\t\t\"PLAN_NAME\": \"EPS设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-101004-3945\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-05-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 1\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"07EE7B85-C868-481A-B446-EDD928C9A6EF\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102446-2491\",\n" + - "\t\t\"REOAIRMAN\": \"panshijin\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",Q\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 2\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0863F267-51EC-451E-AC2F-B2964C81611A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"9b0311c9-b5a5-402c-a888-f6e83f43ca01\",\n" + - "\t\t\"PLAN_NAME\": \"风管、通风口保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-152000-3389\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-08-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 3\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"0B5A58EB-5A43-4DD7-B251-AFD8EE9EC7DC\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180911-102543-9023\",\n" + - "\t\t\"REOAIRMAN\": \"dujiannan\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-09-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-11\",\n" + - "\t\t\"CREATOR\": \"haojing\",\n" + - "\t\t\"rowNum\": 4\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"147C5CE2-B1F7-48B9-B9B0-7A3549AB5088\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165641-5849\",\n" + - "\t\t\"REOAIRMAN\": \"邹盛\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-16\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 5\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 2,\n" + - "\t\t\"KEY_ID\": \"16D18621-B2B6-4726-8301-E4EC04E5B366\",\n" + - "\t\t\"PLAN_KEY_ID\": \"a09e5100-c45e-4e3e-8699-f3d420475357\",\n" + - "\t\t\"PLAN_NAME\": \"低压配电箱(柜)保养计划(季度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \"\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 6\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1B763BDF-65AA-4F61-ACB8-1F9AAD8B94C7\",\n" + - "\t\t\"PLAN_KEY_ID\": \"3e8a6adb-2721-441a-8703-ce86e10bbe84\",\n" + - "\t\t\"PLAN_NAME\": \"水喷淋设备保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-151334-8577\",\n" + - "\t\t\"REOAIRMAN\": \"yuweihua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-06-01\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 7\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 1,\n" + - "\t\t\"KEY_ID\": \"20054191-2C9B-4134-B15B-672497761ECD\",\n" + - "\t\t\"PLAN_KEY_ID\": \"1725b07b-c467-4cc3-b0c9-f090aba0b38d\",\n" + - "\t\t\"PLAN_NAME\": \"火灾自动报警设备保养计划(月度)\",\n" + - "\t\t\"RECORD_NO\": null,\n" + - "\t\t\"REOAIRMAN\": null,\n" + - "\t\t\"MAINTENANCE_DATE\": null,\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-11-01\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 8\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"200AE813-FB83-49E5-BED1-E18436ECB35A\",\n" + - "\t\t\"PLAN_KEY_ID\": \"4874f602-83a2-4e9c-a05f-da1cad9a0427\",\n" + - "\t\t\"PLAN_NAME\": \"弱电间保养计划\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-181016-165809-3203\",\n" + - "\t\t\"REOAIRMAN\": \"杜建男\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-10-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-10-11\",\n" + - "\t\t\"CREATOR\": \"system\",\n" + - "\t\t\"rowNum\": 9\n" + - "\t}, {\n" + - "\t\t\"FINISH\": 0,\n" + - "\t\t\"KEY_ID\": \"1EE38C22-7DD4-43B7-882E-F8A11118B839\",\n" + - "\t\t\"PLAN_KEY_ID\": \"57dadeeb-8e71-40ef-a2ba-f990771c40fd\",\n" + - "\t\t\"PLAN_NAME\": \"潜水泵及潜水泵控制柜\",\n" + - "\t\t\"RECORD_NO\": \"WXBY-180910-145450-4697\",\n" + - "\t\t\"REOAIRMAN\": \"zhangronghua\",\n" + - "\t\t\"MAINTENANCE_DATE\": \"2018-01-02\",\n" + - "\t\t\"BUILD_CABIN\": \",D,P,Q,R,S\",\n" + - "\t\t\"PROJECT\": \"CBL\",\n" + - "\t\t\"CREATEDATE\": \"2018-09-10\",\n" + - "\t\t\"CREATOR\": \"wuping\",\n" + - "\t\t\"rowNum\": 10\n" + - "\t}]\n" + - "}"; - - PgMaintanceDao pgMaintanceDao=new PgMaintanceDaoImpl(); - new ReadMaintanceTask().insertDB(pgMaintanceDao,jsonStr); - - } -} \ No newline at end of file diff --git a/src/com/szpg/task/ReadCH4StatusTask.java b/src/com/szpg/task/ReadCH4StatusTask.java deleted file mode 100644 index f9dbb55..0000000 --- a/src/com/szpg/task/ReadCH4StatusTask.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCH4StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCH4StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".CHALM.WORDCOUNT"))); - - // 调用服务 - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadCOStatusTask.java b/src/com/szpg/task/ReadCOStatusTask.java deleted file mode 100644 index 51bae7f..0000000 --- a/src/com/szpg/task/ReadCOStatusTask.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.szpg.task; - -import java.util.Calendar; -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadCOStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadCOStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCOSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - command.setTime(Calendar.getInstance()); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".COALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadFjRtTask.java b/src/com/szpg/task/ReadFjRtTask.java deleted file mode 100644 index 690d2a9..0000000 --- a/src/com/szpg/task/ReadFjRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadFjRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadFjRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READFJRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".FJRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadHSStatusTask.java b/src/com/szpg/task/ReadHSStatusTask.java deleted file mode 100644 index d31b178..0000000 --- a/src/com/szpg/task/ReadHSStatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadHSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadHSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READHSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".HSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadO2StatusTask.java b/src/com/szpg/task/ReadO2StatusTask.java deleted file mode 100644 index 860b10f..0000000 --- a/src/com/szpg/task/ReadO2StatusTask.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadO2StatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadO2StatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READO2STATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YQALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } - -} diff --git a/src/com/szpg/task/ReadSbRtTask.java b/src/com/szpg/task/ReadSbRtTask.java deleted file mode 100644 index 9083b72..0000000 --- a/src/com/szpg/task/ReadSbRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadSbRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadSbRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READSBRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".SBRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ReadWSStatusTask.java b/src/com/szpg/task/ReadWSStatusTask.java deleted file mode 100644 index 4328426..0000000 --- a/src/com/szpg/task/ReadWSStatusTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadSensorStatusService; -import com.szpg.util.Configure; - -public class ReadWSStatusTask implements Runnable { - - private ReadSensorStatusService service; - - public ReadWSStatusTask() { - service = new ReadSensorStatusService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READWSSTATUS); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - try { - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".WSALM.WORDCOUNT"))); - - service.executeService(client, (ReadMemoryCommand) command); - } catch (Exception ex) { - continue; - } - } - } -} diff --git a/src/com/szpg/task/ReadZmRtTask.java b/src/com/szpg/task/ReadZmRtTask.java deleted file mode 100644 index 30c5835..0000000 --- a/src/com/szpg/task/ReadZmRtTask.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.szpg.task; - -import java.util.Map; - -import com.szpg.plc.message.AppMessageConstants; -import com.szpg.plc.message.command.ReadMemoryCommand; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.service.ReadControllerRuntimeService; -import com.szpg.util.Configure; - -public class ReadZmRtTask implements Runnable { - - private ReadControllerRuntimeService service; - - public ReadZmRtTask() { - service = new ReadControllerRuntimeService(); - } - - @Override - public void run() { - // 查找所有的client - Map clients = ACUClientUtil.getInstance().getClients(); - - for (String key : clients.keySet()) { - ACUClient client = clients.get(key); - - ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READZMRUNTIME); - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - command.setMessageProducerId(sour); - - String dest = client.getNet() + client.getNode() + client.getUnit(); - command.setDestinationId(dest); - - command.setMemoryArea(FINSConstants.MEMORY_DM_AREA); - - command.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.START")), 2)) + "00"); - command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".ZMRT.WORDCOUNT"))); - - service.executeService(client, command); - } - } - -} diff --git a/src/com/szpg/task/ResetDsTask.java b/src/com/szpg/task/ResetDsTask.java deleted file mode 100644 index a9a5a1e..0000000 --- a/src/com/szpg/task/ResetDsTask.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetDsRstBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -/** - * 清除对射报警 - * 0=正常/1=清除 - * - * @author admin - * - */ -public class ResetDsTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public ResetDsTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置解锁位的命令 - SetDsRstBitCommand setRstCmd = new SetDsRstBitCommand(); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".RST"); - if (null != onBlObj) { - setRstCmd.setMessageProducerId(sour); - setRstCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setRstCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setRstCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setRstCmd.setBit(bit); - - // 位数 - setRstCmd.setCount(end - start + 1); - - // 位内容 - setRstCmd.setValue(new byte[] {(byte) SetDsRstBitCommand.DS_RST} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setRstCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setRstCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setRstCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetSdThresholdTask.java b/src/com/szpg/task/SetSdThresholdTask.java deleted file mode 100644 index cab2da8..0000000 --- a/src/com/szpg/task/SetSdThresholdTask.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetSdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetSdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetSdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - String acucode = deviceCode.substring(0, deviceCode.indexOf(".", 6)); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetSdThresholdWordCommand setWetThreCmd = new SetSdThresholdWordCommand(); - setWetThreCmd.setThreshold(threshold); - PgHjsbbl wetBlObj = blDao.findBlByBh(deviceCode + ".WetSet"); - if (null != wetBlObj) { - setWetThreCmd.setMessageProducerId(sour); - setWetThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setWetThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = wetBlObj.getKszdz(); - int end = wetBlObj.getJszdz(); - - // 开始字地址 - setWetThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setWetThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setWetThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setWetThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setWetThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setWetThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/SetWdThresholdTask.java b/src/com/szpg/task/SetWdThresholdTask.java deleted file mode 100644 index ef2630c..0000000 --- a/src/com/szpg/task/SetWdThresholdTask.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetWdThresholdWordCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.plc.util.Bytes; -import com.szpg.util.Configure; - -/** - * 设置温湿度报警阈值 - * - * @author admin - * - */ -public class SetWdThresholdTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private float threshold; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public SetWdThresholdTask(String deviceCode, float threshold) { - this.deviceCode = deviceCode; - this.threshold = threshold; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 发送设置报警阈值的命令 - SetWdThresholdWordCommand setTemThreCmd = new SetWdThresholdWordCommand(); - setTemThreCmd.setThreshold(threshold); - PgHjsbbl temBlObj = blDao.findBlByBh(deviceCode + ".TemSet"); - if (null != temBlObj) { - setTemThreCmd.setMessageProducerId(sour); - setTemThreCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按字写 - setTemThreCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_WORD); - - int start = temBlObj.getKszdz(); - int end = temBlObj.getJszdz(); - - // 开始字地址 - setTemThreCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2)) + "00"); - - // 字数 - int n = end - start + 1; - setTemThreCmd.setCount(n); - - // 字内容 - byte[] temps = ByteUtil.intToBins(Float.floatToIntBits(threshold)); - Bytes dataByte = new Bytes(); - for (int j = n; j > 0; j--) { - dataByte.append(new byte[] {temps[2 * (j-1)], temps[2 * (j-1) + 1]}); - } - setTemThreCmd.setValue( dataByte.toBytes() ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setTemThreCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setTemThreCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setTemThreCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/TurnOffFjTask.java b/src/com/szpg/task/TurnOffFjTask.java deleted file mode 100644 index 2b45870..0000000 --- a/src/com/szpg/task/TurnOffFjTask.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetFjOffBitCommand; -import com.szpg.plc.message.command.write.SetFjOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOffFjTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOffFjTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将启动位置0 - SetFjOnBitCommand clearOnCmd = new SetFjOnBitCommand(); - clearOnCmd.setFjon(SetFjOnBitCommand.FJ_ON_DISABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - clearOnCmd.setMessageProducerId(sour); - clearOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - clearOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOnCmd.setBit(bit); - - // 位数 - clearOnCmd.setCount(end - start + 1); - - // 位内容 - clearOnCmd.setValue(new byte[] {(byte) clearOnCmd.getFjon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除启动位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetFjOffBitCommand setOffCmd = new SetFjOffBitCommand(); - setOffCmd.setFjoff(SetFjOffBitCommand.FJ_OFF_ENABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - setOffCmd.setMessageProducerId(sour); - setOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - setOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOffCmd.setBit(bit); - - // 位数 - setOffCmd.setCount(end - start + 1); - - // 位内容 - setOffCmd.setValue(new byte[] {(byte) setOffCmd.getFjoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOffCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOffCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } -} diff --git a/src/com/szpg/task/TurnOffZmTask.java b/src/com/szpg/task/TurnOffZmTask.java deleted file mode 100644 index c46119b..0000000 --- a/src/com/szpg/task/TurnOffZmTask.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetZmOffBitCommand; -import com.szpg.plc.message.command.write.SetZmOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOffZmTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOffZmTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将启动位置0 - SetZmOnBitCommand clearOnCmd = new SetZmOnBitCommand(); - clearOnCmd.setZmon(SetZmOnBitCommand.ZM_ON_DISABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - clearOnCmd.setMessageProducerId(sour); - clearOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - clearOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOnCmd.setBit(bit); - - // 位数 - clearOnCmd.setCount(end - start + 1); - - // 位内容 - clearOnCmd.setValue(new byte[] {(byte) clearOnCmd.getZmon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除启动位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetZmOffBitCommand setOffCmd = new SetZmOffBitCommand(); - setOffCmd.setZmoff(SetZmOffBitCommand.ZM_OFF_ENABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - setOffCmd.setMessageProducerId(sour); - setOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - setOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOffCmd.setBit(bit); - - // 位数 - setOffCmd.setCount(end - start + 1); - - // 位内容 - setOffCmd.setValue(new byte[] {(byte) setOffCmd.getZmoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOffCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOffCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } -} diff --git a/src/com/szpg/task/TurnOnFjTask.java b/src/com/szpg/task/TurnOnFjTask.java deleted file mode 100644 index d61cded..0000000 --- a/src/com/szpg/task/TurnOnFjTask.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetFjOffBitCommand; -import com.szpg.plc.message.command.write.SetFjOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOnFjTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOnFjTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将停止位置0 - SetFjOffBitCommand clearOffCmd = new SetFjOffBitCommand(); - clearOffCmd.setFjoff(SetFjOffBitCommand.FJ_OFF_DISABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - clearOffCmd.setMessageProducerId(sour); - clearOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - clearOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOffCmd.setBit(bit); - - // 位数 - clearOffCmd.setCount(end - start + 1); - - // 位内容 - clearOffCmd.setValue(new byte[] {(byte) clearOffCmd.getFjoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除停止位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetFjOnBitCommand setOnCmd = new SetFjOnBitCommand(); - setOnCmd.setFjon(SetFjOnBitCommand.FJ_ON_ENABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - setOnCmd.setMessageProducerId(sour); - setOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOnCmd.setBit(bit); - - // 位数 - setOnCmd.setCount(end - start + 1); - - // 位内容 - setOnCmd.setValue(new byte[] {(byte) setOnCmd.getFjon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOnCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOnCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -} diff --git a/src/com/szpg/task/TurnOnZmTask.java b/src/com/szpg/task/TurnOnZmTask.java deleted file mode 100644 index 20e8e56..0000000 --- a/src/com/szpg/task/TurnOnZmTask.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.szpg.task; - -import org.apache.log4j.Logger; - -import com.szpg.db.dao.PgAcuCmdDao; -import com.szpg.db.dao.PgAcuDao; -import com.szpg.db.dao.PgDeviceDao; -import com.szpg.db.dao.PgHjsbblDao; -import com.szpg.db.dao.impl.PgAcuCmdDaoImpl; -import com.szpg.db.dao.impl.PgAcuDaoImpl; -import com.szpg.db.dao.impl.PgDeviceDaoImpl; -import com.szpg.db.dao.impl.PgHjsbblDaoImpl; -import com.szpg.db.data.PgAcu; -import com.szpg.db.data.PgAcuCmd; -import com.szpg.db.data.PgHjsbbl; -import com.szpg.plc.message.CommandResponse; -import com.szpg.plc.message.command.write.SetZmOffBitCommand; -import com.szpg.plc.message.command.write.SetZmOnBitCommand; -import com.szpg.plc.protocol.DTProtocolInterface; -import com.szpg.plc.protocol.ProtocolFactory; -import com.szpg.plc.protocol.fins.FINSConstants; -import com.szpg.plc.server.ACUClient; -import com.szpg.plc.server.ACUClientUtil; -import com.szpg.plc.util.ByteUtil; -import com.szpg.util.Configure; - -public class TurnOnZmTask implements Runnable { - - private Logger logger = Logger.getLogger(this.getClass().getName()); - - private String deviceCode; - private PgHjsbblDao blDao = new PgHjsbblDaoImpl(); - - public TurnOnZmTask(String deviceCode) { - this.deviceCode = deviceCode; - } - - @Override - public void run() { - // 查找ACU的信息 - PgAcuDao acuDao = new PgAcuDaoImpl(); - PgDeviceDao deviceDao = new PgDeviceDaoImpl(); - String acucode = deviceDao.findAcuCodeByCode(deviceCode); - PgAcu acu = acuDao.findACUByCode(acucode); - ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); - if (null != client) { - // 源地址 - String sour = Configure.getProperty("sys", "LOCALHOST.NET") + - Configure.getProperty("sys", "LOCALHOST.NODE") + - Configure.getProperty("sys", "LOCALHOST.UNIT"); - - // 目标地址 - String dest = client.getNet() + client.getNode() + client.getUnit(); - - DTProtocolInterface finspi = ProtocolFactory.getDefaultDTProtocol(); - - // 1首先将停止位置0 - SetZmOffBitCommand clearOffCmd = new SetZmOffBitCommand(); - clearOffCmd.setZmoff(SetZmOffBitCommand.ZM_OFF_DISABLE); - PgHjsbbl offBlObj = blDao.findBlByBh(deviceCode + ".OFF"); - if (null != offBlObj) { - clearOffCmd.setMessageProducerId(sour); - clearOffCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - clearOffCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = offBlObj.getKszdz(); - int end = offBlObj.getJszdz(); - int bit = offBlObj.getSzw(); - - // 开始字地址 - clearOffCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - clearOffCmd.setBit(bit); - - // 位数 - clearOffCmd.setCount(end - start + 1); - - // 位内容 - clearOffCmd.setValue(new byte[] {(byte) clearOffCmd.getZmoff()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(clearOffCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志 - logger.error("清除停止位后的阻塞等待线程被打断", e); - } - - // 2 发送设置启动位的命令 - SetZmOnBitCommand setOnCmd = new SetZmOnBitCommand(); - setOnCmd.setZmon(SetZmOnBitCommand.ZM_ON_ENABLE); - PgHjsbbl onBlObj = blDao.findBlByBh(deviceCode + ".ON"); - if (null != onBlObj) { - setOnCmd.setMessageProducerId(sour); - setOnCmd.setDestinationId(dest); - - // SID在new对象的时候已经生成 - - // 内存区域——按位写 - setOnCmd.setMemoryArea(FINSConstants.MEMORY_WORK_AREA_BIT); - - int start = onBlObj.getKszdz(); - int end = onBlObj.getJszdz(); - int bit = onBlObj.getSzw(); - - // 开始字地址 - setOnCmd.setStartAddress(ByteUtil.binToHexString(ByteUtil.intToBins(start, 2))); - - // 位地址 - setOnCmd.setBit(bit); - - // 位数 - setOnCmd.setCount(end - start + 1); - - // 位内容 - setOnCmd.setValue(new byte[] {(byte) setOnCmd.getZmon()} ); - - // 解析命令对象为字节数组 - byte[] content = finspi.messageToBytes(setOnCmd); - - // 通过socket接口发送出去 - ACUClientUtil.getInstance().sendACUCommand(client, content); - } - - // 3将命令存入数据库 - PgAcuCmdDao cmdDao = new PgAcuCmdDaoImpl(); - PgAcuCmd cmd = new PgAcuCmd(); - cmd.setCmd_type(setOnCmd.getCommandType()); - cmd.setDest_acu_code(acucode); - cmd.setTm(setOnCmd.getTime().getTime()); - cmdDao.addCmdRecord(cmd); - - // 4阻塞,循环查找响应消息池,找到对应的响应消息 - boolean flag = false; - int times = 0; - CommandResponse response = null; - while (flag == false && times < 240) { - response = ACUClientUtil.getInstance().responsePool.getResponse(cmd.getId()); - - if (null != response && response.equals("") == false) { - flag = true; - } - - times++; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO 阻塞线程被打断,需要处理异常 - // 目前的处理流程为1)记录日志;2)将命令置为超时 - logger.error("在响应池中查找命令的响应消息阻塞线程被异常打断", e); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - - return; - } - } - - // 5若未超时,将值存入数据库 - if (null != response) { - // 6根据命令类型的不同将监测值存入对应的数据库 - response.afterAction(); - } else { - // 9超时,将命令的超时标志位置1 - logger.warn("命令超时" + cmd.getId()); - cmdDao.updateCmdRecordTimeout(cmd.getId()); - } - } - } - -}