From 3f3a1ed182e96214e66f6456ee692427bf04d454 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 28 十一月 2025 11:10:23 +0800
Subject: [PATCH] yys 1.库存管理导出修改 2.来票登记分页查询修改

---
 src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java b/src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java
index 22b96b4..ae73e64 100644
--- a/src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java
+++ b/src/main/java/com/ruoyi/production/controller/SalesLedgerSchedulingController.java
@@ -1,7 +1,9 @@
 package com.ruoyi.production.controller;
 
+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.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;
@@ -11,14 +13,22 @@
 import com.ruoyi.production.dto.ProductionDispatchAddDto;
 import com.ruoyi.production.dto.SalesLedgerSchedulingDto;
 import com.ruoyi.production.dto.SalesLedgerSchedulingProcessDto;
+import com.ruoyi.production.mapper.SpeculativeTradingInfoMapper;
+import com.ruoyi.production.pojo.SpeculativeTradingInfo;
 import com.ruoyi.production.service.impl.SalesLedgerSchedulingServiceImpl;
+import com.ruoyi.sales.mapper.LossMapper;
+import com.ruoyi.sales.pojo.Loss;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -32,6 +42,70 @@
 
     @Autowired
     private SalesLedgerSchedulingServiceImpl salesLedgerSchedulingService;
+
+
+    @Autowired
+    private SpeculativeTradingInfoMapper speculativeTradingInfoMapper;
+
+    @Autowired
+    private LossMapper lossMapper;
+
+    @GetMapping("/loss")
+    @Log(title = "鐢熶骇绠$悊-鐢熶骇娲惧伐-鎹熻�楃巼", businessType = BusinessType.OTHER)
+    @ApiOperation("鐢熶骇绠$悊-鐢熶骇娲惧伐-鎹熻�楃巼")
+    public AjaxResult loss() {
+        return AjaxResult.success(lossMapper.selectOne(new LambdaQueryWrapper<Loss>().last("limit 1")));
+    }
+
+    @PostMapping("/addLoss")
+    @Log(title = "鐢熶骇绠$悊-鐢熶骇娲惧伐-娣诲姞鎹熻�楃巼", businessType = BusinessType.INSERT)
+    @ApiOperation("鐢熶骇绠$悊-鐢熶骇娲惧伐-娣诲姞鎹熻�楃巼")
+    public AjaxResult addLoss(@RequestBody Loss loss) {
+        lossMapper.insert(loss);
+        return AjaxResult.success("娣诲姞鎹熻�楃巼鎴愬姛");
+    }
+
+    @PostMapping("/updateLoss")
+    @Log(title = "鐢熶骇绠$悊-鐢熶骇娲惧伐-淇敼鎹熻�楃巼", businessType = BusinessType.UPDATE)
+    @ApiOperation("鐢熶骇绠$悊-鐢熶骇娲惧伐-淇敼鎹熻�楃巼")
+    public AjaxResult updateLoss(@RequestBody Loss loss) {
+        lossMapper.updateById(loss);
+        return AjaxResult.success("淇敼鎹熻�楃巼鎴愬姛");
+    }
+
+    @GetMapping("/list")
+    @Log(title = "鐢熶骇绠$悊-鐢熶骇娲惧伐-鐐掓満淇℃伅", businessType = BusinessType.OTHER)
+    @ApiOperation("鐢熶骇绠$悊-鐢熶骇娲惧伐-鐐掓満淇℃伅")
+    public AjaxResult list() {
+        List<SpeculativeTradingInfo> result = speculativeTradingInfoMapper.selectList(null);
+        result.forEach(item -> {
+            item.setCurrentWorkLoad(salesLedgerSchedulingService.getSchedulingNumBySpeculativeTradingName(item.getName()).divide(new BigDecimal(1000),2, RoundingMode.CEILING));
+            item.setVacant(item.getWorkLoad().subtract(item.getCurrentWorkLoad()).setScale(2, RoundingMode.HALF_UP)); //淇濈暀涓や綅灏忔暟
+        });
+        return AjaxResult.success(result);
+    }
+
+    @PostMapping("/addSpeculatTrading")
+    @Log(title = "鐢熶骇绠$悊-鐢熶骇娲惧伐-娣诲姞鐐掓満淇℃伅", businessType = BusinessType.INSERT)
+    @ApiOperation("鐢熶骇绠$悊-鐢熶骇娲惧伐-娣诲姞鐐掓満淇℃伅")
+    public AjaxResult addSpeculatTrading(@RequestBody List<SpeculativeTradingInfo> speculativeTradingInfo) {
+        if(CollectionUtils.isEmpty(speculativeTradingInfo)) return AjaxResult.error("鏁版嵁缁勪笉鑳戒负绌�");
+        speculativeTradingInfo.forEach(item -> {
+            speculativeTradingInfoMapper.insert(item);
+        });
+        return AjaxResult.success("娣诲姞鐐掓満淇℃伅鎴愬姛");
+    }
+
+    @PostMapping("/updateSpeculatTrading")
+    @Log(title = "鐢熶骇绠$悊-鐢熶骇娲惧伐-淇敼鐐掓満淇℃伅", businessType = BusinessType.UPDATE)
+    @ApiOperation("鐢熶骇绠$悊-鐢熶骇娲惧伐-淇敼鐐掓満淇℃伅")
+    public AjaxResult updateSpeculatTrading(@RequestBody List<SpeculativeTradingInfo> speculativeTradingInfo) {
+        if(CollectionUtils.isEmpty(speculativeTradingInfo)) return AjaxResult.error("鏁版嵁缁勪笉鑳戒负绌�");
+        speculativeTradingInfo.forEach(item -> {
+            speculativeTradingInfoMapper.updateById(item);
+        });
+        return AjaxResult.success("淇敼鐐掓満淇℃伅鎴愬姛");
+    }
 
 
     @GetMapping("/listPage")
