Commit 5e707c49 authored by 张俊's avatar 张俊

单位变更开发,框架优化处理

parent d7abe822
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
......@@ -5,7 +5,7 @@
<groupId>net.cdkj.gjj</groupId>
<artifactId>InternalLogic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<packaging>jar</packaging>
<name>InternalLogic</name>
<description>Demo project for Spring Boot</description>
......@@ -21,35 +21,22 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.sf.json-lib</groupId>-->
<!-- <artifactId>json-lib</artifactId>-->
<!-- <version>2.4</version>-->
<!-- <classifier>jdk15</classifier>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>net.sf.json-lib</groupId>-->
<!-- <artifactId>json-lib</artifactId>-->
<!-- <version>2.4</version>-->
<!-- <classifier>jdk15</classifier>-->
<!-- </dependency>-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
......@@ -60,6 +47,7 @@
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>
<repositories>
......
......@@ -2,6 +2,8 @@ package net.cdkj.gjj.adapter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@SpringBootApplication
public class InternalLogicApplication {
......
package net.cdkj.gjj.adapter;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(InternalLogicApplication.class);
}
}
package net.cdkj.gjj.adapter.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.util.Properties;
/**
* druid 配置多数据源
*
* @author ruoyi
*/
@Configuration
public class DruidConfig {
@Value("${driverClassName:oracle.jdbc.driver.OracleDriver}")
private String driverClassName;
@Value("${url}")
private String url;
@Value("${user}")
private String username;
@Value("${password}")
private String password;
@Bean
public DruidDataSource druidDataSource() {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(driverClassName);
druidDataSource.setUrl(url);
druidDataSource.setUsername(username);
druidDataSource.setPassword(password);
return druidDataSource;
}
}
package net.cdkj.gjj.adapter.encryptor;
package net.cdkj.gjj.adapter.config;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
......@@ -35,10 +35,5 @@ public class JasyptConfig {
return encryptor;
}
public static String encryptStr(String decryptStr) {
StringEncryptor encryptor = new JasyptConfig().stringEncryptor();
return encryptor.decrypt(decryptStr);
}
}
package net.cdkj.gjj.adapter.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -9,6 +10,8 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.RestTemplate;
import javax.sql.DataSource;
/**
* 把RestTemplate注入Spring IOC容器
*
......@@ -36,4 +39,7 @@ public class RestTemplateConfig {
});
return restTemplate;
}
}
\ No newline at end of file
package net.cdkj.gjj.adapter.controller;
import net.cdkj.gjj.adapter.utils.InternalUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
......@@ -20,39 +24,49 @@ import java.util.Date;
//@Async
public class AlarmTask {
private static final Logger log = LoggerFactory.getLogger(DeptInfoUpdateController.class);
//系统服务定时器
@Resource
private DeptInfoUpdateController deptInfoUpdateController;
@Resource
private ProvidentFundServicesController providentFundServicesController;
/**
* 第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次
*/
@Scheduled(initialDelay = 5 * 1000, fixedDelay = 60 * 1000)
// @Scheduled(initialDelay = 5 * 1000, fixedDelay = 60 * 1000)
public void run3() {
String dqsj = "";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
dqsj = sdf.format(dt);
System.out.println("第一个接口开始时间" + dqsj);
log.debug("第一个接口开始时间:{}", InternalUtils.getCurrentTime());
try {
ProvidentFundServicesController.gjjxtfwjk();
providentFundServicesController.gjjxtfwjk();
} catch (Exception e) {
e.printStackTrace();
}
}
//进度数据定时器
// 进度数据定时器
/**
* 第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次
*/
@Scheduled(initialDelay = 20 * 1000, fixedDelay = 60 * 1000)
// @Scheduled(initialDelay = 20 * 1000, fixedDelay = 60 * 1000)
public void run4() {
String dqsj = "";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
dqsj = sdf.format(dt);
System.out.println("第二个接口开始时间" + dqsj);
ProvidentFundServicesController.BusinessProcessing();
log.debug("第二个接口开始时间:{}", InternalUtils.getCurrentTime());
providentFundServicesController.BusinessProcessing();
}
@Scheduled(initialDelay = 40 * 1000, fixedDelay = 60 * 1000)
public void dwxxbgPushTask() {
log.debug("dwxxbgPushTask 开始时间:{}", InternalUtils.getCurrentTime());
deptInfoUpdateController.dwxxbgPush();
}
@Scheduled(initialDelay = 60 * 1000, fixedDelay = 60 * 1000)
public void dwxxbgPullTask() {
log.debug("dwxxbgPullTask 开始时间:{}", InternalUtils.getCurrentTime());
deptInfoUpdateController.dwxxbgPull();
}
}
package net.cdkj.gjj.adapter.controller;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSON;
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 net.cdkj.gjj.adapter.encryptor.JasyptConfig;
import net.cdkj.gjj.adapter.domain.*;
import net.cdkj.gjj.adapter.utils.InternalUtils;
import oracle.jdbc.OracleTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -22,9 +21,12 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.*;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Properties;
/**
......@@ -37,22 +39,20 @@ public class DeptInfoUpdateController {
@Resource
private RestTemplate restTemplate;
@Resource
private DruidDataSource druidDataSource;
private static String url;
private static String user;
private static String password;
private static String frontEndProcessorServer;
@Value("${frontEndProcessorServer}")
private String frontEndProcessorServer;
@Value("${timetype}")
private String timetype;
static {
Properties prop = PropertyqUtil.getConfig("application.properties");
url = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "url"));
user = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "user"));
password = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "password"));
frontEndProcessorServer = PropertyqUtil.getPropValue(prop, "frontEndProcessorServer");
}
@Value("${startTime}")
private String startTime;
@Value("${endTime}")
private String endTime;
private static final Logger log = LoggerFactory.getLogger(DeptInfoUpdateController.class);
......@@ -65,15 +65,13 @@ public class DeptInfoUpdateController {
@ResponseBody
@PostMapping("/getDwxxbgHttp")
public String getDwxxbgHttp() {
Properties prop = PropertyqUtil.getConfig("application.properties");
JSONObject jsonObject = new JSONObject();
String type = PropertyqUtil.getPropValue(prop, "timetype");
if ("1".equals(type)) {// 表示正式环境
if ("1".equals(timetype)) {// 表示正式环境
jsonObject.put("startTime", InternalUtils.currentTime(0));// 正式环境
jsonObject.put("endTime", InternalUtils.currentTime(24));// 正式环境
} else if ("2".equals(type)) {// 表示测试环境或本地环境
jsonObject.put("startTime", PropertyqUtil.getPropValue(prop, "startTime"));// 测试环境或本地环境
jsonObject.put("endTime", PropertyqUtil.getPropValue(prop, "endTime"));// 测试环境或本地环境
} else if ("2".equals(timetype)) {// 表示测试环境或本地环境
jsonObject.put("startTime", startTime);// 测试环境或本地环境
jsonObject.put("endTime", endTime);// 测试环境或本地环境
}
jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
......@@ -85,7 +83,6 @@ public class DeptInfoUpdateController {
}
/**
* (第一个定时的)
* 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,
......@@ -95,29 +92,32 @@ public class DeptInfoUpdateController {
*/
@ResponseBody
@PostMapping("/dwxxbgPull")
public void dwxxbgPull() throws Exception {
public AjaxResult dwxxbgPull() {
// 1.调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,拿到市监返回的开户信息json数据,经过前置机zip解压返回给本内置机处理
String dwxxbgHttp = getDwxxbgHttp();
// String dwxxbgHttp = mockDwxxbgHttp();
log.info("拿到第一个接口返回的第三方数据:{}", dwxxbgHttp);
Json jsonentity = JSONObject.parseObject(dwxxbgHttp, Json.class);
List<UnitAccountOpeningInformation> bills = null;
if (!InternalUtils.isNullOrEmpty(jsonentity)) {
bills = jsonentity.getData();
}
if (!CollectionUtils.isEmpty(bills)) {
if (CollectionUtils.isEmpty(bills)) {
log.info("第三方返回的报文中data数据为空!");
return AjaxResult.success("第三方返回的报文中data数据为空", null);
}
// 2.内置机处理返回的业务数据,调用oracle存储过程
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection(url, user, password);
Connection connection = null;
CallableStatement dwxxbgImp = null;
CallableStatement dwxxbgSave = null;
try {
connection = druidDataSource.getConnection();
// 得到预编译的Statement对象
CallableStatement dwxxbgImp = connection.prepareCall("{call JGJ_KSYW_DWXXBG.DWXXBG_IMP(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}");
dwxxbgImp = connection.prepareCall("{call JGJ_KSYW_DWXXBG.DWXXBG_IMP(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}");
// 循环插入
for (UnitAccountOpeningInformation uniInfom : bills) {
if (!StringUtils.isEmpty(uniInfom.getOplocdistrict())) {
System.out.println("oplocdistrict" + "在规定的值里面,调imp过程");
// 业务标识
String busId = StringUtils.hasText(uniInfom.getBusId()) ? uniInfom.getBusId() : "";
dwxxbgImp.setString(1, busId);
......@@ -168,29 +168,66 @@ public class DeptInfoUpdateController {
dwxxbgImp.registerOutParameter(17, OracleTypes.VARCHAR);
// 执行数据库查询操作
dwxxbgImp.execute();
//获取出参
// 获取出参
String errcode = dwxxbgImp.getString(16);
//String errmsg = dwxxbgImp.getString(17);
String errmsg = dwxxbgImp.getString(17);
log.info("DWXXBG_IMP 执行结果 errcode:{},errmsg :{}", errcode, errmsg);
if (StringUtils.isEmpty(errcode)) {
break;
log.error("DWXXBG_IMP 执行结果 errcode:{},errmsg :{},对应数据为:{}", errcode, errmsg, JSON.toJSONString(uniInfom));
continue;
} else {
try {
// 避免批量插入高并发,此处设置每次停顿5秒
Thread.currentThread().sleep(2000);
System.out.println("间隔2秒传一条数据调一次存储过程");
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
}
}
}
}
// 调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程
CallableStatement dwxxbgSave = connection.prepareCall("{call JGJ_KSYW_DWXXBG.DWXXBG_SAVE()}");
dwxxbgSave = connection.prepareCall("{call JGJ_KSYW_DWXXBG.DWXXBG_SAVE()}");
dwxxbgSave.execute();
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
// 释放资源
try {
dwxxbgImp.close();
dwxxbgSave.close();
connection.close();
} catch (SQLException e) {
log.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
return AjaxResult.success("请求成功", null);
}
/**
* 模拟数据
*
* @return
*/
private static String mockDwxxbgHttp() {
List<UnitAccountOpeningInformation> informationList = new ArrayList<>();
UnitAccountOpeningInformation information = new UnitAccountOpeningInformation();
information.setBusId("2");
information.setUscc("91421122MAC7ANQB8C");
information.setEntName("红安县永利土石方工程有限公司");
information.setDom("湖北省黄冈市红安县高桥镇长扬路东端北侧119号");
information.setLerep("吴永利");
information.setCerType("10");
information.setCerNo("422123197810295851");
information.setOperatorName("吴永利");
information.setOperatorCerNo("422123197810295851");
information.setOperatorPhone("13872001037");
information.setOplocdistrict("421122");
information.setUnitNature("A313");
information.setEconomicType("1");
information.setIndustryphy("E");
information.setUnitPayDay("1");
informationList.add(information);
Json json = new Json();
json.setData(informationList);
String dwxxbgHttp = JSONObject.toJSONString(json);
return dwxxbgHttp;
}
......@@ -204,17 +241,11 @@ public class DeptInfoUpdateController {
@ResponseBody
@PostMapping("/dwxxbgPush")
public String dwxxbgPush() {
System.out.println("调第二个接口了");
// 调oracle存储过程拿到进度推进的数据集合
List<BusinessProcessing> collDwxxbgList = null;
try {
collDwxxbgList = collDwxxbg();
} catch (Exception e) {
log.info("调用 DWXXBG_CX 异常:{}", e);
}
List<BusinessProcessing> collDwxxbgList = collDwxxbg();
JSONObject jsonObject = new JSONObject();
jsonObject.put("state", "1");
if (!collDwxxbgList.isEmpty()) {
if (!CollectionUtils.isEmpty(collDwxxbgList)) {
jsonObject.put("timestamp", collDwxxbgList.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getTime());
jsonObject.put("busId", collDwxxbgList.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getBusId());
} else {
......@@ -228,22 +259,13 @@ public class DeptInfoUpdateController {
String businessprocessingUrl = frontEndProcessorServer + "/FrontEndProcessor/FrontEndProcessor/BusinessProcessing";
//(测试环境)调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口
String forObject = restTemplate.postForObject(businessprocessingUrl, str, String.class);
// 请求返回的数据
log.info("前置机返回第三方解压之后的进度推送结果:{}", forObject);
String uscc = "";
if (!collDwxxbgList.isEmpty()) {
uscc = collDwxxbgList.get(0).getUscc();
}
JSONObject jsonObj = JSONObject.parseObject(forObject);
Integer value = "true".equals(jsonObj.getString("success")) ? 1 : 0;
try {
String uscc = !CollectionUtils.isEmpty(collDwxxbgList) ? collDwxxbgList.get(0).getUscc() : "";
log.info("入参 uscc:{} value:{}", uscc, value);
collDwxxbgHx(uscc, value);
} catch (Exception e) {
log.error("调用 DWXXBG_HX 过程异常:{}", e);
}
return forObject;
}
/**
......@@ -254,19 +276,20 @@ public class DeptInfoUpdateController {
*/
@ResponseBody
@PostMapping("/collDwxxbg")
public static List<BusinessProcessing> collDwxxbg() throws Exception {
public List<BusinessProcessing> collDwxxbg() {
List<BusinessProcessing> list = new ArrayList<>();
Connection connection = null;
CallableStatement dwxxbgCx = null;
ResultSet rs = null;
try {
// 1.调用oracle存储过程,拿到业务办理进度数据
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection(url, user, password);
connection = druidDataSource.getConnection();
// 调用过程,返回企业注册的审核信息
CallableStatement dwxxbgCx = connection.prepareCall("{call JGJ_KSYW_DWXXBG.DWXXBG_CX(?)}");
// 给参数赋值
dwxxbgCx = connection.prepareCall("{call JGJ_KSYW_DWXXBG.DWXXBG_CX(?)}");
dwxxbgCx.registerOutParameter(1, OracleTypes.CURSOR);
// 执行数据库查询操作
dwxxbgCx.execute();
// 输出结果[第二个参数]
ResultSet rs = (ResultSet) dwxxbgCx.getObject(1);// 此处的2要与存储过程中cursor的问题对应
List<BusinessProcessing> list = new ArrayList<>();
rs = (ResultSet) dwxxbgCx.getObject(1);// 此处的2要与存储过程中cursor的问题对应
while (rs.next()) {
BusinessProcessing bp = new BusinessProcessing();
if (StringUtils.hasText(rs.getString(1))) {
......@@ -302,27 +325,45 @@ public class DeptInfoUpdateController {
list.add(bp);
}
log.info("调用 DWXXBG_CX 返回数据:{}", JSONObject.toJSONString(list));
} catch (Exception e) {
log.error("调用 DWXXBG_CX 异常:{}", e);
} finally {
// 释放资源
try {
rs.close();
dwxxbgCx.close();
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return list;
}
public static void collDwxxbgHx(String uscc, Integer value) throws Exception {
public void collDwxxbgHx(String uscc, Integer value) {
Connection connection = null;
CallableStatement pstm = null;
// 1.调用oracle存储过程,拿到业务办理进度数据
try {
// 加载数据库驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection(url, user, password);// 正式环境
connection = druidDataSource.getConnection();
// 得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWXXBG.DWXXBG_HX(?,?)}");
// 给参数赋值
pstm = connection.prepareCall("{call JGJ_KSYW_DWXXBG.DWXXBG_HX(?,?)}");
pstm.setString(1, uscc);
pstm.setInt(2, value);
pstm.execute();
} catch (Exception e) {
log.error("调用 DWXXBG_HX 过程异常:{}", e);
} finally {
// 释放资源
try {
pstm.close();
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}
package net.cdkj.gjj.adapter.encryptor;
package net.cdkj.gjj.adapter.controller;
import net.cdkj.gjj.adapter.config.JasyptConfig;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@RequestMapping("/encrypt")
@CrossOrigin(origins = "*", maxAge = 3600)
public class EncryptController {
@Resource
private StringEncryptor jasyptStringEncryptor;
@PostMapping("/jasyptEnc")
public String encrypt(@RequestParam String encStr) throws Exception {
StringEncryptor encryptor = new JasyptConfig().stringEncryptor();
return encryptor.encrypt(encStr);
public String encrypt(@RequestParam String encStr) {
return jasyptStringEncryptor.encrypt(encStr);
}
@PostMapping("/jasyptDec")
public String decrypt(@RequestParam String decStr) throws Exception {
StringEncryptor encryptor = new JasyptConfig().stringEncryptor();
return encryptor.decrypt(decStr);
public String decrypt(@RequestParam String decStr) {
return jasyptStringEncryptor.decrypt(decStr);
}
}
package net.cdkj.gjj.adapter.controller;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.encryptor.JasyptConfig;
import net.cdkj.gjj.adapter.config.JasyptConfig;
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.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
......@@ -31,19 +35,22 @@ import java.util.*;
@RequestMapping(value = "InternalLogic")
public class ProvidentFundServicesController {
private static String url;
private static String user;
private static String password;
private static String frontEndProcessorServer;
@Resource
private DruidDataSource dataSource;
@Value("${frontEndProcessorServer}")
private String frontEndProcessorServer;
@Value("${timetype}")
private String timetype;
@Value("${startTime}")
private String startTime;
@Value("${endTime}")
private String endTime;
static {
Properties prop = PropertyqUtil.getConfig("application.properties");
url = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "url"));
user = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "user"));
password = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "password"));
frontEndProcessorServer = PropertyqUtil.getPropValue(prop, "frontEndProcessorServer");
}
/**
* 公积金系统服务接口内置机调前置机中间接口
......@@ -53,16 +60,15 @@ public class ProvidentFundServicesController {
*/
@ResponseBody
@PostMapping("ProvidentFundServices")
public static String ProvidentFundServices() {
public String ProvidentFundServices() {
Properties prop = PropertyqUtil.getConfig("application.properties");
JSONObject jsonObject = new JSONObject();
String type = PropertyqUtil.getPropValue(prop, "timetype");
if ("1".equals(type)) {// 表示正式环境
if ("1".equals(timetype)) {// 表示正式环境
jsonObject.put("startTime", currenttime(0));// 正式环境
jsonObject.put("endTime", currenttime(24));// 正式环境
} else if ("2".equals(type)) {// 表示测试环境或本地环境
jsonObject.put("startTime", PropertyqUtil.getPropValue(prop, "startTime"));// 测试环境或本地环境
jsonObject.put("endTime", PropertyqUtil.getPropValue(prop, "endTime"));// 测试环境或本地环境
} else if ("2".equals(timetype)) {// 表示测试环境或本地环境
jsonObject.put("startTime", startTime);// 测试环境或本地环境
jsonObject.put("endTime", endTime);// 测试环境或本地环境
}
jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
......@@ -174,7 +180,7 @@ public class ProvidentFundServicesController {
*/
@ResponseBody
@PostMapping("gjjxtfwjk")
public static void gjjxtfwjk() throws Exception {
public void gjjxtfwjk() throws Exception {
Properties prop = PropertyqUtil.getConfig("application.properties");
// 1.调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,拿到市监返回的开户信息json数据,经过前置机zip解压返回给本内置机处理
String jsoninfom = ProvidentFundServices();
......@@ -186,11 +192,7 @@ public class ProvidentFundServicesController {
}
// 2.内置机处理返回的业务数据,调用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(url, user, password);// 正式环境
Connection connection = dataSource.getConnection();
// 得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWXX_IMP(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
// 调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程
......@@ -393,7 +395,7 @@ public class ProvidentFundServicesController {
*/
@ResponseBody
@PostMapping("BusinessProcessing")
public static String BusinessProcessing() {
public String BusinessProcessing() {
System.out.println("调第二个接口了");
// 调oracle存储过程拿到进度推进的数据集合
List<BusinessProcessing> list = null;
......@@ -515,15 +517,10 @@ public class ProvidentFundServicesController {
*/
@ResponseBody
@PostMapping("zjbmfhywtosj")
public static List<BusinessProcessing> zjbmfhywtosj() throws Exception {
public 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(url, user, password);// 正式环境
Connection connection = dataSource.getConnection();
// 得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_CX(?)}");
// 给参数赋值
......@@ -585,15 +582,11 @@ public class ProvidentFundServicesController {
}
public static void zjbmfhywtosjHX(String uscc, Integer value) throws Exception {
public 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(url, user, password);// 正式环境
Connection connection = dataSource.getConnection();
// 得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_HX(?,?)}");
// 给参数赋值
......
package net.cdkj.gjj.adapter.domain;
import org.springframework.http.HttpStatus;
import java.util.HashMap;
/**
* 操作消息提醒
*
* @author ruoyi
*/
public class AjaxResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
/**
* 状态码
*/
public static final String CODE_TAG = "code";
/**
* 返回内容
*/
public static final String MSG_TAG = "msg";
/**
* 数据对象
*/
public static final String DATA_TAG = "data";
/**
* 总数
*/
public static final String TOTAL_TAG = "total";
/**
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
*/
public AjaxResult() {
}
/**
* 初始化一个新创建的 AjaxResult 对象
*
* @param code 状态码
* @param msg 返回内容
*/
public AjaxResult(int code, String msg) {
super.put(CODE_TAG, code);
super.put(MSG_TAG, msg);
}
/**
* 初始化一个新创建的 AjaxResult 对象
*
* @param code 状态码
* @param msg 返回内容
* @param data 数据对象
*/
public AjaxResult(int code, String msg, Object data) {
super.put(CODE_TAG, code);
super.put(MSG_TAG, msg);
super.put(DATA_TAG, data);
}
/**
* 返回成功消息
*
* @return 成功消息
*/
public static AjaxResult success() {
return AjaxResult.success("操作成功");
}
/**
* 返回成功数据
*
* @return 成功消息
*/
public static AjaxResult success(Object data) {
AjaxResult ajaxResult = AjaxResult.success("操作成功", data);
/*if (data instanceof Page) {
ajaxResult.put(TOTAL_TAG, ((Page<?>) data).getTotal());
}*/
return ajaxResult;
}
/**
* 返回成功消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 成功消息
*/
public static AjaxResult success(String msg, Object data) {
return new AjaxResult(HttpStatus.OK.value(), msg, data);
}
/**
* 返回错误消息
*
* @return
*/
public static AjaxResult error() {
return AjaxResult.error("操作失败");
}
/**
* 返回错误消息
*
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult error(String msg) {
return AjaxResult.error(msg, null);
}
/**
* 返回错误消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 警告消息
*/
public static AjaxResult error(String msg, Object data) {
return new AjaxResult(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg, data);
}
/**
* 返回错误消息
*
* @param code 状态码
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult error(int code, String msg) {
return new AjaxResult(code, msg, null);
}
}
......@@ -71,4 +71,10 @@ public class InternalUtils {
}
return time;
}
public static String getCurrentTime() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
return sdf.format(new Date());
}
}
#??????(1???????2??????????????)
#????????????????????
timetype:1
#??????????????????
#timetype:2
#??????????
......@@ -9,12 +8,24 @@ startTime:20230201 00:00:00
#??????????
endTime:20230208 23:00:00
#?????????
url:2NiJQAsT5i5vcdRA4+QoL0OxDje63w09kf/upD6cZocEy3IvgPXj3BdymdZCw0I0vnYI/K8K+PTYJrRjv6xbqA==
user:7MSN/YEwcQpKaVmXkrQtI5zBlPm6ThDA
password:b6/rlcEodaunlW9hS3Uuigr6oiNIXV7ezgbK2ZAuuIo=
#正式环境
#url:2NiJQAsT5i5vcdRA4+QoL0OxDje63w09kf/upD6cZocEy3IvgPXj3BdymdZCw0I0vnYI/K8K+PTYJrRjv6xbqA==
#user:7MSN/YEwcQpKaVmXkrQtI5zBlPm6ThDA
#password:b6/rlcEodaunlW9hS3Uuigr6oiNIXV7ezgbK2ZAuuIo=
#公司环境
driverClassName:oracle.jdbc.driver.OracleDriver
url:ENC(Et305ScSPFkdAEmh0PpvV6vTeZXprJV57rQ1eL5MOkJZyMnSTt5jttYCJJbnQbPyYyOpPTFhW58z/P5PA9vJbw==)
user:ENC(Dt42e5Z4WWim9j0Ls2G2YjmzwuQ2pjBx)
password:ENC(PI2/xdOsEObL0YZlfGfQnyiJeYUw/90FePU+sO4EDjU=)
#url:jdbc:oracle:thin:@192.168.101.194:1521:zfgjj
#user:GJJ80
#password:GJJ80_Hg41RG
# 前置服务URL
#frontEndProcessorServer:http://192.168.1.252:8888
frontEndProcessorServer:http://127.0.0.1:8081
frontEndProcessorServer: http://192.168.1.252:8888
dwxxbgPushTaskDelay:60000
dwxxbgPullTaskDelay:60000
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="logs"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-debug.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-debug.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.cdkj" level="debug"/>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="file_debug"/>
<appender-ref ref="file_error"/>
</root>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
package net.cdkj.gjj.adapter;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class AdapterApplicationTests {
@Test
void contextLoads() {
}
}
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