Ver Fonte

add:配置查询

wulianwei há 2 anos atrás
pai
commit
36f1d23ce0

+ 31 - 15
src/main/java/com/tuoren/remote/MyServer.java

@@ -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();
+	}
+	
 }
 	
 	

+ 2 - 2
src/main/resource/config/db.setting

@@ -1,7 +1,7 @@
 [dev]
-url = jdbc:mysql://47.101.214.91:7001/nbnetpump?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
+url = jdbc:mysql://192.168.100.32:3306/nbnetpump?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
 username = root
-password = Tuoren123.
+password = 123456
 ## 可选配置
 # 是否在日志中显示执行的SQL
 showSql = true