From f32de021e7af1627b6d18e681b46dbc0a5b108f8 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 21 四月 2026 13:33:04 +0800
Subject: [PATCH] feat: 设备台账与工序进行绑定
---
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java | 203 +++++++++++++++++++++++++++-----------------------
1 files changed, 108 insertions(+), 95 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
index 46d3d48..807aeaf 100644
--- a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
+++ b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -1,9 +1,8 @@
package com.ruoyi.sales.controller;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
@@ -11,15 +10,10 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.framework.web.page.TableDataInfo;
-import com.ruoyi.sales.dto.InvoiceLedgerDto;
-import com.ruoyi.sales.dto.SalesLedgerDto;
+import com.ruoyi.sales.dto.*;
import com.ruoyi.sales.mapper.InvoiceLedgerMapper;
-import com.ruoyi.sales.mapper.InvoiceRegistrationProductMapper;
-import com.ruoyi.sales.mapper.ReceiptPaymentMapper;
-import com.ruoyi.sales.pojo.InvoiceLedger;
-import com.ruoyi.sales.pojo.InvoiceRegistrationProduct;
-import com.ruoyi.sales.pojo.ReceiptPayment;
import com.ruoyi.sales.pojo.SalesLedger;
+import com.ruoyi.sales.pojo.SalesLedgerProcessRoute;
import com.ruoyi.sales.service.ICommonFileService;
import com.ruoyi.sales.service.ISalesLedgerService;
import io.swagger.annotations.Api;
@@ -39,10 +33,7 @@
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -65,12 +56,6 @@
@Autowired
private InvoiceLedgerMapper invoiceLedgerMapper;
- @Autowired
- private InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
-
- @Autowired
- private ReceiptPaymentMapper receiptPaymentMapper;
-
/**
* 瀵煎叆閿�鍞彴璐�
*/
@@ -80,7 +65,8 @@
public AjaxResult importData(@RequestParam("file")
@ApiParam(value = "Excel鏂囦欢", required = true)
MultipartFile file) {
- return salesLedgerService.importData(file);
+ salesLedgerService.importData(file);
+ return AjaxResult.success();
}
@ApiOperation("瀵煎嚭閿�鍞彴璐︽ā鏉�")
@@ -125,16 +111,16 @@
* 鏌ヨ閿�鍞彴璐﹀垪琛�
*/
@GetMapping("/list")
- public TableDataInfo list(Page page, SalesLedgerDto salesLedgerDto) {
+ public TableDataInfo list(Page<?> page, SalesLedgerDto salesLedgerDto) {
startPage();
List<SalesLedger> list = salesLedgerService.selectSalesLedgerList(salesLedgerDto);
// 璁$畻宸插紑绁ㄩ噾棰�/鏈紑绁ㄩ噾棰�(宸插~鍐欏彂绁ㄩ噾棰濅负鍑�)
- if(CollectionUtils.isEmpty(list)){
+ if (CollectionUtils.isEmpty(list)) {
return getDataTable(list);
}
List<Long> salesLedgerIds = list.stream().map(SalesLedger::getId).collect(Collectors.toList());
List<InvoiceLedgerDto> invoiceLedgerDtoList = invoiceLedgerMapper.invoicedTotal(salesLedgerIds);
- if(CollectionUtils.isEmpty(invoiceLedgerDtoList)){
+ if (CollectionUtils.isEmpty(invoiceLedgerDtoList)) {
return getDataTable(list);
}
for (SalesLedger salesLedger : list) {
@@ -163,8 +149,14 @@
@Log(title = "閿�鍞彴璐�", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SalesLedgerDto salesLedgerDto) {
- List<SalesLedger> list = salesLedgerService.selectSalesLedgerList(salesLedgerDto);
+ Page<?> page = new Page<>(-1, -1);
+ IPage<SalesLedger> salesLedgerIPage = listPage(page, salesLedgerDto);
ExcelUtil<SalesLedger> util = new ExcelUtil<SalesLedger>(SalesLedger.class);
+ if (salesLedgerIPage == null) {
+ util.exportExcel(response, new ArrayList<>(), "閿�鍞彴璐︽暟鎹�");
+ return;
+ }
+ List<SalesLedger> list = salesLedgerIPage.getRecords();
util.exportExcel(response, list, "閿�鍞彴璐︽暟鎹�");
}
@@ -174,7 +166,7 @@
@Log(title = "瀵煎嚭寮�绁ㄧ櫥璁板垪琛�", businessType = BusinessType.EXPORT)
@PostMapping("/exportOne")
public void exportOne(HttpServletResponse response, SalesLedgerDto salesLedgerDto) {
- Page page = new Page();
+ Page<?> page = new Page<>();
page.setCurrent(-1);
page.setSize(-1);
IPage<SalesLedger> salesLedgerIPage = listPage(page, salesLedgerDto);
@@ -189,6 +181,16 @@
@PostMapping("/addOrUpdateSalesLedger")
public AjaxResult add(@RequestBody SalesLedgerDto salesLedgerDto) {
return toAjax(salesLedgerService.addOrUpdateSalesLedger(salesLedgerDto));
+ }
+
+ /**
+ * 閿�鍞鍗曠粦瀹氬伐鑹鸿矾绾�
+ */
+ @PostMapping("/saleProcessBind")
+ @ApiOperation("閿�鍞鍗曠粦瀹氬伐鑹鸿矾绾�")
+ public AjaxResult saleProcessBind(@RequestBody SalesLedgerProcessRoute salesLedgerProcessRoute) {
+ salesLedgerService.saleProcessBind(salesLedgerProcessRoute);
+ return AjaxResult.success();
}
/**
@@ -252,7 +254,7 @@
* 杩戝崐骞村紑绁�,鍥炴閲戦
*/
@GetMapping("/getAmountHalfYear")
- public AjaxResult getAmountHalfYear(@RequestParam(value = "type",defaultValue = "1") Integer type) {
+ public AjaxResult getAmountHalfYear(@RequestParam(value = "type", defaultValue = "1") Integer type) {
return AjaxResult.success(salesLedgerService.getAmountHalfYear(type));
}
@@ -260,75 +262,8 @@
* 鏌ヨ閿�鍞彴璐﹀垪琛�
*/
@GetMapping("/listPage")
- public IPage<SalesLedger> listPage(Page page, SalesLedgerDto salesLedgerDto) {
- IPage<SalesLedger> iPage = salesLedgerService.selectSalesLedgerListPage(page,salesLedgerDto);
- // 璁$畻宸插紑绁ㄩ噾棰�/鏈紑绁ㄩ噾棰�(宸插~鍐欏彂绁ㄩ噾棰濅负鍑�)
- if(CollectionUtils.isEmpty(iPage.getRecords())){
- return iPage;
- }
- List<Long> salesLedgerIds = iPage.getRecords().stream().map(SalesLedger::getId).collect(Collectors.toList());
- List<InvoiceLedgerDto> invoiceLedgerDtoList = invoiceLedgerMapper.invoicedTotal(salesLedgerIds);
- if(CollectionUtils.isEmpty(invoiceLedgerDtoList)){
- return iPage;
- }
- // 璁$畻鍥炴閲戦锛屽緟鍥炴閲戦
- List<InvoiceRegistrationProduct> invoiceRegistrationProducts = invoiceRegistrationProductMapper.selectList(new LambdaQueryWrapper<InvoiceRegistrationProduct>()
- .in(InvoiceRegistrationProduct::getSalesLedgerId, salesLedgerIds));
-
- List<InvoiceLedger> invoiceLedgers = invoiceLedgerMapper.selectList(new LambdaQueryWrapper<InvoiceLedger>()
- .in(InvoiceLedger::getInvoiceRegistrationProductId, invoiceRegistrationProducts.stream().map(InvoiceRegistrationProduct::getId).collect(Collectors.toList())));
- List<ReceiptPayment> receiptPayments = new ArrayList<>();
- if(!CollectionUtils.isEmpty(invoiceLedgers)){
- receiptPayments = receiptPaymentMapper.selectList(new LambdaQueryWrapper<ReceiptPayment>()
- .in(ReceiptPayment::getInvoiceLedgerId, invoiceLedgers.stream().map(InvoiceLedger::getId).collect(Collectors.toList())));
- }
- for (SalesLedger salesLedger : iPage.getRecords()) {
- boolean existFlag = false;
- BigDecimal noInvoiceAmountTotal = BigDecimal.ZERO;
- BigDecimal invoiceTotal = BigDecimal.ZERO;
- for (InvoiceLedgerDto invoiceLedgerDto : invoiceLedgerDtoList) {
- if (salesLedger.getId().intValue() == invoiceLedgerDto.getSalesLedgerId()) {
- noInvoiceAmountTotal = salesLedger.getContractAmount().subtract(invoiceLedgerDto.getInvoiceTotal());
- invoiceTotal = invoiceLedgerDto.getInvoiceTotal();
- existFlag = true;
- if(!CollectionUtils.isEmpty(receiptPayments)){
- List<InvoiceRegistrationProduct> collect = invoiceRegistrationProducts.stream()
- .filter(item -> salesLedger.getId().equals(Long.parseLong(item.getSalesLedgerId().toString())))
- .collect(Collectors.toList());
- List<Integer> collect1 = collect.stream()
- .map(InvoiceRegistrationProduct::getId).collect(Collectors.toList());
- List<InvoiceLedger> collect2 = invoiceLedgers.stream()
- .filter(item -> collect1.contains(item.getInvoiceRegistrationProductId()))
- .collect(Collectors.toList());
- // 鑾峰彇宸插洖娆鹃噾棰�
- List<ReceiptPayment> collect3 = receiptPayments.stream()
- .filter(item -> collect2.stream().anyMatch(item1 -> item1.getId().equals(item.getInvoiceLedgerId())))
- .collect(Collectors.toList());
- BigDecimal receiptPaymentAmountTotal = collect3.stream().map(ReceiptPayment::getReceiptPaymentAmount)
- .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
- // 鑾峰彇寰呭洖娆鹃噾棰�
- BigDecimal noReceiptPaymentAmountTotal = invoiceLedgerDto.getInvoiceTotal().subtract(receiptPaymentAmountTotal);
- salesLedger.setReceiptPaymentAmountTotal(receiptPaymentAmountTotal);
- salesLedger.setNoReceiptAmount(noReceiptPaymentAmountTotal);
- }
- break;
- }
- }
- if(existFlag){
- salesLedger.setNoInvoiceAmountTotal(noInvoiceAmountTotal);
- }else {
- salesLedger.setNoInvoiceAmountTotal(salesLedger.getContractAmount());
- }
- salesLedger.setInvoiceTotal(invoiceTotal);
- }
- if (ObjectUtils.isNotEmpty(salesLedgerDto.getStatus())) {
- if (salesLedgerDto.getStatus()) {
- iPage.getRecords().removeIf(salesLedger -> Objects.equals(salesLedger.getNoInvoiceAmountTotal(), new BigDecimal("0.00")));
- iPage.setTotal(iPage.getRecords().size());
- }
- }
-
- return iPage;
+ public IPage<SalesLedger> listPage(Page<?> page, SalesLedgerDto salesLedgerDto) {
+ return salesLedgerService.selectSalesLedgerListPage(page, salesLedgerDto);
}
@ApiOperation("鏌ヨ閿�鍞彴璐︽秷鑰楃墿鏂欎俊鎭�")
@@ -336,4 +271,82 @@
public R getSalesLedgerWithProductsLoss(Long salesLedgerId) {
return R.ok(salesLedgerService.getSalesLedgerWithProductsLoss(salesLedgerId));
}
+
+ @ApiOperation("鑾峰彇閿�鍞鍗曠粦瀹氱殑宸ヨ壓璺嚎")
+ @GetMapping("/salesProcess/{salesLedgerId}")
+ public AjaxResult salesProcess(@PathVariable Long salesLedgerId) {
+ SalesLedgerProcessRouteDto dto = salesLedgerService.salesProcess(salesLedgerId);
+ return AjaxResult.success(dto);
+ }
+
+ @GetMapping("/processCard/{salesLedgerId}")
+ @ApiOperation("鎵撳嵃鐢熶骇娴佺▼鍗�")
+ public AjaxResult processCard(@PathVariable Long salesLedgerId) {
+ SalesProcessCardDto dto = salesLedgerService.processCard(salesLedgerId);
+ return AjaxResult.success(dto);
+ }
+
+ @GetMapping("/salesOrders/{salesLedgerId}")
+ @ApiOperation("鎵撳嵃閿�鍞鍗�")
+ public AjaxResult salesOrders(@PathVariable Long salesLedgerId) {
+ SalesOrdersDto salesOrdersDto = salesLedgerService.salesOrders(salesLedgerId);
+ return AjaxResult.success(salesOrdersDto);
+ }
+
+ @PostMapping("/salesInvoices")
+ @ApiOperation("鎵撳嵃閿�鍞彂璐у崟")
+ public AjaxResult salesInvoices(@RequestBody List<Long> salesLedgerIds) {
+ SalesInvoicesDto dto = salesLedgerService.salesInvoices(salesLedgerIds);
+ return AjaxResult.success(dto);
+ }
+
+ @GetMapping("/salesLabel/{salesLedgerId}")
+ @ApiOperation("鎵撳嵃璁㈠崟鏍囩")
+ public AjaxResult salesLabel(@PathVariable Long salesLedgerId) {
+ List<SalesLabelDto> list = salesLedgerService.salesLabel(salesLedgerId);
+ return AjaxResult.success(list);
+ }
+
+ @PostMapping("/salesStock")
+ @ApiOperation("閿�鍞彴璐︿骇鍝佸叆搴�")
+ public AjaxResult salesStock(@RequestBody SalesProductStockDto dto) {
+ salesLedgerService.salesStock(dto);
+ return AjaxResult.success();
+ }
+
+ @GetMapping("/shippedCustomers")
+ @ApiOperation("宸插彂璐у鎴峰悕鍗�")
+ public AjaxResult shippedCustomers() {
+ List<Customer> list = salesLedgerService.shippedCustomers();
+ return AjaxResult.success(list);
+ }
+
+ @PostMapping("/scanInbound")
+ @ApiOperation("閿�鍞鍗曟壂鐮�-鍚堟牸鍏ュ簱")
+ public AjaxResult scanInbound(@RequestBody SalesScanInboundDto dto) {
+ salesLedgerService.scanInbound(dto);
+ return AjaxResult.success();
+ }
+
+ @PostMapping("/scanInboundUnqualified")
+ @ApiOperation("閿�鍞鍗曟壂鐮�-涓嶅悎鏍煎叆搴�")
+ public AjaxResult scanInboundUnqualified(@RequestBody SalesScanInboundDto dto) {
+ salesLedgerService.scanInboundUnqualified(dto);
+ return AjaxResult.success();
+ }
+
+ @PostMapping("/scanOutbound")
+ @ApiOperation("閿�鍞鍗曟壂鐮�-鍚堟牸鍑哄簱")
+ public AjaxResult scanOutbound(@RequestBody SalesScanInboundDto dto) {
+ salesLedgerService.scanOutbound(dto);
+ return AjaxResult.success();
+ }
+
+ @PostMapping("/scanOutboundUnqualified")
+ @ApiOperation("閿�鍞鍗曟壂鐮�-涓嶅悎鏍煎嚭搴�")
+ public AjaxResult scanOutboundUnqualified(@RequestBody SalesScanInboundDto dto) {
+ salesLedgerService.scanOutboundUnqualified(dto);
+ return AjaxResult.success();
+ }
+
}
--
Gitblit v1.9.3