1.0完成。
This commit is contained in:
parent
f77272ff29
commit
45fb965496
@ -13,59 +13,43 @@
|
|||||||
*/
|
*/
|
||||||
package com.cpic.xim.huixiabao;
|
package com.cpic.xim.huixiabao;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import java.util.Vector;
|
||||||
import com.cpic.xim.huixiabao.data.config.HuixiabaoConfig;
|
|
||||||
|
|
||||||
import cn.hsa.zephyr.apisdk.DefaultZephyrClient;
|
import org.slf4j.Logger;
|
||||||
import cn.hsa.zephyr.apisdk.internal.exception.ZephyrApiException;
|
import org.slf4j.LoggerFactory;
|
||||||
import cn.hsa.zephyr.apisdk.internal.util.encrypt.EncryptionModeEnum;
|
|
||||||
import cn.hsa.zephyr.apisdk.internal.util.encrypt.SignTypeEnum;
|
import com.cpic.xim.huixiabao.data.config.HuixiabaoConfig;
|
||||||
import cn.hsa.zephyr.apisdk.request.DefaultZephyrRequest;
|
import com.cpic.xim.huixiabao.data.pojo.HmbXyxInfo;
|
||||||
import cn.hsa.zephyr.apisdk.response.DefaultZephyrResponse;
|
import com.cpic.xim.huixiabao.nhs.CpicximToXMNHS;
|
||||||
|
|
||||||
public class AppMain
|
public class AppMain
|
||||||
{
|
{
|
||||||
|
private static Logger logger = LoggerFactory.getLogger( AppMain.class );
|
||||||
|
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
{
|
{
|
||||||
String url = HuixiabaoConfig.getUrl();
|
doPostXyxInfo();
|
||||||
String appId = HuixiabaoConfig.getAppid();
|
|
||||||
String appSecret = HuixiabaoConfig.getAppSecret();
|
|
||||||
String funId = "xxx";
|
|
||||||
String encKey = HuixiabaoConfig.getEncKey();
|
|
||||||
String signKey = HuixiabaoConfig.getSignKey();
|
|
||||||
|
|
||||||
EncryptionModeEnum encType = EncryptionModeEnum.SM4;
|
|
||||||
SignTypeEnum signType = SignTypeEnum.SM3;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DefaultZephyrClient client = new DefaultZephyrClient( url,
|
|
||||||
funId,
|
|
||||||
appId,
|
|
||||||
appSecret,
|
|
||||||
signType,
|
|
||||||
signKey,
|
|
||||||
encType,
|
|
||||||
encKey );
|
|
||||||
|
|
||||||
DefaultZephyrRequest req = new DefaultZephyrRequest();
|
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
|
||||||
DefaultZephyrResponse resp = null;
|
|
||||||
|
|
||||||
jsonObject1.put( "code", "XXXXXXXXXXXXXXXXXX" );
|
|
||||||
jsonObject1.put( "scene_code", "XXX" );
|
|
||||||
|
|
||||||
req.setData( jsonObject1 );
|
|
||||||
// resp = client.execute( req );
|
|
||||||
|
|
||||||
System.out.println( req.toString() );
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
System.out.println( "Fuck World!" );
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println( "Hello World!" );
|
System.out.println( "Hello World!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void doPostXyxInfo()
|
||||||
|
{
|
||||||
|
while ( true )
|
||||||
|
{
|
||||||
|
Vector<HmbXyxInfo> xyxInfo = CpicximToXMNHS.getNeverTransHmbList();
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
CpicximToXMNHS.postHmbList( xyxInfo );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep( HuixiabaoConfig.getSleepSeconds() * 1000 );
|
||||||
|
}
|
||||||
|
catch ( InterruptedException error )
|
||||||
|
{
|
||||||
|
logger.error( "sleep时出错:" + error.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,13 @@ public class HuixiabaoConfig
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getSleepSeconds()
|
||||||
|
{
|
||||||
|
return SLEEP_SECONDS;
|
||||||
|
}
|
||||||
|
|
||||||
private static final int MAX_COUNT_PER_REQUEST = 500;
|
private static final int MAX_COUNT_PER_REQUEST = 500;
|
||||||
|
private static final int SLEEP_SECONDS = 10;
|
||||||
|
|
||||||
private static final String url = "https://172.18.1.150:9040";
|
private static final String url = "https://172.18.1.150:9040";
|
||||||
private static final String appid = "hxb-tb";
|
private static final String appid = "hxb-tb";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: Kane
|
* @Author: Kane
|
||||||
*
|
*
|
||||||
* @Date: 2025-03-11 11:10:09
|
* @Date: 2025-03-12 09:01:59
|
||||||
*
|
*
|
||||||
* @LastEditors: Kane
|
* @LastEditors: Kane
|
||||||
*
|
*
|
||||||
@ -11,10 +11,12 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) ${2023} by Kane, All Rights Reserved.
|
* Copyright (c) ${2023} by Kane, All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.cpic.xim.huixiabao.nhs;
|
package com.cpic.xim.huixiabao.nhs;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -32,7 +34,9 @@ import cn.hsa.zephyr.apisdk.request.DefaultZephyrRequest;
|
|||||||
import cn.hsa.zephyr.apisdk.response.DefaultZephyrResponse;
|
import cn.hsa.zephyr.apisdk.response.DefaultZephyrResponse;
|
||||||
import com.cpic.xim.huixiabao.data.config.HuixiabaoConfig;
|
import com.cpic.xim.huixiabao.data.config.HuixiabaoConfig;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings(
|
||||||
|
"unused"
|
||||||
|
)
|
||||||
public class CpicximToXMNHS
|
public class CpicximToXMNHS
|
||||||
{
|
{
|
||||||
private static Logger logger = LoggerFactory.getLogger( CpicximToXMNHS.class );
|
private static Logger logger = LoggerFactory.getLogger( CpicximToXMNHS.class );
|
||||||
@ -61,10 +65,10 @@ public class CpicximToXMNHS
|
|||||||
{
|
{
|
||||||
Class.forName( "com.mysql.cj.jdbc.Driver" );
|
Class.forName( "com.mysql.cj.jdbc.Driver" );
|
||||||
|
|
||||||
String url = CpicximToXMNHS.url;
|
String url = CpicximToXMNHS.url;
|
||||||
String userName = CpicximToXMNHS.userName;
|
String userName = CpicximToXMNHS.userName;
|
||||||
String password = CpicximToXMNHS.password;
|
String password = CpicximToXMNHS.password;
|
||||||
String sql = """
|
String sql = """
|
||||||
select info.psnName, info.certNo, info.serviceId, info.status, info.xyxNo
|
select info.psnName, info.certNo, info.serviceId, info.status, info.xyxNo
|
||||||
from HmbXyxInfo info,
|
from HmbXyxInfo info,
|
||||||
HmbXyxInfo_Update u
|
HmbXyxInfo_Update u
|
||||||
@ -91,19 +95,44 @@ public class CpicximToXMNHS
|
|||||||
}
|
}
|
||||||
catch ( ClassNotFoundException error )
|
catch ( ClassNotFoundException error )
|
||||||
{
|
{
|
||||||
|
logger.error( "加载sql驱动错误:" + error.getMessage() );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
if ( result != null )
|
||||||
{
|
|
||||||
result.close();
|
|
||||||
statement.close();
|
|
||||||
connection.close();
|
|
||||||
}
|
|
||||||
catch ( SQLException error )
|
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result.close();
|
||||||
|
}
|
||||||
|
catch ( SQLException error )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( statement != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch ( SQLException error )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( connection != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
catch ( SQLException error )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,27 +144,30 @@ public class CpicximToXMNHS
|
|||||||
Vector<HmbXyxInfo> items = new Vector<HmbXyxInfo>();
|
Vector<HmbXyxInfo> items = new Vector<HmbXyxInfo>();
|
||||||
HmbXyxInfo item = null;
|
HmbXyxInfo item = null;
|
||||||
|
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
Statement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet result = null;
|
ResultSet result = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class.forName( "com.mysql.cj.jdbc.Driver" );
|
Class.forName( "com.mysql.cj.jdbc.Driver" );
|
||||||
|
|
||||||
String url = CpicximToXMNHS.url;
|
String url = CpicximToXMNHS.url;
|
||||||
String userName = CpicximToXMNHS.userName;
|
String userName = CpicximToXMNHS.userName;
|
||||||
String password = CpicximToXMNHS.password;
|
String password = CpicximToXMNHS.password;
|
||||||
String sql = """
|
String sql = """
|
||||||
delete from HmbXyxInfo_Update where xyxNo = ?""";
|
delete from HmbXyxInfo_Update where xyxNo = ?""";
|
||||||
|
|
||||||
connection = DriverManager.getConnection( url, userName, password );
|
connection = DriverManager.getConnection( url, userName, password );
|
||||||
statement = connection.prepareStatement(sql.trim());
|
statement = connection.prepareStatement( sql.trim() );
|
||||||
|
|
||||||
for ( HmbXyxInfo info : postedItems)
|
for ( HmbXyxInfo info : postedItems )
|
||||||
{
|
{
|
||||||
|
statement.setString( 1, info.getXyxNo() );
|
||||||
|
statement.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connection.commit();
|
||||||
}
|
}
|
||||||
catch ( SQLException error )
|
catch ( SQLException error )
|
||||||
{
|
{
|
||||||
@ -147,8 +179,8 @@ public class CpicximToXMNHS
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error.printStackTrace();
|
logger.error( "清理已发送数据失败:" + error.getMessage() );
|
||||||
}
|
}
|
||||||
catch ( ClassNotFoundException error )
|
catch ( ClassNotFoundException error )
|
||||||
{
|
{
|
||||||
@ -156,15 +188,40 @@ public class CpicximToXMNHS
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
if ( result != null )
|
||||||
{
|
|
||||||
|
|
||||||
statement.close();
|
|
||||||
connection.close();
|
|
||||||
}
|
|
||||||
catch ( SQLException error )
|
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result.close();
|
||||||
|
}
|
||||||
|
catch ( SQLException error )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( statement != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch ( SQLException error )
|
||||||
|
{
|
||||||
|
logger.error( "加载sql驱动错误:" + error.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( connection != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
catch ( SQLException error )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,9 +251,10 @@ public class CpicximToXMNHS
|
|||||||
DefaultZephyrResponse resp = null;
|
DefaultZephyrResponse resp = null;
|
||||||
|
|
||||||
// 数据
|
// 数据
|
||||||
JSONObject requestObject = new JSONObject();
|
JSONObject requestObject = new JSONObject();
|
||||||
JSONObject xyxInfo = null;
|
JSONObject xyxInfo = null;
|
||||||
JSONArray xyxInfoList = new JSONArray();
|
JSONArray xyxInfoList = new JSONArray();
|
||||||
|
Vector<HmbXyxInfo> postedInfo = new Vector<HmbXyxInfo>(); // 存放已经送出的数据
|
||||||
|
|
||||||
requestObject.put( "topic", "hmbXyxInfo" );
|
requestObject.put( "topic", "hmbXyxInfo" );
|
||||||
|
|
||||||
@ -214,6 +272,7 @@ public class CpicximToXMNHS
|
|||||||
xyxInfo.put( "xyxNo", info.getXyxNo() );
|
xyxInfo.put( "xyxNo", info.getXyxNo() );
|
||||||
|
|
||||||
xyxInfoList.add( xyxInfo );
|
xyxInfoList.add( xyxInfo );
|
||||||
|
postedInfo.add( info );
|
||||||
|
|
||||||
request_count++;
|
request_count++;
|
||||||
total_count++;
|
total_count++;
|
||||||
@ -234,6 +293,7 @@ public class CpicximToXMNHS
|
|||||||
logger.info( "发送成功,返回消息:" + resp.getData() );
|
logger.info( "发送成功,返回消息:" + resp.getData() );
|
||||||
|
|
||||||
// 将已发送的数据从update表中清理掉
|
// 将已发送的数据从update表中清理掉
|
||||||
|
removePostedHmbXyxInfo( postedInfo );
|
||||||
}
|
}
|
||||||
catch ( ZephyrApiException error )
|
catch ( ZephyrApiException error )
|
||||||
{
|
{
|
||||||
@ -241,10 +301,15 @@ public class CpicximToXMNHS
|
|||||||
// 失败的数据就留在update表中,待以后重新发送
|
// 失败的数据就留在update表中,待以后重新发送
|
||||||
logger.error( error.getMessage() );
|
logger.error( error.getMessage() );
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// 清理清单,重置计数
|
||||||
|
// 如果发送失败,在HmbXyxInfo_update表中保留发送失败的记录,待下次发送
|
||||||
|
xyxInfoList.clear();
|
||||||
|
postedInfo.clear();
|
||||||
|
|
||||||
// 清理清单,重置计数
|
request_count = 0;
|
||||||
xyxInfoList.clear();
|
}
|
||||||
request_count = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
drop TRIGGER xyxinfo_update;
|
drop TRIGGER xyxinfo_insert;
|
||||||
CREATE TRIGGER xyxinfo_update BEFORE INSERT ON huixiabao.HmbXyxInfo FOR EACH ROW
|
CREATE TRIGGER xyxinfo_insert after INSERT ON huixiabao.HmbXyxInfo FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
delete from huixiabao.HmbXyxInfo_Update u where u.xyxNo = NEW.xyxNo;
|
delete from huixiabao.HmbXyxInfo_Update u where u.xyxNo = NEW.xyxNo;
|
||||||
INSERT INTO huixiabao.HmbXyxInfo_Update ( xyxNo, update_time )
|
INSERT INTO huixiabao.HmbXyxInfo_Update ( xyxNo, update_time )
|
||||||
@ -8,4 +8,17 @@ BEGIN
|
|||||||
new.xyxNo,
|
new.xyxNo,
|
||||||
SYSDATE());
|
SYSDATE());
|
||||||
|
|
||||||
END
|
END;
|
||||||
|
|
||||||
|
|
||||||
|
drop trigger xyxinfo_update;
|
||||||
|
create trigger xyxinfo_update after update on huixiabao.HmbXyxInfo FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
delete from huixiabao.HmbXyxInfo_Update u where u.xyxNo = NEW.xyxNo;
|
||||||
|
INSERT INTO huixiabao.HmbXyxInfo_Update ( xyxNo, update_time )
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
new.xyxNo,
|
||||||
|
SYSDATE());
|
||||||
|
|
||||||
|
END;
|
Loading…
x
Reference in New Issue
Block a user