From 18fa07479d3c7f5a9b683ab0f698528d9bd2a9ec Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 21 四月 2026 11:23:53 +0800
Subject: [PATCH] feat: 入库管理、出库台账增加合同号字段;支持合同模糊查询
---
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java | 228 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 191 insertions(+), 37 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
index 5ac4159..807aeaf 100644
--- a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
+++ b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -2,26 +2,38 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
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;
import com.ruoyi.framework.web.controller.BaseController;
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.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;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.math.BigDecimal;
-import java.util.List;
+import java.net.URLEncoder;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -33,6 +45,8 @@
@RestController
@RequestMapping("/sales/ledger")
@AllArgsConstructor
+@Api(tags = "閿�鍞彴璐�")
+@Slf4j
public class SalesLedgerController extends BaseController {
private ISalesLedgerService salesLedgerService;
@@ -43,19 +57,70 @@
private InvoiceLedgerMapper invoiceLedgerMapper;
/**
+ * 瀵煎叆閿�鍞彴璐�
+ */
+ @Log(title = "瀵煎叆閿�鍞彴璐�", businessType = BusinessType.INSERT)
+ @PostMapping("/import")
+ @ApiOperation("瀵煎叆閿�鍞彴璐�")
+ public AjaxResult importData(@RequestParam("file")
+ @ApiParam(value = "Excel鏂囦欢", required = true)
+ MultipartFile file) {
+ salesLedgerService.importData(file);
+ return AjaxResult.success();
+ }
+
+ @ApiOperation("瀵煎嚭閿�鍞彴璐︽ā鏉�")
+ @PostMapping("/exportTemplate")
+ public void exportTemplate(HttpServletResponse response) {
+ // 1. 妯℃澘鏂囦欢鍦╮esources/static涓嬬殑璺緞
+ String templatePath = "static/閿�鍞彴璐﹀鍏ユā鏉�.xlsx";
+
+ // 2. 鑾峰彇妯℃澘鏂囦欢鐨勮緭鍏ユ祦
+ try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(templatePath)) {
+ if (inputStream == null) {
+ throw new FileNotFoundException("妯℃澘鏂囦欢涓嶅瓨鍦細" + templatePath);
+ }
+
+ // 3. 璁剧疆鍝嶅簲澶达紝瑙﹀彂娴忚鍣ㄤ笅杞�
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setCharacterEncoding("utf-8");
+ String fileName = URLEncoder.encode("閿�鍞彴璐﹀鍏ユā鏉�.xlsx", "utf-8").replaceAll("\\+", "%20");
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName);
+
+ // 4. 灏嗘ā鏉挎枃浠跺啓鍏ュ搷搴旇緭鍑烘祦
+ try (OutputStream outputStream = response.getOutputStream()) {
+ byte[] buffer = new byte[1024];
+ int len;
+ while ((len = inputStream.read(buffer)) > 0) {
+ outputStream.write(buffer, 0, len);
+ }
+ outputStream.flush();
+ }
+ } catch (IOException e) {
+ log.error("瀵煎嚭閿�鍞彴璐︽ā鏉垮け璐�", e);
+ // 鑻ユā鏉挎枃浠惰鍙栧け璐ワ紝杩斿洖閿欒鎻愮ず
+ try {
+ response.getWriter().write("妯℃澘瀵煎嚭澶辫触锛�" + e.getMessage());
+ } catch (IOException ex) {
+ log.error("鍝嶅簲杈撳嚭閿欒", ex);
+ }
+ }
+ }
+
+ /**
* 鏌ヨ閿�鍞彴璐﹀垪琛�
*/
@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) {
@@ -66,6 +131,7 @@
}
}
}
+
return getDataTable(list);
}
@@ -83,9 +149,29 @@
@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, "閿�鍞彴璐︽暟鎹�");
+ }
+
+ /**
+ * 瀵煎嚭寮�绁ㄧ櫥璁板垪琛�
+ */
+ @Log(title = "瀵煎嚭寮�绁ㄧ櫥璁板垪琛�", businessType = BusinessType.EXPORT)
+ @PostMapping("/exportOne")
+ public void exportOne(HttpServletResponse response, SalesLedgerDto salesLedgerDto) {
+ Page<?> page = new Page<>();
+ page.setCurrent(-1);
+ page.setSize(-1);
+ IPage<SalesLedger> salesLedgerIPage = listPage(page, salesLedgerDto);
+ ExcelUtil<SalesLedger> util = new ExcelUtil<SalesLedger>(SalesLedger.class);
+ util.exportExcel(response, salesLedgerIPage == null ? new ArrayList<>() : salesLedgerIPage.getRecords(), "瀵煎嚭寮�绁ㄧ櫥璁板垪琛�");
}
/**
@@ -95,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();
}
/**
@@ -158,41 +254,99 @@
* 杩戝崐骞村紑绁�,鍥炴閲戦
*/
@GetMapping("/getAmountHalfYear")
- public AjaxResult getAmountHalfYear() {
- return AjaxResult.success(salesLedgerService.getAmountHalfYear());
+ public AjaxResult getAmountHalfYear(@RequestParam(value = "type", defaultValue = "1") Integer type) {
+ return AjaxResult.success(salesLedgerService.getAmountHalfYear(type));
}
/**
* 鏌ヨ閿�鍞彴璐﹀垪琛�
*/
@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;
- }
- for (SalesLedger salesLedger : iPage.getRecords()) {
- boolean existFlag = false;
- BigDecimal noInvoiceAmountTotal = BigDecimal.ZERO;
- for (InvoiceLedgerDto invoiceLedgerDto : invoiceLedgerDtoList) {
- if (salesLedger.getId().intValue() == invoiceLedgerDto.getSalesLedgerId()) {
- noInvoiceAmountTotal = salesLedger.getContractAmount().subtract(invoiceLedgerDto.getInvoiceTotal());
- existFlag = true;
- break;
- }
- }
- if(existFlag){
- salesLedger.setNoInvoiceAmountTotal(noInvoiceAmountTotal);
- }else {
- salesLedger.setNoInvoiceAmountTotal(salesLedger.getContractAmount());
- }
- }
- return iPage;
+ public IPage<SalesLedger> listPage(Page<?> page, SalesLedgerDto salesLedgerDto) {
+ return salesLedgerService.selectSalesLedgerListPage(page, salesLedgerDto);
}
+
+ @ApiOperation("鏌ヨ閿�鍞彴璐︽秷鑰楃墿鏂欎俊鎭�")
+ @GetMapping("/getSalesLedgerWithProductsLoss")
+ 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