From d24be3bceee361f46a7bb231e69e03a5744d299a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=90=A6?= Date: Wed, 13 Sep 2023 11:31:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=80=E9=A1=B9=E5=8F=91=E7=A5=A8=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SdnyTDxRecordInvoiceDetailSalesDao.java | 8 ++++ .../sdny/SdnyTDxRecordInvoiceDetailSales.java | 2 + .../service/impl/ImageSubmitServiceImpl.java | 45 ++++++++++++++----- .../SdnyTDxRecordInvoiceDetailSalesDao.xml | 37 +++++++++++++++ 4 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 dxhy-erp/src/main/resources/mapper/SdnyTDxRecordInvoiceDetailSalesDao.xml diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/dao/SdnyTDxRecordInvoiceDetailSalesDao.java b/dxhy-erp/src/main/java/com/dxhy/erp/dao/SdnyTDxRecordInvoiceDetailSalesDao.java index d4017404..9ed9fc55 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/dao/SdnyTDxRecordInvoiceDetailSalesDao.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/dao/SdnyTDxRecordInvoiceDetailSalesDao.java @@ -3,7 +3,15 @@ package com.dxhy.erp.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dxhy.erp.entity.sdny.SdnyTDxRecordInvoiceDetailSales; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; @Mapper public interface SdnyTDxRecordInvoiceDetailSalesDao extends BaseMapper { + + int batchInsert(@Param("data") List data); + + int deleteByUUid(@Param("uuid") String uuid); + } diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/entity/sdny/SdnyTDxRecordInvoiceDetailSales.java b/dxhy-erp/src/main/java/com/dxhy/erp/entity/sdny/SdnyTDxRecordInvoiceDetailSales.java index da2c6a48..127f44e7 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/entity/sdny/SdnyTDxRecordInvoiceDetailSales.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/entity/sdny/SdnyTDxRecordInvoiceDetailSales.java @@ -3,6 +3,7 @@ package com.dxhy.erp.entity.sdny; import java.io.Serializable; import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -137,6 +138,7 @@ public class SdnyTDxRecordInvoiceDetailSales implements Serializable { */ private String taxCode; + @TableField(exist = false) private BigDecimal taxRateOfSap; private static final long serialVersionUID = 1L; 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 636c8866..569c31fe 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 @@ -2,6 +2,7 @@ package com.dxhy.erp.service.impl; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.dxhy.common.constant.DbConstant; @@ -29,7 +30,7 @@ import java.util.*; import java.util.stream.Collectors; @Service -@Transactional(rollbackFor = Exception.class) +//@Transactional(rollbackFor = Exception.class) @Slf4j public class ImageSubmitServiceImpl implements ImageSubmitService { @@ -49,6 +50,9 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { @Autowired private SdnyTDxRecordInvoiceDetailSalesService sdnyTDxRecordInvoiceDetailSalesService; + @Autowired + private SdnyTDxRecordInvoiceDetailSalesDao detailSalesDao; + @Autowired private SNPushCheckRecordService snPushCheckRecordService; @@ -81,10 +85,13 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { String errorMsg = msg.toString(); return R.error(500, "未查询到如下发票,请重新查验," + errorMsg); } - + DynamicContextHolder.push(DbConstant.DETAIL_WRITE); QueryWrapper detailQueryWrapper = new QueryWrapper<>(); detailQueryWrapper.in("uuid", uuidList); List detailList = detailDao.selectList(detailQueryWrapper); + if (detailList == null || detailList.size() == 0) { + return R.error(500,"未查询到发票明细信息,请重新查验"); + } Map> detailiMap = new HashMap<>(); detailList.stream().forEach(item -> { List list = null; @@ -98,6 +105,20 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { detailiMap.put(item.getUuid(), list); } }); + StringBuffer detailErrorMsg = new StringBuffer(); + Boolean flag = false; + for (String uuid : uuidList) { + if (!detailiMap.containsKey(uuid)) { + flag = true; + SNInvoice invoice = paramsInvoiceMap.get(uuid); + String errorMsg = "发票代码:" + invoice.getInvoiceCode() + ",发票号码:" + invoice.getInvoiceNumber() + ";"; + detailErrorMsg.append(errorMsg); + } + } + if (flag) { + String errorMsg = detailErrorMsg.toString(); + return R.error(500, "未查询到如下发票的明细行,请重新查验," + errorMsg); + } invoicesList.stream().forEach(item -> { item.setImageId(params.getImageId()); item.setBzdh(params.getBillNum()); @@ -119,11 +140,11 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { // 新增 saleRecordInvoice = JsonUtils.getInstance().parseObject(JSONObject.toJSONString(invoice), SdnyTDxSaleRecordInvoice.class); saleRecordInvoice.setId(null); + log.info("插入销项表数据,{}",JSONObject.toJSONString(saleRecordInvoice)); DynamicContextHolder.push(DbConstant.BUSINESS_WRITE); sdnyTDxSaleRecordInvoiceDao.insert(saleRecordInvoice); - DynamicContextHolder.push(DbConstant.DETAIL_WRITE); - sdnyTDxRecordInvoiceDetailSalesService.getBaseMapper().delete(new UpdateWrapper().eq("uuid", invoice.getUuid())); - sdnyTDxRecordInvoiceDetailSalesService.saveBatch(salesDetailList); + detailSalesDao.deleteByUUid(invoice.getUuid()); + detailSalesDao.batchInsert(salesDetailList); } else { // 修改 saleRecordInvoice.setImageId(invoice.getImageId()); @@ -142,17 +163,21 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { @Override public R salesInvoiceRollback(SNRequestObject params) { + DynamicContextHolder.push(DbConstant.BUSINESS_WRITE); + List data = sdnyTDxSaleRecordInvoiceDao.selectList(new QueryWrapper().eq("image_id", params.getImageId())); + if (data == null || data.size() == 0) { + return R.error(500, "影像ID不存在"); + } List uuidList = new ArrayList<>(); - params.getInvoiceInfoList().stream().forEach(item -> { - String uuid = (StringUtils.isBlank(item.getInvoiceCode()) ? "" : item.getInvoiceCode()) + item.getInvoiceNumber(); - uuidList.add(uuid); + data.stream().forEach(item -> { + uuidList.add(item.getUuid()); }); - UpdateWrapper updateWrapper = new UpdateWrapper<>(); + UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.set(true, "image_id", null); updateWrapper.set(true, "bzdh", null); updateWrapper.set(true, "bzr", null); updateWrapper.in("uuid", uuidList); - sdnyTDxRecordInvoiceDetailSalesService.update(updateWrapper); + sdnyTDxSaleRecordInvoiceDao.update(null,updateWrapper); return pushSap(null, params); } diff --git a/dxhy-erp/src/main/resources/mapper/SdnyTDxRecordInvoiceDetailSalesDao.xml b/dxhy-erp/src/main/resources/mapper/SdnyTDxRecordInvoiceDetailSalesDao.xml new file mode 100644 index 00000000..2786cdb0 --- /dev/null +++ b/dxhy-erp/src/main/resources/mapper/SdnyTDxRecordInvoiceDetailSalesDao.xml @@ -0,0 +1,37 @@ + + + + + insert into dxhy_detail.t_dx_record_invoice_detail_sales (uuid, invoice_code, invoice_no, + detail_no, goods_name, model, + unit, num, unit_price, + detail_amount, tax_rate, tax_amount, + cph, lx, txrqq, txrqz, + goods_num, is_discount, incentive_flag, + zero_taxrate_flag, added_tax_special, spfwjc, + sphfwssflhbbm, kce, tax_code + ) + values + + (#{item.uuid,jdbcType=VARCHAR}, #{item.invoiceCode,jdbcType=VARCHAR}, #{item.invoiceNo,jdbcType=VARCHAR}, + #{item.detailNo,jdbcType=VARCHAR}, #{item.goodsName,jdbcType=VARCHAR}, #{item.model,jdbcType=VARCHAR}, + #{item.unit,jdbcType=VARCHAR}, #{item.num,jdbcType=VARCHAR}, #{item.unitPrice,jdbcType=VARCHAR}, + #{item.detailAmount,jdbcType=VARCHAR}, #{item.taxRate,jdbcType=VARCHAR}, #{item.taxAmount,jdbcType=VARCHAR}, + #{item.cph,jdbcType=VARCHAR}, #{item.lx,jdbcType=VARCHAR}, #{item.txrqq,jdbcType=VARCHAR}, #{item.txrqz,jdbcType=VARCHAR}, + #{item.goodsNum,jdbcType=VARCHAR}, #{item.isDiscount,jdbcType=VARCHAR}, #{item.incentiveFlag,jdbcType=VARCHAR}, + #{item.zeroTaxrateFlag,jdbcType=VARCHAR}, #{item.addedTaxSpecial,jdbcType=VARCHAR}, #{item.spfwjc,jdbcType=VARCHAR}, + #{item.sphfwssflhbbm,jdbcType=VARCHAR}, #{item.kce,jdbcType=VARCHAR}, #{item.taxCode,jdbcType=VARCHAR} + ) + + + + + + + + + + delete from dxhy_detail.t_dx_record_invoice_detail_sales where uuid=#{uuid} + + + \ No newline at end of file