From 3a0c91c7ddedbe3a48baadc9a21603fc0db2ad77 Mon Sep 17 00:00:00 2001 From: wangrangrang Date: Tue, 18 Jul 2023 15:03:45 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E8=AE=B0=E5=BD=95=E8=A1=A8=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/generator.properties | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/order-management-consumer/src/main/resources/generator.properties b/order-management-consumer/src/main/resources/generator.properties index 801eb0c6..cf48402f 100644 --- a/order-management-consumer/src/main/resources/generator.properties +++ b/order-management-consumer/src/main/resources/generator.properties @@ -1,25 +1,25 @@ #Mybatis Generator configuration #\u751F\u6210\u6570\u636E\u7684\u4E3B\u76EE\u5F55 -projectPath=src/main/java/sn +projectPath=src/main/java #\u751F\u6210\u6570\u636E\u7684\u8D44\u6E90\u76EE\u5F55 -mapLocation=src/main/resources/sn +mapLocation=src/main/resources #\u6570\u636E\u5E93\u9A71\u52A8\u5305\u8DEF\u5F84 -mysqlConJarPath=C:/Users/liufeilong/.m2/repository/mysql/mysql-connector-java/5.1.35/mysql-connector-java-5.1.35.jar +mysqlConJarPath=/Users/wangrangrang/Documents/office-software/apache-maven-3.8.6/repository/mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32.jar #\u6570\u636E\u5E93\u9A71\u52A8\u8DEF\u5F84 jdbc_driver=com.mysql.jdbc.Driver #\u6570\u636E\u5E93\u5730\u5740 -jdbc_url=jdbc:mysql://10.1.1.76:3306/sales_order_sdenergy?useUnicode=true&characterEncoding=utf8&useSSL=false +jdbc_url=jdbc:mysql://172.31.36.143:36000/sales_order?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true #\u6570\u636E\u5E93\u7528\u6237 -jdbc_user=root +jdbc_user=sales_manager #\u6570\u636E\u5E93\u5BC6\u7801 -jdbc_password=dxhydever +jdbc_password=ueHjqtam%zB^WqW5 #\u5B9E\u4F53\u5BF9\u8C61\u751F\u6210\u8DEF\u5F84 -javaModelTargetPath=com.dxhy.order.model +javaModelTargetPath=com.dxhy.order.consumer.model #xml\u751F\u6210\u8DEF\u5F84 xmlTargetPath=mybatis.mapper #\u6570\u636E\u5E93dao\u5C42 -daoTargetPath=com.dxhy.order.dao +daoTargetPath=com.dxhy.order.consumer.dao #\u9700\u8981\u751F\u6210\u6570\u636E\u7684\u8868\u540D -tableName=invoice_remark_set +tableName=push_info_record #\u9700\u8981\u751F\u6210\u6570\u636E\u7684\u5B9E\u4F53\u5BF9\u8C61\u540D\u79F0 -domainObjectName=InvoiceRemarkSet +domainObjectName=PushInfoRecord From d92f547e932d71e8d99c224f645e2a4cee32793e Mon Sep 17 00:00:00 2001 From: wangrangrang Date: Tue, 18 Jul 2023 15:04:17 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E8=AE=B0=E5=BD=95=E8=A1=A8=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../consumer/dao/PushInfoRecordMapper.java | 19 +++ .../order/consumer/model/PushInfoRecord.java | 24 ++++ .../mybatis/mapper/PushInfoRecordMapper.xml | 136 ++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java create mode 100644 order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java create mode 100644 order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java new file mode 100644 index 00000000..1e2d3ac3 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java @@ -0,0 +1,19 @@ +package com.dxhy.order.consumer.dao; + +import com.dxhy.order.consumer.model.PushInfoRecord; + +public interface PushInfoRecordMapper { + int deleteByPrimaryKey(Long id); + + int insert(PushInfoRecord record); + + int insertSelective(PushInfoRecord record); + + PushInfoRecord selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(PushInfoRecord record); + + int updateByPrimaryKeyWithBLOBs(PushInfoRecord record); + + int updateByPrimaryKey(PushInfoRecord record); +} \ No newline at end of file diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java new file mode 100644 index 00000000..b2631339 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java @@ -0,0 +1,24 @@ +package com.dxhy.order.consumer.model; + +import lombok.Data; + +import java.util.Date; + +@Data +public class PushInfoRecord { + private Long id; + + private String interfacePushType; + + private String qyType; + + private String pushStatus; + + private Date createTime; + + private String pushContent; + + private String result; + + private String failReason; +} \ No newline at end of file diff --git a/order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml b/order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml new file mode 100644 index 00000000..60b1e21f --- /dev/null +++ b/order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + id, interface_push_type, qy_type, push_status, create_time,push_content, result, fail_reason + + + + delete from push_info_record + where id = #{id,jdbcType=BIGINT} + + + insert into push_info_record (id, interface_push_type, qy_type, + push_status, create_time, push_content, + result, fail_reason) + values (#{id,jdbcType=BIGINT}, #{interfacePushType,jdbcType=VARCHAR}, #{qyType,jdbcType=VARCHAR}, + #{pushStatus,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{pushContent,jdbcType=LONGVARCHAR}, + #{result,jdbcType=LONGVARCHAR}, #{failReason,jdbcType=LONGVARCHAR}) + + + insert into push_info_record + + + id, + + + interface_push_type, + + + qy_type, + + + push_status, + + + create_time, + + + push_content, + + + result, + + + fail_reason, + + + + + #{id,jdbcType=BIGINT}, + + + #{interfacePushType,jdbcType=VARCHAR}, + + + #{qyType,jdbcType=VARCHAR}, + + + #{pushStatus,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{pushContent,jdbcType=LONGVARCHAR}, + + + #{result,jdbcType=LONGVARCHAR}, + + + #{failReason,jdbcType=LONGVARCHAR}, + + + + + update push_info_record + + + interface_push_type = #{interfacePushType,jdbcType=VARCHAR}, + + + qy_type = #{qyType,jdbcType=VARCHAR}, + + + push_status = #{pushStatus,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + push_content = #{pushContent,jdbcType=LONGVARCHAR}, + + + result = #{result,jdbcType=LONGVARCHAR}, + + + fail_reason = #{failReason,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + update push_info_record + set interface_push_type = #{interfacePushType,jdbcType=VARCHAR}, + qy_type = #{qyType,jdbcType=VARCHAR}, + push_status = #{pushStatus,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + push_content = #{pushContent,jdbcType=LONGVARCHAR}, + result = #{result,jdbcType=LONGVARCHAR}, + fail_reason = #{failReason,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=BIGINT} + + + update push_info_record + set interface_push_type = #{interfacePushType,jdbcType=VARCHAR}, + qy_type = #{qyType,jdbcType=VARCHAR}, + push_status = #{pushStatus,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file From 265b1816c3cc321a8404d0bd7aa850aef4b6cf69 Mon Sep 17 00:00:00 2001 From: wangrangrang Date: Thu, 20 Jul 2023 15:31:39 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=94=B5=E5=95=86?= =?UTF-8?q?=E3=80=81=E5=95=86=E6=97=85=E3=80=81=E5=BD=B1=E5=83=8F=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E6=97=A5=E5=BF=97=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=89=8B=E5=8A=A8=E8=A1=A5=E5=81=BF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/consumer/model/PushInfoRecord.java | 36 ++- .../manager/service/PushInvoiceService.java | 28 +- .../service/impl/PushInvoiceServiceImpl.java | 126 +++++++- .../controller/InvoicePushController.java | 36 +++ .../order/service/InvoicePushService.java | 20 ++ .../service/impl/InvoicePushServiceImpl.java | 306 ++++++++++++++++++ 6 files changed, 522 insertions(+), 30 deletions(-) create mode 100644 order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/controller/InvoicePushController.java create mode 100644 order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/InvoicePushService.java create mode 100644 order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/impl/InvoicePushServiceImpl.java diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java index b2631339..a7c1915f 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java @@ -7,18 +7,40 @@ import java.util.Date; @Data public class PushInfoRecord { private Long id; - + /** + * 接口类型 + */ private String interfacePushType; - + /** + * 企业类型 + */ private String qyType; - + /** + * 推送状态 + */ private String pushStatus; - + /** + * 创建时间 + */ private Date createTime; - + /** + * 推送内容 + */ private String pushContent; - + /** + * 结果 + */ private String result; - + /** + * 失败原因 + */ private String failReason; + /** + * 推送路径ID + */ + private String pushInfoId; + /** + * 重试次数 + */ + private Integer retryCount; } \ No newline at end of file diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/PushInvoiceService.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/PushInvoiceService.java index 5dd6cd70..afcf99dd 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/PushInvoiceService.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/PushInvoiceService.java @@ -1,7 +1,9 @@ package com.dxhy.order.consumer.modules.manager.service; +import com.dxhy.order.exception.OrderReceiveException; import com.dxhy.order.model.R; import com.dxhy.order.invoice.module.invoice.model.PushInfo; +import com.dxhy.order.model.queue.CommonTsMqData; import java.util.List; @@ -12,14 +14,14 @@ import java.util.List; * @date :2018年10月17日 下午6:01:48 */ public interface PushInvoiceService { - + /** * 推送近一个月邮箱发送失败的数据 * * @param shList */ void pushInvoiceEmailMonthTask(List shList); - + /** * 推送统一路由 * @@ -27,7 +29,7 @@ public interface PushInvoiceService { * @return */ R pushRouting(String pushMsg); - + /** * 推送地址配置列表 * @@ -36,7 +38,7 @@ public interface PushInvoiceService { * @return */ List queryPushInfoList(PushInfo pushInfo, List shList); - + /** * 查询推送信息 * @@ -44,7 +46,7 @@ public interface PushInvoiceService { * @return */ PushInfo queryPushInfo(PushInfo pushInfo); - + /** * 更新推送信息 * @@ -52,7 +54,7 @@ public interface PushInvoiceService { * @return */ int updatePushInfo(PushInfo pushInfo); - + /** * 新增推送信息 * @@ -60,4 +62,18 @@ public interface PushInvoiceService { * @return */ int addPushInfo(PushInfo insertPushInfo); + + public String getPushContent(CommonTsMqData commonTsMqData, PushInfo pushInfo, List shList) throws OrderReceiveException; + + public String convertToYwxtParam(CommonTsMqData fpTsMqData,String content); + + public void processPushSuccess(CommonTsMqData commonTsMqData, String s, String version); + + public R processPushFail(CommonTsMqData commonTsMqData, String pushUrl, String msg, List shList); + + public void sendImageSys(String content, String pushType, PushInfo pushInfo); + + public void successPush(Long pushInfoRecordId,String content,String result,PushInfo pushInfo,String pushtype); + + public void failPush(Long pushInfoRecordId,String content,String result,String failReason,PushInfo pushInfo,String pushType); } diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/impl/PushInvoiceServiceImpl.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/impl/PushInvoiceServiceImpl.java index ee3836b3..9b5fa69f 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/impl/PushInvoiceServiceImpl.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/impl/PushInvoiceServiceImpl.java @@ -14,6 +14,8 @@ import com.dxhy.order.baseservice.module.thirdservice.simsback.service.SimsBackS import com.dxhy.order.constant.*; import com.dxhy.order.consumer.config.OpenApiConfig; import com.dxhy.order.consumer.dao.GsClientMapper; +import com.dxhy.order.consumer.dao.PushInfoRecordMapper; +import com.dxhy.order.consumer.model.PushInfoRecord; import com.dxhy.order.consumer.model.protocol.CommonResponse; import com.dxhy.order.consumer.model.protocol.ResponseData; import com.dxhy.order.consumer.model.protocol.ResponseStatus; @@ -60,7 +62,10 @@ import com.dxhy.order.consumer.utils.OpentextUtils; import com.dxhy.order.exception.InterfaceException; import com.dxhy.order.exception.OrderReceiveException; import com.dxhy.order.invoice.config.InvoiceConfig; -import com.dxhy.order.invoice.module.invoice.dao.*; +import com.dxhy.order.invoice.module.invoice.dao.OrderInfoEscMapper; +import com.dxhy.order.invoice.module.invoice.dao.OrderInfoJdcMapper; +import com.dxhy.order.invoice.module.invoice.dao.OrderInfoQdMapper; +import com.dxhy.order.invoice.module.invoice.dao.PushInfoMapper; import com.dxhy.order.invoice.module.invoice.model.FileDownLoad; import com.dxhy.order.invoice.module.invoice.model.PushInfo; import com.dxhy.order.invoice.module.invoice.service.InvalidInvoiceService; @@ -164,6 +169,9 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { @Resource private BaseServiceConfig baseServiceConfig; + @Resource + private PushInfoRecordMapper pushInfoRecordMapper; + @Resource private GsClientMapper gsClientMapper; @Value("${snyx.salt:}") @@ -355,6 +363,56 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { return r; } + public void successPush(Long pushInfoRecordId,String content,String result,PushInfo pushInfo,String pushType){ + PushInfoRecord pushInfoRecord = new PushInfoRecord(); + pushInfoRecord.setId(Long.parseLong(DistributedKeyMaker.generateShotKey())); + pushInfoRecord.setRetryCount(0); + if(pushInfo!=null){ + pushInfoRecord.setPushInfoId(pushInfo.getId()); + pushInfoRecord.setQyType(pushInfo.getByzd1()); + } + if(pushInfoRecordId!=null){ + pushInfoRecord=pushInfoRecordMapper.selectByPrimaryKey(pushInfoRecordId); + pushInfoRecord.setRetryCount(pushInfoRecord.getRetryCount()+1); + pushInfoRecordMapper.updateByPrimaryKeySelective(pushInfoRecord); + } + pushInfoRecord.setPushContent(content); + pushInfoRecord.setInterfacePushType(pushType); + pushInfoRecord.setPushStatus("success"); + pushInfoRecord.setResult(result); + pushInfoRecord.setCreateTime(new Date()); + if(pushInfoRecordId!=null){ + pushInfoRecordMapper.updateByPrimaryKeySelective(pushInfoRecord); + }else { + pushInfoRecordMapper.insert(pushInfoRecord); + } + } + + public void failPush(Long pushInfoRecordId,String content,String result,String failReason,PushInfo pushInfo,String pushType){ + PushInfoRecord pushInfoRecord = new PushInfoRecord(); + pushInfoRecord.setId(Long.parseLong(DistributedKeyMaker.generateShotKey())); + pushInfoRecord.setRetryCount(0); + if(pushInfo!=null){ + pushInfoRecord.setPushInfoId(pushInfo.getId()); + pushInfoRecord.setQyType(pushInfo.getByzd1()); + } + if(pushInfoRecordId!=null){ + pushInfoRecord=pushInfoRecordMapper.selectByPrimaryKey(pushInfoRecordId); + pushInfoRecord.setRetryCount(pushInfoRecord.getRetryCount()+1); + } + pushInfoRecord.setPushContent(content); + pushInfoRecord.setInterfacePushType(pushType); + pushInfoRecord.setPushStatus("fail"); + pushInfoRecord.setResult(result); + pushInfoRecord.setFailReason(failReason); + pushInfoRecord.setCreateTime(new Date()); + if(pushInfoRecordId!=null){ + pushInfoRecordMapper.updateByPrimaryKeySelective(pushInfoRecord); + }else { + pushInfoRecordMapper.insert(pushInfoRecord); + } + } + private R commonPush(CommonTsMqData fpTsMqData) { R r = new R(); List shList = new ArrayList<>(); @@ -382,6 +440,7 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { if (pushInfoList.isEmpty()) { log.warn("{}税号:{},推送地址没有配置", LOGGER_MSG, fpTsMqData.getNsrsbh()); String error = "税号:" + fpTsMqData.getNsrsbh() + ",推送地址没有配置"; + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),error,error,null,fpTsMqData.getPushType()); return R.error(error); } @@ -393,23 +452,33 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { for (PushInfo pushInfo : pushInfoList) { if (StringUtils.isBlank(pushInfo.getPushUrl())) { - log.warn("税号:{},推送地址未配置", fpTsMqData.getNsrsbh()); + String error=String.format("税号:%s,推送地址未配置",fpTsMqData.getNsrsbh()); + log.warn(error); + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),error,error,pushInfo,fpTsMqData.getPushType()); continue; } pushUrl = pushInfo.getPushUrl(); //按照接口类型获取对应的报文数据 //推送影像系统 String content = getPushContent(fpTsMqData, pushInfo, shList); + if (StrUtil.isBlank(content)) { + String error=String.format("税号:%s,组装请求报文为空,不进行推送数据",fpTsMqData.getNsrsbh()); + log.warn(error); + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),error,error,pushInfo,fpTsMqData.getPushType()); + continue; + } try { //推送影像系统 - sendImageSys(content); + sendImageSys(content,fpTsMqData.getPushType(),pushInfo); } catch (Exception e) { + String error=String.format("影像推送出现异常%s,推送类型%s",e.getMessage(),fpTsMqData.getPushType()); + log.error(error); + PushInfo pushInfo1 = new PushInfo(); + pushInfo1.setId(pushInfo.getId()); + pushInfo1.setByzd1("yxxt"); + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),error,error,pushInfo,fpTsMqData.getPushType()); e.printStackTrace(); } - if (StrUtil.isBlank(content)) { - log.warn("税号:{},组装请求报文为空,不进行推送数据", fpTsMqData.getNsrsbh()); - continue; - } OrderProcessInfo orderProcessInfo = null; Map requestMap = commonDisposeService.getRequestParameter(pushInfo.getNsrsbh(), pushInfo.getZipCode(), pushInfo.getEncryptCode(), content, pushInfo.getPushUrl(), pushInfo.getInterfaceType(), pushInfo.getVersionIdent()); if (OrderInfoEnum.INTERFACE_TYPE_INVOICE_PUSH_STATUS_1.getKey().equals(fpTsMqData.getPushType())) { @@ -425,10 +494,10 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { } try { - String param = JsonUtils.getInstance().toJsonString(requestMap); - if (param.length() > 500) { - param = param.substring(0, 400); - } +// String param = JsonUtils.getInstance().toJsonString(requestMap); +// if (param.length() > 500) { +// param = param.substring(0, 400); +// } log.info("{}推送企业开始,推送企业url:{},用户:{},密码:{},推送参数:{}", LOGGER_MSG, pushInfo.getPushUrl(),baseServiceConfig.getPoUserName(),baseServiceConfig.getPoPassword(), fptsParam); long startTime = System.currentTimeMillis(); String result = ""; @@ -518,19 +587,22 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { String s = commonDisposeService.commonDecrypt(commonRequestParam1); log.info("解析结果为,{}", s); processPushSuccess(fpTsMqData, s, pushInfo.getVersionIdent()); - + successPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),s,pushInfo,fpTsMqData.getPushType()); } else { - log.error("推送数据返回的状态结果为失败,信息为:{}", dxhyInterfaceResponse.getReturnMessage()); + String error=String.format("推送数据返回的状态结果为失败,信息为:%s",dxhyInterfaceResponse.getReturnMessage()); + log.error(error); errorMsg = dxhyInterfaceResponse.getReturnMessage(); r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList); sendPushDelay = true; + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),error,error,pushInfo,fpTsMqData.getPushType()); } } else { log.error("推送返回没有接收到状态码!"); errorMsg = "未接收到企业返回推送数据"; r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList); sendPushDelay = true; + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),errorMsg,errorMsg,pushInfo,fpTsMqData.getPushType()); } } else { CommonResponse commonResponse = JSONObject.parseObject(result, CommonResponse.class); @@ -555,12 +627,14 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { errorMsg = res.getMessage(); r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList); sendPushDelay = true; + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),errorMsg,errorMsg,pushInfo,fpTsMqData.getPushType()); } } else { log.error("推送返回没有接收到状态码!"); errorMsg = "未接收到企业返回推送数据"; r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList); sendPushDelay = true; + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),errorMsg,errorMsg,pushInfo,fpTsMqData.getPushType()); } } @@ -571,6 +645,7 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { log.error("{}推送企业失败,失败信息:{}", LOGGER_MSG, errorMsg); r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList); sendPushDelay = true; + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),errorMsg,errorMsg,pushInfo,fpTsMqData.getPushType()); } } catch (Exception e) { //多路径推送,返回数据异常后继续推送 @@ -578,6 +653,7 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { errorMsg = e.getMessage(); r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList); sendPushDelay = true; + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),errorMsg,errorMsg,pushInfo,fpTsMqData.getPushType()); } } @@ -586,6 +662,7 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { errorMsg = e.getMessage(); r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList); sendPushDelay = true; + failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),errorMsg,errorMsg,null,fpTsMqData.getPushType()); } //如果需要放入延时队列需要存入队列中 if (sendPushDelay) { @@ -594,7 +671,10 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { return r; } - private void sendImageSys(String content){ + public void sendImageSys(String content, String pushType, PushInfo pushInfo){ + PushInfo pushInfo1 = new PushInfo(); + pushInfo1.setId(pushInfo.getId()); + pushInfo1.setByzd1("yxxt"); DdfpzxxV5 ddfpzxxV5 = JsonUtils.getInstance().parseObject(content.substring(1,content.length()-1), DdfpzxxV5.class); DdfpxxV5 ddfpxx = ddfpzxxV5.getDDFPXX(); OutputInvoiceRequest outputInvoiceRequest = buildInvoiceRequest(ddfpxx); @@ -605,7 +685,9 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { || OrderInfoEnum.ORDER_INVOICE_TYPE_026.getKey().equals(fplxdm) || OrderInfoEnum.ORDER_INVOICE_TYPE_028.getKey().equals(fplxdm); if(!b){ - log.info("invoiceNo:{} not eleInvoice do not push",outputInvoiceRequest.getInvoiceList().get(0).getInvoiceNumber()); + String error=String.format("invoiceNo:%s not eleInvoice do not push",outputInvoiceRequest.getInvoiceList().get(0).getInvoiceNumber()); + log.info(error); + failPush(null,content,error,error,pushInfo1,pushType); return; } } @@ -625,9 +707,19 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { String status = jsonObject.getString("status");//200 成功、 500 失败 String message = jsonObject.getString("message"); String data = jsonObject.getString("data"); + if("200".equals(status)){ + //成功 + successPush(null,content,data,pushInfo,pushType); + }else { + //失败 + failPush(null,content,message,data,pushInfo,pushType); + } //暂时不保存状态 } catch (Exception e) { + String error=String.format("影像系统推送数据异常,%s ,推送类型为%s",e.getMessage(),pushType); + log.error(error); e.printStackTrace(); + failPush(null,content,error,error,pushInfo1,pushType); } } @@ -971,7 +1063,7 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { } - private R processPushFail(CommonTsMqData commonTsMqData, String pushUrl, String msg, List shList) { + public R processPushFail(CommonTsMqData commonTsMqData, String pushUrl, String msg, List shList) { if (StrUtil.isNotBlank(pushUrl)) { msg = "推送地址:" + pushUrl + "," + msg; @@ -1062,7 +1154,7 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { } - private void processPushSuccess(CommonTsMqData commonTsMqData, String s, String version) { + public void processPushSuccess(CommonTsMqData commonTsMqData, String s, String version) { //按照接口类型进行执行不同的业务 if (OrderInfoEnum.INTERFACE_TYPE_INVOICE_PUSH_STATUS_1.getKey().equals(commonTsMqData.getPushType())) { //开票推送相关业务处理 diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/controller/InvoicePushController.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/controller/InvoicePushController.java new file mode 100644 index 00000000..b0b16a00 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/controller/InvoicePushController.java @@ -0,0 +1,36 @@ +package com.dxhy.order.consumer.modules.order.controller; + +import com.dxhy.order.consumer.modules.order.service.InvoicePushService; +import com.dxhy.order.model.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @title: InvoicePushController + * @Author: wrr + * @Date: 2023/7/20 09:44 + * @Description: + */ +@RestController +@Slf4j +@RequestMapping("/invoicePush") +public class InvoicePushController { + + @Resource + private InvoicePushService invoicePushService; + + /** + * 推送重试 + * @author: wrr + * @date: 2023/7/20 09:59 + * @param pushInfoRecordId + * @return R + */ + public R retryPush(@RequestParam Long pushInfoRecordId){ + return R.ok().put("data", invoicePushService.retryPush(pushInfoRecordId)); + } +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/InvoicePushService.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/InvoicePushService.java new file mode 100644 index 00000000..601cb736 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/InvoicePushService.java @@ -0,0 +1,20 @@ +package com.dxhy.order.consumer.modules.order.service; + +import com.dxhy.order.model.R; + +/** + * @title: InvoicePushService + * @Author: wrr + * @Date: 2023/7/20 09:48 + * @Description: + */ +public interface InvoicePushService { + /** + * 重试推送 + * @author: wrr + * @date: 2023/7/20 10:00 + * @param pushInfoRecordId + * @return R + */ + R retryPush(Long pushInfoRecordId); +} diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/impl/InvoicePushServiceImpl.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/impl/InvoicePushServiceImpl.java new file mode 100644 index 00000000..e5bbd0f1 --- /dev/null +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/impl/InvoicePushServiceImpl.java @@ -0,0 +1,306 @@ +package com.dxhy.order.consumer.modules.order.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.dxhy.order.baseservice.config.BaseServiceConfig; +import com.dxhy.order.constant.*; +import com.dxhy.order.consumer.dao.PushInfoRecordMapper; +import com.dxhy.order.consumer.model.PushInfoRecord; +import com.dxhy.order.consumer.model.protocol.CommonResponse; +import com.dxhy.order.consumer.model.protocol.ResponseData; +import com.dxhy.order.consumer.model.protocol.ResponseStatus; +import com.dxhy.order.consumer.modules.manager.service.PushInvoiceService; +import com.dxhy.order.consumer.modules.order.service.InvoicePushService; +import com.dxhy.order.consumer.modules.order.service.OrderProcessService; +import com.dxhy.order.consumer.openapi.protocol.CommonRequestParam; +import com.dxhy.order.consumer.openapi.protocol.po.EsOutput; +import com.dxhy.order.consumer.openapi.protocol.po.PoCommonResponseParam; +import com.dxhy.order.consumer.openapi.protocol.v4.push.DdfptsV5; +import com.dxhy.order.consumer.openapi.protocol.v5.DxhyInterfaceResponse; +import com.dxhy.order.consumer.openapi.protocol.v5.invalid.ZffpxxV5; +import com.dxhy.order.consumer.openapi.service.CommonDisposeService; +import com.dxhy.order.invoice.module.invoice.dao.PushInfoMapper; +import com.dxhy.order.invoice.module.invoice.model.PushInfo; +import com.dxhy.order.invoice.module.invoice.service.OrderInvoiceInfoService; +import com.dxhy.order.model.OrderInvoiceInfo; +import com.dxhy.order.model.OrderProcessInfo; +import com.dxhy.order.model.R; +import com.dxhy.order.model.queue.CommonTsMqData; +import com.dxhy.order.utils.Base64Encoding; +import com.dxhy.order.utils.HttpUtils; +import com.dxhy.order.utils.JsonUtils; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @title: InvoicePushServiceImpl + * @Author: wrr + * @Date: 2023/7/20 09:48 + * @Description: + */ +@Slf4j +@Service +public class InvoicePushServiceImpl implements InvoicePushService { + private static final String LOGGER_MSG = "(推送重试业务实现类)"; + + @Resource + private PushInfoRecordMapper pushInfoRecordMapper; + @Resource + private PushInfoMapper pushInfoMapper; + + @Resource + private CommonDisposeService commonDisposeService; + + @Resource + private OrderProcessService orderProcessService; + @Resource + private OrderInvoiceInfoService orderInvoiceInfoService; + + @Resource + private BaseServiceConfig baseServiceConfig; + + @Resource + private PushInvoiceService pushInvoiceService; + + + /** + * @param pushInfoRecordId + * @return * @return R + * @author: wrr + * @date: 2023/7/20 10:01 + */ + @Override + public R retryPush(Long pushInfoRecordId) { + R r = new R(); + //查询未推送成功的数据 + PushInfoRecord pushInfoRecord = pushInfoRecordMapper.selectByPrimaryKey(pushInfoRecordId); + if (StringUtils.isBlank(pushInfoRecord.getPushContent())) { + r.put(OrderManagementConstant.CODE, "9999"); + r.put(OrderManagementConstant.ALL_MESSAGE, "推送内容为空"); + return r; + } + CommonTsMqData fpTsMqData = JSONObject.parseObject(pushInfoRecord.getPushContent(), CommonTsMqData.class); + List shList = new ArrayList<>(); + shList.add(fpTsMqData.getNsrsbh()); + //推送地址 + String pushUrl = ""; + String errorMsg = ""; + String xtly = "SAP"; + PushInfo pushInfo = new PushInfo(); + try { + //查询推送地址 + pushInfo.setId(pushInfoRecord.getPushInfoId()); + pushInfo = pushInfoMapper.selectByPushInfo(pushInfo); + log.info("查询到的推送地址信息:{}", JsonUtils.getInstance().toJsonString(pushInfo)); + + if (pushInfo == null) { + log.warn("{}税号:{},推送地址没有配置", LOGGER_MSG, fpTsMqData.getNsrsbh()); + String error = "税号:" + fpTsMqData.getNsrsbh() + ",推送地址没有配置"; + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), error, error, null, fpTsMqData.getPushType()); + r.put(OrderManagementConstant.CODE, "9999"); + r.put(OrderManagementConstant.ALL_MESSAGE, error); + return r; + } + + if (StringUtils.isBlank(pushInfo.getPushUrl())) { + String error = String.format("税号:%s,推送地址未配置", fpTsMqData.getNsrsbh()); + log.warn(error); + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), error, error, pushInfo, fpTsMqData.getPushType()); + r.put(OrderManagementConstant.CODE, "9999"); + r.put(OrderManagementConstant.ALL_MESSAGE, error); + return r; + } + pushUrl = pushInfo.getPushUrl(); + //按照接口类型获取对应的报文数据 + String content = pushInvoiceService.getPushContent(fpTsMqData, pushInfo, shList); + if (StrUtil.isBlank(content)) { + String error = String.format("税号:%s,组装请求报文为空,不进行推送数据", fpTsMqData.getNsrsbh()); + log.warn(error); + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), error, error, pushInfo, fpTsMqData.getPushType()); + r.put(OrderManagementConstant.CODE, "9999"); + r.put(OrderManagementConstant.ALL_MESSAGE, error); + return r; + } + //判断是不是影像的推送 + if ("yxxt".equals(pushInfoRecord.getQyType())) { + try { + //推送影像系统 + pushInvoiceService.sendImageSys(content, fpTsMqData.getPushType(), pushInfo); + return r; + } catch (Exception e) { + String error = String.format("影像推送出现异常%s,推送类型%s", e.getMessage(), fpTsMqData.getPushType()); + log.error(error); + pushInfo.setByzd1("yxxt"); + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), error, error, pushInfo, fpTsMqData.getPushType()); + e.printStackTrace(); + r.put(OrderManagementConstant.CODE, "9999"); + r.put(OrderManagementConstant.ALL_MESSAGE, error); + return r; + } + } + + OrderProcessInfo orderProcessInfo = null; + Map requestMap = commonDisposeService.getRequestParameter(pushInfo.getNsrsbh(), pushInfo.getZipCode(), pushInfo.getEncryptCode(), content, pushInfo.getPushUrl(), pushInfo.getInterfaceType(), pushInfo.getVersionIdent()); + if (OrderInfoEnum.INTERFACE_TYPE_INVOICE_PUSH_STATUS_1.getKey().equals(fpTsMqData.getPushType())) { + orderProcessInfo = orderProcessService.queryOrderProcessInfoByFpqqlsh(fpTsMqData.getFpTsMqData().getFpqqlsh(), null); + } else if (OrderInfoEnum.INTERFACE_TYPE_INVOICE_PUSH_STATUS_2.getKey().equals(fpTsMqData.getPushType())) { + OrderInvoiceInfo orderInvoiceInfo = orderInvoiceInfoService.selectOrderInvoiceInfoByFpdmAndFphm(fpTsMqData.getZfTsMqData().getFpdm(), fpTsMqData.getZfTsMqData().getFphm(), null); + orderProcessInfo = orderProcessService.selectByOrderId(orderInvoiceInfo.getOrderInfoId(), null); + } + String fptsParam = JsonUtils.getInstance().toJsonString(requestMap); + if (StringUtils.isNotBlank(pushInfo.getByzd1())) { + fptsParam = pushInvoiceService.convertToYwxtParam(fpTsMqData, content); + } + + log.info("{}推送企业开始,推送企业url:{},用户:{},密码:{},推送参数:{}", LOGGER_MSG, pushInfo.getPushUrl(), baseServiceConfig.getPoUserName(), baseServiceConfig.getPoPassword(), fptsParam); + long startTime = System.currentTimeMillis(); + String result = ""; + if (ConfigurerInfo.INTERFACE_VERSION_V5.equals(pushInfo.getVersionIdent()) + || ConfigurerInfo.INTERFACE_VERSION_V6.equals(pushInfo.getVersionIdent())) { + if (StringUtils.isNotBlank(pushInfo.getByzd1()) && OrderInfoEnum.SYS_SOURCE_SAP.getKey().equals(pushInfo.getByzd1())) { + result = HttpUtils.sendPo(pushInfo.getPushUrl(), fptsParam, baseServiceConfig.getPoUserName(), baseServiceConfig.getPoPassword()); + } else if (OrderInfoEnum.SYS_SOURCE_DSXT01.getKey().equals(orderProcessInfo.getXtly()) && StringUtils.isNotBlank(pushInfo.getByzd1()) + && pushInfo.getByzd1().equals(orderProcessInfo.getXtly())) { + result = HttpUtils.sendPo(pushInfo.getPushUrl(), fptsParam, baseServiceConfig.getPoUserName(), baseServiceConfig.getPoPassword()); + } else if (OrderInfoEnum.SYS_SOURCE_DSXT02.getKey().equals(orderProcessInfo.getXtly()) && StringUtils.isNotBlank(pushInfo.getByzd1()) + && pushInfo.getByzd1().equals(orderProcessInfo.getXtly())) { + Map map = Maps.newHashMap(); + map.put("ec-key", baseServiceConfig.getEcKey()); + result = HttpUtils.sendPoWithHead(pushInfo.getPushUrl(), fptsParam, baseServiceConfig.getPoUserName(), baseServiceConfig.getPoPassword(), map); + } + } else { + result = HttpUtils.doPost(pushInfo.getPushUrl(), requestMap); + } + long endTime = System.currentTimeMillis(); + log.info("{}推送企业结束,推送企业url:{},企业返回结果:{},推送耗时:{}", LOGGER_MSG, pushInfo.getPushUrl(), result, endTime - startTime); + + if (!StringUtils.isBlank(result)) { + if (ConfigurerInfo.INTERFACE_VERSION_V5.equals(pushInfo.getVersionIdent()) + || ConfigurerInfo.INTERFACE_VERSION_V6.equals(pushInfo.getVersionIdent())) { + DxhyInterfaceResponse dxhyInterfaceResponse = JsonUtils.getInstance().parseObject(result, DxhyInterfaceResponse.class); + if (OrderInfoEnum.INTERFACE_TYPE_INVOICE_PUSH_STATUS_1.getKey().equals(fpTsMqData.getPushType())) { + if (OrderInfoEnum.SYS_SOURCE_SAP.getKey().equals(xtly)) { + PoCommonResponseParam poCommonResponseParam = JsonUtils.getInstance().parseObject(result, PoCommonResponseParam.class); + EsOutput es_output = poCommonResponseParam.getES_OUTPUT(); + String sapkey = es_output.getSAPKEY(); + String ztype = es_output.getZTYPE(); + String zmessage = es_output.getZMESSAGE(); + List resultList = new ArrayList<>(); + DdfptsV5 ddfptsV5 = new DdfptsV5(); + ddfptsV5.setDDQQLSH(fpTsMqData.getFpTsMqData().getFpqqlsh()); + ddfptsV5.setNSRSBH(""); + if (OrderInfoContentEnum.INVOICE_ERROR_CODE_OP_S.getKey().equals(ztype)) { + ddfptsV5.setZTDM(ConfigureConstant.STRING_000000); + } else { + ddfptsV5.setZTDM(ConfigureConstant.STRING_9999); + } + ddfptsV5.setZTXX(zmessage); + dxhyInterfaceResponse.setReturnCode(ConfigureConstant.STRING_000000); + dxhyInterfaceResponse.setReturnMessage("处理成功"); + dxhyInterfaceResponse.setEncryptCode(ConfigurerInfo.ENCRYPTCODE_0); + dxhyInterfaceResponse.setZipCode(ConfigurerInfo.ENCRYPTCODE_0); + resultList.add(ddfptsV5); + dxhyInterfaceResponse.setContent(Base64Encoding.encode(JsonUtils.getInstance().toJsonString(resultList))); + } else { + dxhyInterfaceResponse = JsonUtils.getInstance().parseObject(result, DxhyInterfaceResponse.class); + } + } else if (OrderInfoEnum.INTERFACE_TYPE_INVOICE_PUSH_STATUS_2.getKey().equals(fpTsMqData.getPushType())) { + if (OrderInfoEnum.SYS_SOURCE_SAP.getKey().equals(xtly)) { + PoCommonResponseParam poCommonResponseParam = JsonUtils.getInstance().parseObject(result, PoCommonResponseParam.class); + EsOutput es_output = poCommonResponseParam.getES_OUTPUT(); + String ztype = es_output.getZTYPE(); + String zmessage = es_output.getZMESSAGE(); + ZffpxxV5 zffpxxV5 = new ZffpxxV5(); + zffpxxV5.setXHFSBH(fpTsMqData.getZfTsMqData().getNsrsbh()); + zffpxxV5.setFPDM(fpTsMqData.getZfTsMqData().getFpdm()); + zffpxxV5.setFPHM(fpTsMqData.getZfTsMqData().getFphm()); + if (OrderInfoContentEnum.INVOICE_ERROR_CODE_OP_S.getKey().equals(ztype)) { + zffpxxV5.setZTDM(ConfigureConstant.STRING_000000); + } else { + zffpxxV5.setZTDM(ConfigureConstant.STRING_9999); + } + zffpxxV5.setZTXX(zmessage); + dxhyInterfaceResponse.setReturnCode(ConfigureConstant.STRING_000000); + dxhyInterfaceResponse.setReturnMessage("处理成功"); + dxhyInterfaceResponse.setEncryptCode(ConfigurerInfo.ENCRYPTCODE_0); + dxhyInterfaceResponse.setZipCode(ConfigurerInfo.ENCRYPTCODE_0); + dxhyInterfaceResponse.setContent(Base64Encoding.encode(JsonUtils.getInstance().toJsonString(zffpxxV5))); + } else { + dxhyInterfaceResponse = JsonUtils.getInstance().parseObject(result, DxhyInterfaceResponse.class); + } + } + + if (ObjectUtil.isNotNull(dxhyInterfaceResponse)) { + if (ConfigureConstant.STRING_000000.equals(dxhyInterfaceResponse.getReturnCode())) { + CommonRequestParam commonRequestParam1 = new CommonRequestParam(); + commonRequestParam1.setContent(dxhyInterfaceResponse.getContent()); + commonRequestParam1.setEncryptCode(dxhyInterfaceResponse.getEncryptCode()); + commonRequestParam1.setZipCode(dxhyInterfaceResponse.getZipCode()); + commonRequestParam1.setSecretId(commonDisposeService.getAuthMap(pushInfo.getNsrsbh())); + String s = commonDisposeService.commonDecrypt(commonRequestParam1); + log.info("解析结果为,{}", s); + pushInvoiceService.processPushSuccess(fpTsMqData, s, pushInfo.getVersionIdent()); + pushInvoiceService.successPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), s, pushInfo, fpTsMqData.getPushType()); + + } else { + String error = String.format("推送数据返回的状态结果为失败,信息为:%s", dxhyInterfaceResponse.getReturnMessage()); + log.error(error); + errorMsg = dxhyInterfaceResponse.getReturnMessage(); + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), error, error, pushInfo, fpTsMqData.getPushType()); + } + } else { + log.error("推送返回没有接收到状态码!"); + errorMsg = "未接收到企业返回推送数据"; + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), errorMsg, errorMsg, pushInfo, fpTsMqData.getPushType()); + } + } else { + CommonResponse commonResponse = JSONObject.parseObject(result, CommonResponse.class); + if (commonResponse != null && commonResponse.getResponseStatus() != null) { + + ResponseStatus res = commonResponse.getResponseStatus(); + String code = res.getCode(); + ResponseData responseData = commonResponse.getResponseData(); + + if (ConfigureConstant.STRING_0000.equals(code) || ConfigureConstant.STRING_2000.equals(code)) { + CommonRequestParam commonRequestParam1 = new CommonRequestParam(); + commonRequestParam1.setContent(responseData.getContent()); + commonRequestParam1.setEncryptCode(responseData.getEncryptCode()); + commonRequestParam1.setZipCode(responseData.getZipCode()); + commonRequestParam1.setSecretId(commonDisposeService.getAuthMap(pushInfo.getNsrsbh())); + String s = commonDisposeService.commonDecrypt(commonRequestParam1); + log.info("解析结果为,{}", s); + pushInvoiceService.processPushSuccess(fpTsMqData, s, pushInfo.getVersionIdent()); + + } else { + log.error("推送数据返回的状态结果为失败!"); + errorMsg = res.getMessage(); + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), errorMsg, errorMsg, pushInfo, fpTsMqData.getPushType()); + } + } else { + log.error("推送返回没有接收到状态码!"); + errorMsg = "未接收到企业返回推送数据"; + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), errorMsg, errorMsg, pushInfo, fpTsMqData.getPushType()); + } + + } + } + } catch (Exception e) { + log.error("{}推送异常,异常信息:{}", LOGGER_MSG, e); + errorMsg = e.getMessage(); + } + if (StrUtil.isNotBlank(errorMsg)) { + log.error("{}推送失败,失败信息:{}", LOGGER_MSG, errorMsg); + r = pushInvoiceService.processPushFail(fpTsMqData, pushUrl, errorMsg, shList); + pushInvoiceService.failPush(pushInfoRecordId, JsonUtils.getInstance().toJsonString(fpTsMqData), errorMsg, errorMsg, pushInfo, fpTsMqData.getPushType()); + } + return r; + } +} From 6c98369bd54cbafe4284f2924c22733fa21b9588 Mon Sep 17 00:00:00 2001 From: wangrangrang Date: Thu, 20 Jul 2023 15:46:47 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../consumer/dao/PushInfoRecordMapper.java | 2 - .../mybatis/mapper/PushInfoRecordMapper.xml | 40 +++++++++++++------ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java index 1e2d3ac3..643d2590 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java @@ -13,7 +13,5 @@ public interface PushInfoRecordMapper { int updateByPrimaryKeySelective(PushInfoRecord record); - int updateByPrimaryKeyWithBLOBs(PushInfoRecord record); - int updateByPrimaryKey(PushInfoRecord record); } \ No newline at end of file diff --git a/order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml b/order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml index 60b1e21f..3daa9ad3 100644 --- a/order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml +++ b/order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml @@ -10,9 +10,11 @@ + + - id, interface_push_type, qy_type, push_status, create_time,push_content, result, fail_reason + id, interface_push_type, qy_type, push_status, create_time,push_content, result, fail_reason,push_info_id,retry_count