Merge remote-tracking branch 'origin/feature/push_record' into release

release
WangQi 2 years ago
commit 810ee41257
  1. 17
      order-management-consumer/src/main/java/com/dxhy/order/consumer/dao/PushInfoRecordMapper.java
  2. 46
      order-management-consumer/src/main/java/com/dxhy/order/consumer/model/PushInfoRecord.java
  3. 16
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/PushInvoiceService.java
  4. 150
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/manager/service/impl/PushInvoiceServiceImpl.java
  5. 38
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/controller/InvoicePushController.java
  6. 20
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/InvoicePushService.java
  7. 308
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/order/service/impl/InvoicePushServiceImpl.java
  8. 20
      order-management-consumer/src/main/resources/generator.properties
  9. 150
      order-management-consumer/src/main/resources/mybatis/mapper/PushInfoRecordMapper.xml

@ -0,0 +1,17 @@
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 updateByPrimaryKey(PushInfoRecord record);
}

@ -0,0 +1,46 @@
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;
/**
* 推送路径ID
*/
private String pushInfoId;
/**
* 重试次数
*/
private Integer retryCount;
}

@ -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;
@ -60,4 +62,18 @@ public interface PushInvoiceService {
* @return
*/
int addPushInfo(PushInfo insertPushInfo);
public String getPushContent(CommonTsMqData commonTsMqData, PushInfo pushInfo, List<String> 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<String> shList);
public R sendImageSys(String content, String pushType, PushInfo pushInfo, Long id);
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);
}

@ -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,64 @@ public class PushInvoiceServiceImpl implements PushInvoiceService {
return r;
}
public void successPush(Long pushInfoRecordId,String content,String result,PushInfo pushInfo,String pushType){
try {
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.updateByPrimaryKey(pushInfoRecord);
}else {
pushInfoRecordMapper.insert(pushInfoRecord);
}
} catch (Exception e) {
log.error("记录推送成功日志出错,"+e.getMessage());
}
}
public void failPush(Long pushInfoRecordId,String content,String result,String failReason,PushInfo pushInfo,String pushType){
try {
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.updateByPrimaryKey(pushInfoRecord);
}else {
pushInfoRecordMapper.insert(pushInfoRecord);
}
} catch (NumberFormatException e) {
log.error("记录推送失败日志出错,"+e.getMessage());
}
}
private R commonPush(CommonTsMqData fpTsMqData) {
R r = new R();
List<String> shList = new ArrayList<>();
@ -382,6 +448,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 +460,32 @@ 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, null);
} catch (Exception e) {
String error=String.format("影像推送出现异常%s,推送类型%s",e,fpTsMqData.getPushType());
log.error(error);
PushInfo pushInfo1 = new PushInfo();
pushInfo1.setId(pushInfo.getId());
pushInfo1.setByzd1("YXXT");
failPush(null,content,error,e.getMessage(),pushInfo1,fpTsMqData.getPushType());
e.printStackTrace();
}
if (StrUtil.isBlank(content)) {
log.warn("税号:{},组装请求报文为空,不进行推送数据", fpTsMqData.getNsrsbh());
continue;
}
OrderProcessInfo orderProcessInfo = null;
Map<String, String> 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 +501,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 +594,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 +634,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,21 +652,26 @@ 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) {
//多路径推送,返回数据异常后继续推送
log.error("{}推送企业异常,异常信息:{}", LOGGER_MSG, e);
String error=String.format("%s推送企业异常,异常信息:%s",LOGGER_MSG,e);
log.error(error);
errorMsg = e.getMessage();
r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList);
sendPushDelay = true;
failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),error,errorMsg,pushInfo,fpTsMqData.getPushType());
}
}
} catch (Exception e) {
log.error("{}推送异常,异常信息:{}", LOGGER_MSG, e);
String error=String.format("%s推送异常,异常信息:%s",LOGGER_MSG,e);
log.error(error);
errorMsg = e.getMessage();
r = processPushFail(fpTsMqData, pushUrl, errorMsg, shList);
sendPushDelay = true;
failPush(null,JsonUtils.getInstance().toJsonString(fpTsMqData),error,errorMsg,null,fpTsMqData.getPushType());
}
//如果需要放入延时队列需要存入队列中
if (sendPushDelay) {
@ -594,7 +680,11 @@ public class PushInvoiceServiceImpl implements PushInvoiceService {
return r;
}
private void sendImageSys(String content){
public R sendImageSys(String content, String pushType, PushInfo pushInfo, Long id){
R r = new R();
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,8 +695,12 @@ 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());
return;
String error=String.format("invoiceNo:%s not eleInvoice do not push",outputInvoiceRequest.getInvoiceList().get(0).getInvoiceNumber());
log.info(error);
failPush(id,content,error,error,pushInfo1,pushType);
r.put(OrderManagementConstant.CODE, "9999");
r.put(OrderManagementConstant.ALL_MESSAGE, error);
return r;
}
}
@ -625,10 +719,24 @@ 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(id,content,data,pushInfo,pushType);
}else {
//失败
failPush(id,content,message,data,pushInfo,pushType);
}
//暂时不保存状态
} catch (Exception e) {
String error=String.format("影像系统推送数据异常,%s ,推送类型为%s",e.getMessage(),pushType);
log.error(error);
e.printStackTrace();
failPush(id,content,error,e.getMessage(),pushInfo1,pushType);
r.put(OrderManagementConstant.CODE, "9999");
r.put(OrderManagementConstant.ALL_MESSAGE, error);
return r;
}
return r;
}
public static void main(String[] args) {
@ -971,7 +1079,7 @@ public class PushInvoiceServiceImpl implements PushInvoiceService {
}
private R processPushFail(CommonTsMqData commonTsMqData, String pushUrl, String msg, List<String> shList) {
public R processPushFail(CommonTsMqData commonTsMqData, String pushUrl, String msg, List<String> shList) {
if (StrUtil.isNotBlank(pushUrl)) {
msg = "推送地址:" + pushUrl + "," + msg;
@ -1062,7 +1170,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())) {
//开票推送相关业务处理

@ -0,0 +1,38 @@
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.GetMapping;
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
*/
@GetMapping("/retryPush")
public R retryPush(@RequestParam Long pushInfoRecordId){
return R.ok().put("data", invoicePushService.retryPush(pushInfoRecordId));
}
}

@ -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);
}

