付款单推送中信银行

This commit is contained in:
hecan 2025-03-20 14:45:52 +08:00
parent cff6f09b50
commit 5624b62967
12 changed files with 2548 additions and 0 deletions

View File

@ -0,0 +1,59 @@
package com.hzya.frame.plugin.zxBank.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.masterData.plugin.MdmPluginInitializer;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService;
import com.hzya.frame.sysnew.zxbank.service.IZxBankService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class ZxBankPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(ZxBankPluginInitializer.class);
@Autowired
private IZxBankService zxBankService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "ZxBankPluginInitializer";
}
@Override
public String getPluginName() {
return "ZxBankPluginInitializer插件";
}
@Override
public String getPluginLabel() {
return "ZxBankPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行杭泰付款单同步========");
return zxBankService.queryArchives(requestJson);
}catch (Exception e){
logger.info("======执行杭泰付款单同步失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,56 @@
package com.hzya.frame.plugin.zxBank.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.sysnew.zxbank.service.IZxBankService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class ZxBankResultPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(ZxBankResultPluginInitializer.class);
@Autowired
private IZxBankService zxBankService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "ZxBankResultPluginInitializer";
}
@Override
public String getPluginName() {
return "ZxBankResultPluginInitializer插件";
}
@Override
public String getPluginLabel() {
return "ZxBankResultPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行杭泰付款单查询返回结果========");
return zxBankService.queryArchivesResult(requestJson);
}catch (Exception e){
logger.info("======执行杭泰付款单查询返回结果失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>ZxBankPluginInitializer</id>
<name>ZxBankPluginInitializer插件</name>
<category>25031801</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="ZxBankPluginInitializer" class="com.hzya.frame.plugin.zxBank.plugin.ZxBankPluginInitializer" />
</beans>

View File

@ -0,0 +1,62 @@
package com.hzya.frame.sysnew.zxbank.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity;
import java.util.HashMap;
import java.util.List;
public interface IZxBankDao extends IBaseDao<ZxBankEntity, String> {
/**
*
* @content 查询未推送的付款单
* @Param
* @Return
* @Author hecan
* @Date 2025-03-17 22:28
* **/
List<HashMap<String, Object>> queryListByBank(String str , MdmModuleSourceEntity entity);
/**
*
* @content 数据抽取成功更新推送标识
* @Param
* @Return
* @Author hecan
* @Date 2024-12-05 17:58
* **/
Integer updatePushStatus(ZxBankEntity entity);
/**
*
* @content 查询已推送并且支付结果为空的数据
* @Param
* @Return
* @Author hecan
* @Date 2025-03-18 17:44
* **/
List<ZxBankEntity> queryResultIsNull(ZxBankEntity zxBankEntity);
/**
*
* @content 修改支付状态
* @Param
* @Return
* @Author hecan
* @Date 2025-03-19 10:31
* **/
Integer updateResultStatus(ZxBankEntity entity);
/**
*
* @content 查询已支付并且电子回单为空的数据
* @Param
* @Return
* @Author hecan
* @Date 2025-03-19 14:15
* **/
List<ZxBankEntity> queryElecIsNull(ZxBankEntity entity);
}

View File

@ -0,0 +1,60 @@
package com.hzya.frame.sysnew.zxbank.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.execsql.service.IExecSqlService;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.zxbank.dao.IZxBankDao;
import com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.HashMap;
import java.util.List;
@Repository(value = "ZxBankDaoImpl")
public class ZxBankDaoImpl extends MybatisGenericDao<ZxBankEntity,String> implements IZxBankDao {
@Autowired
private IExecSqlService execSqlService;
private Logger logger = LogManager.getLogger(super.getClass());
@DS("#entity.dataSourceCode")
@Override
public List<HashMap<String, Object>> queryListByBank(String str, MdmModuleSourceEntity entity) {
try {
List<HashMap<String, Object>> hashMaps = execSqlService.execSelectSql(str, "");
return hashMaps;
}catch (Exception e){
logger.info("没有需要推送中信的数据");
return null;
}
}
@DS("#entity.dataSourceCode")
@Override
public Integer updatePushStatus(ZxBankEntity entity) {
return super.update("updatePushStatus",entity);
}
@DS("#entity.dataSourceCode")
@Override
public List<ZxBankEntity> queryResultIsNull(ZxBankEntity entity) {
return super.queryList(entity,"queryResultIsNull");
}
@DS("#entity.dataSourceCode")
@Override
public Integer updateResultStatus(ZxBankEntity entity) {
return super.update("updateResultStatus",entity);
}
@DS("#entity.dataSourceCode")
@Override
public List<ZxBankEntity> queryElecIsNull(ZxBankEntity entity) {
return super.queryList(entity,"queryElecIsNull");
}
}

View File

@ -0,0 +1,42 @@
package com.hzya.frame.sysnew.zxbank.entity;
public enum PayState {
PAYING("PAYING","支付中"),
PAID("PAID","已支付"),
REJECTED("REJECTED","已驳回"),
RETURN_REMITTANCE("RETURN_REMITTANCE","已退汇");
private String type;
//
private String value;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
PayState(String type, String value){
this.type=type;
this.value=value;
}
public static String payStateGetValue(String type){
for (PayState payState : PayState.values()){
if(payState.getType()==type||payState.getType().equals(type)){
return payState.getValue().toString();
}
}
return null;
}
}

View File

@ -0,0 +1,250 @@
package com.hzya.frame.sysnew.zxbank.entity;
import com.hzya.frame.web.entity.BaseEntity;
public class ZxBankEntity extends BaseEntity {
private String sourceFlowNumber;//来源系统流水号租户内唯一
private String documentNo;//业务单据号
private String companyCode;//公司编码
private String fundType;//付款类型
private String digest;//摘要附言
private String payAccountNum;//付方账号
private String payAccountName;//付方户名
private String recAccountNum;//收方账号
private String recAccountName;//收方户名
private String recBankCode;//收方金融机构行联号
private String settleAccountType;//结算方式
private String payChannel;//支付渠道
private String currency;//币种
private String transAmount;//金额
private String payDate;//预计付款日期
private String toPublic;//对公标识 true:对公 /false:对私
private String purpose;//用途
private String submitUser;//提交人姓名
private String tabName;//表名称
private String dataId;//id
private String payResultField;//支付结果字段
private String payDateField;//打款日期字段
private String receiptFiled;//电子回单字段
private String pushStatusField;//推送标识字段
private String payResult;//支付结果
private String receipt;//电子回单
private String pushStatus;//推送标识
public String getTabName() {
return tabName;
}
public void setTabName(String tabName) {
this.tabName = tabName;
}
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
public String getPayResultField() {
return payResultField;
}
public void setPayResultField(String payResultField) {
this.payResultField = payResultField;
}
public String getPayDateField() {
return payDateField;
}
public void setPayDateField(String payDateField) {
this.payDateField = payDateField;
}
public String getReceiptFiled() {
return receiptFiled;
}
public void setReceiptFiled(String receiptFiled) {
this.receiptFiled = receiptFiled;
}
public String getPushStatusField() {
return pushStatusField;
}
public void setPushStatusField(String pushStatusField) {
this.pushStatusField = pushStatusField;
}
public String getPayResult() {
return payResult;
}
public void setPayResult(String payResult) {
this.payResult = payResult;
}
public String getReceipt() {
return receipt;
}
public void setReceipt(String receipt) {
this.receipt = receipt;
}
public String getPushStatus() {
return pushStatus;
}
public void setPushStatus(String pushStatus) {
this.pushStatus = pushStatus;
}
public String getSourceFlowNumber() {
return sourceFlowNumber;
}
public void setSourceFlowNumber(String sourceFlowNumber) {
this.sourceFlowNumber = sourceFlowNumber;
}
public String getDocumentNo() {
return documentNo;
}
public void setDocumentNo(String documentNo) {
this.documentNo = documentNo;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getFundType() {
return fundType;
}
public void setFundType(String fundType) {
this.fundType = fundType;
}
public String getDigest() {
return digest;
}
public void setDigest(String digest) {
this.digest = digest;
}
public String getPayAccountNum() {
return payAccountNum;
}
public void setPayAccountNum(String payAccountNum) {
this.payAccountNum = payAccountNum;
}
public String getPayAccountName() {
return payAccountName;
}
public void setPayAccountName(String payAccountName) {
this.payAccountName = payAccountName;
}
public String getRecAccountNum() {
return recAccountNum;
}
public void setRecAccountNum(String recAccountNum) {
this.recAccountNum = recAccountNum;
}
public String getRecAccountName() {
return recAccountName;
}
public void setRecAccountName(String recAccountName) {
this.recAccountName = recAccountName;
}
public String getRecBankCode() {
return recBankCode;
}
public void setRecBankCode(String recBankCode) {
this.recBankCode = recBankCode;
}
public String getSettleAccountType() {
return settleAccountType;
}
public void setSettleAccountType(String settleAccountType) {
this.settleAccountType = settleAccountType;
}
public String getPayChannel() {
return payChannel;
}
public void setPayChannel(String payChannel) {
this.payChannel = payChannel;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getTransAmount() {
return transAmount;
}
public void setTransAmount(String transAmount) {
this.transAmount = transAmount;
}
public String getPayDate() {
return payDate;
}
public void setPayDate(String payDate) {
this.payDate = payDate;
}
public String getToPublic() {
return toPublic;
}
public void setToPublic(String toPublic) {
this.toPublic = toPublic;
}
public String getPurpose() {
return purpose;
}
public void setPurpose(String purpose) {
this.purpose = purpose;
}
public String getSubmitUser() {
return submitUser;
}
public void setSubmitUser(String submitUser) {
this.submitUser = submitUser;
}
}

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.sysnew.zxbank.dao.impl.ZxBankDaoImpl">
<resultMap id="get-ZxBankEntity-result" type="com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity">
<result property="sourceFlowNumber" column="sourceFlowNumber" />
<result property="documentNo" column="documentNo" />
<result property="companyCode" column="companyCode" />
<result property="fundType" column="fundType" />
<result property="digest" column="digest" />
<result property="payAccountNum" column="payAccountNum" />
<result property="payAccountName" column="payAccountName" />
<result property="recAccountNum" column="recAccountNum" />
<result property="recAccountName" column="recAccountName" />
<result property="recBankCode" column="recBankCode" />
<result property="settleAccountType" column="settleAccountType" />
<result property="payChannel" column="payChannel" />
<result property="currency" column="currency" />
<result property="transAmount" column="transAmount" />
<result property="payDate" column="payDate" />
<result property="toPublic" column="toPublic" />
<result property="purpose" column="purpose" />
<result property="submitUser" column="submitUser" />
<result property="tabName" column="tabName" />
<result property="dataId" column="dataId" />
<result property="payResultField" column="payResultField" />
<result property="payDateField" column="payDateField" />
<result property="receiptFiled" column="receiptFiled" />
<result property="pushStatusField" column="pushStatusField" />
<result property="payResult" column="payResult" />
<result property="receipt" column="receipt" />
<result property="pushStatus" column="pushStatus" />
</resultMap>
<sql id="ZxBankEntity_Base_Column_List">
data_id as dataId
,source_flow_number as sourceFlowNumber
,document_no as documentNo
,company_code as companyCode
,fund_type as fundType
,digest as digest
,pay_account_num as payAccountNum
,pay_account_name as payAccountName
,rec_account_num as recAccountNum
,rec_account_name as recAccountName
,rec_bank_code as recBankCode
,settle_account_type as settleAccountType
,pay_channel as payChannel
,currency as currency
,trans_amount as transAmount
,pay_date as payDate
,to_public as toPublic
,purpose as purpose
,submit_user as submitUser
,tab_name as tabName
,pay_result_field as payResultField
,pay_date_field as payDateField
,receipt_filed as receiptFiled
,push_status_field as pushStatusField
,pay_result as payResult
,receipt as receipt
,push_status as pushStatus
</sql>
<select id="queryZxBank" resultMap="get-ZxBankEntity-result" parameterType="com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity">
select
<include refid="ZxBankEntity_Base_Column_List" />
from v_hzya_pay where push_status is null
</select>
<select id="queryResultIsNull" resultMap="get-ZxBankEntity-result" parameterType="com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity">
select
<include refid="ZxBankEntity_Base_Column_List" />
from v_hzya_pay where push_status is not null and pay_result is null
</select>
<select id="queryElecIsNull" resultMap="get-ZxBankEntity-result" parameterType="com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity">
select
<include refid="ZxBankEntity_Base_Column_List" />
from v_hzya_pay where pay_result='已支付' and receipt is null
</select>
<!--通过主键修改方法-->
<update id="updatePushStatus" parameterType = "com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity" >
update ${tabName} set ${pushStatusField} =#{pushStatus} where id=#{dataId}
</update>
<!--通过主键修改方法-->
<update id="updateResultStatus" parameterType = "com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity" >
update ${tabName} set ${payResultField} =#{payResult} where id=#{dataId}
</update>
</mapper>

View File

@ -0,0 +1,38 @@
package com.hzya.frame.sysnew.zxbank.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IZxBankService extends IBaseService<ZxBankEntity,String> {
/**
*
* @content 查询付款单未推送的数据到中台
* @Param
* @Return
* @Author hecan
* @Date 2025-03-18 9:53
* **/
JsonResultEntity queryArchives(JSONObject jsonObject);
/**
*
* @content 查询已推送并且支付结果为空的数据
* @Param
* @Return
* @Author hecan
* @Date 2025-03-18 17:39
* **/
JsonResultEntity queryArchivesResult(JSONObject jsonObject);
/**
*
* @content 查询电子回单
* @Param
* @Return
* @Author hecan
* @Date 2025-03-19 14:18
* **/
JsonResultEntity queryArchivesElec(JSONObject jsonObject);
}

View File

@ -0,0 +1,360 @@
package com.hzya.frame.sysnew.zxbank.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.sysnew.zxbank.dao.IZxBankDao;
import com.hzya.frame.sysnew.zxbank.entity.PayState;
import com.hzya.frame.sysnew.zxbank.entity.ZxBankEntity;
import com.hzya.frame.sysnew.zxbank.service.IZxBankService;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service("ZxBankServiceImpl")
public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> implements IZxBankService {
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
@Autowired
private IZxBankDao zxBankDao;
@Autowired
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Value("${zt.url}")
private String url;
@Override
public JsonResultEntity queryArchives(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
//根据插件分类查询主数据来源表
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
if (CollectionUtils.isEmpty(list)) {
logger.info("没有类型为插件得数据,无法获取数据");
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
String tableName = "";
List<Object> object=new ArrayList<>();
List<JSONObject> listAll = new ArrayList<>();
try {
String appTyp = mdmModuleSourceEntity.getAppType();//系统类型 1致远OA 2用友U8C 3用友BIP
String dbCode = mdmModuleSourceEntity.getDbCode();//数据源编码
String mdmCode = mdmModuleSourceEntity.getMdmCode();//主数据编码
switch (appTyp){
case "1":
switch (mdmCode){
case ""://杭泰付款单
tableName = "mdm_zxbank";
listAll = bindingZxBank(jsonObject, mdmModuleSourceEntity, dbCode);
break;
default:
break;
}
break;
default:
break;
}
//将查询出来的数据进行组装调用通用方法新增或者更新
if (null != listAll && listAll.size() > 0) {
object = ParametricDocument(listAll, mdmCode, tableName);
if (CollectionUtils.isNotEmpty(object)) {
for (Object obj : object) {
//更新单据视图推送标识不再抽取
JSONObject attributeResult = (JSONObject) JSON.toJSON(obj);
if (attributeResult.getString("status").equals("200")) {
String resultString = attributeResult.getString("list");
if ("".equals(mdmCode)) {
JSONArray jsonArray = JSONArray.parseArray(resultString);
if (CollectionUtils.isNotEmpty(jsonArray)) {
for (Object o : jsonArray) {
JSONObject attributeArray = (JSONObject) JSON.toJSON(o);
String mdmZxBank = attributeArray.getString(tableName);
JSONObject jsonObjectCmpApply = JSONObject.parseObject(mdmZxBank);
String pushStatusField = jsonObjectCmpApply.getString("push_status_field");//推送标识字段
String dataId = jsonObjectCmpApply.getString("data_id");//主表id
String documentNo = jsonObjectCmpApply.getString("document_no");
logger.info("=====开始根据单据id:{},单据号:{},更新杭泰表:{}的推送标识", dataId, documentNo, tableName);
ZxBankEntity zxBankEntity = new ZxBankEntity();
zxBankEntity.setTabName(jsonObjectCmpApply.getString("tab_name"));
zxBankEntity.setPushStatusField(pushStatusField);
zxBankEntity.setPushStatus("1");
zxBankEntity.setId(dataId);
zxBankEntity.setDataSourceCode(mdmModuleSourceEntity.getDataSourceCode());
zxBankDao.updatePushStatus(zxBankEntity);
//保存业务数据日志
saveTaskLivingDetails(dataId, jsonObjectCmpApply.getString("document_no"), listAll.get(0).toString(), object.toString(), true,"ZxBankPluginInitializer");
}
}
}
} else {
saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("mdm_zxbank")).getString("data_id"), JSONObject.parseObject(listAll.get(0).getString("mdm_zxbank")).getString("document_no"), listAll.get(0).toString(), JSON.parseObject(JSON.toJSONString(object)).getString("msg"), false,"ZxBankPluginInitializer");
}
}
}
} else {
logger.info("三维单据视图数据没有需要同步中台的数据");
}
}catch (Exception e){
logger.info("杭泰付款单同步失败:{}",e.getMessage());
saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("mdm_zxbank")).getString("data_id"),JSONObject.parseObject(listAll.get(0).getString("mdm_zxbank")).getString("document_no"),listAll.get(0).toString(),JSON.parseObject(JSON.toJSONString(object)).getString("msg")==null?JSON.parseObject(JSON.toJSONString(object)).getString("list"):JSON.parseObject(JSON.toJSONString(object)).getString("msg"),false,"ZxBankPluginInitializer");
e.printStackTrace();
}
}
return BaseResult.getSuccessMessageEntity("业务数据同步成功");
}
@Override
public JsonResultEntity queryArchivesResult(JSONObject json) {
try {
JSONObject jsonObject = json.getJSONObject("jsonStr");
ZxBankEntity zxBankEntity = jsonObject.toJavaObject(ZxBankEntity.class);
zxBankEntity.setDataSourceCode("");
logger.info("======开始查询中信返回的支付结果=====");
List<ZxBankEntity> zxBankEntities = zxBankDao.queryResultIsNull(zxBankEntity);
if(CollectionUtils.isEmpty(zxBankEntities)){
logger.info("=====杭泰付款单中没有已推送并且支付结果为空的数据========");
return BaseResult.getSuccessMessageEntity("查询成功");
}
for (ZxBankEntity bankEntity : zxBankEntities) {
List<String> list = new ArrayList<>();
list.add(bankEntity.getDocumentNo());
String params = String.join(", ", list);
logger.info("=======杭泰付款单调用中信支付结果查询请求参数为:{}", params);
//发送数据
String result = HttpRequest.post(url).
header("appId", "").
header("apiCode", "").
//header("access_token", tokenBody).
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj").
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(params).
execute().
body();
logger.info("========杭泰付款单调用中信支付结果查询返回参数为:{}==========", result);
JSONObject resultJson = JSONObject.parseObject(result);
if (!resultJson.getBoolean("flag")) {
saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), params, resultJson.toJSONString(), false,"ZxBankResultPluginInitializer");
} else {
String data = resultJson.getString("data");
JSONObject jsonObjectData = JSONObject.parseObject(data);
JSONArray jsonArray = jsonObjectData.getJSONArray("list");
if(CollectionUtils.isNotEmpty(jsonArray)){
for (Object o : jsonArray) {
JSONObject jsonObjectList=(JSONObject) JSON.toJSON(o);
String documentNo = jsonObjectList.getString("documentNo");//返回的业务单据号
String payStatus = jsonObjectList.getString("payStatus");//返回的状态
String errorMsg = jsonObjectList.getString("errorMsg");//返回的错误信息
logger.info("====付款單查询中信返回的单据号为:{},返回结果为:{},错误信息为:{}",documentNo,payStatus,errorMsg);
if(documentNo.equals(bankEntity.getDocumentNo())){
//修改支付状态
bankEntity.setPayResult(PayState.payStateGetValue(payStatus));
zxBankDao.updateResultStatus(bankEntity);
saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), params, resultJson.toJSONString(), true,"ZxBankResultPluginInitializer");
}
}
}else{
logger.info("====查询支付结果返回值中的list为空====");
}
}
}
logger.info("========杭泰付款单查询支付结果执行成功========");
return BaseResult.getSuccessMessageEntity("支付结果查询成功");
}catch (Exception e){
logger.info("=========查询中信返回的支付结果失败=======",e.getMessage());
e.printStackTrace();
}
return BaseResult.getFailureMessageEntity("支付结果查询失败");
}
@Override
public JsonResultEntity queryArchivesElec(JSONObject json) {
try {
JSONObject jsonObject = json.getJSONObject("jsonStr");
ZxBankEntity zxBankEntity = jsonObject.toJavaObject(ZxBankEntity.class);
zxBankEntity.setDataSourceCode("");
logger.info("======开始查询中信电子回单=====");
List<ZxBankEntity> zxBankEntities = zxBankDao.queryElecIsNull(zxBankEntity);
if(CollectionUtils.isEmpty(zxBankEntities)){
logger.info("=====杭泰付款单中没有已支付并且电子回单为空的数据========");
return BaseResult.getSuccessMessageEntity("查询成功");
}
for (ZxBankEntity bankEntity : zxBankEntities) {
JSONObject jsonParam=new JSONObject();
jsonParam.put("companyCode",bankEntity.getCompanyCode());//公司编码
jsonParam.put("documentNo",bankEntity.getDocumentNo());//单据号
String params = jsonParam.toJSONString();
logger.info("======杭泰付款单调用中信电子回单查询请求参数为:{}========",params);
//发送数据
String result = HttpRequest.post(url).
header("appId", "").
header("apiCode", "").
//header("access_token", tokenBody).
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj").
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(params).
execute().
body();
logger.info("======杭泰付款单调用中信电子回单查询返回参数为:{}========",result);
JSONObject resultJson = JSONObject.parseObject(result);
if (!resultJson.getBoolean("flag")) {
saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), params, resultJson.toJSONString(), false,"ZxBankElecPluginInitializer");
} else {
String data = resultJson.getString("data");
JSONObject jsonObjectData = JSONObject.parseObject(data);
String billId = jsonObjectData.getString("billId"); //电子回单id 电子回单下载需要
logger.info("======中信电子回单返回的电子回单id为:{}====",billId);
if(StrUtil.isNotEmpty(billId)){
List<String> list=new ArrayList<>();
list.add(billId);
String paramList = String.join(", ", list);
logger.info("====调用中信电子回单下载得请求参数为:{}=======",paramList);
elecDownlod(paramList);
}
}
}
}catch (Exception e){
logger.info("======杭泰付款单查询中信电子回单失败:{}",e.getMessage());
e.printStackTrace();
}
return null;
}
private JsonResultEntity elecDownlod(String params){
try {
//发送数据
String result = HttpRequest.post(url).
header("appId", "").
header("apiCode", "").
//header("access_token", tokenBody).
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj").
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(params).
execute().
body();
logger.info("======杭泰付款单调用中信电子回单下载返回参数为:{}========",result);
}catch (Exception e){
logger.info("=======中信电子回单下载失败:{}======",e.getMessage());
e.printStackTrace();
}
return null;
}
private List<JSONObject> bindingZxBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
List<JSONObject> list = new ArrayList<>();
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select * from v_hzya_pay where 1=1 and pushStatus is null ");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = zxBankDao.queryListByBank(stringBuffer.toString(), mdmModuleSourceEntity);
int i = 0;
if (CollectionUtils.isNotEmpty(hashMaps)) {
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject bank = new JSONObject();
for (String key : hashMap.keySet()) {
bank.put(key.toLowerCase(), hashMap.get(key));
}
main.put("mdm_zxbank", bank);
list.add(main);
}
}
return list;
}
private List<Object> ParametricDocument(List<JSONObject> hashMaps,String mdmCode,String tableName){
JSONObject jsonObjectUser = new JSONObject();
List<Object> result=new ArrayList<>();
try {
for (JSONObject hashMap : hashMaps) {
JSONObject main = hashMap.getJSONObject(tableName);
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("data_id", main.get("data_id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在
Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr);
logger.info("得到的attribute值为{}", jsonStr.toJSONString(attribute));
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
JSONObject pageInfo = jsonObjectAttribute.getJSONObject("pageInfo");
JSONArray jsonArrayList = pageInfo.getJSONArray("list");
//如果jsonArrayList为null说明没有值在表中不存在
if (jsonArrayList == null || jsonArrayList.size() == 0) {
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
Object object = comparisonServiceimpl.saveEntity(jsonStr);
logger.info("应付单新增结果为:{}", JSON.toJSONString(object));
result.add(object);
} else {
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
Object object = comparisonServiceimpl.updateEntity(jsonStr);
logger.info("应付单更新结果为:{}", JSON.toJSONString(result));
result.add(object);
}
}
return result;
}catch (Exception e){
logger.info("将数据查询之后进行组装调用通用方法错误:{}",e.getMessage());
//保存业务数据日志
saveTaskLivingDetails(jsonObjectUser.getString("data_id"),hashMaps.get(0).getString("documentNo"),hashMaps.get(0).toString(),result.toString(),false,"ZxBankPluginInitializer");
e.printStackTrace();
}
return null;
}
private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag,String plugin) {
try {
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
integrationTaskLivingDetailsEntity.setSts("Y");
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
integrationTaskLivingDetailsEntity.setModify_user_id("1");
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
integrationTaskLivingDetailsEntity.setModify_time(new Date());
integrationTaskLivingDetailsEntity.setOrg_id("0");
integrationTaskLivingDetailsEntity.setCompanyId("0");
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill);
integrationTaskLivingDetailsEntity.setPluginId(plugin);
integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo);
if(flag){
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
}else {
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
}
}catch (Exception e){
logger.info("抽取杭泰付款单保存日志到集成任务日志明细中失败:{}",e.getMessage());
e.printStackTrace();
}
}
}