11 changed files with 19 additions and 267 deletions
-
6.idea/compiler.xml
-
13.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_11_1.xml
-
13.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_11_1.xml
-
4.idea/xm-server.iml
-
8pom.xml
-
2xm-core/src/main/java/com/qqkj/xm/core/service/push/XmMenuPushMsgService.java
-
3xm-core/src/main/java/com/qqkj/xm/core/service/push/XmPushMsgService.java
-
68xm-core/src/main/java/com/qqkj/xm/push/service/CallBizService.java
-
161xm-core/src/main/java/com/qqkj/xm/push/service/PushMsgService.java
-
4xm-core/xm-core.iml
-
4xm-starter/xm-starter.iml
@ -1,13 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="Maven: org.apache.logging.log4j:log4j-api:2.11.1"> |
|
||||
<CLASSES> |
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-api/2.11.1/log4j-api-2.11.1.jar!/" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC> |
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-api/2.11.1/log4j-api-2.11.1-javadoc.jar!/" /> |
|
||||
</JAVADOC> |
|
||||
<SOURCES> |
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-api/2.11.1/log4j-api-2.11.1-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
||||
@ -1,13 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.1"> |
|
||||
<CLASSES> |
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-to-slf4j/2.11.1/log4j-to-slf4j-2.11.1.jar!/" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC> |
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-to-slf4j/2.11.1/log4j-to-slf4j-2.11.1-javadoc.jar!/" /> |
|
||||
</JAVADOC> |
|
||||
<SOURCES> |
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/logging/log4j/log4j-to-slf4j/2.11.1/log4j-to-slf4j-2.11.1-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
||||
@ -1,68 +0,0 @@ |
|||||
package com.qqkj.xm.push.service; |
|
||||
|
|
||||
import java.util.Map; |
|
||||
|
|
||||
import javax.annotation.PostConstruct; |
|
||||
|
|
||||
import org.apache.commons.logging.Log; |
|
||||
import org.apache.commons.logging.LogFactory; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.beans.factory.annotation.Value; |
|
||||
import org.springframework.http.ResponseEntity; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
import org.springframework.util.StringUtils; |
|
||||
|
|
||||
import com.qqkj.mdp.core.entity.Tips; |
|
||||
import com.qqkj.mdp.core.utils.BaseUtils; |
|
||||
import com.qqkj.mdp.safe.common.rest.MdpRestTemplate; |
|
||||
|
|
||||
@Service |
|
||||
public class CallBizService { |
|
||||
|
|
||||
@Value("${spring.profiles.active:dev}") |
|
||||
String profiles="dev"; |
|
||||
|
|
||||
@Autowired |
|
||||
MdpRestTemplate restTemplate; |
|
||||
|
|
||||
Log logger=LogFactory.getLog(CallBizService.class); |
|
||||
|
|
||||
@Value("${mdp.api-gate:http://gate}")//云环境下 |
|
||||
//@Value("${mdp.api-gate:https://www.qingqinkj.com/api/m1}") //本地调试 |
|
||||
String apiGate=""; |
|
||||
|
|
||||
|
|
||||
public Tips callApi(String restUrl,Map<String,Object> params){ |
|
||||
|
|
||||
Tips tips=new Tips("远程调用成功"); |
|
||||
if(!StringUtils.isEmpty(restUrl)) { |
|
||||
if(restUrl.indexOf("http")<0 && restUrl.indexOf("www")<0) { |
|
||||
restUrl=apiGate+restUrl; |
|
||||
} |
|
||||
} |
|
||||
ResponseEntity<Map> forEntity = restTemplate.postForEntity(restUrl, params,Map.class); |
|
||||
Map<String,Object> m = (Map<String,Object>)forEntity.getBody(); |
|
||||
tips= BaseUtils.mapToTips(m); |
|
||||
if(tips!=null) { |
|
||||
if(!tips.isOk()){ |
|
||||
logger.error(tips.toString()); |
|
||||
return tips; |
|
||||
}else { |
|
||||
//成功调用 |
|
||||
logger.info(tips.toString()); |
|
||||
} |
|
||||
}else { |
|
||||
tips=new Tips("后台未返回任何数据"); |
|
||||
} |
|
||||
return tips; |
|
||||
} |
|
||||
|
|
||||
@PostConstruct |
|
||||
void initApiGate(){ |
|
||||
if("dev".equals(this.profiles)) { |
|
||||
//this.apiGate="http://127.0.0.1:7080/workflow"; |
|
||||
this.apiGate="https://www.qingqinkj.com/api/m1"; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,161 +0,0 @@ |
|||||
package com.qqkj.xm.push.service; |
|
||||
|
|
||||
import java.util.ArrayList; |
|
||||
import java.util.HashMap; |
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
import java.util.concurrent.ExecutorService; |
|
||||
import java.util.concurrent.Executors; |
|
||||
import java.util.concurrent.SynchronousQueue; |
|
||||
import java.util.concurrent.ThreadPoolExecutor; |
|
||||
import java.util.concurrent.TimeUnit; |
|
||||
|
|
||||
import javax.annotation.PostConstruct; |
|
||||
|
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import com.qqkj.mdp.core.entity.Tips; |
|
||||
|
|
||||
@Service |
|
||||
public class PushMsgService { |
|
||||
|
|
||||
@Autowired |
|
||||
CallBizService callBizServie; |
|
||||
|
|
||||
private static ExecutorService pool; |
|
||||
|
|
||||
@PostConstruct |
|
||||
public void initPool(){ |
|
||||
//maximumPoolSize设置为2 ,拒绝策略为AbortPolic策略,直接抛出异常 |
|
||||
pool = new ThreadPoolExecutor(10, 20, 1000, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>(),Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy() ); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
public void pushPrichatMsgToIm(String branchId,String sendUserid,String sendUsername,String toUserid,String toUsername,String msg) { |
|
||||
Map<String,Object> map=new HashMap<>(); |
|
||||
map.put("toUserid", toUserid); |
|
||||
map.put("toUsername", toUsername); |
|
||||
map.put("sendUserid", sendUserid); |
|
||||
map.put("sendUsername", sendUsername); |
|
||||
|
|
||||
map.put("sendContent", msg); |
|
||||
map.put("store", "1"); |
|
||||
pool.execute(new Runnable() { |
|
||||
|
|
||||
@Override |
|
||||
public void run() { |
|
||||
try { |
|
||||
Tips tips=callBizServie.callApi("/im/im/push/publishPrichatMessage", map); |
|
||||
} catch (Exception e) { |
|
||||
// TODO Auto-generated catch block |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public void pushMsgToIm(Map<String,Object> message) { |
|
||||
|
|
||||
message.put("store", "1"); |
|
||||
//Tips tips=callBizServie.callApi("/im/im/push/publishMessage", message); |
|
||||
|
|
||||
pool.execute(new Runnable() { |
|
||||
|
|
||||
@Override |
|
||||
public void run() { |
|
||||
try { |
|
||||
Tips tips=callBizServie.callApi("/im/im/push/publishMessage", message); |
|
||||
} catch (Exception e) { |
|
||||
// TODO Auto-generated catch block |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
public void pushGroupMsg(String branchId,String groupId,String sendUserid,String sendUsername,String msg) { |
|
||||
Map<String,Object> message=new HashMap<>(); |
|
||||
message.put("groupId", groupId); |
|
||||
message.put("action", "newMessage"); |
|
||||
message.put("msgType", "group"); |
|
||||
message.put("branchId", branchId); |
|
||||
message.put("sendUserid", sendUserid); |
|
||||
message.put("sendUsername", sendUsername); |
|
||||
message.put("sendContent", msg); |
|
||||
message.put("store", "1"); |
|
||||
this.pushMsgToIm(message); |
|
||||
} |
|
||||
public void pushLeaveChannelGroupMsg(String branchId,String groupId,List<Map<String,Object>> users) { |
|
||||
Map<String,Object> map=new HashMap<>(); |
|
||||
map.put("groupId", groupId); |
|
||||
map.put("action", "leaveChannelGroup"); |
|
||||
map.put("msgType", "group"); |
|
||||
map.put("users",users); |
|
||||
map.put("branchId", branchId); |
|
||||
map.put("store", "1"); |
|
||||
this.pushMsgToIm(map); |
|
||||
} |
|
||||
public void pushJoinChannelGroupMsg(String branchId,String groupId,List<Map<String,Object>> users) { |
|
||||
Map<String,Object> map=new HashMap<>(); |
|
||||
map.put("groupId", groupId); |
|
||||
map.put("action", "joinChannelGroup"); |
|
||||
map.put("msgType", "group"); |
|
||||
map.put("users",users); |
|
||||
map.put("store", "1"); |
|
||||
map.put("branchId", branchId); |
|
||||
this.pushMsgToIm(map); |
|
||||
} |
|
||||
public void pushChannelGroupRemoveMsg(String branchId,String groupId) { |
|
||||
Map<String,Object> map=new HashMap<>(); |
|
||||
map.put("groupId", groupId); |
|
||||
map.put("action", "channelGroupRemove"); |
|
||||
map.put("msgType", "group"); |
|
||||
map.put("branchId", branchId); |
|
||||
map.put("store", "1"); |
|
||||
this.pushMsgToIm(map); |
|
||||
} |
|
||||
public void pushChannelGroupCreateMsg(String branchId,String bizPid,String bizId,String groupId,String groupName,String cuserid,String cusername,List<Map<String,Object>> users,String msg) { |
|
||||
Map<String,Object> map=new HashMap<>(); |
|
||||
map.put("groupId", groupId); |
|
||||
map.put("groupName", groupName); |
|
||||
map.put("categoryId", "common"); |
|
||||
map.put("users", users); |
|
||||
map.put("cuserid", cuserid); |
|
||||
map.put("cusername", cusername); |
|
||||
map.put("branchId", branchId); |
|
||||
map.put("bizPid", bizPid); |
|
||||
map.put("bizId", bizId); |
|
||||
map.put("action", "channelGroupCreate"); |
|
||||
map.put("sendContent", msg); |
|
||||
map.put("msgType", "group"); |
|
||||
map.put("store", "1"); |
|
||||
this.pushMsgToIm(map); |
|
||||
} |
|
||||
public void pushChannelGroupCreateMsg(String branchId,String categoryId,String bizPid,String bizId,String groupId,String groupName,String cuserid,String cusername,List<Map<String,Object>> users,String msg) { |
|
||||
Map<String,Object> map=new HashMap<>(); |
|
||||
map.put("groupId", groupId); |
|
||||
map.put("groupName", groupName); |
|
||||
map.put("categoryId", categoryId); |
|
||||
|
|
||||
map.put("users", users); |
|
||||
map.put("cuserid", cuserid); |
|
||||
map.put("cusername", cusername); |
|
||||
map.put("branchId", branchId); |
|
||||
map.put("bizPid", bizPid); |
|
||||
map.put("bizId", bizId); |
|
||||
|
|
||||
map.put("sendContent", msg); |
|
||||
map.put("action", "channelGroupCreate"); |
|
||||
map.put("msgType", "group"); |
|
||||
map.put("store", "1"); |
|
||||
this.pushMsgToIm(map); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue