From d1f4be00fc8ab2faf990aa0446156b305fc25586 Mon Sep 17 00:00:00 2001
From: 李白 <7387820+wjli_13439841639@user.noreply.gitee.com>
Date: 星期五, 05 六月 2026 08:14:28 +0800
Subject: [PATCH] 新增开票记录和开票项记录
---
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/invoice/service/impl/BIPYsServiceImpl.java | 301 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 301 insertions(+), 0 deletions(-)
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/invoice/service/impl/BIPYsServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/invoice/service/impl/BIPYsServiceImpl.java
index 88f7a45..ff81604 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/invoice/service/impl/BIPYsServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/invoice/service/impl/BIPYsServiceImpl.java
@@ -6,6 +6,7 @@
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.by4cloud.platformx.business.entity.BillingInfo;
import com.by4cloud.platformx.business.entity.SaleCredit;
import com.by4cloud.platformx.business.entity.invoice.BipInvoice;
import com.by4cloud.platformx.business.entity.invoice.InvoiceResult;
@@ -689,6 +690,306 @@
return bipResVo;
}
+ @Override
+ public BipResVo sendBIPYss(BillingInfo railwayEntrust) {
+ BIPBody bipBody = new BIPBody();
+ BIPYsMxHeader mx = new BIPYsMxHeader();
+ List<BIPYsItem> bipYsItems = new ArrayList<>();
+// mx.(railwayEntrust.getFyCompName());//鍙戣繍鐭�
+ //mx.setMX01_code(fromStation2);//鍙戠珯
+ /*if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) && !accountLedger.getId().equals(82)) {
+ contractNum = "";
+ }*/
+ if (StrUtil.isNotEmpty(railwayEntrust.getContractNo())) {
+ mx.setHTBMBT(1);
+ } else {
+ mx.setHTBMBT(0);
+ }
+ mx.setContractNo(railwayEntrust.getContractNo());
+ //mx.setMX021_code(customerCode);//鏀惰揣瀹㈡埛
+ //mx.setMX031_code(customerCode);//缁撶畻瀹㈡埛
+ //mx.setMX04(number);//缁撶畻鍗曞彿
+ mx.setMX0401(railwayEntrust.getEntrustCode());//鎵樻敹鍗曞彿
+ //mx.setMX051_code(businessType);//涓氬姟绉嶇被
+ //mx.setMX06(createName);//鍒涘缓浜�
+ //mx.setMX07(railwayEntrust.getUserName());//瀹℃牳浜�
+
+ //mx.setGX08_code(accountUnitNumber);//鏍哥畻鍗曞厓
+ //String remark = getRemark(railwayEntrust, "閿�", customerCode, id2);
+ mx.setRemarks(railwayEntrust.getInvoiceRemark());
+ //String fileUrl = fileUploadService.fileUpload(6, railwayEntrust.getId());
+ mx.setFk_002(3);
+ /*if (StrUtil.isNotEmpty(fileUrl) && "01".equals(jyType)) {
+ mx.setFk_002(3 + fileUrl.split(",").length);
+ }*/
+ /*if (railwayEntrust.getFatherEntrustId() != null) {
+ fileUrl = fileUploadService.fileUpload(6, contractNum);
+ mx.setFk_002(3);
+ if (StrUtil.isNotEmpty(fileUrl) && "01".equals(jyType)) {
+ mx.setFk_002(3 + fileUrl.split(",").length);
+ }
+ }*/
+ bipBody.setBustypeCode("MXysfp");
+ //bipBody.setStaffCode(userCode);
+// bipBody.setFk_038_code(userCode);
+ bipBody.setObjectType("1");
+ //bipBody.setCustomerCode(customerCode);
+ bipBody.setExtVouchCode(railwayEntrust.getEntrustCode());//鐓ら攢绯荤粺鍗曞彿
+
+ //bipBody.setFinanceOrgCode(id2);//寮�绁ㄧ粍缁嘔D
+ bipBody.setDirection("1");//鍗曟嵁鏂瑰悜 1钃� -1绾�
+ bipBody.setBillDate(DateUtil.format(new Date(), "yyyy-MM-dd"));//寮�绁ㄦ棩鏈�
+// bipBody.setBillDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd"));//寮�绁ㄦ棩鏈�
+
+// if ("0101".equals(jyType)){
+//
+// }
+ //bipBody.setContractNo(contractNum);
+ //bipBody.setOrgCode(id2);//涓氬姟缁勭粐id
+ //bipBody.setDeptCode(deptCode);
+ bipBody.setExchangeRateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+// bipBody.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(), "yyyy-MM-dd HH:mm:ss"));
+// bipBody.setCustomer();//瀹㈡埛缂栫爜
+
+ //bipBody.setRemarks(remark);
+
+ //琛ㄤ綋
+ //鐓ょ绫荤洰
+ BIPYsItem bipYsItem = new BIPYsItem();
+// bipYsItem.setExchangeRateDate(DateUtil.format(railwayEntrust.getBalanceDate(),"yyyy-MM-dd HH:mm:ss"));
+
+ //bipYsItem.setTaxRate(NumUtils.multiplyDouble(railwayEntrust.getTaxRate(),100d));
+ //bipYsItem.setUnitName("鍚�");
+
+ /*bipYsItem.setMaterialCode("7704000001");
+ bipYsItem.setQuantity(BigDecimal.valueOf(railwayEntrust.getTonnage()));
+ bipYsItem.setCustomerCode(customerCode);//瀹㈡埛缂栫爜
+ Double noTaxPrice = railwayEntrust.getPrice();
+ bipYsItem.setOriTaxAmount(BigDecimal.valueOf(railwayEntrust.getTaxFee()));//绋庨
+ String[] codes = expenseItemCode.get().split(",");
+ bipYsItem.setExpenseItemCode(codes[0]);
+
+ Double allPrice = railwayEntrust.getTotalPrice();
+ bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//鍘熷竵鏃犵◣閲戦
+ bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//鍘熷竵鍚◣閲戦
+ bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(railwayEntrust.getCoalFree()));//鏈竵鏃犵◣閲戦
+ bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(railwayEntrust.getTotalPrice()));//鏈竵鍚◣閲戦
+ bipYsItem.setOriTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8));//鏃犵◣鍗曚环
+ bipYsItem.setLocalTaxExcludedPrice(NumUtils.divideDouble(railwayEntrust.getCoalFree(), railwayEntrust.getTonnage(), 8));//鏃犵◣鍗曚环
+ Double realPrice = NumUtils.divideDouble(railwayEntrust.getTotalPrice(), railwayEntrust.getTonnage(), 8);
+ bipYsItem.setOriTaxIncludedPrice(realPrice);//鏈竵鍚◣鍗曚环
+ bipYsItem.setLocalTaxIncludedPrice(realPrice);//鏈竵鍚◣鍗曚环
+ //鍒嗗壊鍗曢噾棰�
+ if (CompUtils.isTsCustomer(railwayEntrust.getCustomerId())) {
+ if (railwayEntrust.getFatherEntrustId() == null) {
+
+ Double noTaxMoney = railwayEntrust.getCoalMoney();
+ Double taxMoney = railwayEntrust.getCoalTaxMoney();
+ Double allMoney = NumUtils.addDouble(noTaxMoney, taxMoney, 2);
+ allPrice = allMoney;
+ bipYsItem.setOriTaxAmount(BigDecimal.valueOf(taxMoney));//绋庨
+ bipYsItem.setOriTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//鍘熷竵鏃犵◣閲戦
+ bipYsItem.setOriTaxIncludedAmount(BigDecimal.valueOf(allMoney));//鍘熷竵鍚◣閲戦
+ bipYsItem.setLocalTaxExcludedAmount(BigDecimal.valueOf(noTaxMoney));//鏈竵鏃犵◣閲戦
+ bipYsItem.setLocalTaxIncludedAmount(BigDecimal.valueOf(allMoney));//鏈竵鍚◣閲戦
+ bipYsItem.setOriTaxExcludedPrice(railwayEntrust.getPrice());//鏃犵◣鍗曚环
+ bipYsItem.setLocalTaxExcludedPrice(railwayEntrust.getPrice());//鏃犵◣鍗曚环
+ bipYsItem.setOriTaxIncludedPrice(NumUtils.divideDouble(allMoney, railwayEntrust.getTonnage(), 8));//鏈竵鍚◣鍗曚环
+ bipYsItem.setLocalTaxIncludedPrice(NumUtils.divideDouble(allMoney, railwayEntrust.getTonnage(), 8));//鏈竵鍚◣鍗曚环
+ }
+
+ }
+ bipYsItem.setRemarks(remark);*/
+
+ //鐓ょ琛ㄤ綋
+ BIPYsMx bipYsMx = new BIPYsMx();
+ //bipYsMx.setJT12_code(ncCoalNumber);//鐗╂枡缂栫爜
+// bipYsMx.setJT25_code(codes[1]);
+ //bipYsMx.setGX06_code(coalBipCode);//鐗╂枡鍚嶇О
+
+ //bipYsMx.setMX021_code(customerCode);//鏀惰揣瀹㈡埛
+ //bipYsMx.setCustomerCode(customerAddressCode);//瀹㈡埛缂栫爜
+ bipYsMx.setJT06_code("01001001");//娆鹃」鏄庣粏
+ bipYsMx.setYSYF14_code("2");
+ /*if (id2!=null){
+ *//*if (id2 != null && id2.equals("10439") && railwayEntrust.getCoalId() != null && railwayEntrust.getCoalId().equals(45)) {
+ bipYsMx.setJT12_code("0101020401");//鐗╂枡缂栫爜
+ bipYsMx.setGX06_code("01010201043902438");//鐗╂枡鍚嶇О
+ }*//*
+ if (id2.equals("126") || id2.equals("10439") || id2.equals("1045116") || id2.equals("104810210") || id2.equals("1027902")) {
+ bipBody.setYSYF_08("0");
+ bipYsMx.setYSYF_08("0");
+ }
+ if (id2.startsWith("104")) {
+ if (focus) {
+ bipYsMx.setYSYF52("0");
+ } else {
+ bipYsMx.setYSYF52("1");
+ }
+
+ }
+
+ }
+ bipYsMx.setGX08_code(accountUnitNumber);*/
+ /*bipYsMx.setMX09(railwayEntrust.getCoalName());//杩愰攢鐓ょ
+ bipYsMx.setMX10(BigDecimal.valueOf(railwayEntrust.getRealTonnage()));//姘寸叅閲�
+ bipYsMx.setMX11(railwayEntrust.getAshContentMetering());//鐏板垎
+ bipYsMx.setMX13(railwayEntrust.getMoistureMetering());
+ bipYsMx.setMX14(railwayEntrust.getSulFurMetering());
+ bipYsMx.setMX15(railwayEntrust.getCoalName());
+ if (railwayEntrust.getInvoiceResultId() == null && !CompUtils.isKp(accountLedger.getId()) && !accountLedger.getId().equals(165)) {
+ throw new RuntimeException("缁撶畻鍗曟湭寮�绁�");
+ }*/
+ InvoiceResult invoiceResult = fpInvoiceResultService.getById(railwayEntrust.getBlueInvoiceResultId());
+ if (invoiceResult != null) {
+ bipYsMx.setYSYF33(invoiceResult.getInvoiceNo());
+ bipYsItem.setInvoiceNo(invoiceResult.getInvoiceNo());
+// bipYsMx.setInvoiceNo(invoiceResult.getInvoiceNo());
+ }
+ bipYsMx.setZzbkfl_code("01");
+ /*if (StrUtil.isNotEmpty(accountLedger.getZzbkfl())) {
+ bipYsMx.setZzbkfl_code(accountLedger.getZzbkfl());
+ }
+ String jyType1 = jyType;//鐗规畩浜ゆ槗鍗�
+ if (jyType.equals("0101") && railwayEntrust.getCustomerId() != null && railwayEntrust.getCustomerId().equals(203)) {
+ jyType1 = "01020202";
+ }
+
+ if (jyType.equals("0101") && railwayEntrust.getCustomerId() != null && (railwayEntrust.getCustomerId().equals(172) || railwayEntrust.getCustomerId().equals(200) || railwayEntrust.getCustomerId().equals(2002381))) {
+ jyType1 = "010201";
+ }*/
+
+ //bipYsMx.setJT04_code(jyType1);
+ //bipYsMx.setMX16(railwayEntrust.getTonnage());//鎶樺共閲�
+ bipYsItem.setFreeChId(bipYsMx);
+// bipYsMx.setMX18(railwayEntrust.getRealTonnage());//鏍囩叅閲�
+// bipYsMx.setMX18(railwayEntrust.getRealPrice());//鏍囩叅閲忓崟浠�
+ //鏀舵璁″垝
+ /*if (focus) {
+ List<BIPPayPlan> bipPayPlans = this.getBipPayPlan(railwayEntrust, allPrice);
+ bipYsItem.setGrandsonItem(bipPayPlans);
+ }*/
+ bipYsItems.add(bipYsItem);
+ String invoiceNo = invoiceResult == null ? "" : invoiceResult.getInvoiceNo();
+
+ /*if (railwayEntrust.getCustomerId() != null && (railwayEntrust.getCustomerId().equals(618) || railwayEntrust.getCustomerId().equals(608) || railwayEntrust.getCustomerId().equals(1367) || railwayEntrust.getCustomerId().equals(1002134))) {
+ this.getTsBt(railwayEntrust, customerCode, jyType1, focus, bipYsItems, isNd, accountUnitNumber, id2, fromStation, invoiceNo, contractNum);
+ } else {
+ this.getPtBt(railwayEntrust, customerCode, jyType1, focus, bipYsItems, isNd, accountUnitNumber, id2, fromStation, invoiceNo, contractNum);
+ }*/
+
+ bipBody.setBodyItem(bipYsItems);
+
+ /*if (railwayEntrust.getFatherEntrustId() == null && !railwayEntrust.getFyCompId().equals(227) && !order.getFiledId().equals(48)) {
+ List<Contract> contracts = fileUploadService.getContractsByEntrustId(railwayEntrust.getId());
+ System.out.println("閲嶅鍚堝悓锛�" + contracts.size() + "涓婄骇ID锛�" + railwayEntrust.getFatherEntrustId() + "缁撶畻鍗曞彿:" + railwayEntrust.getEntrustCode());
+ if (contracts != null && contracts.size() > 0) {
+ contracts.forEach(e -> {
+ BIPYsMxHeader newMx = new BIPYsMxHeader();
+ BeanUtils.copyProperties(mx, newMx);
+ if (accountLedger.getId().equals(80) || accountLedger.getId().equals(81) || accountLedger.getId().equals(82)) {
+ newMx.setContractNo("");
+ newMx.setHTBMBT(0);
+ } else {
+ newMx.setContractNo(e.getNum());
+ newMx.setHTBMBT(1);
+ }
+
+ bipBody.setFreeChId(newMx);
+ });
+ }
+
+ } else {
+ bipBody.setFreeChId(mx);
+ }*/
+
+
+ String result = bipHttpUtil.post(BipApiEnum.搴旀敹鍙戠エ淇濆瓨鎺ュ彛, new JSONObject().set("data", bipBody));
+ BipResVo resVo = JSONUtil.toBean(result, BipResVo.class);
+ //鏀惧埌鍗曟嵁璁板綍琛�
+ BipInvoice bipInvoice = new BipInvoice();
+ bipInvoice.setDay(DateUtil.date());
+ bipInvoice.setInvoice(JSONUtil.toJsonStr(bipBody));
+ bipInvoice.setType(0);
+ bipInvoice.setInvoiceType(0);
+ bipInvoice.setContractNum(railwayEntrust.getContractNo());
+ bipInvoice.setRailwayEntrustId(railwayEntrust.getId());
+ //bipInvoice.setAllId(Long.parseLong(allId+""));
+ bipInvoice.setBipCompNumber("id2");
+ bipInvoice.setDirection(1);
+ bipInvoice.setCompId(railwayEntrust.getCompId());
+ bipInvoice.setResStatus(resVo.getCode());
+// bipInvoice.setMoney(railwayEntrust.getAllPrice());
+// bipInvoice.setTonnage(railwayEntrust.getTonnage());
+// bipInvoice.setPrice(railwayEntrust.getPrice());
+ //bipInvoice.setTrainType(railwayEntrust.getTrainType());
+ BipResVo bipResVo = new BipResVo<>();
+ bipResVo.setCode(resVo.getCode());
+ BIPBody resBipBody = null;
+ if (resVo.getData() == null) {
+ resBipBody = new BIPBody();
+ } else {
+ resBipBody = JSONUtil.toBean(resVo.getData().toString(), BIPBody.class);
+ }
+
+
+ if (resVo.getCode().equals("200") || (StrUtil.isNotEmpty(resVo.getMessage()) && resVo.getMessage().contains("娲诲姩[璐㈠姟瀹℃牳]涓婃壘涓嶅埌鐢ㄦ埛")) || StrUtil.isNotEmpty(resBipBody.getCode())) {
+ bipInvoice.setResInvoice(resVo.getData().toString());
+
+ bipInvoice.setBipNumber(resBipBody.getId());
+ // bipInvoice.setCode("200");
+ bipInvoice.setCode(resBipBody.getCode());
+ bipInvoice.setMessage(resVo.getMessage());
+ bipInvoiceService.save(bipInvoice);
+ bipResVo.setCode("200");
+
+ } else {
+ if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
+ bipInvoice.setBipNumber(resBipBody.getId());
+ bipInvoice.setCode(resBipBody.getCode());
+ }
+ bipInvoice.setMessage(resVo.getMessage());
+ bipResVo.setMessage(resVo.getMessage());
+ bipInvoiceService.save(bipInvoice);
+
+ }
+ if (resVo.getData() != null && StrUtil.isNotEmpty(resVo.getData().toString())) {
+ if (resBipBody.getId() != null) {
+ try {
+ /*if (railwayEntrust.getTrainType().equals(1)) {
+ if (order != null && order.getCompId() != null && order.getCompId().equals(227) && order.getFiledId() != null && order.getFiledId().equals(48)) {
+ fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(8, allId));
+ } else {
+ fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(0, allId));
+ }
+
+ fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(3, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
+ } else if (railwayEntrust.getTrainType().equals(2)) {
+ fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(1, allId));
+ fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(4, railwayEntrust.getId(), railwayEntrust.getQualityName(), railwayEntrust.getUserCompId()));
+ }
+ if (StrUtil.isNotEmpty(fileUrl)) {
+ for (String s : fileUrl.split(",")) {
+ fileUploadService.uploadUrlToBip(railwayEntrust.getId(), resBipBody.getId(), s);
+ }
+ }*/
+ //鍙戠エ
+ railwayEntrust.setBipStatus(200);
+ fpInvoiceResultService.update(new UpdateWrapper<InvoiceResult>().lambda()
+ .eq(InvoiceResult::getEntrustCode, railwayEntrust.getEntrustCode())
+ .set(InvoiceResult::getPushBip, null));
+ //fpInvoiceResultService.pushBlue(railwayEntrust, 0);
+ //fileUploadService.uploadToBip(railwayEntrust.getId(), resBipBody.getId(), fileUploadService.fileUpload(2, allId));
+ } catch (Exception e) {
+ //railwayEntrust.setBipFileStatus(-1);
+ log.error("缁撶畻鍗曟帹閫侀檮浠堕敊璇�---", e);
+ e.printStackTrace();
+ }
+ }
+ }
+ return bipResVo;
+ }
+
public BipResVo sendBIPYf(SaleCredit railwayEntrust,String id1,String id2,String customerCode,String businessType,String fromStation,Integer allId,String contractNum,String number,String jyType,String accountUnitNumber,String deptCode,String userCode,Integer isNd) {
// BipResVo bipResVo1 = new BipResVo<>();
--
Gitblit v1.9.1