|
|
|
@ -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<BaseTDxRecordInvoice> 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<BaseTDxRecordInvoiceDetail> detailWrapper = new QueryWrapper<>(); |
|
|
|
|
detailWrapper.eq("invoice_no", invoiceNo); |
|
|
|
|
DynamicContextHolder.push(DbConstant.DETAIL_READ); |
|
|
|
|
List<BaseTDxRecordInvoiceDetail> 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<RecordInvoiceSaleDetailModel> saleDetailWrapper = new QueryWrapper<>(); |
|
|
|
|
saleDetailWrapper.eq("invoice_no", invoiceNo); |
|
|
|
|
DynamicContextHolder.push(DbConstant.DETAIL_READ); |
|
|
|
|
List<RecordInvoiceSaleDetailModel> 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<Map<String, String>> 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<String, String> snDetailMap = new HashMap<String, String>(); |
|
|
|
|
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("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("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")); |
|
|
|
|