Commit 0ac10f6f authored by 华润's avatar 华润

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

parent f0ec6bdb
......@@ -17,7 +17,6 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.zip.GZIPInputStream;
import static net.cdkj.gjj.adapter.domain.GzipUtil.unzipString;
import static net.cdkj.gjj.adapter.domain.GzipUtil.zipString;
......@@ -48,18 +47,13 @@ public class ProvidentFundServicesController {
}
} catch (Exception e) {
System.out.println(e.toString());
}
String str = json.toString();
System.out.println("内置机传给前置机的公积金系统服务json数据:"+json.toString());
//-----------------------------------------------------
String token = null;
token = huoqutoken();//调用获取token的方法
System.out.println(token);
// System.out.println("内置机传给前置机的json数据:"+str);
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;
......@@ -98,12 +92,6 @@ public class ProvidentFundServicesController {
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();
GZIPInputStream gzis = new GZIPInputStream(is);
InputStreamReader reader = new InputStreamReader(gzis,"UTF-8");
BufferedReader br = new BufferedReader(reader);
......@@ -111,8 +99,6 @@ public class ProvidentFundServicesController {
while ((temp = br.readLine()) != null) {
sb.append(temp);
}
System.out.println("公积金服务第三方返回的zip压缩过的报文:" + sb.toString());
// String s1 = unzipString(sb.toString());//将第三方返回的压缩过的json字符串解压缩
System.out.println("公积金服务第三方返回的zip解压缩之后的报文:" + sb.toString());
return sb.toString();
} else {
......@@ -165,152 +151,52 @@ public class ProvidentFundServicesController {
jsonObject.put("code", 0);
jsonObject.put("message", "数据交换成功");
List<UnitAccountOpeningInformation> list = new ArrayList<>();
UnitAccountOpeningInformation openingInformation = new UnitAccountOpeningInformation();
openingInformation.setBusId("332090890");
openingInformation.setUscc("914205007146987888");
openingInformation.setEntName("湖北稻花香酒业股份有限公司(华润测试)");
openingInformation.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua7888");
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
openingInformation.setEstDate(new Date());
openingInformation.setLerep("蔡开云");
openingInformation.setCerType("10");
openingInformation.setCerNo("421121199402084030");
openingInformation.setOperatorName("张文");
openingInformation.setOperatorCerNo("421121199402084030");
openingInformation.setOperatorPhone("13345678899");
openingInformation.setOplocdistrict("421101001");
openingInformation.setUnitNature("01");
openingInformation.setEconomicType("1222");
openingInformation.setIndustryphy("C1512");
openingInformation.setUnitPayDay("05");
openingInformation.setUnitDepPro("12");
openingInformation.setPersonalDepPro("12");
//-------------------------------------
UnitAccountOpeningInformation openingInformation2 = new UnitAccountOpeningInformation();
openingInformation2.setBusId("332090891");
openingInformation2.setUscc("914205007146987889");
openingInformation2.setEntName("湖北稻花香酒业股份有限公司(华润测试)");
openingInformation2.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua7889");
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
openingInformation2.setEstDate(new Date());
openingInformation2.setLerep("蔡开云");
openingInformation2.setCerType("10");
openingInformation2.setCerNo("421121199402084030");
openingInformation2.setOperatorName("张文");
openingInformation2.setOperatorCerNo("421121199402084030");
openingInformation2.setOperatorPhone("13345678899");
openingInformation2.setOplocdistrict("421101001");
openingInformation2.setUnitNature("01");
openingInformation2.setEconomicType("1222");
openingInformation2.setIndustryphy("C1512");
openingInformation2.setUnitPayDay("05");
openingInformation2.setUnitDepPro("12");
openingInformation2.setPersonalDepPro("12");
list.add(openingInformation);
list.add(openingInformation2);
// UnitAccountOpeningInformation openingInformation = new UnitAccountOpeningInformation();
// openingInformation.setBusId("332090890");
// openingInformation.setUscc("914205007146987888");
// openingInformation.setEntName("湖北稻花香酒业股份有限公司(华润测试)");
// openingInformation.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua7888");
//// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
// openingInformation.setEstDate(new Date());
// openingInformation.setLerep("蔡开云");
// openingInformation.setCerType("10");
// openingInformation.setCerNo("421121199402084030");
// openingInformation.setOperatorName("张文");
// openingInformation.setOperatorCerNo("421121199402084030");
// openingInformation.setOperatorPhone("13345678899");
// openingInformation.setOplocdistrict("421101001");
// openingInformation.setUnitNature("01");
// openingInformation.setEconomicType("1222");
// openingInformation.setIndustryphy("C1512");
// openingInformation.setUnitPayDay("05");
// openingInformation.setUnitDepPro("12");
// openingInformation.setPersonalDepPro("12");
// //-------------------------------------
// UnitAccountOpeningInformation openingInformation2 = new UnitAccountOpeningInformation();
// openingInformation2.setBusId("332090891");
// openingInformation2.setUscc("914205007146987889");
// openingInformation2.setEntName("湖北稻花香酒业股份有限公司(华润测试)");
// openingInformation2.setDom("湖北省宜昌市龙泉镇圣诞快乐房价数量的方式独立开发huahua7889");
//// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
// openingInformation2.setEstDate(new Date());
// openingInformation2.setLerep("蔡开云");
// openingInformation2.setCerType("10");
// openingInformation2.setCerNo("421121199402084030");
// openingInformation2.setOperatorName("张文");
// openingInformation2.setOperatorCerNo("421121199402084030");
// openingInformation2.setOperatorPhone("13345678899");
// openingInformation2.setOplocdistrict("421101001");
// openingInformation2.setUnitNature("01");
// openingInformation2.setEconomicType("1222");
// openingInformation2.setIndustryphy("C1512");
// openingInformation2.setUnitPayDay("05");
// openingInformation2.setUnitDepPro("12");
// openingInformation2.setPersonalDepPro("12");
// 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("第三方传给我的单位开户的数据"+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;
}
/**
* 获取当天零点零分零秒的时间戳和当天24点的时间戳
*
* @return
*/
@ResponseBody
@PostMapping("currentime")
public static String currenttime(int type) {
String time = null;
if (type == 0) {
// 获取当天零点零分零秒的时间戳
Calendar curentDay = Calendar.getInstance();
curentDay.setTime(new Date());
curentDay.set(Calendar.HOUR_OF_DAY, 0);
curentDay.set(Calendar.MINUTE, 0);
curentDay.set(Calendar.SECOND, 0);
SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
time = df2.format(curentDay.getTime().getTime());
System.out.println(time);
} else if (type == 24) {
// 获取当天24点零分零秒的时间戳,即第二天零点时间
Calendar curentDay = Calendar.getInstance();
curentDay.setTime(new Date());
curentDay.set(Calendar.HOUR_OF_DAY, 24);
curentDay.set(Calendar.MINUTE, 0);
curentDay.set(Calendar.SECOND, 0);
SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
time = df2.format(curentDay.getTime().getTime());
System.out.println(time);
}
return time;
return str;
}
/**
......@@ -356,20 +242,17 @@ public class ProvidentFundServicesController {
}
String str = json.toString();
System.out.println("内置机传给前置机的进度接口参数json数据"+json.toString());
//-----------------------------------------------------
String token = null;
token = huoqutoken();//调用获取token的方法
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("http://59.208.149.225:18080/sjzt/api/testretGjjProgData?access_token="+token);//正式第三方地址
// URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/BusinessProcessing2?access_token=" + token);//测试第三方地址
// URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/BusinessProcessing2?access_token=" + token);//本地模拟第三方地址
// 创建http 连接
conn = (HttpURLConnection) url.openConnection();
// 设置允许输出
......@@ -401,12 +284,6 @@ public class ProvidentFundServicesController {
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();
GZIPInputStream gzis = new GZIPInputStream(is);
InputStreamReader reader = new InputStreamReader(gzis,"UTF-8");
BufferedReader br = new BufferedReader(reader);
......@@ -414,8 +291,6 @@ public class ProvidentFundServicesController {
while ((temp = br.readLine()) != null) {
sb.append(temp);
}
System.out.println("第三方返回的zip压缩过的进度结果报文:" + sb.toString());
// String s1 = unzipString(sb.toString());//将第三方返回的压缩过的json字符串解压缩
System.out.println("第三方返回的zip解压缩之后的进度结果报文:" + sb.toString());
return sb.toString();
} else {
......@@ -435,7 +310,6 @@ public class ProvidentFundServicesController {
conn.disconnect();
}
}
return null;
}
......
......@@ -11,6 +11,7 @@ import java.util.zip.GZIPInputStream;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import static net.cdkj.gjj.adapter.domain.GzipUtil.*;
......@@ -37,15 +38,13 @@ public class TokenAcquisitionController {
jsonObject.put("userid", "gjj");
String str = jsonObject.toString();
System.out.println("鉴权参数zip压缩处理之前要发送给第三方的报文:" + str);
// String s = zipString(str);//进行zip压缩
// System.out.println("鉴权参数zip压缩处理之后发送给第三方的报文:" + str);
StringBuffer sb = new StringBuffer();
HttpURLConnection conn = null;
OutputStream out = null;
try {
// 创建url 资源
URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/oauth2/token");//正式第三方地址
// URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/token2");//测试第三方地址
URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/oauth2/token");//测试环境第三方地址
// URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/token2");//本地环境模拟第三方地址
// 创建http 连接
conn = (HttpURLConnection) url.openConnection();
// 设置允许输出
......@@ -89,8 +88,6 @@ public class TokenAcquisitionController {
while ((temp = br.readLine()) != null) {
sb.append(temp);
}
System.out.println("鉴权参数第三方返回的zip压缩过的报文:" + sb.toString());
// String s1 = unzipString(sb.toString());//将第三方返回的压缩过的json字符串解压缩
System.out.println("鉴权参数第三方返回的zip解压缩之后的报文:" + sb.toString());
return sb.toString();
} else {
......@@ -147,22 +144,10 @@ public class TokenAcquisitionController {
jsonObject.put("grant_type", "192.168.101.34");
jsonObject.put("userid", "gjj");
String str = jsonObject.toString();
System.out.println("未经过压缩处理的json字符串:"+str);
System.out.println("未经过压缩处理的json字符串:" + str);
String s = zipString(str);//进行zip压缩
System.out.println("压缩处理之后的json字符串:"+s);
System.out.println("压缩处理之后的json字符串:" + s);
String s1 = unzipString(s);//进行zip解压缩
System.out.println("解压缩处理之后的json字符串:"+s1);
}
/**
* 程序中访问http数据接口
*/
@ResponseBody
@PostMapping("testjson")
public static String getURLContent() {
return null;
System.out.println("解压缩处理之后的json字符串:" + s1);
}
}
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