| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.sales.dto.InvoiceLedgerDto; |
| | | import com.ruoyi.sales.dto.InvoiceRegistrationDto; |
| | | import com.ruoyi.sales.dto.InvoiceRegistrationProductDto; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import com.ruoyi.sales.excel.InvoiceRegisAndProductExcelDto; |
| | | import com.ruoyi.sales.excel.InvoiceRegistrationExportVo; |
| | | import com.ruoyi.sales.mapper.*; |
| | | import com.ruoyi.sales.pojo.InvoiceLedger; |
| | | import com.ruoyi.sales.pojo.InvoiceRegistration; |
| | | import com.ruoyi.sales.pojo.InvoiceRegistrationProduct; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.service.InvoiceRegistrationService; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | |
| | | @Autowired |
| | | private InvoiceLedgerMapper invoiceLedgerMapper; |
| | | |
| | | @Autowired |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | |
| | | /** |
| | | * 开票登记记录新增 |
| | |
| | | for (SalesLedgerProduct productDatum : productData) { |
| | | // 如果开票数为0 跳过 |
| | | BigDecimal currentInvoiceNum = productDatum.getCurrentInvoiceNum(); |
| | | if(null != currentInvoiceNum && BigDecimal.ZERO.compareTo(currentInvoiceNum) == 0){ |
| | | if(null == currentInvoiceNum || BigDecimal.ZERO.compareTo(currentInvoiceNum) == 0){ |
| | | continue; |
| | | } |
| | | invoiceAmountTotal = invoiceAmountTotal.add(currentInvoiceNum); |
| | |
| | | |
| | | /** |
| | | * 开票登记导出 |
| | | * 导出列:销售合同号、客户合同号、客户名称、合同金额、已开票金额、未开票金额 |
| | | * 已开票/未开票金额口径与 /sales/ledger/listPage 页面一致 |
| | | * @param response |
| | | * @param invoiceRegistrationDto |
| | | * @param salesLedgerDto |
| | | */ |
| | | @Override |
| | | public void invoiceRegistrationExport(HttpServletResponse response, InvoiceRegistrationDto invoiceRegistrationDto) { |
| | | List<InvoiceRegisAndProductExcelDto> invoiceRegisAndProductExcelDtoList = invoiceRegistrationMapper.invoiceRegisAndProductExcelDtoList(); |
| | | ExcelUtil<InvoiceRegisAndProductExcelDto> util = new ExcelUtil<InvoiceRegisAndProductExcelDto>(InvoiceRegisAndProductExcelDto.class); |
| | | util.exportExcel(response, invoiceRegisAndProductExcelDtoList, "开票登记信息"); |
| | | public void invoiceRegistrationExport(HttpServletResponse response, SalesLedgerDto salesLedgerDto) { |
| | | Page page = new Page(); |
| | | page.setCurrent(-1); |
| | | page.setSize(-1); |
| | | IPage<SalesLedger> iPage = salesLedgerMapper.selectSalesLedgerListPage(page, salesLedgerDto); |
| | | List<SalesLedger> records = iPage.getRecords(); |
| | | |
| | | // 按销售台账汇总已开票金额 |
| | | Map<Integer, BigDecimal> invoicedMap = new HashMap<>(); |
| | | List<Long> salesLedgerIds = records.stream().map(SalesLedger::getId).collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(salesLedgerIds)) { |
| | | List<InvoiceLedgerDto> invoiceLedgerDtoList = invoiceLedgerMapper.invoicedTotal(salesLedgerIds); |
| | | for (InvoiceLedgerDto invoiceLedgerDto : invoiceLedgerDtoList) { |
| | | invoicedMap.put(invoiceLedgerDto.getSalesLedgerId(), invoiceLedgerDto.getInvoiceTotal()); |
| | | } |
| | | } |
| | | |
| | | List<InvoiceRegistrationExportVo> exportList = new ArrayList<>(); |
| | | for (SalesLedger record : records) { |
| | | BigDecimal contractAmount = record.getContractAmount() == null ? BigDecimal.ZERO : record.getContractAmount(); |
| | | BigDecimal invoiceTotal = invoicedMap.getOrDefault(record.getId().intValue(), BigDecimal.ZERO); |
| | | BigDecimal noInvoiceAmountTotal = contractAmount.subtract(invoiceTotal); |
| | | InvoiceRegistrationExportVo exportVo = new InvoiceRegistrationExportVo(); |
| | | exportVo.setSalesContractNo(record.getSalesContractNo()); |
| | | exportVo.setCustomerContractNo(record.getCustomerContractNo()); |
| | | exportVo.setCustomerName(record.getCustomerName()); |
| | | exportVo.setContractAmount(contractAmount); |
| | | exportVo.setInvoiceTotal(invoiceTotal); |
| | | exportVo.setNoInvoiceAmountTotal(noInvoiceAmountTotal); |
| | | exportList.add(exportVo); |
| | | } |
| | | ExcelUtil<InvoiceRegistrationExportVo> util = new ExcelUtil<InvoiceRegistrationExportVo>(InvoiceRegistrationExportVo.class); |
| | | util.exportExcel(response, exportList, "开票登记信息"); |
| | | } |
| | | } |