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

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

parent 1722eb4b
......@@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
......@@ -37,15 +39,31 @@ public class ProvidentFundServicesController {
*/
@ResponseBody
@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;
token = huoqutoken();//调用获取token的方法
JSONObject jsonObject = new JSONObject();
jsonObject.put("startTime", currenttime(0));
jsonObject.put("endTime", currenttime(24));
jsonObject.put("app_id", "xxxxx");
jsonObject.put("app_secret", "xxxxx");
String str = jsonObject.toString();
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("startTime", currenttime(0));
// jsonObject.put("endTime", currenttime(24));
// jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
// jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
// String str = jsonObject.toString();
// String str = jsonstr;
System.out.println("zip压缩处理之前要发送给第三方的报文:" + str);
String s = zipString(str);//进行zip压缩
......@@ -74,7 +92,7 @@ public class ProvidentFundServicesController {
// 设置文件字符集:
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));
// 开始连接请求
......@@ -125,17 +143,33 @@ public class ProvidentFundServicesController {
*/
@ResponseBody
@PostMapping("ProvidentFundServices2")
public String ProvidentFundServices2() {
String resp = null;
public String ProvidentFundServices2(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 str1 = json.toString();
System.out.println("第三方接收的参数解压之前"+str1);
String str2 = unzipString(str1);//解压缩
System.out.println("第三方接收的参数解压之后"+str2);
//-----------------------------------------------------
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);
jsonObject.put("message", "数据交换成功");
List<UnitAccountOpeningInformation> data = new ArrayList<>();
List<UnitAccountOpeningInformation> list = new ArrayList<>();
UnitAccountOpeningInformation openingInformation = new UnitAccountOpeningInformation();
openingInformation.setBusId("332090890");
openingInformation.setUscc("914205007146986290");
openingInformation.setUscc("914205007146987789");
openingInformation.setEntName("湖北稻花香酒业股份有限公司(华润测试)");
openingInformation.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua2");
openingInformation.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua7789");
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
openingInformation.setEstDate(new Date());
openingInformation.setLerep("蔡开云");
......@@ -154,9 +188,9 @@ public class ProvidentFundServicesController {
//-------------------------------------
UnitAccountOpeningInformation openingInformation2 = new UnitAccountOpeningInformation();
openingInformation2.setBusId("332090891");
openingInformation2.setUscc("914205007146986291");
openingInformation2.setUscc("914205007146987790");
openingInformation2.setEntName("湖北稻花香酒业股份有限公司(华润测试)");
openingInformation2.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua3");
openingInformation2.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua7790");
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
openingInformation2.setEstDate(new Date());
openingInformation2.setLerep("蔡开云");
......@@ -172,14 +206,77 @@ public class ProvidentFundServicesController {
openingInformation2.setUnitPayDay("05");
openingInformation2.setUnitDepPro("12");
openingInformation2.setPersonalDepPro("12");
data.add(openingInformation);
data.add(openingInformation2);
jsonObject.put("data", data);
list.add(openingInformation);
list.add(openingInformation2);
jsonObject.put("data", list);
String str = jsonObject.toString();
String s = zipString(str);//进行zip压缩
// System.out.println(s);
// String s1 = unzipString(s);//解压缩
// System.out.println(s1);
//// System.out.println(s);
//// String s1 = unzipString(s);//解压缩
// 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;
}
......@@ -236,70 +333,124 @@ public class ProvidentFundServicesController {
}
/**
* 将从第三方拿到的单位开户的json信息通过调用oracle存储过程传给数据库处理
* 住建部门返回公积金办理进度数据接口方法
*
* @return
* @param
* @param
*/
@ResponseBody
@PostMapping("getuniAccounInfom")
public static UnitAccountOpeningInformation getuniAccounInfom() throws Exception{
String jsoninfom=ProvidentFundServices();
JSONObject jsonObj = JSONObject.parseObject(jsoninfom);
String str=jsonObj.get("data").toString();
String str1=str.replace("[","");
String str2=str1.replace("]","");
UnitAccountOpeningInformation uniInfom = JSONObject.parseObject(str2,UnitAccountOpeningInformation.class);
System.out.println(uniInfom);
//加载数据库驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//得到Connection连接
Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");
//得到预编译的Statement对象
CallableStatement pstm=connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_SL(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
//给参数赋值
// pstm.getString(1);
pstm.registerOutParameter(1,oracle.jdbc.OracleTypes.VARCHAR);
pstm.setString(2,uniInfom.getBusId());
pstm.setString(3,uniInfom.getUscc());
pstm.setString(4,uniInfom.getEntName());
pstm.setString(5,uniInfom.getDom());
pstm.setDate(6,new java.sql.Date(uniInfom.getEstDate().getTime()));
pstm.setString(7,uniInfom.getLerep());
pstm.setString(8,uniInfom.getCerType());
pstm.setString(9,uniInfom.getCerNo());
pstm.setString(10,uniInfom.getOperatorName());
pstm.setString(11,uniInfom.getOperatorCerNo());
pstm.setString(12,uniInfom.getOperatorPhone());
pstm.setString(13,uniInfom.getOplocdistrict());
pstm.setString(14,uniInfom.getUnitNature());
pstm.setString(15,uniInfom.getEconomicType());
pstm.setString(16,uniInfom.getIndustryphy());
pstm.setString(17,uniInfom.getUnitPayDay());
pstm.setString(18,uniInfom.getUnitDepPro());
pstm.setString(19,uniInfom.getPersonalDepPro());
pstm.setString(20,"");
pstm.setString(21,"");
pstm.registerOutParameter(22,oracle.jdbc.OracleTypes.VARCHAR);
pstm.registerOutParameter(23,oracle.jdbc.OracleTypes.VARCHAR);
pstm.registerOutParameter(24,oracle.jdbc.OracleTypes.VARCHAR);
// pstm.getString(22);
// pstm.getString(23);
// pstm.getString(24);
//执行数据库查询操作
pstm.execute();
//输出结果[第二个参数]
// pstm.registerOutParameter(1,oracle.jdbc.OracleTypes.VARCHAR);
// pstm.registerOutParameter(22,oracle.jdbc.OracleTypes.VARCHAR);
// pstm.registerOutParameter(23,oracle.jdbc.OracleTypes.VARCHAR);
// pstm.registerOutParameter(24,oracle.jdbc.OracleTypes.VARCHAR);
System.out.println(pstm.getString(1));
System.out.println(pstm.getString(22));
System.out.println(pstm.getString(23));
System.out.println(pstm.getString(24));
//释放资源
pstm.close();
connection.close();
return uniInfom;
@PostMapping("BusinessProcessing")
public static String BusinessProcessing(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.toString());
//-----------------------------------------------------
String token = null;
token = huoqutoken();//调用获取token的方法
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("startTime", currenttime(0));
// jsonObject.put("endTime", currenttime(24));
// jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
// jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
// String str = jsonObject.toString();
// String str = jsonstr;
System.out.println("zip压缩处理之前要发送给第三方的报文:" + str);
String s = zipString(str);//进行zip压缩
System.out.println("zip压缩处理之后发送给第三方的报文:" + s);
StringBuffer sb = new StringBuffer();
HttpURLConnection conn = null;
OutputStream out = null;
try {
// 创建url 资源
// URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/testretGjjProgData?access_token="+token);//正式第三方地址
URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/BusinessProcessing2?access_token=" + token);//测试第三方地址
// 创建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 = (str).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 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 {
@PostMapping("token")
public static String TokenAcquisition() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_id", "111");
jsonObject.put("app_secret", "222");
jsonObject.put("grant_type", "192.168.101.34");
jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
jsonObject.put("grant_type", "ip");
jsonObject.put("userid", "gjj");
String str = jsonObject.toString();
System.out.println("zip压缩处理之前要发送给第三方的报文:" + str);
......@@ -112,8 +112,8 @@ public class TokenAcquisitionController {
public String TokenAcquisition2() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("result", true);
jsonObject.put("expires_in", 30);
jsonObject.put("access_token", "skdfhskjdfhskjdfhskdfjhk");
jsonObject.put("expires_in", 7200);
jsonObject.put("access_token", "0faca598-787b-47cd-b74e-1f6f294e0250");
String str = jsonObject.toString();
//压缩处理
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