XMTT 6 ans auparavant
Parent
commit
2253f3f4e7

+ 2 - 2
src/main/java/com/ekexiu/project/bridge/envdata/EnvDataDao.java

93
    @QueryList
93
    @QueryList
94
    @From(EnvTransducer.class)
94
    @From(EnvTransducer.class)
95
    @Select(EnvTransducer.class)
95
    @Select(EnvTransducer.class)
96
    List<EnvTranNew> queryByServer(Connection con,@Nullable Boolean active, @In String[] serverId) throws SQLException;
96
    List<EnvTranLastValue> queryByServer(Connection con, @Nullable Boolean active, @In String[] serverId) throws SQLException;
97
97
98
98
99
    @PageSelect
99
    @PageSelect
102
102
103
    @PageSelect
103
    @PageSelect
104
    @OrderBy("ORDER BY CODE")
104
    @OrderBy("ORDER BY CODE")
105
    PageQueryResult<EnvTransducer> pageQuery(Connection con, @Nullable Boolean active, @Nullable @SqlColumn(handlerClass = StringHandler.class, value = {"ENV_SERVER_ID IN (SELECT ID FROM ENV_SERVER WHERE CODE LIKE ?)"}) String serverCode, @Nullable @GroupSqlColumn(handlerClass = StringHandler.class,value = {"ENV_SERVER_ID IN (SELECT ID FROM ENV_SERVER WHERE BRIDGE_ID IN {SELECT ID FROM BRIDGE WHERE SHORT_NAME LIKE ?})"}) String bridgeName,@Nullable String system, @Nullable Integer deviceId, int pageSize, int pageNo) throws SQLException;
105
    PageQueryResult<EnvTransducer> pageQuery(Connection con, @Nullable Boolean active, @Nullable @SqlColumn(handlerClass = StringHandler.class, value = {"ENV_SERVER_ID IN (SELECT ID FROM ENV_SERVER WHERE CODE LIKE ?)"}) String serverCode, @Nullable @GroupSqlColumn(handlerClass = StringHandler.class,value = {"ENV_SERVER_ID IN (SELECT ID FROM ENV_SERVER WHERE BRIDGE_ID IN {SELECT ID FROM BRIDGE WHERE SHORT_NAME LIKE ?})"}) String bridgeName,@Nullable String system, @Nullable Integer code, int pageSize, int pageNo) throws SQLException;
106
106
107
    @SelectOne
107
    @SelectOne
108
    @Nullable
108
    @Nullable

+ 5 - 5
src/main/java/com/ekexiu/project/bridge/envdata/EnvDataService.java

126
126
127
    @Path("/transducer/pq")
127
    @Path("/transducer/pq")
128
    @Get
128
    @Get
129
    public PageQueryResult<EnvTransducer> pageQuery(@JdbcConn Connection con,@Nullable Boolean active,@Nullable String serverCode,@Nullable String bridgeName,@Nullable String system,@Nullable Integer deviceId,int pageSize,int pageNo)throws SQLException {
130
        return envDataDao.pageQuery(con, active, serverCode == null ? null : "%" + serverCode + "%", bridgeName == null ? null : "%" + bridgeName + "%", system, deviceId, pageSize, pageNo);
129
    public PageQueryResult<EnvTransducer> pageQuery(@JdbcConn Connection con,@Nullable Boolean active,@Nullable String serverCode,@Nullable String bridgeName,@Nullable String system,@Nullable Integer code,int pageSize,int pageNo)throws SQLException {
130
        return envDataDao.pageQuery(con, active, serverCode == null ? null : "%" + serverCode + "%", bridgeName == null ? null : "%" + bridgeName + "%", system, code, pageSize, pageNo);
131
    }
131
    }
132
132
133
    @Path("/server/qo")
133
    @Path("/server/qo")
154
            for (int i = 0; i < servers.size(); ++i) {
154
            for (int i = 0; i < servers.size(); ++i) {
155
                serverIds[i] = servers.get(i).getId();
155
                serverIds[i] = servers.get(i).getId();
156
            }
156
            }
157
            List<EnvTranNew> transducers = envDataDao.queryByServer(con, active, serverIds);
