Commit 85d099d3 authored by 5359's avatar 5359

流水号添加随机数

parent 7986c6ae
...@@ -70,6 +70,7 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -70,6 +70,7 @@ public class PingAnServiceImpl implements PingAnService {
private static Properties pro = null; private static Properties pro = null;
private static Calendar cal = null; private static Calendar cal = null;
private static SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS"); private static SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");
private static String filePath = null;
static { static {
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(1); String path = Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(1);
...@@ -79,6 +80,7 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -79,6 +80,7 @@ public class PingAnServiceImpl implements PingAnService {
} }
baseReqBody.put("MrchCode", pro.getProperty("MrchCode")); baseReqBody.put("MrchCode", pro.getProperty("MrchCode"));
baseReqBody.put("MainAccount", pro.getProperty("AcctNo")); baseReqBody.put("MainAccount", pro.getProperty("AcctNo"));
filePath = pro.getProperty("pingAnDownloadFilePath");
} }
...@@ -88,13 +90,14 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -88,13 +90,14 @@ public class PingAnServiceImpl implements PingAnService {
* @return * @return
*/ */
@Override @Override
public JSONObject invoke(IRequest iRequest,String interfaceName, JSONObject params) { public JSONObject invoke(IRequest iRequest, String interfaceName, JSONObject params) {
JSONObject responseData = new JSONObject(); JSONObject responseData = new JSONObject();
// JSONObject requestBody = ApiUtils.getBaseReqBody(); // JSONObject requestBody = ApiUtils.getBaseReqBody();
JSONObject requestBody = baseReqBody.clone(); JSONObject requestBody = baseReqBody.clone();
cal = Calendar.getInstance(); cal = Calendar.getInstance();
String today = df.format(cal.getTime()); String today = df.format(cal.getTime());
requestBody.put("CnsmrSeqNo", today + "000"); long temp = Math.round(Math.random() * 899 + 100);// 产生100到999的随机数
requestBody.put("CnsmrSeqNo", today + temp);
requestBody.putAll(params); requestBody.putAll(params);
/*插入接口日志表*/ /*插入接口日志表*/
...@@ -166,30 +169,37 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -166,30 +169,37 @@ public class PingAnServiceImpl implements PingAnService {
JSONObject responseData = new JSONObject(); JSONObject responseData = new JSONObject();
logger.info("接收推送消息,推送参数: {}", req.toString()); logger.info("接收推送消息,推送参数: {}", req.toString());
if (Objects.nonNull(req) && req.size() > 0) { if (Objects.nonNull(req) && req.size() > 0) {
// 存表 try {
//实际通知报文中会把数据放在ROOT这个key下 // 存表
JSONObject data = req.getJSONObject("ROOT"); //实际通知报文中会把数据放在ROOT这个key下
DefaultTransactionDefinition def = new DefaultTransactionDefinition(); JSONObject data = req.getJSONObject("ROOT");
// 事务隔离级别:开启新事务 DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事务隔离级别:开启新事务
//对于每次请求都开启一个事物 def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus transactionStatus = transactionManager.getTransaction(def); //对于每次请求都开启一个事物
TransactionStatus transactionStatus = transactionManager.getTransaction(def);
HlsEbankCcbTransaction hlsEbankCcbTransaction = saveTransaction(iRequest, data); HlsEbankCcbTransaction hlsEbankCcbTransaction = saveTransaction(iRequest, data);
//状态刷新 //状态刷新
transactionStatus.flush(); transactionStatus.flush();
//事务提交 //事务提交
transactionManager.commit(transactionStatus); transactionManager.commit(transactionStatus);
// 调用系统的接口服务,推送通知数据 // 调用系统的接口服务,推送通知数据
JSONObject ldo16 = new JSONObject(); JSONObject ldo16 = new JSONObject();
ldo16.put("transaction_id",hlsEbankCcbTransaction.getTransactionId()); ldo16.put("transaction_id", hlsEbankCcbTransaction.getTransactionId());
postNotify(ldo16.toString()); postNotify(ldo16.toString());
responseData.put("TxnReturnCode ","000000"); } catch (Exception e) {
responseData.put("TxnReturnMsg ","接收成功"); e.printStackTrace();
} else { }
responseData.put("TxnReturnCode ","111111"); // responseData.put("TxnReturnCode ","000000");
responseData.put("TxnReturnMsg ","接收失败"); // responseData.put("TxnReturnMsg ","接收成功");
} }
// else {
// responseData.put("TxnReturnCode ","111111");
// responseData.put("TxnReturnMsg ","接收失败");
// }
responseData.put("TxnReturnCode ", "000000");
responseData.put("TxnReturnMsg ", "接收成功");
return responseData; return responseData;
} }
...@@ -297,7 +307,9 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -297,7 +307,9 @@ public class PingAnServiceImpl implements PingAnService {
orderFiles.add(orderFile); orderFiles.add(orderFile);
} }
OrderFileRequest orderFileRequest = new OrderFileRequest(); OrderFileRequest orderFileRequest = new OrderFileRequest();
orderFileRequest.setDownPath("D:\\download\\yqzl"); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String dateString = formatter.format(new Date()) + "\\";
orderFileRequest.setDownPath(filePath + dateString);
File file = new File(orderFileRequest.getDownPath()); File file = new File(orderFileRequest.getDownPath());
if (!file.exists()) { if (!file.exists()) {
file.mkdirs(); file.mkdirs();
...@@ -323,13 +335,13 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -323,13 +335,13 @@ public class PingAnServiceImpl implements PingAnService {
JSONObject res = invoke(iRequest, interfaceName, params); JSONObject res = invoke(iRequest, interfaceName, params);
// 对当前查询到的数据进行存表 // 对当前查询到的数据进行存表
JSONObject data = res.getJSONObject("data"); JSONObject data = res.getJSONObject("data");
if (Objects.nonNull(data)){ if (Objects.nonNull(data)) {
isEnd = data.getString("IsEnd"); isEnd = data.getString("IsEnd");
JSONArray arr = data.getJSONArray("list"); JSONArray arr = data.getJSONArray("list");
if (Objects.nonNull(arr)) { if (Objects.nonNull(arr)) {
batchSaveTransactionByC00602(iRequest, arr); batchSaveTransactionByC00602(iRequest, arr);
} }
}else{ } else {
responseData.put(Constants.RESP_CODE, "1111"); responseData.put(Constants.RESP_CODE, "1111");
responseData.put("respMsg", "查询出错"); responseData.put("respMsg", "查询出错");
break; break;
...@@ -351,30 +363,30 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -351,30 +363,30 @@ public class PingAnServiceImpl implements PingAnService {
JSONObject res = invoke(iRequest, interfaceName, params); JSONObject res = invoke(iRequest, interfaceName, params);
// 对当前查询到的数据进行存表 // 对当前查询到的数据进行存表
JSONObject data = res.getJSONObject("data"); JSONObject data = res.getJSONObject("data");
if (Objects.nonNull(data)){ if (Objects.nonNull(data)) {
if (mainFlag){ if (mainFlag) {
// 处理主账户,每次查询只处理一次 // 处理主账户,每次查询只处理一次
HlsEbankCcbAccount hlsEbankCcbAccount = new HlsEbankCcbAccount(); HlsEbankCcbAccount hlsEbankCcbAccount = new HlsEbankCcbAccount();
hlsEbankCcbAccount.setAccountNo(data.getString("ShadowAcctNo")); hlsEbankCcbAccount.setAccountNo(data.getString("ShadowAcctNo"));
Long recordId = hlsEbankCcbAccountMapper.queryByAccountNo(hlsEbankCcbAccount); Long recordId = hlsEbankCcbAccountMapper.queryByAccountNo(hlsEbankCcbAccount);
hlsEbankCcbAccount.setSubAccNum(data.getLong("SubAccNum")); hlsEbankCcbAccount.setSubAccNum(data.getLong("SubAccNum"));
hlsEbankCcbAccount.setStt(data.getString("Stt")); hlsEbankCcbAccount.setStt(data.getString("Stt"));
if (Objects.nonNull(recordId)){ if (Objects.nonNull(recordId)) {
hlsEbankCcbAccount.setRecordId(recordId); hlsEbankCcbAccount.setRecordId(recordId);
hlsEbankCcbAccountService.updateByPrimaryKeySelective(iRequest,hlsEbankCcbAccount); hlsEbankCcbAccountService.updateByPrimaryKeySelective(iRequest, hlsEbankCcbAccount);
}else{ } else {
hlsEbankCcbAccount.setMainFlag("Y"); hlsEbankCcbAccount.setMainFlag("Y");
hlsEbankCcbAccount.setMainAccount(data.getString("MainAccount")); hlsEbankCcbAccount.setMainAccount(data.getString("MainAccount"));
hlsEbankCcbAccount.setCorId(data.getString("CorId")); hlsEbankCcbAccount.setCorId(data.getString("CorId"));
hlsEbankCcbAccount.setAccName(data.getString("AccountName")); hlsEbankCcbAccount.setAccName(data.getString("AccountName"));
hlsEbankCcbAccountService.insertSelective(iRequest,hlsEbankCcbAccount); hlsEbankCcbAccountService.insertSelective(iRequest, hlsEbankCcbAccount);
} }
mainFlag = false; mainFlag = false;
} }
isEnd = data.getString("IsEnd"); isEnd = data.getString("IsEnd");
batchSaveAccount(iRequest, data); batchSaveAccount(iRequest, data);
}else{ } else {
responseData.put(Constants.RESP_CODE, "1111"); responseData.put(Constants.RESP_CODE, "1111");
responseData.put("respMsg", "查询出错"); responseData.put("respMsg", "查询出错");
break; break;
...@@ -433,9 +445,9 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -433,9 +445,9 @@ public class PingAnServiceImpl implements PingAnService {
} }
} }
private void batchSaveAccount(IRequest iRequest, JSONObject data){ private void batchSaveAccount(IRequest iRequest, JSONObject data) {
JSONArray list = data.getJSONArray("list"); JSONArray list = data.getJSONArray("list");
if (Objects.nonNull(list)){ if (Objects.nonNull(list)) {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
JSONObject item = list.getJSONObject(i); JSONObject item = list.getJSONObject(i);
HlsEbankCcbAccount hlsEbankCcbAccount = new HlsEbankCcbAccount(); HlsEbankCcbAccount hlsEbankCcbAccount = new HlsEbankCcbAccount();
...@@ -444,15 +456,15 @@ public class PingAnServiceImpl implements PingAnService { ...@@ -444,15 +456,15 @@ public class PingAnServiceImpl implements PingAnService {
hlsEbankCcbAccount.setSubAccNum(data.getLong("SubAccNum")); hlsEbankCcbAccount.setSubAccNum(data.getLong("SubAccNum"));
hlsEbankCcbAccount.setStt(item.getString("SubStt")); hlsEbankCcbAccount.setStt(item.getString("SubStt"));
hlsEbankCcbAccount.setAccBalance(item.getDouble("SubAccBalance")); hlsEbankCcbAccount.setAccBalance(item.getDouble("SubAccBalance"));
if (Objects.nonNull(recordId)){ if (Objects.nonNull(recordId)) {
hlsEbankCcbAccount.setRecordId(recordId); hlsEbankCcbAccount.setRecordId(recordId);
hlsEbankCcbAccountService.updateByPrimaryKeySelective(iRequest,hlsEbankCcbAccount); hlsEbankCcbAccountService.updateByPrimaryKeySelective(iRequest, hlsEbankCcbAccount);
}else{ } else {
hlsEbankCcbAccount.setMainFlag("N"); hlsEbankCcbAccount.setMainFlag("N");
hlsEbankCcbAccount.setMainAccount(data.getString("MainAccount")); hlsEbankCcbAccount.setMainAccount(data.getString("MainAccount"));
hlsEbankCcbAccount.setCorId(data.getString("CorId")); hlsEbankCcbAccount.setCorId(data.getString("CorId"));
hlsEbankCcbAccount.setAccName(item.getString("SubAccName")); hlsEbankCcbAccount.setAccName(item.getString("SubAccName"));
hlsEbankCcbAccountService.insertSelective(iRequest,hlsEbankCcbAccount); hlsEbankCcbAccountService.insertSelective(iRequest, hlsEbankCcbAccount);
} }
} }
} }
......
...@@ -9,6 +9,7 @@ queryOrderFileUrl=https://my-st1.orangebank.com.cn:567/fat7/openapi/file/boapFil ...@@ -9,6 +9,7 @@ queryOrderFileUrl=https://my-st1.orangebank.com.cn:567/fat7/openapi/file/boapFil
fileDownLoadOrderFileUrl=https://my-st1.orangebank.com.cn:567/fat7/openapi/file/boapFile/downloadOrderFile fileDownLoadOrderFileUrl=https://my-st1.orangebank.com.cn:567/fat7/openapi/file/boapFile/downloadOrderFile
MrchCode=0090108040000KTAR000 MrchCode=0090108040000KTAR000
AcctNo=15000101414037 AcctNo=15000101414037
pingAnDownloadFilePath=E:\\HCLC_FTP\\PAB_IN\\
#测试客户名称:天津市佳兴机械设备租赁有限公司 #测试客户名称:天津市佳兴机械设备租赁有限公司
#测试合同:L21BD00209 #测试合同:L21BD00209
\ No newline at end of file
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