From 5c1a58d067512df6099f9cc95f577c9991128163 Mon Sep 17 00:00:00 2001
From: lishenao <3065849776@qq.com>
Date: 星期一, 30 六月 2025 15:16:09 +0800
Subject: [PATCH] 入库管理,出库管理,库存管理后端接口

---
 src/main/java/com/ruoyi/inventory/service/impl/StockInServiceImpl.java         |  117 ++++
 src/main/java/com/ruoyi/inventory/excel/StockInExcelDto.java                   |   35 +
 src/main/resources/mapper/inventory/StockManagementMapper.xml                  |  149 ++---
 src/main/java/com/ruoyi/inventory/dto/StockManagementDto.java                  |   36 +
 src/main/java/com/ruoyi/inventory/mapper/StockManagementMapper.java            |   24 
 src/main/java/com/ruoyi/inventory/service/impl/StockOutServiceImpl.java        |   79 ++
 src/main/resources/mapper/inventory/StockOutMapper.xml                         |  168 ++----
 src/main/java/com/ruoyi/inventory/mapper/StockOutMapper.java                   |   22 
 src/main/java/com/ruoyi/inventory/dto/StockinDto.java                          |   52 ++
 src/main/java/com/ruoyi/inventory/pojo/StockOut.java                           |   29 
 src/main/java/com/ruoyi/inventory/excel/StockManagementExcelDto.java           |   39 +
 src/main/java/com/ruoyi/inventory/excel/StockOutExcelDto.java                  |   33 +
 src/main/java/com/ruoyi/inventory/service/impl/StockManagementServiceImpl.java |   49 +
 src/main/java/com/ruoyi/inventory/mapper/StockInMapper.java                    |   23 
 src/main/java/com/ruoyi/inventory/service/StockManagementService.java          |   18 
 src/main/java/com/ruoyi/inventory/controller/StockInController.java            |   74 +-
 src/main/java/com/ruoyi/inventory/service/StockInService.java                  |   21 
 src/main/java/com/ruoyi/inventory/dto/StockoutDto.java                         |   38 +
 src/main/resources/mapper/inventory/StockInMapper.xml                          |  220 ++++----
 src/main/java/com/ruoyi/inventory/pojo/StockManagement.java                    |   35 
 src/main/java/com/ruoyi/inventory/service/StockOutService.java                 |   16 
 src/main/java/com/ruoyi/inventory/controller/StockManagementController.java    |   64 +-
 src/main/java/com/ruoyi/inventory/pojo/StockIn.java                            |   49 -
 src/main/java/com/ruoyi/inventory/controller/StockOutController.java           |   61 +-
 24 files changed, 903 insertions(+), 548 deletions(-)

diff --git a/src/main/java/com/ruoyi/inventory/controller/StockInController.java b/src/main/java/com/ruoyi/inventory/controller/StockInController.java
index 3f01298..b205053 100644
--- a/src/main/java/com/ruoyi/inventory/controller/StockInController.java
+++ b/src/main/java/com/ruoyi/inventory/controller/StockInController.java
@@ -1,64 +1,66 @@
 package com.ruoyi.inventory.controller;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.pojo.Customer;
+import com.ruoyi.basic.pojo.SupplierManage;
 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.inventory.dto.StockinDto;
+import com.ruoyi.inventory.excel.StockInExcelDto;
 import com.ruoyi.inventory.service.StockInService;
 import com.ruoyi.inventory.pojo.StockIn;
+import com.ruoyi.purchase.dto.PurchaseLedgerDto;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.Date;
 import java.util.List;
 
 @RestController
 @RequestMapping("/stockin")
