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

代码提交内置机

parent 36972e43
package net.cdkj.gjj.adapter.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.domain.BusinessProcessing;
import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation;
......@@ -17,10 +18,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
......@@ -39,12 +37,11 @@ public class ProvidentFundServicesController {
@ResponseBody
@PostMapping("ProvidentFundServices")
public static String ProvidentFundServices() {
String token = null;
JSONObject jsonObject = new JSONObject();
jsonObject.put("startTime", currenttime(0));
jsonObject.put("endTime", currenttime(24));
jsonObject.put("app_id", "xxxxx");
jsonObject.put("app_secret", "xxxxx");
jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
String str = jsonObject.toString();
StringBuffer sb = new StringBuffer();
HttpURLConnection conn = null;
......@@ -144,6 +141,7 @@ public class ProvidentFundServicesController {
}
/**
* (第一个定时的)
* 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,
*拿到市监返回的开户信息json数据,经过前置机zip解压返回给本内置机处理
* @return
......@@ -155,111 +153,262 @@ public class ProvidentFundServicesController {
String jsoninfom=ProvidentFundServices();
System.out.println(jsoninfom);
//2.内置机处理返回的业务数据,调用oracle存储过程
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);
JSONObject a = JSONObject.parseObject(jsoninfom);
JSONArray jsonArray = (JSONArray)a.get("data");
List<UnitAccountOpeningInformation> bills = (List<UnitAccountOpeningInformation>)JSONArray.parseArray(jsonArray.toString(), UnitAccountOpeningInformation.class);
System.out.println(bills);
//加载数据库驱动
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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
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.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.execute();
//输出结果[第二个参数]
System.out.println(pstm.getString(1));
System.out.println(pstm.getString(22));
System.out.println(pstm.getString(23));
System.out.println(pstm.getString(24));
if(!bills.isEmpty()){
for(UnitAccountOpeningInformation uniInfom:bills){
if(!"".equals(uniInfom.getBusId())&&uniInfom.getBusId()!=null){
pstm.setString(1,uniInfom.getBusId());
}else{
pstm.setString(1,"");
}
if(!"".equals(uniInfom.getUscc())&&uniInfom.getUscc()!=null){
pstm.setString(2,uniInfom.getUscc());
}else{
pstm.setString(2,"");
}
if(!"".equals(uniInfom.getEntName())&&uniInfom.getEntName()!=null){
pstm.setString(3,uniInfom.getEntName());
}else{
pstm.setString(3,"");
}
if(!"".equals(uniInfom.getDom())&&uniInfom.getDom()!=null){
pstm.setString(4,uniInfom.getDom());
}else{
pstm.setString(4,"");
}
if(!"".equals(uniInfom.getEstDate())&&uniInfom.getEstDate()!=null){
pstm.setDate(5,new java.sql.Date(uniInfom.getEstDate().getTime()));
}else{
pstm.setString(5,"");
}
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();
pstm2.close();
connection.close();
}
/**
* 调用oracle存储过程
* @param jsoninfom
* @throws Exception
* 住建部门返回公积金办理进度数据接口方法
*(第二个定时)
* @param
* @param
*/
public static void oracleprocess(String jsoninfom) throws Exception {
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.execute();
//输出结果[第二个参数]
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();
@ResponseBody
@PostMapping("BusinessProcessing")
public static String BusinessProcessing() {
//调oracle存储过程拿到进度推进的数据集合
List<BusinessProcessing> list=null;
try {
list=zjbmfhywtosj();
} catch (Exception e) {
e.printStackTrace();
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("state","1");
if(!list.isEmpty()){
jsonObject.put("timestamp",list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getTime());
}else{
jsonObject.put("timestamp","");
}
if(!list.isEmpty()){
jsonObject.put("busId",list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getBusId());
}else{
jsonObject.put("busId","");
}
jsonObject.put("departCode", "10");
jsonObject.put("nodeList",list);
String str = jsonObject.toString();
StringBuffer sb = new StringBuffer();
HttpURLConnection conn = null;
OutputStream out = null;
try {
// 创建url 资源
URL url = new URL("http://192.168.101.34:8080/FrontEndProcessor/FrontEndProcessor/BusinessProcessing");//调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口
// 创建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(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 {
*/
@ResponseBody
@PostMapping("zjbmfhywtosj")
public static void zjbmfhywtosj() throws Exception{
public static List<BusinessProcessing> zjbmfhywtosj() 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_CX(?,?)}");
CallableStatement pstm=connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_CX(?)}");
//给参数赋值
pstm.setString(1,"914205007146986289");
pstm.registerOutParameter(2, OracleTypes.CURSOR);
// pstm.setString(1,"914205007146986289");
pstm.registerOutParameter(1, OracleTypes.CURSOR);
//执行数据库查询操作
pstm.execute();
//输出结果[第二个参数]
ResultSet rs= (ResultSet)pstm.getObject(2);//此处的2要与存储过程中cursor的问题对应
ResultSet rs= (ResultSet)pstm.getObject(1);//此处的2要与存储过程中cursor的问题对应
List<BusinessProcessing> list=new ArrayList<>();
while(rs.next()){
BusinessProcessing b=new BusinessProcessing();
......@@ -330,7 +479,28 @@ public class ProvidentFundServicesController {
//释放资源
pstm.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 {
private String entName;
private String busId;
public String getBusiLink() {
return busiLink;
}
......@@ -100,6 +102,14 @@ public class BusinessProcessing {
this.entName = entName;
}
public String getBusId() {
return busId;
}
public void setBusId(String busId) {
this.busId = busId;
}
@Override
public String toString() {
return "BusinessProcessing{" +
......@@ -112,6 +122,7 @@ public class BusinessProcessing {
", time=" + time +
", uscc='" + uscc + '\'' +
", 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