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 4f225658..d765ac1d 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 @@ -33,7 +33,6 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; -import java.math.RoundingMode; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -107,7 +106,6 @@ public class SDNYMainProcessController extends AbstractController { @Resource private GatherService gatherService; - /** * 查验发票 */ @@ -203,10 +201,10 @@ public class SDNYMainProcessController extends AbstractController { List baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); - if (baseTDxRecordInvoiceDetail != null && baseTDxRecordInvoiceDetail.size() == 0) { + if(baseTDxRecordInvoiceDetail != null && baseTDxRecordInvoiceDetail.size() == 0){ //先删除原有主数据,再查验更新主数据和明细数据 int delete = baseTDxRecordInvoiceDao.delete(recordWrapper); - if (delete > 0) { + if(delete > 0) { checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); if (!checkInvoiceResult.containsKey("code")) { @@ -261,13 +259,14 @@ 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(); - log.error("查验失败,errormsg:{}", e.getMessage()); - return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败," + e.getMessage()))); + log.error("查验失败,errormsg:{}",e.getMessage()); + return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败,"+e.getMessage()))); } + if (!checkInvoiceResult.containsKey("code")) { if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { @@ -290,7 +289,6 @@ public class SDNYMainProcessController extends AbstractController { return ResponseEntity.ok(JSONObject.toJSONString(data)); } - } else { //其他类发票,直接入库 log.info("其他类发票,不做查验,直接入库"); @@ -456,7 +454,7 @@ public class SDNYMainProcessController extends AbstractController { 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").contains("详见销货清单")) { + if(StringUtils.isNotEmpty(detail.getString("goodsName")) && detail.getString("goodsName").contains("详见销货清单")){ continue; } Map snDetailMap = new HashMap(); @@ -506,33 +504,24 @@ public class SDNYMainProcessController extends AbstractController { int index = taxRateDetail.indexOf("%"); if (index > 0) { taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); - Float num = Float.parseFloat(taxRateDetail); - if (num > 9) { - taxRateDetail = "0." + taxRateDetail; - } else { - if (!taxRateDetail.startsWith("0")) { - taxRateDetail = "0.0" + taxRateDetail; - } - } - } else { - Float num = Float.parseFloat(taxRateDetail); - if (num > 9) { - taxRateDetail = "0." + taxRateDetail; - } else { - if (!taxRateDetail.startsWith("0")) { - taxRateDetail = "0.0" + taxRateDetail; - } - } +// Float num = Float.parseFloat(taxRateDetail); +// if (num > 9) { +// taxRateDetail = "0." + taxRateDetail; +// } else { +// if (!taxRateDetail.startsWith("0")) { +// taxRateDetail = "0.0" + taxRateDetail; +// } +// } } } } - } catch (Exception e) { - log.error("报错的原因为:{}", e); - taxRateDetail = "0.00"; + }catch (Exception e){ + log.error("报错的原因为:{}",e); + taxRateDetail = "0"; } if ("11".equals(invoiceType)) { - taxRateDetail = "0.000"; + taxRateDetail = "0"; } log.info("明细-发票税率为:{}", taxRateDetail); snDetailMap.put("taxRate", taxRateDetail); @@ -687,11 +676,11 @@ public class SDNYMainProcessController extends AbstractController { log.error("同步SAP失败,报错信息为:{}", exception); exception.printStackTrace(); return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT))); - } catch (NullPointerException exception) { + } catch(NullPointerException exception){ log.error("同步SAP失败,报错信息为:{}", exception); exception.printStackTrace(); return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT))); - } catch (Exception exception) { + } catch(Exception exception){ log.error("同步SAP失败,报错信息为:{}", exception); exception.printStackTrace(); return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT))); @@ -798,7 +787,6 @@ public class SDNYMainProcessController extends AbstractController { info.setZGFZH(snInvoice.getPurchaserBank()); info.setZBZ(snInvoice.getRemarks()); - List invoiceLineList = snInvoice.getInvoiceLineList(); List sapInvoiceDetailList = new ArrayList<>(); //查询明细 @@ -830,36 +818,26 @@ public class SDNYMainProcessController extends AbstractController { sapInvoiceDetail.setZJK(snInvoiceDetail.getAmount()); sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo()); //将类似于0.03数据格式转化为3.00 - if (snInvoiceDetail.getTaxRate() != null && !"".equals(snInvoiceDetail.getTaxRate())) { + if (snInvoiceDetail.getTaxRate() != null && snInvoiceDetail.getTaxRate() != "") { sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate()); if ("0".equals(snInvoiceDetail.getTaxRate())) { sapInvoiceDetail.setZTAX("0.00"); - sapInvoiceDetail.setZSM(sapInvoiceDetail.getZTAX()); +// sapInvoiceDetail.setZSM(sapInvoiceDetail.getZTAX()); } if (snInvoiceDetail.getTaxRate().contains(".")) { String getTaxRate = snInvoiceDetail.getTaxRate(); -// if (snInvoiceDetail.getTaxRate().length() > 4) { -// getTaxRate = getTaxRate.substring(0, 4); -// } + if (snInvoiceDetail.getTaxRate().length() > 4) { + getTaxRate = getTaxRate.substring(0, 4); + } BigDecimal tax = new BigDecimal(getTaxRate); sapInvoiceDetail.setZSM(getZSM(tax.toString())); BigDecimal tax1 = tax.multiply(new BigDecimal("100")); sapInvoiceDetail.setZTAX(tax1.toString()); - if (tax1.compareTo(new BigDecimal("100")) > 0) { - sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate()); - } else if (tax1.scale() > 2) { - BigDecimal substring = tax1.setScale(2, RoundingMode.FLOOR); - sapInvoiceDetail.setZTAX(substring.toPlainString()); - } - } if (snInvoiceDetail.getTaxRate().contains("%") && !snInvoiceDetail.getTaxRate().contains(".")) { String replace = snInvoiceDetail.getTaxRate().replace("%", ".00"); - String replaceZsm = snInvoiceDetail.getTaxRate().replace("%", ""); - sapInvoiceDetail.setZSM(getZSM(replaceZsm)); sapInvoiceDetail.setZTAX(replace); } - } // if (invoiceLineList.size() == 1 && snInvoice.getTaxRate() == null) { // info.setZTAX(sapInvoiceDetail.getZTAX()); @@ -885,16 +863,15 @@ 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.contains("%") && !zsmTax.contains(".")) { -// zsmTax = (new BigDecimal(zsmTax.replace("%", ""))).divide(new BigDecimal("100")).toString(); -// } -//// sapInvoiceDetail.setZSM(getZSM(snInvoiceDetail.getTaxRate())); -// sapInvoiceDetail.setZSM(getZSM(zsmTax)); + String zsmTax = snInvoiceDetail.getTaxRate(); + if (zsmTax != null && zsmTax != "" && zsmTax.length() > 4) { + zsmTax = zsmTax.substring(0, 4); + } + if (zsmTax != null && zsmTax.contains("%") && !zsmTax.contains(".")) { + zsmTax = (new BigDecimal(zsmTax.replace("%", ""))).divide(new BigDecimal("100")).toString(); + } +// sapInvoiceDetail.setZSM(getZSM(snInvoiceDetail.getTaxRate())); + sapInvoiceDetail.setZSM(getZSM(zsmTax)); sapInvoiceDetail.setZGGXH(snInvoiceDetail.getSpecificationModel()); if (snInvoice.getInvoiceCode() != null) { sapInvoiceDetail.setZTID(snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber() + snFplx); @@ -912,7 +889,7 @@ public class SDNYMainProcessController extends AbstractController { if (taxRate != null && !taxRate.contains("%")) { BigDecimal bigDecimal = new BigDecimal(taxRate); BigDecimal multiply = bigDecimal.multiply(new BigDecimal("100")); - info.setZTAX(multiply.toPlainString()); + info.setZTAX(multiply.toString()); info.setZSM(getZSM(taxRate)); } if (taxRate != null && taxRate.contains("%")) { @@ -925,19 +902,20 @@ public class SDNYMainProcessController extends AbstractController { info.setZSM(getZSM(divide.toString())); } if (taxRate != null && taxRate.contains(".") && !taxRate.contains("%")) { - - BigDecimal tax = new BigDecimal(taxRate); - info.setZSM(getZSM(tax.toPlainString())); - BigDecimal tax1 = tax.multiply(new BigDecimal("100")); - info.setZTAX(tax1.setScale(2, RoundingMode.FLOOR).toPlainString()); - + 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)) { info.setZTAX("0.00"); info.setZSM(getZSM(info.getZTAX())); } if (invoiceLineList == null || invoiceLineList.size() == 0) { - if (info.getZTAX() == null || "".equals(info.getZTAX())) { + if (info.getZTAX() == null || info.getZTAX() == "") { info.setZTAX("0.00"); info.setZSM(getZSM(info.getZTAX())); } @@ -1024,12 +1002,12 @@ public class SDNYMainProcessController extends AbstractController { || "08".equals(snInvoice.getInvoiceType()) || "10".equals(snInvoice.getInvoiceType()) || "11".equals(snInvoice.getInvoiceType()) || "14".equals(snInvoice.getInvoiceType()) || "15".equals(snInvoice.getInvoiceType()) || "31".equals(snInvoice.getInvoiceType()) || "32".equals(snInvoice.getInvoiceType())) { //可查验发票, - log.info("发票类型为:{}", snInvoice.getInvoiceType()); + log.info("发票类型为:{}",snInvoice.getInvoiceType()); //0608 区块链发票 并且 checkStatus = 3 的时候 提交sap状态为3(刘振和谈楚才提出需求) - if ("10".equals(snInvoice.getInvoiceType()) && "3".equals(snInvoice.getCheckStatus())) { + if("10".equals(snInvoice.getInvoiceType()) && "3".equals(snInvoice.getCheckStatus())){ log.info("区块链发票 传输状态checkStatus = 3"); info.setZCYZT("3"); - } else { + }else { info.setZCYZT("1"); } } else { @@ -1200,9 +1178,6 @@ public class SDNYMainProcessController extends AbstractController { case "1.5": sm = "JA"; break; - case "0.015": - sm = "JA"; - break; case "1": sm = "J9"; break; @@ -1276,17 +1251,4 @@ public class SDNYMainProcessController extends AbstractController { } return ZCYJG; } - - /** - * 查验发票 - */ - @PostMapping("/refresh") - @ResponseBody - @SysLog("发票查验") - public String refreshDetailData(@RequestBody Map pramsMap) throws Exception { - log.info("接口请求的参数为:{}", pramsMap); - String result = snPushCheckRecordService.getRecords(pramsMap); - return result; - } - } 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 4ef5a0e8..d72e8764 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 @@ -4,9 +4,7 @@ import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.dxhy.common.constant.DbConstant; import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.enums.FplxEnum; @@ -42,7 +40,6 @@ import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; -import java.util.stream.Collectors; /** * 与山东能源交互数据主类 @@ -91,18 +88,12 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { @Resource private TDxInvoiceReimburseDao invoiceReimburseDao; - @Resource - private TdxRecordInvoiceDao tdxRecordInvoiceDao; - @Resource private BaseTDxRecordInvoiceDao baseTDxRecordInvoiceDao; @Resource private TDxInvoiceReimburseService tDxInvoiceReimburseService; - @Resource - private BaseTDxRecordInvoiceDetailDao baseTDxRecordInvoiceDetailDao; - @Resource private SysDeptDao sysDeptDao; @@ -279,50 +270,6 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { return queryInvoiceResult; } - public String getRecords(Map pramsMap) { - DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); - QueryWrapper recordWrapper = new QueryWrapper<>(); - List uuids = tdxRecordInvoiceDao.selectRecords(pramsMap); - log.info("获取的uuid为{}",uuids); - - for (String uuid: uuids) { - boolean flag = false; - QueryWrapper detailWrapper = new QueryWrapper<>(); - detailWrapper.eq("uuid", uuid); - DynamicContextHolder.push("business" + DbConstant.DETAIL_READ); - List details = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); - DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); - - log.info("获取到的明细为:{}",details); - String taxRate = ""; - for(BaseTDxRecordInvoiceDetail detail : details){ - //获取明细信息 更新主表税率 - if(StringUtils.isNotEmpty(detail.getTaxRate())){ - if(flag){ - if(!taxRate.contains(detail.getTaxRate())) { - taxRate = taxRate + "," + detail.getTaxRate(); - } - }else{ - if(!taxRate.contains(detail.getTaxRate())) { - taxRate = taxRate + detail.getTaxRate(); - } - flag = true; - } - } - } - log.info("获取的数据明细taxRate为={}",taxRate); - if(StringUtils.isNotEmpty(taxRate)) { - Map updateParam = new HashMap<>(); - updateParam.put("taxRate", taxRate); - updateParam.put("uuid", uuid); - - tdxRecordInvoiceDao.updateTaxRate(updateParam); - } - } - return "ok"; - } - - public JSONObject singleCheckInvoice(Map pramsMap) throws Exception { //1.封装查验参数 @@ -512,7 +459,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { jsonObject.put("tonnage", invoiceData.get("dw")); jsonObject.put("limitPeople", invoiceData.get("xcrs")); String taxRate = ""; - if (StringUtils.isNotEmpty(invoiceData.get("sl").toString()) || "免税".equals(invoiceData.get("sl").toString()) || "不征税".equals(invoiceData.get("sl").toString()) || "***".equals(invoiceData.get("sl").toString())) { + if (StringUtils.isBlank(invoiceData.get("sl").toString()) || "免税".equals(invoiceData.get("sl").toString()) || "不征税".equals(invoiceData.get("sl").toString()) || "***".equals(invoiceData.get("sl").toString())) { taxRate = "0"; jsonObject.put("taxRate", taxRate); } else { @@ -608,13 +555,13 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { taxRateDetail = "0"; snDetailMap.put("taxRate", taxRateDetail); } else { - if (detail.get("sl") != null && StringUtils.isNoneBlank(detail.get("sl").toString())) { + if (StringUtils.isNoneBlank(detail.get("sl").toString())) { taxRateDetail = detail.get("sl").toString(); if (!"0".equals(taxRateDetail)) { if (StringUtils.isNoneBlank(taxRateDetail)) { int index = taxRateDetail.indexOf("%"); - if (index > 0) { - taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); +// if (index > 0) { +// taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); // Float num = Float.parseFloat(taxRateDetail); // if (num > 9) { // taxRateDetail = "0." + taxRateDetail; @@ -623,7 +570,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { // taxRateDetail = "0.0" + taxRateDetail; // } // } - } +// } } }