Commit 846fd74d authored by 华润's avatar 华润

内置机本地环境,测试环境,正式环境动态参数配置,方便切换和维护

parent ee24a26a
......@@ -5,6 +5,7 @@ package net.cdkj.gjj.adapter.controller;
import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.domain.BusinessProcessing;
import net.cdkj.gjj.adapter.domain.Json;
import net.cdkj.gjj.adapter.domain.PropertyqUtil;
import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation;
import oracle.jdbc.OracleTypes;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -36,11 +37,16 @@ public class ProvidentFundServicesController {
@ResponseBody
@PostMapping("ProvidentFundServices")
public static String ProvidentFundServices() {
Properties prop = PropertyqUtil.getConfig("application.properties");
JSONObject jsonObject = new JSONObject();
String type= PropertyqUtil.getPropValue( prop ,"timetype");
if("1".equals(type)){//表示正式环境
jsonObject.put("startTime", currenttime(0));//正式环境
jsonObject.put("endTime", currenttime(24));//正式环境
// jsonObject.put("startTime", "20210520 00:00:00");//测试环境
// jsonObject.put("endTime", "20210520 23:00:00");//测试环境
}else if("2".equals(type)){//表示测试环境或本地环境
jsonObject.put("startTime", PropertyqUtil.getPropValue( prop ,"startTime"));//测试环境或本地环境
jsonObject.put("endTime", PropertyqUtil.getPropValue( prop ,"endTime"));//测试环境或本地环境
}
jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
String str = jsonObject.toString();
......@@ -152,6 +158,7 @@ public class ProvidentFundServicesController {
@ResponseBody
@PostMapping("gjjxtfwjk")
public static void gjjxtfwjk() throws Exception {
Properties prop = PropertyqUtil.getConfig("application.properties");
//1.调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,拿到市监返回的开户信息json数据,经过前置机zip解压返回给本内置机处理
String jsoninfom = ProvidentFundServices();
System.out.println("拿到第一个接口返回的第三方数据,准备调第一个存储过程" + jsoninfom);
......@@ -166,7 +173,7 @@ public class ProvidentFundServicesController {
//得到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.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.33:1596:zfgjj", "gjj80", "HG80_Y9E1C5");//正式环境
Connection connection = DriverManager.getConnection(PropertyqUtil.getPropValue( prop ,"url"), PropertyqUtil.getPropValue( prop ,"user"), PropertyqUtil.getPropValue( prop ,"password"));//正式环境
//得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWXX_IMP(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
//调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程
......@@ -476,13 +483,14 @@ public class ProvidentFundServicesController {
@ResponseBody
@PostMapping("zjbmfhywtosj")
public static List<BusinessProcessing> zjbmfhywtosj() throws Exception {
Properties prop = PropertyqUtil.getConfig("application.properties");
//1.调用oracle存储过程,拿到业务办理进度数据
//加载数据库驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//得到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.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.33:1596:zfgjj", "gjj80", "HG80_Y9E1C5");//正式环境
Connection connection = DriverManager.getConnection(PropertyqUtil.getPropValue( prop ,"url"), PropertyqUtil.getPropValue( prop ,"user"), PropertyqUtil.getPropValue( prop ,"password"));//正式环境
//得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_CX(?)}");
//给参数赋值
......@@ -545,13 +553,14 @@ public class ProvidentFundServicesController {
public static void zjbmfhywtosjHX(String uscc, Integer value) throws Exception {
Properties prop = PropertyqUtil.getConfig("application.properties");
//1.调用oracle存储过程,拿到业务办理进度数据
//加载数据库驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//得到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.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.33:1596:zfgjj", "gjj80", "HG80_Y9E1C5");//正式环境
Connection connection = DriverManager.getConnection(PropertyqUtil.getPropValue( prop ,"url"), PropertyqUtil.getPropValue( prop ,"user"), PropertyqUtil.getPropValue( prop ,"password"));//正式环境
//得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_HX(?,?)}");
//给参数赋值
......
package net.cdkj.gjj.adapter.domain;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
/**
* 获取配置文件application.properties里的属性值所用到的工具类
*/
public class PropertyqUtil {
/**
* 读取 classpath 下 指定的properties配置文件,加载到Properties并返回Properties
* @param name 配置文件名,如:mongo.properties
* @return
*/
public static Properties getConfig(String name){
Properties props=null;
try{
props = new Properties();
InputStream in = PropertyqUtil.class.getClassLoader().getResourceAsStream(name);
BufferedReader bf = new BufferedReader(new InputStreamReader(in));
props.load(bf);
in.close();
}catch(Exception ex){
ex.printStackTrace();
}
return props;
}
public static String getPropValue(Properties prop,String key){
if(key == null || "".equals(key.trim())){
return null;
}
String value = prop.getProperty(key);
if(value == null){
return null;
}
value = value.trim();
//判断是否是环境变量配置属性,例如 server.env=${serverEnv:local}
if(value.startsWith("${") && value.endsWith("}") && value.contains(":")){
int indexOfColon = value.indexOf(":");
String envName = value.substring(2,indexOfColon);
//获取系统环境变量 envName 的内容,如果没有找到,则返回defaultValue
String envValue = System.getenv(envName);
if(envValue == null){
//配置的默认值
return value.substring(indexOfColon+1,value.length()-1);
}
return envValue;
}
return value;
}
}
#查询日期类型(1表示正式环境,2表示测试环境或者表示本地环境)
#正式环境用的日期类型(取当天一天的时间)
timetype:1
#测试环境用的日期类型(配置固定日期)
#timetype:2
#测试环境用的起始时间
#startTime:20210520 00:00:00
#测试环境用的起始时间
#endTime:20210520 23:00:00
#数据库(正式环境)
url:jdbc:oracle:thin:@192.168.1.33:1596:zfgjj
user:gjj80
password:HG80_Y9E1C5
#数据库(测试环境)
#url:jdbc:oracle:thin:@192.168.1.36:1521:zfgjj
#user:GJJ80
#password:GJJ80
#数据库(本地环境)
#url:jdbc:oracle:thin:@192.168.101.194:1521:zfgjj
#user:HG2020
#password:HG2020
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