15b8bfaf by zenglele

预查封 查封推送

1 parent ede126ed
......@@ -240,6 +240,12 @@
<artifactId>minio</artifactId>
<version>8.3.4</version>
</dependency>
<!-- http -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
......@@ -250,7 +256,7 @@
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${oracle.version}</version>
<version>11.2.0.3</version>
</dependency>
<dependency>
......
package com.pashanhoo.common;
import com.google.common.collect.Lists;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class HttpUtil {
public HttpUtil() {
}
public static String getReturnResByUrl(String url, Map<String, String> params,
Map<String, String> headers, String encode) throws IOException {
Logger logger = LoggerFactory.getLogger(HttpUtil.class);
CloseableHttpClient client = HttpClientBuilder.create().build();
String res = "";
HttpPost httppost = new HttpPost(url);
if (encode == null) {
encode = "utf-8";
}
Integer URLOUTTIME = 0;
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(URLOUTTIME)
.setConnectTimeout(URLOUTTIME).setSocketTimeout(URLOUTTIME).build();
httppost.setConfig(requestConfig);
// 设置header
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httppost.setHeader(entry.getKey(), entry.getValue());
}
}
List<NameValuePair> urlParameters = Lists.newArrayList();
if (params != null && params.size() > 0) {
Iterator<String> it = params.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
urlParameters.add(new BasicNameValuePair(key, params.get(key)));
}
httppost.setEntity(new UrlEncodedFormEntity(urlParameters, encode));
}
CloseableHttpResponse response = client.execute(httppost);
if (response.getStatusLine().getStatusCode() == 200) {
res = EntityUtils.toString(response.getEntity(), encode);
}
logger.info("http post back:" + res);
httppost.releaseConnection();
response.close();
client.close();
return res;
}
public static String get(String url, List<NameValuePair> params, Map<String, String> headers)
{
String body = null;
try
{
HttpGet httpget = new HttpGet(url);
String str = EntityUtils.toString(new UrlEncodedFormEntity(params, "UTF-8"));
String f = url.indexOf("?") > -1 ? "&" : "?";
httpget.setURI(new URI(httpget.getURI().toString() + f + str));
CloseableHttpClient hc = HttpClientBuilder.create().build();
if ((headers != null) && (headers.size() > 0)) {
for (Map.Entry entry : headers.entrySet()) {
httpget.setHeader((String)entry.getKey(), (String)entry.getValue());
}
}
Object httpresponse = hc.execute(httpget);
if (((HttpResponse)httpresponse).getStatusLine().getStatusCode() == 200)
{
HttpEntity entity = ((HttpResponse)httpresponse).getEntity();
body = EntityUtils.toString(entity);
if (entity != null)
entity.consumeContent();
}
else
{
httpget.abort();
}
}
catch (Exception e) {
e.printStackTrace();
}
return body;
}
}
......@@ -12,11 +12,11 @@ public class QysTask {
@Autowired
private EciService eciService;
@Scheduled(cron="0 0/10 * * * ?")
/* @Scheduled(cron="0 0/10 * * * ?")
public void accessCreateContract() {
System.out.println("===========创建合同定时任务进来了=========");
eciService.accessCreateContract();
System.out.println("===========创建合同定时任务走了=========");
}
}*/
}
......
......@@ -30,4 +30,19 @@ public class ZhjTask {
System.out.println("===========每天晚上九点定时任务走了=========");
}
@Scheduled(cron="0 0 18 * * ? ")
public void executeYcfInfo() {
System.out.println("===========每天晚上九点定时任务进来了=========");
zhjDatasSynService.synYcfInfo();
System.out.println("===========每天晚上九点定时任务走了=========");
}
@Scheduled(cron="0 0 22 * * ? ")
public void executeCfInfo() {
System.out.println("===========每天晚上九点定时任务进来了=========");
zhjDatasSynService.synCfInfo();
System.out.println("===========每天晚上九点定时任务走了=========");
}
}
......
......@@ -22,6 +22,10 @@ public interface SynZhjInfoMapper extends BaseMapper<SynZhjInfoDo> {
List<Map> getQymxfcdyxx();
List<Map> getYCFBdcxx();
List<Map> getCFBdcxx();
}
......
......@@ -21,6 +21,6 @@ public interface ZhjDatasSynService extends IService<RegBusBdcqzsdjxxDo> {
public void synQyInfo();
public void synYcfInfo();
public void synCfInfo();
}
......
......@@ -2,6 +2,7 @@ package com.pashanhoo.zhj.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pashanhoo.common.HttpUtil;
import com.pashanhoo.zhj.entity.RegBusBdcqzsdjxxDo;
import com.pashanhoo.zhj.entity.SynZhjInfoDo;
import com.pashanhoo.zhj.mapper.RegBusBdcqzsdjxxMapper;
......@@ -11,6 +12,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.io.*;
import java.net.HttpURLConnection;
......@@ -42,6 +44,10 @@ public class ZhjDatasSynServiceImpl extends ServiceImpl<RegBusBdcqzsdjxxMapper,
private String appkey="3cd832c411238faa1df46d532a21bfcd";
private String appSecret="ee7612083f63c2ce0d016c2aefd0a8d2";
//查封信息认证令牌
private String cfappkey="efd3cca4d0734cc0b99f06fbba303efb";
private String cfappSecret="255e3cbe16fe44c7ac9074aeff52c384";
public void send_bdcYwInfo() {
List<SynZhjInfoDo> selectAllListInfo=synZhjInfoMapper.selectAllInfo();
if(selectAllListInfo!=null && selectAllListInfo.size()>0){
......@@ -517,4 +523,100 @@ public class ZhjDatasSynServiceImpl extends ServiceImpl<RegBusBdcqzsdjxxMapper,
}
/*推送查封信息*/
@Override
public void synYcfInfo() {
//预查封推送执行
new Thread(new Runnable() {
@Override
public void run() {
System.out.println("===============当前线程是:"+Thread.currentThread().getName());
synYcfBDCXX();
}
}).start();
}
/*推送查封信息*/
@Override
public void synCfInfo() {
//组装中小微企业基本信息
new Thread(new Runnable() {
@Override
public void run() {
System.out.println("===============当前线程是:"+Thread.currentThread().getName());
getCFBdcxx();
}
}).start();
}
//907 房屋预查封 905 房屋查封登记
public void synYcfBDCXX() {
List<Map> list=synZhjInfoMapper.getYCFBdcxx();
if(list!=null && list.size()>0) {
for (int j = 0; j < list.size(); j++) {
try {
String url=zhjurl+"/dclp/hzapi/token?appKey="+cfappkey+"&appSecret="+cfappSecret;
Map map1=doGetForNew(url);
if(map1!=null && (Integer)map1.get("code")==200) {
final Map map2 = (Map) map1.get("data");
final String token = (String) map2.get("token");
Map<String, String> map = list.get(j);
if (((String) map.get("ISCHAFENG"))!=null) {
if (Integer.valueOf((String) map.get("ISCHAFENG")) >= 100) {
map.put("ISCHAFENG", "1");
}
}
Map<String, String> headers = new HashMap<>();
headers.put("X-Access-Token", token);
String url1 = zhjurl + "/dclp/hzapi/YCFXX";
HttpUtil.getReturnResByUrl(url1, map, headers, "utf-8");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
public void getCFBdcxx() {
List<Map> list=synZhjInfoMapper.getCFBdcxx();
if(list!=null && list.size()>0) {
for (int j = 0; j < list.size(); j++) {
try {
String url=zhjurl+"/dclp/hzapi/token?appKey="+cfappkey+"&appSecret="+cfappSecret;
Map map1=doGetForNew(url);
if(map1!=null && (Integer)map1.get("code")==200) {
final Map map2 = (Map) map1.get("data");
final String token = (String) map2.get("token");
Map<String, String> map = list.get(j);
if (((String) map.get("ISCHAFENG")) != null) {
if (Integer.valueOf((String) map.get("ISCHAFENG")) >= 100) {
map.put("ISCHAFENG", "1");
}
}
Map<String, String> headers = new HashMap<>();
headers.put("X-Access-Token", token);
String url1 = zhjurl + "/dclp/hzapi/CFXX";
HttpUtil.getReturnResByUrl(url1, map, headers, "utf-8");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}
......
spring:
profiles:
active: test
active: dev
......
......@@ -69,4 +69,62 @@
)
group by dyqr, DYQRZJH, bdcqzh, bdcdyh, QLLX, DYR, DYDJSJ
</select>
<select id="getYCFBdcxx" resultType="java.util.Map">
SELECT DISTINCT
q.qlrMc qlrny,
q.ZJH qlrsfzh,
a.BDCQZH bdcqzsh,
to_char(c.CFQSSJ,'yyyy-MM-dd HH24:mi:ss') cfrq,
c.CFJG cfjg,
c.CFWH,
c.BDCDYH ,to_char(c.JFDJSJ,'yyyy-MM-dd HH24:mi:ss') CHAFENGTIME,
h.ISCHAFENG ISCHAFENG
FROM
REG_BUS_BDCQZSDJXX a,
reg_bus_cfdj c,
reg_bus_qlr q,
reg_base_H h
WHERE
a.ywh = c.ywh
AND a.BDCDYH = c.BDCDYH
AND a.ywh = q.ywh
AND a.djlx = '907'
AND a.DEL_FLAG = '0'
AND a.ISLOGOUT = '1'
and h.BDCDYH=a.BDCDYH
and to_char(c.UPDATE_DATE,'yyyy-MM-dd')= to_char(SYSDATE,'yyyy-MM-dd')
ORDER BY
cfrq ASC
</select>
<select id="getCFBdcxx" resultType="java.util.Map">
SELECT DISTINCT
q.qlrMc qlrny,
q.ZJH qlrsfzh,
a.BDCQZH bdcqzsh,
to_char(c.CFQSSJ,'yyyy-MM-dd HH24:mi:ss') cfrq,
c.CFJG cfjg,
c.CFWH,
c.BDCDYH ,to_char(c.JFDJSJ,'yyyy-MM-dd HH24:mi:ss') CHAFENGTIME,
h.ISCHAFENG ISCHAFENG
FROM
REG_BUS_BDCQZSDJXX a,
reg_bus_cfdj c,
reg_bus_qlr q,
reg_base_H h
WHERE
a.ywh = c.ywh
AND a.BDCDYH = c.BDCDYH
AND a.ywh = q.ywh
AND a.djlx = '905'
AND a.DEL_FLAG = '0'
AND a.ISLOGOUT = '1'
and h.BDCDYH=a.BDCDYH
and to_char(c.UPDATE_DATE,'yyyy-MM-dd')= to_char(SYSDATE,'yyyy-MM-dd')
ORDER BY
cfrq ASC
</select>
</mapper>
......