|
|
|
@ -21,17 +21,24 @@ import com.weaver.openapi.service.AuthService;
|
|
|
|
|
import com.weaver.openapi.service.MessageService;
|
|
|
|
|
import com.weaver.seconddev.interfaces.prop.ConfigProp;
|
|
|
|
|
import com.weaver.verupgrade.conn.RecordSet;
|
|
|
|
|
import com.weaver.verupgrade.hrm.resource.ResourceComInfo;
|
|
|
|
|
import com.weaver.workflow.list.api.rest.publicapi.WflRequestListRest;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.axis.client.Call;
|
|
|
|
|
import org.apache.axis.client.Service;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import javax.xml.namespace.QName;
|
|
|
|
|
import javax.xml.rpc.ParameterMode;
|
|
|
|
|
import javax.xml.rpc.ServiceException;
|
|
|
|
|
import javax.xml.rpc.encoding.XMLType;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.rmi.RemoteException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
@ -54,7 +61,7 @@ public class MessageSubscriptionController {
|
|
|
|
|
private ConfigProp configProp;
|
|
|
|
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(MessageSubscriptionController.class);
|
|
|
|
|
@PostMapping("/subscription")
|
|
|
|
|
public WeaResult<String> subscription(@RequestParam Map<String,Object> param, @RequestBody Map<String,Object> params ) {
|
|
|
|
|
public WeaResult<String> subscription(@RequestParam Map<String,Object> param, @RequestBody Map<String,Object> params ) throws ServiceException, RemoteException {
|
|
|
|
|
logger.error("MessageSubscriptionController Start " );
|
|
|
|
|
String jtzhkey = "t6kj9c07jr";
|
|
|
|
|
// String jtzhadmin = configProp.getJtzhadmin();
|
|
|
|
@ -66,11 +73,126 @@ public class MessageSubscriptionController {
|
|
|
|
|
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
|
|
|
|
|
|
|
|
|
logger.error("params == " + params);
|
|
|
|
|
|
|
|
|
|
sendMsg(params);
|
|
|
|
|
|
|
|
|
|
logger.error("subscription 推送成功");
|
|
|
|
|
map.put("msg","推送成功");
|
|
|
|
|
return WeaResult.success(map.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sendMsg(Map<String,Object> params) throws RemoteException, ServiceException {
|
|
|
|
|
logger.error("sendMsg params " + params);
|
|
|
|
|
String systemId = "SYS006";
|
|
|
|
|
String password = "123456";
|
|
|
|
|
String moudule = "流程待办";
|
|
|
|
|
String messages = "<messages>";
|
|
|
|
|
String content = String.valueOf(params.get("content"));
|
|
|
|
|
String url = String.valueOf(params.get("pcUrl"));
|
|
|
|
|
String mobileurl = String.valueOf(params.get("h5Url"));
|
|
|
|
|
String pcurl = configProp.getPc_url()+ URLEncoder.encode(url);
|
|
|
|
|
String msgurl = configProp.getPc_url()+ URLEncoder.encode(mobileurl);
|
|
|
|
|
String m_msgtitle = String.valueOf(params.get("title"));
|
|
|
|
|
String sendid = String.valueOf(params.get("senderId"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.error(" moudule: " + moudule);
|
|
|
|
|
logger.error(" pcurl: " + pcurl);
|
|
|
|
|
logger.error(" msgurl: " + msgurl);
|
|
|
|
|
logger.error(" m_msgtitle: " + m_msgtitle);
|
|
|
|
|
logger.error(" moudule: " + moudule);
|
|
|
|
|
logger.error(" sendid: " + sendid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String sendname = "系统管理员";
|
|
|
|
|
String userid = "1";
|
|
|
|
|
ResourceComInfo rc = I18nContextUtil.getBean(ResourceComInfo.class);
|
|
|
|
|
if (sendid != "1") {
|
|
|
|
|
sendname = rc.getLastname(sendid + "");
|
|
|
|
|
userid = rc.getWorkcode(sendid + "");
|
|
|
|
|
}
|
|
|
|
|
String pre = "";
|
|
|
|
|
String msgtt = m_msgtitle;
|
|
|
|
|
if (m_msgtitle.contains("~`~`7")) {
|
|
|
|
|
msgtt = m_msgtitle.substring(m_msgtitle.indexOf("~`~`7") + 6, m_msgtitle.indexOf("`~`8"));
|
|
|
|
|
}
|
|
|
|
|
if ("会议".equals(moudule)) {
|
|
|
|
|
content = content.substring(content.indexOf("~`~`7") + 6, content.indexOf("`~`8")).replaceAll("<br/>", " ");
|
|
|
|
|
msgtt = "您有一个会议即将开始,会议名称:" + msgtt + " " + content;
|
|
|
|
|
}
|
|
|
|
|
if ("通知公告".equals(moudule)) {
|
|
|
|
|
content = content.substring(content.indexOf("~`~`7") + 6, content.indexOf("`~`8")).replaceAll("<br/>", " ");
|
|
|
|
|
msgtt = "您有新的待阅文档:" + msgtt;
|
|
|
|
|
}
|
|
|
|
|
String refurl;
|
|
|
|
|
if ("流程待办".equals(moudule)) {
|
|
|
|
|
refurl = m_msgtitle;
|
|
|
|
|
if (refurl.contains("~`~`7")) {
|
|
|
|
|
refurl = refurl.substring(refurl.indexOf("~`~`7") + 6, refurl.indexOf("`~`8"));
|
|
|
|
|
msgtt = refurl + ":" + msgtt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
logger.error(" content: " + content);
|
|
|
|
|
logger.error(" msgtt: " + msgtt);
|
|
|
|
|
|
|
|
|
|
refurl = msgurl;
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String msgtime = df.format(new Date());
|
|
|
|
|
String target = "2";
|
|
|
|
|
String extdata = "";
|
|
|
|
|
// Set<String> useridset = msg.getRecivers();
|
|
|
|
|
List<String> useridset = Collections.singletonList(String.valueOf(params.get("receivers")));
|
|
|
|
|
Object[] arr = useridset.toArray();
|
|
|
|
|
for (int i = 0; i < arr.length; i += 100) {
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
for (int j = i; j < i + 100 && j < arr.length; ++j) {
|
|
|
|
|
sb.append(rc.getWorkcode(arr[j] + "") + ",");
|
|
|
|
|
}
|
|
|
|
|
String user = sb.toString().substring(0, sb.length() - 1);
|
|
|
|
|
String msgid = "MsgSYS006" + userid + (new Date()).getTime();
|
|
|
|
|
messages = messages + "<message>";
|
|
|
|
|
messages = messages + "<MSG_ID>" + msgid + "</MSG_ID><PRE_MSG_ID>" + pre + "</PRE_MSG_ID><USER_ID>" + user + "</USER_ID><MSG_TITLE>" + msgtt + "</MSG_TITLE><MSG_CONTENT>" + msgtt + "</MSG_CONTENT><SENDER_NAME>" + sendname + "</SENDER_NAME><REF_URL>" + refurl + "</REF_URL><MSG_TIME>" + msgtime + "</MSG_TIME><TARGET>" + target + "</TARGET><EXT_DATA>" + extdata + "</EXT_DATA>";
|
|
|
|
|
messages = messages + "</message>";
|
|
|
|
|
if (!"流程待办".equals(moudule)) {
|
|
|
|
|
String pctarget = "1";
|
|
|
|
|
pre = msgid;
|
|
|
|
|
msgid = "MsgPCSYS006" + userid + (new Date()).getTime();
|
|
|
|
|
messages = messages + "<message>";
|
|
|
|
|
messages = messages + "<MSG_ID>" + msgid + "</MSG_ID><PRE_MSG_ID>" + pre + "</PRE_MSG_ID><USER_ID>" + user + "</USER_ID><MSG_TITLE>" + msgtt + "</MSG_TITLE><MSG_CONTENT>" + msgtt + "</MSG_CONTENT><SENDER_NAME>" + sendname + "</SENDER_NAME><REF_URL>" + pcurl + "</REF_URL><MSG_TIME>" + msgtime + "</MSG_TIME><TARGET>" + pctarget + "</TARGET><EXT_DATA>" + extdata + "</EXT_DATA>";
|
|
|
|
|
messages = messages + "</message>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
messages = messages + "</messages>";
|
|
|
|
|
logger.error(" messages: " + messages);
|
|
|
|
|
|
|
|
|
|
String typeNamespace = "http://message.ht_portal_webservice.com";
|
|
|
|
|
String endpoint = "https://sappop.htgd.com.cn:50001/XISOAPAdapter/MessageServlet?senderParty=&senderService=BS_HTU_POP&receiverParty=&receiverService=&interface=SI_HTPortalMessage_OUT&interfaceNamespace=http%3A%2F%2Fhengtong.com%2FHTU%2FHTPortalMessage";
|
|
|
|
|
Service service = new Service();
|
|
|
|
|
Call call = (Call) service.createCall();
|
|
|
|
|
call.setTimeout(300000);
|
|
|
|
|
call.setTargetEndpointAddress(endpoint);
|
|
|
|
|
call.setOperationName(new QName(typeNamespace, "message"));
|
|
|
|
|
call.addParameter(new QName(typeNamespace, "systemId"), XMLType.XSD_STRING, ParameterMode.IN);
|
|
|
|
|
call.addParameter(new QName(typeNamespace, "password"), XMLType.XSD_STRING, ParameterMode.IN);
|
|
|
|
|
call.addParameter(new QName(typeNamespace, "moudule"), XMLType.XSD_STRING, ParameterMode.IN);
|
|
|
|
|
call.addParameter(new QName(typeNamespace, "messages"), XMLType.XSD_STRING, ParameterMode.IN);
|
|
|
|
|
call.setReturnClass(String.class);
|
|
|
|
|
call.setReturnQName(new QName(typeNamespace, "messageResponse"));
|
|
|
|
|
call.setUseSOAPAction(true);
|
|
|
|
|
call.setSOAPActionURI("http://sap.com/xi/WebService/soap1.1");
|
|
|
|
|
Hashtable<String, String> headers = (Hashtable) call.getProperty("HTTP-Request-Headers");
|
|
|
|
|
if (headers == null) {
|
|
|
|
|
headers = new Hashtable();
|
|
|
|
|
call.setProperty("HTTP-Request-Headers", headers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
headers.put("Authorization", configProp.getUrl_password());
|
|
|
|
|
|
|
|
|
|
Object[] val = new Object[] { systemId, password, moudule, messages };
|
|
|
|
|
String obj = (String) call.invoke(val);
|
|
|
|
|
|
|
|
|
|
logger.error(" obj: " + String.valueOf(obj));
|
|
|
|
|
|
|
|
|
|
logger.error(String.valueOf("----onMessage--<\n"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|