From fa2e62e6aa9d7a9f10f53863ccbf9cc35a69e59e Mon Sep 17 00:00:00 2001 From: yefei Date: Fri, 12 May 2023 14:25:51 +0800 Subject: [PATCH] =?UTF-8?q?ariesy=20=E6=9F=A5=E9=AA=8C=E6=97=B6,=E5=BA=95?= =?UTF-8?q?=E8=B4=A6=E5=BA=93=E5=AD=98=E5=9C=A8=E7=9A=84=E5=8F=91=E7=A5=A8?= =?UTF-8?q?,=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SDNYMainProcessController.java | 84 +++++++------ .../dao/BaseTDxRecordInvoiceDetailDao.java | 20 +++ .../dao/InvoiceDownDetaiSaleInsertDao.java | 14 +++ .../entity/BaseTDxRecordInvoiceDetail.java | 118 ++++++++++++++++++ .../entity/RecordInvoiceSaleDetailModel.java | 94 ++++++++++++++ .../impl/SignSaveInvoiceInfoServiceImpl.java | 3 + 6 files changed, 294 insertions(+), 39 deletions(-) create mode 100644 dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseTDxRecordInvoiceDetailDao.java create mode 100644 dxhy-erp/src/main/java/com/dxhy/erp/dao/InvoiceDownDetaiSaleInsertDao.java create mode 100644 dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxRecordInvoiceDetail.java create mode 100644 dxhy-erp/src/main/java/com/dxhy/erp/entity/RecordInvoiceSaleDetailModel.java diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java index 05620a1d..a41895d2 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java @@ -11,32 +11,26 @@ import com.dxhy.common.controller.AbstractController; import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.enums.SNFplxEnum; import com.dxhy.common.util.InvoiceUtil; -import com.dxhy.common.util.UserInfoUtil; import com.dxhy.common.utils.Base64Encoding; import com.dxhy.common.utils.R; -import com.dxhy.common.vo.Tax; -import com.dxhy.common.vo.TaxOrgCode; import com.dxhy.erp.dao.*; import com.dxhy.erp.entity.*; import com.dxhy.erp.entity.sdny.*; import com.dxhy.erp.service.*; import com.dxhy.erp.utils.Base64; import com.dxhy.erp.utils.HmacSHA1Util; -import com.dxhy.erp.utils.ServiceResult; +import com.google.gson.JsonArray; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.annotations.Result; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.scheduling.annotation.Async; -import org.springframework.util.Base64Utils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.text.ParseException; -import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.*; @@ -85,6 +79,12 @@ public class SDNYMainProcessController extends AbstractController { @Resource private BaseTDxRecordInvoiceDao baseTDxRecordInvoiceDao; + @Resource + private BaseTDxRecordInvoiceDetailDao baseTDxRecordInvoiceDetailDao; + + @Resource + private InvoiceDownDetaiSaleInsertDao invoiceDownDetaiSaleInsertDao; + @Resource private RecordInvoiceDao recordInvoiceDao; @@ -175,16 +175,25 @@ public class SDNYMainProcessController extends AbstractController { return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes))); } - - //查询底账库是否有对应发票,有则直接返回 - TdxCheckRecordInvoice checkInvoiceByUuid = signCheckRecordService.getCheckInvoiceByUuid(uuid); + QueryWrapper recordWrapper = new QueryWrapper<>(); + recordWrapper.eq("uuid", uuid); + BaseTDxRecordInvoice checkInvoiceByUuid = baseTDxRecordInvoiceDao.selectOne(recordWrapper); if (checkInvoiceByUuid != null) { log.info("进项票池已存在发票.直接返回票池信息"); R data = new R(1000, "default success"); + String invoiceNo = checkInvoiceByUuid.getInvoiceNo(); + QueryWrapper detailWrapper = new QueryWrapper<>(); + detailWrapper.eq("invoice_no", invoiceNo); + DynamicContextHolder.push(DbConstant.DETAIL_READ); + List baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); + + DynamicContextHolder.push(DbConstant.BUSINESS_READ); JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(checkInvoiceByUuid); - convertToResult(checkInvoice); + JSONArray checkInvoiceDetail = (JSONArray) JSONObject.toJSON(baseTDxRecordInvoiceDetail); + + convertToResult(checkInvoice,checkInvoiceDetail); data.put("data", checkInvoice); //查验结果保存 @@ -198,8 +207,17 @@ public class SDNYMainProcessController extends AbstractController { log.info("销项票池已存在发票.直接返回票池信息"); R data = new R(1000, "default success"); + String invoiceNo = tdxSaleRecordInvoice.getInvoiceNo(); + QueryWrapper saleDetailWrapper = new QueryWrapper<>(); + saleDetailWrapper.eq("invoice_no", invoiceNo); + DynamicContextHolder.push(DbConstant.DETAIL_READ); + List recordInvoiceSaleDetailModel = invoiceDownDetaiSaleInsertDao.selectList(saleDetailWrapper); + + DynamicContextHolder.push(DbConstant.BUSINESS_READ); + JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(tdxSaleRecordInvoice); - convertToResult(checkInvoice); + JSONArray saleDetail = (JSONArray) JSONObject.toJSON(recordInvoiceSaleDetailModel); + convertToResult(checkInvoice,saleDetail); data.put("data", checkInvoice); //查验结果保存 @@ -340,7 +358,7 @@ public class SDNYMainProcessController extends AbstractController { return data; } - private void convertToResult(JSONObject checkInvoice) throws ParseException { + private void convertToResult(JSONObject checkInvoice, JSONArray detailArray) throws ParseException { checkInvoice.put("totalTax", checkInvoice.getString("taxAmount")); checkInvoice.put("amountTax", checkInvoice.getString("totalAmount")); checkInvoice.put("totalAmount", checkInvoice.getString("invoiceAmount")); @@ -390,40 +408,29 @@ public class SDNYMainProcessController extends AbstractController { String taxRate = ""; List> returnDetailList = new ArrayList<>(); -// JSONArray detailList = (JSONArray) invoiceData.get("detailList"); - JSONArray detailList = new JSONArray(); + JSONArray detailList = detailArray; for (int i = 0; i < detailList.size(); i++) { String taxRateDetail = ""; JSONObject detail = (JSONObject) detailList.get(i); Map snDetailMap = new HashMap(); snDetailMap.put("rowNo", i + 1 + ""); - snDetailMap.put("commodityCode", detail.getString("ssflbm")); - snDetailMap.put("commodityName", detail.getString("hwmc")); - snDetailMap.put("specificationModel", detail.getString("ggxh")); - snDetailMap.put("unit", detail.getString("jldw")); - String quantity = detail.getString("spsl"); -// if (quantity.length() > 3) { -// int index = quantity.indexOf("."); -// quantity = quantity.substring(0, index + 2); -// } + snDetailMap.put("commodityCode", detail.getString("goodsNum")); + snDetailMap.put("commodityName", detail.getString("spfwjc")); + snDetailMap.put("specificationModel", detail.getString("model")); + snDetailMap.put("unit", detail.getString("unit")); + String quantity = detail.getString("num"); snDetailMap.put("quantity", quantity); - String unitPrice = detail.getString("bhsdj"); -// if (unitPrice.length() > 3) { -// int index = unitPrice.indexOf("."); -// unitPrice = unitPrice.substring(0, index + 3); -// } - + String unitPrice = detail.getString("unitPrice"); snDetailMap.put("unitPrice", unitPrice); - if ("11".equals(invoiceType)) { snDetailMap.put("tax", "0"); //如果是卷票计算合计金额 Float hjje = null; - if (detail.getString("se") != null && detail.getString("je") != null) { + if (detail.getString("detailAmount") != null && detail.getString("taxAmount") != null) { Float je = Float.parseFloat(detail.getString("je")); Float se = Float.parseFloat(detail.getString("se")); hjje = je + se; @@ -433,17 +440,17 @@ public class SDNYMainProcessController extends AbstractController { snDetailMap.put("amount", hjje.toString()); } else { - snDetailMap.put("tax", "***".equals(detail.getString("se")) ? "0.00" : detail.getString("se")); - snDetailMap.put("amount", detail.getString("je")); + snDetailMap.put("tax", "***".equals(detail.getString("amount")) ? "0.00" : detail.getString("se")); + snDetailMap.put("amount", detail.getString("detailAmount")); } - if ("免税".equals(detail.getString("sl"))) { + if ("免税".equals(detail.getString("taxRate"))) { taxRateDetail = "0"; snDetailMap.put("taxRate", taxRateDetail); } else { - if (detail.get("sl") != null && StringUtils.isNoneBlank(detail.get("sl").toString())) { - taxRateDetail = detail.get("sl").toString(); + if (detail.get("taxRate") != null && StringUtils.isNoneBlank(detail.get("taxRate").toString())) { + taxRateDetail = detail.get("taxRate").toString(); if (!"0".equals(taxRateDetail)) { if (StringUtils.isNoneBlank(taxRateDetail)) { int index = taxRateDetail.indexOf("%"); @@ -469,8 +476,7 @@ public class SDNYMainProcessController extends AbstractController { } } - log.info("明细-tax={}", detail.get("se")); - log.info("明细-commodityCode={}", detail.get("ssflbm")); + log.info("明细-tax={}", detail.get("taxAmount")); snDetailMap.put("currentDateEnd", detail.getString("txrqz")); snDetailMap.put("currentDateStart", detail.getString("txrqq")); snDetailMap.put("licensePlateNum", detail.getString("cph")); diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseTDxRecordInvoiceDetailDao.java b/dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseTDxRecordInvoiceDetailDao.java new file mode 100644 index 00000000..ae5ba34f --- /dev/null +++ b/dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseTDxRecordInvoiceDetailDao.java @@ -0,0 +1,20 @@ +package com.dxhy.erp.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dxhy.erp.entity.BaseTDxRecordInvoiceDetail; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * + * 底账明细表dao + * + * + * @author peipei.li + * @date 2019-04-23 + */ +@SuppressWarnings("AlibabaClassNamingShouldBeCamel") +@Mapper +public interface BaseTDxRecordInvoiceDetailDao extends BaseMapper { + +} diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/dao/InvoiceDownDetaiSaleInsertDao.java b/dxhy-erp/src/main/java/com/dxhy/erp/dao/InvoiceDownDetaiSaleInsertDao.java new file mode 100644 index 00000000..e77229e2 --- /dev/null +++ b/dxhy-erp/src/main/java/com/dxhy/erp/dao/InvoiceDownDetaiSaleInsertDao.java @@ -0,0 +1,14 @@ +package com.dxhy.erp.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dxhy.erp.entity.RecordInvoiceSaleDetailModel; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author user + */ +@SuppressWarnings({"AlibabaLowerCamelCaseVariableNaming", "AlibabaClassNamingShouldBeCamel"}) +@Mapper +public interface InvoiceDownDetaiSaleInsertDao extends BaseMapper { + +} diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxRecordInvoiceDetail.java b/dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxRecordInvoiceDetail.java new file mode 100644 index 00000000..ae0d8db9 --- /dev/null +++ b/dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxRecordInvoiceDetail.java @@ -0,0 +1,118 @@ +package com.dxhy.erp.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * + * + * 底账明细表 + * + * @author peipei.li + * @date 2019-04-23 + */ +@SuppressWarnings("AlibabaClassNamingShouldBeCamel") +@Data +@TableName("t_dx_record_invoice_detail") +public class BaseTDxRecordInvoiceDetail implements Serializable { + + private static final long serialVersionUID = -6703830991573450761L; + + /** + * id + */ + private Long id; + + /** + * 唯一标识(发票代码+发票号码) + */ + private String uuid; + + /** + * 发票代码 + */ + private String invoiceCode; + + /** + * 发票号码 + */ + private String invoiceNo; + + /** + * 明细序号 + */ + private String detailNo; + + /** + * 货物或应税劳务名称 + */ + private String goodsName; + + /** + * 规格型号 + */ + private String model; + + /** + * 单位 + */ + private String unit; + + /** + * 数量 + */ + private String num; + + /** + * 单价 + */ + private String unitPrice; + + /** + * 金额 + */ + private String detailAmount; + + /** + * 税率 + */ + private String taxRate; + + /** + * 税额 + */ + private String taxAmount; + + /** + * 车牌号 + */ + private String cph; + + /** + * 类型 + */ + private String lx; + + /** + * 通行日期起 + */ + private String txrqq; + + /** + * 通行日期止 + */ + private String txrqz; + + /** + * 商品编码 + */ + private String goodsNum; + + /** + * 商品编码 + */ + private String spfwjc; + +} diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/entity/RecordInvoiceSaleDetailModel.java b/dxhy-erp/src/main/java/com/dxhy/erp/entity/RecordInvoiceSaleDetailModel.java new file mode 100644 index 00000000..a638fa43 --- /dev/null +++ b/dxhy-erp/src/main/java/com/dxhy/erp/entity/RecordInvoiceSaleDetailModel.java @@ -0,0 +1,94 @@ +package com.dxhy.erp.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * 专普电明细 + * + * @author jiaohongyang + */ +@Data +@Getter +@Setter +@ToString +@TableName("t_dx_record_invoice_detail_sales") +public class RecordInvoiceSaleDetailModel { + @TableId + private Long id; + /** + * 货物或应税劳务名称 + */ + private String goodsName; + + /** + * 规格型号 + */ + private String model; + + /** + * 单位 + */ + private String unit; + + /** + * 数量 + */ + private String num; + + /** + * 单价 + */ + private String unitPrice; + + /** + * 金额 + */ + private String detailAmount; + + /** + * 税率 + */ + private String taxRate; + + /** + * 税额 + */ + private String taxAmount; + + /** + * 车牌号 + */ + private String cph; + + /** + * 类型 + */ + private String lx; + + /** + * 通行日期起 + */ + private String txrqq; + + /** + * 通行日期止 + */ + private String txrqz; + + /** + * 商品编码 + */ + private String goodsNum; + + private String uuid; + + private String invoiceCode; + + private String invoiceNo; + +} diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/SignSaveInvoiceInfoServiceImpl.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/SignSaveInvoiceInfoServiceImpl.java index e04faabf..71dec67d 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/SignSaveInvoiceInfoServiceImpl.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/SignSaveInvoiceInfoServiceImpl.java @@ -348,6 +348,9 @@ public class SignSaveInvoiceInfoServiceImpl extends MpBaseServiceImpl