|
|
@@ -11,8 +11,6 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.db.sql.SqlExecutor;
|
|
|
import io.netty.bootstrap.ServerBootstrap;
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
@@ -86,20 +84,9 @@ class MyServerHandler extends ChannelInboundHandlerAdapter{
|
|
|
|
|
|
try {
|
|
|
if("getRemoteConf".equals(method)){
|
|
|
-
|
|
|
+ JSONObject params = jsonRequest.getJSONObject("params");
|
|
|
+ jsonString = handleRegist(params);
|
|
|
}
|
|
|
- JSONObject json = new JSONObject();
|
|
|
- json.put("code", 0);
|
|
|
- json.put("type", 0x15);
|
|
|
- json.put("hosnum", "123456");
|
|
|
- json.put("total", 50);
|
|
|
- json.put("limit", 4);
|
|
|
- json.put("add", 21);
|
|
|
- json.put("lock", 3);
|
|
|
- json.put("flow", 12);
|
|
|
- json.put("first", 3);
|
|
|
- jsonString = json.toString();
|
|
|
- //jsonString = handleRegist(msgStr);
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
// TODO: handle exception
|
|
|
@@ -114,6 +101,35 @@ class MyServerHandler extends ChannelInboundHandlerAdapter{
|
|
|
ctx.flush();
|
|
|
}
|
|
|
|
|
|
+ private String handleRegist(JSONObject jsonData) throws Exception{
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("code", 1);
|
|
|
+
|
|
|
+ String deviceName = jsonData.getString("devive");
|
|
|
+
|
|
|
+ Connection conn = ds.getConnection();
|
|
|
+ ResultSet resultSet = SqlExecutor.callQuery(conn, "select type,total_dose,first_dose,max_dose,append_dose,continue_dose,self_control_lock_time,patient_code from bus_device_configuration where device_id = ? limit 1", deviceName);
|
|
|
+ if(resultSet.next()){
|
|
|
+ json.put("code", 0);
|
|
|
+ json.put("hosnum", resultSet.getString("patient_code"));
|
|
|
+ json.put("total", resultSet.getInt("total_dose"));
|
|
|
+ json.put("limit", resultSet.getInt("max_dose"));
|
|
|
+ json.put("add", (int)(resultSet.getFloat("append_dose")*10));
|
|
|
+ json.put("lock", resultSet.getInt("self_control_lock_time"));
|
|
|
+ json.put("flow", (int)(resultSet.getFloat("continue_dose")*10));
|
|
|
+ json.put("first", resultSet.getInt("first_dose"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ if(!conn.getAutoCommit())
|
|
|
+ {
|
|
|
+ conn.commit();
|
|
|
+ }
|
|
|
+ */
|
|
|
+ conn.close();
|
|
|
+ return json.toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|