From b7e71faaec8e83386714b405f74d02b2f52c7755 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期一, 26 五月 2025 10:02:20 +0800
Subject: [PATCH] Merge branch 'master' of http://159.223.171.199:10439/r/Haier_MES_II

---
 nglib/src/druid.properties                  |    8 
 nglib/src/builder/HttpApi.java              |  224 +++++++++++++++++++++++++++++++++++++
 gmms/WebContent/bigScreen/peifangchaxun.jsp |   22 ++-
 nglib/bin/druid.properties                  |    8 
 nglib/src/ng/devices/MysqlService.java      |   65 ++++++----
 5 files changed, 282 insertions(+), 45 deletions(-)

diff --git a/gmms/WebContent/bigScreen/peifangchaxun.jsp b/gmms/WebContent/bigScreen/peifangchaxun.jsp
index 993a6e5..e00b190 100644
--- a/gmms/WebContent/bigScreen/peifangchaxun.jsp
+++ b/gmms/WebContent/bigScreen/peifangchaxun.jsp
@@ -55,31 +55,35 @@
 		</section>
 	
 	<div id = "allstatu" ></div>
-	   	<div id = "info" ></div>
+	   	<div id = "info" style="height:3%;" >
+	   		<input style="display:none" type="text" name="groups" value="${groups}" />
+	   	</div>
 		<!-- Main content -->
-			<input style="display:none" type="text" name="groups" value="${groups}" />
-		<section class="content container-fluid" style="padding: 0px;">
-			<div>		
-			</div>
 			
-			<div class="box" style="height: 600px; overflow: auto;margin-top: 10px;">
+		<section class="content container-fluid" style="padding: 0px;">
+			<div class="box" style="height:90%; overflow: auto;margin-top: 10px;">
 					<table class="table table-striped table-hover"
 						style="overflow-x: auto;font-size: 12px;">
-						<thead>
+						<thead style="font-size: 22px;font-weight: bold;">
 							<tr>
 								<th>璁惧ID</th>
 								<th>璁惧鍚嶇О</th>
 								<th>璁惧IP</th>
 								<th>褰撳墠閰嶆柟</th>
+								<th>褰撳墠閰嶆柟鏇存柊鏃堕棿</th>
+								<th>MES鍙戦�侀厤鏂�</th>
+								<th>MES鍙戦�侀厤鏂规洿鏂版椂闂�</th>
 							</tr>
 						</thead>
 						<tbody>
 							<tr v-for="(item, index) in shuzu" :key="index" style="height: 51px;">
 								<td>{{item['0_id']}}</td>
-								<td>{{item['1_machine_name']}}</td>
+								<td style="font-size: 18px;font-weight: bold;">{{item['1_machine_name']}}</td>
 								<td>{{item['2_ip_address']}}</td>
 								<td style="font-weight: bold; font-size: 18px">{{item['3_content_value']}}</td>
-
+								<td style="font-size: 18px">{{item['4_finsh_time']}}</td>
+								<td style="font-weight: bold; font-size: 18px">{{item['5_content_value2']}}</td>
+								<td style="font-size: 18px">{{item['6_finsh_time2']}}</td>
 								</td>
 							</tr>
 						</tbody>
diff --git a/nglib/bin/druid.properties b/nglib/bin/druid.properties
index faab9b5..4159041 100644
--- a/nglib/bin/druid.properties
+++ b/nglib/bin/druid.properties
@@ -3,9 +3,9 @@
 username=root
 password=beibo.123/
 
-#初始化时池中建立的物理连接个数
+#锟斤拷始锟斤拷时锟斤拷锟叫斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟接革拷锟斤拷
 initialSize=10
-#最大的可活跃的连接池数量
-maxActive=20
-#获取连接时最大等待时间,单位毫秒,超过连接就会失效
+#锟斤拷锟侥可伙拷跃锟斤拷锟斤拷锟接筹拷锟斤拷锟斤拷
+maxActive=50
+#锟斤拷取锟斤拷锟斤拷时锟斤拷锟饺达拷时锟戒,锟斤拷位锟斤拷锟诫,锟斤拷锟斤拷锟斤拷锟接就伙拷失效
 maxWait=3000