-public class StockInController extends BaseController {
+public class StockInController{
     @Autowired
     private StockInService stockInService;
 
-    @PostMapping("/add")// 鏂板鍏ュ簱璁板綍
-    public AjaxResult addStockIn(@RequestBody StockIn stockIn) {
-        int i = stockInService.addStockIn(stockIn);
-        if(i>0){
-            return success();
-        }
-        return error();
+    @GetMapping("/listPage")
+    public AjaxResult listPage(Page page, StockinDto stockinDto) {
+        return AjaxResult.success(stockInService.selectStockInPage(page,stockinDto));
     }
-    @GetMapping("/list")// 鍒楀嚭鎵�鏈夊叆搴撹褰�
-    public AjaxResult listStockIns() {
-        List<StockIn> stockIns = stockInService.listStockIns();
-        return success(stockIns);
+
+    @PostMapping("/add")
+    public AjaxResult add(@RequestBody StockIn stockIn) {
+        stockInService.saveStockin(stockIn);
+        return AjaxResult.success();
     }
+
     @GetMapping("/{id}")// 鏍规嵁ID鑾峰彇鍏ュ簱璁板綍
     public AjaxResult getStockInById(@PathVariable Long id) {
         StockIn stockIn = stockInService.getStockInById(id);
-        return success(stockIn);
+        return AjaxResult.success(stockIn);
     }
     @PutMapping("/update")// 鏇存柊鍏ュ簱璁板綍
     public AjaxResult updateStockIn(@RequestBody StockIn stockIn) {
-        int i = stockInService.updateStockIn(stockIn);
-        if(i>0){
-            return success();
-        }
-        return error();
-    }
-    @DeleteMapping("/delete/{id}")// 鍒犻櫎鍏ュ簱璁板綍
-    public AjaxResult deleteStockIn(@PathVariable Long id) {
-        int i = stockInService.deleteStockIn(id);
-        if(i>0){
-            return success();
-        }
-        return error();
-    }
-//    @Log(title = "宀椾綅绠$悊", businessType = BusinessType.EXPORT)
-//    @PreAuthorize("@ss.hasPermi('system:post:export')")
-    @GetMapping("/export")// 瀵煎嚭鍏ュ簱鏁版嵁
-    public AjaxResult exportStockInData() {
-        List<StockIn> stockIns = stockInService.listStockIns();
-        ExcelUtil<StockIn> util = new ExcelUtil<StockIn>(StockIn.class);
-        util.exportExcel(stockIns, "搴撳瓨鍏ュ簱淇℃伅");
-        return success();
+        stockInService.updateStockIn(stockIn);
+        return AjaxResult.success();
     }
 
-
+    @DeleteMapping("/del")
+    public AjaxResult delStockin(@RequestBody List<Integer> ids) {
+        if(CollectionUtils.isEmpty(ids)){
+            return AjaxResult.error("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�");
+        }
+        stockInService.delStockin(ids);
+        return AjaxResult.success();
+    }
+//瀵煎嚭
+    @Log(title = "鍏ュ簱妗f", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, StockinDto stockinDto) {
+        stockInService.stockinExport(response, stockinDto);
+    }
 }
diff --git a/src/main/java/com/ruoyi/inventory/controller/StockManagementController.java b/src/main/java/com/ruoyi/inventory/controller/StockManagementController.java
index c8084e2..3a38b4f 100644
--- a/src/main/java/com/ruoyi/inventory/controller/StockManagementController.java
+++ b/src/main/java/com/ruoyi/inventory/controller/StockManagementController.java
@@ -1,11 +1,17 @@
 package com.ruoyi.inventory.controller;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.dto.SupplierManageDto;
 import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.inventory.dto.StockManagementDto;
+import com.ruoyi.inventory.dto.StockoutDto;
 import com.ruoyi.inventory.pojo.StockManagement;
 import com.ruoyi.inventory.service.StockManagementService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 import static com.ruoyi.framework.web.domain.AjaxResult.error;
@@ -16,39 +22,29 @@
 public class StockManagementController {
     @Autowired
     private StockManagementService stockManagementService;
-    @RequestMapping("/list")// 鍒楀嚭鎵�鏈夊嚭搴撹褰�
-    public AjaxResult listStockOuts() {
-        List<StockManagement> stockManagements = stockManagementService.getStockManagements();
-        return success(stockManagements);
-    }
-    @GetMapping("/{id}")// 鏍规嵁ID鑾峰彇鍑哄簱璁板綍
-    public AjaxResult getStockOutById(@PathVariable Long id) {
-        StockManagement stockManagement = stockManagementService.getStockManagementById(id);
-        return success(stockManagement);
-    }
-    @PostMapping("add")// 鏂板鍑哄簱璁板綍
-    public AjaxResult addStockOut(@RequestBody StockManagement stockManagement) {
-        int i = stockManagementService.addStockManagement(stockManagement);
-        if(i>0){
-            return success();
-        }
-        return error();
-    }
-    @PutMapping("/update")// 鏇存柊鍑哄簱璁板綍
-    public AjaxResult updateStockOut(@RequestBody StockManagement stockManagement) {
-        int i = stockManagementService.updateStockManagement(stockManagement);
-        if(i>0){
-            return success();
-        }
-        return error();
-    }
-    @DeleteMapping("/delete/{id}")// 鍒犻櫎鍑哄簱璁板綍
-    public AjaxResult deleteStockOut(@PathVariable Long id) {
-        int i = stockManagementService.deleteStockManagement(id);
-        if(i>0){
-            return success();
-        }
-        return error();
-    }
 
+//    鏇存柊搴撳瓨
+    @PutMapping("/update")
+    public AjaxResult updateStockManagement(@RequestBody StockManagement stockManagement) {
+        stockManagementService.updateStockManagement(stockManagement);
+        return AjaxResult.success();
+    }
+    @DeleteMapping("/del")
+    public AjaxResult delStockManage(@RequestBody List<Integer> ids) {
+        if(CollectionUtils.isEmpty(ids)){
+            return AjaxResult.error("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�");
+        }
+        stockManagementService.delStockManage(ids);
+        return AjaxResult.success();
+    }
+//    鍒嗛〉鏌ヨ
+    @GetMapping("/page")
+    public AjaxResult getStockManagementPage(Page page, StockManagementDto stockManagementdto) {
+        return success(stockManagementService.selectStockManagePage(page, stockManagementdto));
+    }
+//    瀵煎嚭
+    @PostMapping("/export")
+    public void stockmanageExport(HttpServletResponse response, StockManagementDto stockManagementDto) {
+        stockManagementService.stockManageExport(response, stockManagementDto);
+    }
 }
diff --git a/src/main/java/com/ruoyi/inventory/controller/StockOutController.java b/src/main/java/com/ruoyi/inventory/controller/StockOutController.java
index d0457fd..d201d66 100644
--- a/src/main/java/com/ruoyi/inventory/controller/StockOutController.java
+++ b/src/main/java/com/ruoyi/inventory/controller/StockOutController.java
@@ -1,13 +1,20 @@
 package com.ruoyi.inventory.controller;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.inventory.dto.StockManagementDto;
+import com.ruoyi.inventory.dto.StockoutDto;
 import com.ruoyi.inventory.mapper.StockManagementMapper;
+import com.ruoyi.inventory.pojo.StockIn;
 import com.ruoyi.inventory.pojo.StockOut;
 import com.ruoyi.inventory.service.StockOutService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 
@@ -19,38 +26,38 @@
     @Autowired
     private StockManagementMapper stockManagementMapper;
 
-    @RequestMapping("/add")
-    public AjaxResult addStockOut(StockOut stockOut) {
-        int i = stockOutService.addStockOut(stockOut);
-        if(i>0){
-            return success();
-        }
-        return error();
+    @PostMapping("/add")
+    public AjaxResult add(@RequestBody StockOut stockout) {
+        stockOutService.saveStockout(stockout);
+        return AjaxResult.success();
     }
-    @RequestMapping("/list")
-    public AjaxResult listStockOuts() {
-        List<StockOut> stockOuts = stockOutService.getStockOuts();
-        return success(stockOuts);
-    }
+
     @RequestMapping("/{id}")
     public AjaxResult getStockOutById(@PathVariable Long id) {
-        StockOut stockOut = stockOutService.getStockOutById(id);
-        return success(stockOut);
+        return success(stockOutService.getStockOutById(id));
     }
-    @RequestMapping("/update")
-    public AjaxResult updateStockOut(@RequestBody StockOut stockOut) {
-        int i = stockOutService.updateStockOut(stockOut);
-        if(i>0){
-            return success();
-        }
-        return error();
+    @PutMapping("/update")// 鏇存柊鍏ュ簱璁板綍
+    public AjaxResult updateStockout(@RequestBody StockOut stockOut) {
+        stockOutService.updateStockOut(stockOut);
+        return AjaxResult.success();
     }
-    @RequestMapping("/delete/{id}")
-    public AjaxResult deleteStockOut(Long id) {
-        int i = stockOutService.deleteStockOut(id);
-        if(i>0){
-            return success();
+    @RequestMapping("/page")
+    public AjaxResult getStockOutPage(Page page, StockoutDto stockOutdto) {
+        IPage<StockoutDto> stockOutPage = stockOutService.selectStockOutPage(page, stockOutdto);
+        return success(stockOutPage);
+    }
+//    瀵煎嚭
+    @PostMapping("/export")
+    public void stockoutExport(HttpServletResponse response, StockoutDto stockoutDto) {
+        stockOutService.stockoutExport(response, stockoutDto);
+    }
+
+    @DeleteMapping("/del")
+    public AjaxResult delStockOut(@RequestBody List<Integer> ids) {
+        if(CollectionUtils.isEmpty(ids)){
+            return AjaxResult.error("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�");
         }
-        return error();
+        stockOutService.delStockOut(ids);
+        return AjaxResult.success();
     }
 }
diff --git a/src/main/java/com/ruoyi/inventory/dto/StockManagementDto.java b/src/main/java/com/ruoyi/inventory/dto/StockManagementDto.java
new file mode 100644
index 0000000..b92308b
--- /dev/null
+++ b/src/main/java/com/ruoyi/inventory/dto/StockManagementDto.java
@@ -0,0 +1,36 @@
+package com.ruoyi.inventory.dto;
+
+import com.ruoyi.inventory.pojo.StockManagement;
+import lombok.Data;
+
+import java.math.BigDecimal;
+@Data
+public class StockManagementDto extends StockManagement {
+
+    private String supplierName;
+    private String productCategory;
+    private String unit;
+    /**
+     * 鍚◣鍗曚环
+     */
+    private BigDecimal taxInclusiveUnitPrice;
+
+    /**
+     * 鍚◣鎬讳环
+     */
+    private BigDecimal taxInclusiveTotalPrice;
+
+    /**
+     * 绋庣巼
+     */
+    private BigDecimal taxRate;
+
+    /**
+     * 涓嶅惈绋庢�讳环
+     */
+    private BigDecimal taxExclusiveTotalPrice;
+    /**
+     * 瑙勬牸鍨嬪彿
+     */
+    private String specificationModel;
+}
diff --git a/src/main/java/com/ruoyi/inventory/dto/StockinDto.java b/src/main/java/com/ruoyi/inventory/dto/StockinDto.java
new file mode 100644
index 0000000..c325f5e
--- /dev/null
+++ b/src/main/java/com/ruoyi/inventory/dto/StockinDto.java
@@ -0,0 +1,52 @@
+package com.ruoyi.inventory.dto;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.inventory.pojo.StockIn;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+@Data
+public class StockinDto extends StockIn{
+
+    @ApiModelProperty(value = "浜у搧澶х被")
+    private String productCategory;
+
+    /**
+     * 瑙勬牸鍨嬪彿
+     */
+    @ApiModelProperty(value = "瑙勬牸鍨嬪彿")
+    private String specificationModel;
+    @ApiModelProperty(value = "鍗曚綅")
+    private String unit;
+    /**
+     * 鍚◣鍗曚环
+     */
+    private BigDecimal taxInclusiveUnitPrice;
+
+    /**
+     * 鍚◣鎬讳环
+     */
+    private BigDecimal taxInclusiveTotalPrice;
+
+    /**
+     * 绋庣巼
+     */
+    private BigDecimal taxRate;
+
+    /**
+     * 涓嶅惈绋庢�讳环
+     */
+    private BigDecimal taxExclusiveTotalPrice;
+    @ApiModelProperty(value = "渚涘簲鍟嗗悕绉�")
+    private String supplierName;
+    @TableField(exist = false)
+    private Date startTime;
+    @TableField(exist = false)
+    private Date endTime;
+}
diff --git a/src/main/java/com/ruoyi/inventory/dto/StockoutDto.java b/src/main/java/com/ruoyi/inventory/dto/StockoutDto.java
new file mode 100644
index 0000000..c3605b8
--- /dev/null
+++ b/src/main/java/com/ruoyi/inventory/dto/StockoutDto.java
@@ -0,0 +1,38 @@
+package com.ruoyi.inventory.dto;
+
+import com.ruoyi.inventory.pojo.StockOut;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+@Data
+public class StockoutDto extends StockOut {
+
+    private String supplierName;
+    private String unit;
+    private String productCategory;
+    /**
+     * 鍚◣鍗曚环
+     */
+    private BigDecimal taxInclusiveUnitPrice;
+
+    /**
+     * 鍚◣鎬讳环
+     */
+    private BigDecimal taxInclusiveTotalPrice;
+
+    /**
+     * 绋庣巼
+     */
+    private BigDecimal taxRate;
+
+    /**
+     * 涓嶅惈绋庢�讳环
+     */
+    private BigDecimal taxExclusiveTotalPrice;
+
+    /**
+     * 瑙勬牸鍨嬪彿
+     */
+    private String specificationModel;
+}
diff --git a/src/main/java/com/ruoyi/inventory/excel/StockInExcelDto.java b/src/main/java/com/ruoyi/inventory/excel/StockInExcelDto.java
new file mode 100644
index 0000000..7680b0a
--- /dev/null
+++ b/src/main/java/com/ruoyi/inventory/excel/StockInExcelDto.java
@@ -0,0 +1,35 @@
+package com.ruoyi.inventory.excel;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class StockInExcelDto {
+    @Excel(name = "鍏ュ簱鏃堕棿")
+    private String inboundTime;
+    @Excel(name = "鍏ュ簱鎵规")
+    private String inboundBatch;
+    @Excel(name = "渚涘簲鍟嗗悕绉�")
+    private String supplierName;
+    @Excel(name = "浜у搧澶х被")
+    private String productCategory;
+    @Excel(name = "瑙勬牸鍨嬪彿")
+    private String specificationModel;
+    @Excel(name = "鍗曚綅")
+    private String unit;
+    @Excel(name = "鍏ュ簱鏁伴噺")
+    private Integer inboundQuantity;
+    @Excel(name = "鍚◣鍗曚环")
+    private BigDecimal taxInclusiveUnitPrice;
+    @Excel(name = "鍚◣鎬讳环")
+    private BigDecimal taxInclusiveTotal;
+    @Excel(name = "涓嶅惈绋庢�讳环")
+    private BigDecimal taxExclusiveTotal;
+    @Excel(name = "绋庣巼")
+    private BigDecimal taxRate;
+    @Excel(name = "鍏ュ簱浜�")
+    private String inboundPerson;
+}
diff --git a/src/main/java/com/ruoyi/inventory/excel/StockManagementExcelDto.java b/src/main/java/com/ruoyi/inventory/excel/StockManagementExcelDto.java
new file mode 100644
index 0000000..73f77ce
--- /dev/null
+++ b/src/main/java/com/ruoyi/inventory/excel/StockManagementExcelDto.java
@@ -0,0 +1,39 @@
+package com.ruoyi.inventory.excel;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+@Data
+public class StockManagementExcelDto {
+    @Excel(name = "搴撳瓨鏃ユ湡")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date boundTime;
+    @Excel(name = "鍏ュ簱鏃堕棿")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date inboundTime;
+    @Excel(name = "渚涘簲鍟嗗悕绉�")
+    private String supplierName;
+    @Excel(name = "浜у搧澶х被")
+    private String productCategory;
+    @Excel(name = "瑙勬牸鍨嬪彿")
+    private String specificationModel;
+    @Excel(name = "鍗曚綅")
+    private String unit;
+    @Excel(name = "搴撳瓨鏁伴噺")
+    private Integer stockQuantity;
+    @Excel(name = "鍚◣鍗曚环")
+    private BigDecimal taxInclusiveUnitPrice;
+    @Excel(name = "鍚◣鎬讳环")
+    private BigDecimal taxInclusiveTotal;
+    @Excel(name = "涓嶅惈绋庢�讳环")
+    private BigDecimal taxExclusiveTotal;
+    @Excel(name = "绋庣巼")
+    private BigDecimal taxRate;
+    @Excel(name = "鍏ュ簱浜�")
+    private String inboundPerson;
+}
diff --git a/src/main/java/com/ruoyi/inventory/excel/StockOutExcelDto.java b/src/main/java/com/ruoyi/inventory/excel/StockOutExcelDto.java
new file mode 100644
index 0000000..f62d765
--- /dev/null
+++ b/src/main/java/com/ruoyi/inventory/excel/StockOutExcelDto.java
@@ -0,0 +1,33 @@
+package com.ruoyi.inventory.excel;
+
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class StockOutExcelDto {
+    @Excel(name = "鍑哄簱鏃堕棿")
+    private String inboundTime;
+    @Excel(name = "鍑哄簱鎵规")
+    private String inboundBatch;
+    @Excel(name = "浜у搧澶х被")
+    private String productCategory;
+    @Excel(name = "瑙勬牸鍨嬪彿")
+    private String specificationModel;
+    @Excel(name = "鍗曚綅")
+    private String unit;
+    @Excel(name = "鍑哄簱鏁伴噺")
+    private Integer inboundQuantity;
+    @Excel(name = "鍚◣鍗曚环")
+    private BigDecimal taxInclusiveUnitPrice;
+    @Excel(name = "鍚◣鎬讳环")
+    private BigDecimal taxInclusiveTotal;
+    @Excel(name = "涓嶅惈绋庢�讳环")
+    private BigDecimal taxExclusiveTotal;
+    @Excel(name = "绋庣巼")
+    private BigDecimal taxRate;
+    @Excel(name = "鍑哄簱浜�")
+    private String outboundPerson;
+
+}
diff --git a/src/main/java/com/ruoyi/inventory/mapper/StockInMapper.java b/src/main/java/com/ruoyi/inventory/mapper/StockInMapper.java
index 0412c6e..16b3abd 100644
--- a/src/main/java/com/ruoyi/inventory/mapper/StockInMapper.java
+++ b/src/main/java/com/ruoyi/inventory/mapper/StockInMapper.java
@@ -1,7 +1,16 @@
 package com.ruoyi.inventory.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.excel.SupplierManageExcelDto;
+import com.ruoyi.inventory.dto.StockinDto;
+import com.ruoyi.inventory.excel.StockInExcelDto;
 import com.ruoyi.inventory.pojo.StockIn;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -10,16 +19,10 @@
 * @createDate 2025-06-23 18:11:59
 * @Entity inventory.domain.StockIn
 */
-public interface StockInMapper {
+@Mapper
+public interface StockInMapper extends BaseMapper<StockIn> {
 
-    int deleteByPrimaryKey(Long id);
-
-    int insertSelective(StockIn record);
-
-    StockIn selectByPrimaryKey(Long id);
-
-    int updateByPrimaryKeySelective(StockIn record);
-
-    List<StockIn> selectList();
+    IPage<StockIn> selectStockInWithProductInfo(Page page, @Param("stockinDto") StockinDto stockinDto);
+    List<StockInExcelDto> stockinExportList(@Param("stockinDto") StockinDto stockinDto);
 
 }
diff --git a/src/main/java/com/ruoyi/inventory/mapper/StockManagementMapper.java b/src/main/java/com/ruoyi/inventory/mapper/StockManagementMapper.java
index 0d55981..96b76ad 100644
--- a/src/main/java/com/ruoyi/inventory/mapper/StockManagementMapper.java
+++ b/src/main/java/com/ruoyi/inventory/mapper/StockManagementMapper.java
@@ -1,8 +1,19 @@
 package com.ruoyi.inventory.mapper;
 
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.dto.SupplierManageDto;
+import com.ruoyi.basic.excel.SupplierManageExcelDto;
+import com.ruoyi.inventory.dto.StockManagementDto;
+import com.ruoyi.inventory.dto.StockinDto;
+import com.ruoyi.inventory.excel.StockManagementExcelDto;
 import com.ruoyi.inventory.pojo.StockManagement;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -11,15 +22,10 @@
 * @createDate 2025-06-23 18:11:59
 * @Entity inventory.domain.StockManagement
 */
-public interface StockManagementMapper {
-    List<StockManagement> selectAll();
-    int deleteByPrimaryKey(Long id);
+@Mapper
+public interface StockManagementMapper extends BaseMapper<StockManagement> {
 
-    int insertSelective(StockManagement record);
-
-    StockManagement selectByPrimaryKey(Long id);
-
-    int updateByPrimaryKeySelective(StockManagement record);
-
+    IPage<StockManagement> selectStockManagementBypage(Page page, @Param("stockManagementDto") StockManagementDto stockManagementDto);
+    List<StockManagementExcelDto> stockManageExportList(@Param("stockManagementDto") StockManagementDto stockManagementDto);
 
 }
diff --git a/src/main/java/com/ruoyi/inventory/mapper/StockOutMapper.java b/src/main/java/com/ruoyi/inventory/mapper/StockOutMapper.java
index 91449de..93d55ae 100644
--- a/src/main/java/com/ruoyi/inventory/mapper/StockOutMapper.java
+++ b/src/main/java/com/ruoyi/inventory/mapper/StockOutMapper.java
@@ -1,7 +1,16 @@
 package com.ruoyi.inventory.mapper;
 
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.dto.SupplierManageDto;
+import com.ruoyi.basic.excel.SupplierManageExcelDto;
+import com.ruoyi.inventory.dto.StockoutDto;
+import com.ruoyi.inventory.excel.StockOutExcelDto;
 import com.ruoyi.inventory.pojo.StockOut;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -11,16 +20,11 @@
 * @createDate 2025-06-23 18:11:59
 * @Entity inventory.domain.StockOut
 */
-public interface StockOutMapper {
+@Mapper
+public interface StockOutMapper extends BaseMapper<StockOut> {
 
-    int deleteByPrimaryKey(Long id);
-
-    List<StockOut> selectAll();
-    int insertSelective(StockOut record);
-
-    StockOut selectByPrimaryKey(Long id);
-
-    int updateByPrimaryKeySelective(StockOut record);
+    IPage<StockoutDto> selectStockOutBypage(Page page,@Param("stockOutdto") StockoutDto stockOutdto);
+    List<StockOutExcelDto> stockoutExportList(@Param("stockOutdto") StockoutDto stockOutdto);
 
 
 }
diff --git a/src/main/java/com/ruoyi/inventory/pojo/StockIn.java b/src/main/java/com/ruoyi/inventory/pojo/StockIn.java
index d28cd2e..886682d 100644
--- a/src/main/java/com/ruoyi/inventory/pojo/StockIn.java
+++ b/src/main/java/com/ruoyi/inventory/pojo/StockIn.java
@@ -1,31 +1,36 @@
 package com.ruoyi.inventory.pojo;
-
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
-import java.util.List;
-
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+
+import javax.validation.constraints.NotNull;
 
 /**
  * 
  * @TableName stock_in
  */
 @Data
-public class StockIn implements Serializable {
+@TableName("stock_in")
+public class StockIn{
     /**
      * 鍏ュ簱璁板綍ID
      */
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**
      * 浜у搧id
      */
-    private Integer productId;
+    private Long productId;
 
     /**
      * 鍏ュ簱鏃堕棿
      */
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date inboundTime;
 
     /**
@@ -34,40 +39,30 @@
     private String inboundBatch;
 
     /**
-     * 渚涘簲鍟嗗悕绉�
+     * 渚涘簲鍟唅d
      */
-    private String supplierName;
-
+    private Long supplierId;
     /**
      * 鍏ュ簱鏁伴噺
      */
     private Integer inboundQuantity;
 
-    /**
-     * 鍚◣鍗曚环
-     */
-    private BigDecimal taxInclusivePrice;
 
-    /**
-     * 鍚◣鎬讳环
-     */
-    private BigDecimal taxInclusiveTotal;
-
-    /**
-     * 绋庣巼
-     */
-    private BigDecimal taxRate;
-
-    /**
-     * 涓嶅惈绋庢�讳环
-     */
-    private BigDecimal taxExclusiveTotal;
 
     /**
      * 鍏ュ簱浜�
      */
     private String inboundPerson;
+//    tenant_id
+    /**
+     * 绉熸埛ID
+     */
+    @ApiModelProperty(value = "绉熸埛ID")
+    @TableField(fill = FieldFill.INSERT)
+    private Long tenantId;
+
 
     private static final long serialVersionUID = 1L;
-    private List<StockProduct> stockProducts;
+//    private List<StockProduct> stockProducts;
+
 }
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/inventory/pojo/StockManagement.java b/src/main/java/com/ruoyi/inventory/pojo/StockManagement.java
index 640fe57..0a25c1c 100644
--- a/src/main/java/com/ruoyi/inventory/pojo/StockManagement.java
+++ b/src/main/java/com/ruoyi/inventory/pojo/StockManagement.java
@@ -2,6 +2,12 @@
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 /**
@@ -9,7 +15,8 @@
  * @TableName stock_management
  */
 @Data
-public class StockManagement implements Serializable {
+@TableName("stock_management")
+public class StockManagement{
     /**
      * 搴撳瓨璁板綍ID
      */
@@ -18,37 +25,27 @@
     /**
      * 浜у搧id
      */
-    private Integer productId;
+    private Long productId;
 
     /**
      * 褰撳墠搴撳瓨閲�
      */
     private Integer stockQuantity;
 
-    /**
-     * 鍚◣鍗曚环
-     */
-    private BigDecimal taxInclusivePrice;
 
-    /**
-     * 鍚◣鎬讳环
-     */
-    private BigDecimal taxInclusiveTotal;
+    private Long supplierId;
 
-    /**
-     * 绋庣巼
-     */
-    private BigDecimal taxRate;
-
-    /**
-     * 涓嶅惈绋庢�讳环
-     */
-    private BigDecimal taxExclusiveTotal;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date boundTime;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date inboundTime;
 
     /**
      * 鍏ュ簱浜�
      */
     private String inboundPerson;
+    @TableField(fill = FieldFill.INSERT)
+    private Long tenantId;
 
     private static final long serialVersionUID = 1L;
 }
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/inventory/pojo/StockOut.java b/src/main/java/com/ruoyi/inventory/pojo/StockOut.java
index acb735b..d3a90a1 100644
--- a/src/main/java/com/ruoyi/inventory/pojo/StockOut.java
+++ b/src/main/java/com/ruoyi/inventory/pojo/StockOut.java
@@ -3,6 +3,10 @@
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 /**
@@ -10,6 +14,7 @@
  * @TableName stock_out
  */
 @Data
+@TableName("stock_out")
 public class StockOut implements Serializable {
     /**
      * 鍑哄簱璁板綍ID
@@ -19,7 +24,7 @@
     /**
      * 浜у搧id
      */
-    private Integer productId;
+    private Long productId;
 
     /**
      * 鍑哄簱鏃堕棿
@@ -34,37 +39,21 @@
     /**
      * 渚涘簲鍟嗗悕绉�
      */
-    private String supplierName;
+    private Long supplierId;
 
     /**
      * 鍏ュ簱鏁伴噺
      */
     private Integer inboundQuantity;
 
-    /**
-     * 鍚◣鍗曚环
-     */
-    private BigDecimal taxInclusivePrice;
 
-    /**
-     * 鍚◣鎬讳环
-     */
-    private BigDecimal taxInclusiveTotal;
-
-    /**
-     * 绋庣巼
-     */
-    private BigDecimal taxRate;
-
-    /**
-     * 涓嶅惈绋庢�讳环
-     */
-    private BigDecimal taxExclusiveTotal;
 
     /**
      * 鍑哄簱浜�
      */
     private String inboundPerson;
+    @TableField(fill = FieldFill.INSERT)
+    private Long tenantId;
 
     private static final long serialVersionUID = 1L;
 }
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/inventory/service/StockInService.java b/src/main/java/com/ruoyi/inventory/service/StockInService.java
index 7b7f7a9..3229280 100644
--- a/src/main/java/com/ruoyi/inventory/service/StockInService.java
+++ b/src/main/java/com/ruoyi/inventory/service/StockInService.java
@@ -1,21 +1,28 @@
 package com.ruoyi.inventory.service;
 
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.inventory.dto.StockinDto;
 import com.ruoyi.inventory.pojo.StockIn;
 
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.Date;
 import java.util.List;
 
 
-public interface StockInService {
-    int addStockIn(StockIn stockIn);
-
-    List<StockIn> listStockIns();
+public interface StockInService extends IService<StockIn> {
+    void saveStockin(StockIn stockIn);
 
     StockIn getStockInById(Long id);
 
     int updateStockIn(StockIn stockIn);
 
-    int deleteStockIn(Long id);
-
-
+    int delStockin(List<Integer> ids);
+//    PageInfo<StockinProcuct> getStockInPage(Integer pageNum, Integer pageSize, StockInQueryDTO query);
+    IPage<StockIn> selectStockInPage(Page page, StockinDto stockinDto);
+    void stockinExport(HttpServletResponse response, StockinDto stockinDto);
 }
diff --git a/src/main/java/com/ruoyi/inventory/service/StockManagementService.java b/src/main/java/com/ruoyi/inventory/service/StockManagementService.java
index 6f8fe06..1f8bbdc 100644
--- a/src/main/java/com/ruoyi/inventory/service/StockManagementService.java
+++ b/src/main/java/com/ruoyi/inventory/service/StockManagementService.java
@@ -1,14 +1,22 @@
 package com.ruoyi.inventory.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.basic.dto.SupplierManageDto;
+import com.ruoyi.inventory.dto.StockManagementDto;
+import com.ruoyi.inventory.dto.StockinDto;
 import com.ruoyi.inventory.pojo.StockManagement;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 
-public interface StockManagementService {
-    List<StockManagement> getStockManagements();
-    StockManagement getStockManagementById(Long id);
-    int addStockManagement(StockManagement stockManagement);
+public interface StockManagementService extends IService<StockManagement> {
+
     int updateStockManagement(StockManagement stockManagement);
-    int deleteStockManagement(Long id);
+    int delStockManage(List<Integer> ids);
+    IPage<StockManagement> selectStockManagePage(Page page, StockManagementDto stockManagementdto);
+    void stockManageExport(HttpServletResponse response, StockManagementDto stockManagementdto);
+
 }
diff --git a/src/main/java/com/ruoyi/inventory/service/StockOutService.java b/src/main/java/com/ruoyi/inventory/service/StockOutService.java
index 9be4b97..cd8700c 100644
--- a/src/main/java/com/ruoyi/inventory/service/StockOutService.java
+++ b/src/main/java/com/ruoyi/inventory/service/StockOutService.java
@@ -1,13 +1,23 @@
 package com.ruoyi.inventory.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.dto.SupplierManageDto;
+import com.ruoyi.inventory.dto.StockinDto;
+import com.ruoyi.inventory.dto.StockoutDto;
+import com.ruoyi.inventory.pojo.StockIn;
 import com.ruoyi.inventory.pojo.StockOut;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 public interface StockOutService {
-    List<StockOut> getStockOuts();
+    int delStockOut(List<Integer> ids);
+
     StockOut getStockOutById(Long id);
-    int addStockOut(StockOut stockOut);
+    void saveStockout(StockOut stockout);
     int updateStockOut(StockOut stockOut);
-    int deleteStockOut(Long id);
+    IPage<StockoutDto> selectStockOutPage(Page page, StockoutDto stockoutDto);
+    void stockoutExport(HttpServletResponse response, StockoutDto stockoutDto);
+
 }
diff --git a/src/main/java/com/ruoyi/inventory/service/impl/StockInServiceImpl.java b/src/main/java/com/ruoyi/inventory/service/impl/StockInServiceImpl.java
index c215d2a..8c035f8 100644
--- a/src/main/java/com/ruoyi/inventory/service/impl/StockInServiceImpl.java
+++ b/src/main/java/com/ruoyi/inventory/service/impl/StockInServiceImpl.java
@@ -1,45 +1,128 @@
 package com.ruoyi.inventory.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.inventory.dto.StockinDto;
+import com.ruoyi.inventory.excel.StockInExcelDto;
+import com.ruoyi.inventory.mapper.StockManagementMapper;
 import com.ruoyi.inventory.pojo.StockIn;
 import com.ruoyi.inventory.mapper.StockInMapper;
+import com.ruoyi.inventory.pojo.StockManagement;
 import com.ruoyi.inventory.service.StockInService;
+import com.ruoyi.purchase.dto.PurchaseLedgerDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
+
 @Service
-public class StockInServiceImpl implements StockInService {
+public class StockInServiceImpl extends ServiceImpl<StockInMapper,StockIn> implements StockInService {
     @Autowired
     private StockInMapper stockInMapper;
+    @Autowired
+    private StockManagementMapper stockManagementMapper;
 
-    @Override//娣诲姞搴撳瓨鍏ュ簱淇℃伅
-    public int addStockIn(StockIn stockIn) {
-        int i = stockInMapper.insertSelective(stockIn);
-        return i;
+
+//    鏂板鏂规硶
+    /**
+     * 鏂板搴撳瓨鍏ュ簱淇℃伅
+     * @param stockIn
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void saveStockin(StockIn stockIn) {
+        stockInMapper.insert(stockIn);
+        StockManagement stockManagement = new StockManagement();
+//        杩涜鍒ゆ柇鏄惁瀛樺湪鐩稿悓鐨勪骇鍝乮d鍜屼緵搴斿晢id
+        LambdaQueryWrapper<StockManagement> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(StockManagement::getProductId, stockIn.getProductId());
+        queryWrapper.eq(StockManagement::getSupplierId, stockIn.getSupplierId());
+        StockManagement stockManagement1 = stockManagementMapper.selectOne(queryWrapper);
+        if (stockManagement1!= null) {
+            stockManagement1.setStockQuantity(stockManagement1.getStockQuantity() + stockIn.getInboundQuantity());
+            stockManagement1.setInboundTime(stockIn.getInboundTime());
+            stockManagement1.setBoundTime(new Date());
+            stockManagement1.setInboundPerson(stockIn.getInboundPerson());
+            System.out.println(stockManagement1+"22");
+            stockManagementMapper.updateById(stockManagement1);
         }
-
-    @Override//鍒楀嚭鎵�鏈夊簱瀛樺叆搴撲俊鎭�
-    public List<StockIn> listStockIns() {
-        List<StockIn> stockIns = stockInMapper.selectList();
-        return stockIns;
+        else {
+            stockManagement.setProductId(stockIn.getProductId());
+            stockManagement.setStockQuantity(stockIn.getInboundQuantity());
+            stockManagement.setBoundTime(stockIn.getInboundTime());
+            stockManagement.setStockQuantity(stockIn.getInboundQuantity());
+            stockManagement.setInboundPerson(stockIn.getInboundPerson());
+            stockManagement.setSupplierId(stockIn.getSupplierId());
+            stockManagement.setTenantId(stockIn.getTenantId());
+            stockManagement.setBoundTime(new Date());
+            stockManagementMapper.insert(stockManagement);
+        }
     }
 
     @Override//鏍规嵁id鑾峰彇搴撳瓨鍏ュ簱淇℃伅
     public StockIn getStockInById(Long id) {
-        StockIn stockIn = stockInMapper.selectByPrimaryKey(id);
+        StockIn stockIn = stockInMapper.selectById(id);
         return stockIn;
     }
 
     @Override//鏇存柊搴撳瓨鍏ュ簱淇℃伅
+    @Transactional(rollbackFor = Exception.class)
     public int updateStockIn(StockIn stockIn) {
-        int i = stockInMapper.updateByPrimaryKeySelective(stockIn);
-        return i;
+        StockIn stockIn1 = stockInMapper.selectById(stockIn.getId());
+//        杩涜鍒ゆ柇鏄惁瀛樺湪鐩稿悓鐨勪骇鍝乮d鍜屼緵搴斿晢id
+        LambdaQueryWrapper<StockManagement> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(StockManagement::getProductId, stockIn.getProductId());
+        queryWrapper.eq(StockManagement::getSupplierId, stockIn.getSupplierId());
+        StockManagement stockManagement1 = stockManagementMapper.selectOne(queryWrapper);
+        if (stockManagement1!= null) {
+            stockManagement1.setStockQuantity(stockManagement1.getStockQuantity() - stockIn1.getInboundQuantity() + stockIn.getInboundQuantity());
+            stockManagement1.setInboundTime(stockIn.getInboundTime());
+            stockManagement1.setBoundTime(new Date());
+            stockManagement1.setInboundPerson(stockIn.getInboundPerson());
+            System.out.println(stockManagement1 + "22");
+            stockManagementMapper.updateById(stockManagement1);
+        }        else {
+            StockManagement stockManagement = new StockManagement();
+            stockManagement.setProductId(stockIn.getProductId());
+            stockManagement.setStockQuantity(stockIn.getInboundQuantity());
+            stockManagement.setBoundTime(stockIn.getInboundTime());
+            stockManagement.setStockQuantity(stockIn.getInboundQuantity());
+            stockManagement.setInboundPerson(stockIn.getInboundPerson());
+            stockManagement.setSupplierId(stockIn.getSupplierId());
+            stockManagement.setTenantId(stockIn.getTenantId());
+            stockManagement.setBoundTime(new Date());
+            System.out.println(stockManagement + "33");
+            stockManagementMapper.insert(stockManagement);
+        }
+        return stockInMapper.updateById(stockIn);
     }
 
-    @Override//鍒犻櫎搴撳瓨鍏ュ簱淇℃伅
-    public int deleteStockIn(Long id) {
-        int i = stockInMapper.deleteByPrimaryKey(id);
-        return i;
+    @Override
+    public int delStockin(List<Integer> ids) {
+        LambdaQueryWrapper<StockIn> delWrapper = new LambdaQueryWrapper<>();
+        delWrapper.in(StockIn::getId, ids);
+        return stockInMapper.delete(delWrapper);
     }
 
+    @Override
+    public IPage<StockIn> selectStockInPage(Page page, StockinDto stockinDto) {
+        System.out.println(stockinDto);
+        IPage<StockIn> stockinDtoIPage = stockInMapper.selectStockInWithProductInfo(page, stockinDto);
+        System.out.println(stockinDtoIPage.getRecords());
+        return stockInMapper.selectStockInWithProductInfo(page, stockinDto);
+    }
+
+    @Override
+    public void stockinExport(HttpServletResponse response, StockinDto stockinDto) {
+        List<StockInExcelDto> stockInExcelDtoList = stockInMapper.stockinExportList(stockinDto);
+        ExcelUtil<StockInExcelDto> util = new ExcelUtil<StockInExcelDto>(StockInExcelDto.class);
+        util.exportExcel(response, stockInExcelDtoList, "渚涘簲鍟嗗鍑�");
+    }
 }
diff --git a/src/main/java/com/ruoyi/inventory/service/impl/StockManagementServiceImpl.java b/src/main/java/com/ruoyi/inventory/service/impl/StockManagementServiceImpl.java
index 1c5d1e2..18a48dd 100644
--- a/src/main/java/com/ruoyi/inventory/service/impl/StockManagementServiceImpl.java
+++ b/src/main/java/com/ruoyi/inventory/service/impl/StockManagementServiceImpl.java
@@ -1,45 +1,46 @@
 package com.ruoyi.inventory.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.excel.SupplierManageExcelDto;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.inventory.dto.StockManagementDto;
+import com.ruoyi.inventory.excel.StockManagementExcelDto;
 import com.ruoyi.inventory.mapper.StockManagementMapper;
 import com.ruoyi.inventory.pojo.StockManagement;
 import com.ruoyi.inventory.service.StockManagementService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 @Service
-public class StockManagementServiceImpl implements StockManagementService {
+public class StockManagementServiceImpl extends ServiceImpl<StockManagementMapper,StockManagement> implements StockManagementService {
     @Autowired
     private StockManagementMapper stockManagementMapper;
 
     @Override
-    public List<StockManagement> getStockManagements() {
-        List<StockManagement> stockManagements = stockManagementMapper.selectAll();
-        return stockManagements;
-    }
-
-    @Override
-    public StockManagement getStockManagementById(Long id) {
-        StockManagement stockManagement = stockManagementMapper.selectByPrimaryKey(id);
-        return stockManagement;
-    }
-
-    @Override
-    public int addStockManagement(StockManagement stockManagement) {
-        int i = stockManagementMapper.insertSelective(stockManagement);
-        return i;
-    }
-
-    @Override
     public int updateStockManagement(StockManagement stockManagement) {
-        int i = stockManagementMapper.updateByPrimaryKeySelective(stockManagement);
-        return i;
+        return stockManagementMapper.updateById(stockManagement);
     }
 
     @Override
-    public int deleteStockManagement(Long id) {
-        int i = stockManagementMapper.deleteByPrimaryKey(id);
-        return i;
+    public int delStockManage(List<Integer> ids) {
+        return stockManagementMapper.deleteBatchIds(ids);
+    }
+
+
+    @Override
+    public IPage<StockManagement> selectStockManagePage(Page page, StockManagementDto stockManagementdto) {
+        return stockManagementMapper.selectStockManagementBypage(page, stockManagementdto);
+    }
+
+    @Override
+    public void stockManageExport(HttpServletResponse response, StockManagementDto stockManagementdto) {
+        List<StockManagementExcelDto> stockManageList = stockManagementMapper.stockManageExportList(stockManagementdto);
+        ExcelUtil<StockManagementExcelDto> util = new ExcelUtil<StockManagementExcelDto>(StockManagementExcelDto.class);
+        util.exportExcel(response, stockManageList, "搴撳瓨瀵煎嚭");
     }
 }
diff --git a/src/main/java/com/ruoyi/inventory/service/impl/StockOutServiceImpl.java b/src/main/java/com/ruoyi/inventory/service/impl/StockOutServiceImpl.java
index ff084b9..e7dfd58 100644
--- a/src/main/java/com/ruoyi/inventory/service/impl/StockOutServiceImpl.java
+++ b/src/main/java/com/ruoyi/inventory/service/impl/StockOutServiceImpl.java
@@ -1,46 +1,101 @@
 package com.ruoyi.inventory.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.excel.SupplierManageExcelDto;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.inventory.dto.StockoutDto;
+import com.ruoyi.inventory.excel.StockOutExcelDto;
+import com.ruoyi.inventory.mapper.StockManagementMapper;
 import com.ruoyi.inventory.mapper.StockOutMapper;
+import com.ruoyi.inventory.pojo.StockManagement;
 import com.ruoyi.inventory.pojo.StockOut;
 import com.ruoyi.inventory.service.StockOutService;
 
 import lombok.AllArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.Date;
 import java.util.List;
 
 @Service
 public class StockOutServiceImpl implements StockOutService {
     @Autowired
     private StockOutMapper stockOutMapper;
+    @Autowired
+    private StockManagementMapper stockManagementMapper;
+
+
     @Override
-    public List<StockOut> getStockOuts() {
-        List<StockOut> stockOuts = stockOutMapper.selectAll();
-        return stockOuts;
+    public int delStockOut(List<Integer> ids) {
+        return stockOutMapper.deleteBatchIds(ids);
     }
 
     @Override
     public StockOut getStockOutById(Long id) {
-        StockOut stockOut = stockOutMapper.selectByPrimaryKey(id);
+        StockOut stockOut = stockOutMapper.selectById(id);
         return stockOut;
     }
 
     @Override
-    public int addStockOut(StockOut stockOut) {
-        int i = stockOutMapper.insertSelective(stockOut);
-        return i;
+    @Transactional(rollbackFor = Exception.class)
+    public void saveStockout(StockOut stockOut) {
+//    杩涜鍒ゆ柇鏄惁瀛樺湪鐩稿悓鐨勪骇鍝乮d鍜屼緵搴斿晢id
+        LambdaQueryWrapper<StockManagement> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(StockManagement::getProductId, stockOut.getProductId());
+        queryWrapper.eq(StockManagement::getSupplierId, stockOut.getSupplierId());
+        StockManagement stockManagement1 = stockManagementMapper.selectOne(queryWrapper);
+        if (stockManagement1!= null) {
+//            鍒ゆ柇搴撳瓨鏁伴噺鏄惁澶т簬鍑哄簱鏁伴噺
+            if (stockManagement1.getStockQuantity() < stockOut.getInboundQuantity()) {
+                throw new RuntimeException("搴撳瓨鏁伴噺涓嶈冻");
+            }
+            stockOutMapper.insert(stockOut);
+            stockManagement1.setStockQuantity(stockManagement1.getStockQuantity() - stockOut.getInboundQuantity());
+            stockManagement1.setInboundTime(new Date());
+            stockManagementMapper.updateById(stockManagement1);
+        }
+        else {
+            throw new RuntimeException("搴撳瓨涓嶅瓨鍦�");
+        }
     }
 
     @Override
     public int updateStockOut(StockOut stockOut) {
-        int i = stockOutMapper.updateByPrimaryKeySelective(stockOut);
-        return i;
+//        闇�瑕佽繘琛屽垽鏂湪搴撳瓨涓槸鍚﹀瓨鍦ㄨ浜у搧锛屽鏋滃瓨鍦紝灏辫繘琛屼慨鏀癸紝鍚﹀垯灏辨姏鍑哄紓甯�
+        StockOut stockOut1 = stockOutMapper.selectById(stockOut.getId());
+            LambdaQueryWrapper<StockManagement> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(StockManagement::getProductId, stockOut.getProductId());
+            StockManagement stockManagement1 = stockManagementMapper.selectOne(queryWrapper);
+            if (stockManagement1!= null) {
+//                鍒ゆ柇搴撳瓨鏁伴噺鏄惁澶т簬鍑哄簱鏁伴噺
+                if (stockManagement1.getStockQuantity()+stockOut1.getInboundQuantity() < stockOut.getInboundQuantity()) {
+                    throw new RuntimeException("搴撳瓨鏁伴噺涓嶈冻");
+                }
+                stockManagement1.setStockQuantity(stockManagement1.getStockQuantity() + stockOut1.getInboundQuantity() - stockOut.getInboundQuantity());
+                stockManagement1.setInboundTime(stockOut.getInboundTime());
+                stockManagement1.setBoundTime(new Date());
+                System.out.println(stockManagement1 + "22");
+                stockManagementMapper.updateById(stockManagement1);
+            } else {
+                throw new RuntimeException("搴撳瓨涓嶅瓨鍦�");
+            }
+        return stockOutMapper.updateById(stockOut);
     }
 
     @Override
-    public int deleteStockOut(Long id) {
-        int i = stockOutMapper.deleteByPrimaryKey(id);
-        return i;
+    public IPage<StockoutDto> selectStockOutPage(Page page, StockoutDto stockoutDto) {
+        return stockOutMapper.selectStockOutBypage(page, stockoutDto);
+    }
+
+    @Override
+    public void stockoutExport(HttpServletResponse response, StockoutDto stockoutDto) {
+        List<StockOutExcelDto> stockoutList = stockOutMapper.stockoutExportList(stockoutDto);
+        ExcelUtil<StockOutExcelDto> util = new ExcelUtil<StockOutExcelDto>(StockOutExcelDto.class);
+        util.exportExcel(response, stockoutList, "渚涘簲鍟嗗鍑�");
     }
 }
diff --git a/src/main/resources/mapper/inventory/StockInMapper.xml b/src/main/resources/mapper/inventory/StockInMapper.xml
index 223d083..fca267e 100644
--- a/src/main/resources/mapper/inventory/StockInMapper.xml
+++ b/src/main/resources/mapper/inventory/StockInMapper.xml
@@ -4,119 +4,123 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.inventory.mapper.StockInMapper">
 
-    <resultMap id="BaseResultMap" type="com.ruoyi.inventory.pojo.StockIn">
-            <id property="id" column="id" jdbcType="INTEGER"/>
-            <result property="productId" column="product_id" jdbcType="INTEGER"/>
-            <result property="inboundTime" column="inbound_time" jdbcType="TIMESTAMP"/>
-            <result property="inboundBatch" column="inbound_batch" jdbcType="VARCHAR"/>
-            <result property="supplierName" column="supplier_name" jdbcType="VARCHAR"/>
-            <result property="inboundQuantity" column="inbound_quantity" jdbcType="INTEGER"/>
-            <result property="taxInclusivePrice" column="tax_inclusive_price" jdbcType="DECIMAL"/>
-            <result property="taxInclusiveTotal" column="tax_inclusive_total" jdbcType="DECIMAL"/>
-            <result property="taxRate" column="tax_rate" jdbcType="DECIMAL"/>
-            <result property="taxExclusiveTotal" column="tax_exclusive_total" jdbcType="DECIMAL"/>
-            <result property="inboundPerson" column="inbound_person" jdbcType="VARCHAR"/>
-            <collection property="stockProducts" ofType="com.ruoyi.inventory.pojo.StockProduct"
-                        select="com.ruoyi.inventory.mapper.StockProductMapper.selectByPrimaryKey" column="productId">
-                <id property="id" column="productId" jdbcType="INTEGER"/>
-            </collection>
-    </resultMap>
 
-    <sql id="Base_Column_List">
-        id,product_id,inbound_time,
-        inbound_batch,supplier_name,inbound_quantity,
-        tax_inclusive_price,tax_inclusive_total,tax_rate,
-        tax_exclusive_total,inbound_person
-    </sql>
+<!--    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultType="com.ruoyi.inventory.dto.StockinDto">-->
+<!--        SELECT-->
+<!--            T1.id,-->
+<!--            T1.product_id,-->
+<!--            T1.inbound_time,-->
+<!--            T1.inbound_batch,-->
+<!--            T1.supplier_id,-->
+<!--            T1.inbound_quantity,-->
+<!--            T1.tax_inclusive_price,-->
+<!--            T1.tax_inclusive_total,-->
+<!--            T1.tax_rate,-->
+<!--            T1.tax_exclusive_total,-->
+<!--            T1.inbound_person,-->
+<!--            T1.tenant_id,-->
+<!--            T2.product_category,-->
+<!--            T2.specification_model,-->
+<!--            T3.supplier_name-->
+<!--        FROM-->
+<!--            stock_in T1-->
+<!--                INNER JOIN-->
+<!--            product_record T2-->
+<!--            ON-->
+<!--                T1.product_id = T2.product_id-->
+<!--                INNER JOIN-->
+<!--            supplier_manage T3-->
+<!--            ON-->
+<!--                T1.supplier_id = T3.id-->
+<!--        where  T1.id = #{id,jdbcType=INTEGER}-->
+<!--    </select>-->
 
-    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-        select
-        <include refid="Base_Column_List" />
-        from stock_in
-        where  id = #{id,jdbcType=INTEGER} 
-    </select>
-    <select id="selectList" resultType="com.ruoyi.inventory.pojo.StockIn">
-        select
-        <include refid="Base_Column_List" />
-        from stock_in
-    </select>
-    <select id="selectListByPage" resultType="com.ruoyi.inventory.pojo.StockIn">
-        select
-        <include refid="Base_Column_List" />
-        from stock_in
-        limit #{pageNum},#{pageSize}
+
+    <select id="selectStockInWithProductInfo" resultType="com.ruoyi.inventory.dto.StockinDto">
+        SELECT
+        T1.id,
+        T1.product_id,
+        T1.inbound_time,
+        T1.inbound_batch,
+        T1.supplier_id,
+        T1.inbound_quantity,
+        T2.tax_inclusive_unit_price,
+        T2.tax_inclusive_total_price,
+        T2.tax_rate,
+        T2.tax_exclusive_total_price,
+        T1.inbound_person,
+        T1.tenant_id,
+        T2.product_category,
+        T2.specification_model,
+        T2.unit,
+        T3.supplier_name
+        FROM
+        stock_in T1
+        INNER JOIN
+        product_record T2
+        ON
+        T1.product_id = T2.product_id
+        INNER JOIN
+        supplier_manage T3
+        ON
+        T1.supplier_id = T3.id
+        <where>
+            <if test="stockinDto.supplierName != null and stockinDto.supplierName != ''">
+                AND T3.supplier_name LIKE CONCAT('%', #{stockinDto.supplierName}, '%')
+            </if>
+            <if test="stockinDto.startTime != null and stockinDto.startTime != ''">
+                AND T1.inbound_time &gt;= #{stockinDto.startTime}
+            </if>
+            <if test="stockinDto.endTime != null and stockinDto.endTime != ''">
+                AND T1.inbound_time &lt;= #{stockinDto.endTime}
+            </if>
+        </where>
+        ORDER BY T1.inbound_time DESC
     </select>
 
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete from stock_in
-        where  id = #{id,jdbcType=INTEGER} 
-    </delete>
+    <select id="stockinExportList" resultType="com.ruoyi.inventory.excel.StockInExcelDto">
+        SELECT
+        T1.id,
+        T1.product_id,
+        T1.inbound_time,
+        T1.inbound_batch,
+        T1.supplier_id,
+        T1.inbound_quantity,
+        T2.tax_inclusive_unit_price,
+        T2.tax_inclusive_total_price,
+        T2.tax_rate,
+        T2.tax_exclusive_total_price,
+        T1.inbound_person,
+        T1.tenant_id,
+        T2.product_category,
+        T2.specification_model,
+        T2.unit,
+        T3.supplier_name
+        FROM
+        stock_in T1
+        INNER JOIN
+        product_record T2
+        ON
+        T1.product_id = T2.product_id
+        INNER JOIN
+        supplier_manage T3
+        ON
+        T1.supplier_id = T3.id
+        <where>
+            <if test="stockinDto.supplierName != null and stockinDto.supplierName != ''">
+                AND T3.supplier_name LIKE CONCAT('%', #{stockinDto.supplierName}, '%')
+            </if>
+            <if test="stockinDto.startTime != null and stockinDto.startTime != ''">
+                AND T1.inbound_time &gt;= #{stockinDto.startTime}
+            </if>
+            <if test="stockinDto.endTime != null and stockinDto.endTime != ''">
+                AND T1.inbound_time &lt;= #{stockinDto.endTime}
+            </if>
+        </where>
+        ORDER BY T1.inbound_time DESC
+    </select>
 
-    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.inventory.pojo.StockIn" useGeneratedKeys="true">
-        insert into stock_in
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-                <if test="id != null">id,</if>
-                <if test="productId != null">product_id,</if>
-                <if test="inboundTime != null">inbound_time,</if>
-                <if test="inboundBatch != null">inbound_batch,</if>
-                <if test="supplierName != null">supplier_name,</if>
-                <if test="inboundQuantity != null">inbound_quantity,</if>
-                <if test="taxInclusivePrice != null">tax_inclusive_price,</if>
-                <if test="taxInclusiveTotal != null">tax_inclusive_total,</if>
-                <if test="taxRate != null">tax_rate,</if>
-                <if test="taxExclusiveTotal != null">tax_exclusive_total,</if>
-                <if test="inboundPerson != null">inbound_person,</if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-                <if test="id != null">#{id,jdbcType=INTEGER},</if>
-                <if test="productId != null">#{productId,jdbcType=INTEGER},</if>
-                <if test="inboundTime != null">#{inboundTime,jdbcType=TIMESTAMP},</if>
-                <if test="inboundBatch != null">#{inboundBatch,jdbcType=VARCHAR},</if>
-                <if test="supplierName != null">#{supplierName,jdbcType=VARCHAR},</if>
-                <if test="inboundQuantity != null">#{inboundQuantity,jdbcType=INTEGER},</if>
-                <if test="taxInclusivePrice != null">#{taxInclusivePrice,jdbcType=DECIMAL},</if>
-                <if test="taxInclusiveTotal != null">#{taxInclusiveTotal,jdbcType=DECIMAL},</if>
-                <if test="taxRate != null">#{taxRate,jdbcType=DECIMAL},</if>
-                <if test="taxExclusiveTotal != null">#{taxExclusiveTotal,jdbcType=DECIMAL},</if>
-                <if test="inboundPerson != null">#{inboundPerson,jdbcType=VARCHAR},</if>
-        </trim>
-    </insert>
 
-    <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.inventory.pojo.StockIn">
-        update stock_in
-        <set>
-                <if test="productId != null">
-                    product_id = #{productId,jdbcType=INTEGER},
-                </if>
-                <if test="inboundTime != null">
-                    inbound_time = #{inboundTime,jdbcType=TIMESTAMP},
-                </if>
-                <if test="inboundBatch != null">
-                    inbound_batch = #{inboundBatch,jdbcType=VARCHAR},
-                </if>
-                <if test="supplierName != null">
-                    supplier_name = #{supplierName,jdbcType=VARCHAR},
-                </if>
-                <if test="inboundQuantity != null">
-                    inbound_quantity = #{inboundQuantity,jdbcType=INTEGER},
-                </if>
-                <if test="taxInclusivePrice != null">
-                    tax_inclusive_price = #{taxInclusivePrice,jdbcType=DECIMAL},
-                </if>
-                <if test="taxInclusiveTotal != null">
-                    tax_inclusive_total = #{taxInclusiveTotal,jdbcType=DECIMAL},
-                </if>
-                <if test="taxRate != null">
-                    tax_rate = #{taxRate,jdbcType=DECIMAL},
-                </if>
-                <if test="taxExclusiveTotal != null">
-                    tax_exclusive_total = #{taxExclusiveTotal,jdbcType=DECIMAL},
-                </if>
-                <if test="inboundPerson != null">
-                    inbound_person = #{inboundPerson,jdbcType=VARCHAR},
-                </if>
-        </set>
-        where   id = #{id,jdbcType=INTEGER} 
-    </update>
+
 
 </mapper>
diff --git a/src/main/resources/mapper/inventory/StockManagementMapper.xml b/src/main/resources/mapper/inventory/StockManagementMapper.xml
index f46d1e2..a1f6ef4 100644
--- a/src/main/resources/mapper/inventory/StockManagementMapper.xml
+++ b/src/main/resources/mapper/inventory/StockManagementMapper.xml
@@ -4,89 +4,76 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.inventory.mapper.StockManagementMapper">
 
-    <resultMap id="BaseResultMap" type="com.ruoyi.inventory.pojo.StockManagement">
-            <id property="id" column="id" jdbcType="INTEGER"/>
-            <result property="productId" column="product_id" jdbcType="INTEGER"/>
-            <result property="stockQuantity" column="stock_quantity" jdbcType="INTEGER"/>
-            <result property="taxInclusivePrice" column="tax_inclusive_price" jdbcType="DECIMAL"/>
-            <result property="taxInclusiveTotal" column="tax_inclusive_total" jdbcType="DECIMAL"/>
-            <result property="taxRate" column="tax_rate" jdbcType="DECIMAL"/>
-            <result property="taxExclusiveTotal" column="tax_exclusive_total" jdbcType="DECIMAL"/>
-            <result property="inboundPerson" column="inbound_person" jdbcType="VARCHAR"/>
-    </resultMap>
-
-    <sql id="Base_Column_List">
-        id,product_id,stock_quantity,
-        tax_inclusive_price,tax_inclusive_total,tax_rate,
-        tax_exclusive_total,inbound_person
-    </sql>
-
-    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-        select
-        <include refid="Base_Column_List" />
-        from stock_management
-        where  id = #{id,jdbcType=INTEGER} 
-    </select>
-    <select id="selectAll" resultType="com.ruoyi.inventory.pojo.StockManagement">
-        select
-        <include refid="Base_Column_List" />
-        from stock_management
+<!--    鏍规嵁渚涘簲鍟嗘ā绯婃悳绱�-->
+    <select id="selectStockManagementBypage" resultType="com.ruoyi.inventory.dto.StockManagementDto">
+        SELECT
+            T2.unit,
+            T2.product_category,
+            T2.specification_model,
+            T3.supplier_name,
+            T1.id,
+            T1.product_id,
+            T1.stock_quantity,
+            T2.tax_inclusive_unit_price,
+            T2.tax_inclusive_total_price,
+            T2.tax_rate,
+            T2.tax_exclusive_total_price,
+            T1.inbound_person,
+            T1.supplier_id,
+            T1.tenant_id,
+            T1.bound_time,
+            T1.inbound_time
+        FROM
+            stock_management T1
+                INNER JOIN
+            product_record T2
+            ON
+                T1.product_id = T2.product_id
+                INNER JOIN
+            supplier_manage T3
+            ON
+                T1.supplier_id = T3.id
+        <where>
+            <if test="stockManagementDto.supplierName != null and stockManagementDto.supplierName != ''">
+                AND T3.supplier_name LIKE CONCAT('%', #{stockManagementDto.supplierName}, '%')
+            </if>
+        </where>
     </select>
 
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete from stock_management
-        where  id = #{id,jdbcType=INTEGER} 
-    </delete>
+    <select id="stockManageExportList" resultType="com.ruoyi.inventory.excel.StockManagementExcelDto">
+        SELECT
+        T2.unit,
+        T2.product_category,
+        T2.specification_model,
+        T3.supplier_name,
+        T1.id,
+        T1.product_id,
+        T1.stock_quantity,
+        T2.tax_inclusive_unit_price,
+        T2.tax_inclusive_total_price,
+        T2.tax_rate,
+        T2.tax_exclusive_total_price,
+        T1.inbound_person,
+        T1.supplier_id,
+        T1.tenant_id,
+        T1.bound_time,
+        T1.inbound_time
+        FROM
+        stock_management T1
+        INNER JOIN
+        product_record T2
+        ON
+        T1.product_id = T2.product_id
+        INNER JOIN
+        supplier_manage T3
+        ON
+        T1.supplier_id = T3.id
+        <where>
+            <if test="stockManagementDto.supplierName != null and stockManagementDto.supplierName != ''">
+                AND T3.supplier_name LIKE CONCAT('%', #{stockManagementDto.supplierName}, '%')
+            </if>
+        </where>
+    </select>
 
-    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.inventory.pojo.StockManagement" useGeneratedKeys="true">
-        insert into stock_management
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-                <if test="id != null">id,</if>
-                <if test="productId != null">product_id,</if>
-                <if test="stockQuantity != null">stock_quantity,</if>
-                <if test="taxInclusivePrice != null">tax_inclusive_price,</if>
-                <if test="taxInclusiveTotal != null">tax_inclusive_total,</if>
-                <if test="taxRate != null">tax_rate,</if>
-                <if test="taxExclusiveTotal != null">tax_exclusive_total,</if>
-                <if test="inboundPerson != null">inbound_person,</if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-                <if test="id != null">#{id,jdbcType=INTEGER},</if>
-                <if test="productId != null">#{productId,jdbcType=INTEGER},</if>
-                <if test="stockQuantity != null">#{stockQuantity,jdbcType=INTEGER},</if>
-                <if test="taxInclusivePrice != null">#{taxInclusivePrice,jdbcType=DECIMAL},</if>
-                <if test="taxInclusiveTotal != null">#{taxInclusiveTotal,jdbcType=DECIMAL},</if>
-                <if test="taxRate != null">#{taxRate,jdbcType=DECIMAL},</if>
-                <if test="taxExclusiveTotal != null">#{taxExclusiveTotal,jdbcType=DECIMAL},</if>
-                <if test="inboundPerson != null">#{inboundPerson,jdbcType=VARCHAR},</if>
-        </trim>
-    </insert>
-    <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.inventory.pojo.StockManagement">
-        update stock_management
-        <set>
-                <if test="productId != null">
-                    product_id = #{productId,jdbcType=INTEGER},
-                </if>
-                <if test="stockQuantity != null">
-                    stock_quantity = #{stockQuantity,jdbcType=INTEGER},
-                </if>
-                <if test="taxInclusivePrice != null">
-                    tax_inclusive_price = #{taxInclusivePrice,jdbcType=DECIMAL},
-                </if>
-                <if test="taxInclusiveTotal != null">
-                    tax_inclusive_total = #{taxInclusiveTotal,jdbcType=DECIMAL},
-                </if>
-                <if test="taxRate != null">
-                    tax_rate = #{taxRate,jdbcType=DECIMAL},
-                </if>
-                <if test="taxExclusiveTotal != null">
-                    tax_exclusive_total = #{taxExclusiveTotal,jdbcType=DECIMAL},
-                </if>
-                <if test="inboundPerson != null">
-                    inbound_person = #{inboundPerson,jdbcType=VARCHAR},
-                </if>
-        </set>
-        where   id = #{id,jdbcType=INTEGER} 
-    </update>
 
 </mapper>
diff --git a/src/main/resources/mapper/inventory/StockOutMapper.xml b/src/main/resources/mapper/inventory/StockOutMapper.xml
index 5569d99..a551498 100644
--- a/src/main/resources/mapper/inventory/StockOutMapper.xml
+++ b/src/main/resources/mapper/inventory/StockOutMapper.xml
@@ -4,108 +4,76 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.inventory.mapper.StockOutMapper">
 
-    <resultMap id="BaseResultMap" type="com.ruoyi.inventory.pojo.StockOut">
-            <id property="id" column="id" jdbcType="INTEGER"/>
-            <result property="productId" column="product_id" jdbcType="INTEGER"/>
-            <result property="inboundTime" column="inbound_time" jdbcType="TIMESTAMP"/>
-            <result property="inboundBatch" column="inbound_batch" jdbcType="VARCHAR"/>
-            <result property="supplierName" column="supplier_name" jdbcType="VARCHAR"/>
-            <result property="inboundQuantity" column="inbound_quantity" jdbcType="INTEGER"/>
-            <result property="taxInclusivePrice" column="tax_inclusive_price" jdbcType="DECIMAL"/>
-            <result property="taxInclusiveTotal" column="tax_inclusive_total" jdbcType="DECIMAL"/>
-            <result property="taxRate" column="tax_rate" jdbcType="DECIMAL"/>
-            <result property="taxExclusiveTotal" column="tax_exclusive_total" jdbcType="DECIMAL"/>
-            <result property="inboundPerson" column="inbound_person" jdbcType="VARCHAR"/>
-    </resultMap>
-
-    <sql id="Base_Column_List">
-        id,product_id,inbound_time,
-        inbound_batch,supplier_name,inbound_quantity,
-        tax_inclusive_price,tax_inclusive_total,tax_rate,
-        tax_exclusive_total,inbound_person
-    </sql>
-
-    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-        select
-        <include refid="Base_Column_List" />
-        from stock_out
-        where  id = #{id,jdbcType=INTEGER} 
+    <select id="selectStockOutBypage" resultType="com.ruoyi.inventory.dto.StockoutDto">
+        SELECT
+        T1.id,
+        T1.product_id,
+        T1.inbound_time,
+        T1.inbound_batch,
+        T1.supplier_id,
+        T1.inbound_quantity,
+        T2.tax_inclusive_unit_price,
+        T2.tax_inclusive_total_price,
+        T2.tax_rate,
+        T2.tax_exclusive_total_price,
+        T1.inbound_person,
+        T1.tenant_id,
+        T2.product_category,
+        T2.specification_model,
+        T2.unit,
+        T3.supplier_name
+        FROM
+        stock_out T1
+        INNER JOIN
+        product_record T2
+        ON
+        T1.product_id = T2.product_id
+        INNER JOIN
+        supplier_manage T3
+        ON
+        T1.supplier_id = T3.id
+        <where>
+            <if test="stockOutdto.supplierName != null and stockOutdto.supplierName != ''">
+                AND T3.supplier_name LIKE CONCAT('%', #{stockOutdto.supplierName}, '%')
+            </if>
+        </where>
+        ORDER BY T1.inbound_time DESC
     </select>
-    <select id="selectAll" resultType="com.ruoyi.inventory.pojo.StockOut">
-        select
-        <include refid="Base_Column_List" />
-        from stock_out
+    <select id="stockoutExportList" resultType="com.ruoyi.inventory.excel.StockOutExcelDto">
+        SELECT
+        T1.id,
+        T1.product_id,
+        T1.inbound_time,
+        T1.inbound_batch,
+        T1.supplier_id,
+        T1.inbound_quantity,
+        T2.tax_inclusive_unit_price,
+        T2.tax_inclusive_total_price,
+        T2.tax_rate,
+        T2.tax_exclusive_total_price,
+        T1.inbound_person,
+        T1.tenant_id,
+        T2.product_category,
+        T2.specification_model,
+        T2.unit,
+        T3.supplier_name
+        FROM
+        stock_out T1
+        INNER JOIN
+        product_record T2
+        ON
+        T1.product_id = T2.product_id
+        INNER JOIN
+        supplier_manage T3
+        ON
+        T1.supplier_id = T3.id
+        <where>
+            <if test="stockOutdto.supplierName != null and stockOutdto.supplierName != ''">
+                AND T3.supplier_name LIKE CONCAT('%', #{stockOutdto.supplierName}, '%')
+            </if>
+        </where>
+        ORDER BY T1.inbound_time DESC
     </select>
 
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete from stock_out
-        where  id = #{id,jdbcType=INTEGER} 
-    </delete>
-
-    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.inventory.pojo.StockOut" useGeneratedKeys="true">
-        insert into stock_out
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-                <if test="id != null">id,</if>
-                <if test="productId != null">product_id,</if>
-                <if test="inboundTime != null">inbound_time,</if>
-                <if test="inboundBatch != null">inbound_batch,</if>
-                <if test="supplierName != null">supplier_name,</if>
-                <if test="inboundQuantity != null">inbound_quantity,</if>
-                <if test="taxInclusivePrice != null">tax_inclusive_price,</if>
-                <if test="taxInclusiveTotal != null">tax_inclusive_total,</if>
-                <if test="taxRate != null">tax_rate,</if>
-                <if test="taxExclusiveTotal != null">tax_exclusive_total,</if>
-                <if test="inboundPerson != null">inbound_person,</if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-                <if test="id != null">#{id,jdbcType=INTEGER},</if>
-                <if test="productId != null">#{productId,jdbcType=INTEGER},</if>
-                <if test="inboundTime != null">#{inboundTime,jdbcType=TIMESTAMP},</if>
-                <if test="inboundBatch != null">#{inboundBatch,jdbcType=VARCHAR},</if>
-                <if test="supplierName != null">#{supplierName,jdbcType=VARCHAR},</if>
-                <if test="inboundQuantity != null">#{inboundQuantity,jdbcType=INTEGER},</if>
-                <if test="taxInclusivePrice != null">#{taxInclusivePrice,jdbcType=DECIMAL},</if>
-                <if test="taxInclusiveTotal != null">#{taxInclusiveTotal,jdbcType=DECIMAL},</if>
-                <if test="taxRate != null">#{taxRate,jdbcType=DECIMAL},</if>
-                <if test="taxExclusiveTotal != null">#{taxExclusiveTotal,jdbcType=DECIMAL},</if>
-                <if test="inboundPerson != null">#{inboundPerson,jdbcType=VARCHAR},</if>
-        </trim>
-    </insert>
-    <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.inventory.pojo.StockOut">
-        update stock_out
-        <set>
-                <if test="productId != null">
-                    product_id = #{productId,jdbcType=INTEGER},
-                </if>
-                <if test="inboundTime != null">
-                    inbound_time = #{inboundTime,jdbcType=TIMESTAMP},
-                </if>
-                <if test="inboundBatch != null">
-                    inbound_batch = #{inboundBatch,jdbcType=VARCHAR},
-                </if>
-                <if test="supplierName != null">
-                    supplier_name = #{supplierName,jdbcType=VARCHAR},
-                </if>
-                <if test="inboundQuantity != null">
-                    inbound_quantity = #{inboundQuantity,jdbcType=INTEGER},
-                </if>
-                <if test="taxInclusivePrice != null">
-                    tax_inclusive_price = #{taxInclusivePrice,jdbcType=DECIMAL},
-                </if>
-                <if test="taxInclusiveTotal != null">
-                    tax_inclusive_total = #{taxInclusiveTotal,jdbcType=DECIMAL},
-                </if>
-                <if test="taxRate != null">
-                    tax_rate = #{taxRate,jdbcType=DECIMAL},
-                </if>
-                <if test="taxExclusiveTotal != null">
-                    tax_exclusive_total = #{taxExclusiveTotal,jdbcType=DECIMAL},
-                </if>
-                <if test="inboundPerson != null">
-                    inbound_person = #{inboundPerson,jdbcType=VARCHAR},
-                </if>
-        </set>
-        where   id = #{id,jdbcType=INTEGER} 
-    </update>
 
 </mapper>

--
Gitblit v1.9.3