liupeng 5 år sedan
förälder
incheckning
3831a52f0a

+ 25 - 0
code/sapparent/sapservice/src/main/java/org/fouram/core/plugin/weixin/cp/core/WXCpMessage.java

@@ -0,0 +1,25 @@
+package org.fouram.core.plugin.weixin.cp.core;
+
+import org.fouram.core.util.ConfConfig;
+
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
+
+/**
+ * 企业微信工具类
+ * 
+ * @author Liup
+ */
+public class WXCpMessage {
+	
+	public static final WxCpService service = new WxCpServiceImpl();
+	static {
+		WxCpDefaultConfigImpl configStorage = new WxCpDefaultConfigImpl();
+		configStorage.setCorpId(ConfConfig.getConfigString("wxCp.corpId"));
+		configStorage.setCorpSecret(ConfConfig.getConfigString("wxCp.massage.secret"));
+		configStorage.setAgentId(ConfConfig.getConfigInteger("wxCp.massage.agentId"));
+		// 初始化基础service
+		service.setWxCpConfigStorage(configStorage);
+	}
+}

+ 35 - 0
code/sapparent/sapservice/src/main/java/org/fouram/core/plugin/weixin/cp/util/WXCpMessageUtil.java

@@ -0,0 +1,35 @@
+package org.fouram.core.plugin.weixin.cp.util;
+
+import org.fouram.core.plugin.weixin.cp.core.WXCpMessage;
+import org.fouram.core.util.ConfConfig;
+import org.fouram.core.util.LoggerUtil;
+
+import me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.bean.WxCpMessage;
+import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
+
+/**
+ * 企业微信用户工具类
+ * 
+ * @author Liup
+ */
+public class WXCpMessageUtil {
+
+	public static void sendQuitUserMsg(String content) throws WxErrorException {
+		try {
+			WxCpMessage message = new WxCpMessage();
+			message.setToUser(ConfConfig.getConfigString("wxCp.massage.toUser"));
+			message.setMsgType(XmlMsgType.TEXT);
+			message.setContent(content);
+			WxCpMessageSendResult sendResult = WXCpMessage.service.messageSend(message);
+			LoggerUtil.info(sendResult.toString());
+		} catch (WxErrorException e) {
+			LoggerUtil.error(e);
+		}
+	}
+
+	public static void main(String[] args) throws WxErrorException {
+		sendQuitUserMsg("1111111111222");
+	}
+}

+ 2 - 1
code/sapparent/sapservice/src/main/java/org/fouram/service/TaskService.java

@@ -5,6 +5,7 @@ import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.fouram.core.base.service.BaseService;
+import org.fouram.core.plugin.weixin.cp.util.WXCpMessageUtil;
 import org.fouram.core.plugin.weixin.cp.util.WXCpUserUtil;
 import org.fouram.core.util.DateUtil;
 import org.fouram.core.util.LoggerUtil;
@@ -71,7 +72,7 @@ public class TaskService extends BaseService {
 		List<SapUser> unableSapUsers = sapUserService.selectDeleteList();
 		LoggerUtil.info("SAP禁用数据->" + unableSapUsers.size());
 		if (unableSapUsers.size() > 0) {
-
+			WXCpMessageUtil.sendQuitUserMsg("离职用户"+unableSapUsers.size()+"个,请确认");
 		}
 
 		// 部分数据插入微信未成功,处理数据后,重新插入

+ 5 - 3
code/sapparent/sapservice/src/main/resources/env/develop/config.properties

@@ -3,12 +3,14 @@ env = develop
 #fouram
 wxCp.corpId = ww51602aeb8dab7a95
 wxCp.corpSecret = 0i1jzYxLcriGTXhoatAGYaCFUXshfASbavRScZQxVmI
-#test
-#wxCp.corpId = ww3fa314d9782219c7
-#wxCp.corpSecret = 80lhnjKd6hKNp1tNkRsN9i0wOtrSZ7Sg_apJDNa1RDQ
+wxCp.massage.agentId = 1000003
+wxCp.massage.secret = Sf9mHYuIeAFyqvyoDnTXAH2hlly7kWq6LoIYGCuTZUM
+wxCp.massage.toUser = 1000001
 #prod
 #wxCp.corpId = ww911e29458d3a46fd
 #wxCp.corpSecret = amUNgH2lo-szEYkLmClZN2jMYcDu0NnXIAtWfW729P4
+#wxCp.massage.agentId = 1000009
+#wxCp.massage.secret = a0HDbErBYZxL43yLIzTZ_9Q5q4eFf2EHSi67TWP1RbE
 
 wxCp.mailList.corpSecret = aI66cnVoFAd381rgd3NpyZaEP2qnuZJ2ogpZKWmz9qg
 wxCp.redirectUri = http://cmcadressbook.suggest.vip/sapcms

+ 4 - 3
code/sapparent/sapservice/src/main/resources/env/product/config.properties

@@ -3,12 +3,13 @@ env = product
 #fouram
 #wxCp.corpId = ww51602aeb8dab7a95
 #wxCp.corpSecret = 0i1jzYxLcriGTXhoatAGYaCFUXshfASbavRScZQxVmI
-#test
-#wxCp.corpId = ww3fa314d9782219c7
-#wxCp.corpSecret = 80lhnjKd6hKNp1tNkRsN9i0wOtrSZ7Sg_apJDNa1RDQ
+#wxCp.massage.agentId = 1000003
+#wxCp.massage.secret = Sf9mHYuIeAFyqvyoDnTXAH2hlly7kWq6LoIYGCuTZUM
 #prod
 wxCp.corpId = ww911e29458d3a46fd
 wxCp.corpSecret = amUNgH2lo-szEYkLmClZN2jMYcDu0NnXIAtWfW729P4
+wxCp.massage.agentId = 1000009
+wxCp.massage.secret = a0HDbErBYZxL43yLIzTZ_9Q5q4eFf2EHSi67TWP1RbE
 
 wxCp.mailList.corpSecret = aI66cnVoFAd381rgd3NpyZaEP2qnuZJ2ogpZKWmz9qg
 wxCp.redirectUri = http://cmcadressbook.suggest.vip/sapcms