Browse Source

过滤掉无需发送的消息

yh 2 years ago
parent
commit
a728b1b3bf

+ 9 - 5
bpm-core/src/main/java/com/srm/bpm/logic/service/impl/PushMsgLogicImpl.java

@@ -12,11 +12,13 @@
12
 
12
 
13
 package com.srm.bpm.logic.service.impl;
13
 package com.srm.bpm.logic.service.impl;
14
 
14
 
15
+import java.util.Collections;
15
 import java.util.List;
16
 import java.util.List;
16
 import java.util.stream.Collectors;
17
 import java.util.stream.Collectors;
17
 
18
 
18
 import org.springframework.http.ResponseEntity;
19
 import org.springframework.http.ResponseEntity;
19
 import org.springframework.stereotype.Service;
20
 import org.springframework.stereotype.Service;
21
+import org.springframework.util.CollectionUtils;
20
 
22
 
21
 import com.alibaba.fastjson.JSON;
23
 import com.alibaba.fastjson.JSON;
22
 import com.alibaba.fastjson.JSONObject;
24
 import com.alibaba.fastjson.JSONObject;
@@ -39,11 +41,13 @@ public class PushMsgLogicImpl implements PushMsgLogic {
39
 	@Override
41
 	@Override
40
 	public void push(List<FlowMsgDTO> allMsg) {
42
 	public void push(List<FlowMsgDTO> allMsg) {
41
 		allMsg = allMsg.stream().filter(e->(e.getPush() != null && !e.getPush().equals(""))).collect(Collectors.toList());
43
 		allMsg = allMsg.stream().filter(e->(e.getPush() != null && !e.getPush().equals(""))).collect(Collectors.toList());
42
-		JSONObject data = new JSONObject();
43
-		data.put("msg", JSON.toJSON(allMsg));
44
-		log.info("回调返回的数据:{}", allMsg);
45
-		final ResponseEntity<R> post = restTemplateUtil.post(bpmConfig.getPushmsgUrl(), data, "1");
46
-		log.info("回调返回的数据:{}", post);
44
+		if(!CollectionUtils.isEmpty(allMsg)) {
45
+			JSONObject data = new JSONObject();
46
+			data.put("msg", JSON.toJSON(allMsg));
47
+			log.info("回调返回的数据:{}", allMsg);
48
+			final ResponseEntity<R> post = restTemplateUtil.post(bpmConfig.getPushmsgUrl(), data, "1");
49
+			log.info("回调返回的数据:{}", post);
50
+		}
47
 	}
51
 	}
48
 }
52
 }
49
 
53