Ecology-Dev-chaofa/盛虹化纤/interface/shhq/tb003.jsp

161 lines
6.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="weaver.general.*,java.util.*,java.math.*" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="org.apache.http.impl.client.*" %>
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
<%@ page import="org.apache.http.client.methods.HttpPost" %>
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
<%@ page import="org.apache.http.message.BasicHeader" %>
<%@ page import="cn.hutool.core.codec.Base64" %>
<%@ page import="org.apache.http.entity.*" %>
<%@ page import="java.nio.charset.Charset" %>
<%@ page import="org.apache.http.HttpEntity" %>
<%@ page import="org.apache.http.util.EntityUtils" %>
<%@ page import="java.io.IOException" %>
<%
int sum = 0;
String url = "http://podevsrv.shenghongtec.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=SH_EOS&receiverParty=&receiverService=&interface=SKD3_Syn_Out&interfaceNamespace=urn:shenghong:eos:bpm";
//
String val = "{\n" +
"\"sysName\": \"SAP_DFSH\",\n" +
"\"returnUrl\": \"%DM_BC%/NNForm/api/Process/GetXiangMuView\",\n" +
"\"processName\": \"HX_TY_ZPRCDJB\",\n" +
"\"dataId\": \"SSQ202308030009\",\n" +
"\"title\": \"江苏国望高科纤维有限公司-张三\",\n" +
"\"initiatorName\": \"85010888\",\n" +
"\"GongSi\": \"江苏国望高科纤维有限公司\",\n" +
"\"XingMing\": \"张三\",\n" +
"\"XingBie\": \"男\",\n" +
"\"MinZhu\": \"汉族\",\n" +
"\"JiGuan\": \"江苏省\",\n" +
"\"ChuShengNY\": \"1996-07-01\",\n" +
"\"ZhengZhiMM\": \"群众\",\n" +
"\"ShenFenZH\": \"14052419761114803Y\",\n" +
"\"LianXiDH\": \"13888888888\",\n" +
"\"ShenGao\": \"170\",\n" +
"\"TiZhong\": \"75\",\n" +
"\"ZhuanYe\": \"人力资源专业\",\n" +
"\"XueLi\": \"本科\",\n" +
"\"BiYeYX\": \"西安交通大学\",\n" +
"\"JiaTingDZ\": \"云南省德宏傣族景颇族\",\n" +
"\"XueXiJL\": \"2000年6月-2004年7月 交通大学\",\n" +
"\"GongZuoJL\": \"2000年6月-2004年7月 盛虹化纤\",\n" +
"\"YingPingGW\": \"人资主任\",\n" +
"\"ZhaoPinZYGH\": \"85010888\",\n" +
"\"DangAnGID\": \"3357199313267944455\",\n" +
"\"ZhaoPinZY\": \"85010888\",\n" +
"\"ShenQingRBuMenID\": \"80109000\",\n" +
"\"ShenQingRGongSiID\": \"80100000\",\n" +
"\"GongSiMC\": \"江苏国望高科纤维有限公司\",\n" +
"\"BuMenMC\": \"数智化部\"\n" +
"}";
// 同步工号的入参
String xml ="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">\n" +
" <soapenv:Header/>\n" +
" <soapenv:Body>\n" +
" <tem:SDK3>\n" +
" <tem:json>"+val+"</tem:json>\n" +
" </tem:SDK3>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope>";
String usr_pwd = "po_sender:posender0807" ;
String soapAction = "";
Map<String,String> msgMap = doPostSoap(url,xml,soapAction,usr_pwd);
sum++;
%>
<%!
public Map<String,String> doPostSoap(String url, String soapXml, String soapAction, String userpass) throws Exception
{
Map<String,String> msgMap = new HashMap<String,String>();
System.out.println("url:"+url);
System.out.println("soapXml:"+soapXml);
System.out.println("soapAction:"+soapAction);
System.out.println("userpass:"+userpass);
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpPost httpPost = new HttpPost(url);
//设置请求和传输超时时间
String result = "";
CloseableHttpResponse response = null;
try {
httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
httpPost.setHeader("SOAPAction", soapAction);
httpPost.addHeader(new BasicHeader("Authorization", "Basic " + new String(Base64.encode(userpass.getBytes()))));
StringEntity data = new StringEntity(soapXml, Charset.forName("UTF-8"));
System.out.println("data:"+data.toString());
httpPost.setEntity(data);
response = closeableHttpClient.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null)
{
result = EntityUtils.toString(httpEntity, "UTF-8");
System.out.println("result:"+result);
if(!"".equals(result))
{
result = result.replace("&lt;","<").replace("&gt;",">");
msgMap.put("result",result);
}else{
msgMap.put("code","-100");
msgMap.put("sqlcode","-100");
msgMap.put("description","ERP接口返回值为空");
}
}else{
msgMap.put("code","-200");
msgMap.put("sqlcode","-200");
msgMap.put("description","ERP接口返回值为空");
}
} catch (Exception e)
{
e.printStackTrace();
System.out.println("e"+e);
msgMap.put("code","-200");
msgMap.put("sqlcode","-200");
msgMap.put("description","ERP接口调用异常:"+e);
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return msgMap;
}
%>
<HEAD>
</HEAD>
<BODY>
<h1>Congratulation Mode 666666 !</h1>
<h1> 招聘人才登记表 </h1>
<h1> 返回结果 <%=msgMap%></h1>
<h1> sum <%=sum%> </h1>
</BODY>