|
|
@ -401,7 +401,12 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { |
|
|
|
//按照接口类型获取对应的报文数据
|
|
|
|
//按照接口类型获取对应的报文数据
|
|
|
|
//推送影像系统
|
|
|
|
//推送影像系统
|
|
|
|
String content = getPushContent(fpTsMqData, pushInfo, shList); |
|
|
|
String content = getPushContent(fpTsMqData, pushInfo, shList); |
|
|
|
//sendImageSys(content,"","");
|
|
|
|
try { |
|
|
|
|
|
|
|
//推送影像系统
|
|
|
|
|
|
|
|
sendImageSys(content); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
if (StrUtil.isBlank(content)) { |
|
|
|
if (StrUtil.isBlank(content)) { |
|
|
|
log.warn("税号:{},组装请求报文为空,不进行推送数据", fpTsMqData.getNsrsbh()); |
|
|
|
log.warn("税号:{},组装请求报文为空,不进行推送数据", fpTsMqData.getNsrsbh()); |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -574,103 +579,126 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private SNInvoice buildSNInvoice(String content){ |
|
|
|
private void sendImageSys(String content){ |
|
|
|
DdfpzxxV5 ddfpzxxV5 = JsonUtils.getInstance().parseObject(content.substring(1,content.length()-1), DdfpzxxV5.class); |
|
|
|
|
|
|
|
DdfpxxV5 ddfpxx = ddfpzxxV5.getDDFPXX(); |
|
|
|
OutputInvoiceRequest outputInvoiceRequest = buildInvoiceRequest(content); |
|
|
|
JdctxxV5 jdctxx = ddfpzxxV5.getJDCTXX(); |
|
|
|
if(outputInvoiceRequest.getInvoiceList() != null && outputInvoiceRequest.getInvoiceList().size() > 0){ |
|
|
|
List<DdmxxxV5> ddmxxx = ddfpzxxV5.getDDMXXX(); |
|
|
|
String fplxdm = outputInvoiceRequest.getInvoiceList().get(0).getInvoiceType(); |
|
|
|
List<SNInvoiceDetail> invoiceLineList = new ArrayList<>(); |
|
|
|
boolean b = OrderInfoEnum.ORDER_INVOICE_TYPE_001.getKey().equals(fplxdm) |
|
|
|
SNInvoice invoice = new SNInvoice(); |
|
|
|
|| OrderInfoEnum.ORDER_INVOICE_TYPE_002.getKey().equals(fplxdm) |
|
|
|
invoice.setInvoiceType(convertToSapType(ddfpxx.getFPLXDM())); |
|
|
|
|| OrderInfoEnum.ORDER_INVOICE_TYPE_026.getKey().equals(fplxdm) |
|
|
|
invoice.setInvoiceCode(ddfpxx.getFPDM()); |
|
|
|
|| OrderInfoEnum.ORDER_INVOICE_TYPE_028.getKey().equals(fplxdm); |
|
|
|
invoice.setInvoiceNumber(ddfpxx.getFPHM()); |
|
|
|
if(!b){ |
|
|
|
invoice.setBillingDate(ddfpxx.getKPRQ()); |
|
|
|
log.info("发票号码:{}为非电票不推送影像查验",outputInvoiceRequest.getInvoiceList().get(0).getInvoiceNumber()); |
|
|
|
invoice.setPurchaserName(ddfpxx.getGMFMC()); |
|
|
|
return; |
|
|
|
invoice.setPurchaserTaxNo(ddfpxx.getGMFSBH()); |
|
|
|
} |
|
|
|
invoice.setPurchaserBank(ddfpxx.getGMFYH()+ddfpxx.getGMFZH()); |
|
|
|
|
|
|
|
invoice.setPurchaserAddressPhone(ddfpxx.getGMFDZ()+ddfpxx.getGMFDH()); |
|
|
|
|
|
|
|
invoice.setSalesName(ddfpxx.getXHFMC()); |
|
|
|
|
|
|
|
invoice.setSalesTaxNo(ddfpxx.getXHFSBH()); |
|
|
|
|
|
|
|
invoice.setSalesAddressPhone(ddfpxx.getXHFDZ()+ddfpxx.getXHFDH()); |
|
|
|
|
|
|
|
invoice.setSalesBank(ddfpxx.getXHFYH()+ddfpxx.getXHFZH()); |
|
|
|
|
|
|
|
invoice.setTotalAmount(ddfpxx.getHJJE()); |
|
|
|
|
|
|
|
invoice.setTotalTax(ddfpxx.getHJSE()); |
|
|
|
|
|
|
|
invoice.setAmountTax(ddfpxx.getJSHJ()); |
|
|
|
|
|
|
|
invoice.setCheckCode(ddfpxx.getJYM()); |
|
|
|
|
|
|
|
String state = "0"; |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(ddfpxx.getZFBZ())){ |
|
|
|
|
|
|
|
state = "1"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(ddfpxx.getCHBZ())){ |
|
|
|
|
|
|
|
state = "2"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
invoice.setState(state);//发票状态(0-正常1-作废2-红冲3-失控4-异常)
|
|
|
|
|
|
|
|
invoice.setRemarks(ddfpxx.getBZ()); |
|
|
|
|
|
|
|
for (DdmxxxV5 ddmxxxV5 : ddmxxx) { |
|
|
|
|
|
|
|
SNInvoiceDetail snInvoiceDetail = new SNInvoiceDetail(); |
|
|
|
|
|
|
|
snInvoiceDetail.setRowNo(ddmxxxV5.getXH()); |
|
|
|
|
|
|
|
snInvoiceDetail.setCommodityCode(ddmxxxV5.getSPBM()); |
|
|
|
|
|
|
|
snInvoiceDetail.setCommodityName(ddmxxxV5.getXMMC()); |
|
|
|
|
|
|
|
snInvoiceDetail.setSpecificationModel(ddmxxxV5.getGGXH()); |
|
|
|
|
|
|
|
snInvoiceDetail.setUnit(ddmxxxV5.getDW()); |
|
|
|
|
|
|
|
snInvoiceDetail.setQuantity(ddmxxxV5.getSPSL()); |
|
|
|
|
|
|
|
snInvoiceDetail.setUnitPrice(ddmxxxV5.getDJ()); |
|
|
|
|
|
|
|
snInvoiceDetail.setAmount(ddmxxxV5.getJE()); |
|
|
|
|
|
|
|
snInvoiceDetail.setTax(ddmxxxV5.getSE()); |
|
|
|
|
|
|
|
snInvoiceDetail.setTaxRate(ddmxxxV5.getSL()); |
|
|
|
|
|
|
|
invoiceLineList.add(snInvoiceDetail); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
invoice.setInvoiceLineList(invoiceLineList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return invoice; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void sendImageSys(String content,String imageId,String compCode){ |
|
|
|
|
|
|
|
JSONObject request = new JSONObject(); |
|
|
|
|
|
|
|
List<SAPInvoiceInfo> sapInvoiceInfos = new ArrayList<>(); |
|
|
|
|
|
|
|
SNSAPObject object = new SNSAPObject(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SNInvoice invoice = buildSNInvoice(content); |
|
|
|
|
|
|
|
object.setSYSID("FPXT"); |
|
|
|
|
|
|
|
object.setIFYWID("FI845"); |
|
|
|
|
|
|
|
object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
|
|
|
object.setSAPKEY(""); |
|
|
|
|
|
|
|
object.setZORG("公司代码"); |
|
|
|
|
|
|
|
object.setZFILED1(""); |
|
|
|
|
|
|
|
object.setZFILED2(""); |
|
|
|
|
|
|
|
object.setZFILED3(""); |
|
|
|
|
|
|
|
object.setZFILED4(""); |
|
|
|
|
|
|
|
object.setZFILED5(invoiceConfig.getEnvironment()); |
|
|
|
|
|
|
|
SAPInvoiceInfo info = convertToSapOnject(invoice, imageId, compCode); |
|
|
|
|
|
|
|
sapInvoiceInfos.add(info); |
|
|
|
|
|
|
|
object.setZDATA(JSONObject.toJSONString(sapInvoiceInfos)); |
|
|
|
|
|
|
|
request.put("IS_INPUT", object); |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
HttpUtils.pushCheckResultToSAP(request.toJSONString(),invoiceConfig.getSnYxUrl(),invoiceConfig.getSapUserName(),invoiceConfig.getSapPassword()); |
|
|
|
String md5Encode = MD5.getMd5Encode(invoiceConfig.getSapSalt() + outputInvoiceRequest.getBillNum()); |
|
|
|
|
|
|
|
Map<String, String> headerMap = Maps.newHashMap(); |
|
|
|
|
|
|
|
headerMap.put("Authorization",md5Encode); |
|
|
|
|
|
|
|
log.info("调用影像查验接口,调用地址:{},请求头:{},请求参数:{}",invoiceConfig.getSnYxUrl(),JSONObject.toJSONString(headerMap),JSONObject.toJSONString(outputInvoiceRequest)); |
|
|
|
|
|
|
|
String body = HttpRequest.post(invoiceConfig.getSnYxUrl()).addHeaders(headerMap).body(JSONObject.toJSONString(outputInvoiceRequest)).timeout(300000).execute().body(); |
|
|
|
|
|
|
|
log.info("调用影像查验接口返回参数:{}",body); |
|
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body); |
|
|
|
|
|
|
|
String status = jsonObject.getString("status");//200 成功、 500 失败
|
|
|
|
|
|
|
|
String message = jsonObject.getString("message"); |
|
|
|
|
|
|
|
String data = jsonObject.getString("data"); |
|
|
|
|
|
|
|
//暂时不保存状态
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private String convertToSapType(String invoiceType) { |
|
|
|
|
|
|
|
|
|
|
|
private OutputInvoiceRequest buildInvoiceRequest(String content){ |
|
|
|
|
|
|
|
DdfpzxxV5 ddfpzxxV5 = JsonUtils.getInstance().parseObject(content.substring(1,content.length()-1), DdfpzxxV5.class); |
|
|
|
|
|
|
|
DdfpxxV5 ddfpxx = ddfpzxxV5.getDDFPXX(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String fplxdm = ddfpxx.getFPLXDM(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<InvoiceInfo> invoiceList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<InvoiceInfo> invalidList = new ArrayList<>(); |
|
|
|
|
|
|
|
OutputInvoiceRequest invoiceRequest = new OutputInvoiceRequest(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
invoiceRequest.setBillNum(ddfpxx.getBillNum()); |
|
|
|
|
|
|
|
invoiceRequest.setCompanyCode(ddfpxx.getCompanyCode()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if("1".equals(ddfpxx.getZFBZ())){ |
|
|
|
|
|
|
|
InvoiceInfo invalidInfo = new InvoiceInfo(); |
|
|
|
|
|
|
|
invalidInfo.setInvoiceType(convertToSapType(ddfpxx.getFPLXDM())); |
|
|
|
|
|
|
|
invalidInfo.setInvoiceCode(ddfpxx.getFPDM()); |
|
|
|
|
|
|
|
invalidInfo.setInvoiceNumber(ddfpxx.getFPHM()); |
|
|
|
|
|
|
|
invalidList.add(invalidInfo); |
|
|
|
|
|
|
|
invoiceList.clear(); |
|
|
|
|
|
|
|
invoiceRequest.setDeleteList(invalidList); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
InvoiceInfo invoiceInfo = new InvoiceInfo(); |
|
|
|
|
|
|
|
invoiceInfo.setInvoiceType(convertToSapType(ddfpxx.getFPLXDM())); |
|
|
|
|
|
|
|
invoiceInfo.setInvoiceCode(ddfpxx.getFPDM()); |
|
|
|
|
|
|
|
invoiceInfo.setInvoiceNumber(ddfpxx.getFPHM()); |
|
|
|
|
|
|
|
invoiceInfo.setFileName(ddfpxx.getFileName()); |
|
|
|
|
|
|
|
invoiceInfo.setPdfOrImg(ddfpxx.getZJLLX()); |
|
|
|
|
|
|
|
invoiceInfo.setFileByte(ddfpxx.getPDFZJL()); |
|
|
|
|
|
|
|
invoiceInfo.setBillingDate(ddfpxx.getKPRQ()); |
|
|
|
|
|
|
|
invoiceInfo.setPurchaserName(ddfpxx.getGMFMC()); |
|
|
|
|
|
|
|
invoiceInfo.setPurchaserTaxNo(ddfpxx.getGMFSBH()); |
|
|
|
|
|
|
|
invoiceInfo.setPurchaserAddressPhone(String.format("%s%s",StringUtils.isNotBlank(ddfpxx.getGMFDZ())?ddfpxx.getGMFDZ():"",StringUtils.isNotBlank(ddfpxx.getGMFDH())?ddfpxx.getGMFDH():"")); |
|
|
|
|
|
|
|
invoiceInfo.setPurchaserBank(String.format("%s%s",StringUtils.isNotBlank(ddfpxx.getGMFYH())?ddfpxx.getGMFYH():"",StringUtils.isNotBlank(ddfpxx.getGMFZH())?ddfpxx.getGMFZH():"")); |
|
|
|
|
|
|
|
invoiceInfo.setSalesName(ddfpxx.getXHFMC()); |
|
|
|
|
|
|
|
invoiceInfo.setSalesTaxNo(ddfpxx.getXHFSBH()); |
|
|
|
|
|
|
|
invoiceInfo.setSalesAddressPhone(ddfpxx.getXHFDZ()+ddfpxx.getXHFDH()); |
|
|
|
|
|
|
|
invoiceInfo.setSalesBank(ddfpxx.getXHFYH()+ddfpxx.getXHFZH()); |
|
|
|
|
|
|
|
invoiceInfo.setTotalAmount(ddfpxx.getHJJE()); |
|
|
|
|
|
|
|
invoiceInfo.setTotalTax(ddfpxx.getHJSE()); |
|
|
|
|
|
|
|
invoiceInfo.setAmountTax(ddfpxx.getJSHJ()); |
|
|
|
|
|
|
|
invoiceInfo.setCheckCode(StringUtils.isNotBlank(ddfpxx.getJYM())?ddfpxx.getJYM():""); |
|
|
|
|
|
|
|
// String state = "1".equals(ddfpxx.getZFBZ()) ? "1" : "1".equals(ddfpxx.getCHBZ()) ? "2" : "0";
|
|
|
|
|
|
|
|
invoiceInfo.setState("0"); |
|
|
|
|
|
|
|
invoiceInfo.setRemarks(StringUtils.isNotBlank(ddfpxx.getBZ())?ddfpxx.getBZ():""); |
|
|
|
|
|
|
|
//invoiceInfo.setSource(ddfpxx.getDDLX());
|
|
|
|
|
|
|
|
invoiceInfo.setMachineCode(ddfpxx.getJQBH()); |
|
|
|
|
|
|
|
invoiceList.add(invoiceInfo); |
|
|
|
|
|
|
|
invoiceRequest.setInvoiceList(invoiceList); |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(ddfpxx.getYFPDM())&&StringUtils.isNotBlank(ddfpxx.getFPHM())){ |
|
|
|
|
|
|
|
InvoiceInfo invalidInfo = new InvoiceInfo(); |
|
|
|
|
|
|
|
invalidInfo.setInvoiceType(convertToSapType(ddfpxx.getYFPLX())); |
|
|
|
|
|
|
|
invalidInfo.setInvoiceCode(ddfpxx.getYFPDM()); |
|
|
|
|
|
|
|
invalidInfo.setInvoiceNumber(ddfpxx.getYFPHM()); |
|
|
|
|
|
|
|
invalidList.add(invalidInfo); |
|
|
|
|
|
|
|
invoiceRequest.setDeleteList(invalidList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return invoiceRequest; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private static String convertToSapType(String invoiceType) { |
|
|
|
|
|
|
|
|
|
|
|
switch (invoiceType) { |
|
|
|
switch (invoiceType) { |
|
|
|
|
|
|
|
|
|
|
|
case "0":// 增值税专用发票
|
|
|
|
case "004":// 增值税专用发票
|
|
|
|
invoiceType = "01"; |
|
|
|
invoiceType = "100"; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "007": |
|
|
|
|
|
|
|
invoiceType = "101"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "2": |
|
|
|
case "026": |
|
|
|
invoiceType = "04"; |
|
|
|
invoiceType = "102"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "51": |
|
|
|
case "028": |
|
|
|
invoiceType = "10"; |
|
|
|
invoiceType = "121"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "52": |
|
|
|
case "001": |
|
|
|
invoiceType = "08"; |
|
|
|
invoiceType = "130"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "01": |
|
|
|
case "002": |
|
|
|
invoiceType = "31"; |
|
|
|
invoiceType = "131"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "02": |
|
|
|
case "006": |
|
|
|
invoiceType = "32"; |
|
|
|
invoiceType = "105"; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "005": |
|
|
|
|
|
|
|
invoiceType = "104"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
invoiceType = ""; |
|
|
|
invoiceType = ""; |
|
|
@ -680,6 +708,8 @@ public class PushInvoiceServiceImpl implements PushInvoiceService { |
|
|
|
return invoiceType; |
|
|
|
return invoiceType; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SAPInvoiceInfo convertToSapOnject(SNInvoice snInvoice, String imageId, String compCode) { |
|
|
|
private SAPInvoiceInfo convertToSapOnject(SNInvoice snInvoice, String imageId, String compCode) { |
|
|
|
|
|
|
|
|
|
|
|
//转换时间格式
|
|
|
|
//转换时间格式
|
|
|
|