From a96b03a0604a307c11acd91fc42ca35ae9c04e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Thu, 23 Jul 2026 14:49:19 +0800 Subject: [PATCH 01/13] =?UTF-8?q?nc=E6=8E=A8=E9=80=81=E6=94=B9=E9=80=A0(?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=B8=AD);?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/mapper/BillManageMapper.java | 2 + .../persistence/BillManageImpl.java | 763 ++++++++++++++++-- .../resources/mapper/BillManageMapper.xml | 4 + 3 files changed, 688 insertions(+), 81 deletions(-) diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillManageMapper.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillManageMapper.java index 1a075701b..5a4edf3f3 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillManageMapper.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillManageMapper.java @@ -44,4 +44,6 @@ public interface BillManageMapper extends BaseMapper String getDeptName(@Param("dictCode") String dictCode); String getOrgCodeNc(@Param("organizationId") Long organizationId); + + Long getShipperId(@Param("userId") Long userId, @Param("organizationId") Long organizationId); } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java index 014e611f8..01fa77070 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java @@ -9,7 +9,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.mhd.bms.domain.billManage.entity.BillDetail; import com.mhd.bms.domain.billManage.entity.BillManage; +import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService; import com.mhd.bms.domain.billManage.repository.facade.IBillManageService; import com.mhd.bms.domain.billManage.repository.mapper.BillManageMapper; import com.mhd.bms.domain.billManage.repository.po.BillManagePO; @@ -24,6 +26,8 @@ import com.mhd.bms.domain.ncDataPushConfig.entity.NcDataPushConfig; import com.mhd.bms.domain.ncDataPushConfig.repository.mapper.NcDataPushConfigMapper; import com.mhd.bms.domain.ncLog.entity.NcLog; import com.mhd.bms.domain.ncLog.repository.mapper.NcLogMapper; +import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers; +import com.mhd.bms.domain.settlementCustomers.repository.facade.ISettlementCustomersService; import com.mhd.bms.interfaces.dto.billManage.BillManageDTO; import com.mhd.common.core.domain.dto.ReconciliationDTO; import com.mhd.common.core.domain.dto.nc.*; @@ -83,6 +87,8 @@ public class BillManageImpl extends ServiceImpl im @Autowired private BillManageMapper billManageMapper; @Autowired + private IBillDetailService billDetailService; + @Autowired private BmsInvoiceListMapper bmsInvoiceListMapper; //nc测试环境地址 @@ -103,6 +109,8 @@ public class BillManageImpl extends ServiceImpl im private BmsMakeOutInvoiceMapper bmsMakeOutInvoiceMapper; @Resource private BmsMakeOutInvoiceItemMapper bmsMakeOutInvoiceItemMapper; + @Autowired + private ISettlementCustomersService settlementCustomersService; /** * 查询账单管理列表 */ @@ -177,7 +185,6 @@ public class BillManageImpl extends ServiceImpl im return true; } - public boolean synchronousNc_TY(String businessDocumentDetaliId) { BillManage reconciliation=billManageMapper.selectById(businessDocumentDetaliId); if(reconciliation.getSynchronousStatus()==1){ @@ -190,10 +197,13 @@ public class BillManageImpl extends ServiceImpl im SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); String dateString = sdf.format(date); String invoiceId = reconciliation.getInvoiceId(); - List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); - if (bmsMakeOutInvoices != null && bmsMakeOutInvoices.size() > 0){ +// List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); + List billDetails = billDetailService.list(new LambdaQueryWrapper() + .eq(BillDetail::getBillManageId, businessDocumentDetaliId) + .eq(BillDetail::getDelFlag, 1)); + if (billDetails!=null && billDetails.size()>0){ int count = 0; - for (BmsMakeOutInvoice make : bmsMakeOutInvoices) { + for (BillDetail make : billDetails) { count++; List ysitemList=new ArrayList(); String url = ""; @@ -213,8 +223,19 @@ public class BillManageImpl extends ServiceImpl im String deptName = billManageMapper.getDeptName(customerUserDept); String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); String salesmanCodeNc=salespersonNcCode; - String appointShipper=make.getActualInvoiceCustomerName(); - String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); + + Long settlementCustomersId = reconciliation.getSettlementCustomersId(); + SettlementCustomers settlementCustomers = settlementCustomersService.getById(settlementCustomersId); + if (settlementCustomers==null){ + throw new ServiceException("结算对象未找到!"); + } + Long settlementEntityId = settlementCustomers.getSettlementEntityId(); + Long shipperId = billManageMapper.getShipperId(settlementEntityId, organizationId); + if (shipperId==null||shipperId==0){ + throw new ServiceException("结算对象未找到!"); + } + String appointShipper=settlementCustomers.getSettlementEntity(); + String actualInvoiceCustomerId = String.valueOf(shipperId); String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { @@ -241,85 +262,82 @@ public class BillManageImpl extends ServiceImpl im String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); String makerCodeNc = documentPreparerNcCode; String settlementCurrencyNcCode = settlementCurrency; - String invoiceNumber=make.getInvoiceNumber(); - List bmsMakeOutInvoiceItems = bmsMakeOutInvoiceItemMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoiceItem::getMakeId, make.getId())); - if (bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0) { - for (BmsMakeOutInvoiceItem item1 : bmsMakeOutInvoiceItems) { - if(item1.getInvoiceValue().compareTo(BigDecimal.ZERO)>0){ - Ysitem item=new Ysitem(); - if (deptValue != null && !deptValue.isEmpty()) { - item.setSo_deptid(deptValue); - } else { - item.setSo_deptid("NG0408"); - } - if (deptValue != null && !deptValue.isEmpty()) { - item.setPk_deptid(deptValue); - } else { - item.setPk_deptid("NG0408"); - } - //业务员nc - item.setPk_psndoc(salesmanCodeNc); - //客户nc - item.setCustomer(customerCodeNc); - item.setObjtype("0"); - item.setDirection("1"); - String invoiceItem = item1.getInvoiceItem(); - List names = new ArrayList<>(); - List nccodes = new ArrayList<>(); - if (invoiceItem != null && !invoiceItem.isEmpty()) { - String[] items = invoiceItem.split(","); - for (String s : items) { - String invoiceItemName1 = billManageMapper.getInvoiceItemName(s); - String invoiceItemNcCode1 = billManageMapper.getInvoiceItemNcCode(s); - names.add(invoiceItemName1); - nccodes.add(invoiceItemNcCode1); - } - } - String invoiceItemName = String.join(",", names); - //item.setDef29(invoiceItemName); - if (deptName != null && !deptName.isEmpty()) { - item.setScomment(deptName+":应收"+appointShipper+invoiceItemName+invoiceNumber); - } else { - item.setScomment("业务部:应收"+appointShipper+invoiceItemName+invoiceNumber); - } - // item.setPk_currtype("CNY"); - item.setPk_currtype(settlementCurrencyNcCode); - item.setPurchaseorder(""); - item.setTaxrate(String.valueOf(item1.getTaxRate())); - item.setQuantity_de("0"); - item.setMoney_de(String.valueOf(item1.getInvoiceValue())); - item.setMoney_bal(String.valueOf(item1.getInvoiceValue())); - BigDecimal tax_de=item1.getTaxAmount(); - BigDecimal notax_de=item1.getTaxFreeFee(); - item.setNotax_de(String.valueOf(notax_de)); - item.setLocal_tax_de(String.valueOf(tax_de)); - item.setTax_de(String.valueOf(tax_de)); - item.setPrice(String.valueOf(item1.getInvoiceValue())); - item.setTaxprice(String.valueOf(item1.getInvoiceValue())); -// 费用类别 - String feeType = item1.getFeeType(); - String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); - if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { - item.setDef75(serviceItemsCodeNc); - } else { - item.setDef75("T04"); - } - String invoiceItem1 = item1.getInvoiceItem(); - if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { - String[] split = invoiceItem1.split(","); - item.setDef29(split[0]); - //item.setDef29(invoiceItem1); - } - if (nccodes != null && !nccodes.isEmpty()&&nccodes.size()>0) { - item.setDef29(nccodes.get(0)); - } - item.setTaxcodeid("ZL01"); - item.setInvoiceno(invoiceNumber); - ysitemList.add(item); + + if(make.getBillingAmount().compareTo(BigDecimal.ZERO)>0){ + Ysitem item=new Ysitem(); + if (deptValue != null && !deptValue.isEmpty()) { + item.setSo_deptid(deptValue); + } else { + item.setSo_deptid("NG0408"); + } + if (deptValue != null && !deptValue.isEmpty()) { + item.setPk_deptid(deptValue); + } else { + item.setPk_deptid("NG0408"); + } + //业务员nc + item.setPk_psndoc(salesmanCodeNc); + //客户nc + item.setCustomer(customerCodeNc); + item.setObjtype("0"); + item.setDirection("1"); + String invoiceItem = make.getInvoiceItem(); + List names = new ArrayList<>(); + List nccodes = new ArrayList<>(); + if (invoiceItem != null && !invoiceItem.isEmpty()) { + String[] items = invoiceItem.split(","); + for (String s : items) { + String invoiceItemName1 = billManageMapper.getInvoiceItemName(s); + String invoiceItemNcCode1 = billManageMapper.getInvoiceItemNcCode(s); + names.add(invoiceItemName1); + nccodes.add(invoiceItemNcCode1); } } + String invoiceItemName = String.join(",", names); + //item.setDef29(invoiceItemName); + if (deptName != null && !deptName.isEmpty()) { + item.setScomment(deptName+":应收"+appointShipper+invoiceItemName); + } else { + item.setScomment("业务部:应收"+appointShipper+invoiceItemName); + } + // item.setPk_currtype("CNY"); + item.setPk_currtype(settlementCurrencyNcCode); + item.setPurchaseorder(""); + item.setTaxrate(String.valueOf(make.getTaxRate())); + item.setQuantity_de("0"); + item.setMoney_de(String.valueOf(make.getBillingAmount())); + item.setMoney_bal(String.valueOf(make.getBillingAmount())); + BigDecimal tax_de=make.getTaxAmount(); + BigDecimal notax_de=make.getTaxFreeFee(); + item.setNotax_de(String.valueOf(notax_de)); + item.setLocal_tax_de(String.valueOf(tax_de)); + item.setTax_de(String.valueOf(tax_de)); + item.setPrice(String.valueOf(make.getBillingAmount())); + item.setTaxprice(String.valueOf(make.getBillingAmount())); +// 费用类别 + String feeType = make.getFeeType(); + String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); + if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { + item.setDef75(serviceItemsCodeNc); + } else { + item.setDef75("T04"); + } + String invoiceItem1 = make.getInvoiceItem(); + if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { + String[] split = invoiceItem1.split(","); + item.setDef29(split[0]); + //item.setDef29(invoiceItem1); + } + if (nccodes != null && !nccodes.isEmpty()&&nccodes.size()>0) { + item.setDef29(nccodes.get(0)); + } + item.setTaxcodeid("ZL01"); +// item.setInvoiceno(invoiceNumber); + ysitemList.add(item); } + + Ysbodys bodys=new Ysbodys(); bodys.setItem(ysitemList); Ysbillhead billhead=new Ysbillhead(); @@ -469,6 +487,298 @@ public class BillManageImpl extends ServiceImpl im return true; } + //按发票推送版本 +// public boolean synchronousNc_TY(String businessDocumentDetaliId) { +// BillManage reconciliation=billManageMapper.selectById(businessDocumentDetaliId); +// if(reconciliation.getSynchronousStatus()==1){ +// throw new ServiceException("该记录已同步,不需要再次同步"); +// } +// try { +// Date date = reconciliation.getCreateTime(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy"); +// SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); +// String dateString = sdf.format(date); +// String invoiceId = reconciliation.getInvoiceId(); +// List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); +// if (bmsMakeOutInvoices != null && bmsMakeOutInvoices.size() > 0){ +// int count = 0; +// for (BmsMakeOutInvoice make : bmsMakeOutInvoices) { +// count++; +// List ysitemList=new ArrayList(); +// String url = ""; +// Long organizationId = reconciliation.getOrganizationId(); +// String organizationName = reconciliation.getOrganizationName(); +// String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); +// if (ncUrl!=null&&ncUrl!="") { +// url = ncUrl; +// } else { +// reconciliation.setSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// throw new ServiceException("未找到该组织的推送地址!"); +// } +// String salesmanId = reconciliation.getSalesmanId(); +// String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); +// String deptValue = billManageMapper.getDeptValue(customerUserDept); +// String deptName = billManageMapper.getDeptName(customerUserDept); +// String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); +// String salesmanCodeNc=salespersonNcCode; +// String appointShipper=make.getActualInvoiceCustomerName(); +// String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); +// String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); +// String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); +// if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { +// ObjectMapper objectMapper = new ObjectMapper(); +// List> listNc = objectMapper.readValue( +// customerCodeNcJson, +// new TypeReference>>() {} +// ); +// if (listNc != null && listNc.size() > 0) { +// Map targetMap = listNc.stream() +// .filter(map -> { +// Object codeObj = map.get("code"); +// return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); +// }) +// .findFirst() +// .orElse(null); +// if (targetMap != null) { +// customerCodeNc = (String) targetMap.get("ncCustomer"); +// } +// } +// } +// String settlementCurrency=reconciliation.getSettlementCurrency(); +// String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); +// String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); +// String makerCodeNc = documentPreparerNcCode; +// String settlementCurrencyNcCode = settlementCurrency; +// String invoiceNumber=make.getInvoiceNumber(); +// List bmsMakeOutInvoiceItems = bmsMakeOutInvoiceItemMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoiceItem::getMakeId, make.getId())); +// if (bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0) { +// for (BmsMakeOutInvoiceItem item1 : bmsMakeOutInvoiceItems) { +// if(item1.getInvoiceValue().compareTo(BigDecimal.ZERO)>0){ +// Ysitem item=new Ysitem(); +// if (deptValue != null && !deptValue.isEmpty()) { +// item.setSo_deptid(deptValue); +// } else { +// item.setSo_deptid("NG0408"); +// } +// if (deptValue != null && !deptValue.isEmpty()) { +// item.setPk_deptid(deptValue); +// } else { +// item.setPk_deptid("NG0408"); +// } +// //业务员nc +// item.setPk_psndoc(salesmanCodeNc); +// //客户nc +// item.setCustomer(customerCodeNc); +// item.setObjtype("0"); +// item.setDirection("1"); +// String invoiceItem = item1.getInvoiceItem(); +// List names = new ArrayList<>(); +// List nccodes = new ArrayList<>(); +// if (invoiceItem != null && !invoiceItem.isEmpty()) { +// String[] items = invoiceItem.split(","); +// for (String s : items) { +// String invoiceItemName1 = billManageMapper.getInvoiceItemName(s); +// String invoiceItemNcCode1 = billManageMapper.getInvoiceItemNcCode(s); +// names.add(invoiceItemName1); +// nccodes.add(invoiceItemNcCode1); +// } +// } +// String invoiceItemName = String.join(",", names); +// //item.setDef29(invoiceItemName); +// if (deptName != null && !deptName.isEmpty()) { +// item.setScomment(deptName+":应收"+appointShipper+invoiceItemName+invoiceNumber); +// } else { +// item.setScomment("业务部:应收"+appointShipper+invoiceItemName+invoiceNumber); +// } +// // item.setPk_currtype("CNY"); +// item.setPk_currtype(settlementCurrencyNcCode); +// item.setPurchaseorder(""); +// item.setTaxrate(String.valueOf(item1.getTaxRate())); +// item.setQuantity_de("0"); +// item.setMoney_de(String.valueOf(item1.getInvoiceValue())); +// item.setMoney_bal(String.valueOf(item1.getInvoiceValue())); +// BigDecimal tax_de=item1.getTaxAmount(); +// BigDecimal notax_de=item1.getTaxFreeFee(); +// item.setNotax_de(String.valueOf(notax_de)); +// item.setLocal_tax_de(String.valueOf(tax_de)); +// item.setTax_de(String.valueOf(tax_de)); +// item.setPrice(String.valueOf(item1.getInvoiceValue())); +// item.setTaxprice(String.valueOf(item1.getInvoiceValue())); +//// 费用类别 +// String feeType = item1.getFeeType(); +// String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); +// if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { +// item.setDef75(serviceItemsCodeNc); +// } else { +// item.setDef75("T04"); +// } +// String invoiceItem1 = item1.getInvoiceItem(); +// if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { +// String[] split = invoiceItem1.split(","); +// item.setDef29(split[0]); +// //item.setDef29(invoiceItem1); +// } +// if (nccodes != null && !nccodes.isEmpty()&&nccodes.size()>0) { +// item.setDef29(nccodes.get(0)); +// } +// item.setTaxcodeid("ZL01"); +// item.setInvoiceno(invoiceNumber); +// ysitemList.add(item); +// } +// } +// } +// +// Ysbodys bodys=new Ysbodys(); +// bodys.setItem(ysitemList); +// Ysbillhead billhead=new Ysbillhead(); +// billhead.setPk_group("CNK"); +// if (orgCodeNc != null && !orgCodeNc.isEmpty()) { +// billhead.setPk_org(orgCodeNc); +// billhead.setSett_org(orgCodeNc); +// } else { +// billhead.setPk_org("NG04"); +// billhead.setSett_org("NG04"); +// } +// billhead.setCreationtime(dateString); +// billhead.setCreator(makerCodeNc); +// billhead.setPk_billtype("F0"); +// billhead.setPk_tradetype("D0"); +// billhead.setBillclass("ys"); +// billhead.setIsinit("N"); +// date=reconciliation.getCreateTime(); +// dateString = sdf.format(date); +// billhead.setBilldate(dateString); +// billhead.setSyscode("0"); +// billhead.setBillno(""); +// billhead.setDef59(""); +// billhead.setSrc_syscode("0"); +// billhead.setBillstatus("0"); +// billhead.setBillmaker(makerCodeNc); +// billhead.setPk_busitype(""); +// billhead.setBillyear(sdf1.format(date)); +// billhead.setBillperiod(sdf2.format(date)); +// billhead.setEffectstatus("0"); +// billhead.setDef28("nqyw"); +// billhead.setDef29(reconciliation.getBillNumber()); +// billhead.setBodys(bodys); +// Ysbill bill=new Ysbill(); +// bill.setId("ys"+String.valueOf(reconciliation.getBillManageId())+"_"+count); +// bill.setBillhead(billhead); +// Ysufinterface ufinterface=new Ysufinterface(); +// ufinterface.setAccount("NKNC"); +// ufinterface.setBilltype("F0"); +// ufinterface.setBusinessunitcode(""); +// ufinterface.setFilename(""); +// ufinterface.setIsexchange("Y"); +// if (orgCodeNc != null && !orgCodeNc.isEmpty()) { +// ufinterface.setOrgcode(orgCodeNc); +// ufinterface.setReceiver(orgCodeNc); +// } else { +// ufinterface.setOrgcode("NG04"); +// ufinterface.setReceiver("NG04"); +// } +// ufinterface.setReplace("Y"); +// ufinterface.setRoottag(""); +// ufinterface.setSender("nqyw"); +// ufinterface.setBill(bill); +// JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class); +// Marshaller marshaller = jaxbContext.createMarshaller(); +// marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); +// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 +// StringWriter sw = new StringWriter(); +// marshaller.marshal(ufinterface, sw); +// String xmlString = sw.toString(); // 这是要发送的XML字符串 +// System.out.println(xmlString); +// NcLog ncLog=new NcLog(); +// ncLog.setOrderId(reconciliation.getBillManageId()); +// ncLog.setRequestBody(xmlString); +// ncLog.setResponeBody(""); +// ncLog.setType(0L); +// ncLog.setSendTime(new Date()); +// ncLog.setOrganizationId(reconciliation.getOrganizationId()); +// ncLog.setOrganizationName(reconciliation.getOrganizationName()); +// ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); +// ncLogMapper.insert(ncLog); +// reconciliation.setSynchronousStatus(1); +// reconciliation.setSynchronousTime(new Date()); +// reconciliation.setNcId("ys"+String.valueOf(reconciliation.getBillManageId())); +// //reconciliationMapper.updateById(reconciliation); +// CloseableHttpClient httpClient = HttpClients.createDefault(); +// HttpPost httpPost = new HttpPost(url); +// StringEntity postingString = new StringEntity(xmlString, "UTF-8"); +// httpPost.setEntity(postingString); +// httpPost.setHeader("Content-type", "application/xml"); +// try { +// CloseableHttpResponse response = httpClient.execute(httpPost); +// String responseString = EntityUtils.toString(response.getEntity()); +// System.out.println(responseString); +// ncLog.setResponeBody(responseString); +// // 创建DOM解析器 +// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); +// DocumentBuilder builder = factory.newDocumentBuilder(); +// Document document = builder.parse(new InputSource(new StringReader(responseString))); +// +// // 获取根元素 +// Element root = document.getDocumentElement(); +// +// // 获取ufinterface元素的属性 +// String billtype = root.getAttribute("billtype"); +// String filename = root.getAttribute("filename"); +// System.out.println("billtype: " + billtype); +// System.out.println("filename: " + filename); +// +// // 获取sendresult节点 +// NodeList sendResultList = root.getElementsByTagName("sendresult"); +// if (sendResultList.getLength() > 0) { +// Element sendResult = (Element) sendResultList.item(0); +// +// // 获取子元素内容 +// String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); +// String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); +// String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); +// +// System.out.println("bdocid: " + bdocid); +// System.out.println("resultcode: " + resultcode); +// System.out.println("content: " + content); +// if(resultcode.equals("1")){ +// reconciliation.setSynchronousStatus(1); +// }else{ +// reconciliation.setSynchronousStatus(2); +// } +// } +// ncLogMapper.updateById(ncLog); +// billManageMapper.updateById(reconciliation); +// response.close(); +// } catch (Exception e) { +// reconciliation.setSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// e.printStackTrace(); +// } finally { +// try { +// httpClient.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// } else { +// reconciliation.setSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// } +// } catch (JAXBException e) { +// reconciliation.setSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// e.printStackTrace(); +// } catch (JsonMappingException e) { +// throw new RuntimeException(e); +// } catch (JsonProcessingException e) { +// throw new RuntimeException(e); +// } +// return true; +// } + @Override public boolean synchronousNcSK(String businessDocumentDetaliIds) { String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(","); @@ -778,6 +1088,297 @@ public class BillManageImpl extends ServiceImpl im } return true; } + + //按发票推送版本 +// public boolean synchronousNcSK_TY(String businessDocumentDetaliId) { +// BillManage reconciliation=billManageMapper.selectById(businessDocumentDetaliId); +// if(reconciliation.getSkSynchronousStatus()==1){ +// throw new ServiceException("该记录已同步,不需要再次同步"); +// } +// try { +// Date date = reconciliation.getCreateTime(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy"); +// SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); +// String dateString = sdf.format(date); +// String invoiceId = reconciliation.getInvoiceId(); +// ReconciliationDTO makeQuery=new ReconciliationDTO(); +// makeQuery.setInnerNumber(invoiceId); +// List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); +// if (bmsMakeOutInvoices != null && bmsMakeOutInvoices.size() > 0) { +// int count= 0; +// for (BmsMakeOutInvoice make : bmsMakeOutInvoices) { +// count++; +// List ysitemList=new ArrayList(); +// ReconciliationDTO reconciliationDTO=new ReconciliationDTO(); +// reconciliationDTO.setInnerNumber(reconciliation.getBillNumber()); +// String url = ""; +// Long organizationId = reconciliation.getOrganizationId(); +// String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); +// String organizationName = reconciliation.getOrganizationName(); +// String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); +// if (ncUrl!=null&&ncUrl!="") { +// url = ncUrl; +// } else { +// reconciliation.setSkSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// throw new ServiceException("未找到该组织的推送地址!"); +// } +// List bmsMakeOutInvoiceItems = bmsMakeOutInvoiceItemMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoiceItem::getMakeId, make.getId())); +// String makerCodeNc = ""; +// if(bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0){ +// if(ObjectUtil.isNotNull(bmsMakeOutInvoiceItems)){ +// // 汇总 list 中 invoiceValue 的总值 +// BigDecimal totalInvoiceValue = bmsMakeOutInvoiceItems.stream() +// .map(BmsMakeOutInvoiceItem::getInvoiceValue) +// .filter(java.util.Objects::nonNull) +// .reduce(BigDecimal.ZERO, BigDecimal::add); +// +// // 将 feeType 用、拼接起来 +// String feeTypes = bmsMakeOutInvoiceItems.stream() +// .map(BmsMakeOutInvoiceItem::getFeeType) +// .filter(java.util.Objects::nonNull) +// .collect(java.util.stream.Collectors.joining("、")); +// +// // 按 createTime 倒序排序并获取第一条记录 +// BmsMakeOutInvoiceItem firstItem = bmsMakeOutInvoiceItems.stream() +// .sorted((a, b) -> { +// if (a.getCreateTime() == null) return 1; +// if (b.getCreateTime() == null) return -1; +// return b.getCreateTime().compareTo(a.getCreateTime()); +// }) +// .findFirst() +// .orElse(null); +// String salesmanId = reconciliation.getSalesmanId(); +// String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); +// String deptValue = billManageMapper.getDeptValue(customerUserDept); +// String deptName = billManageMapper.getDeptName(customerUserDept); +// String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); +// String salesmanCodeNc=salespersonNcCode; +// String appointShipper=make.getActualInvoiceCustomerName(); +// String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); +// String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); +// String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); +// if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { +// ObjectMapper objectMapper = new ObjectMapper(); +// List> listNc = objectMapper.readValue( +// customerCodeNcJson, +// new TypeReference>>() {} +// ); +// if (listNc != null && listNc.size() > 0) { +// Map targetMap = listNc.stream() +// .filter(map -> { +// Object codeObj = map.get("code"); +// return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); +// }) +// .findFirst() +// .orElse(null); +// if (targetMap != null) { +// customerCodeNc = (String) targetMap.get("ncCustomer"); +// } +// } +// } +// String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); +// String settlementCurrency=reconciliation.getSettlementCurrency(); +// String settlementCurrencyNcCode = settlementCurrency; +// makerCodeNc=documentPreparerNcCode; +// SKitem item=new SKitem(); +// if (deptValue != null && !deptValue.isEmpty()) { +// item.setSo_deptid(deptValue); +// } else { +// item.setSo_deptid("NG0408"); +// } +// if (deptValue != null && !deptValue.isEmpty()) { +// item.setPk_deptid(deptValue); +// } else { +// item.setPk_deptid("NG0408"); +// } +// item.setCheckdirection("ar"); +// item.setPk_psndoc(salesmanCodeNc); +// item.setCustomer(customerCodeNc); +// item.setPurchaseorder(""); +// item.setObjtype("0"); +// item.setDirection("1"); +// if (deptName != null && !deptName.isEmpty()) { +// if (feeTypes != null && !feeTypes.isEmpty()) { +// item.setScomment(deptName+":"+appointShipper+feeTypes); +// } else { +// item.setScomment(deptName+":"+appointShipper+feeTypes); +// } +// } else { +// if (feeTypes != null && !feeTypes.isEmpty()) { +// item.setScomment("业务部:"+appointShipper+feeTypes); +// } else { +// item.setScomment("业务部:"+appointShipper+feeTypes); +// } +// } +// // 费用类别 +// String feeType = firstItem.getFeeType(); +// String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); +// if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { +// item.setDef75(serviceItemsCodeNc); +// } else { +// item.setDef75("T10"); +// } +// String invoiceItem1 = firstItem.getInvoiceItem(); +// if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { +// String[] split = invoiceItem1.split(","); +// item.setDef29(split[0]); +// } +// item.setPk_currtype(settlementCurrencyNcCode); +// item.setMoney_cr(String.valueOf(totalInvoiceValue)); +// item.setMoney_bal(String.valueOf(totalInvoiceValue)); +// ysitemList.add(item); +// } +// } +// SKbodys bodys=new SKbodys(); +// bodys.setItem(ysitemList); +// SKbillhead billhead=new SKbillhead(); +// billhead.setPk_group("CNK"); +// if (orgCodeNc != null && !orgCodeNc.isEmpty()) { +// billhead.setPk_org(orgCodeNc); +// billhead.setSett_org(orgCodeNc); +// } else { +// billhead.setPk_org("NG04"); +// billhead.setSett_org("NG04"); +// } +// billhead.setCreationtime(dateString); +// billhead.setPk_billtype("F2"); +// billhead.setCreator(makerCodeNc); +// billhead.setPk_tradetype("D2"); +// billhead.setBillclass("sk"); +// billhead.setBilldate(dateString); +// billhead.setSyscode("0"); +// billhead.setBillno(""); +// billhead.setDef59(""); +// billhead.setSrc_syscode("0"); +// billhead.setBillstatus("0"); +// billhead.setBillmaker(makerCodeNc); +// billhead.setPk_busitype(""); +// billhead.setBillyear(sdf1.format(date)); +// billhead.setBillperiod(sdf2.format(date)); +// billhead.setEffectstatus("0"); +// billhead.setDef28("nqyw"); +// billhead.setDef29(reconciliation.getBillNumber()); +// billhead.setBodys(bodys); +// SKbill bill=new SKbill(); +// bill.setId("sk"+String.valueOf(reconciliation.getBillManageId())+"_"+count); +// bill.setBillhead(billhead); +// SKufinterface ufinterface=new SKufinterface(); +// ufinterface.setAccount("NKNC"); +// ufinterface.setBilltype("F2"); +// ufinterface.setBusinessunitcode(""); +// ufinterface.setFilename(""); +// ufinterface.setIsexchange("Y"); +// if (orgCodeNc != null && !orgCodeNc.isEmpty()) { +// ufinterface.setOrgcode(orgCodeNc); +// ufinterface.setReceiver(orgCodeNc); +// } else { +// ufinterface.setOrgcode("NG04"); +// ufinterface.setReceiver("NG04"); +// } +// ufinterface.setReplace("Y"); +// ufinterface.setRoottag(""); +// ufinterface.setSender("nqyw"); +// ufinterface.setBill(bill); +// JAXBContext jaxbContext = null; +// //String xmlString =""; +// jaxbContext = JAXBContext.newInstance(SKufinterface.class); +// Marshaller marshaller = jaxbContext.createMarshaller(); +// marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); +// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 +// StringWriter sw = new StringWriter(); +// marshaller.marshal(ufinterface, sw); +// String xmlString = sw.toString(); // 这是要发送的XML字符串 +// System.out.println(xmlString); +// NcLog ncLog=new NcLog(); +// ncLog.setOrderId(reconciliation.getBillManageId()); +// ncLog.setRequestBody(xmlString); +// ncLog.setResponeBody(""); +// ncLog.setType(1L); +// ncLog.setSendTime(new Date()); +// ncLog.setOrganizationId(reconciliation.getOrganizationId()); +// ncLog.setOrganizationName(reconciliation.getOrganizationName()); +// ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); +// ncLogMapper.insert(ncLog); +// reconciliation.setSkSynchronousStatus(1); +// reconciliation.setSkSynchronousTime(new Date()); +// reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getBillManageId())); +// //reconciliationMapper.updateById(reconciliation); +// CloseableHttpClient httpClient = HttpClients.createDefault(); +// HttpPost httpPost = new HttpPost(url); +// StringEntity postingString = new StringEntity(xmlString, "UTF-8"); +// httpPost.setEntity(postingString); +// httpPost.setHeader("Content-type", "application/xml"); +// try { +// CloseableHttpResponse response = httpClient.execute(httpPost); +// String responseString = EntityUtils.toString(response.getEntity()); +// System.out.println(responseString); +// ncLog.setResponeBody(responseString); +// // 创建DOM解析器 +// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); +// DocumentBuilder builder = factory.newDocumentBuilder(); +// Document document = builder.parse(new InputSource(new StringReader(responseString))); +// +// // 获取根元素 +// Element root = document.getDocumentElement(); +// +// // 获取ufinterface元素的属性 +// String billtype = root.getAttribute("billtype"); +// String filename = root.getAttribute("filename"); +// System.out.println("billtype: " + billtype); +// System.out.println("filename: " + filename); +// +// // 获取sendresult节点 +// NodeList sendResultList = root.getElementsByTagName("sendresult"); +// if (sendResultList.getLength() > 0) { +// Element sendResult = (Element) sendResultList.item(0); +// +// // 获取子元素内容 +// String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); +// String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); +// String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); +// +// System.out.println("bdocid: " + bdocid); +// System.out.println("resultcode: " + resultcode); +// System.out.println("content: " + content); +// if(resultcode.equals("1")){ +// reconciliation.setSkSynchronousStatus(1); +// }else{ +// reconciliation.setSkSynchronousStatus(2); +// } +// } +// ncLogMapper.updateById(ncLog); +// billManageMapper.updateById(reconciliation); +// response.close(); +// } catch (Exception e) { +// reconciliation.setSkSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// e.printStackTrace(); +// } finally { +// try { +// httpClient.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// +// } +// } else { +// reconciliation.setSkSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// } +// } catch (JAXBException e) { +// reconciliation.setSkSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// e.printStackTrace(); +// } catch (JsonMappingException e) { +// throw new RuntimeException(e); +// } catch (JsonProcessingException e) { +// throw new RuntimeException(e); +// } +// return true; +// } @Override diff --git a/mhd_bms/src/main/resources/mapper/BillManageMapper.xml b/mhd_bms/src/main/resources/mapper/BillManageMapper.xml index 6be84c7ad..398e298ce 100644 --- a/mhd_bms/src/main/resources/mapper/BillManageMapper.xml +++ b/mhd_bms/src/main/resources/mapper/BillManageMapper.xml @@ -162,4 +162,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT NC_CODE FROM NGWL_TEST_PRODUCT."SYS_ORGANIZATION" where DEL_FLAG = 1 and organization_id = #{organizationId} limit 1 + + \ No newline at end of file From 914a751d965d1a310f48df50905f5512be53deff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Thu, 23 Jul 2026 17:46:32 +0800 Subject: [PATCH 02/13] =?UTF-8?q?bms2.0=E5=BA=94=E6=94=B6=E5=8D=95?= =?UTF-8?q?=E5=92=8C=E6=94=B6=E6=AC=BE=E5=8D=95=E6=8E=A8=E9=80=81nc?= =?UTF-8?q?=E4=BF=AE=E6=94=B9;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/facade/IBillDetailService.java | 4 +- .../repository/mapper/BillDetailMapper.java | 4 +- .../persistence/BillDetailImpl.java | 7 +- .../persistence/BillManageImpl.java | 927 +++++++++--------- .../resources/mapper/BillDetailMapper.xml | 22 +- 5 files changed, 491 insertions(+), 473 deletions(-) diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/facade/IBillDetailService.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/facade/IBillDetailService.java index f2cbe3d43..192395468 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/facade/IBillDetailService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/facade/IBillDetailService.java @@ -38,4 +38,6 @@ public interface IBillDetailService extends IService public BillDetailPO getInfo(Long billDetailId); List getDetailsByBillManageId(Long billManageId); -} + + List getDetailsByBillManageIdAndGroup(Long billManageId); +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java index 1ea7709f4..b8fcdd9c5 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java @@ -17,4 +17,6 @@ public interface BillDetailMapper extends BaseMapper { List getDetailsByBillManageId(@Param("billManageId") Long billManageId); -} + + List getDetailsByBillManageIdAndGroup(@Param("billManageId") Long billManageId); +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillDetailImpl.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillDetailImpl.java index cf62504d6..2aa419a1f 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillDetailImpl.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillDetailImpl.java @@ -75,4 +75,9 @@ public class BillDetailImpl extends ServiceImpl im public List getDetailsByBillManageId(Long billManageId) { return billDetailMapper.getDetailsByBillManageId(billManageId); } -} + + @Override + public List getDetailsByBillManageIdAndGroup(Long billManageId) { + return billDetailMapper.getDetailsByBillManageIdAndGroup(billManageId); + } +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java index 01fa77070..17872b7f1 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java @@ -197,72 +197,68 @@ public class BillManageImpl extends ServiceImpl im SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); String dateString = sdf.format(date); String invoiceId = reconciliation.getInvoiceId(); -// List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); - List billDetails = billDetailService.list(new LambdaQueryWrapper() - .eq(BillDetail::getBillManageId, businessDocumentDetaliId) - .eq(BillDetail::getDelFlag, 1)); - if (billDetails!=null && billDetails.size()>0){ - int count = 0; + List billDetails = billDetailService.getDetailsByBillManageIdAndGroup(Long.parseLong(businessDocumentDetaliId)); + + List ysitemList=new ArrayList(); + String url = ""; + Long organizationId = reconciliation.getOrganizationId(); + String organizationName = reconciliation.getOrganizationName(); + String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); + if (ncUrl!=null&&ncUrl!="") { + url = ncUrl; + } else { + reconciliation.setSynchronousStatus(2); + billManageMapper.updateById(reconciliation); + throw new ServiceException("未找到该组织的推送地址!"); + } + String salesmanId = reconciliation.getSalesmanId(); + String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); + String deptValue = billManageMapper.getDeptValue(customerUserDept); + String deptName = billManageMapper.getDeptName(customerUserDept); + String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); + String salesmanCodeNc=salespersonNcCode; + + Long settlementCustomersId = reconciliation.getSettlementCustomersId(); + SettlementCustomers settlementCustomers = settlementCustomersService.getById(settlementCustomersId); + if (settlementCustomers==null){ + throw new ServiceException("结算对象未找到!"); + } + Long settlementEntityId = settlementCustomers.getSettlementEntityId(); + Long shipperId = billManageMapper.getShipperId(settlementEntityId, organizationId); + if (shipperId==null||shipperId==0){ + throw new ServiceException("结算对象未找到!"); + } + String appointShipper=settlementCustomers.getSettlementEntity(); + String actualInvoiceCustomerId = String.valueOf(shipperId); + String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); + String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); + if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { + ObjectMapper objectMapper = new ObjectMapper(); + List> listNc = objectMapper.readValue( + customerCodeNcJson, + new TypeReference>>() {} + ); + if (listNc != null && listNc.size() > 0) { + Map targetMap = listNc.stream() + .filter(map -> { + Object codeObj = map.get("code"); + return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); + }) + .findFirst() + .orElse(null); + if (targetMap != null) { + customerCodeNc = (String) targetMap.get("ncCustomer"); + } + } + } + String settlementCurrency=reconciliation.getSettlementCurrency(); + String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); + String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); + String makerCodeNc = documentPreparerNcCode; + String settlementCurrencyNcCode = settlementCurrency; + + if (billDetails!=null&&billDetails.size()>0){ for (BillDetail make : billDetails) { - count++; - List ysitemList=new ArrayList(); - String url = ""; - Long organizationId = reconciliation.getOrganizationId(); - String organizationName = reconciliation.getOrganizationName(); - String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); - if (ncUrl!=null&&ncUrl!="") { - url = ncUrl; - } else { - reconciliation.setSynchronousStatus(2); - billManageMapper.updateById(reconciliation); - throw new ServiceException("未找到该组织的推送地址!"); - } - String salesmanId = reconciliation.getSalesmanId(); - String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); - String deptValue = billManageMapper.getDeptValue(customerUserDept); - String deptName = billManageMapper.getDeptName(customerUserDept); - String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); - String salesmanCodeNc=salespersonNcCode; - - Long settlementCustomersId = reconciliation.getSettlementCustomersId(); - SettlementCustomers settlementCustomers = settlementCustomersService.getById(settlementCustomersId); - if (settlementCustomers==null){ - throw new ServiceException("结算对象未找到!"); - } - Long settlementEntityId = settlementCustomers.getSettlementEntityId(); - Long shipperId = billManageMapper.getShipperId(settlementEntityId, organizationId); - if (shipperId==null||shipperId==0){ - throw new ServiceException("结算对象未找到!"); - } - String appointShipper=settlementCustomers.getSettlementEntity(); - String actualInvoiceCustomerId = String.valueOf(shipperId); - String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); - String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); - if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { - ObjectMapper objectMapper = new ObjectMapper(); - List> listNc = objectMapper.readValue( - customerCodeNcJson, - new TypeReference>>() {} - ); - if (listNc != null && listNc.size() > 0) { - Map targetMap = listNc.stream() - .filter(map -> { - Object codeObj = map.get("code"); - return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); - }) - .findFirst() - .orElse(null); - if (targetMap != null) { - customerCodeNc = (String) targetMap.get("ncCustomer"); - } - } - } - String settlementCurrency=reconciliation.getSettlementCurrency(); - String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); - String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); - String makerCodeNc = documentPreparerNcCode; - String settlementCurrencyNcCode = settlementCurrency; - if(make.getBillingAmount().compareTo(BigDecimal.ZERO)>0){ Ysitem item=new Ysitem(); if (deptValue != null && !deptValue.isEmpty()) { @@ -285,22 +281,18 @@ public class BillManageImpl extends ServiceImpl im List names = new ArrayList<>(); List nccodes = new ArrayList<>(); if (invoiceItem != null && !invoiceItem.isEmpty()) { - String[] items = invoiceItem.split(","); - for (String s : items) { - String invoiceItemName1 = billManageMapper.getInvoiceItemName(s); - String invoiceItemNcCode1 = billManageMapper.getInvoiceItemNcCode(s); - names.add(invoiceItemName1); - nccodes.add(invoiceItemNcCode1); - } + String invoiceItemName1 = billManageMapper.getInvoiceItemName(invoiceItem); + String invoiceItemNcCode1 = billManageMapper.getInvoiceItemNcCode(invoiceItem); + names.add(invoiceItemName1); + nccodes.add(invoiceItemNcCode1); } - String invoiceItemName = String.join(",", names); + String invoiceItemName = make.getInvoiceItemName(); //item.setDef29(invoiceItemName); if (deptName != null && !deptName.isEmpty()) { item.setScomment(deptName+":应收"+appointShipper+invoiceItemName); } else { item.setScomment("业务部:应收"+appointShipper+invoiceItemName); } - // item.setPk_currtype("CNY"); item.setPk_currtype(settlementCurrencyNcCode); item.setPurchaseorder(""); item.setTaxrate(String.valueOf(make.getTaxRate())); @@ -314,7 +306,7 @@ public class BillManageImpl extends ServiceImpl im item.setTax_de(String.valueOf(tax_de)); item.setPrice(String.valueOf(make.getBillingAmount())); item.setTaxprice(String.valueOf(make.getBillingAmount())); -// 费用类别 + //费用类别 String feeType = make.getFeeType(); String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { @@ -324,157 +316,152 @@ public class BillManageImpl extends ServiceImpl im } String invoiceItem1 = make.getInvoiceItem(); if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { - String[] split = invoiceItem1.split(","); - item.setDef29(split[0]); - //item.setDef29(invoiceItem1); + item.setDef29(invoiceItem1); } if (nccodes != null && !nccodes.isEmpty()&&nccodes.size()>0) { item.setDef29(nccodes.get(0)); } item.setTaxcodeid("ZL01"); -// item.setInvoiceno(invoiceNumber); + item.setInvoiceno(""); ysitemList.add(item); } + } + } + Ysbodys bodys=new Ysbodys(); + bodys.setItem(ysitemList); + Ysbillhead billhead=new Ysbillhead(); + billhead.setPk_group("CNK"); + if (orgCodeNc != null && !orgCodeNc.isEmpty()) { + billhead.setPk_org(orgCodeNc); + billhead.setSett_org(orgCodeNc); + } else { + billhead.setPk_org("NG04"); + billhead.setSett_org("NG04"); + } + billhead.setCreationtime(dateString); + billhead.setCreator(makerCodeNc); + billhead.setPk_billtype("F0"); + billhead.setPk_tradetype("D0"); + billhead.setBillclass("ys"); + billhead.setIsinit("N"); + date=reconciliation.getCreateTime(); + dateString = sdf.format(date); + billhead.setBilldate(dateString); + billhead.setSyscode("0"); + billhead.setBillno(""); + billhead.setDef59(""); + billhead.setSrc_syscode("0"); + billhead.setBillstatus("0"); + billhead.setBillmaker(makerCodeNc); + billhead.setPk_busitype(""); + billhead.setBillyear(sdf1.format(date)); + billhead.setBillperiod(sdf2.format(date)); + billhead.setEffectstatus("0"); + billhead.setDef28("nqyw"); + billhead.setDef29(reconciliation.getBillNumber()); + billhead.setBodys(bodys); + Ysbill bill=new Ysbill(); + bill.setId("ys"+String.valueOf(reconciliation.getBillManageId())+"_"+1); + bill.setBillhead(billhead); + Ysufinterface ufinterface=new Ysufinterface(); + ufinterface.setAccount("NKNC"); + ufinterface.setBilltype("F0"); + ufinterface.setBusinessunitcode(""); + ufinterface.setFilename(""); + ufinterface.setIsexchange("Y"); + if (orgCodeNc != null && !orgCodeNc.isEmpty()) { + ufinterface.setOrgcode(orgCodeNc); + ufinterface.setReceiver(orgCodeNc); + } else { + ufinterface.setOrgcode("NG04"); + ufinterface.setReceiver("NG04"); + } + ufinterface.setReplace("Y"); + ufinterface.setRoottag(""); + ufinterface.setSender("nqyw"); + ufinterface.setBill(bill); + JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 + StringWriter sw = new StringWriter(); + marshaller.marshal(ufinterface, sw); + String xmlString = sw.toString(); // 这是要发送的XML字符串 + System.out.println(xmlString); + NcLog ncLog=new NcLog(); + ncLog.setOrderId(reconciliation.getBillManageId()); + ncLog.setRequestBody(xmlString); + ncLog.setResponeBody(""); + ncLog.setType(0L); + ncLog.setSendTime(new Date()); + ncLog.setOrganizationId(reconciliation.getOrganizationId()); + ncLog.setOrganizationName(reconciliation.getOrganizationName()); + ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); + ncLogMapper.insert(ncLog); + reconciliation.setSynchronousStatus(1); + reconciliation.setSynchronousTime(new Date()); + reconciliation.setNcId("ys"+String.valueOf(reconciliation.getBillManageId())); + //reconciliationMapper.updateById(reconciliation); + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + StringEntity postingString = new StringEntity(xmlString, "UTF-8"); + httpPost.setEntity(postingString); + httpPost.setHeader("Content-type", "application/xml"); + try { + CloseableHttpResponse response = httpClient.execute(httpPost); + String responseString = EntityUtils.toString(response.getEntity()); + System.out.println(responseString); + ncLog.setResponeBody(responseString); + // 创建DOM解析器 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document document = builder.parse(new InputSource(new StringReader(responseString))); + // 获取根元素 + Element root = document.getDocumentElement(); - Ysbodys bodys=new Ysbodys(); - bodys.setItem(ysitemList); - Ysbillhead billhead=new Ysbillhead(); - billhead.setPk_group("CNK"); - if (orgCodeNc != null && !orgCodeNc.isEmpty()) { - billhead.setPk_org(orgCodeNc); - billhead.setSett_org(orgCodeNc); - } else { - billhead.setPk_org("NG04"); - billhead.setSett_org("NG04"); - } - billhead.setCreationtime(dateString); - billhead.setCreator(makerCodeNc); - billhead.setPk_billtype("F0"); - billhead.setPk_tradetype("D0"); - billhead.setBillclass("ys"); - billhead.setIsinit("N"); - date=reconciliation.getCreateTime(); - dateString = sdf.format(date); - billhead.setBilldate(dateString); - billhead.setSyscode("0"); - billhead.setBillno(""); - billhead.setDef59(""); - billhead.setSrc_syscode("0"); - billhead.setBillstatus("0"); - billhead.setBillmaker(makerCodeNc); - billhead.setPk_busitype(""); - billhead.setBillyear(sdf1.format(date)); - billhead.setBillperiod(sdf2.format(date)); - billhead.setEffectstatus("0"); - billhead.setDef28("nqyw"); - billhead.setDef29(reconciliation.getBillNumber()); - billhead.setBodys(bodys); - Ysbill bill=new Ysbill(); - bill.setId("ys"+String.valueOf(reconciliation.getBillManageId())+"_"+count); - bill.setBillhead(billhead); - Ysufinterface ufinterface=new Ysufinterface(); - ufinterface.setAccount("NKNC"); - ufinterface.setBilltype("F0"); - ufinterface.setBusinessunitcode(""); - ufinterface.setFilename(""); - ufinterface.setIsexchange("Y"); - if (orgCodeNc != null && !orgCodeNc.isEmpty()) { - ufinterface.setOrgcode(orgCodeNc); - ufinterface.setReceiver(orgCodeNc); - } else { - ufinterface.setOrgcode("NG04"); - ufinterface.setReceiver("NG04"); - } - ufinterface.setReplace("Y"); - ufinterface.setRoottag(""); - ufinterface.setSender("nqyw"); - ufinterface.setBill(bill); - JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class); - Marshaller marshaller = jaxbContext.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 - StringWriter sw = new StringWriter(); - marshaller.marshal(ufinterface, sw); - String xmlString = sw.toString(); // 这是要发送的XML字符串 - System.out.println(xmlString); - NcLog ncLog=new NcLog(); - ncLog.setOrderId(reconciliation.getBillManageId()); - ncLog.setRequestBody(xmlString); - ncLog.setResponeBody(""); - ncLog.setType(0L); - ncLog.setSendTime(new Date()); - ncLog.setOrganizationId(reconciliation.getOrganizationId()); - ncLog.setOrganizationName(reconciliation.getOrganizationName()); - ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); - ncLogMapper.insert(ncLog); - reconciliation.setSynchronousStatus(1); - reconciliation.setSynchronousTime(new Date()); - reconciliation.setNcId("ys"+String.valueOf(reconciliation.getBillManageId())); - //reconciliationMapper.updateById(reconciliation); - CloseableHttpClient httpClient = HttpClients.createDefault(); - HttpPost httpPost = new HttpPost(url); - StringEntity postingString = new StringEntity(xmlString, "UTF-8"); - httpPost.setEntity(postingString); - httpPost.setHeader("Content-type", "application/xml"); - try { - CloseableHttpResponse response = httpClient.execute(httpPost); - String responseString = EntityUtils.toString(response.getEntity()); - System.out.println(responseString); - ncLog.setResponeBody(responseString); - // 创建DOM解析器 - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document document = builder.parse(new InputSource(new StringReader(responseString))); + // 获取ufinterface元素的属性 + String billtype = root.getAttribute("billtype"); + String filename = root.getAttribute("filename"); + System.out.println("billtype: " + billtype); + System.out.println("filename: " + filename); - // 获取根元素 - Element root = document.getDocumentElement(); + // 获取sendresult节点 + NodeList sendResultList = root.getElementsByTagName("sendresult"); + if (sendResultList.getLength() > 0) { + Element sendResult = (Element) sendResultList.item(0); - // 获取ufinterface元素的属性 - String billtype = root.getAttribute("billtype"); - String filename = root.getAttribute("filename"); - System.out.println("billtype: " + billtype); - System.out.println("filename: " + filename); + // 获取子元素内容 + String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); + String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); + String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); - // 获取sendresult节点 - NodeList sendResultList = root.getElementsByTagName("sendresult"); - if (sendResultList.getLength() > 0) { - Element sendResult = (Element) sendResultList.item(0); - - // 获取子元素内容 - String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); - String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); - String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); - - System.out.println("bdocid: " + bdocid); - System.out.println("resultcode: " + resultcode); - System.out.println("content: " + content); - if(resultcode.equals("1")){ - reconciliation.setSynchronousStatus(1); - }else{ - reconciliation.setSynchronousStatus(2); - } - } - ncLogMapper.updateById(ncLog); - billManageMapper.updateById(reconciliation); - response.close(); - } catch (Exception e) { + System.out.println("bdocid: " + bdocid); + System.out.println("resultcode: " + resultcode); + System.out.println("content: " + content); + if(resultcode.equals("1")){ + reconciliation.setSynchronousStatus(1); + }else{ reconciliation.setSynchronousStatus(2); - billManageMapper.updateById(reconciliation); - e.printStackTrace(); - } finally { - try { - httpClient.close(); - } catch (IOException e) { - e.printStackTrace(); - } } } - } else { + ncLogMapper.updateById(ncLog); + billManageMapper.updateById(reconciliation); + response.close(); + } catch (Exception e) { reconciliation.setSynchronousStatus(2); billManageMapper.updateById(reconciliation); + e.printStackTrace(); + } finally { + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } } + + } catch (JAXBException e) { reconciliation.setSynchronousStatus(2); billManageMapper.updateById(reconciliation); @@ -810,273 +797,275 @@ public class BillManageImpl extends ServiceImpl im SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); String dateString = sdf.format(date); - String invoiceId = reconciliation.getInvoiceId(); - ReconciliationDTO makeQuery=new ReconciliationDTO(); - makeQuery.setInnerNumber(invoiceId); - List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); - if (bmsMakeOutInvoices != null && bmsMakeOutInvoices.size() > 0) { - int count= 0; - for (BmsMakeOutInvoice make : bmsMakeOutInvoices) { - count++; - List ysitemList=new ArrayList(); - ReconciliationDTO reconciliationDTO=new ReconciliationDTO(); - reconciliationDTO.setInnerNumber(reconciliation.getBillNumber()); - String url = ""; - Long organizationId = reconciliation.getOrganizationId(); - String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); - String organizationName = reconciliation.getOrganizationName(); - String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); - if (ncUrl!=null&&ncUrl!="") { - url = ncUrl; - } else { - reconciliation.setSkSynchronousStatus(2); - billManageMapper.updateById(reconciliation); - throw new ServiceException("未找到该组织的推送地址!"); - } - List bmsMakeOutInvoiceItems = bmsMakeOutInvoiceItemMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoiceItem::getMakeId, make.getId())); - String makerCodeNc = ""; - if(bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0){ - if(ObjectUtil.isNotNull(bmsMakeOutInvoiceItems)){ - // 汇总 list 中 invoiceValue 的总值 - BigDecimal totalInvoiceValue = bmsMakeOutInvoiceItems.stream() - .map(BmsMakeOutInvoiceItem::getInvoiceValue) - .filter(java.util.Objects::nonNull) - .reduce(BigDecimal.ZERO, BigDecimal::add); + List billDetails = billDetailService.list(new LambdaQueryWrapper() + .eq(BillDetail::getBillManageId, reconciliation.getBillManageId()) + .eq(BillDetail::getDelFlag, 1)); - // 将 feeType 用、拼接起来 - String feeTypes = bmsMakeOutInvoiceItems.stream() - .map(BmsMakeOutInvoiceItem::getFeeType) - .filter(java.util.Objects::nonNull) - .collect(java.util.stream.Collectors.joining("、")); - - // 按 createTime 倒序排序并获取第一条记录 - BmsMakeOutInvoiceItem firstItem = bmsMakeOutInvoiceItems.stream() - .sorted((a, b) -> { - if (a.getCreateTime() == null) return 1; - if (b.getCreateTime() == null) return -1; - return b.getCreateTime().compareTo(a.getCreateTime()); - }) - .findFirst() - .orElse(null); - String salesmanId = reconciliation.getSalesmanId(); - String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); - String deptValue = billManageMapper.getDeptValue(customerUserDept); - String deptName = billManageMapper.getDeptName(customerUserDept); - String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); - String salesmanCodeNc=salespersonNcCode; - String appointShipper=make.getActualInvoiceCustomerName(); - String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); - String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); - String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); - if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { - ObjectMapper objectMapper = new ObjectMapper(); - List> listNc = objectMapper.readValue( - customerCodeNcJson, - new TypeReference>>() {} - ); - if (listNc != null && listNc.size() > 0) { - Map targetMap = listNc.stream() - .filter(map -> { - Object codeObj = map.get("code"); - return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); - }) - .findFirst() - .orElse(null); - if (targetMap != null) { - customerCodeNc = (String) targetMap.get("ncCustomer"); - } - } - } - String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); - String settlementCurrency=reconciliation.getSettlementCurrency(); - String settlementCurrencyNcCode = settlementCurrency; - makerCodeNc=documentPreparerNcCode; - SKitem item=new SKitem(); - if (deptValue != null && !deptValue.isEmpty()) { - item.setSo_deptid(deptValue); - } else { - item.setSo_deptid("NG0408"); - } - if (deptValue != null && !deptValue.isEmpty()) { - item.setPk_deptid(deptValue); - } else { - item.setPk_deptid("NG0408"); - } - item.setCheckdirection("ar"); - item.setPk_psndoc(salesmanCodeNc); - item.setCustomer(customerCodeNc); - item.setPurchaseorder(""); - item.setObjtype("0"); - item.setDirection("1"); - if (deptName != null && !deptName.isEmpty()) { - if (feeTypes != null && !feeTypes.isEmpty()) { - item.setScomment(deptName+":"+appointShipper+feeTypes); - } else { - item.setScomment(deptName+":"+appointShipper+feeTypes); - } - } else { - if (feeTypes != null && !feeTypes.isEmpty()) { - item.setScomment("业务部:"+appointShipper+feeTypes); - } else { - item.setScomment("业务部:"+appointShipper+feeTypes); - } - } - // 费用类别 - String feeType = firstItem.getFeeType(); - String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); - if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { - item.setDef75(serviceItemsCodeNc); - } else { - item.setDef75("T10"); - } - String invoiceItem1 = firstItem.getInvoiceItem(); - if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { - String[] split = invoiceItem1.split(","); - item.setDef29(split[0]); - } - item.setPk_currtype(settlementCurrencyNcCode); - item.setMoney_cr(String.valueOf(totalInvoiceValue)); - item.setMoney_bal(String.valueOf(totalInvoiceValue)); - ysitemList.add(item); - } - } - SKbodys bodys=new SKbodys(); - bodys.setItem(ysitemList); - SKbillhead billhead=new SKbillhead(); - billhead.setPk_group("CNK"); - if (orgCodeNc != null && !orgCodeNc.isEmpty()) { - billhead.setPk_org(orgCodeNc); - billhead.setSett_org(orgCodeNc); - } else { - billhead.setPk_org("NG04"); - billhead.setSett_org("NG04"); - } - billhead.setCreationtime(dateString); - billhead.setPk_billtype("F2"); - billhead.setCreator(makerCodeNc); - billhead.setPk_tradetype("D2"); - billhead.setBillclass("sk"); - billhead.setBilldate(dateString); - billhead.setSyscode("0"); - billhead.setBillno(""); - billhead.setDef59(""); - billhead.setSrc_syscode("0"); - billhead.setBillstatus("0"); - billhead.setBillmaker(makerCodeNc); - billhead.setPk_busitype(""); - billhead.setBillyear(sdf1.format(date)); - billhead.setBillperiod(sdf2.format(date)); - billhead.setEffectstatus("0"); - billhead.setDef28("nqyw"); - billhead.setDef29(reconciliation.getBillNumber()); - billhead.setBodys(bodys); - SKbill bill=new SKbill(); - bill.setId("sk"+String.valueOf(reconciliation.getBillManageId())+"_"+count); - bill.setBillhead(billhead); - SKufinterface ufinterface=new SKufinterface(); - ufinterface.setAccount("NKNC"); - ufinterface.setBilltype("F2"); - ufinterface.setBusinessunitcode(""); - ufinterface.setFilename(""); - ufinterface.setIsexchange("Y"); - if (orgCodeNc != null && !orgCodeNc.isEmpty()) { - ufinterface.setOrgcode(orgCodeNc); - ufinterface.setReceiver(orgCodeNc); - } else { - ufinterface.setOrgcode("NG04"); - ufinterface.setReceiver("NG04"); - } - ufinterface.setReplace("Y"); - ufinterface.setRoottag(""); - ufinterface.setSender("nqyw"); - ufinterface.setBill(bill); - JAXBContext jaxbContext = null; - //String xmlString =""; - jaxbContext = JAXBContext.newInstance(SKufinterface.class); - Marshaller marshaller = jaxbContext.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 - StringWriter sw = new StringWriter(); - marshaller.marshal(ufinterface, sw); - String xmlString = sw.toString(); // 这是要发送的XML字符串 - System.out.println(xmlString); - NcLog ncLog=new NcLog(); - ncLog.setOrderId(reconciliation.getBillManageId()); - ncLog.setRequestBody(xmlString); - ncLog.setResponeBody(""); - ncLog.setType(1L); - ncLog.setSendTime(new Date()); - ncLog.setOrganizationId(reconciliation.getOrganizationId()); - ncLog.setOrganizationName(reconciliation.getOrganizationName()); - ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); - ncLogMapper.insert(ncLog); - reconciliation.setSkSynchronousStatus(1); - reconciliation.setSkSynchronousTime(new Date()); - reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getBillManageId())); - //reconciliationMapper.updateById(reconciliation); - CloseableHttpClient httpClient = HttpClients.createDefault(); - HttpPost httpPost = new HttpPost(url); - StringEntity postingString = new StringEntity(xmlString, "UTF-8"); - httpPost.setEntity(postingString); - httpPost.setHeader("Content-type", "application/xml"); - try { - CloseableHttpResponse response = httpClient.execute(httpPost); - String responseString = EntityUtils.toString(response.getEntity()); - System.out.println(responseString); - ncLog.setResponeBody(responseString); - // 创建DOM解析器 - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document document = builder.parse(new InputSource(new StringReader(responseString))); - - // 获取根元素 - Element root = document.getDocumentElement(); - - // 获取ufinterface元素的属性 - String billtype = root.getAttribute("billtype"); - String filename = root.getAttribute("filename"); - System.out.println("billtype: " + billtype); - System.out.println("filename: " + filename); - - // 获取sendresult节点 - NodeList sendResultList = root.getElementsByTagName("sendresult"); - if (sendResultList.getLength() > 0) { - Element sendResult = (Element) sendResultList.item(0); - - // 获取子元素内容 - String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); - String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); - String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); - - System.out.println("bdocid: " + bdocid); - System.out.println("resultcode: " + resultcode); - System.out.println("content: " + content); - if(resultcode.equals("1")){ - reconciliation.setSkSynchronousStatus(1); - }else{ - reconciliation.setSkSynchronousStatus(2); - } - } - ncLogMapper.updateById(ncLog); - billManageMapper.updateById(reconciliation); - response.close(); - } catch (Exception e) { - reconciliation.setSkSynchronousStatus(2); - billManageMapper.updateById(reconciliation); - e.printStackTrace(); - } finally { - try { - httpClient.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - } + List ysitemList=new ArrayList(); + ReconciliationDTO reconciliationDTO=new ReconciliationDTO(); + reconciliationDTO.setInnerNumber(reconciliation.getBillNumber()); + String url = ""; + Long organizationId = reconciliation.getOrganizationId(); + String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); + String organizationName = reconciliation.getOrganizationName(); + String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); + if (ncUrl!=null&&ncUrl!="") { + url = ncUrl; } else { reconciliation.setSkSynchronousStatus(2); billManageMapper.updateById(reconciliation); + throw new ServiceException("未找到该组织的推送地址!"); } + String makerCodeNc = ""; + if(billDetails != null && billDetails.size() > 0){ + if(ObjectUtil.isNotNull(billDetails)){ + // 汇总 list 中 invoiceValue 的总值 + BigDecimal totalInvoiceValue = billDetails.stream() + .map(BillDetail::getBillingAmount) + .filter(java.util.Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 将 feeType 用、拼接起来 + String feeTypes = billDetails.stream() + .map(BillDetail::getInvoiceItemName) + .filter(java.util.Objects::nonNull) + .collect(java.util.stream.Collectors.joining("、")); + + // 按 createTime 倒序排序并获取第一条记录 + BillDetail firstItem = billDetails.stream() + .sorted((a, b) -> { + if (a.getCreateTime() == null) return 1; + if (b.getCreateTime() == null) return -1; + return b.getCreateTime().compareTo(a.getCreateTime()); + }) + .findFirst() + .orElse(null); + String salesmanId = reconciliation.getSalesmanId(); + String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); + String deptValue = billManageMapper.getDeptValue(customerUserDept); + String deptName = billManageMapper.getDeptName(customerUserDept); + String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); + String salesmanCodeNc=salespersonNcCode; + Long settlementCustomersId = reconciliation.getSettlementCustomersId(); + SettlementCustomers settlementCustomers = settlementCustomersService.getById(settlementCustomersId); + if (settlementCustomers==null){ + throw new ServiceException("结算对象未找到!"); + } + Long settlementEntityId = settlementCustomers.getSettlementEntityId(); + Long shipperId = billManageMapper.getShipperId(settlementEntityId, organizationId); + if (shipperId==null||shipperId==0){ + throw new ServiceException("结算对象未找到!"); + } + String appointShipper=settlementCustomers.getSettlementEntity(); + String actualInvoiceCustomerId = String.valueOf(shipperId); + String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); + String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); + if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { + ObjectMapper objectMapper = new ObjectMapper(); + List> listNc = objectMapper.readValue( + customerCodeNcJson, + new TypeReference>>() {} + ); + if (listNc != null && listNc.size() > 0) { + Map targetMap = listNc.stream() + .filter(map -> { + Object codeObj = map.get("code"); + return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); + }) + .findFirst() + .orElse(null); + if (targetMap != null) { + customerCodeNc = (String) targetMap.get("ncCustomer"); + } + } + } + String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); + String settlementCurrency=reconciliation.getSettlementCurrency(); + String settlementCurrencyNcCode = settlementCurrency; + makerCodeNc=documentPreparerNcCode; + SKitem item=new SKitem(); + if (deptValue != null && !deptValue.isEmpty()) { + item.setSo_deptid(deptValue); + } else { + item.setSo_deptid("NG0408"); + } + if (deptValue != null && !deptValue.isEmpty()) { + item.setPk_deptid(deptValue); + } else { + item.setPk_deptid("NG0408"); + } + item.setCheckdirection("ar"); + item.setPk_psndoc(salesmanCodeNc); + item.setCustomer(customerCodeNc); + item.setPurchaseorder(""); + item.setObjtype("0"); + item.setDirection("1"); + if (deptName != null && !deptName.isEmpty()) { + if (feeTypes != null && !feeTypes.isEmpty()) { + item.setScomment(deptName+":"+appointShipper+feeTypes); + } else { + item.setScomment(deptName+":"+appointShipper+feeTypes); + } + } else { + if (feeTypes != null && !feeTypes.isEmpty()) { + item.setScomment("业务部:"+appointShipper+feeTypes); + } else { + item.setScomment("业务部:"+appointShipper+feeTypes); + } + } + // 费用类别 + String feeType = firstItem.getFeeType(); + String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); + if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { + item.setDef75(serviceItemsCodeNc); + } else { + item.setDef75("T10"); + } + String invoiceItem1 = firstItem.getInvoiceItem(); + if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { + String[] split = invoiceItem1.split(","); + item.setDef29(split[0]); + } + item.setPk_currtype(settlementCurrencyNcCode); + item.setMoney_cr(String.valueOf(totalInvoiceValue)); + item.setMoney_bal(String.valueOf(totalInvoiceValue)); + ysitemList.add(item); + } + } + SKbodys bodys=new SKbodys(); + bodys.setItem(ysitemList); + SKbillhead billhead=new SKbillhead(); + billhead.setPk_group("CNK"); + if (orgCodeNc != null && !orgCodeNc.isEmpty()) { + billhead.setPk_org(orgCodeNc); + billhead.setSett_org(orgCodeNc); + } else { + billhead.setPk_org("NG04"); + billhead.setSett_org("NG04"); + } + billhead.setCreationtime(dateString); + billhead.setPk_billtype("F2"); + billhead.setCreator(makerCodeNc); + billhead.setPk_tradetype("D2"); + billhead.setBillclass("sk"); + billhead.setBilldate(dateString); + billhead.setSyscode("0"); + billhead.setBillno(""); + billhead.setDef59(""); + billhead.setSrc_syscode("0"); + billhead.setBillstatus("0"); + billhead.setBillmaker(makerCodeNc); + billhead.setPk_busitype(""); + billhead.setBillyear(sdf1.format(date)); + billhead.setBillperiod(sdf2.format(date)); + billhead.setEffectstatus("0"); + billhead.setDef28("nqyw"); + billhead.setDef29(reconciliation.getBillNumber()); + billhead.setBodys(bodys); + SKbill bill=new SKbill(); + bill.setId("sk"+String.valueOf(reconciliation.getBillManageId())+"_"+1); + bill.setBillhead(billhead); + SKufinterface ufinterface=new SKufinterface(); + ufinterface.setAccount("NKNC"); + ufinterface.setBilltype("F2"); + ufinterface.setBusinessunitcode(""); + ufinterface.setFilename(""); + ufinterface.setIsexchange("Y"); + if (orgCodeNc != null && !orgCodeNc.isEmpty()) { + ufinterface.setOrgcode(orgCodeNc); + ufinterface.setReceiver(orgCodeNc); + } else { + ufinterface.setOrgcode("NG04"); + ufinterface.setReceiver("NG04"); + } + ufinterface.setReplace("Y"); + ufinterface.setRoottag(""); + ufinterface.setSender("nqyw"); + ufinterface.setBill(bill); + JAXBContext jaxbContext = null; + //String xmlString =""; + jaxbContext = JAXBContext.newInstance(SKufinterface.class); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 + StringWriter sw = new StringWriter(); + marshaller.marshal(ufinterface, sw); + String xmlString = sw.toString(); // 这是要发送的XML字符串 + System.out.println(xmlString); + NcLog ncLog=new NcLog(); + ncLog.setOrderId(reconciliation.getBillManageId()); + ncLog.setRequestBody(xmlString); + ncLog.setResponeBody(""); + ncLog.setType(1L); + ncLog.setSendTime(new Date()); + ncLog.setOrganizationId(reconciliation.getOrganizationId()); + ncLog.setOrganizationName(reconciliation.getOrganizationName()); + ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); + ncLogMapper.insert(ncLog); + reconciliation.setSkSynchronousStatus(1); + reconciliation.setSkSynchronousTime(new Date()); + reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getBillManageId())); + //reconciliationMapper.updateById(reconciliation); + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + StringEntity postingString = new StringEntity(xmlString, "UTF-8"); + httpPost.setEntity(postingString); + httpPost.setHeader("Content-type", "application/xml"); + try { + CloseableHttpResponse response = httpClient.execute(httpPost); + String responseString = EntityUtils.toString(response.getEntity()); + System.out.println(responseString); + ncLog.setResponeBody(responseString); + // 创建DOM解析器 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document document = builder.parse(new InputSource(new StringReader(responseString))); + + // 获取根元素 + Element root = document.getDocumentElement(); + + // 获取ufinterface元素的属性 + String billtype = root.getAttribute("billtype"); + String filename = root.getAttribute("filename"); + System.out.println("billtype: " + billtype); + System.out.println("filename: " + filename); + + // 获取sendresult节点 + NodeList sendResultList = root.getElementsByTagName("sendresult"); + if (sendResultList.getLength() > 0) { + Element sendResult = (Element) sendResultList.item(0); + + // 获取子元素内容 + String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); + String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); + String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); + + System.out.println("bdocid: " + bdocid); + System.out.println("resultcode: " + resultcode); + System.out.println("content: " + content); + if(resultcode.equals("1")){ + reconciliation.setSkSynchronousStatus(1); + }else{ + reconciliation.setSkSynchronousStatus(2); + } + } + ncLogMapper.updateById(ncLog); + billManageMapper.updateById(reconciliation); + response.close(); + } catch (Exception e) { + reconciliation.setSkSynchronousStatus(2); + billManageMapper.updateById(reconciliation); + e.printStackTrace(); + } finally { + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + } catch (JAXBException e) { reconciliation.setSkSynchronousStatus(2); billManageMapper.updateById(reconciliation); diff --git a/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml b/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml index e56269307..5c4d156ed 100644 --- a/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml +++ b/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml @@ -27,5 +27,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND bd.bill_manage_id = #{billManageId} + - + + \ No newline at end of file From 895c8d6a4b5536f4e5282f413d1932c4a3836565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Thu, 23 Jul 2026 17:48:19 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E5=8F=91=E6=B5=8B=E8=AF=95;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mhd/system/api/BmsServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/OmsServiceFeign.java | 2 +- .../main/java/com/mhd/system/api/WlhyServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/WmsServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/YmsServiceFeign.java | 2 +- mhd_bms/src/main/resources/bootstrap.yml | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java index 8cc8bfd57..91f2f8a11 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java @@ -18,7 +18,7 @@ import java.util.Set; /** * bms财务结算系统feign调用接口 */ -@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.33.0.109:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface BmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java index 560febea1..03d48d2f4 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.concurrent.CompletableFuture; -@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.33:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.33.0.99:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface OmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java index d976fcc98..ba9a45148 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java @@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; -@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.31:8014",configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.33.0.129:8014",configuration = FeignAutoConfiguration.class) public interface WlhyServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java index 653f44d4b..688e5ea7c 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java @@ -21,7 +21,7 @@ import java.util.Map; * @description: TODO * @date 2024/5/10 8:58 **/ -@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.32:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.33.0.109:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface WmsServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java index 238ec5f81..48d76d01e 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java @@ -9,7 +9,7 @@ import com.mhd.system.api.feign.FeignAutoConfiguration; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; -@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.33:8018", configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.33.0.99:8018", configuration = FeignAutoConfiguration.class) public interface YmsServiceFeign { /** diff --git a/mhd_bms/src/main/resources/bootstrap.yml b/mhd_bms/src/main/resources/bootstrap.yml index 1b1edd68f..5532be09f 100644 --- a/mhd_bms/src/main/resources/bootstrap.yml +++ b/mhd_bms/src/main/resources/bootstrap.yml @@ -18,15 +18,15 @@ spring: discovery: # server-addr: 127.0.0.1:8848 # 线上测试环境配置 容器名+端口号 -# server-addr: 10.33.0.129:6010 - server-addr: 10.102.192.31:6848 + server-addr: 10.33.0.129:6010 +# server-addr: 10.102.192.31:6848 username: nacos password: manhuoda@2023 config: # server-addr: 127.0.0.1:8848 # 线上测试环境配置 容器名+端口号 -# server-addr: 10.33.0.129:6010 - server-addr: 10.102.192.31:6848 + server-addr: 10.33.0.129:6010 +# server-addr: 10.102.192.31:6848 username: nacos password: manhuoda@2023 group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置 From 885d38565c800a30cc5738d228c393177d3ebeef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 14:45:32 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=B7=BB=E5=8A=A0=E6=89=A7=E8=A1=8C=E5=8D=95=E4=BF=A1?= =?UTF-8?q?=E6=81=AF;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mapper/SettlementCustomersMapper.xml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml b/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml index 54d6b7a3a..6bff7db29 100644 --- a/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml +++ b/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml @@ -200,10 +200,7 @@ AND ( a.organization_id = #{settlementCustomersDO.organizationId} - OR b.org_code LIKE concat('%"code":"', #{settlementCustomersDO.organizationId}, '"%') - OR b.org_code LIKE concat('%code:', #{settlementCustomersDO.organizationId}, '%') - OR b.org_code LIKE concat('%code: ', #{settlementCustomersDO.organizationId}, '%') - OR b.org_code LIKE concat('%"code":', #{settlementCustomersDO.organizationId}, '%') + OR b.org_code LIKE concat('%', #{settlementCustomersDO.organizationId}, '%') ) @@ -216,4 +213,4 @@ and a.customer_type_code = #{settlementCustomersDO.customerTypeCode} - + \ No newline at end of file From f1567eb81e31a6bb56c9b732ecda29060537e8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 14:48:09 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E6=9F=A5=E8=B4=A7=E4=B8=BB=E5=8D=A1?= =?UTF-8?q?=E6=AD=BB;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mapper/SettlementCustomersMapper.xml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml b/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml index 54d6b7a3a..6bff7db29 100644 --- a/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml +++ b/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml @@ -200,10 +200,7 @@ AND ( a.organization_id = #{settlementCustomersDO.organizationId} - OR b.org_code LIKE concat('%"code":"', #{settlementCustomersDO.organizationId}, '"%') - OR b.org_code LIKE concat('%code:', #{settlementCustomersDO.organizationId}, '%') - OR b.org_code LIKE concat('%code: ', #{settlementCustomersDO.organizationId}, '%') - OR b.org_code LIKE concat('%"code":', #{settlementCustomersDO.organizationId}, '%') + OR b.org_code LIKE concat('%', #{settlementCustomersDO.organizationId}, '%') ) @@ -216,4 +213,4 @@ and a.customer_type_code = #{settlementCustomersDO.customerTypeCode} - + \ No newline at end of file From 7a6c570a88aab20e81e8ab44cbefdc2cc2e50eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 15:17:00 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E6=9F=A5=E8=B4=A7=E4=B8=BB=E5=8D=A1?= =?UTF-8?q?=E6=AD=BB;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml b/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml index 6bff7db29..e2fd28e11 100644 --- a/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml +++ b/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml @@ -200,7 +200,6 @@ AND ( a.organization_id = #{settlementCustomersDO.organizationId} - OR b.org_code LIKE concat('%', #{settlementCustomersDO.organizationId}, '%') ) From b9fe4bc4d25580398d83e1c3e0c1003e6ea40268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 17:01:52 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=94=E6=94=B6?= =?UTF-8?q?=E8=B4=A6=E5=8D=95=E6=8E=A8=E9=80=81nc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BillManageApplicationService.java | 27 ++++++++++++ .../repository/mapper/BillDetailMapper.java | 3 ++ .../persistence/BillManageImpl.java | 41 +++++++++++++++++++ .../resources/mapper/BillDetailMapper.xml | 10 +++++ 4 files changed, 81 insertions(+) diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java index bb1fc6170..ee8b50793 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java @@ -7,6 +7,7 @@ import com.mhd.bms.application.server.receiptManage.ReceiptManageApplicationServ import com.mhd.bms.domain.billManage.entity.BillDetail; import com.mhd.bms.domain.billManage.entity.BillManage; import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService; +import com.mhd.bms.domain.billManage.repository.facade.IBillManageService; import com.mhd.bms.domain.billManage.repository.mapper.BillDetailMapper; import com.mhd.bms.domain.billManage.repository.po.BillDetailPO; import com.mhd.bms.domain.billManage.repository.po.BillManagePO; @@ -78,6 +79,8 @@ public class BillManageApplicationService { private BillDetailMapper billDetailMapper; @Autowired private NcLogMapper ncLogMapper; + @Autowired + private IBillManageService billManageService; /** @@ -465,6 +468,30 @@ public class BillManageApplicationService { }); } //保存账单明细 + double allTaxRate = 0.0d; + BigDecimal allTaxAmount = BigDecimal.ZERO; + BigDecimal allTaxFreeFee = BigDecimal.ZERO; + for (BillDetailDTO item : billDetailDTOList) { + String firstSubjectCode = item.getFirstSubjectCode(); + Double taxRate = billDetailMapper.getTaxRate(firstSubjectCode); + BigDecimal amount = item.getBillingAmount(); + BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal taxFreeFee = amount.subtract(taxAmount); + item.setTaxAmount(taxAmount); + item.setTaxFreeFee(taxFreeFee); + item.setTaxRate(taxRate); + allTaxRate += taxRate; + allTaxAmount = allTaxAmount.add(taxAmount); + allTaxFreeFee = allTaxFreeFee.add(taxFreeFee); + } + + BillManage billManage = billManageService.getById(billManageDO.getBillManageId()); + if (billManage != null) { + billManage.setTaxRate(allTaxRate); + billManage.setTaxAmount(allTaxAmount); + billManage.setTaxFreeFee(allTaxFreeFee); + billManageService.updateById(billManage); + } Boolean flagTwo = billDetailDomainService.saveBatch(billDetailDTOList); //保存操作记录 BillOperationLogDO billOperationLogDO = new BillOperationLogDO(); diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java index b8fcdd9c5..044e5565c 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java @@ -5,6 +5,7 @@ import com.mhd.bms.domain.billManage.entity.BillDetail; import com.mhd.bms.domain.billManage.repository.po.BillDetailPO; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; /** @@ -19,4 +20,6 @@ public interface BillDetailMapper extends BaseMapper List getDetailsByBillManageId(@Param("billManageId") Long billManageId); List getDetailsByBillManageIdAndGroup(@Param("billManageId") Long billManageId); + + Double getTaxRate(@Param("code") String code); } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java index 17872b7f1..4cb9549dc 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java @@ -13,6 +13,7 @@ import com.mhd.bms.domain.billManage.entity.BillDetail; import com.mhd.bms.domain.billManage.entity.BillManage; import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService; import com.mhd.bms.domain.billManage.repository.facade.IBillManageService; +import com.mhd.bms.domain.billManage.repository.mapper.BillDetailMapper; import com.mhd.bms.domain.billManage.repository.mapper.BillManageMapper; import com.mhd.bms.domain.billManage.repository.po.BillManagePO; import com.mhd.bms.domain.billManage.repository.todo.BillManageDO; @@ -28,6 +29,7 @@ import com.mhd.bms.domain.ncLog.entity.NcLog; import com.mhd.bms.domain.ncLog.repository.mapper.NcLogMapper; import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers; import com.mhd.bms.domain.settlementCustomers.repository.facade.ISettlementCustomersService; +import com.mhd.bms.interfaces.dto.billManage.BillDetailDTO; import com.mhd.bms.interfaces.dto.billManage.BillManageDTO; import com.mhd.common.core.domain.dto.ReconciliationDTO; import com.mhd.common.core.domain.dto.nc.*; @@ -89,6 +91,10 @@ public class BillManageImpl extends ServiceImpl im @Autowired private IBillDetailService billDetailService; @Autowired + private IBillManageService billManageService; + @Autowired + private BillDetailMapper billDetailMapper; + @Autowired private BmsInvoiceListMapper bmsInvoiceListMapper; //nc测试环境地址 @@ -199,6 +205,41 @@ public class BillManageImpl extends ServiceImpl im String invoiceId = reconciliation.getInvoiceId(); List billDetails = billDetailService.getDetailsByBillManageIdAndGroup(Long.parseLong(businessDocumentDetaliId)); + //保存税额等 + double allTaxRate = 0.0d; + BigDecimal allTaxAmount = BigDecimal.ZERO; + BigDecimal allTaxFreeFee = BigDecimal.ZERO; + for (BillDetail item : billDetails) { + String firstSubjectCode = item.getInvoiceItem(); + Double taxRate = billDetailMapper.getTaxRate(firstSubjectCode); + BigDecimal amount = item.getBillingAmount(); + BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal taxFreeFee = amount.subtract(taxAmount); + if (item.getTaxAmount() == null) { + item.setTaxAmount(taxAmount); + } + if (item.getTaxFreeFee() == null) { + item.setTaxFreeFee(taxFreeFee); + } + if (item.getTaxRate() == null) { + item.setTaxRate(taxRate); + } + allTaxRate += taxRate; + allTaxAmount = allTaxAmount.add(taxAmount); + allTaxFreeFee = allTaxFreeFee.add(taxFreeFee); + } + + if (reconciliation.getTaxRate() == null) { + reconciliation.setTaxRate(allTaxRate); + } + if (reconciliation.getTaxAmount() == null) { + reconciliation.setTaxAmount(allTaxAmount); + } + if (reconciliation.getTaxFreeFee() == null) { + reconciliation.setTaxFreeFee(allTaxFreeFee); + } + + List ysitemList=new ArrayList(); String url = ""; Long organizationId = reconciliation.getOrganizationId(); diff --git a/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml b/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml index 5c4d156ed..0fc27b019 100644 --- a/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml +++ b/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml @@ -47,5 +47,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND bill_manage_id = #{billManageId} GROUP BY INVOICE_ITEM,INVOICE_ITEM_NAME,FEE_TYPE + + \ No newline at end of file From 2787f7651e0532deff499815a9dfae2fd3f010e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Wed, 5 Aug 2026 17:14:03 +0800 Subject: [PATCH 08/13] 30 --- .../src/main/java/com/mhd/system/api/BmsServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/OmsServiceFeign.java | 2 +- .../main/java/com/mhd/system/api/WlhyServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/WmsServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/YmsServiceFeign.java | 2 +- mhd_wms/src/main/resources/bootstrap.yml | 8 ++++---- .../resources/mapper/reviewOrder/ReviewOrderMapper.xml | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java index 91f2f8a11..e18484e8d 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java @@ -18,7 +18,7 @@ import java.util.Set; /** * bms财务结算系统feign调用接口 */ -@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.33.0.109:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.3:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface BmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java index 03d48d2f4..e34bb9cd4 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.concurrent.CompletableFuture; -@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.33.0.99:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.4:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface OmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java index ba9a45148..e4a817238 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java @@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; -@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.33.0.129:8014",configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.30:8014",configuration = FeignAutoConfiguration.class) public interface WlhyServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java index 688e5ea7c..743be7c29 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java @@ -21,7 +21,7 @@ import java.util.Map; * @description: TODO * @date 2024/5/10 8:58 **/ -@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.33.0.109:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.3:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface WmsServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java index 48d76d01e..dfac7337f 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java @@ -9,7 +9,7 @@ import com.mhd.system.api.feign.FeignAutoConfiguration; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; -@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.33.0.99:8018", configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.4:8018", configuration = FeignAutoConfiguration.class) public interface YmsServiceFeign { /** diff --git a/mhd_wms/src/main/resources/bootstrap.yml b/mhd_wms/src/main/resources/bootstrap.yml index 39eb710cb..fc7380c20 100644 --- a/mhd_wms/src/main/resources/bootstrap.yml +++ b/mhd_wms/src/main/resources/bootstrap.yml @@ -14,18 +14,18 @@ spring: nacos: discovery: # server-addr: 127.0.0.1:8848 - server-addr: 10.33.0.129:6010 +# server-addr: 10.33.0.129:6010 # 线上测试环境配置 容器名+端口号 -# server-addr: 10.102.192.30:6848 + server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 #线上正式环境 # server-addr: 10.102.192.105:6848 config: # server-addr: 127.0.0.1:8848 - server-addr: 10.33.0.129:6010 +# server-addr: 10.33.0.129:6010 # 线上测试环境配置 容器名+端口号 -# server-addr: 10.102.192.30:6848 + server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 #线上正式环境 diff --git a/mhd_wms/src/main/resources/mapper/reviewOrder/ReviewOrderMapper.xml b/mhd_wms/src/main/resources/mapper/reviewOrder/ReviewOrderMapper.xml index 86a8a0466..d03ce31fc 100644 --- a/mhd_wms/src/main/resources/mapper/reviewOrder/ReviewOrderMapper.xml +++ b/mhd_wms/src/main/resources/mapper/reviewOrder/ReviewOrderMapper.xml @@ -4,7 +4,7 @@ - + @@ -84,7 +84,7 @@ - a.review_order_id, + a.review_order_id AS review_order_id, a.review_order_number, a.out_order_id, a.out_order_number, From 0f4da97358513fbd984c380e82a6bf8151a5fb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 17:30:17 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=94=E6=94=B6?= =?UTF-8?q?=E8=B4=A6=E5=8D=95=E6=8E=A8=E9=80=81nc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/billManage/BillManageApplicationService.java | 2 ++ .../mhd/bms/domain/billManage/repository/todo/BillManageDO.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java index ee8b50793..532c7219e 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java @@ -431,6 +431,7 @@ public class BillManageApplicationService { billManageDO.setReconciliationStatus(1); billManageDO.setCreateTime(new Date()); billManageDO.setCreateBy(loginUser.getUserid()); + billManageDO.setSalesmanId(String.valueOf(loginUser.getUserid())); billManageDO.setCreateByName(loginUser.getUserPo().getUserName()); billManageDO.setUpdateTime(new Date()); billManageDO.setUpdateBy(loginUser.getUserid()); @@ -490,6 +491,7 @@ public class BillManageApplicationService { billManage.setTaxRate(allTaxRate); billManage.setTaxAmount(allTaxAmount); billManage.setTaxFreeFee(allTaxFreeFee); + billManage.setSalesmanId(String.valueOf(loginUser.getUserid())); billManageService.updateById(billManage); } Boolean flagTwo = billDetailDomainService.saveBatch(billDetailDTOList); diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillManageDO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillManageDO.java index 399ad44c4..cfb053614 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillManageDO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillManageDO.java @@ -264,4 +264,6 @@ public class BillManageDO extends BaseVOEntity{ private String paymentAccountId; @ApiModelProperty("收款帐户名称") private String paymentAccountName; + @ApiModelProperty("业务员ID") + private String salesmanId; } \ No newline at end of file From 18c8c4d18da1a7158ada863b8f4c347c977c7870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 17:32:17 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E5=8F=9131?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mhd/system/api/BmsServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/OmsServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/WlhyServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/WmsServiceFeign.java | 2 +- .../src/main/java/com/mhd/system/api/YmsServiceFeign.java | 2 +- mhd_wms/src/main/resources/bootstrap.yml | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java index e18484e8d..8cc8bfd57 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java @@ -18,7 +18,7 @@ import java.util.Set; /** * bms财务结算系统feign调用接口 */ -@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.3:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface BmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java index e34bb9cd4..560febea1 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.concurrent.CompletableFuture; -@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.4:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.33:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface OmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java index e4a817238..d976fcc98 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java @@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; -@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.30:8014",configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.31:8014",configuration = FeignAutoConfiguration.class) public interface WlhyServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java index 743be7c29..653f44d4b 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java @@ -21,7 +21,7 @@ import java.util.Map; * @description: TODO * @date 2024/5/10 8:58 **/ -@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.3:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.32:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface WmsServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java index dfac7337f..238ec5f81 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java @@ -9,7 +9,7 @@ import com.mhd.system.api.feign.FeignAutoConfiguration; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; -@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.4:8018", configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.33:8018", configuration = FeignAutoConfiguration.class) public interface YmsServiceFeign { /** diff --git a/mhd_wms/src/main/resources/bootstrap.yml b/mhd_wms/src/main/resources/bootstrap.yml index fc7380c20..e8f169bf2 100644 --- a/mhd_wms/src/main/resources/bootstrap.yml +++ b/mhd_wms/src/main/resources/bootstrap.yml @@ -16,7 +16,7 @@ spring: # server-addr: 127.0.0.1:8848 # server-addr: 10.33.0.129:6010 # 线上测试环境配置 容器名+端口号 - server-addr: 10.102.192.30:6848 + server-addr: 10.102.192.31:6848 username: nacos password: manhuoda@2023 #线上正式环境 @@ -25,7 +25,7 @@ spring: # server-addr: 127.0.0.1:8848 # server-addr: 10.33.0.129:6010 # 线上测试环境配置 容器名+端口号 - server-addr: 10.102.192.30:6848 + server-addr: 10.102.192.31:6848 username: nacos password: manhuoda@2023 #线上正式环境 From 987a7c564d2f540642ed4f3e4d3476364b92c0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 17:54:11 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E5=8F=9131?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../billManage/BillManageApplicationService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java index 532c7219e..50f706d8d 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java @@ -453,6 +453,16 @@ public class BillManageApplicationService { for (BillDetailDTO billDetailDTO : billDetailDTOListNoBillingStatementId) { BillingStatementDTO billingStatementDTO = new BillingStatementDTO(); BeanUtils.copyProperties(billDetailDTO, billingStatementDTO); + + String firstSubjectCode = billDetailDTO.getFirstSubjectCode(); + Double taxRate = billDetailMapper.getTaxRate(firstSubjectCode); + BigDecimal amount = billingStatementDTO.getBillingAmount(); + BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal taxFreeFee = amount.subtract(taxAmount); + billingStatementDTO.setTaxAmount(taxAmount); + billingStatementDTO.setTaxFreeFee(taxFreeFee); + billingStatementDTO.setTaxRate(taxRate); + billingStatementDTO.setBillingAmount(amount); billingStatementDTO.setAccountExpenseType(billDetailDTO.getBillType()); billingStatementDTO.setBillManageId(billManageDO.getBillManageId()); billingStatementDTO.setBillingState(3); From 7842ceaf71d673ebe0148bdc8bec818d014cd6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 18:13:30 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E5=9B=9E=E6=98=BE=E5=BA=94=E6=94=B6?= =?UTF-8?q?=E5=BA=94=E4=BB=98;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../billingStatement/BillingStatementApplicationService.java | 2 ++ .../billingStatement/repository/po/BillingStatementPO.java | 4 ++++ .../billingStatement/repository/todo/BillingStatementDO.java | 4 ++++ .../interfaces/dto/billingStatement/BillingStatementDTO.java | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/billingStatement/BillingStatementApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/billingStatement/BillingStatementApplicationService.java index 9e56458e6..0f553dc75 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/billingStatement/BillingStatementApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/billingStatement/BillingStatementApplicationService.java @@ -585,6 +585,8 @@ public class BillingStatementApplicationService { 此方法只进行实体返回,并不进行数据保存 */ LoginUser loginUser = SecurityUtils.getLoginUser(); + + billingStatementDO.setAccountExpenseType(billingStatementDO.getAccountExpenseType()); if (ObjectUtil.isNull(loginUser)) { throw new DigitalLogisticsException(UserError.TIMEOUT); } diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementPO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementPO.java index 447b38446..6a5d308c7 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementPO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementPO.java @@ -100,6 +100,10 @@ public class BillingStatementPO extends BaseVOEntity{ @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") private Integer accountExpenseType; + @ApiModelProperty("收支类型(1-应收,2-应付)") + @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") + private Integer billType; + @ApiModelProperty("流水备注") @Excel(name = "流水备注") private String billingRemark; diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/todo/BillingStatementDO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/todo/BillingStatementDO.java index af1576753..23fc1d687 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/todo/BillingStatementDO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/todo/BillingStatementDO.java @@ -101,6 +101,10 @@ public class BillingStatementDO extends BaseVOEntity{ @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") private Integer accountExpenseType; + @ApiModelProperty("收支类型(1-应收,2-应付)") + @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") + private Integer billType; + @ApiModelProperty("流水备注") @Excel(name = "流水备注") private String billingRemark; diff --git a/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billingStatement/BillingStatementDTO.java b/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billingStatement/BillingStatementDTO.java index 48e195c69..855e5040b 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billingStatement/BillingStatementDTO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billingStatement/BillingStatementDTO.java @@ -102,6 +102,10 @@ public class BillingStatementDTO extends BaseVOEntity{ @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") private Integer accountExpenseType; + @ApiModelProperty("收支类型(1-应收,2-应付)") + @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") + private Integer billType; + @ApiModelProperty("流水备注") @Excel(name = "流水备注") private String billingRemark; From 0ee27d796fcc23fd5a78b5649cdd1a1f80e3d2d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=8E=E5=85=B4?= <2220574228@qq.com> Date: Wed, 5 Aug 2026 18:16:25 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E5=9B=9E=E6=98=BE=E5=BA=94=E6=94=B6?= =?UTF-8?q?=E5=BA=94=E4=BB=98;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/BillManageImpl.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java index 4cb9549dc..8f5a7b64c 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java @@ -842,6 +842,41 @@ public class BillManageImpl extends ServiceImpl im .eq(BillDetail::getBillManageId, reconciliation.getBillManageId()) .eq(BillDetail::getDelFlag, 1)); + + //保存税额等 + double allTaxRate = 0.0d; + BigDecimal allTaxAmount = BigDecimal.ZERO; + BigDecimal allTaxFreeFee = BigDecimal.ZERO; + for (BillDetail item : billDetails) { + String firstSubjectCode = item.getInvoiceItem(); + Double taxRate = billDetailMapper.getTaxRate(firstSubjectCode); + BigDecimal amount = item.getBillingAmount(); + BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal taxFreeFee = amount.subtract(taxAmount); + if (item.getTaxAmount() == null) { + item.setTaxAmount(taxAmount); + } + if (item.getTaxFreeFee() == null) { + item.setTaxFreeFee(taxFreeFee); + } + if (item.getTaxRate() == null) { + item.setTaxRate(taxRate); + } + allTaxRate += taxRate; + allTaxAmount = allTaxAmount.add(taxAmount); + allTaxFreeFee = allTaxFreeFee.add(taxFreeFee); + } + + if (reconciliation.getTaxRate() == null) { + reconciliation.setTaxRate(allTaxRate); + } + if (reconciliation.getTaxAmount() == null) { + reconciliation.setTaxAmount(allTaxAmount); + } + if (reconciliation.getTaxFreeFee() == null) { + reconciliation.setTaxFreeFee(allTaxFreeFee); + } + List ysitemList=new ArrayList(); ReconciliationDTO reconciliationDTO=new ReconciliationDTO(); reconciliationDTO.setInnerNumber(reconciliation.getBillNumber());