Commit 78278dd8 authored by 华润's avatar 华润

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

parent 37ccd284
......@@ -2,8 +2,6 @@ package net.cdkj.gjj.adapter.controller;
import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.domain.Json;
import net.cdkj.gjj.adapter.domain.TimeExpiredPoolCache;
import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -13,6 +11,9 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
......@@ -37,17 +38,16 @@ public class ProvidentFundServicesController {
*/
@ResponseBody
@PostMapping("ProvidentFundServices")
public String ProvidentFundServices() {
String token=null;
token=CacheDemoController.getToken();
if(!"".equals(token)&&token!=null){//若token未过期,则用内存中的token
String resp = null;
public static String ProvidentFundServices() {
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();
// String str = jsonstr;
System.out.println("zip压缩处理之前要发送给第三方的报文:" + str);
String s = zipString(str);//进行zip压缩
System.out.println("zip压缩处理之后发送给第三方的报文:" + s);
......@@ -57,7 +57,7 @@ public class ProvidentFundServicesController {
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/ProvidentFundServices2?access_token="+token);//测试第三方地址
URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/ProvidentFundServices2?access_token=" + token);//测试第三方地址
// 创建http 连接
conn = (HttpURLConnection) url.openConnection();
// 设置允许输出
......@@ -114,10 +114,7 @@ public class ProvidentFundServicesController {
conn.disconnect();
}
}
}else{//若token已过期,则重新调用鉴权认证接口获取token存入内存中
CacheDemoController.saveToken();
token=CacheDemoController.getToken();
}
return null;
}
......@@ -134,25 +131,31 @@ public class ProvidentFundServicesController {
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);
jsonObject.put("message", "数据交换成功");
List<UnitAccountOpeningInformation> data=new ArrayList<>();
UnitAccountOpeningInformation openingInformation=new UnitAccountOpeningInformation();
List<UnitAccountOpeningInformation> data = new ArrayList<>();
UnitAccountOpeningInformation openingInformation = new UnitAccountOpeningInformation();
openingInformation.setBusId("332090874");
openingInformation.setUscc("914205007146986237");
openingInformation.setEntName("湖北稻花香酒业股份有限公司");
data.add(openingInformation);
jsonObject.put("data", data);
String str = jsonObject.toString();
return jsonObject.toString();
String s = zipString(str);//进行zip压缩
// System.out.println(s);
// String s1 = unzipString(s);//解压缩
// System.out.println(s1);
return s;
}
/**
* 获取当天零点零分零秒的时间戳和当天24点的时间戳
*
* @return
*/
@ResponseBody
@PostMapping("currentime")
public static String currenttime(int type){
String time=null;
if(type==0){
public static String currenttime(int type) {
String time = null;
if (type == 0) {
// 获取当天零点零分零秒的时间戳
Calendar curentDay = Calendar.getInstance();
curentDay.setTime(new Date());
......@@ -160,9 +163,9 @@ public class ProvidentFundServicesController {
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());
time = df2.format(curentDay.getTime().getTime());
System.out.println(time);
}else if(type==24){
} else if (type == 24) {
// 获取当天24点零分零秒的时间戳,即第二天零点时间
Calendar curentDay = Calendar.getInstance();
curentDay.setTime(new Date());
......@@ -170,10 +173,62 @@ public class ProvidentFundServicesController {
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());
time = df2.format(curentDay.getTime().getTime());
System.out.println(time);
}
return time;
}
/**
* 获取token专用方法
*
* @return
*/
@ResponseBody
@PostMapping("huoqutoken")
public static String huoqutoken() {
String token = null;
token = CacheDemoController.getToken();//优先从内存中拿
if (!"".equals(token) && token != null) {//若token未过期,则用内存中的token
} else {//若token已过期,则重新调用鉴权认证接口获取token存入内存中
CacheDemoController.saveToken();
token = CacheDemoController.getToken();
}
return token;
}
/**
* 将从第三方拿到的单位开户的json信息通过调用oracle存储过程传给数据库处理
*
* @return
*/
@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.setObject(1,uniInfom);
//执行数据库查询操作
pstm.execute();
//输出结果[第二个参数]
System.out.println(pstm.getObject(2));
//释放资源
pstm.close();
connection.close();
return uniInfom;
}
}
package net.cdkj.gjj.adapter.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects;
/**
* 单位开户信息对象
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UnitAccountOpeningInformation {
private String busId;
private String uscc;
private String entName;
private String dom;
private String estDate;
private String lerep;
private String cerType;
private String cerNo;
private String operatorName;
private String operatorCerNo;
private String operatorPhone;
private String oplocdistrict;
private String unitNature;
private String economicType;
private String industryphy;
private String unitPayDay;
private String unitDepPro;
private String personalDepPro;
public String getBusId() {
return busId;
}
......@@ -16,4 +54,164 @@ public class UnitAccountOpeningInformation {
public void setBusId(String busId) {
this.busId = busId;
}
public String getUscc() {
return uscc;
}
public void setUscc(String uscc) {
this.uscc = uscc;
}
public String getEntName() {
return entName;
}
public void setEntName(String entName) {
this.entName = entName;
}
public String getDom() {
return dom;
}
public void setDom(String dom) {
this.dom = dom;
}
public String getEstDate() {
return estDate;
}
public void setEstDate(String estDate) {
this.estDate = estDate;
}
public String getLerep() {
return lerep;
}
public void setLerep(String lerep) {
this.lerep = lerep;
}
public String getCerType() {
return cerType;
}
public void setCerType(String cerType) {
this.cerType = cerType;
}
public String getCerNo() {
return cerNo;
}
public void setCerNo(String cerNo) {
this.cerNo = cerNo;
}
public String getOperatorName() {
return operatorName;
}
public void setOperatorName(String operatorName) {
this.operatorName = operatorName;
}
public String getOperatorCerNo() {
return operatorCerNo;
}
public void setOperatorCerNo(String operatorCerNo) {
this.operatorCerNo = operatorCerNo;
}
public String getOperatorPhone() {
return operatorPhone;
}
public void setOperatorPhone(String operatorPhone) {
this.operatorPhone = operatorPhone;
}
public String getOplocdistrict() {
return oplocdistrict;
}
public void setOplocdistrict(String oplocdistrict) {
this.oplocdistrict = oplocdistrict;
}
public String getUnitNature() {
return unitNature;
}
public void setUnitNature(String unitNature) {
this.unitNature = unitNature;
}
public String getEconomicType() {
return economicType;
}
public void setEconomicType(String economicType) {
this.economicType = economicType;
}
public String getIndustryphy() {
return industryphy;
}
public void setIndustryphy(String industryphy) {
this.industryphy = industryphy;
}
public String getUnitPayDay() {
return unitPayDay;
}
public void setUnitPayDay(String unitPayDay) {
this.unitPayDay = unitPayDay;
}
public String getUnitDepPro() {
return unitDepPro;
}
public void setUnitDepPro(String unitDepPro) {
this.unitDepPro = unitDepPro;
}
public String getPersonalDepPro() {
return personalDepPro;
}
public void setPersonalDepPro(String personalDepPro) {
this.personalDepPro = personalDepPro;
}
@Override
public String toString() {
return "UnitAccountOpeningInformation{" +
"busId='" + busId + '\'' +
", uscc='" + uscc + '\'' +
", entName='" + entName + '\'' +
", dom='" + dom + '\'' +
", estDate='" + estDate + '\'' +
", lerep='" + lerep + '\'' +
", cerType='" + cerType + '\'' +
", cerNo='" + cerNo + '\'' +
", operatorName='" + operatorName + '\'' +
", operatorCerNo='" + operatorCerNo + '\'' +
", operatorPhone='" + operatorPhone + '\'' +
", oplocdistrict='" + oplocdistrict + '\'' +
", unitNature='" + unitNature + '\'' +
", economicType='" + economicType + '\'' +
", industryphy='" + industryphy + '\'' +
", unitPayDay='" + unitPayDay + '\'' +
", unitDepPro='" + unitDepPro + '\'' +
", personalDepPro='" + personalDepPro + '\'' +
'}';
}
}
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