\ No newline at end of file
diff --git a/nglib/src/builder/HttpApi.java b/nglib/src/builder/HttpApi.java
new file mode 100644
index 0000000..3f9c72f
--- /dev/null
+++ b/nglib/src/builder/HttpApi.java
@@ -0,0 +1,224 @@
+package builder;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import ng.db.DBHelper;
+import ng.db.DBSession;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.sql.ResultSet;
+
+public class HttpApi {
+    public static String Ip="192.168.30.111";
+    public static void main(String[] args) {
+        JSONObject jsonObject=new JSONObject();
+        jsonObject.put("thickness", 4);
+        jsonObject.put("width", 3660);
+        jsonObject.put("height", 2440);
+        jsonObject.put("sameCount", 4);
+        jsonObject.put("glassType", "CFL");
+
+//        JSONObject C=shelfTaskApi(jsonObject);
+//        System.out.println(C);
+
+        JSONObject C2=thisShelfTaskApi();
+        System.out.println(C2);
+
+        //减少上片数量
+        //JSONObject b=loadRackReduction();
+
+        //查询上片位信息
+        JSONObject a=selectLoadRack();
+        if(a!=null){
+            double width=Double.valueOf(a.get("width").toString());
+            double height=Double.valueOf(a.get("height").toString());
+            double thickness=Double.valueOf(a.get("thickness").toString());
+            int sameCount=Integer.valueOf(a.get("sameCount").toString());
+            System.out.println(width+","+height+","+thickness+","+sameCount);
+        }
+
+    }
+    //发送仓储任务
+    public static boolean sendShelfTask(){
+        DBSession sn=null;
+        try{
+            //读取设备列表
+            DBHelper db=DBHelper.getDBHelper("mes");
+            sn=DBHelper.getDBHelper("mes").createSession(false);
+            sn.createSql("select o.id,o.largeglass_length,o.largeglass_width,o.largeglass_no,o.largeglass_completed,r.thickness,r.color\n" +
+                    "\t from `order` as o INNER JOIN recipe as r on o.recipe_no=r.id\n" +
+                    "\twhere o.order_status=2 LIMIT 0,1;");
+            ResultSet set= sn.query().getCurrentResult();
+            //查询结果
+            while(set.next()){
+                Integer id= Integer.valueOf(set.getString(1)) ;
+                double largeglass_length=set.getDouble(2);//订单原片长
+                double largeglass_width=set.getDouble(3);//订单原片宽
+                int largeglass_no=set.getInt(4);//订单原片任务数
+                int largeglass_completed=set.getInt(5);//订单原片完成数
+                int not_completed=largeglass_no-largeglass_completed;//订单原片未完成数
+
+                int thickness=set.getInt(6);//订单原片厚
+                String color=set.getString(7);//订单原片膜系
+                if(not_completed>0){  //有未完成的原片任务
+                    JSONObject thisShelfTask = HttpApi.thisShelfTaskApi();//查询仓储当前任务
+                    JSONObject jsonObject=new JSONObject();
+                    jsonObject.put("thickness", thickness);
+                    jsonObject.put("width", largeglass_length);
+                    jsonObject.put("height", largeglass_width);
+                    jsonObject.put("sameCount", not_completed);
+                    jsonObject.put("glassType", color);
+                    if (thisShelfTask != null) {
+                        double width_shelf = Double.valueOf(thisShelfTask.get("width").toString());
+                        double height_shelf = Double.valueOf(thisShelfTask.get("height").toString());
+                        int thickness_shelf = Integer.valueOf(thisShelfTask.get("thickness").toString());
+                        int sameCount_shelf = Integer.valueOf(thisShelfTask.get("sameCount").toString());
+                        String glassType_shelf = thisShelfTask.get("glassType").toString();
+                        if(largeglass_length!=width_shelf||largeglass_width!=height_shelf||thickness!=thickness_shelf||!color.equals(glassType_shelf)||sameCount_shelf==0){
+                            JSONObject shelfJosn=shelfTaskApi(jsonObject);
+                        }
+                        return true;
+                    }else{
+                        JSONObject shelfJosn=shelfTaskApi(jsonObject);
+                        return false;
+                    }
+                }
+
+            }
+        }
+        catch(Exception e){
+
+        }
+        finally{
+            if(sn!=null){
+                sn.close();
+            }
+        }
+        return false;
+    }
+    //发送仓储任务
+    public static JSONObject shelfTaskApi(JSONObject params){
+        try {
+            String requestURL="http://"+Ip+":5000/GlassInfo";
+            String requestBody =params.toString();
+            JSONObject resultJSON= httpApi(requestURL,"POST",requestBody);
+            return resultJSON;
+        } catch (Exception e) {
+            // TODO: handle exception
+            System.out.println("HTTP ERROR:http://39.105.110.179:5000/GlassInfo  POST");
+        }
+        return null;
+    }
+    //MES当前任务
+    public static JSONObject thisShelfTaskApi(){
+        try {
+            String requestURL="http://"+Ip+":5000/GlassInfo";
+            JSONObject resultJSON= httpApi(requestURL,"GET",null);
+            JSONArray jsonArray=resultJSON.getJSONArray("data");
+            if(jsonArray.size()>0){
+                JSONObject thisShelfJson=jsonArray.getJSONObject(0);
+                return thisShelfJson;
+            }
+            return null;
+        } catch (Exception e) {
+            // TODO: handle exception
+            System.out.println("HTTP ERROR:http://39.105.110.179:5000/GlassInfo  GET");
+        }
+        return null;
+    }
+    //查询上片位信息
+    public static JSONObject selectLoadRack(){
+        try {
+            String requestURL="http://"+Ip+":5000/GlassInfo/getReady";
+            JSONObject resultJSON= httpApi(requestURL,"GET",null);
+            JSONArray jsonArray=resultJSON.getJSONObject("data").getJSONArray("stocklist");
+            if(jsonArray.size()>0){
+                JSONObject loadRack=jsonArray.getJSONObject(0);
+                String isPackages=loadRack.get("packages").toString();
+                if("false".equals(isPackages) ){
+                    return loadRack;
+                }
+            }
+            return null;
+        } catch (Exception e) {
+            // TODO: handle exception
+            System.out.println("HTTP ERROR:http://"+Ip+":5000/GlassInfo GET");
+        }
+        return null;
+    }
+    //上片位玻璃-1
+    public static JSONObject loadRackReduction(){
+        try {
+            String requestURL="http://"+Ip+":5000/GlassInfo/finishGet";
+            JSONObject resultJSON= httpApi(requestURL,"GET",null);
+            return resultJSON;
+        } catch (Exception e) {
+            // TODO: handle exception
+            System.out.println("HTTP ERROR:http://"+Ip+":5000/GlassInfo/finishGet GET");
+        }
+        return null;
+    }
+    //库内玻璃信息查询
+    public static JSONObject storageRackInfo(){
+        try {
+            String requestURL="http://"+Ip+":5000/GlassInfo";
+            JSONObject resultJSON= httpApi(requestURL,"GET",null);
+            return resultJSON;
+        } catch (Exception e) {
+            // TODO: handle exception
+            System.out.println("HTTP ERROR:http://39.105.110.179:5000/GlassInfo GET");
+        }
+        return null;
+    }
+    public static JSONObject httpApi(String requestURL,String requestMethod,String requestBody){
+        JSONObject jsonObject = null;
+        try {
+            //"http://192.168.112:8081/deviceInteraction/account/selectAccount"
+            URL url = new URL(requestURL);
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestMethod(requestMethod);
+            connection.setDoOutput(true);
+            connection.setDoInput(true);  // 设置该连接可输入
+            connection.setDoOutput(true); // 设置该连接可输出
+            connection.setUseCaches(false);
+            connection.setInstanceFollowRedirects(true);
+            //connection.setRequestProperty("Charsert", "UTF-8");
+            connection.setRequestProperty("Content-type", "application/json; charset=UTF-8");
+            System.out.println(requestBody);
+            if(requestBody!=null){
+                try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
+                    byte requestBodyByte[]=requestBody.getBytes("UTF-8");
+                    outputStream.write(requestBodyByte);
+                    outputStream.flush();
+                }
+            }
+            int responseCode = connection.getResponseCode();
+            if (responseCode==200){
+                BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+                String line;
+                StringBuilder response = new StringBuilder();
+                while ((line = reader.readLine()) != null) {
+                    response.append(line);
+                }
+                reader.close();
+
+                String resultStr = response.toString();
+                if (resultStr!=null&&resultStr.length()>0) {
+                    jsonObject =JSONObject.parseObject(resultStr);
+                }
+                //System.out.println(jsonObject);
+            }else{
+                System.out.println("Response Code: " + responseCode);
+            }
+            connection.disconnect();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return jsonObject;
+    }
+}
diff --git a/nglib/src/druid.properties b/nglib/src/druid.properties
index faab9b5..4159041 100644
--- a/nglib/src/druid.properties
+++ b/nglib/src/druid.properties
@@ -3,9 +3,9 @@
 username=root
 password=beibo.123/
 
