diff --git a/mhd-common/mhd-common-core/src/main/java/com/mhd/common/core/domain/dto/nc/Ysitem.java b/mhd-common/mhd-common-core/src/main/java/com/mhd/common/core/domain/dto/nc/Ysitem.java index 4d8bdb48f..206e03081 100644 --- a/mhd-common/mhd-common-core/src/main/java/com/mhd/common/core/domain/dto/nc/Ysitem.java +++ b/mhd-common/mhd-common-core/src/main/java/com/mhd/common/core/domain/dto/nc/Ysitem.java @@ -83,6 +83,9 @@ public class Ysitem { @ApiModelProperty( "") private String def75; + @ApiModelProperty( "") + private String def29; + //税率id private String taxcodeid; diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/entity/ServiceItemsManage.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/entity/ServiceItemsManage.java index c2f4a538d..97793849f 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/entity/ServiceItemsManage.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/entity/ServiceItemsManage.java @@ -53,6 +53,8 @@ public class ServiceItemsManage extends BaseVOEntity{ @ApiModelProperty("备注") @Excel(name = "备注") private String remark; + @ApiModelProperty("服务项编码nc") + @Excel(name = "服务项编码nc") + private String serviceItemsCodeNc; - -} +} \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/repository/po/ServiceItemsManagePO.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/repository/po/ServiceItemsManagePO.java index f44582fd3..ec49db4ac 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/repository/po/ServiceItemsManagePO.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/repository/po/ServiceItemsManagePO.java @@ -59,4 +59,8 @@ public class ServiceItemsManagePO extends BaseVOEntity{ private String costType; -} + @ApiModelProperty("服务项编码nc") + @Excel(name = "服务项编码nc") + private String serviceItemsCodeNc; + +} \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/repository/todo/ServiceItemsManageDO.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/repository/todo/ServiceItemsManageDO.java index aaf8e976d..95b4d5ae3 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/repository/todo/ServiceItemsManageDO.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/serviceItemsManage/repository/todo/ServiceItemsManageDO.java @@ -53,6 +53,10 @@ public class ServiceItemsManageDO extends BaseVOEntity{ @Excel(name = "备注") private String remark; + @ApiModelProperty("服务项编码nc") + @Excel(name = "服务项编码nc") + private String serviceItemsCodeNc; + @ApiModelProperty(name = "组织ID集合") private List organizationIdList; @@ -68,4 +72,5 @@ public class ServiceItemsManageDO extends BaseVOEntity{ private String updateTimeStart; @ApiModelProperty(name = "修改时间查询条件结束日期") private String updateTimeEnd; -} + +} \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/serviceItemsManage/ServiceItemsManageDTO.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/serviceItemsManage/ServiceItemsManageDTO.java index 718ed02cf..5b1654f22 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/serviceItemsManage/ServiceItemsManageDTO.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/serviceItemsManage/ServiceItemsManageDTO.java @@ -61,4 +61,8 @@ public class ServiceItemsManageDTO extends BaseVOEntity{ @ApiModelProperty("服务项管理ids") private String serviceItemsManageIds; -} + + @ApiModelProperty("服务项编码nc") + @Excel(name = "服务项编码nc") + private String serviceItemsCodeNc; +} \ No newline at end of file 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 3bf0ee7ac..d20a9e6f3 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.mapper.BillDetailMapper; import com.mhd.bms.domain.billManage.repository.po.BillDetailPO; import com.mhd.bms.domain.billManage.repository.po.BillManagePO; import com.mhd.bms.domain.billManage.repository.todo.BillDetailDO; @@ -69,6 +70,8 @@ public class BillManageApplicationService { private ReceiptManageDomainService receiptManageDomainService; @Autowired private PaymentOrderDomainService paymentOrderDomainService; + @Autowired + private BillDetailMapper billDetailMapper; /** @@ -121,7 +124,13 @@ public class BillManageApplicationService { } } } - return billManageDomainService.queryList(billManageDO); + List billManagePOS = billManageDomainService.queryList(billManageDO); + for (BillManagePO billManagePO : billManagePOS) { + String billNumber = billManagePO.getBillNumber(); // 获取账单编号 + List billDetails = billDetailMapper.selectList(new LambdaQueryWrapper().eq(BillDetail::getBillNumber, billNumber)); + billManagePO.setBillDetailList(billDetails); + } + return billManagePOS; } diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/entity/BillDetail.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/entity/BillDetail.java index 32eb7303b..546cf0e14 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/entity/BillDetail.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/entity/BillDetail.java @@ -82,4 +82,10 @@ public class BillDetail extends BaseVOEntity{ private Double taxRate; @ApiModelProperty("结算币种") private String settlementCurrency; + @ApiModelProperty(value = "开票项目") + private String invoiceItem; + @ApiModelProperty(value = "开票项目名称") + private String invoiceItemName; + @ApiModelProperty(value = "费用类别") + private String feeType; } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/entity/BillManage.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/entity/BillManage.java index 7b5ba8e36..4a95fe41b 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/entity/BillManage.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/entity/BillManage.java @@ -234,4 +234,9 @@ public class BillManage extends BaseVOEntity{ private Double taxRate; @ApiModelProperty("结算币种") private String settlementCurrency; + @ApiModelProperty("业务员ID") + private String salesmanId; + + @ApiModelProperty("业务员ID") + private String salesmanName; } \ No newline at end of file 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 8647aa8d4..9b56d9f1e 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 @@ -19,4 +19,16 @@ public interface BillManageMapper extends BaseMapper */ public List queryList(@Param("billManageDO") BillManageDO billManageDO); -} + String getInvoiceItemName(@Param("invoiceItemId") String invoiceItemId); + + String getCustomerCodeNc(@Param("actualInvoiceCustomerId") String actualInvoiceCustomerId); + + String getDocumentPreparerNcCode(@Param("salesmanId") String salesmanId); + + String getsalespersonNcCode(@Param("salesmanId") String salesmanId); + + String getSettlementCurrencyNcCode(@Param("settlementCurrency") String settlementCurrency); + + String getServiceItemsCodeNc(@Param("name") String name); + +} \ 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 59a5bdd48..a2b4bc3e7 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 @@ -1,6 +1,7 @@ package com.mhd.bms.domain.billManage.repository.persistence; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fasterxml.jackson.databind.ObjectMapper; @@ -11,19 +12,29 @@ import com.mhd.bms.domain.billManage.repository.po.BillManagePO; import com.mhd.bms.domain.billManage.repository.todo.BillManageDO; import com.mhd.bms.domain.bmsInvoiceList.entity.BmsInvoiceList; import com.mhd.bms.domain.bmsInvoiceList.repository.mapper.BmsInvoiceListMapper; +import com.mhd.bms.domain.bmsMakeOutInvoice.entity.BmsMakeOutInvoice; +import com.mhd.bms.domain.bmsMakeOutInvoice.repository.mapper.BmsMakeOutInvoiceMapper; +import com.mhd.bms.domain.bmsMakeOutInvoiceItem.entity.BmsMakeOutInvoiceItem; +import com.mhd.bms.domain.bmsMakeOutInvoiceItem.repository.mapper.BmsMakeOutInvoiceItemMapper; 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.interfaces.dto.billManage.BillManageDTO; +import com.mhd.common.core.domain.dto.ReconciliationDTO; import com.mhd.common.core.domain.dto.nc.*; import com.mhd.common.core.domain.entity.R; import com.mhd.common.core.domain.entity.TmsOrder; import com.mhd.common.core.domain.po.UserPo; +import com.mhd.common.core.domain.po.thirdparty.SysDepartInterfaceInfoPo; +import com.mhd.common.core.domain.thirdparty.SysDepartInterfaceInfoDTO; import com.mhd.common.core.exception.ServiceException; +import com.mhd.common.core.feign.ThirdPartyServiceFeign; import com.mhd.common.security.utils.SecurityUtils; import com.mhd.system.api.WlhyServiceFeign; import com.mhd.system.api.domain.TmsInvoiceListDetailsVO; +import com.mhd.system.api.domain.TmsMakeOutInvoice; +import com.mhd.system.api.domain.TmsMakeOutInvoiceItem; import com.mhd.system.api.model.LoginUser; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; @@ -49,6 +60,7 @@ import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -80,6 +92,12 @@ public class BillManageImpl extends ServiceImpl im private WlhyServiceFeign wlhyServiceFeign; @Autowired private NcDataPushConfigMapper ncDataPushConfigMapper; + @Resource + private ThirdPartyServiceFeign thirdPartyServiceFeign; + @Resource + private BmsMakeOutInvoiceMapper bmsMakeOutInvoiceMapper; + @Resource + private BmsMakeOutInvoiceItemMapper bmsMakeOutInvoiceItemMapper; /** * 查询账单管理列表 */ @@ -138,72 +156,125 @@ public class BillManageImpl extends ServiceImpl im @Override public boolean synchronousNc(String businessDocumentDetaliIds) { String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(","); - LoginUser loginUser= SecurityUtils.getLoginUser(); - UserPo userPo=loginUser.getUserPo(); - ObjectMapper mapper = new ObjectMapper(); for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){ - BillManage reconciliation=billManageMapper.selectById(businessDocumentDetaliId); - if(reconciliation.getSynchronousStatus()==1){ + BillManage billManage=billManageMapper.selectById(businessDocumentDetaliId); + if(billManage.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); - List ysitemList=new ArrayList(); -// BillManageDTO reconciliationDTO=new BillManageDTO(); -// reconciliationDTO.setBillNumber(reconciliation.getBillNumber()); -// R> result=wlhyServiceFeign.getOrderListByReconciliation(reconciliationDTO); - String makerCodeNc=""; - String invoiceNumber=""; + if(billManage.getOrganizationName().contains("通宇")){ + boolean b = synchronousNc_TY(businessDocumentDetaliId); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return true; + } - //获取发票信息 - String invoiceId = reconciliation.getInvoiceId(); - BmsInvoiceList bmsInvoiceList = bmsInvoiceListMapper.selectById(invoiceId); - invoiceNumber = bmsInvoiceList.getInvoiceNumber(); - //关联不到订单暂时new - List list=new ArrayList<>(); - if(ObjectUtil.isNotNull(list) && list.size()>0){ - for(TmsOrder tmsOrder:list){ - date=tmsOrder.getDocumentDate(); - dateString = sdf.format(date); - makerCodeNc=tmsOrder.getMakerCodeNc(); - Ysitem item=new Ysitem(); - item.setSo_deptid("NG040104"); - item.setPk_deptid("NG040104"); - item.setPk_psndoc(tmsOrder.getSalesmanCodeNc()); - item.setCustomer(tmsOrder.getCustomerCodeNc()); - item.setObjtype("0"); - item.setDirection("1"); - item.setScomment(tmsOrder.getAppointShipper()); - // item.setPk_currtype("CNY"); - item.setPk_currtype(tmsOrder.getSettlementCurrency()); - item.setPurchaseorder(tmsOrder.getGoodsNumber()); - item.setTaxrate("0"); - item.setQuantity_de("0"); - item.setMoney_de(String.valueOf(tmsOrder.getDeliveryFreight())); - item.setMoney_bal(String.valueOf(tmsOrder.getDeliveryFreight())); - BigDecimal tax_de=tmsOrder.getDeliveryFreight().multiply(tmsOrder.getTaxRate().divide(BigDecimal.valueOf(100))).setScale(2,BigDecimal.ROUND_HALF_UP); - BigDecimal notax_de=tmsOrder.getDeliveryFreight().subtract(tax_de); - item.setNotax_de(String.valueOf(notax_de)); - item.setLocal_tax_de(String.valueOf(notax_de)); - item.setTax_de(String.valueOf(tax_de)); - item.setPrice(String.valueOf(tmsOrder.getDeliveryFreight())); - item.setTaxprice(String.valueOf(tmsOrder.getDeliveryFreight())); - item.setDef75("T10"); - item.setInvoiceno(invoiceNumber); - ysitemList.add(item); + + 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 = ""; + SysDepartInterfaceInfoDTO query= new SysDepartInterfaceInfoDTO(); + query.setOrganizationId(reconciliation.getOrganizationId()); + query.setOrganizationName(reconciliation.getOrganizationName()); + query.setInterfaceType("nc"); + List urlList = thirdPartyServiceFeign.queryList(query); + if (urlList != null && urlList.size() > 0) { + url = urlList.get(0).getInterfaceTypeValue(); + } else { + throw new ServiceException("未找到该组织的推送地址!"); } + String salesmanId = reconciliation.getSalesmanId(); + String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); + String salesmanCodeNc=salespersonNcCode; + String appointShipper=make.getActualInvoiceCustomerName(); + String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); + String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); + String settlementCurrency=reconciliation.getSettlementCurrency(); + + 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(); + item.setSo_deptid("NG0408"); + 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<>(); + if (invoiceItem != null && !invoiceItem.isEmpty()) { + String[] items = invoiceItem.split(","); + for (String s : items) { + String invoiceItemName1 = billManageMapper.getInvoiceItemName(s); + names.add(invoiceItemName1); + } + } + String invoiceItemName = String.join(",", names); + item.setDef29(invoiceItemName); + 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"); + } + item.setTaxcodeid("ZL01"); + item.setInvoiceno(invoiceNumber); + ysitemList.add(item); + } + } + } + Ysbodys bodys=new Ysbodys(); bodys.setItem(ysitemList); Ysbillhead billhead=new Ysbillhead(); billhead.setPk_group("CNK"); - billhead.setPk_org("NG0401"); - billhead.setSett_org("NG0401"); - billhead.setBilldate(dateString); + billhead.setPk_org("NG04"); + billhead.setSett_org("NG04"); + billhead.setCreationtime(dateString); billhead.setCreator(makerCodeNc); billhead.setPk_billtype("F0"); billhead.setPk_tradetype("D0"); @@ -211,7 +282,7 @@ public class BillManageImpl extends ServiceImpl im billhead.setIsinit("N"); date=reconciliation.getCreateTime(); dateString = sdf.format(date); - billhead.setCreationtime(dateString); + billhead.setBilldate(dateString); billhead.setSyscode("0"); billhead.setBillno(""); billhead.setDef59(""); @@ -226,7 +297,7 @@ public class BillManageImpl extends ServiceImpl im billhead.setDef29(reconciliation.getBillNumber()); billhead.setBodys(bodys); Ysbill bill=new Ysbill(); - bill.setId("ys"+String.valueOf(reconciliation.getBillManageId())); + bill.setId("ys"+String.valueOf(reconciliation.getBillManageId())+"_"+count); bill.setBillhead(billhead); Ysufinterface ufinterface=new Ysufinterface(); ufinterface.setAccount("NKNC"); @@ -234,8 +305,8 @@ public class BillManageImpl extends ServiceImpl im ufinterface.setBusinessunitcode(""); ufinterface.setFilename(""); ufinterface.setIsexchange("Y"); - ufinterface.setOrgcode("NG0401"); - ufinterface.setReceiver("NG0401"); + ufinterface.setOrgcode("NG04"); + ufinterface.setReceiver("NG04"); ufinterface.setReplace("Y"); ufinterface.setRoottag(""); ufinterface.setSender("nqyw"); @@ -260,17 +331,9 @@ public class BillManageImpl extends ServiceImpl im reconciliation.setSynchronousStatus(1); reconciliation.setSynchronousTime(new Date()); reconciliation.setNcId("ys"+String.valueOf(reconciliation.getBillManageId())); - //billManageMapper.updateById(reconciliation); - Long organizationId = reconciliation.getOrganizationId(); - List ncurl = ncDataPushConfigMapper.selectList(new QueryWrapper().eq("organization_id", organizationId)); - String zsurl = ""; - if (ncurl != null && ncurl.size() > 0) { - zsurl = ncurl.get(0).getNcUrl(); - } else { - throw new ServiceException("未找到对应的nc推送地址"); - } + //reconciliationMapper.updateById(reconciliation); CloseableHttpClient httpClient = HttpClients.createDefault(); - HttpPost httpPost = new HttpPost(zsurl); + HttpPost httpPost = new HttpPost(url); StringEntity postingString = new StringEntity(xmlString, "UTF-8"); httpPost.setEntity(postingString); httpPost.setHeader("Content-type", "application/xml"); @@ -325,9 +388,9 @@ public class BillManageImpl extends ServiceImpl im } } } - } catch (JAXBException e) { - e.printStackTrace(); } + } catch (JAXBException e) { + e.printStackTrace(); } return true; } @@ -335,8 +398,6 @@ public class BillManageImpl extends ServiceImpl im @Override public boolean synchronousNcSK(String businessDocumentDetaliIds) { String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(","); - LoginUser loginUser= SecurityUtils.getLoginUser(); - UserPo userPo=loginUser.getUserPo(); for (String businessDocumentDetaliId:businessDocumentDetaliIdArray){ BillManage reconciliation=billManageMapper.selectById(businessDocumentDetaliId); if(reconciliation.getSkSynchronousStatus()==1){ @@ -344,171 +405,210 @@ public class BillManageImpl extends ServiceImpl im } 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); - List ysitemList=new ArrayList(); - BillManageDTO reconciliationDTO=new BillManageDTO(); - reconciliationDTO.setBillNumber(reconciliation.getBillNumber()); - - String makerCodeNc=""; - //关联不到订单暂时new - List list = new ArrayList<>(); - if(ObjectUtil.isNotNull(list) && list.size()>0){ - for(TmsOrder tmsOrder:list){ - makerCodeNc=tmsOrder.getMakerCodeNc(); - makerCodeNc="xiangna"; - SKitem item=new SKitem(); - item.setSo_deptid("NG040104"); - item.setPk_deptid("NG040104"); - item.setCheckdirection("ar"); - item.setPk_psndoc(tmsOrder.getSalesmanCodeNc()); - item.setCustomer(tmsOrder.getCustomerCodeNc()); - item.setPurchaseorder(tmsOrder.getGoodsNumber()); - item.setObjtype("0"); - item.setDirection("1"); - item.setScomment(tmsOrder.getAppointShipper()); - item.setPk_currtype(tmsOrder.getSettlementCurrency()); - item.setMoney_cr(String.valueOf(tmsOrder.getCollectedFreight())); - item.setMoney_bal(String.valueOf(tmsOrder.getCollectedFreight())); - ysitemList.add(item); - } + if(reconciliation.getOrganizationName().contains("通宇")){ + boolean b = synchronousNcSK_TY(businessDocumentDetaliId); } - - SKbodys bodys=new SKbodys(); - bodys.setItem(ysitemList); - SKbillhead billhead=new SKbillhead(); - billhead.setPk_group("CNK"); - billhead.setPk_org("NG0401"); - billhead.setSett_org("NG0401"); - 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())); - bill.setBillhead(billhead); - SKufinterface ufinterface=new SKufinterface(); - ufinterface.setAccount("NKNC"); - ufinterface.setBilltype("F2"); - ufinterface.setBusinessunitcode(""); - ufinterface.setFilename(""); - ufinterface.setIsexchange("Y"); - ufinterface.setOrgcode("NG0401"); - ufinterface.setReceiver("NG0401"); - 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.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())); - //billManageMapper.updateById(reconciliation); - CloseableHttpClient httpClient = HttpClients.createDefault(); - Long organizationId = reconciliation.getOrganizationId(); - List ncurl = ncDataPushConfigMapper.selectList(new QueryWrapper().eq("organization_id", organizationId)); - String zsurl = ""; - if (ncurl != null && ncurl.size() > 0) { - zsurl = ncurl.get(0).getNcUrl(); - } else { - throw new ServiceException("未找到对应的nc推送地址"); - } - HttpPost httpPost = new HttpPost(zsurl); - 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) { - e.printStackTrace(); - } finally { - try { - httpClient.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } catch (JAXBException e) { + } catch (Exception e) { e.printStackTrace(); } } 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 = ""; + SysDepartInterfaceInfoDTO query= new SysDepartInterfaceInfoDTO(); + query.setOrganizationId(reconciliation.getOrganizationId()); + query.setOrganizationName(reconciliation.getOrganizationName()); + query.setInterfaceType("nc"); + List urlList = thirdPartyServiceFeign.queryList(query); + if (urlList != null && urlList.size() > 0) { + url = urlList.get(0).getInterfaceTypeValue(); + } else { + 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); + String salesmanId = reconciliation.getSalesmanId(); + String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); + String salesmanCodeNc=salespersonNcCode; + String appointShipper=make.getActualInvoiceCustomerName(); + String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); + String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); + String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); + String settlementCurrency=reconciliation.getSettlementCurrency(); + String settlementCurrencyNcCode = settlementCurrency; + makerCodeNc=documentPreparerNcCode; + SKitem item=new SKitem(); + item.setSo_deptid("NG0408"); + item.setPk_deptid("NG0408"); + item.setCheckdirection("ar"); + item.setPk_psndoc(salesmanCodeNc); + item.setCustomer(customerCodeNc); + item.setPurchaseorder(""); + item.setObjtype("0"); + item.setDirection("1"); + item.setScomment("业务部:"+appointShipper+"物流费"); + 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"); + 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"); + 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.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) { + e.printStackTrace(); + } finally { + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + } + } catch (JAXBException e) { + e.printStackTrace(); + } + return true; + } @Override diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/po/BillDetailPO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/po/BillDetailPO.java index dfb1a2b8d..1a0cb7eee 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/po/BillDetailPO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/po/BillDetailPO.java @@ -128,6 +128,11 @@ public class BillDetailPO extends BaseVOEntity{ private Double taxRate; @ApiModelProperty("结算币种") private String settlementCurrency; - + @ApiModelProperty(value = "开票项目") + private String invoiceItem; + @ApiModelProperty(value = "开票项目名称") + private String invoiceItemName; + @ApiModelProperty(value = "费用类别") + private String feeType; } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/po/BillManagePO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/po/BillManagePO.java index 69c40f11c..e1dab5fd2 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/po/BillManagePO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/po/BillManagePO.java @@ -1,5 +1,6 @@ package com.mhd.bms.domain.billManage.repository.po; +import com.mhd.bms.domain.billManage.entity.BillDetail; import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO; import com.mhd.common.core.annotation.Excel; import lombok.Data; @@ -245,4 +246,10 @@ public class BillManagePO extends BaseVOEntity{ private Double taxRate; @ApiModelProperty("结算币种") private String settlementCurrency; + @ApiModelProperty("业务员ID") + private String salesmanId; + + @ApiModelProperty("业务员ID") + private String salesmanName; + private List billDetailList; } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillDetailDO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillDetailDO.java index 4349cfaa7..e443f47f0 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillDetailDO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillDetailDO.java @@ -87,4 +87,15 @@ public class BillDetailDO extends BaseVOEntity{ private Double taxRate; @ApiModelProperty("结算币种") private String settlementCurrency; + @ApiModelProperty("业务员ID") + private String salesmanId; + + @ApiModelProperty("业务员ID") + private String salesmanName; + @ApiModelProperty(value = "开票项目") + private String invoiceItem; + @ApiModelProperty(value = "开票项目名称") + private String invoiceItemName; + @ApiModelProperty(value = "费用类别") + private String feeType; } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/service/BillManageDomainService.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/service/BillManageDomainService.java index 2c345d38d..486f0f415 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/service/BillManageDomainService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/service/BillManageDomainService.java @@ -16,6 +16,8 @@ import com.mhd.bms.domain.billOperationLog.entity.BillOperationLog; import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO; import com.mhd.bms.domain.billOperationLog.service.BillOperationLogDomainService; import com.mhd.bms.domain.billingStatement.entity.BillingStatement; +import com.mhd.bms.domain.billingStatement.repository.mapper.BillingStatementMapper; +import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementADDVO; import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO; import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO; import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService; @@ -65,6 +67,8 @@ public class BillManageDomainService { @Autowired private BillingStatementDomainService billingStatementDomainService; @Autowired + private BillingStatementMapper billingStatementMapper; + @Autowired private BillDetailDomainService billDetailDomainService; @Autowired private SystemServiceFeign systemServiceFeign; @@ -115,12 +119,20 @@ public class BillManageDomainService { /** * 保存账单 */ - public Boolean saveBill(List billingStatementPOS,String billingRemark,Date billCreateTime) { + public Boolean saveBill(List billingStatementPOS,String billingRemark,Date billCreateTime,BillingStatementDTO billingStatementDTO) { LoginUser loginUser = SecurityUtils.getLoginUser(); if (ObjectUtil.isNull(loginUser)) { throw new DigitalLogisticsException(UserError.TIMEOUT); } + BigDecimal taxAmount = billingStatementDTO.getTaxAmount(); // 获取税额 + Double taxRate = billingStatementDTO.getTaxRate(); // 获取税率 + BigDecimal taxFreeFee = billingStatementDTO.getTaxFreeFee(); // 获取税免金额 + String settlementCurrency = billingStatementDTO.getSettlementCurrency(); // 获取结算币种 BillManage billManage = new BillManage(); + billManage.setTaxAmount(taxAmount); + billManage.setTaxRate(taxRate); + billManage.setTaxFreeFee(taxFreeFee); + billManage.setSettlementCurrency(settlementCurrency); billManage.setCreateBy(loginUser.getUserPo().getUserId()); billManage.setCreateByName(loginUser.getUserPo().getUserName()); billManage.setCreateTime(billCreateTime==null ? new Date():billCreateTime); @@ -135,6 +147,8 @@ public class BillManageDomainService { billManage.setSettlementCustomersId(billingStatementPOS.get(0).getSettlementCustomersId()); billManage.setSettlementEntity(billingStatementPOS.get(0).getSettlementEntity()); billManage.setSettlementCustomersCode(billingStatementPOS.get(0).getSettlementCustomersCode()); + billManage.setSalesmanId(billingStatementPOS.get(0).getSalesmanId()); + billManage.setSalesmanName(billingStatementPOS.get(0).getSalesmanName()); billManage.setBillRemark(billingRemark); //查询结算对象信息 SettlementCustomersPO settlementCustomersPO = settlementCustomersDomainService.getInfo(billingStatementPOS.get(0).getSettlementCustomersId()); @@ -181,6 +195,13 @@ public class BillManageDomainService { billDetail.setBillingTotalAmount(billingStatementPO.getBillingAmount()); billDetail.setBillingAmount(billingStatementPO.getBillingAmount()); billDetail.setBillType(billingStatementPO.getAccountExpenseType()); + billDetail.setTaxAmount(billingStatementPO.getTaxAmount()); + billDetail.setTaxRate(billingStatementPO.getTaxRate()); + billDetail.setTaxFreeFee(billingStatementPO.getTaxFreeFee()); + billDetail.setSettlementCurrency(billingStatementPO.getSettlementCurrency()); + billDetail.setFeeType(billingStatementPO.getFeeType()); + billDetail.setInvoiceItem(billingStatementPO.getInvoiceItem()); + billDetail.setInvoiceItemName(billingStatementPO.getInvoiceItemName()); billDetailList.add(billDetail); } boolean flagTwo = billDetailDomainService.insertBatch(billDetailList); @@ -190,6 +211,15 @@ public class BillManageDomainService { billOperationLogDO.setOperationInfo(StringUtils.format(BillLogsConstants.create_bill_text, billManage.getBillNumber(), billManage.getBillTotalAmount())); billOperationLogDO.setOperationType(1); boolean three = billOperationLogDomainService.saveBillOperationLog(billOperationLogDO); + //修改流水记录 + billingStatementDTO.getBillingStatementList().forEach(billingStatementADDVO -> { + billingStatementMapper.update(null, + new LambdaUpdateWrapper().set(BillingStatement::getTaxAmount,billingStatementADDVO.getTaxAmount()) + .set(BillingStatement::getTaxRate,billingStatementADDVO.getTaxRate()) + .set(BillingStatement::getTaxFreeFee,billingStatementADDVO.getTaxFreeFee()) + .set(BillingStatement::getSettlementCurrency,billingStatementADDVO.getSettlementCurrency()) + .eq(BillingStatement::getBillingStatementId,billingStatementADDVO.getBillingStatementId())); + }); return flag && flagTwo && three; } @@ -208,11 +238,22 @@ public class BillManageDomainService { BillingStatementDO billingStatementDO = new BillingStatementDO(); billingStatementDO.setBillingStatementIdSet(billingSet); List billingStatementPOS = billingStatementDomainService.queryList(billingStatementDO); - + List billingStatementList = billingStatementDTO.getBillingStatementList(); + for (BillingStatementPO billingStatementPO : billingStatementPOS) { + Long billingStatementId = billingStatementPO.getBillingStatementId(); + BillingStatementADDVO billingStatementADDVO = billingStatementList.stream().filter(billingStatementADDVO1 -> billingStatementADDVO1.getBillingStatementId().equals(billingStatementId)).findFirst().orElse(null); + billingStatementPO.setTaxAmount(billingStatementADDVO.getTaxAmount()); // 设置税额 + billingStatementPO.setTaxRate(billingStatementADDVO.getTaxRate()); // 设置税率 + billingStatementPO.setTaxFreeFee(billingStatementADDVO.getTaxFreeFee()); // 设置税免金额 + billingStatementPO.setSettlementCurrency(billingStatementADDVO.getSettlementCurrency());//设置结算币种 + billingStatementPO.setFeeType(billingStatementADDVO.getFeeType()); + billingStatementPO.setInvoiceItem(billingStatementADDVO.getInvoiceItem()); + billingStatementPO.setInvoiceItemName(billingStatementADDVO.getInvoiceItemName()); + } if(billingStatementPOS==null || billingStatementPOS.size()==0){ throw new ServiceException("所选流水信息未找到"); } - return saveBill(billingStatementPOS,billingStatementDTO.getBillingRemark(),billingStatementDTO.getBillCreateTime()); + return saveBill(billingStatementPOS,billingStatementDTO.getBillingRemark(),billingStatementDTO.getBillCreateTime(),billingStatementDTO); } diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/entity/BillingStatement.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/entity/BillingStatement.java index 0fca54ae5..ccadc2fdf 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/entity/BillingStatement.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/entity/BillingStatement.java @@ -189,4 +189,18 @@ public class BillingStatement extends BaseVOEntity{ @ApiModelProperty("业务单据记录id") private Long businessDocumentId; -} + + @ApiModelProperty(value = "无税费用") + private BigDecimal taxFreeFee; + @ApiModelProperty(value = "税额") + private BigDecimal taxAmount; + @ApiModelProperty(value = "税率") + private Double taxRate; + @ApiModelProperty("结算币种") + private String settlementCurrency; + @ApiModelProperty("业务员ID") + private String salesmanId; + + @ApiModelProperty("业务员ID") + private String salesmanName; +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementADDVO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementADDVO.java new file mode 100644 index 000000000..786ed0c80 --- /dev/null +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementADDVO.java @@ -0,0 +1,57 @@ +package com.mhd.bms.domain.billingStatement.repository.po; + +import com.mhd.common.core.annotation.Excel; +import lombok.Data; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import com.mhd.common.core.web.domain.BaseVOEntity; + + +/** + * 计费流水对象 billing_statement + * + * @author gen + * @date 2024-06-26 + */ + +@Data +@ApiModel(value = "计费流水对象", description = "计费流水响应对象") +public class BillingStatementADDVO extends BaseVOEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("计费流水id") + private Long billingStatementId; + + @ApiModelProperty("结算对象") + @Excel(name = "结算对象") + private String settlementEntity; + + @ApiModelProperty("流水金额") + @Excel(name = "流水金额") + private BigDecimal billingAmount; + + @ApiModelProperty("费用总额") + private BigDecimal billingTotalAmount; + + @ApiModelProperty("账单优惠金额") + private BigDecimal billingDiscountAmount; + @ApiModelProperty(value = "无税费用") + private BigDecimal taxFreeFee; + @ApiModelProperty(value = "税额") + private BigDecimal taxAmount; + @ApiModelProperty(value = "税率") + private Double taxRate; + @ApiModelProperty("结算币种") + private String settlementCurrency; + + @ApiModelProperty(value = "开票项目") + private String invoiceItem; + @ApiModelProperty(value = "开票项目名称") + private String invoiceItemName; + @ApiModelProperty(value = "费用类别") + private String feeType; + +} \ No newline at end of file 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 dc94bc194..d14881c82 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 @@ -194,6 +194,25 @@ public class BillingStatementPO extends BaseVOEntity{ @ApiModelProperty("账单优惠金额") private BigDecimal billingDiscountAmount; + @ApiModelProperty(value = "无税费用") + private BigDecimal taxFreeFee; + @ApiModelProperty(value = "税额") + private BigDecimal taxAmount; + @ApiModelProperty(value = "税率") + private Double taxRate; + @ApiModelProperty("结算币种") + private String settlementCurrency; + @ApiModelProperty("业务员ID") + private String salesmanId; + @ApiModelProperty("业务员ID") + private String salesmanName; -} + @ApiModelProperty(value = "开票项目") + private String invoiceItem; + @ApiModelProperty(value = "开票项目名称") + private String invoiceItemName; + @ApiModelProperty(value = "费用类别") + private String feeType; + +} \ No newline at end of file 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 8bae187a7..b1d99c74b 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 @@ -221,4 +221,18 @@ public class BillingStatementDO extends BaseVOEntity{ @ApiModelProperty("业务单据记录id") private Long businessDocumentId; -} + + @ApiModelProperty(value = "无税费用") + private BigDecimal taxFreeFee; + @ApiModelProperty(value = "税额") + private BigDecimal taxAmount; + @ApiModelProperty(value = "税率") + private Double taxRate; + @ApiModelProperty("结算币种") + private String settlementCurrency; + @ApiModelProperty("业务员ID") + private String salesmanId; + + @ApiModelProperty("业务员ID") + private String salesmanName; +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/service/BillingStatementDomainService.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/service/BillingStatementDomainService.java index 34be902e5..0e91b484b 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/service/BillingStatementDomainService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/service/BillingStatementDomainService.java @@ -351,7 +351,7 @@ public class BillingStatementDomainService { final Date billCreateTime = billingStatementDTO.getBillCreateTime(); if(value.size()>0){ //生成账单 - billManageDomainService.saveBill(value,billingRemark,billCreateTime); + billManageDomainService.saveBill(value,billingRemark,billCreateTime,billingStatementDTO); } }); //修改流水状态 @@ -618,4 +618,4 @@ public class BillingStatementDomainService { public List comprehensiveList(QueryWrapper queryWrapper) { return billingStatementService.list(queryWrapper); } -} +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/persistence/BmsInvoiceListServiceImpl.java b/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/persistence/BmsInvoiceListServiceImpl.java index 5d81325a1..1b9a4cf00 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/persistence/BmsInvoiceListServiceImpl.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/persistence/BmsInvoiceListServiceImpl.java @@ -150,10 +150,10 @@ public class BmsInvoiceListServiceImpl extends ServiceImpl bmsMakeOutInvoiceList=bmsMakeOutInvoiceMapper.selectList(new QueryWrapper().lambda() .eq(BmsMakeOutInvoice::getInvoiceId,id) .eq(BmsMakeOutInvoice::getIsDelete,0)); + for (BmsMakeOutInvoice bmsMakeOutInvoice : bmsMakeOutInvoiceList) { + Long makeid = bmsMakeOutInvoice.getId(); + List bmsMakeOutInvoiceItemList = bmsMakeOutInvoiceItemMapper.selectList(new QueryWrapper().lambda().eq(BmsMakeOutInvoiceItem::getMakeId, makeid)); + bmsMakeOutInvoice.setBmsMakeOutInvoiceItems(bmsMakeOutInvoiceItemList); + } bmsInvoiceListDetailsVO.setBmsMakeOutInvoices(bmsMakeOutInvoiceList); return bmsInvoiceListDetailsVO; } @@ -337,25 +342,19 @@ public class BmsInvoiceListServiceImpl extends ServiceImpl bmsMakeOutInvoices = bmsInvoiceListInvoiceStateDTO.getTmsMakeOutInvoices(); + List bmsMakeOutInvoices = bmsInvoiceListInvoiceStateDTO.getBmsMakeOutInvoices(); if (bmsMakeOutInvoices == null) { throw new ServiceException("开票不得少于一张!"); } bmsInvoiceList.setInvoiceState(2); for (BmsMakeOutInvoice bmsMakeOutInvoice : bmsMakeOutInvoices) { - /* if(StringUtils.isBlank(bmsMakeOutInvoice.getInvoiceCode())){ - throw new ServiceException("所有发票的发票号码不得为空!"); - } - if(StringUtils.isBlank(bmsMakeOutInvoice.getInvoiceNumber())){ - throw new ServiceException("所有发票的发票号码不得为空!"); - }*/ + String invoiceNumber=bmsMakeOutInvoice.getInvoiceNumber(); String invoiceCode=bmsMakeOutInvoice.getInvoiceCode(); + String invoiceAbstract=bmsMakeOutInvoice.getInvoiceAbstract(); BigDecimal invoiceValue=bmsMakeOutInvoice.getInvoiceValue(); - BeanUtils.copyProperties(bmsInvoiceList, bmsMakeOutInvoice); - //bmsMakeOutInvoice.setId(""); - //bmsMakeOutInvoice.setCreateBy(sysUser.getId()); + BeanUtils.copyProperties(bmsInvoiceList, bmsMakeOutInvoice,"id"); bmsMakeOutInvoice.setCreateTime(date); bmsMakeOutInvoice.setInvoiceId(bmsInvoiceList.getId()); bmsMakeOutInvoice.setMakeOutInvoiceId(sysUser.getId()); @@ -363,7 +362,22 @@ public class BmsInvoiceListServiceImpl extends ServiceImpl bmsMakeOutInvoiceItems = bmsMakeOutInvoice.getBmsMakeOutInvoiceItems(); + if (bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0) { + bmsMakeOutInvoiceItemMapper.delete(new QueryWrapper().lambda().eq(BmsMakeOutInvoiceItem::getMakeId, bmsMakeOutInvoice.getId())); + for (BmsMakeOutInvoiceItem bmsMakeOutInvoiceItem : bmsMakeOutInvoiceItems) { + bmsMakeOutInvoiceItem.setMakeId(bmsMakeOutInvoice.getId()); + //bmsMakeOutInvoiceItem.setCreateBy(sysUser.getId()); + bmsMakeOutInvoiceItem.setCreateTime(date); + bmsMakeOutInvoiceItemMapper.insert(bmsMakeOutInvoiceItem); + } + } } Long id = bmsInvoiceList.getId(); List billManages = billManageMapper.selectList(new QueryWrapper().lambda().eq(BillManage::getInvoiceId, id.toString())); diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/todo/BmsInvoiceListAddDTO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/todo/BmsInvoiceListAddDTO.java index 9baf61bc8..21a481eb0 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/todo/BmsInvoiceListAddDTO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/todo/BmsInvoiceListAddDTO.java @@ -66,6 +66,10 @@ public class BmsInvoiceListAddDTO implements Serializable { @Excel(name = "对账单id", width = 15) private Long billManageId; + @ApiModelProperty(value = "对账单金额") + @Excel(name = "对账单金额", width = 15) + private BigDecimal billAmount; + private List bmsMakeOutInvoices; } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/todo/BmsInvoiceListInvoiceStateDTO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/todo/BmsInvoiceListInvoiceStateDTO.java index f3da65300..ede855125 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/todo/BmsInvoiceListInvoiceStateDTO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/bmsInvoiceList/repository/todo/BmsInvoiceListInvoiceStateDTO.java @@ -77,7 +77,7 @@ public class BmsInvoiceListInvoiceStateDTO implements Serializable { /**开票表集合*/ @ApiModelProperty(value = "开票表集合") @Excel(name = "开票表集合", width = 15) - private List tmsMakeOutInvoices; + private List bmsMakeOutInvoices; /**操作类型*/ @ApiModelProperty(value = "操作类型(取消申请-0,驳回-1)") @Excel(name = "操作类型(取消申请-0,驳回-1)", width = 15) diff --git a/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billManage/BillDetailDTO.java b/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billManage/BillDetailDTO.java index 97e4b3a9a..5d9446fc8 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billManage/BillDetailDTO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billManage/BillDetailDTO.java @@ -133,4 +133,10 @@ public class BillDetailDTO extends BaseVOEntity{ private Double taxRate; @ApiModelProperty("结算币种") private String settlementCurrency; + @ApiModelProperty(value = "开票项目") + private String invoiceItem; + @ApiModelProperty(value = "开票项目名称") + private String invoiceItemName; + @ApiModelProperty(value = "费用类别") + private String feeType; } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billManage/BillManageDTO.java b/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billManage/BillManageDTO.java index 25261eb0f..fd2a942f6 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billManage/BillManageDTO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billManage/BillManageDTO.java @@ -262,4 +262,9 @@ public class BillManageDTO extends BaseVOEntity{ private Double taxRate; @ApiModelProperty("结算币种") private String settlementCurrency; + @ApiModelProperty("业务员ID") + private String salesmanId; + + @ApiModelProperty("业务员ID") + private String salesmanName; } \ No newline at end of file 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 66b05f85b..7bf6860cb 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 @@ -1,5 +1,6 @@ package com.mhd.bms.interfaces.dto.billingStatement; +import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementADDVO; import com.mhd.common.core.annotation.Excel; import lombok.Data; import java.util.Date; @@ -227,4 +228,20 @@ public class BillingStatementDTO extends BaseVOEntity{ @ApiModelProperty("业务单据记录id") private Long businessDocumentId; -} + @ApiModelProperty(value = "无税费用") + private BigDecimal taxFreeFee; + @ApiModelProperty(value = "税额") + private BigDecimal taxAmount; + @ApiModelProperty(value = "税率") + private Double taxRate; + @ApiModelProperty("结算币种") + private String settlementCurrency; + + @ApiModelProperty("业务员ID") + private String salesmanId; + + @ApiModelProperty("业务员ID") + private String salesmanName; + private List billingStatementList; + +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/interfaces/facadeApi/BillManageApi.java b/mhd_bms/src/main/java/com/mhd/bms/interfaces/facadeApi/BillManageApi.java index 95434ccce..a9117b133 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/interfaces/facadeApi/BillManageApi.java +++ b/mhd_bms/src/main/java/com/mhd/bms/interfaces/facadeApi/BillManageApi.java @@ -298,10 +298,10 @@ public class BillManageApi extends BaseController{ @Log(title = "应收账单应收单同步用户nc65", description = "应收账单应收单同步用户nc65", businessType = BusinessType.OTHER) @ApiOperation("应收账单应收单同步用户nc65") @GetMapping(value = "/synchronousNc") - public AjaxResult synchronousNc(@RequestParam(name="reconciliationId") String reconciliationId) + public AjaxResult synchronousNc(@RequestParam(name="billManageId") String billManageId) { try{ - return AjaxResult.success(billManageApplicationService.synchronousNc(reconciliationId));} + return AjaxResult.success(billManageApplicationService.synchronousNc(billManageId));} catch (Exception e){ e.printStackTrace(); return AjaxResult.error(e.getMessage()); @@ -314,10 +314,10 @@ public class BillManageApi extends BaseController{ @Log(title = "应收账单收款单同步用户nc65", description = "应收账单收款单同步用户nc65", businessType = BusinessType.OTHER) @ApiOperation("应收账单收款单同步用户nc65") @GetMapping(value = "/synchronousNcSK") - public AjaxResult synchronousNcSK(@RequestParam(name="reconciliationId") String reconciliationId) + public AjaxResult synchronousNcSK(@RequestParam(name="billManageId") String billManageId) { try{ - return AjaxResult.success(billManageApplicationService.synchronousNcSK(reconciliationId)); + return AjaxResult.success(billManageApplicationService.synchronousNcSK(billManageId)); } catch (Exception e){ e.printStackTrace(); return AjaxResult.error(e.getMessage()); diff --git a/mhd_bms/src/main/resources/mapper/BillManageMapper.xml b/mhd_bms/src/main/resources/mapper/BillManageMapper.xml index 41151bcaf..24eaa4cc2 100644 --- a/mhd_bms/src/main/resources/mapper/BillManageMapper.xml +++ b/mhd_bms/src/main/resources/mapper/BillManageMapper.xml @@ -79,4 +79,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + + \ No newline at end of file diff --git a/mhd_finance/src/main/java/com/linke/finance/domain/reconciliation/repository/mapper/ReconciliationMapper.java b/mhd_finance/src/main/java/com/linke/finance/domain/reconciliation/repository/mapper/ReconciliationMapper.java index 22fe00328..bb185391f 100644 --- a/mhd_finance/src/main/java/com/linke/finance/domain/reconciliation/repository/mapper/ReconciliationMapper.java +++ b/mhd_finance/src/main/java/com/linke/finance/domain/reconciliation/repository/mapper/ReconciliationMapper.java @@ -42,4 +42,6 @@ public interface ReconciliationMapper extends BaseMapper String getDocumentPreparerNcCode(@Param("salesmanId") String salesmanId); String getSettlementCurrencyNcCode(@Param("settlementCurrency") String settlementCurrency); + + String getServiceItemsCodeNc(@Param("name") String name); } \ No newline at end of file diff --git a/mhd_finance/src/main/java/com/linke/finance/domain/reconciliation/repository/persistence/ReconciliationImpl.java b/mhd_finance/src/main/java/com/linke/finance/domain/reconciliation/repository/persistence/ReconciliationImpl.java index f050c2dc3..cd680ab89 100644 --- a/mhd_finance/src/main/java/com/linke/finance/domain/reconciliation/repository/persistence/ReconciliationImpl.java +++ b/mhd_finance/src/main/java/com/linke/finance/domain/reconciliation/repository/persistence/ReconciliationImpl.java @@ -721,6 +721,7 @@ public class ReconciliationImpl extends ServiceImpl SELECT NC_SYSTEM_CODE FROM NGWL_TEST_WLHY."TMS_SETTLEMENT_EXCHANGE_RATE" where IS_DELETE = '0' and ENGLISH_NAME = #{settlementCurrency} limit 1 + + \ No newline at end of file