diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
+
+
+
+ +
+ +
+
    +
    +
    +
    + +
    +
    资产信息
    +
    +
    + 所在分区: + 资产代码: + 资产名称: +
    +
    +
    + + +
    +
    当前值
    +
    +
    + + 时间: + + + 对射状态: + + + + +
    +
    +
    + + +
    +
    远程指令
    +
    +
    + + +
    +
    +
    +
    +
    +
    + + + + + + diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
    +
    +
    +
    + +
    + +
    +
      +
      +
      +
      + +
      +
      资产信息
      +
      +
      + 所在分区: + 资产代码: + 资产名称: +
      +
      +
      + + +
      +
      当前值
      +
      +
      + + 时间: + + + 对射状态: + + + + +
      +
      +
      + + +
      +
      远程指令
      +
      +
      + + +
      +
      +
      +
      +
      +
      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
      +
      +
      +
      + +
      + +
      +
        +
        +
        +
        + +
        +
        资产信息
        +
        +
        + 所在分区: + 资产代码: + 资产名称: +
        +
        +
        + + +
        +
        当前值
        +
        +
        + + 时间: + + + 对射状态: + + + + +
        +
        +
        + + +
        +
        远程指令
        +
        +
        + + +
        +
        +
        +
        +
        +
        + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
        +
        +
        +
        + +
        + +
        +
          +
          +
          +
          + +
          +
          资产信息
          +
          +
          + 所在分区: + 资产代码: + 资产名称: +
          +
          +
          + + +
          +
          当前值
          +
          +
          + + 时间: + + + 对射状态: + + + + +
          +
          +
          + + +
          +
          远程指令
          +
          +
          + + +
          +
          +
          +
          +
          +
          + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
          +
          +
          +
          + +
          + +
          +
            +
            +
            +
            + +
            +
            资产信息
            +
            +
            + 所在分区: + 资产代码: + 资产名称: +
            +
            +
            + + +
            +
            当前值
            +
            +
            + + 时间: + + + 对射状态: + + + + +
            +
            +
            + + +
            +
            远程指令
            +
            +
            + + +
            +
            +
            +
            +
            +
            + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
            +
            +
            +
            + +
            + +
            +
              +
              +
              +
              + +
              +
              资产信息
              +
              +
              + 所在分区: + 资产代码: + 资产名称: +
              +
              +
              + + +
              +
              当前值
              +
              +
              + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
              +
              +
              + + +
              +
              远程指令
              +
              +
              + +
              +
              +
              +
              +
              +
              + + + + + + diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
              +
              +
              +
              + +
              + +
              +
                +
                +
                +
                + +
                +
                资产信息
                +
                +
                + 所在分区: + 资产代码: + 资产名称: +
                +
                +
                + + +
                +
                当前值
                +
                +
                + + 时间: + + + 对射状态: + + + + +
                +
                +
                + + +
                +
                远程指令
                +
                +
                + + +
                +
                +
                +
                +
                +
                + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                +
                +
                +
                + +
                + +
                +
                  +
                  +
                  +
                  + +
                  +
                  资产信息
                  +
                  +
                  + 所在分区: + 资产代码: + 资产名称: +
                  +
                  +
                  + + +
                  +
                  当前值
                  +
                  +
                  + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                  +
                  +
                  + + +
                  +
                  远程指令
                  +
                  +
                  + +
                  +
                  +
                  +
                  +
                  +
                  + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                  +
                  +
                  +
                  + +
                  + +
                  +
                    +
                    +
                    +
                    + +
                    +
                    资产信息
                    +
                    +
                    + 所在分区: + 资产代码: + 资产名称: +
                    +
                    +
                    + + +
                    +
                    当前值
                    +
                    +
                    + + 时间: + + + 爆管状态: + + + + +
                    +
                    +
                    + + +
                    +
                    远程指令
                    +
                    +
                    + +
                    +
                    +
                    +
                    +
                    +
                    + + + + + + diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                    +
                    +
                    +
                    + +
                    + +
                    +
                      +
                      +
                      +
                      + +
                      +
                      资产信息
                      +
                      +
                      + 所在分区: + 资产代码: + 资产名称: +
                      +
                      +
                      + + +
                      +
                      当前值
                      +
                      +
                      + + 时间: + + + 对射状态: + + + + +
                      +
                      +
                      + + +
                      +
                      远程指令
                      +
                      +
                      + + +
                      +
                      +
                      +
                      +
                      +
                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                      +
                      +
                      +
                      + +
                      + +
                      +
                        +
                        +
                        +
                        + +
                        +
                        资产信息
                        +
                        +
                        + 所在分区: + 资产代码: + 资产名称: +
                        +
                        +
                        + + +
                        +
                        当前值
                        +
                        +
                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                        +
                        +
                        + + +
                        +
                        远程指令
                        +
                        +
                        + +
                        +
                        +
                        +
                        +
                        +
                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                        +
                        +
                        +
                        + +
                        + +
                        +
                          +
                          +
                          +
                          + +
                          +
                          资产信息
                          +
                          +
                          + 所在分区: + 资产代码: + 资产名称: +
                          +
                          +
                          + + +
                          +
                          当前值
                          +
                          +
                          + + 时间: + + + 爆管状态: + + + + +
                          +
                          +
                          + + +
                          +
                          远程指令
                          +
                          +
                          + +
                          +
                          +
                          +
                          +
                          +
                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                          +
                          +
                          +
                          + +
                          + +
                          +
                            +
                            +
                            +
                            + +
                            +
                            资产信息
                            +
                            +
                            + 所在分区: + 资产代码: + 资产名称: +
                            +
                            +
                            + + +
                            +
                            当前值
                            +
                            +
                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                            +
                            +
                            + + +
                            +
                            远程指令
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            +
                            + + + + + + diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                              +
                              +
                              +
                              + +
                              +
                              资产信息
                              +
                              +
                              + 所在分区: + 资产代码: + 资产名称: +
                              +
                              +
                              + + +
                              +
                              当前值
                              +
                              +
                              + + 时间: + + + 对射状态: + + + + +
                              +
                              +
                              + + +
                              +
                              远程指令
                              +
                              +
                              + + +
                              +
                              +
                              +
                              +
                              +
                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                              +
                              +
                              +
                              + +
                              + +
                              +
                                +
                                +
                                +
                                + +
                                +
                                资产信息
                                +
                                +
                                + 所在分区: + 资产代码: + 资产名称: +
                                +
                                +
                                + + +
                                +
                                当前值
                                +
                                +
                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                +
                                +
                                + + +
                                +
                                远程指令
                                +
                                +
                                + +
                                +
                                +
                                +
                                +
                                +
                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                +
                                +
                                +
                                + +
                                + +
                                +
                                  +
                                  +
                                  +
                                  + +
                                  +
                                  资产信息
                                  +
                                  +
                                  + 所在分区: + 资产代码: + 资产名称: +
                                  +
                                  +
                                  + + +
                                  +
                                  当前值
                                  +
                                  +
                                  + + 时间: + + + 爆管状态: + + + + +
                                  +
                                  +
                                  + + +
                                  +
                                  远程指令
                                  +
                                  +
                                  + +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                  +
                                  +
                                  +
                                  + +
                                  + +
                                  +
                                    +
                                    +
                                    +
                                    + +
                                    +
                                    资产信息
                                    +
                                    +
                                    + 所在分区: + 资产代码: + 资产名称: +
                                    +
                                    +
                                    + + +
                                    +
                                    当前值
                                    +
                                    +
                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                    +
                                    +
                                    + + +
                                    +
                                    远程指令
                                    +
                                    +
                                    + + + +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                    +
                                    +
                                    +
                                    + +
                                    + +
                                    +
                                      +
                                      +
                                      +
                                      + +
                                      +
                                      资产信息
                                      +
                                      +
                                      + 所在分区: + 资产代码: + 资产名称: +
                                      +
                                      +
                                      + + +
                                      +
                                      当前值
                                      +
                                      +
                                      + + 时间: + + + 对射状态: + + + + +
                                      +
                                      +
                                      + + +
                                      +
                                      远程指令
                                      +
                                      +
                                      + + +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                      +
                                      +
                                      +
                                      + +
                                      + +
                                      +
                                        +
                                        +
                                        +
                                        + +
                                        +
                                        资产信息
                                        +
                                        +
                                        + 所在分区: + 资产代码: + 资产名称: +
                                        +
                                        +
                                        + + +
                                        +
                                        当前值
                                        +
                                        +
                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                        +
                                        +
                                        + + +
                                        +
                                        远程指令
                                        +
                                        +
                                        + +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                        +
                                        +
                                        +
                                        + +
                                        + +
                                        +
                                          +
                                          +
                                          +
                                          + +
                                          +
                                          资产信息
                                          +
                                          +
                                          + 所在分区: + 资产代码: + 资产名称: +
                                          +
                                          +
                                          + + +
                                          +
                                          当前值
                                          +
                                          +
                                          + + 时间: + + + 爆管状态: + + + + +
                                          +
                                          +
                                          + + +
                                          +
                                          远程指令
                                          +
                                          +
                                          + +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                          +
                                          +
                                          +
                                          + +
                                          + +
                                          +
                                            +
                                            +
                                            +
                                            + +
                                            +
                                            资产信息
                                            +
                                            +
                                            + 所在分区: + 资产代码: + 资产名称: +
                                            +
                                            +
                                            + + +
                                            +
                                            当前值
                                            +
                                            +
                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                            +
                                            +
                                            + + +
                                            +
                                            远程指令
                                            +
                                            +
                                            + + + +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                            +
                                            +
                                            +
                                            + +
                                            + +
                                            +
                                              +
                                              +
                                              +
                                              + +
                                              +
                                              资产信息
                                              +
                                              +
                                              + 所在分区: + 资产代码: + 资产名称: +
                                              +
                                              +
                                              + + +
                                              +
                                              当前值
                                              +
                                              +
                                              + + 时间: + + + 对射状态: + + + + +
                                              +
                                              +
                                              + + +
                                              +
                                              远程指令
                                              +
                                              +
                                              + + +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                              +
                                              +
                                              +
                                              + +
                                              + +
                                              +
                                                +
                                                +
                                                +
                                                + +
                                                +
                                                资产信息
                                                +
                                                +
                                                + 所在分区: + 资产代码: + 资产名称: +
                                                +
                                                +
                                                + + +
                                                +
                                                当前值
                                                +
                                                +
                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                +
                                                +
                                                + + +
                                                +
                                                远程指令
                                                +
                                                +
                                                + +
                                                +
                                                +
                                                +
                                                +
                                                +
                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                +
                                                +
                                                +
                                                + +
                                                + +
                                                +
                                                  +
                                                  +
                                                  +
                                                  + +
                                                  +
                                                  资产信息
                                                  +
                                                  +
                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                  +
                                                  +
                                                  + + +
                                                  +
                                                  当前值
                                                  +
                                                  +
                                                  + + 时间: + + + 爆管状态: + + + + +
                                                  +
                                                  +
                                                  + + +
                                                  +
                                                  远程指令
                                                  +
                                                  +
                                                  + +
                                                  +
                                                  +
                                                  +
                                                  +
                                                  +
                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                  +
                                                  +
                                                  +
                                                  + +
                                                  + +
                                                  +
                                                    +
                                                    +
                                                    +
                                                    + +
                                                    +
                                                    资产信息
                                                    +
                                                    +
                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                    +
                                                    +
                                                    + + +
                                                    +
                                                    当前值
                                                    +
                                                    +
                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                    +
                                                    +
                                                    + + +
                                                    +
                                                    远程指令
                                                    +
                                                    +
                                                    + + + +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    +
                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                    +
                                                    +
                                                    +
                                                    + +
                                                    + +
                                                    +
                                                      +
                                                      +
                                                      +
                                                      + +
                                                      +
                                                      资产信息
                                                      +
                                                      +
                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                      +
                                                      +
                                                      + + +
                                                      +
                                                      当前值
                                                      +
                                                      +
                                                      + + 时间: + + + 对射状态: + + + + +
                                                      +
                                                      +
                                                      + + +
                                                      +
                                                      远程指令
                                                      +
                                                      +
                                                      + + +
                                                      +
                                                      +
                                                      +
                                                      +
                                                      +
                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                      +
                                                      +
                                                      +
                                                      + +
                                                      + +
                                                      +
                                                        +
                                                        +
                                                        +
                                                        + +
                                                        +
                                                        资产信息
                                                        +
                                                        +
                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                        +
                                                        +
                                                        + + +
                                                        +
                                                        当前值
                                                        +
                                                        +
                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                        +
                                                        +
                                                        + + +
                                                        +
                                                        远程指令
                                                        +
                                                        +
                                                        + +
                                                        +
                                                        +
                                                        +
                                                        +
                                                        +
                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                        +
                                                        +
                                                        +
                                                        + +
                                                        + +
                                                        +
                                                          +
                                                          +
                                                          +
                                                          + +
                                                          +
                                                          资产信息
                                                          +
                                                          +
                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                          +
                                                          +
                                                          + + +
                                                          +
                                                          当前值
                                                          +
                                                          +
                                                          + + 时间: + + + 爆管状态: + + + + +
                                                          +
                                                          +
                                                          + + +
                                                          +
                                                          远程指令
                                                          +
                                                          +
                                                          + +
                                                          +
                                                          +
                                                          +
                                                          +
                                                          +
                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                          +
                                                          +
                                                          +
                                                          + +
                                                          + +
                                                          +
                                                            +
                                                            +
                                                            +
                                                            + +
                                                            +
                                                            资产信息
                                                            +
                                                            +
                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                            +
                                                            +
                                                            + + +
                                                            +
                                                            当前值
                                                            +
                                                            +
                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                            +
                                                            +
                                                            + + +
                                                            +
                                                            远程指令
                                                            +
                                                            +
                                                            + + + +
                                                            +
                                                            +
                                                            +
                                                            +
                                                            +
                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                            +
                                                            +
                                                            +
                                                            + +
                                                            + +
                                                            +
                                                              +
                                                              +
                                                              +
                                                              + +
                                                              +
                                                              资产信息
                                                              +
                                                              +
                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                              +
                                                              +
                                                              + + +
                                                              +
                                                              当前值
                                                              +
                                                              +
                                                              + + 时间: + + + 对射状态: + + + + +
                                                              +
                                                              +
                                                              + + +
                                                              +
                                                              远程指令
                                                              +
                                                              +
                                                              + + +
                                                              +
                                                              +
                                                              +
                                                              +
                                                              +
                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                              +
                                                              +
                                                              +
                                                              + +
                                                              + +
                                                              +
                                                                +
                                                                +
                                                                +
                                                                + +
                                                                +
                                                                资产信息
                                                                +
                                                                +
                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                +
                                                                +
                                                                + + +
                                                                +
                                                                当前值
                                                                +
                                                                +
                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                +
                                                                +
                                                                + + +
                                                                +
                                                                远程指令
                                                                +
                                                                +
                                                                + +
                                                                +
                                                                +
                                                                +
                                                                +
                                                                +
                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                +
                                                                +
                                                                +
                                                                + +
                                                                + +
                                                                +
                                                                  +
                                                                  +
                                                                  +
                                                                  + +
                                                                  +
                                                                  资产信息
                                                                  +
                                                                  +
                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                  +
                                                                  +
                                                                  + + +
                                                                  +
                                                                  当前值
                                                                  +
                                                                  +
                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                  +
                                                                  +
                                                                  + + +
                                                                  +
                                                                  远程指令
                                                                  +
                                                                  +
                                                                  + +
                                                                  +
                                                                  +
                                                                  +
                                                                  +
                                                                  +
                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                  +
                                                                  +
                                                                  +
                                                                  + +
                                                                  + +
                                                                  +
                                                                    +
                                                                    +
                                                                    +
                                                                    + +
                                                                    +
                                                                    资产信息
                                                                    +
                                                                    +
                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                    +
                                                                    +
                                                                    + + +
                                                                    +
                                                                    当前值
                                                                    +
                                                                    +
                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                    +
                                                                    +
                                                                    + + +
                                                                    +
                                                                    远程指令
                                                                    +
                                                                    +
                                                                    + + + +
                                                                    +
                                                                    +
                                                                    +
                                                                    +
                                                                    +
                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                    +
                                                                    +
                                                                    +
                                                                    + +
                                                                    + +
                                                                    +
                                                                      +
                                                                      +
                                                                      +
                                                                      + +
                                                                      +
                                                                      资产信息
                                                                      +
                                                                      +
                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                      +
                                                                      +
                                                                      + + +
                                                                      +
                                                                      当前值
                                                                      +
                                                                      +
                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                      +
                                                                      +
                                                                      + + +
                                                                      +
                                                                      远程指令
                                                                      +
                                                                      +
                                                                      + + +
                                                                      +
                                                                      +
                                                                      +
                                                                      +
                                                                      +
                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                      +
                                                                      +
                                                                      +
                                                                      + +
                                                                      + +
                                                                      +
                                                                        +
                                                                        +
                                                                        +
                                                                        + +
                                                                        +
                                                                        资产信息
                                                                        +
                                                                        +
                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                        +
                                                                        +
                                                                        + + +
                                                                        +
                                                                        当前值
                                                                        +
                                                                        +
                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                        +
                                                                        +
                                                                        + + +
                                                                        +
                                                                        远程指令
                                                                        +
                                                                        +
                                                                        + +
                                                                        +
                                                                        +
                                                                        +
                                                                        +
                                                                        +
                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                        +
                                                                        +
                                                                        +
                                                                        + +
                                                                        + +
                                                                        +
                                                                          +
                                                                          +
                                                                          +
                                                                          + +
                                                                          +
                                                                          资产信息
                                                                          +
                                                                          +
                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                          +
                                                                          +
                                                                          + + +
                                                                          +
                                                                          当前值
                                                                          +
                                                                          +
                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                          +
                                                                          +
                                                                          + + +
                                                                          +
                                                                          远程指令
                                                                          +
                                                                          +
                                                                          + +
                                                                          +
                                                                          +
                                                                          +
                                                                          +
                                                                          +
                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                          +
                                                                          +
                                                                          +
                                                                          + +
                                                                          + +
                                                                          +
                                                                            +
                                                                            +
                                                                            +
                                                                            + +
                                                                            +
                                                                            资产信息
                                                                            +
                                                                            +
                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                            +
                                                                            +
                                                                            + + +
                                                                            +
                                                                            当前值
                                                                            +
                                                                            +
                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                            +
                                                                            +
                                                                            + + +
                                                                            +
                                                                            远程指令
                                                                            +
                                                                            +
                                                                            + + + +
                                                                            +
                                                                            +
                                                                            +
                                                                            +
                                                                            +
                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                            +
                                                                            +
                                                                            +
                                                                            + +
                                                                            + +
                                                                            +
                                                                              +
                                                                              +
                                                                              +
                                                                              + +
                                                                              +
                                                                              资产信息
                                                                              +
                                                                              +
                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                              +
                                                                              +
                                                                              + + +
                                                                              +
                                                                              当前值
                                                                              +
                                                                              +
                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                              +
                                                                              +
                                                                              + + +
                                                                              +
                                                                              远程指令
                                                                              +
                                                                              +
                                                                              + + +
                                                                              +
                                                                              +
                                                                              +
                                                                              +
                                                                              +
                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                              +
                                                                              +
                                                                              +
                                                                              + +
                                                                              + +
                                                                              +
                                                                                +
                                                                                +
                                                                                +
                                                                                + +
                                                                                +
                                                                                资产信息
                                                                                +
                                                                                +
                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                +
                                                                                +
                                                                                + + +
                                                                                +
                                                                                当前值
                                                                                +
                                                                                +
                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                +
                                                                                +
                                                                                + + +
                                                                                +
                                                                                远程指令
                                                                                +
                                                                                +
                                                                                + +
                                                                                +
                                                                                +
                                                                                +
                                                                                +
                                                                                +
                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                +
                                                                                +
                                                                                +
                                                                                + +
                                                                                + +
                                                                                +
                                                                                  +
                                                                                  +
                                                                                  +
                                                                                  + +
                                                                                  +
                                                                                  资产信息
                                                                                  +
                                                                                  +
                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                  +
                                                                                  +
                                                                                  + + +
                                                                                  +
                                                                                  当前值
                                                                                  +
                                                                                  +
                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                  +
                                                                                  +
                                                                                  + + +
                                                                                  +
                                                                                  远程指令
                                                                                  +
                                                                                  +
                                                                                  + +
                                                                                  +
                                                                                  +
                                                                                  +
                                                                                  +
                                                                                  +
                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                  +
                                                                                  +
                                                                                  +
                                                                                  + +
                                                                                  + +
                                                                                  +
                                                                                    +
                                                                                    +
                                                                                    +
                                                                                    + +
                                                                                    +
                                                                                    资产信息
                                                                                    +
                                                                                    +
                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                    +
                                                                                    +
                                                                                    + + +
                                                                                    +
                                                                                    当前值
                                                                                    +
                                                                                    +
                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                    +
                                                                                    +
                                                                                    + + +
                                                                                    +
                                                                                    远程指令
                                                                                    +
                                                                                    +
                                                                                    + + + +
                                                                                    +
                                                                                    +
                                                                                    +
                                                                                    +
                                                                                    +
                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                    +
                                                                                    +
                                                                                    +
                                                                                    + +
                                                                                    + +
                                                                                    +
                                                                                      +
                                                                                      +
                                                                                      +
                                                                                      + +
                                                                                      +
                                                                                      资产信息
                                                                                      +
                                                                                      +
                                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                                      +
                                                                                      +
                                                                                      + + +
                                                                                      +
                                                                                      当前值
                                                                                      +
                                                                                      +
                                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                                      +
                                                                                      +
                                                                                      + + +
                                                                                      +
                                                                                      远程指令
                                                                                      +
                                                                                      +
                                                                                      + + +
                                                                                      +
                                                                                      +
                                                                                      +
                                                                                      +
                                                                                      +
                                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                      +
                                                                                      +
                                                                                      +
                                                                                      + +
                                                                                      + +
                                                                                      +
                                                                                        +
                                                                                        +
                                                                                        +
                                                                                        + +
                                                                                        +
                                                                                        资产信息
                                                                                        +
                                                                                        +
                                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                                        +
                                                                                        +
                                                                                        + + +
                                                                                        +
                                                                                        当前值
                                                                                        +
                                                                                        +
                                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                        +
                                                                                        +
                                                                                        + + +
                                                                                        +
                                                                                        远程指令
                                                                                        +
                                                                                        +
                                                                                        + +
                                                                                        +
                                                                                        +
                                                                                        +
                                                                                        +
                                                                                        +
                                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                        +
                                                                                        +
                                                                                        +
                                                                                        + +
                                                                                        + +
                                                                                        +
                                                                                          +
                                                                                          +
                                                                                          +
                                                                                          + +
                                                                                          +
                                                                                          资产信息
                                                                                          +
                                                                                          +
                                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                                          +
                                                                                          +
                                                                                          + + +
                                                                                          +
                                                                                          当前值
                                                                                          +
                                                                                          +
                                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                                          +
                                                                                          +
                                                                                          + + +
                                                                                          +
                                                                                          远程指令
                                                                                          +
                                                                                          +
                                                                                          + +
                                                                                          +
                                                                                          +
                                                                                          +
                                                                                          +
                                                                                          +
                                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                          +
                                                                                          +
                                                                                          +
                                                                                          + +
                                                                                          + +
                                                                                          +
                                                                                            +
                                                                                            +
                                                                                            +
                                                                                            + +
                                                                                            +
                                                                                            资产信息
                                                                                            +
                                                                                            +
                                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                                            +
                                                                                            +
                                                                                            + + +
                                                                                            +
                                                                                            当前值
                                                                                            +
                                                                                            +
                                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                            +
                                                                                            +
                                                                                            + + +
                                                                                            +
                                                                                            远程指令
                                                                                            +
                                                                                            +
                                                                                            + + + +
                                                                                            +
                                                                                            +
                                                                                            +
                                                                                            +
                                                                                            +
                                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                            +
                                                                                            +
                                                                                            +
                                                                                            + +
                                                                                            + +
                                                                                            +
                                                                                              +
                                                                                              +
                                                                                              +
                                                                                              + +
                                                                                              +
                                                                                              资产信息
                                                                                              +
                                                                                              +
                                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                                              +
                                                                                              +
                                                                                              + + +
                                                                                              +
                                                                                              当前值
                                                                                              +
                                                                                              +
                                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                                              +
                                                                                              +
                                                                                              + + +
                                                                                              +
                                                                                              远程指令
                                                                                              +
                                                                                              +
                                                                                              + + +
                                                                                              +
                                                                                              +
                                                                                              +
                                                                                              +
                                                                                              +
                                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                              +
                                                                                              +
                                                                                              +
                                                                                              + +
                                                                                              + +
                                                                                              +
                                                                                                +
                                                                                                +
                                                                                                +
                                                                                                + +
                                                                                                +
                                                                                                资产信息
                                                                                                +
                                                                                                +
                                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                                +
                                                                                                +
                                                                                                + + +
                                                                                                +
                                                                                                当前值
                                                                                                +
                                                                                                +
                                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                +
                                                                                                +
                                                                                                + + +
                                                                                                +
                                                                                                远程指令
                                                                                                +
                                                                                                +
                                                                                                + +
                                                                                                +
                                                                                                +
                                                                                                +
                                                                                                +
                                                                                                +
                                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                +
                                                                                                +
                                                                                                +
                                                                                                + +
                                                                                                + +
                                                                                                +
                                                                                                  +
                                                                                                  +
                                                                                                  +
                                                                                                  + +
                                                                                                  +
                                                                                                  资产信息
                                                                                                  +
                                                                                                  +
                                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                                  +
                                                                                                  +
                                                                                                  + + +
                                                                                                  +
                                                                                                  当前值
                                                                                                  +
                                                                                                  +
                                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                                  +
                                                                                                  +
                                                                                                  + + +
                                                                                                  +
                                                                                                  远程指令
                                                                                                  +
                                                                                                  +
                                                                                                  + +
                                                                                                  +
                                                                                                  +
                                                                                                  +
                                                                                                  +
                                                                                                  +
                                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                  +
                                                                                                  +
                                                                                                  +
                                                                                                  + +
                                                                                                  + +
                                                                                                  +
                                                                                                    +
                                                                                                    +
                                                                                                    +
                                                                                                    + +
                                                                                                    +
                                                                                                    资产信息
                                                                                                    +
                                                                                                    +
                                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                                    +
                                                                                                    +
                                                                                                    + + +
                                                                                                    +
                                                                                                    当前值
                                                                                                    +
                                                                                                    +
                                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                    +
                                                                                                    +
                                                                                                    + + +
                                                                                                    +
                                                                                                    远程指令
                                                                                                    +
                                                                                                    +
                                                                                                    + + + +
                                                                                                    +
                                                                                                    +
                                                                                                    +
                                                                                                    +
                                                                                                    +
                                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                    +
                                                                                                    +
                                                                                                    +
                                                                                                    + +
                                                                                                    + +
                                                                                                    +
                                                                                                      +
                                                                                                      +
                                                                                                      +
                                                                                                      + +
                                                                                                      +
                                                                                                      资产信息
                                                                                                      +
                                                                                                      +
                                                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                                                      +
                                                                                                      +
                                                                                                      + + +
                                                                                                      +
                                                                                                      当前值
                                                                                                      +
                                                                                                      +
                                                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                                                      +
                                                                                                      +
                                                                                                      + + +
                                                                                                      +
                                                                                                      远程指令
                                                                                                      +
                                                                                                      +
                                                                                                      + + +
                                                                                                      +
                                                                                                      +
                                                                                                      +
                                                                                                      +
                                                                                                      +
                                                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                      +
                                                                                                      +
                                                                                                      +
                                                                                                      + +
                                                                                                      + +
                                                                                                      +
                                                                                                        +
                                                                                                        +
                                                                                                        +
                                                                                                        + +
                                                                                                        +
                                                                                                        资产信息
                                                                                                        +
                                                                                                        +
                                                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                                                        +
                                                                                                        +
                                                                                                        + + +
                                                                                                        +
                                                                                                        当前值
                                                                                                        +
                                                                                                        +
                                                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                        +
                                                                                                        +
                                                                                                        + + +
                                                                                                        +
                                                                                                        远程指令
                                                                                                        +
                                                                                                        +
                                                                                                        + +
                                                                                                        +
                                                                                                        +
                                                                                                        +
                                                                                                        +
                                                                                                        +
                                                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                        +
                                                                                                        +
                                                                                                        +
                                                                                                        + +
                                                                                                        + +
                                                                                                        +
                                                                                                          +
                                                                                                          +
                                                                                                          +
                                                                                                          + +
                                                                                                          +
                                                                                                          资产信息
                                                                                                          +
                                                                                                          +
                                                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                                                          +
                                                                                                          +
                                                                                                          + + +
                                                                                                          +
                                                                                                          当前值
                                                                                                          +
                                                                                                          +
                                                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                                                          +
                                                                                                          +
                                                                                                          + + +
                                                                                                          +
                                                                                                          远程指令
                                                                                                          +
                                                                                                          +
                                                                                                          + +
                                                                                                          +
                                                                                                          +
                                                                                                          +
                                                                                                          +
                                                                                                          +
                                                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                          +
                                                                                                          +
                                                                                                          +
                                                                                                          + +
                                                                                                          + +
                                                                                                          +
                                                                                                            +
                                                                                                            +
                                                                                                            +
                                                                                                            + +
                                                                                                            +
                                                                                                            资产信息
                                                                                                            +
                                                                                                            +
                                                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                                                            +
                                                                                                            +
                                                                                                            + + +
                                                                                                            +
                                                                                                            当前值
                                                                                                            +
                                                                                                            +
                                                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                            +
                                                                                                            +
                                                                                                            + + +
                                                                                                            +
                                                                                                            远程指令
                                                                                                            +
                                                                                                            +
                                                                                                            + + + +
                                                                                                            +
                                                                                                            +
                                                                                                            +
                                                                                                            +
                                                                                                            +
                                                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                            +
                                                                                                            +
                                                                                                            +
                                                                                                            + +
                                                                                                            + +
                                                                                                            +
                                                                                                              +
                                                                                                              +
                                                                                                              +
                                                                                                              + +
                                                                                                              +
                                                                                                              资产信息
                                                                                                              +
                                                                                                              +
                                                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                                                              +
                                                                                                              +
                                                                                                              + + +
                                                                                                              +
                                                                                                              当前值
                                                                                                              +
                                                                                                              +
                                                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                                                              +
                                                                                                              +
                                                                                                              + + +
                                                                                                              +
                                                                                                              远程指令
                                                                                                              +
                                                                                                              +
                                                                                                              + + +
                                                                                                              +
                                                                                                              +
                                                                                                              +
                                                                                                              +
                                                                                                              +
                                                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                              +
                                                                                                              +
                                                                                                              +
                                                                                                              + +
                                                                                                              + +
                                                                                                              +
                                                                                                                +
                                                                                                                +
                                                                                                                +
                                                                                                                + +
                                                                                                                +
                                                                                                                资产信息
                                                                                                                +
                                                                                                                +
                                                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                +
                                                                                                                +
                                                                                                                + + +
                                                                                                                +
                                                                                                                当前值
                                                                                                                +
                                                                                                                +
                                                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                +
                                                                                                                +
                                                                                                                + + +
                                                                                                                +
                                                                                                                远程指令
                                                                                                                +
                                                                                                                +
                                                                                                                + +
                                                                                                                +
                                                                                                                +
                                                                                                                +
                                                                                                                +
                                                                                                                +
                                                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                +
                                                                                                                +
                                                                                                                +
                                                                                                                + +
                                                                                                                + +
                                                                                                                +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  + +
                                                                                                                  +
                                                                                                                  资产信息
                                                                                                                  +
                                                                                                                  +
                                                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  + + +
                                                                                                                  +
                                                                                                                  当前值
                                                                                                                  +
                                                                                                                  +
                                                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  + + +
                                                                                                                  +
                                                                                                                  远程指令
                                                                                                                  +
                                                                                                                  +
                                                                                                                  + +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  +
                                                                                                                  + +
                                                                                                                  + +
                                                                                                                  +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    + +
                                                                                                                    +
                                                                                                                    资产信息
                                                                                                                    +
                                                                                                                    +
                                                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    + + +
                                                                                                                    +
                                                                                                                    当前值
                                                                                                                    +
                                                                                                                    +
                                                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    + + +
                                                                                                                    +
                                                                                                                    远程指令
                                                                                                                    +
                                                                                                                    +
                                                                                                                    + + + +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    +
                                                                                                                    + +
                                                                                                                    + +
                                                                                                                    +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      + +
                                                                                                                      +
                                                                                                                      资产信息
                                                                                                                      +
                                                                                                                      +
                                                                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      + + +
                                                                                                                      +
                                                                                                                      当前值
                                                                                                                      +
                                                                                                                      +
                                                                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      + + +
                                                                                                                      +
                                                                                                                      远程指令
                                                                                                                      +
                                                                                                                      +
                                                                                                                      + + +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      +
                                                                                                                      + +
                                                                                                                      + +
                                                                                                                      +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        + +
                                                                                                                        +
                                                                                                                        资产信息
                                                                                                                        +
                                                                                                                        +
                                                                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        + + +
                                                                                                                        +
                                                                                                                        当前值
                                                                                                                        +
                                                                                                                        +
                                                                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        + + +
                                                                                                                        +
                                                                                                                        远程指令
                                                                                                                        +
                                                                                                                        +
                                                                                                                        + +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        +
                                                                                                                        + +
                                                                                                                        + +
                                                                                                                        +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          + +
                                                                                                                          +
                                                                                                                          资产信息
                                                                                                                          +
                                                                                                                          +
                                                                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          + + +
                                                                                                                          +
                                                                                                                          当前值
                                                                                                                          +
                                                                                                                          +
                                                                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          + + +
                                                                                                                          +
                                                                                                                          远程指令
                                                                                                                          +
                                                                                                                          +
                                                                                                                          + +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          +
                                                                                                                          + +
                                                                                                                          + +
                                                                                                                          +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            + +
                                                                                                                            +
                                                                                                                            资产信息
                                                                                                                            +
                                                                                                                            +
                                                                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            + + +
                                                                                                                            +
                                                                                                                            当前值
                                                                                                                            +
                                                                                                                            +
                                                                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            + + +
                                                                                                                            +
                                                                                                                            远程指令
                                                                                                                            +
                                                                                                                            +
                                                                                                                            + + + +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            +
                                                                                                                            + +
                                                                                                                            + +
                                                                                                                            +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              + +
                                                                                                                              +
                                                                                                                              资产信息
                                                                                                                              +
                                                                                                                              +
                                                                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              + + +
                                                                                                                              +
                                                                                                                              当前值
                                                                                                                              +
                                                                                                                              +
                                                                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              + + +
                                                                                                                              +
                                                                                                                              远程指令
                                                                                                                              +
                                                                                                                              +
                                                                                                                              + + +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              +
                                                                                                                              + +
                                                                                                                              + +
                                                                                                                              +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                + +
                                                                                                                                +
                                                                                                                                资产信息
                                                                                                                                +
                                                                                                                                +
                                                                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                + + +
                                                                                                                                +
                                                                                                                                当前值
                                                                                                                                +
                                                                                                                                +
                                                                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                + + +
                                                                                                                                +
                                                                                                                                远程指令
                                                                                                                                +
                                                                                                                                +
                                                                                                                                + +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                +
                                                                                                                                + +
                                                                                                                                + +
                                                                                                                                +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  + +
                                                                                                                                  +
                                                                                                                                  资产信息
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  + + +
                                                                                                                                  +
                                                                                                                                  当前值
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  + + +
                                                                                                                                  +
                                                                                                                                  远程指令
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  + +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  +
                                                                                                                                  + +
                                                                                                                                  + +
                                                                                                                                  +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + +
                                                                                                                                    +
                                                                                                                                    资产信息
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + + +
                                                                                                                                    +
                                                                                                                                    当前值
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + + +
                                                                                                                                    +
                                                                                                                                    远程指令
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + + + +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + +
                                                                                                                                    + +
                                                                                                                                    +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + +
                                                                                                                                      +
                                                                                                                                      资产信息
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + + +
                                                                                                                                      +
                                                                                                                                      当前值
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + + +
                                                                                                                                      +
                                                                                                                                      远程指令
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + + +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + +
                                                                                                                                      + +
                                                                                                                                      +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        + +
                                                                                                                                        +
                                                                                                                                        资产信息
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        + + +
                                                                                                                                        +
                                                                                                                                        当前值
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        + + +
                                                                                                                                        +
                                                                                                                                        远程指令
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        + +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        +
                                                                                                                                        + +
                                                                                                                                        + +
                                                                                                                                        +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          + +
                                                                                                                                          +
                                                                                                                                          资产信息
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          + + +
                                                                                                                                          +
                                                                                                                                          当前值
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          + + +
                                                                                                                                          +
                                                                                                                                          远程指令
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          + +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          +
                                                                                                                                          + +
                                                                                                                                          + +
                                                                                                                                          +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            + +
                                                                                                                                            +
                                                                                                                                            资产信息
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            + + +
                                                                                                                                            +
                                                                                                                                            当前值
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            + + +
                                                                                                                                            +
                                                                                                                                            远程指令
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            + + + +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            +
                                                                                                                                            + +
                                                                                                                                            + +
                                                                                                                                            +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              + +
                                                                                                                                              +
                                                                                                                                              资产信息
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              + + +
                                                                                                                                              +
                                                                                                                                              当前值
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              + + +
                                                                                                                                              +
                                                                                                                                              远程指令
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              + + +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              +
                                                                                                                                              + +
                                                                                                                                              + +
                                                                                                                                              +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                + +
                                                                                                                                                +
                                                                                                                                                资产信息
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                + + +
                                                                                                                                                +
                                                                                                                                                当前值
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                + + +
                                                                                                                                                +
                                                                                                                                                远程指令
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                + +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                +
                                                                                                                                                + +
                                                                                                                                                + +
                                                                                                                                                +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  + +
                                                                                                                                                  +
                                                                                                                                                  资产信息
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  + + +
                                                                                                                                                  +
                                                                                                                                                  当前值
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  + + +
                                                                                                                                                  +
                                                                                                                                                  远程指令
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  + +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  +
                                                                                                                                                  + +
                                                                                                                                                  + +
                                                                                                                                                  +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    + +
                                                                                                                                                    +
                                                                                                                                                    资产信息
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    + + +
                                                                                                                                                    +
                                                                                                                                                    当前值
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    + + +
                                                                                                                                                    +
                                                                                                                                                    远程指令
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    + + + +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    +
                                                                                                                                                    + +
                                                                                                                                                    + +
                                                                                                                                                    +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      + +
                                                                                                                                                      +
                                                                                                                                                      资产信息
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      + + +
                                                                                                                                                      +
                                                                                                                                                      当前值
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      + + +
                                                                                                                                                      +
                                                                                                                                                      远程指令
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      + + +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      +
                                                                                                                                                      + +
                                                                                                                                                      + +
                                                                                                                                                      +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        + +
                                                                                                                                                        +
                                                                                                                                                        资产信息
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        + + +
                                                                                                                                                        +
                                                                                                                                                        当前值
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        + + +
                                                                                                                                                        +
                                                                                                                                                        远程指令
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        + +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        +
                                                                                                                                                        + +
                                                                                                                                                        + +
                                                                                                                                                        +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          + +
                                                                                                                                                          +
                                                                                                                                                          资产信息
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          + + +
                                                                                                                                                          +
                                                                                                                                                          当前值
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          + + +
                                                                                                                                                          +
                                                                                                                                                          远程指令
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          + +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          +
                                                                                                                                                          + +
                                                                                                                                                          + +
                                                                                                                                                          +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            + +
                                                                                                                                                            +
                                                                                                                                                            资产信息
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            + + +
                                                                                                                                                            +
                                                                                                                                                            当前值
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            + + +
                                                                                                                                                            +
                                                                                                                                                            远程指令
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            + + + +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java index cf5c600..a3289ea 100644 --- a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; +import com.szpg.db.data.PgSbStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -112,6 +113,14 @@ deviceDao.updateDeviceStatus(deviceId, sb1Run.get(i) | sb2Run.get(i) == true ? "水泵运行" : "水泵停止"); } } + + // 更新水泵状态现状表 + PgSbStat temp = sbDao.findLatestStatByDevice(deviceId); + if (null == temp) { + sbDao.addStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } else { + sbDao.updateStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } // 如果单泵或者双泵有任意一个故障则都报警 if ((null != sb1Flt.get(i) && sb1Flt.get(i) == true) || (null != sb2Flt.get(i) && sb2Flt.get(i) == true)) { diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            +
                                                                                                                                                            + +
                                                                                                                                                            + +
                                                                                                                                                            +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              + +
                                                                                                                                                              +
                                                                                                                                                              资产信息
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              + + +
                                                                                                                                                              +
                                                                                                                                                              当前值
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              + + +
                                                                                                                                                              +
                                                                                                                                                              远程指令
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              + + +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              +
                                                                                                                                                              + +
                                                                                                                                                              + +
                                                                                                                                                              +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                + +
                                                                                                                                                                +
                                                                                                                                                                资产信息
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                + + +
                                                                                                                                                                +
                                                                                                                                                                当前值
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                + + +
                                                                                                                                                                +
                                                                                                                                                                远程指令
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                + +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                +
                                                                                                                                                                + +
                                                                                                                                                                + +
                                                                                                                                                                +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  + +
                                                                                                                                                                  +
                                                                                                                                                                  资产信息
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  + + +
                                                                                                                                                                  +
                                                                                                                                                                  当前值
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  + + +
                                                                                                                                                                  +
                                                                                                                                                                  远程指令
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  + +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  +
                                                                                                                                                                  + +
                                                                                                                                                                  + +
                                                                                                                                                                  +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    + +
                                                                                                                                                                    +
                                                                                                                                                                    资产信息
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    + + +
                                                                                                                                                                    +
                                                                                                                                                                    当前值
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    + + +
                                                                                                                                                                    +
                                                                                                                                                                    远程指令
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    + + + +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java index cf5c600..a3289ea 100644 --- a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; +import com.szpg.db.data.PgSbStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -112,6 +113,14 @@ deviceDao.updateDeviceStatus(deviceId, sb1Run.get(i) | sb2Run.get(i) == true ? "水泵运行" : "水泵停止"); } } + + // 更新水泵状态现状表 + PgSbStat temp = sbDao.findLatestStatByDevice(deviceId); + if (null == temp) { + sbDao.addStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } else { + sbDao.updateStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } // 如果单泵或者双泵有任意一个故障则都报警 if ((null != sb1Flt.get(i) && sb1Flt.get(i) == true) || (null != sb2Flt.get(i) && sb2Flt.get(i) == true)) { diff --git a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java index e95137a..b21b453 100644 --- a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addYWAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段液位爆管报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    +
                                                                                                                                                                    + +
                                                                                                                                                                    + +
                                                                                                                                                                    +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      + +
                                                                                                                                                                      +
                                                                                                                                                                      资产信息
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      + + +
                                                                                                                                                                      +
                                                                                                                                                                      当前值
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      + + +
                                                                                                                                                                      +
                                                                                                                                                                      远程指令
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      + + +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      +
                                                                                                                                                                      + +
                                                                                                                                                                      + +
                                                                                                                                                                      +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        + +
                                                                                                                                                                        +
                                                                                                                                                                        资产信息
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        + + +
                                                                                                                                                                        +
                                                                                                                                                                        当前值
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        + + +
                                                                                                                                                                        +
                                                                                                                                                                        远程指令
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        + +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        +
                                                                                                                                                                        + +
                                                                                                                                                                        + +
                                                                                                                                                                        +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          + +
                                                                                                                                                                          +
                                                                                                                                                                          资产信息
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          + + +
                                                                                                                                                                          +
                                                                                                                                                                          当前值
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          + + +
                                                                                                                                                                          +
                                                                                                                                                                          远程指令
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          + +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          +
                                                                                                                                                                          + +
                                                                                                                                                                          + +
                                                                                                                                                                          +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            + +
                                                                                                                                                                            +
                                                                                                                                                                            资产信息
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            + + +
                                                                                                                                                                            +
                                                                                                                                                                            当前值
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            + + +
                                                                                                                                                                            +
                                                                                                                                                                            远程指令
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            + + + +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java index cf5c600..a3289ea 100644 --- a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; +import com.szpg.db.data.PgSbStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -112,6 +113,14 @@ deviceDao.updateDeviceStatus(deviceId, sb1Run.get(i) | sb2Run.get(i) == true ? "水泵运行" : "水泵停止"); } } + + // 更新水泵状态现状表 + PgSbStat temp = sbDao.findLatestStatByDevice(deviceId); + if (null == temp) { + sbDao.addStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } else { + sbDao.updateStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } // 如果单泵或者双泵有任意一个故障则都报警 if ((null != sb1Flt.get(i) && sb1Flt.get(i) == true) || (null != sb2Flt.get(i) && sb2Flt.get(i) == true)) { diff --git a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java index e95137a..b21b453 100644 --- a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addYWAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段液位爆管报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/rmi/PgInterface.java b/src/com/szpg/rmi/PgInterface.java index 0c4840a..9a63462 100644 --- a/src/com/szpg/rmi/PgInterface.java +++ b/src/com/szpg/rmi/PgInterface.java @@ -77,7 +77,7 @@ // 跨域查询接口 String baseURL = Configure.getProperty("sys", "PGINTERFACE_API_URL"); - String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDevice", params); + String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDev", params); JSONObject jsonObject = new JSONObject(response); JSONArray jArray = jsonObject.getJSONArray("result"); diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            +
                                                                                                                                                                            + +
                                                                                                                                                                            + +
                                                                                                                                                                            +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              + +
                                                                                                                                                                              +
                                                                                                                                                                              资产信息
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              + + +
                                                                                                                                                                              +
                                                                                                                                                                              当前值
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              + + +
                                                                                                                                                                              +
                                                                                                                                                                              远程指令
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              + + +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              +
                                                                                                                                                                              + +
                                                                                                                                                                              + +
                                                                                                                                                                              +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                + +
                                                                                                                                                                                +
                                                                                                                                                                                资产信息
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                + + +
                                                                                                                                                                                +
                                                                                                                                                                                当前值
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                + + +
                                                                                                                                                                                +
                                                                                                                                                                                远程指令
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                + +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                +
                                                                                                                                                                                + +
                                                                                                                                                                                + +
                                                                                                                                                                                +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  + +
                                                                                                                                                                                  +
                                                                                                                                                                                  资产信息
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  + + +
                                                                                                                                                                                  +
                                                                                                                                                                                  当前值
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  + + +
                                                                                                                                                                                  +
                                                                                                                                                                                  远程指令
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  + +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  +
                                                                                                                                                                                  + +
                                                                                                                                                                                  + +
                                                                                                                                                                                  +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    + +
                                                                                                                                                                                    +
                                                                                                                                                                                    资产信息
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    + + +
                                                                                                                                                                                    +
                                                                                                                                                                                    当前值
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    + + +
                                                                                                                                                                                    +
                                                                                                                                                                                    远程指令
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    + + + +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java index cf5c600..a3289ea 100644 --- a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; +import com.szpg.db.data.PgSbStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -112,6 +113,14 @@ deviceDao.updateDeviceStatus(deviceId, sb1Run.get(i) | sb2Run.get(i) == true ? "水泵运行" : "水泵停止"); } } + + // 更新水泵状态现状表 + PgSbStat temp = sbDao.findLatestStatByDevice(deviceId); + if (null == temp) { + sbDao.addStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } else { + sbDao.updateStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } // 如果单泵或者双泵有任意一个故障则都报警 if ((null != sb1Flt.get(i) && sb1Flt.get(i) == true) || (null != sb2Flt.get(i) && sb2Flt.get(i) == true)) { diff --git a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java index e95137a..b21b453 100644 --- a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addYWAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段液位爆管报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/rmi/PgInterface.java b/src/com/szpg/rmi/PgInterface.java index 0c4840a..9a63462 100644 --- a/src/com/szpg/rmi/PgInterface.java +++ b/src/com/szpg/rmi/PgInterface.java @@ -77,7 +77,7 @@ // 跨域查询接口 String baseURL = Configure.getProperty("sys", "PGINTERFACE_API_URL"); - String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDevice", params); + String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDev", params); JSONObject jsonObject = new JSONObject(response); JSONArray jArray = jsonObject.getJSONArray("result"); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d48bae7..a4abdce 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -1,5 +1,12 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgAlarmDao; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.impl.PgAlarmDaoImpl; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.data.PgAlarm; +import com.szpg.db.data.PgDevice; +import com.szpg.util.TimeFormat; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +32,9 @@ import z.json.JSONObject; +import java.net.URLEncoder; +import java.util.Calendar; + public class RemoteDSCommandAction extends ActionSupport { /** @@ -241,6 +251,33 @@ return null; } } + + + public String readDsStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgAlarmDao alarmDao = new PgAlarmDaoImpl(); + PgDevice device = deviceDao.findDeviceByCode(zcbh); + if (null != device) { + JSONObject obj = new JSONObject(); + if (null != device.getIsopen() && device.getIsopen().indexOf("入侵") > 0) { + PgAlarm alarm = alarmDao.findLatestAlarmByDevice(device.getId()); + if (null != alarm) { + obj.put("alm", null != alarm.getDescription() ? URLEncoder.encode(alarm.getDescription(), "UTF-8") : ""); + obj.put("time", TimeFormat.formatTimestamp(alarm.getAlarm_date())); + } + } else { + obj.put("alm", URLEncoder.encode("正常", "UTF-8")); + obj.put("time", TimeFormat.formatTimestamp(Calendar.getInstance().getTime())); + } + jResult.put("dsStat", obj); + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    +
                                                                                                                                                                                    + +
                                                                                                                                                                                    + +
                                                                                                                                                                                    +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      + +
                                                                                                                                                                                      +
                                                                                                                                                                                      资产信息
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      + + +
                                                                                                                                                                                      +
                                                                                                                                                                                      当前值
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      + + +
                                                                                                                                                                                      +
                                                                                                                                                                                      远程指令
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      + + +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      +
                                                                                                                                                                                      + +
                                                                                                                                                                                      + +
                                                                                                                                                                                      +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        + +
                                                                                                                                                                                        +
                                                                                                                                                                                        资产信息
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        + + +
                                                                                                                                                                                        +
                                                                                                                                                                                        当前值
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        + + +
                                                                                                                                                                                        +
                                                                                                                                                                                        远程指令
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        + +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        +
                                                                                                                                                                                        + +
                                                                                                                                                                                        + +
                                                                                                                                                                                        +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          + +
                                                                                                                                                                                          +
                                                                                                                                                                                          资产信息
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          + + +
                                                                                                                                                                                          +
                                                                                                                                                                                          当前值
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          + + +
                                                                                                                                                                                          +
                                                                                                                                                                                          远程指令
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          + +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          +
                                                                                                                                                                                          + +
                                                                                                                                                                                          + +
                                                                                                                                                                                          +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            + +
                                                                                                                                                                                            +
                                                                                                                                                                                            资产信息
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            + + +
                                                                                                                                                                                            +
                                                                                                                                                                                            当前值
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            + + +
                                                                                                                                                                                            +
                                                                                                                                                                                            远程指令
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            + + + +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java index cf5c600..a3289ea 100644 --- a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; +import com.szpg.db.data.PgSbStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -112,6 +113,14 @@ deviceDao.updateDeviceStatus(deviceId, sb1Run.get(i) | sb2Run.get(i) == true ? "水泵运行" : "水泵停止"); } } + + // 更新水泵状态现状表 + PgSbStat temp = sbDao.findLatestStatByDevice(deviceId); + if (null == temp) { + sbDao.addStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } else { + sbDao.updateStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } // 如果单泵或者双泵有任意一个故障则都报警 if ((null != sb1Flt.get(i) && sb1Flt.get(i) == true) || (null != sb2Flt.get(i) && sb2Flt.get(i) == true)) { diff --git a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java index e95137a..b21b453 100644 --- a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addYWAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段液位爆管报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/rmi/PgInterface.java b/src/com/szpg/rmi/PgInterface.java index 0c4840a..9a63462 100644 --- a/src/com/szpg/rmi/PgInterface.java +++ b/src/com/szpg/rmi/PgInterface.java @@ -77,7 +77,7 @@ // 跨域查询接口 String baseURL = Configure.getProperty("sys", "PGINTERFACE_API_URL"); - String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDevice", params); + String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDev", params); JSONObject jsonObject = new JSONObject(response); JSONArray jArray = jsonObject.getJSONArray("result"); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d48bae7..a4abdce 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -1,5 +1,12 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgAlarmDao; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.impl.PgAlarmDaoImpl; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.data.PgAlarm; +import com.szpg.db.data.PgDevice; +import com.szpg.util.TimeFormat; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +32,9 @@ import z.json.JSONObject; +import java.net.URLEncoder; +import java.util.Calendar; + public class RemoteDSCommandAction extends ActionSupport { /** @@ -241,6 +251,33 @@ return null; } } + + + public String readDsStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgAlarmDao alarmDao = new PgAlarmDaoImpl(); + PgDevice device = deviceDao.findDeviceByCode(zcbh); + if (null != device) { + JSONObject obj = new JSONObject(); + if (null != device.getIsopen() && device.getIsopen().indexOf("入侵") > 0) { + PgAlarm alarm = alarmDao.findLatestAlarmByDevice(device.getId()); + if (null != alarm) { + obj.put("alm", null != alarm.getDescription() ? URLEncoder.encode(alarm.getDescription(), "UTF-8") : ""); + obj.put("time", TimeFormat.formatTimestamp(alarm.getAlarm_date())); + } + } else { + obj.put("alm", URLEncoder.encode("正常", "UTF-8")); + obj.put("time", TimeFormat.formatTimestamp(Calendar.getInstance().getTime())); + } + jResult.put("dsStat", obj); + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 4bb1148..d5c8cec 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -1,5 +1,10 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.PgJgDao; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.dao.impl.PgJgDaoImpl; +import com.szpg.db.data.PgJgStat; import com.szpg.plc.message.command.write.SetJgLockBitCommand; import com.szpg.plc.message.command.write.SetJgOffBitCommand; import com.szpg.plc.message.command.write.SetJgOnBitCommand; @@ -459,7 +464,26 @@ return null; } } - + + + public String readJgStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgJgDao jgDao = new PgJgDaoImpl(); + + int deviceId = deviceDao.findDeviceIdByCode(zcbh); + if (deviceId > 0) { + PgJgStat jgStat = jgDao.findLatestStatByDevice(deviceId); + if (null != jgStat) { + jResult.put("jgStat", jgStat.toJson()); + } + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            +
                                                                                                                                                                                            + +
                                                                                                                                                                                            + +
                                                                                                                                                                                            +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              + +
                                                                                                                                                                                              +
                                                                                                                                                                                              资产信息
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              + + +
                                                                                                                                                                                              +
                                                                                                                                                                                              当前值
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              + + +
                                                                                                                                                                                              +
                                                                                                                                                                                              远程指令
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              + + +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              +
                                                                                                                                                                                              + +
                                                                                                                                                                                              + +
                                                                                                                                                                                              +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                + +
                                                                                                                                                                                                +
                                                                                                                                                                                                资产信息
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                + + +
                                                                                                                                                                                                +
                                                                                                                                                                                                当前值
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                + + +
                                                                                                                                                                                                +
                                                                                                                                                                                                远程指令
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                + +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                +
                                                                                                                                                                                                + +
                                                                                                                                                                                                + +
                                                                                                                                                                                                +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  + +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  资产信息
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  + + +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  当前值
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  + + +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  远程指令
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  + +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  +
                                                                                                                                                                                                  + +
                                                                                                                                                                                                  + +
                                                                                                                                                                                                  +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    + +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    资产信息
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    + + +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    当前值
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    + + +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    远程指令
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    + + + +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java index cf5c600..a3289ea 100644 --- a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; +import com.szpg.db.data.PgSbStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -112,6 +113,14 @@ deviceDao.updateDeviceStatus(deviceId, sb1Run.get(i) | sb2Run.get(i) == true ? "水泵运行" : "水泵停止"); } } + + // 更新水泵状态现状表 + PgSbStat temp = sbDao.findLatestStatByDevice(deviceId); + if (null == temp) { + sbDao.addStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } else { + sbDao.updateStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } // 如果单泵或者双泵有任意一个故障则都报警 if ((null != sb1Flt.get(i) && sb1Flt.get(i) == true) || (null != sb2Flt.get(i) && sb2Flt.get(i) == true)) { diff --git a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java index e95137a..b21b453 100644 --- a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addYWAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段液位爆管报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/rmi/PgInterface.java b/src/com/szpg/rmi/PgInterface.java index 0c4840a..9a63462 100644 --- a/src/com/szpg/rmi/PgInterface.java +++ b/src/com/szpg/rmi/PgInterface.java @@ -77,7 +77,7 @@ // 跨域查询接口 String baseURL = Configure.getProperty("sys", "PGINTERFACE_API_URL"); - String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDevice", params); + String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDev", params); JSONObject jsonObject = new JSONObject(response); JSONArray jArray = jsonObject.getJSONArray("result"); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d48bae7..a4abdce 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -1,5 +1,12 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgAlarmDao; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.impl.PgAlarmDaoImpl; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.data.PgAlarm; +import com.szpg.db.data.PgDevice; +import com.szpg.util.TimeFormat; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +32,9 @@ import z.json.JSONObject; +import java.net.URLEncoder; +import java.util.Calendar; + public class RemoteDSCommandAction extends ActionSupport { /** @@ -241,6 +251,33 @@ return null; } } + + + public String readDsStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgAlarmDao alarmDao = new PgAlarmDaoImpl(); + PgDevice device = deviceDao.findDeviceByCode(zcbh); + if (null != device) { + JSONObject obj = new JSONObject(); + if (null != device.getIsopen() && device.getIsopen().indexOf("入侵") > 0) { + PgAlarm alarm = alarmDao.findLatestAlarmByDevice(device.getId()); + if (null != alarm) { + obj.put("alm", null != alarm.getDescription() ? URLEncoder.encode(alarm.getDescription(), "UTF-8") : ""); + obj.put("time", TimeFormat.formatTimestamp(alarm.getAlarm_date())); + } + } else { + obj.put("alm", URLEncoder.encode("正常", "UTF-8")); + obj.put("time", TimeFormat.formatTimestamp(Calendar.getInstance().getTime())); + } + jResult.put("dsStat", obj); + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 4bb1148..d5c8cec 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -1,5 +1,10 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.PgJgDao; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.dao.impl.PgJgDaoImpl; +import com.szpg.db.data.PgJgStat; import com.szpg.plc.message.command.write.SetJgLockBitCommand; import com.szpg.plc.message.command.write.SetJgOffBitCommand; import com.szpg.plc.message.command.write.SetJgOnBitCommand; @@ -459,7 +464,26 @@ return null; } } - + + + public String readJgStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgJgDao jgDao = new PgJgDaoImpl(); + + int deviceId = deviceDao.findDeviceIdByCode(zcbh); + if (deviceId > 0) { + PgJgStat jgStat = jgDao.findLatestStatByDevice(deviceId); + if (null != jgStat) { + jResult.put("jgStat", jgStat.toJson()); + } + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/src/com/szpg/rmi/RemoteSBCommandAction.java b/src/com/szpg/rmi/RemoteSBCommandAction.java index 9d090ef..0faf4fe 100644 --- a/src/com/szpg/rmi/RemoteSBCommandAction.java +++ b/src/com/szpg/rmi/RemoteSBCommandAction.java @@ -1,5 +1,10 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.PgSbDao; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.dao.impl.PgSbDaoImpl; +import com.szpg.db.data.PgSbStat; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -145,6 +150,25 @@ return null; } } + + public String readSbStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgSbDao sbDao = new PgSbDaoImpl(); + + int deviceId = deviceDao.findDeviceIdByCode(zcbh); + if (deviceId > 0) { + PgSbStat sbStat = sbDao.findLatestStatByDevice(deviceId); + if (null != sbStat) { + jResult.put("sbStat", sbStat.toJson()); + } + } + + returnToFront(jResult); + return null; + } /** diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    +
                                                                                                                                                                                                    + +
                                                                                                                                                                                                    + +
                                                                                                                                                                                                    +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      + +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      资产信息
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      + + +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      当前值
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      + + 时间: + + + 对射状态: + + + + +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      + + +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      远程指令
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      + + +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      +
                                                                                                                                                                                                      + +
                                                                                                                                                                                                      + +
                                                                                                                                                                                                      +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        + +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        资产信息
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        + + +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        当前值
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        + + +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        远程指令
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        + +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        +
                                                                                                                                                                                                        + +
                                                                                                                                                                                                        + +
                                                                                                                                                                                                        +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          + +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          资产信息
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          + + +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          当前值
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          + + +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          远程指令
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          + +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          +
                                                                                                                                                                                                          + +
                                                                                                                                                                                                          + +
                                                                                                                                                                                                          +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            + +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            资产信息
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            + + +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            当前值
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            + + +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            远程指令
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            + + + +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java index cf5c600..a3289ea 100644 --- a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; +import com.szpg.db.data.PgSbStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -112,6 +113,14 @@ deviceDao.updateDeviceStatus(deviceId, sb1Run.get(i) | sb2Run.get(i) == true ? "水泵运行" : "水泵停止"); } } + + // 更新水泵状态现状表 + PgSbStat temp = sbDao.findLatestStatByDevice(deviceId); + if (null == temp) { + sbDao.addStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } else { + sbDao.updateStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } // 如果单泵或者双泵有任意一个故障则都报警 if ((null != sb1Flt.get(i) && sb1Flt.get(i) == true) || (null != sb2Flt.get(i) && sb2Flt.get(i) == true)) { diff --git a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java index e95137a..b21b453 100644 --- a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addYWAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段液位爆管报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/rmi/PgInterface.java b/src/com/szpg/rmi/PgInterface.java index 0c4840a..9a63462 100644 --- a/src/com/szpg/rmi/PgInterface.java +++ b/src/com/szpg/rmi/PgInterface.java @@ -77,7 +77,7 @@ // 跨域查询接口 String baseURL = Configure.getProperty("sys", "PGINTERFACE_API_URL"); - String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDevice", params); + String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDev", params); JSONObject jsonObject = new JSONObject(response); JSONArray jArray = jsonObject.getJSONArray("result"); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d48bae7..a4abdce 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -1,5 +1,12 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgAlarmDao; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.impl.PgAlarmDaoImpl; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.data.PgAlarm; +import com.szpg.db.data.PgDevice; +import com.szpg.util.TimeFormat; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +32,9 @@ import z.json.JSONObject; +import java.net.URLEncoder; +import java.util.Calendar; + public class RemoteDSCommandAction extends ActionSupport { /** @@ -241,6 +251,33 @@ return null; } } + + + public String readDsStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgAlarmDao alarmDao = new PgAlarmDaoImpl(); + PgDevice device = deviceDao.findDeviceByCode(zcbh); + if (null != device) { + JSONObject obj = new JSONObject(); + if (null != device.getIsopen() && device.getIsopen().indexOf("入侵") > 0) { + PgAlarm alarm = alarmDao.findLatestAlarmByDevice(device.getId()); + if (null != alarm) { + obj.put("alm", null != alarm.getDescription() ? URLEncoder.encode(alarm.getDescription(), "UTF-8") : ""); + obj.put("time", TimeFormat.formatTimestamp(alarm.getAlarm_date())); + } + } else { + obj.put("alm", URLEncoder.encode("正常", "UTF-8")); + obj.put("time", TimeFormat.formatTimestamp(Calendar.getInstance().getTime())); + } + jResult.put("dsStat", obj); + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 4bb1148..d5c8cec 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -1,5 +1,10 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.PgJgDao; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.dao.impl.PgJgDaoImpl; +import com.szpg.db.data.PgJgStat; import com.szpg.plc.message.command.write.SetJgLockBitCommand; import com.szpg.plc.message.command.write.SetJgOffBitCommand; import com.szpg.plc.message.command.write.SetJgOnBitCommand; @@ -459,7 +464,26 @@ return null; } } - + + + public String readJgStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgJgDao jgDao = new PgJgDaoImpl(); + + int deviceId = deviceDao.findDeviceIdByCode(zcbh); + if (deviceId > 0) { + PgJgStat jgStat = jgDao.findLatestStatByDevice(deviceId); + if (null != jgStat) { + jResult.put("jgStat", jgStat.toJson()); + } + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/src/com/szpg/rmi/RemoteSBCommandAction.java b/src/com/szpg/rmi/RemoteSBCommandAction.java index 9d090ef..0faf4fe 100644 --- a/src/com/szpg/rmi/RemoteSBCommandAction.java +++ b/src/com/szpg/rmi/RemoteSBCommandAction.java @@ -1,5 +1,10 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.PgSbDao; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.dao.impl.PgSbDaoImpl; +import com.szpg.db.data.PgSbStat; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -145,6 +150,25 @@ return null; } } + + public String readSbStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgSbDao sbDao = new PgSbDaoImpl(); + + int deviceId = deviceDao.findDeviceIdByCode(zcbh); + if (deviceId > 0) { + PgSbStat sbStat = sbDao.findLatestStatByDevice(deviceId); + if (null != sbStat) { + jResult.put("sbStat", sbStat.toJson()); + } + } + + returnToFront(jResult); + return null; + } /** diff --git a/src/com/szpg/rmi/RemoteYWCommandAction.java b/src/com/szpg/rmi/RemoteYWCommandAction.java new file mode 100644 index 0000000..bbc0037 --- /dev/null +++ b/src/com/szpg/rmi/RemoteYWCommandAction.java @@ -0,0 +1,177 @@ +package com.szpg.rmi; + +import com.opensymphony.xwork2.ActionSupport; +import com.szpg.db.dao.*; +import com.szpg.db.dao.impl.*; +import com.szpg.db.data.PgAcu; +import com.szpg.db.data.PgAlarm; +import com.szpg.db.data.PgDevice; +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.ReadControllerStatusService; +import com.szpg.util.Configure; +import com.szpg.util.TimeFormat; +import com.szpg.util.UnicodeConvertor; +import org.apache.log4j.Logger; +import org.apache.struts2.ServletActionContext; +import z.json.JSONObject; + +import java.net.URLEncoder; +import java.util.Calendar; + +public class RemoteYWCommandAction extends ActionSupport { + + /** + * + */ + private static final long serialVersionUID = 2221187086461756012L; + + private String zcbh; + + private String format; + private String jsoncallback; + + private Logger logger = Logger.getLogger(this.getClass().getName()); + + public String getZcbh() { + return zcbh; + } + + public void setZcbh(String zcbh) { + this.zcbh = zcbh; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getJsoncallback() { + return jsoncallback; + } + + public void setJsoncallback(String jsoncallback) { + this.jsoncallback = jsoncallback; + } + + /** + * 读取爆管液位实时状态 + * @return + * @throws Exception + */ + public String readYwStatus() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgAcuDao acuDao = new PgAcuDaoImpl(); + + if (null == zcbh || zcbh.equals("") == true) { + jResult.put("success", false); + jResult.put("code", "1"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("资产编号为空")); + + returnToFront(jResult); + return null; + } + + String acucode = zcbh.substring(0, zcbh.indexOf(".", 6)); + PgAcu acu = acuDao.findACUByCode(acucode); + if (null == acu) { + jResult.put("success", false); + jResult.put("code", "2"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到资产对应的PLC主机")); + + returnToFront(jResult); + return null; + } + + ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); + if (null != client) { + ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READYWSTATUS); + String sour = Configure.getProperty("sys", "LOCALHOST.NET") + + Configure.getProperty("sys", "LOCALHOST.NODE") + + Configure.getProperty("sys", "LOCALHOST.UNIT"); + command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); + + 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() + ".YWALM.START")), 2)) + "00"); + command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YWALM.WORDCOUNT"))); + + // 调用服务过程执行命令发送服务 + ReadControllerStatusService service = new ReadControllerStatusService(); + service.executeService(client, command); + logger.info(command); + } catch (Exception ex) { + logger.error("发送查询爆管液位指令异常" + ex); + } + + jResult.put("success", true); + jResult.put("resaon", UnicodeConvertor.string2Unicode("发送成功,请等待响应")); + + returnToFront(jResult); + return null; + } else { + jResult.put("success", false); + jResult.put("code", "3"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("PLC主机不在线")); + + returnToFront(jResult); + return null; + } + } + + public String readYwStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgAlarmDao alarmDao = new PgAlarmDaoImpl(); + PgDevice device = deviceDao.findDeviceByCode(zcbh); + if (null != device) { + JSONObject obj = new JSONObject(); + if (null != device.getIsopen() && device.getIsopen().indexOf("爆管") > 0) { + PgAlarm alarm = alarmDao.findLatestAlarmByDevice(device.getId()); + if (null != alarm) { + obj.put("alm", null != alarm.getDescription() ? URLEncoder.encode(alarm.getDescription(), "UTF-8") : ""); + obj.put("time", TimeFormat.formatTimestamp(alarm.getAlarm_date())); + } + } else { + obj.put("alm", URLEncoder.encode("正常", "UTF-8")); + obj.put("time", TimeFormat.formatTimestamp(Calendar.getInstance().getTime())); + } + jResult.put("ywStat", obj); + } + + returnToFront(jResult); + return null; + } + + /** + * 给前端返回 + * @param jResult + * @throws Exception + */ + private void returnToFront(JSONObject jResult) throws Exception { + // 返回jsonp格式的数据 + if (null != format && format.equalsIgnoreCase("jsonp") == true) { + ServletActionContext.getResponse().getWriter().write(jsoncallback + "(" + jResult.toString() + ");"); + } + + ServletActionContext.getResponse().getWriter().write(jResult.toString()); + } + +} diff --git a/WebRoot/device/alarm.jsp b/WebRoot/device/alarm.jsp new file mode 100644 index 0000000..f6ef215 --- /dev/null +++ b/WebRoot/device/alarm.jsp @@ -0,0 +1,183 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 对射数据及控制 + + + + + +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            +
                                                                                                                                                                                                            + +
                                                                                                                                                                                                            + +
                                                                                                                                                                                                            +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              + +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              资产信息
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              + + +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              当前值
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              + + 时间: + + + 对射状态: + + + + +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              + + +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              远程指令
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              + + +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              + + + + + + diff --git a/WebRoot/device/fan.jsp b/WebRoot/device/fan.jsp index c081311..ca6a133 100644 --- a/WebRoot/device/fan.jsp +++ b/WebRoot/device/fan.jsp @@ -113,7 +113,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=风机&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/light.jsp b/WebRoot/device/light.jsp index 78d9b40..b139b3b 100644 --- a/WebRoot/device/light.jsp +++ b/WebRoot/device/light.jsp @@ -105,7 +105,7 @@ // 查询设备列表 function initDeviceList(acu) { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=应急荧光灯&partition=" + acu}, dataType: "json", type: "POST", diff --git a/WebRoot/device/power.jsp b/WebRoot/device/power.jsp index 5311973..231c537 100644 --- a/WebRoot/device/power.jsp +++ b/WebRoot/device/power.jsp @@ -88,7 +88,7 @@ // 查询配电柜列表 function initDeviceList() { $.ajax({ - url: "http://localhost:8080/pgdsc/api/getPgDevice.action", + url: "api/getPgDevice.action", data: {params: "devType=配电柜"}, dataType: "json", type: "POST", diff --git a/WebRoot/device/pump.jsp b/WebRoot/device/pump.jsp new file mode 100644 index 0000000..115c5ac --- /dev/null +++ b/WebRoot/device/pump.jsp @@ -0,0 +1,187 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 水泵数据 + + + + + +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              +
                                                                                                                                                                                                              + +
                                                                                                                                                                                                              + +
                                                                                                                                                                                                              +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                + +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                资产信息
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                + + +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                当前值
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                + + 时间: + + + 水泵1状态: + + + 水泵2状态: + + + + +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                + + +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                远程指令
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                + +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                + + + + + + diff --git a/WebRoot/device/water.jsp b/WebRoot/device/water.jsp new file mode 100644 index 0000000..e2bdbf7 --- /dev/null +++ b/WebRoot/device/water.jsp @@ -0,0 +1,182 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 爆管液位数据 + + + + + +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                + +
                                                                                                                                                                                                                + +
                                                                                                                                                                                                                +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  + +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  资产信息
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  + + +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  当前值
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  + + 时间: + + + 爆管状态: + + + + +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  + + +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  远程指令
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  + +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  + + + + + + diff --git a/WebRoot/device/well.jsp b/WebRoot/device/well.jsp new file mode 100644 index 0000000..4130e8b --- /dev/null +++ b/WebRoot/device/well.jsp @@ -0,0 +1,239 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<% + String path = request.getContextPath(); + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + 井盖数据及控制 + + + + + +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                  + +
                                                                                                                                                                                                                  + +
                                                                                                                                                                                                                  +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    + +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    资产信息
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    + 所在分区: + 资产代码: + 资产名称: +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    + + +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    当前值
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    + + 时间: + + + 井盖开闭: + + + 井盖解锁: + + + + +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    + + +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    远程指令
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    + + + +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    +
                                                                                                                                                                                                                    + + + + + + diff --git a/src/ACUBL.properties b/src/ACUBL.properties index f7a4600..82761aa 100644 --- a/src/ACUBL.properties +++ b/src/ACUBL.properties @@ -106,13 +106,13 @@ #\u6C34\u6CF5\u6570\u91CF -THXC.ACU001.SB.COUNT = 18 +THXC.ACU001.SB.COUNT = 12 #\u6C34\u6CF5\u7F16\u7801\u5217\u8868 -THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.DSB05;THXC.ACU001.P.DSB06;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.SSB05;THXC.ACU001.P.SSB06;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04;THXC.ACU001.P.RSB05;THXC.ACU001.P.RSB06 +THXC.ACU001.SB.ZC.LIST = THXC.ACU001.P.DSB01;THXC.ACU001.P.DSB02;THXC.ACU001.P.DSB03;THXC.ACU001.P.DSB04;THXC.ACU001.P.SSB01;THXC.ACU001.P.SSB02;THXC.ACU001.P.SSB03;THXC.ACU001.P.SSB04;THXC.ACU001.P.RSB01;THXC.ACU001.P.RSB02;THXC.ACU001.P.RSB03;THXC.ACU001.P.RSB04 #\u98CE\u673A\u72B6\u6001\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBSTAT.START = 50 #\u6C34\u6CF5\u72B6\u6001\u6240\u5360\u5B57\u6570 -THXC.ACU001.SBSTAT.WORDCOUNT = 17 +THXC.ACU001.SBSTAT.WORDCOUNT = 27 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u8D77\u59CB\u5730\u5740 THXC.ACU001.SBRT.START = 100 #\u6C34\u6CF5\u8FD0\u884C\u65F6\u957F\u6240\u5360\u5B57\u6570 diff --git a/src/com/szpg/db/dao/PgAlarmDao.java b/src/com/szpg/db/dao/PgAlarmDao.java index 039766e..11d8a1d 100644 --- a/src/com/szpg/db/dao/PgAlarmDao.java +++ b/src/com/szpg/db/dao/PgAlarmDao.java @@ -5,6 +5,7 @@ public interface PgAlarmDao { public int findAlarmCountByDate(String date); + public PgAlarm findLatestAlarmByDevice(int deviceId); public long insertAlarmRecord(PgAlarm alarmRecord); } diff --git a/src/com/szpg/db/dao/PgDeviceDao.java b/src/com/szpg/db/dao/PgDeviceDao.java index 2180c16..bddc936 100644 --- a/src/com/szpg/db/dao/PgDeviceDao.java +++ b/src/com/szpg/db/dao/PgDeviceDao.java @@ -11,6 +11,7 @@ public Integer findDeviceIdByCode(String code); public PgDevice findDeviceById(Integer deviceId); + public PgDevice findDeviceByCode(String code); public List findDeviceByAcu(String acucode); public List findDeviceByPositionAndType(String acucode, String devtype, String cabin); diff --git a/src/com/szpg/db/dao/PgJgDao.java b/src/com/szpg/db/dao/PgJgDao.java index 2192e88..fef9378 100644 --- a/src/com/szpg/db/dao/PgJgDao.java +++ b/src/com/szpg/db/dao/PgJgDao.java @@ -19,6 +19,7 @@ public List findStatByDeviceAndTm(Integer deviceid, String start, String end); public PgJgStat findLatestStatByDevice(Integer deviceid); - public int addSbjzRecord(PgJgStat jgstat); - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid); + public int addJgStatRecord(PgJgStat jgstat); + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid); + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/PgSbDao.java b/src/com/szpg/db/dao/PgSbDao.java index e3e16a6..1c65a7e 100644 --- a/src/com/szpg/db/dao/PgSbDao.java +++ b/src/com/szpg/db/dao/PgSbDao.java @@ -30,5 +30,6 @@ public int addStatRecord(PgSbStat sbstat); public int addStatRecord(boolean run1, boolean flt1, String tm, int deviceid); - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid); + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid); } diff --git a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java index 11de6ff..c7f4fd3 100644 --- a/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgAlarmDaoImpl.java @@ -2,9 +2,13 @@ import java.sql.Connection; import java.sql.SQLException; +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.commons.dbutils.handlers.BeanListHandler; import org.apache.commons.dbutils.handlers.ScalarHandler; import org.apache.log4j.Logger; @@ -44,6 +48,55 @@ } @Override + public PgAlarm findLatestAlarmByDevice(int deviceId) { + Connection conn = null; + String queryStr = "SELECT A.* FROM " + + "(SELECT ID, ACTIVE, ALARM_DATE, ALARM_VALUE, DESCRIPTION, ALARMDEVID, ALARMTYPEID FROM PG_ALARM WHERE ALARMDEVID = ? ORDER BY ALARM_DATE DESC) A " + + "WHERE ROWNUM <= 1"; + Object[] param = new Object[1]; + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + QueryRunner runner = new QueryRunner(); + param[0] = deviceId; + + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); + if (null != tempList && tempList.isEmpty() == false) { + PgAlarm alarm = new PgAlarm(); + Object[] item = tempList.get(0); + + alarm.setId(((Number) item[0]).intValue()); + alarm.setActive(((Number) item[1]).intValue()); + + long tmValue = ((java.sql.Timestamp) ((oracle.sql.TIMESTAMP) item[2]).toJdbc()).getTime(); + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(tmValue); + alarm.setAlarm_date(cal.getTime()); + + alarm.setAlarm_value((String) item[3]); + alarm.setDescription((String) item[4]); + alarm.setAlarmdevid(((Number) item[5]).intValue()); + alarm.setAlarmtypeid(((Number) item[6]).intValue()); + + logger.debug("根据设备查询最新报警记录成功"); + + return alarm; + } else { + return null; + } + } catch (Exception ex) { + logger.error("根据设备查询最新报警记录成功", ex); + return null; + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + + @Override public long insertAlarmRecord(PgAlarm alarmRecord) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java index eb9e1c1..9f23c70 100644 --- a/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgDeviceDaoImpl.java @@ -126,6 +126,39 @@ } @Override + public PgDevice findDeviceByCode(String code) { + Connection conn = null; + + String queryStr = "SELECT * FROM PG_DEVICE WHERE ASSETCODE = ?"; + Object[] params = new Object[1]; + params[0] = code; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + PgDevice device = (PgDevice) runner.query(conn, queryStr, new BeanHandler(PgDevice.class), params); + + if (null != device) { + logger.debug("根据code查询设备资产成功"); + + return device; + } else + return null; + } catch (Exception ex) { + logger.error("根据code查询设备资产异常", ex); + } finally { + try { + DbUtils.commitAndClose(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return null; + } + + @Override public List findDeviceByAcu(String acucode) { Connection conn = null; diff --git a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java index a923a0f..30cefbc 100644 --- a/src/com/szpg/db/dao/impl/PgJgDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgJgDaoImpl.java @@ -49,7 +49,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -97,7 +97,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据ID查询井盖状态成功" + stat + "]"); @@ -149,7 +149,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -203,7 +203,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); list.add(stat); } @@ -231,8 +231,11 @@ 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()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgJgStat stat = new PgJgStat(); @@ -248,7 +251,7 @@ stat.setUptime(cal.getTime()); stat.setJgopen((String) item[3]); - stat.setJglock(Boolean.parseBoolean((String) item[4])); + stat.setJglock(item[4] != null && item[4].equals("1") == true ? true: false); logger.debug("根据设备ID查询最新的井盖状态成功" + stat); return stat; @@ -268,12 +271,12 @@ } @Override - public int addSbjzRecord(PgJgStat jgstat) { - return addSbjzRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); + public int addJgStatRecord(PgJgStat jgstat) { + return addJgStatRecord(jgstat.getJgopen(), jgstat.getJglock(), jgstat.getTmStr(), jgstat.getPgdeviceid()); } @Override - public int addSbjzRecord(String open, boolean lock, String tm, int deviceid) { + public int addJgStatRecord(String open, boolean lock, String tm, int deviceid) { Connection conn = null; String insertStr = "INSERT INTO PG_JG_STAT " + @@ -311,4 +314,46 @@ return 0; } + @Override + public int updateJgStatRecord(String open, boolean lock, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_JG_STAT SET " + + "JGOPEN = ?, " + + "JGLOCK = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[5]; + params[0] = open; + params[1] = lock; + params[2] = tm; + params[3] = tm; + params[4] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新井盖状态成功[tm=" + tm + ", open=" + open + ", lock=" + lock + ", 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/dao/impl/PgSbDaoImpl.java b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java index 3de90f8..dbd9d63 100644 --- a/src/com/szpg/db/dao/impl/PgSbDaoImpl.java +++ b/src/com/szpg/db/dao/impl/PgSbDaoImpl.java @@ -32,7 +32,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbRt rt = new PgSbRt(); @@ -183,11 +183,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -233,11 +233,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵运行状态成功" + stat + "]"); @@ -287,11 +287,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -343,11 +343,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); list.add(stat); } @@ -379,7 +379,7 @@ conn.setAutoCommit(false); QueryRunner runner = new QueryRunner(); - List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler()); + List tempList = (List) runner.query(conn, queryStr, new ArrayListHandler(), param); if (null != tempList && tempList.isEmpty() == false) { PgSbStat stat = new PgSbStat(); @@ -393,11 +393,11 @@ cal.setTimeInMillis(tmValue); stat.setLogtime(cal.getTime()); stat.setUptime(cal.getTime()); - - stat.setRun1(Boolean.parseBoolean((String) item[3])); - stat.setRun2(Boolean.parseBoolean((String) item[4])); - stat.setFlt1(Boolean.parseBoolean((String) item[5])); - stat.setFlt2(Boolean.parseBoolean((String) item[6])); + + stat.setRun1(item[3] != null && item[3].equals("1") == true ? true: false); + stat.setRun2(item[4] != null && item[4].equals("1") == true ? true: false); + stat.setFlt1(item[5] != null && item[5].equals("1") == true ? true: false); + stat.setFlt2(item[6] != null && item[6].equals("1") == true ? true: false); logger.debug("根据ID查询水泵最新运行状态成功" + stat + "]"); @@ -498,11 +498,11 @@ } @Override - public int addStatRecord(boolean run1, boolean run2, boolean flt1, boolean flt2, String tm, int deviceid) { + public int addStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { Connection conn = null; - - String insertStr = "INSERT INTO PG_SB_STAT " + - "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + + + String insertStr = "INSERT INTO PG_SB_STAT " + + "(RUN1, RUN2, FLT1, FLT2, LOGTIME, UPTIME, PGDEVICEID) " + "VALUES (?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?)"; Object[] params = new Object[7]; params[0] = run1; @@ -538,4 +538,50 @@ return 0; } + @Override + public int updateStatRecord(Boolean run1, Boolean run2, Boolean flt1, Boolean flt2, String tm, int deviceid) { + Connection conn = null; + + String updateStr = "UPDATE PG_SB_STAT SET " + + "RUN1 = ?, " + + "RUN2 = ?, " + + "FLT1 = ?, " + + "FLT2 = ?, " + + "LOGTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), " + + "UPTIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') " + + "WHERE PGDEVICEID = ?"; + Object[] params = new Object[7]; + params[0] = run1; + params[1] = run2; + params[2] = flt1; + params[3] = flt2; + params[4] = tm; + params[5] = tm; + params[6] = deviceid; + + try { + conn = ConnectionManager.getConnectionFromC3P0(); + conn.setAutoCommit(false); + + QueryRunner runner = new QueryRunner(); + int count = runner.update(conn, updateStr, params); + + if (count > 0) + logger.debug("更新水泵运行状态成功[tm=" + tm + ", run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", 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/PgDevice.java b/src/com/szpg/db/data/PgDevice.java index eac3c52..f448205 100644 --- a/src/com/szpg/db/data/PgDevice.java +++ b/src/com/szpg/db/data/PgDevice.java @@ -15,7 +15,7 @@ private String devcode; // private String devtype; // private String ip; // - private Integer isopen; // + private String isopen; // private String modbus; // private String mod; private String partition; @@ -87,11 +87,11 @@ this.ip = ip; } - public Integer getIsopen() { + public String getIsopen() { return isopen; } - public void setIsopen(Integer isopen) { + public void setIsopen(String isopen) { this.isopen = isopen; } diff --git a/src/com/szpg/db/data/PgJgStat.java b/src/com/szpg/db/data/PgJgStat.java index 1be839c..d617ac8 100644 --- a/src/com/szpg/db/data/PgJgStat.java +++ b/src/com/szpg/db/data/PgJgStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 井盖状态数据表 @@ -97,4 +101,19 @@ public String toString() { return "PgJgStat[open=" + jgopen + ", lock=" + jglock + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("open", null != this.getJgopen() ? URLEncoder.encode(getJgopen(), "UTF-8") : ""); + json.put("lock", null != this.getJglock() && this.getJglock() == true ? URLEncoder.encode("井盖解锁", "UTF-8") : URLEncoder.encode("井盖锁定", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/db/data/PgSbStat.java b/src/com/szpg/db/data/PgSbStat.java index 1986965..6d7dbc2 100644 --- a/src/com/szpg/db/data/PgSbStat.java +++ b/src/com/szpg/db/data/PgSbStat.java @@ -1,8 +1,12 @@ package com.szpg.db.data; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import com.szpg.util.TimeFormat; +import z.json.JSONException; +import z.json.JSONObject; /** * 水泵运行状态数据表 @@ -115,4 +119,21 @@ public String toString() { return "PgSbStat[run=" + run1 + "/" + run2 + ", flt=" + flt1 + "/" + flt2 + ", logtime=" + TimeFormat.formatTimestamp(logtime) + "]"; } + + public JSONObject toJson() { + JSONObject json = new JSONObject(); + try { + json.put("time", this.getTmStr()); + json.put("run1", null != this.getRun1() && this.getRun1() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("run2", null != this.getRun2() && this.getRun2() == true ? URLEncoder.encode("水泵运行", "UTF-8") : URLEncoder.encode("水泵停止", "UTF-8")); + json.put("flt1", null != this.getFlt1() && this.getFlt1() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + json.put("flt2", null != this.getFlt2() && this.getFlt2() == true ? URLEncoder.encode("水泵故障", "UTF-8") : URLEncoder.encode("正常", "UTF-8")); + } catch (JSONException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return json; + } } diff --git a/src/com/szpg/plc/PGDSCServlet.java b/src/com/szpg/plc/PGDSCServlet.java index 881c2e3..8ea7aca 100644 --- a/src/com/szpg/plc/PGDSCServlet.java +++ b/src/com/szpg/plc/PGDSCServlet.java @@ -66,42 +66,42 @@ } // 3启动查询温湿度的定时任务 - sendQueryWSValueCommand(); - sendSetWSThresholdCommand(); +// sendQueryWSValueCommand(); +// sendSetWSThresholdCommand(); // 4启动查询甲烷的定时任务 - sendQueryCH4ValueCommand(); - sendSetCH4ThresholdCommand(); +// sendQueryCH4ValueCommand(); +// sendSetCH4ThresholdCommand(); // 5启动查询一氧化碳的定时任务 - sendQueryCOValueCommand(); - sendSetCOThresholdCommand(); +// sendQueryCOValueCommand(); +// sendSetCOThresholdCommand(); // 6氧气 - sendQueryO2ValueCommand(); - sendSetO2ThresholdCommand(); +// sendQueryO2ValueCommand(); +// sendSetO2ThresholdCommand(); // 7硫化氢 - sendQueryHSValueCommand(); - sendSetHSThresholdCommand(); +// sendQueryHSValueCommand(); +// sendSetHSThresholdCommand(); // 8对射报警 - sendQueryDSStatusCommand(); +// sendQueryDSStatusCommand(); // 9液位报警 - sendQueryYWStatusCommand(); +// sendQueryYWStatusCommand(); // 10风机状态 - sendQueryFJStatusCommand(); +// sendQueryFJStatusCommand(); // 11照明状态 - sendQueryZMStatusCommand(); +// sendQueryZMStatusCommand(); // 12水泵状态 - sendQuerySBStatusCommand(); +// sendQuerySBStatusCommand(); // 13井盖状态 - sendQueryJGStatusCommand(); +// sendQueryJGStatusCommand(); //10巡检数据同步 // synchAssetInSpection(); diff --git a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java index 49396dc..a91d0e8 100644 --- a/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadDSStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addDSAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段入侵报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java index 2d2b5a9..3190a32 100644 --- a/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadJgStatusCommandResponse.java @@ -2,8 +2,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import com.szpg.db.data.PgJgStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -93,8 +95,15 @@ int id = deviceDao.findDeviceIdByCode(zcbh); if (id > 0) { - jgDao.addSbjzRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); deviceDao.updateDeviceStatus(id, jgzt.get(i)); + + // 更新风机状态现状表 + PgJgStat temp = jgDao.findLatestStatByDevice(id); + if (null == temp) { + jgDao.addJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), id); + } else { + jgDao.updateJgStatRecord(jgzt.get(i), jgsd.get(i), TimeFormat.formatTimestamp(Calendar.getInstance().getTime()), id); + } } } } diff --git a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java index cf5c600..a3289ea 100644 --- a/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadSbStatCommandResponse.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; +import com.szpg.db.data.PgSbStat; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -112,6 +113,14 @@ deviceDao.updateDeviceStatus(deviceId, sb1Run.get(i) | sb2Run.get(i) == true ? "水泵运行" : "水泵停止"); } } + + // 更新水泵状态现状表 + PgSbStat temp = sbDao.findLatestStatByDevice(deviceId); + if (null == temp) { + sbDao.addStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } else { + sbDao.updateStatRecord(sb1Run.get(i), sb2Run.get(i), sb1Flt.get(i), sb2Flt.get(i), TimeFormat.formatTimestamp(this.getTime().getTime()), deviceId); + } // 如果单泵或者双泵有任意一个故障则都报警 if ((null != sb1Flt.get(i) && sb1Flt.get(i) == true) || (null != sb2Flt.get(i) && sb2Flt.get(i) == true)) { diff --git a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java index e95137a..b21b453 100644 --- a/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java +++ b/src/com/szpg/plc/message/response/read/ReadYWStatusCommandResponse.java @@ -86,6 +86,8 @@ String bjsj = date.replace("-", ""); String dsbjResp = DataPushInterface.addYWAlarmData(bjbh, zcbh, bjms, bjsj); logger.info("同步舱段液位爆管报警记录日志结果:" + dsbjResp); + } else { + deviceDao.updateDeviceStatus(deviceId, "正常"); } } } diff --git a/src/com/szpg/rmi/PgInterface.java b/src/com/szpg/rmi/PgInterface.java index 0c4840a..9a63462 100644 --- a/src/com/szpg/rmi/PgInterface.java +++ b/src/com/szpg/rmi/PgInterface.java @@ -77,7 +77,7 @@ // 跨域查询接口 String baseURL = Configure.getProperty("sys", "PGINTERFACE_API_URL"); - String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDevice", params); + String response = HttpRequest.sendPostByHttp(baseURL + "pgDevice/getPgDev", params); JSONObject jsonObject = new JSONObject(response); JSONArray jArray = jsonObject.getJSONArray("result"); diff --git a/src/com/szpg/rmi/RemoteDSCommandAction.java b/src/com/szpg/rmi/RemoteDSCommandAction.java index d48bae7..a4abdce 100644 --- a/src/com/szpg/rmi/RemoteDSCommandAction.java +++ b/src/com/szpg/rmi/RemoteDSCommandAction.java @@ -1,5 +1,12 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgAlarmDao; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.impl.PgAlarmDaoImpl; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.data.PgAlarm; +import com.szpg.db.data.PgDevice; +import com.szpg.util.TimeFormat; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -25,6 +32,9 @@ import z.json.JSONObject; +import java.net.URLEncoder; +import java.util.Calendar; + public class RemoteDSCommandAction extends ActionSupport { /** @@ -241,6 +251,33 @@ return null; } } + + + public String readDsStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgAlarmDao alarmDao = new PgAlarmDaoImpl(); + PgDevice device = deviceDao.findDeviceByCode(zcbh); + if (null != device) { + JSONObject obj = new JSONObject(); + if (null != device.getIsopen() && device.getIsopen().indexOf("入侵") > 0) { + PgAlarm alarm = alarmDao.findLatestAlarmByDevice(device.getId()); + if (null != alarm) { + obj.put("alm", null != alarm.getDescription() ? URLEncoder.encode(alarm.getDescription(), "UTF-8") : ""); + obj.put("time", TimeFormat.formatTimestamp(alarm.getAlarm_date())); + } + } else { + obj.put("alm", URLEncoder.encode("正常", "UTF-8")); + obj.put("time", TimeFormat.formatTimestamp(Calendar.getInstance().getTime())); + } + jResult.put("dsStat", obj); + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/src/com/szpg/rmi/RemoteJGCommandAction.java b/src/com/szpg/rmi/RemoteJGCommandAction.java index 4bb1148..d5c8cec 100644 --- a/src/com/szpg/rmi/RemoteJGCommandAction.java +++ b/src/com/szpg/rmi/RemoteJGCommandAction.java @@ -1,5 +1,10 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.PgJgDao; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.dao.impl.PgJgDaoImpl; +import com.szpg.db.data.PgJgStat; import com.szpg.plc.message.command.write.SetJgLockBitCommand; import com.szpg.plc.message.command.write.SetJgOffBitCommand; import com.szpg.plc.message.command.write.SetJgOnBitCommand; @@ -459,7 +464,26 @@ return null; } } - + + + public String readJgStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgJgDao jgDao = new PgJgDaoImpl(); + + int deviceId = deviceDao.findDeviceIdByCode(zcbh); + if (deviceId > 0) { + PgJgStat jgStat = jgDao.findLatestStatByDevice(deviceId); + if (null != jgStat) { + jResult.put("jgStat", jgStat.toJson()); + } + } + + returnToFront(jResult); + return null; + } /** * 给前端返回 diff --git a/src/com/szpg/rmi/RemoteSBCommandAction.java b/src/com/szpg/rmi/RemoteSBCommandAction.java index 9d090ef..0faf4fe 100644 --- a/src/com/szpg/rmi/RemoteSBCommandAction.java +++ b/src/com/szpg/rmi/RemoteSBCommandAction.java @@ -1,5 +1,10 @@ package com.szpg.rmi; +import com.szpg.db.dao.PgDeviceDao; +import com.szpg.db.dao.PgSbDao; +import com.szpg.db.dao.impl.PgDeviceDaoImpl; +import com.szpg.db.dao.impl.PgSbDaoImpl; +import com.szpg.db.data.PgSbStat; import org.apache.log4j.Logger; import org.apache.struts2.ServletActionContext; @@ -145,6 +150,25 @@ return null; } } + + public String readSbStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgSbDao sbDao = new PgSbDaoImpl(); + + int deviceId = deviceDao.findDeviceIdByCode(zcbh); + if (deviceId > 0) { + PgSbStat sbStat = sbDao.findLatestStatByDevice(deviceId); + if (null != sbStat) { + jResult.put("sbStat", sbStat.toJson()); + } + } + + returnToFront(jResult); + return null; + } /** diff --git a/src/com/szpg/rmi/RemoteYWCommandAction.java b/src/com/szpg/rmi/RemoteYWCommandAction.java new file mode 100644 index 0000000..bbc0037 --- /dev/null +++ b/src/com/szpg/rmi/RemoteYWCommandAction.java @@ -0,0 +1,177 @@ +package com.szpg.rmi; + +import com.opensymphony.xwork2.ActionSupport; +import com.szpg.db.dao.*; +import com.szpg.db.dao.impl.*; +import com.szpg.db.data.PgAcu; +import com.szpg.db.data.PgAlarm; +import com.szpg.db.data.PgDevice; +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.ReadControllerStatusService; +import com.szpg.util.Configure; +import com.szpg.util.TimeFormat; +import com.szpg.util.UnicodeConvertor; +import org.apache.log4j.Logger; +import org.apache.struts2.ServletActionContext; +import z.json.JSONObject; + +import java.net.URLEncoder; +import java.util.Calendar; + +public class RemoteYWCommandAction extends ActionSupport { + + /** + * + */ + private static final long serialVersionUID = 2221187086461756012L; + + private String zcbh; + + private String format; + private String jsoncallback; + + private Logger logger = Logger.getLogger(this.getClass().getName()); + + public String getZcbh() { + return zcbh; + } + + public void setZcbh(String zcbh) { + this.zcbh = zcbh; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getJsoncallback() { + return jsoncallback; + } + + public void setJsoncallback(String jsoncallback) { + this.jsoncallback = jsoncallback; + } + + /** + * 读取爆管液位实时状态 + * @return + * @throws Exception + */ + public String readYwStatus() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgAcuDao acuDao = new PgAcuDaoImpl(); + + if (null == zcbh || zcbh.equals("") == true) { + jResult.put("success", false); + jResult.put("code", "1"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("资产编号为空")); + + returnToFront(jResult); + return null; + } + + String acucode = zcbh.substring(0, zcbh.indexOf(".", 6)); + PgAcu acu = acuDao.findACUByCode(acucode); + if (null == acu) { + jResult.put("success", false); + jResult.put("code", "2"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("未找到资产对应的PLC主机")); + + returnToFront(jResult); + return null; + } + + ACUClient client = ACUClientUtil.getInstance().getClients().get(acu.getAcu_host() + ":" + acu.getAcu_port()); + if (null != client) { + ReadMemoryCommand command = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READYWSTATUS); + String sour = Configure.getProperty("sys", "LOCALHOST.NET") + + Configure.getProperty("sys", "LOCALHOST.NODE") + + Configure.getProperty("sys", "LOCALHOST.UNIT"); + command.setMessageProducerId(sour); + command.setMessageProducerHost(client.getHost()); + + 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() + ".YWALM.START")), 2)) + "00"); + command.setCountWord(Integer.parseInt(Configure.getProperty("acubl", client.getAcucode() + ".YWALM.WORDCOUNT"))); + + // 调用服务过程执行命令发送服务 + ReadControllerStatusService service = new ReadControllerStatusService(); + service.executeService(client, command); + logger.info(command); + } catch (Exception ex) { + logger.error("发送查询爆管液位指令异常" + ex); + } + + jResult.put("success", true); + jResult.put("resaon", UnicodeConvertor.string2Unicode("发送成功,请等待响应")); + + returnToFront(jResult); + return null; + } else { + jResult.put("success", false); + jResult.put("code", "3"); + jResult.put("resaon", UnicodeConvertor.string2Unicode("PLC主机不在线")); + + returnToFront(jResult); + return null; + } + } + + public String readYwStatusFromDB() throws Exception { + // 返回结果 + JSONObject jResult = new JSONObject(); + + PgDeviceDao deviceDao = new PgDeviceDaoImpl(); + PgAlarmDao alarmDao = new PgAlarmDaoImpl(); + PgDevice device = deviceDao.findDeviceByCode(zcbh); + if (null != device) { + JSONObject obj = new JSONObject(); + if (null != device.getIsopen() && device.getIsopen().indexOf("爆管") > 0) { + PgAlarm alarm = alarmDao.findLatestAlarmByDevice(device.getId()); + if (null != alarm) { + obj.put("alm", null != alarm.getDescription() ? URLEncoder.encode(alarm.getDescription(), "UTF-8") : ""); + obj.put("time", TimeFormat.formatTimestamp(alarm.getAlarm_date())); + } + } else { + obj.put("alm", URLEncoder.encode("正常", "UTF-8")); + obj.put("time", TimeFormat.formatTimestamp(Calendar.getInstance().getTime())); + } + jResult.put("ywStat", obj); + } + + returnToFront(jResult); + return null; + } + + /** + * 给前端返回 + * @param jResult + * @throws Exception + */ + private void returnToFront(JSONObject jResult) throws Exception { + // 返回jsonp格式的数据 + if (null != format && format.equalsIgnoreCase("jsonp") == true) { + ServletActionContext.getResponse().getWriter().write(jsoncallback + "(" + jResult.toString() + ");"); + } + + ServletActionContext.getResponse().getWriter().write(jResult.toString()); + } + +} diff --git a/src/struts.xml b/src/struts.xml index 63c4305..b7d9189 100644 --- a/src/struts.xml +++ b/src/struts.xml @@ -2,7 +2,6 @@ - @@ -39,6 +38,7 @@ + @@ -46,10 +46,16 @@ + + + + + +