Kaynağa Gözat

支持按照功能号上报消息队列

fenghanchao 1 yıl önce
ebeveyn
işleme
2cc8b9ea9c

BIN
config.xls


+ 1 - 0
src/main/java/com/saga/thread/common/LoadConfigThread.java

@@ -665,6 +665,7 @@ public class LoadConfigThread extends Thread {
 					pty = Constant.toLower(pty);
 					Constant.activeMqBrokerUrl = rowData.get(pty.get("brokerurl"));
 					Constant.queueName = rowData.get(pty.get("queuename"));
+					Constant.reportFuncId = rowData.get(pty.get("reportfuncid"));
 				}
 			}
 		}

+ 22 - 5
src/main/java/com/saga/thread/common/SaveThread.java

@@ -1,15 +1,13 @@
 package com.saga.thread.common;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 import com.alibaba.fastjson.JSONObject;
 import com.saga.util.MessageUtil;
+import org.apache.commons.lang.StringUtils;
 import org.zillion.util.log.LogUtil;
 
 import com.saga.entity.Record;
@@ -242,7 +240,7 @@ public class SaveThread extends Thread {
 
 	private void sendMessage(Record record) {
 		executorService.execute(() -> {
-			if (Constant.activeMqPointSet.contains(record.buildingSign + "-" + record.meterSign + "-" + record.funcID)) {
+			if (isSendMessage(record)) {
 				try {
 					MessageUtil.sendMessage(JSONObject.toJSONString(record));
 				} catch (Exception e) {
@@ -252,6 +250,25 @@ public class SaveThread extends Thread {
 		});
 	}
 
+	private boolean isSendMessage(Record record) {
+		if (Constant.activeMqPointSet.contains(record.buildingSign + "-" + record.meterSign + "-" + record.funcID)) {
+			return true;
+		}
+		if (StringUtils.isBlank(Constant.reportFuncId)) {
+			return false;
+		}
+		String[] reportFunIds = Constant.reportFuncId.split(",");
+		for (String funcId : reportFunIds) {
+			if (StringUtils.isBlank(funcId)) {
+				continue;
+			}
+			if (Integer.valueOf(funcId).equals(record.funcID)) {
+				return true;
+			}
+		}
+		return false;
+	}
+
 	/**
 	 * ÊÇ·ñÐèÒª½ø¿â
 	 * 

+ 1 - 0
src/main/java/com/saga/util/Constant.java

@@ -115,6 +115,7 @@ public class Constant {
 
 	public static String activeMqBrokerUrl;
 	public static String queueName;
+	public static String reportFuncId;
 
 	public static Set<String> activeMqPointSet = new HashSet<>();