Commit 833b3b27 authored by 华润's avatar 华润

跨省单位开户公积金服务接口

parent 1722eb4b
...@@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
...@@ -37,15 +39,31 @@ public class ProvidentFundServicesController { ...@@ -37,15 +39,31 @@ public class ProvidentFundServicesController {
*/ */
@ResponseBody @ResponseBody
@PostMapping("ProvidentFundServices") @PostMapping("ProvidentFundServices")
public static String ProvidentFundServices() { public static String ProvidentFundServices(HttpServletRequest request) {
//-----------------------------------------------------
StringBuffer json = new StringBuffer();
String line = null;
try {
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null) {
// System.out.println("line:" + line);
json.append(line);
}
} catch (Exception e) {
System.out.println(e.toString());
}
String str = json.toString();
System.out.println("内置机传给前置机的json数据:"+json.toString());
//-----------------------------------------------------
String token = null; String token = null;
token = huoqutoken();//调用获取token的方法 token = huoqutoken();//调用获取token的方法
JSONObject jsonObject = new JSONObject(); // JSONObject jsonObject = new JSONObject();
jsonObject.put("startTime", currenttime(0)); // jsonObject.put("startTime", currenttime(0));
jsonObject.put("endTime", currenttime(24)); // jsonObject.put("endTime", currenttime(24));
jsonObject.put("app_id", "xxxxx"); // jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "xxxxx"); // jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
String str = jsonObject.toString(); // String str = jsonObject.toString();
// String str = jsonstr; // String str = jsonstr;
System.out.println("zip压缩处理之前要发送给第三方的报文:" + str); System.out.println("zip压缩处理之前要发送给第三方的报文:" + str);
String s = zipString(str);//进行zip压缩 String s = zipString(str);//进行zip压缩
...@@ -74,7 +92,7 @@ public class ProvidentFundServicesController { ...@@ -74,7 +92,7 @@ public class ProvidentFundServicesController {
// 设置文件字符集: // 设置文件字符集:
conn.setRequestProperty("Charset", "UTF-8"); conn.setRequestProperty("Charset", "UTF-8");
// 转换为字节数组 // 转换为字节数组
byte[] data = (str).getBytes("UTF-8"); byte[] data = (s).getBytes("UTF-8");
// 设置文件长度 // 设置文件长度
conn.setRequestProperty("Content-Length", String.valueOf(data.length)); conn.setRequestProperty("Content-Length", String.valueOf(data.length));
// 开始连接请求 // 开始连接请求
...@@ -125,17 +143,33 @@ public class ProvidentFundServicesController { ...@@ -125,17 +143,33 @@ public class ProvidentFundServicesController {
*/ */
@ResponseBody @ResponseBody
@PostMapping("ProvidentFundServices2") @PostMapping("ProvidentFundServices2")
public String ProvidentFundServices2() { public String ProvidentFundServices2(HttpServletRequest request) {
String resp = null; //-----------------------------------------------------
StringBuffer json = new StringBuffer();
String line = null;
try {
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null) {
// System.out.println("line:" + line);
json.append(line);
}
} catch (Exception e) {
System.out.println(e.toString());
}
String str1 = json.toString();
System.out.println("第三方接收的参数解压之前"+str1);
String str2 = unzipString(str1);//解压缩
System.out.println("第三方接收的参数解压之后"+str2);
//-----------------------------------------------------
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0); jsonObject.put("code", 0);
jsonObject.put("message", "数据交换成功"); jsonObject.put("message", "数据交换成功");
List<UnitAccountOpeningInformation> data = new ArrayList<>(); List<UnitAccountOpeningInformation> list = new ArrayList<>();
UnitAccountOpeningInformation openingInformation = new UnitAccountOpeningInformation(); UnitAccountOpeningInformation openingInformation = new UnitAccountOpeningInformation();
openingInformation.setBusId("332090890"); openingInformation.setBusId("332090890");
openingInformation.setUscc("914205007146986290"); openingInformation.setUscc("914205007146987789");
openingInformation.setEntName("湖北稻花香酒业股份有限公司(华润测试)"); openingInformation.setEntName("湖北稻花香酒业股份有限公司(华润测试)");
openingInformation.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua2"); openingInformation.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua7789");
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
openingInformation.setEstDate(new Date()); openingInformation.setEstDate(new Date());
openingInformation.setLerep("蔡开云"); openingInformation.setLerep("蔡开云");
...@@ -154,9 +188,9 @@ public class ProvidentFundServicesController { ...@@ -154,9 +188,9 @@ public class ProvidentFundServicesController {
//------------------------------------- //-------------------------------------
UnitAccountOpeningInformation openingInformation2 = new UnitAccountOpeningInformation(); UnitAccountOpeningInformation openingInformation2 = new UnitAccountOpeningInformation();
openingInformation2.setBusId("332090891"); openingInformation2.setBusId("332090891");
openingInformation2.setUscc("914205007146986291"); openingInformation2.setUscc("914205007146987790");
openingInformation2.setEntName("湖北稻花香酒业股份有限公司(华润测试)"); openingInformation2.setEntName("湖北稻花香酒业股份有限公司(华润测试)");
openingInformation2.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua3"); openingInformation2.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua7790");
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
openingInformation2.setEstDate(new Date()); openingInformation2.setEstDate(new Date());
openingInformation2.setLerep("蔡开云"); openingInformation2.setLerep("蔡开云");
...@@ -172,14 +206,77 @@ public class ProvidentFundServicesController { ...@@ -172,14 +206,77 @@ public class ProvidentFundServicesController {
openingInformation2.setUnitPayDay("05"); openingInformation2.setUnitPayDay("05");
openingInformation2.setUnitDepPro("12"); openingInformation2.setUnitDepPro("12");
openingInformation2.setPersonalDepPro("12"); openingInformation2.setPersonalDepPro("12");
data.add(openingInformation); list.add(openingInformation);
data.add(openingInformation2); list.add(openingInformation2);
jsonObject.put("data", data); jsonObject.put("data", list);
String str = jsonObject.toString(); String str = jsonObject.toString();
String s = zipString(str);//进行zip压缩 String s = zipString(str);//进行zip压缩
// System.out.println(s); //// System.out.println(s);
// String s1 = unzipString(s);//解压缩 //// String s1 = unzipString(s);//解压缩
// System.out.println(s1); // System.out.println("第三方传给我的单位开户的数据"+s);
// StringBuffer sb = new StringBuffer();
// HttpURLConnection conn = null;
// OutputStream out = null;
// try {
// // 创建url 资源
//// URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/dx/e39a08e0a52b413897f9d23359540b27/GJJ?access_token="+token);//正式第三方地址
// URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/ProvidentFundServices?");//测试第三方地址
// // 创建http 连接
// conn = (HttpURLConnection) url.openConnection();
// // 设置允许输出
// conn.setDoOutput(true);
// // 设置允许输入
// conn.setDoInput(true);
// // 设置不使用缓存
// conn.setUseCaches(false);
// // 设置传递方式
// conn.setRequestMethod("POST");
// // 设置维持长连接
// conn.setRequestProperty("Connection", "Keep-Alive");
// // 设置文件类型:
// conn.setRequestProperty("Content-Type", "application/json");
// // 设置文件字符集:
// conn.setRequestProperty("Charset", "UTF-8");
// // 转换为字节数组
// byte[] data = (s).getBytes("UTF-8");
// // 设置文件长度
// conn.setRequestProperty("Content-Length", String.valueOf(data.length));
// // 开始连接请求
// conn.connect();
// //创建写入流,写入请求的字符串
// out = new DataOutputStream(conn.getOutputStream());
// out.write(data);
// // 请求返回的状态
// if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {
// // 请求返回的数据
// InputStream is = conn.getInputStream();
// String readLine = new String();
// BufferedReader responseReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
// while ((readLine = responseReader.readLine()) != null) {
// sb.append(readLine);
// }
// responseReader.close();
//// System.out.println("第三方返回的zip压缩过的报文:" + sb.toString());
//// String s1 = unzipString(sb.toString());//将第三方返回的压缩过的json字符串解压缩
//// System.out.println("第三方返回的zip解压缩之后的报文:" + s1);
//// return s1;
// } else {
// System.out.println("请求失败!!!");
// }
// } catch (IOException e) {
// e.printStackTrace();
// } finally {
// if (out != null) {
// try {
// out.flush();
// out.close();
// } catch (IOException e) {
// }
// }
// if (conn != null) {
// conn.disconnect();
// }
// }
return s; return s;
} }
...@@ -236,70 +333,124 @@ public class ProvidentFundServicesController { ...@@ -236,70 +333,124 @@ public class ProvidentFundServicesController {
} }
/** /**
* 将从第三方拿到的单位开户的json信息通过调用oracle存储过程传给数据库处理 * 住建部门返回公积金办理进度数据接口方法
* *
* @return * @param
* @param
*/ */
@ResponseBody @ResponseBody
@PostMapping("getuniAccounInfom") @PostMapping("BusinessProcessing")
public static UnitAccountOpeningInformation getuniAccounInfom() throws Exception{ public static String BusinessProcessing(HttpServletRequest request) {
String jsoninfom=ProvidentFundServices(); //-----------------------------------------------------
JSONObject jsonObj = JSONObject.parseObject(jsoninfom); StringBuffer json = new StringBuffer();
String str=jsonObj.get("data").toString(); String line = null;
String str1=str.replace("[",""); try {
String str2=str1.replace("]",""); BufferedReader reader = request.getReader();
UnitAccountOpeningInformation uniInfom = JSONObject.parseObject(str2,UnitAccountOpeningInformation.class); while ((line = reader.readLine()) != null) {
System.out.println(uniInfom); // System.out.println("line:" + line);
//加载数据库驱动 json.append(line);
Class.forName("oracle.jdbc.driver.OracleDriver"); }
//得到Connection连接 } catch (Exception e) {
Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020"); System.out.println(e.toString());
//得到预编译的Statement对象
CallableStatement pstm=connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_SL(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); }
//给参数赋值 String str = json.toString();
// pstm.getString(1); System.out.println(json.toString());
pstm.registerOutParameter(1,oracle.jdbc.OracleTypes.VARCHAR); //-----------------------------------------------------
pstm.setString(2,uniInfom.getBusId()); String token = null;
pstm.setString(3,uniInfom.getUscc()); token = huoqutoken();//调用获取token的方法
pstm.setString(4,uniInfom.getEntName()); // JSONObject jsonObject = new JSONObject();
pstm.setString(5,uniInfom.getDom()); // jsonObject.put("startTime", currenttime(0));
pstm.setDate(6,new java.sql.Date(uniInfom.getEstDate().getTime())); // jsonObject.put("endTime", currenttime(24));
pstm.setString(7,uniInfom.getLerep()); // jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
pstm.setString(8,uniInfom.getCerType()); // jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
pstm.setString(9,uniInfom.getCerNo()); // String str = jsonObject.toString();
pstm.setString(10,uniInfom.getOperatorName()); // String str = jsonstr;
pstm.setString(11,uniInfom.getOperatorCerNo()); System.out.println("zip压缩处理之前要发送给第三方的报文:" + str);
pstm.setString(12,uniInfom.getOperatorPhone()); String s = zipString(str);//进行zip压缩
pstm.setString(13,uniInfom.getOplocdistrict()); System.out.println("zip压缩处理之后发送给第三方的报文:" + s);
pstm.setString(14,uniInfom.getUnitNature()); StringBuffer sb = new StringBuffer();
pstm.setString(15,uniInfom.getEconomicType()); HttpURLConnection conn = null;
pstm.setString(16,uniInfom.getIndustryphy()); OutputStream out = null;
pstm.setString(17,uniInfom.getUnitPayDay()); try {
pstm.setString(18,uniInfom.getUnitDepPro()); // 创建url 资源
pstm.setString(19,uniInfom.getPersonalDepPro()); // URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/testretGjjProgData?access_token="+token);//正式第三方地址
pstm.setString(20,""); URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/BusinessProcessing2?access_token=" + token);//测试第三方地址
pstm.setString(21,""); // 创建http 连接
pstm.registerOutParameter(22,oracle.jdbc.OracleTypes.VARCHAR); conn = (HttpURLConnection) url.openConnection();
pstm.registerOutParameter(23,oracle.jdbc.OracleTypes.VARCHAR); // 设置允许输出
pstm.registerOutParameter(24,oracle.jdbc.OracleTypes.VARCHAR); conn.setDoOutput(true);
// pstm.getString(22); // 设置允许输入
// pstm.getString(23); conn.setDoInput(true);
// pstm.getString(24); // 设置不使用缓存
//执行数据库查询操作 conn.setUseCaches(false);
pstm.execute(); // 设置传递方式
//输出结果[第二个参数] conn.setRequestMethod("POST");
// pstm.registerOutParameter(1,oracle.jdbc.OracleTypes.VARCHAR); // 设置维持长连接
// pstm.registerOutParameter(22,oracle.jdbc.OracleTypes.VARCHAR); conn.setRequestProperty("Connection", "Keep-Alive");
// pstm.registerOutParameter(23,oracle.jdbc.OracleTypes.VARCHAR); // 设置文件类型:
// pstm.registerOutParameter(24,oracle.jdbc.OracleTypes.VARCHAR); conn.setRequestProperty("Content-Type", "application/json");
System.out.println(pstm.getString(1)); // 设置文件字符集:
System.out.println(pstm.getString(22)); conn.setRequestProperty("Charset", "UTF-8");
System.out.println(pstm.getString(23)); // 转换为字节数组
System.out.println(pstm.getString(24)); byte[] data = (str).getBytes("UTF-8");
//释放资源 // 设置文件长度
pstm.close(); conn.setRequestProperty("Content-Length", String.valueOf(data.length));
connection.close(); // 开始连接请求
return uniInfom; conn.connect();
//创建写入流,写入请求的字符串
out = new DataOutputStream(conn.getOutputStream());
out.write(data);
// 请求返回的状态
if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {
// 请求返回的数据
InputStream is = conn.getInputStream();
String readLine = new String();
BufferedReader responseReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
while ((readLine = responseReader.readLine()) != null) {
sb.append(readLine);
}
responseReader.close();
System.out.println("第三方返回的zip压缩过的报文:" + sb.toString());
String s1 = unzipString(sb.toString());//将第三方返回的压缩过的json字符串解压缩
System.out.println("第三方返回的zip解压缩之后的报文:" + s1);
return s1;
} else {
System.out.println("请求失败!!!");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException e) {
}
}
if (conn != null) {
conn.disconnect();
}
}
return null;
}
/**
* 模拟住建部门返回公积金办理进度数据接口请求第三方,获取第三方返回的数据
*
* @param
* @param
*/
@ResponseBody
@PostMapping("BusinessProcessing2")
public String BusinessProcessing2() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("success", "false");
jsonObject.put("msg", "系统内部错误");
String str = jsonObject.toString();
String s = zipString(str);//进行zip压缩
return s;
} }
} }
...@@ -27,9 +27,9 @@ public class TokenAcquisitionController { ...@@ -27,9 +27,9 @@ public class TokenAcquisitionController {
@PostMapping("token") @PostMapping("token")
public static String TokenAcquisition() { public static String TokenAcquisition() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "111"); jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "222"); jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
jsonObject.put("grant_type", "192.168.101.34"); jsonObject.put("grant_type", "ip");
jsonObject.put("userid", "gjj"); jsonObject.put("userid", "gjj");
String str = jsonObject.toString(); String str = jsonObject.toString();
System.out.println("zip压缩处理之前要发送给第三方的报文:" + str); System.out.println("zip压缩处理之前要发送给第三方的报文:" + str);
...@@ -112,8 +112,8 @@ public class TokenAcquisitionController { ...@@ -112,8 +112,8 @@ public class TokenAcquisitionController {
public String TokenAcquisition2() { public String TokenAcquisition2() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("result", true); jsonObject.put("result", true);
jsonObject.put("expires_in", 30); jsonObject.put("expires_in", 7200);
jsonObject.put("access_token", "skdfhskjdfhskjdfhskdfjhk"); jsonObject.put("access_token", "0faca598-787b-47cd-b74e-1f6f294e0250");
String str = jsonObject.toString(); String str = jsonObject.toString();
//压缩处理 //压缩处理
String s = zipString(str); String s = zipString(str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment