销项发票提交

release
王琦 2 years ago
parent 8319080ee4
commit d24be3bcee
  1. 8
      dxhy-erp/src/main/java/com/dxhy/erp/dao/SdnyTDxRecordInvoiceDetailSalesDao.java
  2. 2
      dxhy-erp/src/main/java/com/dxhy/erp/entity/sdny/SdnyTDxRecordInvoiceDetailSales.java
  3. 45
      dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ImageSubmitServiceImpl.java
  4. 37
      dxhy-erp/src/main/resources/mapper/SdnyTDxRecordInvoiceDetailSalesDao.xml

@ -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<SdnyTDxRecordInvoiceDetailSales> {
int batchInsert(@Param("data") List<SdnyTDxRecordInvoiceDetailSales> data);
int deleteByUUid(@Param("uuid") String uuid);
}

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

@ -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<SdnyTDxRecordInvoiceDetail> detailQueryWrapper = new QueryWrapper<>();
detailQueryWrapper.in("uuid", uuidList);
List<SdnyTDxRecordInvoiceDetail> detailList = detailDao.selectList(detailQueryWrapper);
if (detailList == null || detailList.size() == 0) {
return R.error(500,"未查询到发票明细信息,请重新查验");
}
Map<String, List<SdnyTDxRecordInvoiceDetail>> detailiMap = new HashMap<>();
detailList.stream().forEach(item -> {
List<SdnyTDxRecordInvoiceDetail> 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<SdnyTDxRecordInvoiceDetailSales>().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<SdnyTDxSaleRecordInvoice> data = sdnyTDxSaleRecordInvoiceDao.selectList(new QueryWrapper<SdnyTDxSaleRecordInvoice>().eq("image_id", params.getImageId()));
if (data == null || data.size() == 0) {
return R.error(500, "影像ID不存在");
}
List<String> 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<SdnyTDxRecordInvoiceDetailSales> updateWrapper = new UpdateWrapper<>();
UpdateWrapper<SdnyTDxSaleRecordInvoice> 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);
}

@ -0,0 +1,37 @@
<?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.erp.dao.SdnyTDxRecordInvoiceDetailSalesDao">
<insert id="batchInsert">
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
<foreach collection="data" item="item" separator=",">
(#{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}
)
</foreach>
</insert>
<delete id="deleteByUUid">
delete from dxhy_detail.t_dx_record_invoice_detail_sales where uuid=#{uuid}
</delete>
</mapper>
Loading…
Cancel
Save