| 
					
				 | 
			
			
				@@ -1,7 +1,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.flow.job; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.flow.entity.Notify; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.flow.entity.User; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.flow.mapstruct.NotifyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.flow.mapstruct.UserRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dm.jdbc.filter.stat.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -13,11 +15,12 @@ import org.springframework.web.client.RestTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.format.DateTimeFormatter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Collections; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.regex.Matcher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.regex.Pattern; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -63,16 +66,6 @@ public class SendUskyJob { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("执行消息同步定时任务,结束时间:" + endTime.format(FORMATTER)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 查询未发送的消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public List<Notify> unSendUsky(LocalDateTime startTime, LocalDateTime endTime) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String sql = "SELECT * FROM sys_notify WHERE is_send_usky = 0 AND receiving_time BETWEEN ? AND ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return jdbcTemplate.query( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                sql, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                new Object[]{startTime, endTime}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                new NotifyRowMapper() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // 发送消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Async 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void sendUsky(List<Notify> unSend) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -94,15 +87,22 @@ public class SendUskyJob { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<String> userNames = unSend.stream().map(Notify::getSender).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, String> userNamesMap = unSendUser(userNames).stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .collect(Collectors.toMap(User::getUsername, User::getName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             JSONObject sendJson = new JSONObject() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .put("infoTypeName", "OA审批") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .put("infoType", 3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .put("infoTitle", send.getSender() + send.getSubject()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .put("infoContent", extractContentInBrackets(send.getContent())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .put("infoTitle", "OA审批") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .put("infoContent", userNamesMap.get(send.getSender()) + send.getSubject()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .put("userName", send.getSender()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .put("userNames", Collections.singletonList(send.getReceiver())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .put("id", send.getId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .put("approvalResult", approvalResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .put("approvalResult", approvalResult) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .put("processName", send.getSubject()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .put("approvalNode", extractContentInBrackets(send.getContent())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .put("realName", userNamesMap.get(send.getSender())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String sendJsonString = sendJson.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             log.info("准备发送 {} 的消息:{} ", send.getSender(), sendJsonString); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -120,6 +120,26 @@ public class SendUskyJob { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("消息发送完成,成功数量:" + successCount + ",失败数量:" + failCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 查询未发送的消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<Notify> unSendUsky(LocalDateTime startTime, LocalDateTime endTime) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String sql = "SELECT * FROM sys_notify WHERE is_send_usky = 0 AND receiving_time BETWEEN ? AND ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return jdbcTemplate.query( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                sql, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Object[]{startTime, endTime}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new NotifyRowMapper() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 查询未发送消息的用户名与真实姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<User> unSendUser(List<String> userNames) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String sql = "SELECT username, name FROM sys_user WHERE username IN ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return jdbcTemplate.query( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                sql, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Object[]{userNames}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new UserRowMapper() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // 更新已发送消息同步状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void updateNotify(List<Notify> unSend) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (Notify send : unSend) { 
			 |