@@ -52,12 +126,34 @@
         salesLedgerSchedulingService.export(response);
     }
 
+
+    /**
+     * 瀵煎嚭
+     * @param response
+     */
+    @PostMapping("/exportOne")
+    @ApiOperation("鐢熶骇绠$悊-鐢熶骇娲惧伐-瀵煎嚭")
+    public void exportOne(HttpServletResponse response) {
+        salesLedgerSchedulingService.exportOne(response);
+    }
+
     @PostMapping("/productionDispatch")
     @Log(title = "鐢熶骇绠$悊-鐢熶骇璁㈠崟-鐢熶骇娲惧伐", businessType = BusinessType.INSERT)
     @ApiOperation("鐢熶骇绠$悊-鐢熶骇璁㈠崟-鐢熶骇娲惧伐")
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult productionDispatch(@RequestBody ProductionDispatchAddDto productionDispatchAddDto) {
-        int result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDto);
+        List<ProductionDispatchAddDto> productionDispatchAddDtoList = new ArrayList<>();
+        productionDispatchAddDtoList.add(productionDispatchAddDto);
+        String result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDtoList);
+        return AjaxResult.success(result);
+    }
+
+    @PostMapping("/productionDispatchList")
+    @Log(title = "鐢熶骇绠$悊-鐢熶骇璁㈠崟-鑷姩娲惧伐", businessType = BusinessType.INSERT)
+    @ApiOperation("鐢熶骇绠$悊-鐢熶骇璁㈠崟-鑷姩娲惧伐")
+    @Transactional(rollbackFor = Exception.class)
+    public AjaxResult productionDispatchList(@RequestBody List<ProductionDispatchAddDto> productionDispatchAddDto) {
+        String result = salesLedgerSchedulingService.productionDispatch(productionDispatchAddDto);
         return AjaxResult.success(result);
     }
 
@@ -69,6 +165,23 @@
         return AjaxResult.success(result);
     }
 
+    /**
+     * 瀵煎嚭
+     * @param response
+     */
+    @PostMapping("/exportTwo")
+    @ApiOperation("鐢熶骇绠$悊-宸ュ簭鎺掍骇-瀵煎嚭")
+    public void exportTwo(HttpServletResponse response) {
+        Page page = new Page(-1,-1);
+        SalesLedgerSchedulingProcessDto salesLedgerSchedulingDto = new SalesLedgerSchedulingProcessDto();
+        IPage<SalesLedgerSchedulingProcessDto> result = salesLedgerSchedulingService.listPageProcess(page,salesLedgerSchedulingDto);
+        result.getRecords().forEach(item -> {
+            item.setStatusName(item.getStatus().toString());
+        });
+        ExcelUtil<SalesLedgerSchedulingProcessDto> util = new ExcelUtil<>(SalesLedgerSchedulingProcessDto.class);
+        util.exportExcel(response, result.getRecords(), "宸ュ簭鎺掍骇");
+    }
+
 
     @DeleteMapping("/productionDispatchDelete")
     @Log(title = "鐢熶骇绠$悊-宸ュ簭鎺掍骇-鍙栨秷鎺掍骇", businessType = BusinessType.DELETE)

--
Gitblit v1.9.3