-#初始化时池中建立的物理连接个数
+#锟斤拷始锟斤拷时锟斤拷锟叫斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟接革拷锟斤拷
 initialSize=10
-#最大的可活跃的连接池数量
-maxActive=20
-#获取连接时最大等待时间,单位毫秒,超过连接就会失效
+#锟斤拷锟侥可伙拷跃锟斤拷锟斤拷锟接筹拷锟斤拷锟斤拷
+maxActive=50
+#锟斤拷取锟斤拷锟斤拷时锟斤拷锟饺达拷时锟戒,锟斤拷位锟斤拷锟诫,锟斤拷锟斤拷锟斤拷锟接就伙拷失效
 maxWait=3000
\ No newline at end of file
diff --git a/nglib/src/ng/devices/MysqlService.java b/nglib/src/ng/devices/MysqlService.java
index f94cb08..fb4ad57 100644
--- a/nglib/src/ng/devices/MysqlService.java
+++ b/nglib/src/ng/devices/MysqlService.java
@@ -97,7 +97,6 @@
 	    pack.Content=bb;
 	    return true;
 	}
-	
      //服务实现函数
 	@Override
 	protected boolean Service(ModbusDataPackage arg0, ModbusDataPackage arg1) {
@@ -114,42 +113,52 @@
 		//上片
 		if(id==2){
 			try{
+				//创建连接
+				sn=this.db.createSession(false);
+				Connection con= sn.getConnection();
 				JSONObject jSONObject=HttpApi.selectLoadRack();
+				boolean isSuccess=HttpApi.sendShelfTask();
 //				JSONObject jSONObject=new JSONObject();
 //				jSONObject.put("thickness", "4");
 //				jSONObject.put("width", "3660");
 //				jSONObject.put("height", "2440");
 //				jSONObject.put("sameCount", "1");
 //				jSONObject.put("glassType", "string");
+				double width_load = 0;
+				double height_load = 0;
+				double thickness_load = 0;
+				int sameCount_load = 0;
+				String glassType="";
 				if (jSONObject!=null){
-					//创建连接
-					sn=this.db.createSession(false);
-					Connection con= sn.getConnection();
-					//调用那个存储过程
-					CallableStatement sql=con.prepareCall("{call Total_method_load(?,?,?,?,?,?,?,?)}");
-					sql.registerOutParameter(7, java.sql.Types.VARCHAR);
-					sql.registerOutParameter(8, java.sql.Types.VARCHAR);
-					sql.setString(1, s);
-					sql.setLong(2, id);
-					sql.setDouble(3, Double.valueOf(jSONObject.get("width").toString()) );
-					sql.setDouble(4, Double.valueOf(jSONObject.get("height").toString()) );
-					sql.setDouble(5, Double.valueOf(jSONObject.get("thickness").toString()) );
-					sql.setLong(6, Integer.valueOf(jSONObject.get("sameCount").toString()) );
-					sql.execute();
-					//读取返回参数
-					result= sql.getString(7);
-					flag= sql.getString(8);//1 表示任务完成数量减一
-					if ("1".equals(flag) ){
-						for (int i=0;i<1;){
-							JSONObject loadRackReductionJson=HttpApi.loadRackReduction();
-							if ("true".equals(loadRackReductionJson.get("success").toString())){
-								//调用成功
-								i++;
-								break;
-							}
-						}
+					width_load = Double.valueOf(jSONObject.get("width").toString());
+					height_load = Double.valueOf(jSONObject.get("height").toString());
+					thickness_load = Double.valueOf(jSONObject.get("thickness").toString());
+					sameCount_load = Integer.valueOf(jSONObject.get("sameCount").toString());
+					glassType =jSONObject.get("glassType").toString();
+				}
+				//System.out.println(width_load+","+height_load+","+thickness_load+","+sameCount_load+","+glassType);
+				//调用那个存储过程
+				CallableStatement sql=con.prepareCall("{call Total_method_load(?,?,?,?,?,?,?,?,?)}");
+				sql.registerOutParameter(8, java.sql.Types.VARCHAR);
+				sql.registerOutParameter(9, java.sql.Types.VARCHAR);
+				sql.setString(1, s);
+				sql.setLong(2, id);
+				sql.setDouble(3, width_load );
+				sql.setDouble(4, height_load );
+				sql.setDouble(5, thickness_load );
+				sql.setLong(6, sameCount_load );
+				sql.setString(7, glassType );
+				sql.execute();
+				//读取返回参数
+				//System.out.println("result:"+result);
+				result= sql.getString(8);
+				flag= sql.getString(9);//1 表示任务完成数量减一
+				if ("1".equals(flag) ){
+					//减少上片数量
+					JSONObject b=HttpApi.loadRackReduction();
 
-					}
+				}else if("3".equals(flag) ){
+
 				}
 			}catch(Exception e){
 				e.printStackTrace();

--
Gitblit v1.8.0