@ -0,0 +1,308 @@
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;
}
PushInfo pushInfo = new PushInfo();
//查询推送地址
pushInfo.setId(pushInfoRecord.getPushInfoId());
pushInfo = pushInfoMapper.selectByPushInfo(pushInfo);
log.info("查询到的推送地址信息:{}", JsonUtils.getInstance().toJsonString(pushInfo));
//判断是不是影像的推送
if ("YXXT".equals(pushInfoRecord.getQyType())) {
String pushType = pushInfoRecord.getInterfacePushType();
try {
//推送影像系统
r=pushInvoiceService.sendImageSys(pushInfoRecord.getPushContent(), pushType, pushInfo,pushInfoRecord.getId());
return r;
} catch (Exception e) {
String error = String.format("影像推送出现异常%s,推送类型%s", e.getMessage(), pushType);
log.error(error);
pushInfo.setByzd1("YXXT");
pushInvoiceService.failPush(pushInfoRecordId, pushInfoRecord.getPushContent(), error, e.getMessage(), pushInfo, pushType);
e.printStackTrace();
r.put(OrderManagementConstant.CODE, "9999");
r.put(OrderManagementConstant.ALL_MESSAGE, error);
return r;
}
}
CommonTsMqData fpTsMqData = JSONObject.parseObject(pushInfoRecord.getPushContent(), CommonTsMqData.class);
List<String> shList = new ArrayList<>();
shList.add(fpTsMqData.getNsrsbh());
//推送地址
String pushUrl = "";
String errorMsg = "";
String xtly = "SAP";
try {
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;
}
OrderProcessInfo orderProcessInfo = null;
Map<String, String> 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<DdfptsV5> 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;
}
}

@ -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

@ -0,0 +1,150 @@
<?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.dxhy.order.consumer.dao.PushInfoRecordMapper" >
<resultMap id="BaseResultMap" type="com.dxhy.order.consumer.model.PushInfoRecord" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="interface_push_type" property="interfacePushType" jdbcType="VARCHAR" />
<result column="qy_type" property="qyType" jdbcType="VARCHAR" />
<result column="push_status" property="pushStatus" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="push_content" property="pushContent" jdbcType="LONGVARCHAR" />
<result column="result" property="result" jdbcType="LONGVARCHAR" />
<result column="fail_reason" property="failReason" jdbcType="LONGVARCHAR" />
<result column="push_info_id" property="pushInfoId" jdbcType="BIGINT" />
<result column="retry_count" property="retryCount" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, interface_push_type, qy_type, push_status, create_time,push_content, result, fail_reason,push_info_id,retry_count
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from push_info_record
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from push_info_record
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.dxhy.order.consumer.model.PushInfoRecord" >
insert into push_info_record (id, interface_push_type, qy_type,
push_status, create_time, push_content,
result, fail_reason, push_info_id,retry_count)
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},#{pushInfoId},#{retryCount})
</insert>
<insert id="insertSelective" parameterType="com.dxhy.order.consumer.model.PushInfoRecord" >
insert into push_info_record
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="interfacePushType != null" >
interface_push_type,
</if>
<if test="qyType != null" >
qy_type,
</if>
<if test="pushStatus != null" >
push_status,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="pushContent != null" >
push_content,
</if>
<if test="result != null" >
result,
</if>
<if test="failReason != null" >
fail_reason,
</if>
<if test="pushInfoId != null" >
push_info_id,
</if>
<if test="retryCount != null" >
retry_count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="interfacePushType != null" >
#{interfacePushType,jdbcType=VARCHAR},
</if>
<if test="qyType != null" >
#{qyType,jdbcType=VARCHAR},
</if>
<if test="pushStatus != null" >
#{pushStatus,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="pushContent != null" >
#{pushContent,jdbcType=LONGVARCHAR},
</if>
<if test="result != null" >
#{result,jdbcType=LONGVARCHAR},
</if>
<if test="failReason != null" >
#{failReason,jdbcType=LONGVARCHAR},
</if>
<if test="pushInfoId != null" >
#{pushInfoId},
</if>
<if test="retryCount != null" >
#{retryCount},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.dxhy.order.consumer.model.PushInfoRecord" >
update push_info_record
<set >
<if test="interfacePushType != null" >
interface_push_type = #{interfacePushType,jdbcType=VARCHAR},
</if>
<if test="qyType != null" >
qy_type = #{qyType,jdbcType=VARCHAR},
</if>
<if test="pushStatus != null" >
push_status = #{pushStatus,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="pushContent != null" >
push_content = #{pushContent,jdbcType=LONGVARCHAR},
</if>
<if test="result != null" >
result = #{result,jdbcType=LONGVARCHAR},
</if>
<if test="failReason != null" >
fail_reason = #{failReason,jdbcType=LONGVARCHAR},
</if>
<if test="pushInfoId != null" >
push_info_id = #{pushInfoId},
</if>
<if test="retryCount != null" >
retry_count = #{retryCount},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.dxhy.order.consumer.model.PushInfoRecord" >
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},
push_info_id = #{pushInfoId},
retry_count = #{retryCount}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
Loading…
Cancel
Save