1.机动车&二手车发票增加相关信息

2.从销项获取税号信息
release
yefei 2 years ago
parent 3f680cc534
commit 9ba9f3d5e4
  1. 4
      dxhy-admin/src/main/resources/bootstrap-test.yaml
  2. 212
      dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java
  3. 19
      dxhy-erp/src/main/java/com/dxhy/erp/dao/VihicleInvoiceDetailDao.java
  4. 15
      dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java
  5. 14
      dxhy-erp/src/main/resources/bootstrap-dev.yaml
  6. 4
      dxhy-erp/src/main/resources/bootstrap-test.yaml
  7. 33
      dxhy-erp/src/main/resources/mapper/InvoiceDetails.xml
  8. 10
      pom.xml

@ -4,7 +4,7 @@ spring:
nacos:
config:
# Nacos config 地址
server-addr: 172.31.36.143:33000
server-addr: 172.31.36.146:33000
# Nacos config 命名空间,对应配置中的名称(dxhy-jxpt-namespace)
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c
# Nacos config 分组
@ -19,7 +19,7 @@ spring:
file-extension: yaml
# Nacos discovery 配置
discovery:
server-addr: 172.31.36.143:33000
server-addr: 172.31.36.146:33000
# Nacos config 登录用户名
username: admin
# Nacos config 登录密码

@ -110,6 +110,7 @@ public class SDNYMainProcessController extends AbstractController {
@Resource
private RequestRecordService requestRecordService;
/**
* 查验发票
*/
@ -264,11 +265,18 @@ public class SDNYMainProcessController extends AbstractController {
String invoiceNo = checkInvoiceByUuid.getInvoiceNo();
QueryWrapper<BaseTDxRecordInvoiceDetail> detailWrapper = new QueryWrapper<>();
detailWrapper.eq("uuid", uuid);
List<BaseTDxRecordInvoiceDetail> baseTDxRecordInvoiceDetail = null;
List<TDxVehicleSaleInvoice> vehicleList = null;
if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) {
vehicleList = snPushCheckRecordService.vihicleList(uuid);
} else {
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ);
List<BaseTDxRecordInvoiceDetail> baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper);
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<String> activeCallRequest = new ArrayList<>();
@ -285,11 +293,15 @@ public class SDNYMainProcessController extends AbstractController {
if (delete > 0) {
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber"));
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName);
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 +320,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 +722,194 @@ 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"));
}
//二手车
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("buyerUnitCode"));
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"));
}
String taxRate = "";
List<Map<String, String>> 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<String, String> snDetailMap = new HashMap<String, String>();
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);
}
/**
* 查验发票
*/

@ -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<TDxVehicleSaleInvoice> {
List<TDxVehicleSaleInvoice> selectVehicleSaleInvoice(String uuid);
List<TDxVehicleSaleInvoice> selectVehicleInvoiceInfo(String uuid);
}

@ -79,9 +79,6 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
@Resource
private ApiUtils apiUtils;
@Autowired
private AreaDao areaDao;
@Resource
private BaseTDxTaxCurrentDao baseTDxTaxCurrentDao;
@ -106,6 +103,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
@Resource
private TdxPlatformCheckLogService platformCheckLogService;
@Resource
private VihicleInvoiceDetailDao vihicleInvoiceDetailDao;
public String pushCheckResultToSAP(String requestParam) {
log.info("获取请求参数:{} , 请求地址:{}", requestParam, snYxUrl);
String post = HttpUtils.sendPo(snYxUrl, requestParam, userName, password);
@ -272,6 +272,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
/**
* 发票查验API
*
* @param pramsMap
* @param isInteger
* @return
@ -886,6 +887,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
}
private InvoiceInfo convertToInvoiceInfo(SNInvoice snInvoice) {
InvoiceInfo invoice = new InvoiceInfo();
invoice.setInvoiceTypeCode(snInvoice.getInvoiceType());
@ -1164,4 +1166,11 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
return true;
}
public List<TDxVehicleSaleInvoice> vihicleList(String uuid){
List<TDxVehicleSaleInvoice> tDxVehicleSaleInvoices = vihicleInvoiceDetailDao.selectVehicleInvoiceInfo(uuid);
return tDxVehicleSaleInvoices;
}
}

@ -4,13 +4,13 @@ spring:
nacos:
config:
# Nacos config 地址
server-addr: 172.31.36.147:33000
server-addr: 172.31.36.146:33000
# Nacos config 命名空间,对应配置中的名称(dxhy-jxpt-namespace)
namespace: eb6eab27-62a4-4ccf-8640-b8e91df0a1a6
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c
# Nacos config 分组
group: dxhy-erp-group
# Nacos config 登录用户名
username: nacos
username: admin
# Nacos config 登录密码
password: Invoice.nacos.!1
# Nacos config 配置文件前缀
@ -19,9 +19,7 @@ spring:
file-extension: yaml
# Nacos discovery 配置
discovery:
server-addr: 172.31.36.147:33000
# Nacos config 登录用户名
username: nacos
# Nacos config 登录密码
server-addr: 172.31.36.146:33000
username: admin
password: Invoice.nacos.!1
namespace: eb6eab27-62a4-4ccf-8640-b8e91df0a1a6
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c

@ -4,7 +4,7 @@ spring:
nacos:
config:
# Nacos config 地址
server-addr: 172.31.36.143:33000
server-addr: 172.31.36.146:33000
# Nacos config 命名空间,对应配置中的名称(dxhy-jxpt-namespace)
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c
# Nacos config 分组
@ -19,7 +19,7 @@ spring:
file-extension: yaml
# Nacos discovery 配置
discovery:
server-addr: 172.31.36.143:33000
server-addr: 172.31.36.146:33000
username: admin
password: Invoice.nacos.!1
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c

@ -0,0 +1,33 @@
<?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.VihicleInvoiceDetailDao">
<select id="selectVehicleSaleInvoice" parameterType="java.lang.String"
resultType="com.dxhy.erp.entity.TDxVehicleSaleInvoice">
select id,
uuid,
buyer_id_num,
vehicle_type,
factory_model,
product_place,
certificate,
certificate_import,
inspection_num,
engine_no,
vehicle_no,
phone,
buyer_bank,
tax_rate
from t_dx_vehicle_sale_invoice
where uuid = #{uuid}
</select>
<select id="selectVehicleInvoiceInfo" parameterType="java.lang.String"
resultType="com.dxhy.erp.entity.TDxVehicleSaleInvoice">
select *
from t_dx_vehicle_sale_invoice
where uuid = #{uuid}
</select>
</mapper>

@ -188,7 +188,10 @@
<deployType>test</deployType>
<logging.file>/home/dxhy/logs/</logging.file>
</properties>
<!-- 默认激活 -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 伊利测试环境 -->
<profile>
@ -221,10 +224,7 @@
<deployType>std</deployType>
<logging.file>/home/dxhy/logs/</logging.file>
</properties>
<!-- 默认激活 -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>

Loading…
Cancel
Save