ariesy 无明细数据,再次查验补充明细

release
yefei 2 years ago
parent 052725b75e
commit 7a11ccd71f
  1. 73
      dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java

@ -110,7 +110,7 @@ public class SDNYMainProcessController extends AbstractController {
@PostMapping("/singleInvoiceCheck")
@ResponseBody
@SysLog("发票查验")
public ResponseEntity<String> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) throws ParseException {
public ResponseEntity<String> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) throws Exception {
log.info("传入的参数为:{}", pramsMap);
String userid = "101833";
String dbName = "business";
@ -165,7 +165,7 @@ public class SDNYMainProcessController extends AbstractController {
return ResponseEntity.ok(JSONObject.toJSONString(R.error("金额不能为空!")));
}
} else {
if (StringUtils.isBlank(pramsMap.get("checkCode"))){
if (StringUtils.isBlank(pramsMap.get("checkCode"))) {
return ResponseEntity.ok(JSONObject.toJSONString(R.error("校验码不能为空!")));
}
}
@ -184,7 +184,7 @@ public class SDNYMainProcessController extends AbstractController {
}
//非通行费类发票 先判断底账库中是否已存在
if(!"32000".equals(pramsMap.get("invoiceType"))) {
if (!"32000".equals(pramsMap.get("invoiceType"))) {
//查询底账库是否有对应发票,有则直接返回
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>();
recordWrapper.eq("uuid", uuid);
@ -197,9 +197,26 @@ public class SDNYMainProcessController extends AbstractController {
detailWrapper.eq("uuid", uuid);
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ);
List<BaseTDxRecordInvoiceDetail> baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper);
DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ);
if(baseTDxRecordInvoiceDetail != null && baseTDxRecordInvoiceDetail.size() == 0){
//先删除原有主数据,再查验更新主数据和明细数据
int delete = baseTDxRecordInvoiceDao.delete(recordWrapper);
if(delete > 0) {
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap);
if (!checkInvoiceResult.containsKey("code")) {
if (!checkInvoiceResult.containsKey("cyjg")) {
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);
}
}
JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(checkInvoiceByUuid);
JSONArray checkInvoiceDetail = (JSONArray) JSONObject.toJSON(baseTDxRecordInvoiceDetail);
@ -240,8 +257,8 @@ public class SDNYMainProcessController extends AbstractController {
}
try {
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap);
log.info("查验结果为:{}", checkInvoiceResult);
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap);
log.info("查验结果为:{}", checkInvoiceResult);
} catch (Exception e) {
e.printStackTrace();
}
@ -312,7 +329,7 @@ public class SDNYMainProcessController extends AbstractController {
private R errorInfo(JSONObject checkInvoiceResult, R data) {
if ("0002".equals(checkInvoiceResult.getString("cyjg"))) {
data = new R(1002, checkInvoiceResult.getString("cyjgxx"));
data = new R(1002, checkInvoiceResult.getString("cyjgxx"));
}
if ("0005".equals(checkInvoiceResult.getString("cyjg"))) {
@ -375,7 +392,7 @@ public class SDNYMainProcessController extends AbstractController {
checkInvoice.put("totalAmount", checkInvoice.getString("invoiceAmount"));
//添加非空判断
String invoiceCode = null;
if ( checkInvoice.get("invoiceCode") != null){
if (checkInvoice.get("invoiceCode") != null) {
invoiceCode = checkInvoice.get("invoiceCode").toString();
}
String invoiceType = checkInvoice.get("invoiceType").toString();
@ -390,10 +407,10 @@ public class SDNYMainProcessController extends AbstractController {
checkInvoice.put("administrativeDivisionNo", "");
checkInvoice.put("administrativeDivisionName", "");
if("31".equals(invoiceType) || "32".equals(invoiceType) || "185".equals(invoiceType) || "186".equals(invoiceType)){
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("invoiceNumber", invoiceCode == null ? checkInvoice.get("invoiceNo").toString() : invoiceCode + checkInvoice.get("invoiceNo").toString());
} else {
checkInvoice.put("invoiceCode", invoiceCode);
checkInvoice.put("invoiceNumber", checkInvoice.get("invoiceNo").toString());
}
@ -452,10 +469,10 @@ public class SDNYMainProcessController extends AbstractController {
Float hjje = null;
if (detail.getString("detailAmount") != null && detail.getString("taxAmount") != null) {
Float je = Float.parseFloat(detail.getString("detailAmount"));
if(detail.getString("taxAmount") != null) {
if (detail.getString("taxAmount") != null) {
Float se = Float.parseFloat(detail.getString("taxAmount"));
hjje = je + se;
}else{
} else {
hjje = je;
}
}
@ -531,7 +548,7 @@ public class SDNYMainProcessController extends AbstractController {
String company = "";
String taxno = "";
String taxname = "";
if(orgByCompCode != null) {
if (orgByCompCode != null) {
company = orgByCompCode.getCompany();
taxno = orgByCompCode.getTaxno();
taxname = orgByCompCode.getTaxname();
@ -650,7 +667,7 @@ public class SDNYMainProcessController extends AbstractController {
}
}
} catch (Exception exception) {
log.error("同步SAP失败,报错信息为:{}",exception);
log.error("同步SAP失败,报错信息为:{}", exception);
exception.printStackTrace();
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)));
@ -759,7 +776,7 @@ public class SDNYMainProcessController extends AbstractController {
List<SAPInvoiceDetail> sapInvoiceDetailList = new ArrayList<>();
//查询明细
String uuid = snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber();
if (StringUtils.isBlank(snInvoice.getInvoiceCode())){
if (StringUtils.isBlank(snInvoice.getInvoiceCode())) {
uuid = snInvoice.getInvoiceNumber();
}
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ);
@ -788,7 +805,7 @@ public class SDNYMainProcessController extends AbstractController {
//将类似于0.03数据格式转化为3.00
if (snInvoiceDetail.getTaxRate() != null && snInvoiceDetail.getTaxRate() != "") {
sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate());
if ( "0".equals(snInvoiceDetail.getTaxRate())){
if ("0".equals(snInvoiceDetail.getTaxRate())) {
sapInvoiceDetail.setZTAX("0.00");
// sapInvoiceDetail.setZSM(sapInvoiceDetail.getZTAX());
}
@ -802,7 +819,7 @@ public class SDNYMainProcessController extends AbstractController {
BigDecimal tax1 = tax.multiply(new BigDecimal("100"));
sapInvoiceDetail.setZTAX(tax1.toString());
}
if (snInvoiceDetail.getTaxRate().contains("%") && !snInvoiceDetail.getTaxRate().contains(".")){
if (snInvoiceDetail.getTaxRate().contains("%") && !snInvoiceDetail.getTaxRate().contains(".")) {
String replace = snInvoiceDetail.getTaxRate().replace("%", ".00");
sapInvoiceDetail.setZTAX(replace);
}
@ -818,11 +835,11 @@ public class SDNYMainProcessController extends AbstractController {
sapInvoiceDetail.setZCYR(info.getZCYRMC());
sapInvoiceDetail.setZDW(snInvoiceDetail.getUnit());
sapInvoiceDetail.setZGSJBM(snInvoiceDetail.getCommodityCode());
if (StringUtils.isNotBlank(snInvoiceDetail.getTax())){
if (StringUtils.isNotBlank(snInvoiceDetail.getTax())) {
sapInvoiceDetail.setZSE(snInvoiceDetail.getTax());
}else {
if (detailInfo != null && !detailInfo.isEmpty()){
} else {
if (detailInfo != null && !detailInfo.isEmpty()) {
for (InvoiceDetailInfo invoiceDetailInfo : detailInfo) {
if (StringUtils.isNotBlank(invoiceDetailInfo.getDetailNo()) && invoiceDetailInfo.getDetailNo().equals(snInvoiceDetail.getRowNo())) {
sapInvoiceDetail.setZSE(invoiceDetailInfo.getTaxAmount());
@ -832,10 +849,10 @@ public class SDNYMainProcessController extends AbstractController {
}
sapInvoiceDetail.setZSL(snInvoiceDetail.getQuantity());
String zsmTax = snInvoiceDetail.getTaxRate();
if (zsmTax != null && zsmTax != "" && zsmTax.length() > 4){
zsmTax = zsmTax.substring(0,4);
if (zsmTax != null && zsmTax != "" && zsmTax.length() > 4) {
zsmTax = zsmTax.substring(0, 4);
}
if (zsmTax != null && zsmTax.contains("%") && !zsmTax.contains(".")){
if (zsmTax != null && zsmTax.contains("%") && !zsmTax.contains(".")) {
zsmTax = (new BigDecimal(zsmTax.replace("%", ""))).divide(new BigDecimal("100")).toString();
}
// sapInvoiceDetail.setZSM(getZSM(snInvoiceDetail.getTaxRate()));
@ -869,16 +886,16 @@ public class SDNYMainProcessController extends AbstractController {
info.setZTAX(replace + ".00");
info.setZSM(getZSM(divide.toString()));
}
if (taxRate != null && taxRate.contains(".") && !taxRate.contains("%")){
if (taxRate.length() >4){
taxRate = taxRate.substring(0,4);
if (taxRate != null && taxRate.contains(".") && !taxRate.contains("%")) {
if (taxRate.length() > 4) {
taxRate = taxRate.substring(0, 4);
BigDecimal tax = new BigDecimal(taxRate);
info.setZSM(getZSM(tax.toString()));
BigDecimal tax1 = tax.multiply(new BigDecimal("100"));
info.setZTAX(tax1.toString());
}
}
if (taxRate != null && "0".equals(taxRate)){
if (taxRate != null && "0".equals(taxRate)) {
info.setZTAX("0.00");
info.setZSM(getZSM(info.getZTAX()));
}

Loading…
Cancel
Save