158
            for (EnvTranNew transducer : transducers) {
157
            List<EnvTranLastValue> transducers = envDataDao.queryByServer(con, active, serverIds);
158
            for (EnvTranLastValue transducer : transducers) {
159
                final int id = transducer.getSeq();
159
                final int id = transducer.getSeq();
160
                transducer.setValue(JdbcUtil.queryDouble(con, "select * from env_data WHERE item_id = ? ORDER BY create_time desc limit 1", new PreparedStatementConfig() {
160
                transducer.setLastValue(JdbcUtil.queryDouble(con, "select * from env_data WHERE item_id = ? ORDER BY create_time desc limit 1", new PreparedStatementConfig() {
161
                    @Override
161
                    @Override
162
                    public void config(PreparedStatement preparedStatement) throws SQLException {
162
                    public void config(PreparedStatement preparedStatement) throws SQLException {
163
                        preparedStatement.setInt(1,id);
163
                        preparedStatement.setInt(1,id);

+ 16 - 0
src/main/java/com/ekexiu/project/bridge/envdata/EnvTranLastValue.java

1
package com.ekexiu.project.bridge.envdata;
2
3
/**
4
 * Created by TT on 2019/3/19.
5
 */
6
public class EnvTranLastValue extends EnvTransducer {
7
    private Double lastValue;
8
9
    public Double getLastValue() {
10
        return lastValue;
11
    }
12
13
    public void setLastValue(Double lastValue) {
14
        this.lastValue = lastValue;
15
    }
16
}

+ 0 - 16
src/main/java/com/ekexiu/project/bridge/envdata/EnvTranNew.java

1
package com.ekexiu.project.bridge.envdata;
2
3
/**
4
 * Created by TT on 2019/3/19.
5
 */
6
public class EnvTranNew extends EnvTransducer {
7
    private Double value;
8
9
    public Double getValue() {
10
        return value;
11
    }
12
13
    public void setValue(Double value) {
14
        this.value = value;
15
    }
16
}

+ 5 - 5
src/main/java/com/ekexiu/project/bridge/envdata/EnvTransducer.java

17
    private String serverId;
17
    private String serverId;
18
    private String system;
18
    private String system;
19
    private int organize;
19
    private int organize;
20
    private int deviceId;
20
    private int code;
21
    private int seq;
21
    private int seq;
22
    private String name;
22
    private String name;
23
    private String position;
23
    private String position;
69
69
70
70
71
    @Column(descp = "传感器编号", value = DE.int_de)
71
    @Column(descp = "传感器编号", value = DE.int_de)
72
    public int getDeviceId() {
73
        return deviceId;
72
    public int getCode() {
73
        return code;
74
    }
74
    }
75
75
76
    public void setDeviceId(int deviceId) {
77
        this.deviceId = deviceId;
76
    public void setCode(int code) {
77
        this.code = code;
78
    }
78
    }
79
79
80
    @Column(descp = "内部编号", value = DE.int_de)
80
    @Column(descp = "内部编号", value = DE.int_de)

+ 1 - 1
src/main/java/com/ekexiu/project/bridge/servlet/AlarmDataServlet.java

219
								//String to = u.getEmail();
219
								//String to = u.getEmail();
220
								//try {
220
								//try {
221
								//	if (to != null && to.length() > 0) {
221
								//	if (to != null && to.length() > 0) {
222
								//		mailService.sendSimpleMail(to,  u.getName() + "您好:" + entry.getValue(), null, "桥梁临控报警");
222
								//		mailService.sendSimpleMail(to,  u.getName() + "您好:" + entry.getLastValue(), null, "桥梁临控报警");
223
								//	}
223
								//	}
224
								//} catch (Throwable thr) {
224
								//} catch (Throwable thr) {
225
								//}
225
								//}

+ 2 - 2
src/main/resources/database.sql

3779
        SERVER_ID TEXT NOT NULL,
3779
        SERVER_ID TEXT NOT NULL,
3780
        SYSTEM TEXT NOT NULL,
3780
        SYSTEM TEXT NOT NULL,
3781
        ORGANIZE INTEGER NOT NULL,
3781
        ORGANIZE INTEGER NOT NULL,
3782
        DEVICE_ID INTEGER NOT NULL,
3782
        CODE INTEGER NOT NULL,
3783
        SEQ INTEGER NOT NULL,
3783
        SEQ INTEGER NOT NULL,
3784
        NAME TEXT NOT NULL,
3784
        NAME TEXT NOT NULL,
3785
        POSITION TEXT NOT NULL,
3785
        POSITION TEXT NOT NULL,
3797
COMMENT ON COLUMN ENV_TRANSDUCER.SERVER_ID IS '所属服务器ID';
3797
COMMENT ON COLUMN ENV_TRANSDUCER.SERVER_ID IS '所属服务器ID';
3798
COMMENT ON COLUMN ENV_TRANSDUCER.SYSTEM IS '所属系统';
3798
COMMENT ON COLUMN ENV_TRANSDUCER.SYSTEM IS '所属系统';
3799
COMMENT ON COLUMN ENV_TRANSDUCER.ORGANIZE IS '所属组';
3799
COMMENT ON COLUMN ENV_TRANSDUCER.ORGANIZE IS '所属组';
3800
COMMENT ON COLUMN ENV_TRANSDUCER.DEVICE_ID IS '传感器编号';
3800
COMMENT ON COLUMN ENV_TRANSDUCER.CODE IS '传感器编号';
3801
COMMENT ON COLUMN ENV_TRANSDUCER.SEQ IS '内部编号';
3801
COMMENT ON COLUMN ENV_TRANSDUCER.SEQ IS '内部编号';
3802
COMMENT ON COLUMN ENV_TRANSDUCER.NAME IS '名称';
3802
COMMENT ON COLUMN ENV_TRANSDUCER.NAME IS '名称';
3803
COMMENT ON COLUMN ENV_TRANSDUCER.POSITION IS '所属方位';
3803
COMMENT ON COLUMN ENV_TRANSDUCER.POSITION IS '所属方位';