From 2a8729301fa0e4b20a2cf14273790cd3640ae5a6 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 22 一月 2026 17:36:08 +0800
Subject: [PATCH] yys  巡检管理修改

---
 src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java |   62 +++++++++++-------------------
 1 files changed, 23 insertions(+), 39 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java b/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
index c498b93..a4a5943 100644
--- a/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
+++ b/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
@@ -3,11 +3,13 @@
 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.enums.FileNameType;
 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.other.service.impl.TempFileServiceImpl;
 import com.ruoyi.sales.mapper.ShipmentApprovalMapper;
 import com.ruoyi.sales.mapper.ShippingInfoMapper;
 import com.ruoyi.sales.pojo.SalesLedger;
@@ -17,6 +19,7 @@
 import com.ruoyi.sales.service.ISalesLedgerProductService;
 import com.ruoyi.sales.service.ISalesLedgerService;
 import com.ruoyi.sales.service.ShippingInfoService;
+import com.ruoyi.sales.service.impl.CommonFileServiceImpl;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections4.CollectionUtils;
@@ -25,6 +28,7 @@
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -43,6 +47,12 @@
     @Autowired
     private ISalesLedgerProductService salesLedgerProductService;
 
+    @Autowired
+    private TempFileServiceImpl tempFileService;
+
+    @Autowired
+    private CommonFileServiceImpl commonFileService;
+
 
     @GetMapping("/listPage")
     @ApiOperation("鍙戣揣淇℃伅鍒楄〃")
@@ -54,64 +64,38 @@
     @PostMapping("/add")
     @ApiOperation("娣诲姞鍙戣揣淇℃伅")
     @Transactional(rollbackFor = Exception.class)
-    public AjaxResult add(@RequestBody ShippingInfo req) {
-        LambdaQueryWrapper<ShippingInfo> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(ShippingInfo::getSalesLedgerId, req.getSalesLedgerId());
-        wrapper.eq(ShippingInfo::getSalesLedgerProductId, req.getSalesLedgerProductId());
-        List<ShippingInfo> list = shippingInfoService.list(wrapper);
-        if(!CollectionUtils.isEmpty(list)){
-            return AjaxResult.error("鍙戣揣淇℃伅宸插瓨鍦�");
-        }
+    public AjaxResult add(@RequestBody ShippingInfo req) throws IOException {
         boolean save = shippingInfoService.save(req);
-        if(save){
-            ShippingInfo shippingInfo = shippingInfoService.getOne(wrapper);
-            ShipmentApproval shipmentApproval = new ShipmentApproval();
-            shipmentApproval.setSalesLedgerId(req.getSalesLedgerId());
-            shipmentApproval.setSalesLedgerProductId(req.getSalesLedgerProductId());
-            shipmentApproval.setApproveUserId(req.getApproverId());
-            shipmentApproval.setApproveStatus(2);
-            shipmentApproval.setShippingInfoId(shippingInfo.getId());
-            shipmentApprovalMapper.insert(shipmentApproval);
-
-            SalesLedgerProduct salesLedgerProduct = salesLedgerProductService.getById(req.getSalesLedgerProductId());
-            if(salesLedgerProduct != null){
-                salesLedgerProduct.setApproveStatus(2);
-                salesLedgerProductService.updateById(salesLedgerProduct);
-            }
-
+        // 杩佺Щ鏂囦欢
+        if(CollectionUtils.isNotEmpty(req.getTempFileIds())){
+            tempFileService.migrateTempFilesToFormal(req.getId(), req.getTempFileIds(), FileNameType.SHIP.getValue());
         }
         return save ? AjaxResult.success() : AjaxResult.error();
     }
 
     @PostMapping("/update")
     @ApiOperation("淇敼鍙戣揣淇℃伅")
-    public AjaxResult update(@RequestBody ShippingInfo req) {
+    @Transactional(rollbackFor = Exception.class)
+    public AjaxResult update(@RequestBody ShippingInfo req) throws IOException {
         ShippingInfo byId = shippingInfoService.getById(req.getId());
         if (byId == null) {
             return AjaxResult.error("鍙戣揣淇℃伅涓嶅瓨鍦�");
         }
-        Long userId = getLoginUser().getUserId();
-        if(!userId.equals(Long.parseLong(byId.getCreateUser().toString()))){
-            return AjaxResult.error("鎮ㄦ病鏈夋潈闄愪慨鏀规鍙戣揣淇℃伅");
-        }
         boolean update = shippingInfoService.updateById(req);
+        if(CollectionUtils.isNotEmpty(req.getTempFileIds())){
+            tempFileService.migrateTempFilesToFormal(req.getId(), req.getTempFileIds(), FileNameType.SHIP.getValue());
+        }
         return update ? AjaxResult.success() : AjaxResult.error();
     }
 
     @DeleteMapping("/delete")
     @ApiOperation("鍒犻櫎鍙戣揣淇℃伅")
+    @Transactional(rollbackFor = Exception.class)
     public AjaxResult delete(@RequestBody List<Long> ids) {
-        Long userId = getLoginUser().getUserId();
-        ids.forEach(id -> {
-            ShippingInfo byId = shippingInfoService.getById(id);
-            if (byId == null) {
-                throw new RuntimeException("鍙戣揣淇℃伅涓嶅瓨鍦�");
-            }
-            if(!userId.equals(Long.parseLong(byId.getCreateUser().toString()))){
-                throw new RuntimeException("鎮ㄦ病鏈夋潈闄愬垹闄ゆ鍙戣揣淇℃伅");
-            }
-        });
+        if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("璇烽�夋嫨瑕佸垹闄ょ殑璁板綍");
         boolean delete = shippingInfoService.removeBatchByIds(ids);
+        // 鍒犻櫎闄勪欢
+        commonFileService.deleteByBusinessIds(ids, FileNameType.SHIP.getValue());
         return delete ? AjaxResult.success("鍒犻櫎鎴愬姛") : AjaxResult.error("鍒犻櫎澶辫触");
     }
 

--
Gitblit v1.9.3