diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ImageSubmitServiceImpl.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ImageSubmitServiceImpl.java index b2094e70..ef9f8cb5 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ImageSubmitServiceImpl.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ImageSubmitServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.dxhy.common.constant.DbConstant; import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.enums.FplxEnum; +import com.dxhy.common.enums.SNFplxEnum; import com.dxhy.common.utils.DateUtils; import com.dxhy.common.utils.R; import com.dxhy.erp.dao.*; @@ -68,19 +69,26 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.in("uuid", uuidList); List invoicesList = tdxRecordInvoiceDao.selectList(queryWrapper); - if (invoicesList == null || invoicesList.size() == 0) { - QueryWrapper salesQueryWrapper = new QueryWrapper<>(); - salesQueryWrapper.in("uuid", uuidList); - List saleRecordInvoices = sdnyTDxSaleRecordInvoiceDao.selectList(salesQueryWrapper); - if (saleRecordInvoices == null || saleRecordInvoices.size() == 0) { - return R.error(500, "未查询到发票信息,请重新查验"); + List recordUuidList = null; + QueryWrapper salesQueryWrapper = new QueryWrapper<>(); + salesQueryWrapper.in("uuid", uuidList); + if (invoicesList != null && invoicesList.size() > 0) { + recordUuidList = invoicesList.stream().map(SdnyTDxRecordInvoice::getUuid).collect(Collectors.toList()); + salesQueryWrapper.notIn("uuid", recordUuidList); + } + List saleInvoices = sdnyTDxSaleRecordInvoiceDao.selectList(salesQueryWrapper); + if (saleInvoices!=null && saleInvoices.size()>0) { + if (invoicesList == null || invoicesList.size() == 0) { + invoicesList = new ArrayList<>(); } - invoicesList = new ArrayList<>(); - for (SdnyTDxSaleRecordInvoice item : saleRecordInvoices) { + for (SdnyTDxSaleRecordInvoice item : saleInvoices) { SdnyTDxRecordInvoice invoice = JsonUtils.getInstance().parseObject(JSONObject.toJSONString(item), SdnyTDxRecordInvoice.class); invoicesList.add(invoice); } } + if (invoicesList == null || invoicesList.size() == 0) { + return R.error(500, "未查询到发票信息,请重新查验"); + } if (invoicesList.size() != uuidList.size()) { StringBuffer msg = new StringBuffer(); Map invoiceMap = invoicesList.stream().collect(Collectors.toMap(SdnyTDxRecordInvoice::getUuid, v -> v)); @@ -97,19 +105,25 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { QueryWrapper detailQueryWrapper = new QueryWrapper<>(); detailQueryWrapper.in("uuid", uuidList); List detailList = detailDao.selectList(detailQueryWrapper); - if (detailList == null || detailList.size() == 0) { - QueryWrapper salesQueryWrapper = new QueryWrapper<>(); - salesQueryWrapper.in("uuid", uuidList); - List salesDetailList = detailSalesDao.selectList(salesQueryWrapper); - if (salesDetailList == null || salesDetailList.size() == 0) { - return R.error(500,"未查询到发票明细信息,请重新查验"); + if (saleInvoices != null && saleInvoices.size()>0) { + QueryWrapper salesDetailQueryWrapper = new QueryWrapper<>(); + salesDetailQueryWrapper.in("uuid", uuidList); + if (recordUuidList != null && recordUuidList.size() > 0) { + salesDetailQueryWrapper.notIn("uuid", recordUuidList); + } + List salesDetailList = detailSalesDao.selectList(salesDetailQueryWrapper); + if (detailList == null || detailList.size() == 0) { + detailList = new ArrayList<>(); } - detailList = new ArrayList<>(); for (SdnyTDxRecordInvoiceDetailSales item : salesDetailList) { SdnyTDxRecordInvoiceDetail detail = JsonUtils.getInstance().parseObject(JSONObject.toJSONString(item), SdnyTDxRecordInvoiceDetail.class); detailList.add(detail); } } + if (detailList == null || detailList.size() == 0) { + return R.error(500,"未查询到发票明细信息,请重新查验"); + + } Map> detailiMap = new HashMap<>(); detailList.stream().forEach(item -> { List list = null; @@ -230,6 +244,10 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { ZData zdata = new ZData(); zdata.setZFPDM(StringUtils.isBlank(item.getInvoiceCode())?"":item.getInvoiceCode()); zdata.setZFPHM(item.getInvoiceNo()); + if (SNFplxEnum.QDPP.getFplxDm().equals(item.getInvoiceType()) || SNFplxEnum.QDZP.getFplxDm().equals(item.getInvoiceType())) { + zdata.setZFPDM(""); + zdata.setZFPHM(item.getEleInvoiceNo()); + } zdata.setZFPLX(invoiceType); zdata.setZXFBM(item.getXfTaxNo()); zdata.setZGFBH(item.getGfTaxNo()); @@ -288,7 +306,7 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { detail.setTaxRate(detail.getTaxRateOfSap().multiply(new BigDecimal(100)).setScale(4,BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString()); log.info("明细行数据:{}",JSONObject.toJSONString(detail)); BigDecimal totalAmount = new BigDecimal(detail.getDetailAmount()).add(new BigDecimal(detail.getTaxAmount())); - zDatas.add(ZData.builder() + ZData datas = ZData.builder() .ZBHSJE(detail.getDetailAmount()) .ZBHSJE_DIF("0") .ZBHSJE_Y(detail.getDetailAmount()) @@ -310,7 +328,13 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { .ZHWMC(detail.getGoodsName()) .ZTID(zdata.getZTID()) .ZSM(TaxRateCodeEnum.getCode(detail.getTaxRate())) - .build()); + .build(); + if (SNFplxEnum.QDPP.getFplxDm().equals(item.getInvoiceType()) || SNFplxEnum.QDZP.getFplxDm().equals(item.getInvoiceType())) { + datas.setZFPDM(""); + datas.setZFPHM(item.getEleInvoiceNo()); + } + zDatas.add(datas); + } String taxRate = ""; if (item.getDetailList().size() > 0) {