Browse Source

修复功能:1、pointread指令bug;2、down端口恢复支持read指令。

Jay Lee 6 years ago
parent
commit
43d190116e

+ 23 - 4
collect/src/main/java/com/saga/thread/common/CheckThread.java

@@ -111,8 +111,16 @@ public class CheckThread extends Thread {
 						String mac = pointUp.getKey().split("-")[1];
 						String point = pointUp.getKey().split("-")[2];
 						// System.out.println(point);
-						String meter = point.split("\\.")[0];
-						String funcid = point.split("\\.")[1];
+						String[] slist = point.split("\\.");
+						StringBuffer sb = new StringBuffer();
+						for (int i = 0; i < slist.length - 1; i++) {
+							if (i > 0) {
+								sb.append(".");
+							}
+							sb.append(slist[i]);
+						}
+						String meter = sb.toString();
+						String funcid = slist[slist.length - 1];
 						// System.out.println(meter);
 						// System.out.println(funcid);
 						String status = "";
@@ -162,11 +170,22 @@ public class CheckThread extends Thread {
 						while (it.hasNext()) {
 							try {
 								Entry<String, Long> n = it.next();
+
 								String building = Constant.id2point.get(n.getKey()).split("-")[0];
 								String mac = Constant.id2point.get(n.getKey()).split("-")[1];
 								String point = Constant.id2point.get(n.getKey()).split("-")[2];
-								String meter = point.split("\\.")[0];
-								String funcid = point.split("\\.")[1];
+
+								String[] slist = point.split("\\.");
+								StringBuffer sb = new StringBuffer();
+								for (int i = 0; i < slist.length - 1; i++) {
+									if (i > 0) {
+										sb.append(".");
+									}
+									sb.append(slist[i]);
+								}
+								String meter = sb.toString();
+								String funcid = slist[slist.length - 1];
+
 								// String function =
 								// Constant.id2function.get(n.getKey());
 

+ 73 - 93
collect/src/main/java/com/saga/thread/down/CollectThread.java

@@ -393,48 +393,34 @@ public class CollectThread extends Thread {
 
 						}
 						this.updateMeterCollectorControl(rList[0], meterList, p.address);
+					} else if (rList.length > 6 && "pointread".equalsIgnoreCase(rList[2])) {
+						// 1101070037;1;pointread;;123;1001;11
+						//String key = rList[0] + "-" + rList[1] + "-" + rList[5] + "." + rList[6];
+						//String id = rList[0] + "-" + rList[1] + "-" + rList[4];
+						// Constant.id2time.put(key,
+						// System.currentTimeMillis());
+						// Constant.id2point.put(id, key);
+						// Constant.id2function.put(id, "pointread");
+						// Constant.id2status.put(id, "processing:rcvd");
+
+						StringBuffer sb1 = new StringBuffer();
+						sb1 = this.getCacheData(rList);
+						server.AppendToSend(p.address, new Packet(sb1.toString()));
+						LogUtil.info(server.Name() + " AppendToSend: " + p.address + " " + sb.toString());
+					} else if (rList.length > 6 && "realtimepointdata".equalsIgnoreCase(rList[2])) {
+						//String key = rList[0] + "-" + rList[1] + "-" + rList[5] + "." + rList[6];
+						//String id = rList[0] + "-" + rList[1] + "-" + rList[4];
+						// Constant.id2time.put(key,
+						// System.currentTimeMillis());
+						// Constant.id2point.put(id, key);
+						// Constant.id2function.put(id, "realtimepointdata");
+						// Constant.id2status.put(id, "processing:rcvd");
+
+						StringBuffer sb1 = new StringBuffer();
+						sb1 = this.getCacheData2(rList);
+						server.AppendToSend(p.address, new Packet(sb1.toString()));
+						LogUtil.info(server.Name() + " AppendToSend: " + p.address + " " + sb.toString());
 					}
-					// else if (rList.length > 6 &&
-					// "pointread".equalsIgnoreCase(rList[2])) {
-					// // 1101070037;1;pointread;;123;1001;11
-					// String key = rList[0] + "-" + rList[1] + "-" +
-					// rList[5] +
-					// "." + rList[6];
-					// String id = rList[0] + "-" + rList[1] + "-" +
-					// rList[4];
-					// Constant.id2time.put(key,
-					// System.currentTimeMillis());
-					// Constant.id2point.put(id, key);
-					// Constant.id2function.put(id, "pointread");
-					// Constant.id2status.put(id, "processing:rcvd");
-					//
-					// StringBuffer sb1 = new StringBuffer();
-					// sb1 = this.getCacheData(rList);
-					// server.AppendToSend(p.address, new
-					// Packet(sb1.toString()));
-					// LogUtil.info(server.Name() + " AppendToSend: " +
-					// p.address + " " + sb.toString());
-					// }
-					// else if (rList.length > 6 &&
-					// "realtimepointdata".equalsIgnoreCase(rList[2])) {
-					// String key = rList[0] + "-" + rList[1] + "-" +
-					// rList[5] +
-					// "." + rList[6];
-					// String id = rList[0] + "-" + rList[1] + "-" +
-					// rList[4];
-					// Constant.id2time.put(key,
-					// System.currentTimeMillis());
-					// Constant.id2point.put(id, key);
-					// Constant.id2function.put(id, "realtimepointdata");
-					// Constant.id2status.put(id, "processing:rcvd");
-					//
-					// StringBuffer sb1 = new StringBuffer();
-					// sb1 = this.getCacheData2(rList);
-					// server.AppendToSend(p.address, new
-					// Packet(sb1.toString()));
-					// LogUtil.info(server.Name() + " AppendToSend: " +
-					// p.address + " " + sb.toString());
-					// }
 				}
 				LogUtil.info("CollectThread Challenge Constant.CollectReportList release...");
 
@@ -749,59 +735,53 @@ public class CollectThread extends Thread {
 	// return true;
 	// }
 
-	// private StringBuffer getCacheData(String[] rList) {
-	// // TODO Auto-generated method stub
-	// Record record = new Record();
-	// StringBuffer sb = new StringBuffer();
-	// if (Constant.RecordAddress.get(rList[0] + "-" + rList[5] + "-" +
-	// rList[6]) != null) {
-	// int address = Constant.RecordAddress.get(rList[0] + "-" + rList[5] + "-"
-	// + rList[6]);
-	// record = Constant.RecordList.get(address);
-	// // Constant.info("get pointread by address !");
-	// } else {
-	// for (Record r : Constant.RecordList) {
-	// if (rList[0].equalsIgnoreCase(r.buildingSign) &&
-	// rList[5].equalsIgnoreCase(r.meterSign)
-	// && Integer.valueOf(rList[6]) == r.funcID) {
-	// record = r;
-	// // Constant.info("get pointread by for circle !");
-	// break;
-	// }
-	// }
-	// }
-	// sb.append(rList[0]).append(";").append(rList[1]).append(";").append("pointreadack").append(";")
-	// .append(Constant.format(record.receivetime)).append(";").append(rList[4]).append(";")
-	// .append(record.meterSign).append(";").append(record.funcID).append(";").append(record.data).append(";");
-	// return sb;
-	// }
+	private StringBuffer getCacheData(String[] rList) {
+		// TODO Auto-generated method stub
+		Record record = new Record();
+		StringBuffer sb = new StringBuffer();
+		if (Constant.RecordAddress.get(rList[0] + "-" + rList[5] + "-" + rList[6]) != null) {
+			int address = Constant.RecordAddress.get(rList[0] + "-" + rList[5] + "-" + rList[6]);
+			record = Constant.RecordList.get(address);
+			// Constant.info("get pointread by address !");
+		} else {
+			for (Record r : Constant.RecordList) {
+				if (rList[0].equalsIgnoreCase(r.buildingSign) && rList[5].equalsIgnoreCase(r.meterSign)
+						&& Integer.valueOf(rList[6]) == r.funcID) {
+					record = r;
+					// Constant.info("get pointread by for circle !");
+					break;
+				}
+			}
+		}
+		sb.append(rList[0]).append(";").append(rList[1]).append(";").append("pointreadack").append(";")
+				.append(Constant.format(record.receivetime)).append(";").append(rList[4]).append(";")
+				.append(record.meterSign).append(";").append(record.funcID).append(";").append(record.data).append(";");
+		return sb;
+	}
 
-	// private StringBuffer getCacheData2(String[] rList) {
-	// // TODO Auto-generated method stub
-	// Record record = new Record();
-	// StringBuffer sb = new StringBuffer();
-	// if (Constant.RecordAddress.get(rList[0] + "-" + rList[5] + "-" +
-	// rList[6]) != null) {
-	// int address = Constant.RecordAddress.get(rList[0] + "-" + rList[5] + "-"
-	// + rList[6]);
-	// record = Constant.RecordList.get(address);
-	// // Constant.info("get pointread by address !");
-	// } else {
-	// for (Record r : Constant.RecordList) {
-	// if (rList[0].equalsIgnoreCase(r.buildingSign) &&
-	// rList[5].equalsIgnoreCase(r.meterSign)
-	// && Integer.valueOf(rList[6]) == r.funcID) {
-	// record = r;
-	// // Constant.info("get pointread by for circle !");
-	// break;
-	// }
-	// }
-	// }
-	// sb.append(rList[0]).append(";").append(rList[1]).append(";").append("realtimepointdataack").append(";")
-	// .append(Constant.format(record.receivetime)).append(";").append(rList[4]).append(";")
-	// .append(record.meterSign).append(";").append(record.funcID).append(";").append(record.data).append(";");
-	// return sb;
-	// }
+	private StringBuffer getCacheData2(String[] rList) {
+		// TODO Auto-generated method stub
+		Record record = new Record();
+		StringBuffer sb = new StringBuffer();
+		if (Constant.RecordAddress.get(rList[0] + "-" + rList[5] + "-" + rList[6]) != null) {
+			int address = Constant.RecordAddress.get(rList[0] + "-" + rList[5] + "-" + rList[6]);
+			record = Constant.RecordList.get(address);
+			// Constant.info("get pointread by address !");
+		} else {
+			for (Record r : Constant.RecordList) {
+				if (rList[0].equalsIgnoreCase(r.buildingSign) && rList[5].equalsIgnoreCase(r.meterSign)
+						&& Integer.valueOf(rList[6]) == r.funcID) {
+					record = r;
+					// Constant.info("get pointread by for circle !");
+					break;
+				}
+			}
+		}
+		sb.append(rList[0]).append(";").append(rList[1]).append(";").append("realtimepointdataack").append(";")
+				.append(Constant.format(record.receivetime)).append(";").append(rList[4]).append(";")
+				.append(record.meterSign).append(";").append(record.funcID).append(";").append(record.data).append(";");
+		return sb;
+	}
 	// private boolean needHandle(Date receivetime) {
 	// // TODO Auto-generated method stub
 	// try {

+ 1 - 1
collect/src/main/java/com/saga/thread/up/SendThread.java

@@ -198,7 +198,7 @@ public class SendThread extends Thread {
 
 			for (String result : resultArray) {
 				String[] rList = result.split(";");
-				if (rList.length > 7) {
+				if (rList.length > 6) {
 					String MAC = rList[1];
 
 					if (Constant.pointMAC.containsKey(rList[0] + "-" + rList[5])) {