From ef095b4b5f685f0d245c17069362fdf6cc96bbc5 Mon Sep 17 00:00:00 2001 From: yefei Date: Tue, 22 Aug 2023 16:25:53 +0800 Subject: [PATCH] =?UTF-8?q?ariesy=20=E5=AF=BC=E5=87=BA=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=BB=84=E7=BB=87=E7=BC=96=E7=A0=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=A8=8E=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SDNYMainProcessController.java | 222 +++++++++++++++++- .../dxhy/erp/dao/VihicleInvoiceDetailDao.java | 19 ++ .../erp/service/SNPushCheckRecordService.java | 10 + .../main/resources/mapper/InvoiceDetails.xml | 2 +- 4 files changed, 244 insertions(+), 9 deletions(-) create mode 100644 dxhy-erp/src/main/java/com/dxhy/erp/dao/VihicleInvoiceDetailDao.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 59e41515..ba54c52c 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 @@ -264,11 +264,19 @@ public class SDNYMainProcessController extends AbstractController { String invoiceNo = checkInvoiceByUuid.getInvoiceNo(); QueryWrapper detailWrapper = new QueryWrapper<>(); detailWrapper.eq("uuid", uuid); - DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); - List baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); + + List baseTDxRecordInvoiceDetail = null; + List vehicleList = null; + if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) { + vehicleList = snPushCheckRecordService.vihicleList(uuid); + } else { + DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); + baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); + } + DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); - if(baseTDxRecordInvoiceDetail == null || baseTDxRecordInvoiceDetail.size() == 0){ + if((baseTDxRecordInvoiceDetail == null || baseTDxRecordInvoiceDetail.size() == 0) && (vehicleList == null || vehicleList.size() == 0)){ checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,null); List activeCallRequest = new ArrayList<>(); @@ -285,10 +293,13 @@ public class SDNYMainProcessController extends AbstractController { if(delete > 0) { checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName); - - DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); - baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); - DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); + if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) { + vehicleList = snPushCheckRecordService.vihicleList(uuid); + } else { + DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); + baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); + DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); + } } }else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { data = errorInfo(checkInvoiceResult, data); @@ -308,8 +319,12 @@ public class SDNYMainProcessController extends AbstractController { } JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(checkInvoiceByUuid); JSONArray checkInvoiceDetail = (JSONArray) JSONObject.toJSON(baseTDxRecordInvoiceDetail); + JSONObject vehicleDetail = new JSONObject(); + if(vehicleList != null && vehicleList.size() > 0) { + vehicleDetail = (JSONObject) JSONObject.toJSON(vehicleList.get(0)); + } - convertToResult(checkInvoice, checkInvoiceDetail); + convertToResult(checkInvoice, checkInvoiceDetail, vehicleDetail); data.put("data", checkInvoice); //查验结果保存 @@ -706,6 +721,197 @@ public class SDNYMainProcessController extends AbstractController { checkInvoice.put("invoiceLineList", returnDetailList); } + private void convertToResult(JSONObject checkInvoice, JSONArray detailArray, JSONObject vehicleList) throws ParseException { + + checkInvoice.put("totalTax", checkInvoice.getString("taxAmount")); + checkInvoice.put("amountTax", checkInvoice.getString("totalAmount")); + checkInvoice.put("totalAmount", checkInvoice.getString("invoiceAmount")); + // 增加备注字段 + checkInvoice.put("remarks", checkInvoice.getString("remark")); + //添加非空判断 + String invoiceCode = null; + if (checkInvoice.get("invoiceCode") != null) { + invoiceCode = checkInvoice.get("invoiceCode").toString(); + } + String invoiceType = checkInvoice.get("invoiceType").toString(); + if ("22".equals(invoiceType)) { + invoiceType = "33"; + } + if ("21".equals(invoiceType)) { + invoiceType = "31"; + } + + checkInvoice.put("invoiceType", invoiceType); + checkInvoice.put("administrativeDivisionNo", ""); + checkInvoice.put("administrativeDivisionName", ""); + + if ("31".equals(invoiceType) || "32".equals(invoiceType) || "185".equals(invoiceType) || "186".equals(invoiceType)) { + checkInvoice.put("invoiceCode", ""); + checkInvoice.put("invoiceNumber", invoiceCode == null ? checkInvoice.get("invoiceNo").toString() : invoiceCode + checkInvoice.get("invoiceNo").toString()); + } else { + checkInvoice.put("invoiceCode", invoiceCode); + checkInvoice.put("invoiceNumber", checkInvoice.get("invoiceNo").toString()); + } + String uuid = ""; + if (invoiceCode != null && StringUtils.isNoneBlank(invoiceCode)) { + uuid = invoiceCode + checkInvoice.get("invoiceNo").toString(); + checkInvoice.put("uuid", uuid); + } else { + uuid = checkInvoice.get("invoiceNo").toString(); + checkInvoice.put("uuid", uuid); + } + + + String kprq = checkInvoice.get("invoiceDate").toString(); + SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); + Date date = sdf.parse(kprq); + String formatStr = new SimpleDateFormat("yyyy-MM-dd").format(date); + log.info("开票日期为:{} ", formatStr); + + checkInvoice.put("billingDate", formatStr); + checkInvoice.put("purchaserName", checkInvoice.get("gfName")); + checkInvoice.put("purchaserTaxNo", checkInvoice.get("gfTaxNo")); + checkInvoice.put("purchaserBank", checkInvoice.get("gfBankAndNo")); + checkInvoice.put("purchaserAddressPhone", checkInvoice.get("gfAddressAndPhone")); + checkInvoice.put("salesName", checkInvoice.get("xfName")); + checkInvoice.put("salesTaxNo", checkInvoice.get("xfTaxNo")); + checkInvoice.put("salesAddressPhone", checkInvoice.get("gfAddressAndPhone")); + checkInvoice.put("salesBank", checkInvoice.get("gfBankAndNo")); + checkInvoice.put("checkCode", checkInvoice.get("checkCode")); + checkInvoice.put("state", "0"); + checkInvoice.put("tollSign", "07"); + //机动车 + if ("03".equals(invoiceType)) { + checkInvoice.put("vehicleType", vehicleList.getString("vehicleType")); + checkInvoice.put("brandModel", vehicleList.getString("factoryModel")); + checkInvoice.put("originPlace", vehicleList.getString("productPlace")); + checkInvoice.put("certificateNo", vehicleList.getString("certificate")); + checkInvoice.put("inspectionListNo", vehicleList.getString("inspectionNum")); + checkInvoice.put("engineNo", vehicleList.getString("engineNo")); + checkInvoice.put("vehicleNo", vehicleList.getString("vehicleNo")); + checkInvoice.put("paymentVoucherNo", vehicleList.getString("taxRecords")); + checkInvoice.put("passengersLimited", vehicleList.getString("limitPeople")); + checkInvoice.put("taxAuthorityNo", vehicleList.getString("taxBureauCode")); + checkInvoice.put("taxAuthorityName", vehicleList.getString("taxBureauName")); + checkInvoice.put("idcardNo", vehicleList.getString("buyerIdNum")); + } + //二手车 + if ("15".equals(invoiceType)) { + checkInvoice.put("vehicleType", vehicleList.getString("vehicleType")); + checkInvoice.put("vehicleNo", vehicleList.getString("vehicleNo")); + checkInvoice.put("brandModel", vehicleList.getString("factoryModel")); + checkInvoice.put("licensePlate", vehicleList.getString("plateNo")); + checkInvoice.put("buyerUnitOrIndividual", vehicleList.getString("buyerUnit")); + checkInvoice.put("buyerUnitCodeOrIdNo", vehicleList.getString("buyerIdNum")); + checkInvoice.put("buyerUnitOrIndividualAddress", vehicleList.getString("buyerUnitAddress")); + checkInvoice.put("sellerUnitOrIndividual", vehicleList.getString("sellerUnit")); + checkInvoice.put("sellerUnitCodeOrIdNo", vehicleList.getString("sellerUnitCode")); + checkInvoice.put("sellerUnitOrIndividualAddress", vehicleList.getString("sellerUnitAddress")); + checkInvoice.put("sellerPhone", vehicleList.getString("sellerPhone")); + checkInvoice.put("lemonMarket", vehicleList.getString("carMarket")); + checkInvoice.put("lemonMarketAddress", vehicleList.getString("carMarketAddress")); + checkInvoice.put("lemonMarketPhone", vehicleList.getString("carMarketPhone")); + checkInvoice.put("lemonMarketBankAndAccount", vehicleList.getString("carMarketBank")); + checkInvoice.put("vehicleAdminOffice", vehicleList.getString("vehicleAdminOffice")); + checkInvoice.put("registrationNo", vehicleList.getString("registrationNo")); + checkInvoice.put("lemonMarketTaxNo", vehicleList.getString("carMarketTaxNo")); + checkInvoice.put("idcardNo", vehicleList.getString("buyerIdNum")); + checkInvoice.put("amountTax", vehicleList.getString("carPrice")); + } + + String taxRate = ""; + List> returnDetailList = new ArrayList<>(); + + JSONArray detailList = detailArray; + if (detailList != null) { + for (int i = 0; i < detailList.size(); i++) { + String taxRateDetail = ""; + JSONObject detail = (JSONObject) detailList.get(i); + if (StringUtils.isNotEmpty(detail.getString("goodsName")) && (detail.getString("goodsName").equals("(详见销货清单)") || detail.getString("goodsName").equals("(详见销货清单)"))) { + continue; + } + Map snDetailMap = new HashMap(); + snDetailMap.put("rowNo", i + 1 + ""); + snDetailMap.put("commodityCode", detail.getString("goodsNum")); + snDetailMap.put("commodityName", detail.getString("goodsName")); + 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("unitPrice"); + snDetailMap.put("unitPrice", unitPrice); + + if ("11".equals(invoiceType)) { + snDetailMap.put("tax", "0"); + + //如果是卷票计算合计金额 + String hjje = null; + if (detail.getString("detailAmount") != null && detail.getString("taxAmount") != null) { + BigDecimal je = new BigDecimal(detail.getString("detailAmount")); + if (detail.getString("taxAmount") != null) { + hjje = je.add(new BigDecimal(detail.getString("taxAmount"))).toPlainString(); + } else { + hjje = je.toPlainString(); + } + } + + if (StringUtils.isNotBlank(hjje)) + snDetailMap.put("amount", hjje); + + } else { + snDetailMap.put("tax", "***".equals(detail.getString("taxAmount")) ? "0.00" : detail.getString("taxAmount")); + snDetailMap.put("amount", detail.getString("detailAmount")); + } + + if ("免税".equals(detail.getString("taxRate")) || "不征税".equals(detail.getString("taxRate")) || "***".equals(detail.getString("taxRate"))) { + taxRateDetail = "0"; + snDetailMap.put("taxRate", taxRateDetail); + } else { + if (detail.get("taxRate") != null && StringUtils.isNoneBlank(detail.get("taxRate").toString())) { + try { + taxRateDetail = detail.get("taxRate").toString(); + if (!"0".equals(taxRateDetail)) { + if (StringUtils.isNoneBlank(taxRateDetail)) { + if (taxRateDetail.contains("%")) { + taxRateDetail = taxRateDetail.replace("%", ""); + } + BigDecimal tax = new BigDecimal(taxRateDetail); + BigDecimal tax1 = tax.divide(new BigDecimal("100")); + if (tax.compareTo(new BigDecimal("0.99")) < 1) { + taxRateDetail = tax.toPlainString(); + } else { + taxRateDetail = tax1.toPlainString(); + } + } + } + } catch (Exception e) { + log.error("报错的原因为:{}", e); + taxRateDetail = "0.00"; + } + + if ("11".equals(invoiceType)) { + taxRateDetail = "0.000"; + } + log.info("明细-发票税率为:{}", taxRateDetail); + snDetailMap.put("taxRate", taxRateDetail); + } + } + + log.info("明细-tax={}", detail.get("taxAmount")); + snDetailMap.put("currentDateEnd", detail.getString("txrqz")); + snDetailMap.put("currentDateStart", detail.getString("txrqq")); + snDetailMap.put("licensePlateNum", detail.getString("cph")); + snDetailMap.put("type", detail.getString("lx")); + + returnDetailList.add(snDetailMap); + } + } + + + checkInvoice.put("invoiceLineList", returnDetailList); + } + /** * 查验发票 */ diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/dao/VihicleInvoiceDetailDao.java b/dxhy-erp/src/main/java/com/dxhy/erp/dao/VihicleInvoiceDetailDao.java new file mode 100644 index 00000000..88bd7624 --- /dev/null +++ b/dxhy-erp/src/main/java/com/dxhy/erp/dao/VihicleInvoiceDetailDao.java @@ -0,0 +1,19 @@ +package com.dxhy.erp.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dxhy.erp.entity.TDxVehicleSaleInvoice; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author dxhy + */ +@Mapper +public interface VihicleInvoiceDetailDao extends BaseMapper { + + List selectVehicleSaleInvoice(String uuid); + + List selectVehicleInvoiceInfo(String uuid); + +} \ No newline at end of file diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java index e1da36d4..0f90df42 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java @@ -97,6 +97,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { @Resource private SysDeptDao sysDeptDao; + @Resource + private VihicleInvoiceDetailDao vihicleInvoiceDetailDao; + @Resource private SNPushCheckRecordService snPushCheckRecordService; @@ -1164,4 +1167,11 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { return true; } + public List vihicleList(String uuid){ + + List tDxVehicleSaleInvoices = vihicleInvoiceDetailDao.selectVehicleInvoiceInfo(uuid); + return tDxVehicleSaleInvoices; + + } + } diff --git a/dxhy-erp/src/main/resources/mapper/InvoiceDetails.xml b/dxhy-erp/src/main/resources/mapper/InvoiceDetails.xml index 73481414..5ac90864 100644 --- a/dxhy-erp/src/main/resources/mapper/InvoiceDetails.xml +++ b/dxhy-erp/src/main/resources/mapper/InvoiceDetails.xml @@ -1,7 +1,7 @@ - +