Commit 70f38a14 authored by 华润's avatar 华润

代码提交内置机

parent 36972e43
package net.cdkj.gjj.adapter.controller; package net.cdkj.gjj.adapter.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.domain.BusinessProcessing; import net.cdkj.gjj.adapter.domain.BusinessProcessing;
import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation; import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation;
...@@ -17,10 +18,7 @@ import java.sql.Connection; ...@@ -17,10 +18,7 @@ import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/** /**
...@@ -39,12 +37,11 @@ public class ProvidentFundServicesController { ...@@ -39,12 +37,11 @@ public class ProvidentFundServicesController {
@ResponseBody @ResponseBody
@PostMapping("ProvidentFundServices") @PostMapping("ProvidentFundServices")
public static String ProvidentFundServices() { public static String ProvidentFundServices() {
String token = null;
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();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
HttpURLConnection conn = null; HttpURLConnection conn = null;
...@@ -144,6 +141,7 @@ public class ProvidentFundServicesController { ...@@ -144,6 +141,7 @@ public class ProvidentFundServicesController {
} }
/** /**
* (第一个定时的)
* 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口, * 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,
*拿到市监返回的开户信息json数据,经过前置机zip解压返回给本内置机处理 *拿到市监返回的开户信息json数据,经过前置机zip解压返回给本内置机处理
* @return * @return
...@@ -155,111 +153,262 @@ public class ProvidentFundServicesController { ...@@ -155,111 +153,262 @@ public class ProvidentFundServicesController {
String jsoninfom=ProvidentFundServices(); String jsoninfom=ProvidentFundServices();
System.out.println(jsoninfom); System.out.println(jsoninfom);
//2.内置机处理返回的业务数据,调用oracle存储过程 //2.内置机处理返回的业务数据,调用oracle存储过程
JSONObject jsonObj = JSONObject.parseObject(jsoninfom); JSONObject a = JSONObject.parseObject(jsoninfom);
String str=jsonObj.get("data").toString(); JSONArray jsonArray = (JSONArray)a.get("data");
String str1=str.replace("[",""); List<UnitAccountOpeningInformation> bills = (List<UnitAccountOpeningInformation>)JSONArray.parseArray(jsonArray.toString(), UnitAccountOpeningInformation.class);
String str2=str1.replace("]",""); System.out.println(bills);
UnitAccountOpeningInformation uniInfom = JSONObject.parseObject(str2,UnitAccountOpeningInformation.class);
System.out.println(uniInfom);
//加载数据库驱动 //加载数据库驱动
Class.forName("oracle.jdbc.driver.OracleDriver"); Class.forName("oracle.jdbc.driver.OracleDriver");
//得到Connection连接 //得到Connection连接
Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020"); Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");
//得到预编译的Statement对象 //得到预编译的Statement对象
CallableStatement pstm=connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_SL(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); CallableStatement pstm=connection.prepareCall("{call JGJ_KSYW_DWKH.DWXX_IMP(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
//调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程
CallableStatement pstm2=connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_SAVE()}");
//给参数赋值 //给参数赋值
// pstm.getString(1); // pstm.getString(1);
pstm.registerOutParameter(1,oracle.jdbc.OracleTypes.VARCHAR); if(!bills.isEmpty()){
pstm.setString(2,uniInfom.getBusId()); for(UnitAccountOpeningInformation uniInfom:bills){
pstm.setString(3,uniInfom.getUscc()); if(!"".equals(uniInfom.getBusId())&&uniInfom.getBusId()!=null){
pstm.setString(4,uniInfom.getEntName()); pstm.setString(1,uniInfom.getBusId());
pstm.setString(5,uniInfom.getDom()); }else{
pstm.setDate(6,new java.sql.Date(uniInfom.getEstDate().getTime())); pstm.setString(1,"");
pstm.setString(7,uniInfom.getLerep()); }
pstm.setString(8,uniInfom.getCerType());
pstm.setString(9,uniInfom.getCerNo()); if(!"".equals(uniInfom.getUscc())&&uniInfom.getUscc()!=null){
pstm.setString(10,uniInfom.getOperatorName()); pstm.setString(2,uniInfom.getUscc());
pstm.setString(11,uniInfom.getOperatorCerNo()); }else{
pstm.setString(12,uniInfom.getOperatorPhone()); pstm.setString(2,"");
pstm.setString(13,uniInfom.getOplocdistrict()); }
pstm.setString(14,uniInfom.getUnitNature());
pstm.setString(15,uniInfom.getEconomicType()); if(!"".equals(uniInfom.getEntName())&&uniInfom.getEntName()!=null){
pstm.setString(16,uniInfom.getIndustryphy()); pstm.setString(3,uniInfom.getEntName());
pstm.setString(17,uniInfom.getUnitPayDay()); }else{
pstm.setString(18,uniInfom.getUnitDepPro()); pstm.setString(3,"");
pstm.setString(19,uniInfom.getPersonalDepPro()); }
pstm.setString(20,"");
pstm.setString(21,""); if(!"".equals(uniInfom.getDom())&&uniInfom.getDom()!=null){
pstm.registerOutParameter(22,oracle.jdbc.OracleTypes.VARCHAR); pstm.setString(4,uniInfom.getDom());
pstm.registerOutParameter(23,oracle.jdbc.OracleTypes.VARCHAR); }else{
pstm.registerOutParameter(24,oracle.jdbc.OracleTypes.VARCHAR); pstm.setString(4,"");
//执行数据库查询操作 }
pstm.execute();
//输出结果[第二个参数] if(!"".equals(uniInfom.getEstDate())&&uniInfom.getEstDate()!=null){
System.out.println(pstm.getString(1)); pstm.setDate(5,new java.sql.Date(uniInfom.getEstDate().getTime()));
System.out.println(pstm.getString(22)); }else{
System.out.println(pstm.getString(23)); pstm.setString(5,"");
System.out.println(pstm.getString(24)); }
if(!"".equals(uniInfom.getLerep())&&uniInfom.getLerep()!=null){
pstm.setString(6,uniInfom.getLerep());
}else{
pstm.setString(6,"");
}
if(!"".equals(uniInfom.getCerType())&&uniInfom.getCerType()!=null){
pstm.setString(7,uniInfom.getCerType());
}else{
pstm.setString(7,"");
}
if(!"".equals(uniInfom.getCerNo())&&uniInfom.getCerNo()!=null){
pstm.setString(8,uniInfom.getCerNo());
}else{
pstm.setString(8,"");
}
if(!"".equals(uniInfom.getOperatorName())&&uniInfom.getOperatorName()!=null){
pstm.setString(9,uniInfom.getOperatorName());
}else{
pstm.setString(9,"");
}
if(!"".equals(uniInfom.getOperatorCerNo())&&uniInfom.getOperatorCerNo()!=null){
pstm.setString(10,uniInfom.getOperatorCerNo());
}else{
pstm.setString(10,"");
}
if(!"".equals(uniInfom.getOperatorPhone())&&uniInfom.getOperatorPhone()!=null){
pstm.setString(11,uniInfom.getOperatorPhone());
}else{
pstm.setString(11,"");
}
if(!"".equals(uniInfom.getOplocdistrict())&&uniInfom.getOplocdistrict()!=null){
pstm.setString(12,uniInfom.getOplocdistrict());
}else{
pstm.setString(12,"");
}
if(!"".equals(uniInfom.getUnitNature())&&uniInfom.getUnitNature()!=null){
pstm.setString(13,uniInfom.getUnitNature());
}else{
pstm.setString(13,"");
}
if(!"".equals(uniInfom.getEconomicType())&&uniInfom.getEconomicType()!=null){
pstm.setString(14,uniInfom.getEconomicType());
}else{
pstm.setString(14,"");
}
if(!"".equals(uniInfom.getIndustryphy())&&uniInfom.getIndustryphy()!=null){
pstm.setString(15,uniInfom.getIndustryphy());
}else{
pstm.setString(15,"");
}
if(!"".equals(uniInfom.getUnitPayDay())&&uniInfom.getUnitPayDay()!=null){
pstm.setString(16,uniInfom.getUnitPayDay());
}else{
pstm.setString(16,"");
}
if(!"".equals(uniInfom.getUnitDepPro())&&uniInfom.getUnitDepPro()!=null){
pstm.setString(17,uniInfom.getUnitDepPro());
}else{
pstm.setString(17,"");
}
if(!"".equals(uniInfom.getPersonalDepPro())&&uniInfom.getPersonalDepPro()!=null){
pstm.setString(18,uniInfom.getPersonalDepPro());
}else{
pstm.setString(18,"");
}
pstm.registerOutParameter(19,oracle.jdbc.OracleTypes.VARCHAR);
pstm.registerOutParameter(20,oracle.jdbc.OracleTypes.VARCHAR);
//执行数据库查询操作
pstm.execute();
//输出结果[第二个参数]
System.out.println(pstm.getString(19));
System.out.println(pstm.getString(20));
if("".equals(pstm.getString(19))||pstm.getString(19)==null){
break;
}else{
try {
// 避免批量插入高并发,此处设置每次停顿5秒
Thread.currentThread().sleep(2000);
System.out.println("间隔2秒传一条数据调一次存储过程");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
pstm2.execute();
}
//释放资源 //释放资源
pstm.close(); pstm.close();
pstm2.close();
connection.close(); connection.close();
} }
/** /**
* 调用oracle存储过程 * 住建部门返回公积金办理进度数据接口方法
* @param jsoninfom *(第二个定时)
* @throws Exception * @param
* @param
*/ */
public static void oracleprocess(String jsoninfom) throws Exception { @ResponseBody
JSONObject jsonObj = JSONObject.parseObject(jsoninfom); @PostMapping("BusinessProcessing")
String str=jsonObj.get("data").toString(); public static String BusinessProcessing() {
String str1=str.replace("[",""); //调oracle存储过程拿到进度推进的数据集合
String str2=str1.replace("]",""); List<BusinessProcessing> list=null;
UnitAccountOpeningInformation uniInfom = JSONObject.parseObject(str2,UnitAccountOpeningInformation.class); try {
System.out.println(uniInfom); list=zjbmfhywtosj();
//加载数据库驱动 } catch (Exception e) {
Class.forName("oracle.jdbc.driver.OracleDriver"); e.printStackTrace();
//得到Connection连接 }
Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020"); JSONObject jsonObject = new JSONObject();
//得到预编译的Statement对象 jsonObject.put("state","1");
CallableStatement pstm=connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_SL(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); if(!list.isEmpty()){
//给参数赋值 jsonObject.put("timestamp",list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getTime());
// pstm.getString(1); }else{
pstm.registerOutParameter(1,oracle.jdbc.OracleTypes.VARCHAR); jsonObject.put("timestamp","");
pstm.setString(2,uniInfom.getBusId()); }
pstm.setString(3,uniInfom.getUscc());
pstm.setString(4,uniInfom.getEntName()); if(!list.isEmpty()){
pstm.setString(5,uniInfom.getDom()); jsonObject.put("busId",list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getBusId());
pstm.setDate(6,new java.sql.Date(uniInfom.getEstDate().getTime())); }else{
pstm.setString(7,uniInfom.getLerep()); jsonObject.put("busId","");
pstm.setString(8,uniInfom.getCerType()); }
pstm.setString(9,uniInfom.getCerNo()); jsonObject.put("departCode", "10");
pstm.setString(10,uniInfom.getOperatorName()); jsonObject.put("nodeList",list);
pstm.setString(11,uniInfom.getOperatorCerNo()); String str = jsonObject.toString();
pstm.setString(12,uniInfom.getOperatorPhone()); StringBuffer sb = new StringBuffer();
pstm.setString(13,uniInfom.getOplocdistrict()); HttpURLConnection conn = null;
pstm.setString(14,uniInfom.getUnitNature()); OutputStream out = null;
pstm.setString(15,uniInfom.getEconomicType()); try {
pstm.setString(16,uniInfom.getIndustryphy()); // 创建url 资源
pstm.setString(17,uniInfom.getUnitPayDay()); URL url = new URL("http://192.168.101.34:8080/FrontEndProcessor/FrontEndProcessor/BusinessProcessing");//调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口
pstm.setString(18,uniInfom.getUnitDepPro()); // 创建http 连接
pstm.setString(19,uniInfom.getPersonalDepPro()); conn = (HttpURLConnection) url.openConnection();
pstm.setString(20,""); // 设置允许输出
pstm.setString(21,""); conn.setDoOutput(true);
pstm.registerOutParameter(22,oracle.jdbc.OracleTypes.VARCHAR); // 设置允许输入
pstm.registerOutParameter(23,oracle.jdbc.OracleTypes.VARCHAR); conn.setDoInput(true);
pstm.registerOutParameter(24,oracle.jdbc.OracleTypes.VARCHAR); // 设置不使用缓存
//执行数据库查询操作 conn.setUseCaches(false);
pstm.execute(); // 设置传递方式
//输出结果[第二个参数] conn.setRequestMethod("POST");
System.out.println(pstm.getString(1)); // 设置维持长连接
System.out.println(pstm.getString(22)); conn.setRequestProperty("Connection", "Keep-Alive");
System.out.println(pstm.getString(23)); // 设置文件类型:
System.out.println(pstm.getString(24)); conn.setRequestProperty("Content-Type", "application/json");
//释放资源 // 设置文件字符集:
pstm.close(); conn.setRequestProperty("Charset", "UTF-8");
connection.close(); // 转换为字节数组
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(sb.toString());
String uscc=list.get(0).getUscc();
System.out.println(uscc);
JSONObject jsonObj= JSONObject.parseObject(sb.toString());
String success= jsonObj.getString("success");
Boolean value=Boolean.getBoolean(success);
try {
zjbmfhywtosjHX(uscc,value);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(value);
return sb.toString();
} 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;
} }
/** /**
...@@ -270,21 +419,21 @@ public class ProvidentFundServicesController { ...@@ -270,21 +419,21 @@ public class ProvidentFundServicesController {
*/ */
@ResponseBody @ResponseBody
@PostMapping("zjbmfhywtosj") @PostMapping("zjbmfhywtosj")
public static void zjbmfhywtosj() throws Exception{ public static List<BusinessProcessing> zjbmfhywtosj() throws Exception{
//1.调用oracle存储过程,拿到业务办理进度数据 //1.调用oracle存储过程,拿到业务办理进度数据
//加载数据库驱动 //加载数据库驱动
Class.forName("oracle.jdbc.driver.OracleDriver"); Class.forName("oracle.jdbc.driver.OracleDriver");
//得到Connection连接 //得到Connection连接
Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020"); Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");
//得到预编译的Statement对象 //得到预编译的Statement对象
CallableStatement pstm=connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_CX(?,?)}"); CallableStatement pstm=connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_CX(?)}");
//给参数赋值 //给参数赋值
pstm.setString(1,"914205007146986289"); // pstm.setString(1,"914205007146986289");
pstm.registerOutParameter(2, OracleTypes.CURSOR); pstm.registerOutParameter(1, OracleTypes.CURSOR);
//执行数据库查询操作 //执行数据库查询操作
pstm.execute(); pstm.execute();
//输出结果[第二个参数] //输出结果[第二个参数]
ResultSet rs= (ResultSet)pstm.getObject(2);//此处的2要与存储过程中cursor的问题对应 ResultSet rs= (ResultSet)pstm.getObject(1);//此处的2要与存储过程中cursor的问题对应
List<BusinessProcessing> list=new ArrayList<>(); List<BusinessProcessing> list=new ArrayList<>();
while(rs.next()){ while(rs.next()){
BusinessProcessing b=new BusinessProcessing(); BusinessProcessing b=new BusinessProcessing();
...@@ -330,7 +479,28 @@ public class ProvidentFundServicesController { ...@@ -330,7 +479,28 @@ public class ProvidentFundServicesController {
//释放资源 //释放资源
pstm.close(); pstm.close();
connection.close(); connection.close();
return list;
} }
public static void zjbmfhywtosjHX(String uscc,Boolean value) throws Exception{
//1.调用oracle存储过程,拿到业务办理进度数据
//加载数据库驱动
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_HX(?,?)}");
//给参数赋值
pstm.setString(1,uscc);
pstm.setBoolean(2,value);
// pstm.registerOutParameter(1, OracleTypes.CURSOR);
//执行数据库查询操作
pstm.execute();
//输出结果[第二个参数]
//释放资源
pstm.close();
connection.close();
}
} }
...@@ -28,6 +28,8 @@ public class BusinessProcessing { ...@@ -28,6 +28,8 @@ public class BusinessProcessing {
private String entName; private String entName;
private String busId;
public String getBusiLink() { public String getBusiLink() {
return busiLink; return busiLink;
} }
...@@ -100,6 +102,14 @@ public class BusinessProcessing { ...@@ -100,6 +102,14 @@ public class BusinessProcessing {
this.entName = entName; this.entName = entName;
} }
public String getBusId() {
return busId;
}
public void setBusId(String busId) {
this.busId = busId;
}
@Override @Override
public String toString() { public String toString() {
return "BusinessProcessing{" + return "BusinessProcessing{" +
...@@ -112,6 +122,7 @@ public class BusinessProcessing { ...@@ -112,6 +122,7 @@ public class BusinessProcessing {
", time=" + time + ", time=" + time +
", uscc='" + uscc + '\'' + ", uscc='" + uscc + '\'' +
", entName='" + entName + '\'' + ", entName='" + entName + '\'' +
", busId='" + busId + '\'' +
'}'; '}';
} }
} }
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