From a8e4132c3e2e9c3b3fcb0360901b35571b6464ea Mon Sep 17 00:00:00 2001
From: hsy <1029150275@qq.com>
Date: 星期五, 28 八月 2026 10:13:01 +0800
Subject: [PATCH] feat: 综合业务模块功能补充与实体拓展

---
 src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java |   63 +++++++++++++------------------
 1 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java b/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
index 9ca9b3a..5782115 100644
--- a/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
+++ b/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
@@ -2,15 +2,12 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.approve.bean.vo.ApproveProcessVO;
 import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
-import com.ruoyi.common.utils.OrderUtils;
-import com.ruoyi.common.utils.SecurityUtils;
 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.security.LoginUser;
 import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.framework.web.domain.R;
 import com.ruoyi.sales.dto.ShippingInfoDto;
 import com.ruoyi.sales.mapper.ShippingInfoMapper;
@@ -24,7 +21,6 @@
 import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
-import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -44,62 +40,57 @@
 
     @GetMapping("/listPage")
     @Operation(summary = "鍙戣揣淇℃伅鍒楄〃")
-    public R<?> listPage(Page page, ShippingInfo req) {
+    public AjaxResult listPage(Page page, ShippingInfo req) {
         IPage<ShippingInfoDto> listPage = shippingInfoService.listPage(page,req);
-        return R.ok(listPage);
+        return AjaxResult.success(listPage);
     }
 
     @PostMapping("/add")
     @Operation(summary = "娣诲姞鍙戣揣淇℃伅")
     @Transactional(rollbackFor = Exception.class)
     @Log(title = "鍙戣揣淇℃伅绠$悊", businessType = BusinessType.INSERT)
-    public R<?> add(@RequestBody ShippingInfoDto req) throws Exception {
-        LoginUser loginUser = SecurityUtils.getLoginUser();
-        String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH","shipping_no");
-        // 鍙戣揣瀹℃壒
-        ApproveProcessVO approveProcessVO = new ApproveProcessVO();
-        approveProcessVO.setApproveType(7);
-        approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
-        approveProcessVO.setApproveReason(sh);//鍙戣揣缂栧彿
-        approveProcessVO.setApproveUserIds(req.getApproveUserIds());
-        approveProcessVO.setApproveUser(loginUser.getUserId());
-        approveProcessVO.setApproveTime(LocalDate.now().toString());
-        approveProcessService.addApprove(approveProcessVO);
-        // 娣诲姞鍙戣揣娑堟伅
-        req.setShippingNo(sh);
-        req.setStatus("寰呭鏍�");
-        boolean save = shippingInfoService.add(req);
-        return save ? R.ok() : R.fail();
+    public AjaxResult add(@RequestBody ShippingInfoDto req) throws Exception {
+        return AjaxResult.success(shippingInfoService.addReq(req) ? "娣诲姞鎴愬姛" : "娣诲姞澶辫触");
     }
 
     @Operation(summary = "鍙戣揣鎵e簱瀛�")
     @PostMapping("/deductStock")
     @Transactional(rollbackFor = Exception.class)
     @Log(title = "鍙戣揣淇℃伅绠$悊", businessType = BusinessType.UPDATE)
-    public R<?> deductStock(@RequestBody ShippingInfoDto req) throws IOException {
-        return shippingInfoService.deductStock( req) ? R.ok() : R.fail();
+    public AjaxResult deductStock(@RequestBody ShippingInfoDto req) throws IOException {
+        return shippingInfoService.deductStock( req) ? AjaxResult.success() : AjaxResult.error();
     }
 
     @PostMapping("/update")
     @Operation(summary = "淇敼鍙戣揣淇℃伅")
     @Transactional(rollbackFor = Exception.class)
     @Log(title = "鍙戣揣淇℃伅绠$悊", businessType = BusinessType.UPDATE)
-    public R<?> update(@RequestBody ShippingInfo req) {
+    public AjaxResult update(@RequestBody ShippingInfo req) {
         ShippingInfo byId = shippingInfoService.getById(req.getId());
         if (byId == null) {
-            return R.fail("鍙戣揣淇℃伅涓嶅瓨鍦�");
+            return AjaxResult.error("鍙戣揣淇℃伅涓嶅瓨鍦�");
+        }
+        if ("瀹℃牳閫氳繃".equals(byId.getStatus()) && !"宸插彂璐�".equals(req.getStatus())) {
+            // Note: If the request is from outbound management trying to change status to "宸插彂璐�", it's allowed.
+            // But if it's a normal edit, it's blocked. We just check if it's already 瀹℃牳閫氳繃 and they are updating other fields.
+            return AjaxResult.error("宸插鏍搁�氳繃锛屼笉鑳界紪杈戝彂璐т俊鎭�");
         }
         boolean update = shippingInfoService.updateById(req);
-        return update ? R.ok() : R.fail();
+        return update ? AjaxResult.success() : AjaxResult.error();
     }
 
     @DeleteMapping("/delete")
     @Operation(summary = "鍒犻櫎鍙戣揣淇℃伅")
     @Transactional(rollbackFor = Exception.class)
     @Log(title = "鍙戣揣淇℃伅绠$悊", businessType = BusinessType.DELETE)
-    public R<?> delete(@RequestBody List<Long> ids) {
-
-        return shippingInfoService.delete(ids) ? R.ok("鍒犻櫎鎴愬姛") : R.fail("鍒犻櫎澶辫触");
+    public AjaxResult delete(@RequestBody List<Long> ids) {
+        for (Long id : ids) {
+            ShippingInfo byId = shippingInfoService.getById(id);
+            if (byId != null && ("宸插彂璐�".equals(byId.getStatus()) || "瀹℃牳閫氳繃".equals(byId.getStatus()))) {
+                return AjaxResult.error("瀛樺湪宸插彂璐ф垨瀹℃牳閫氳繃鐨勪骇鍝侊紝涓嶈兘鍒犻櫎");
+            }
+        }
+        return shippingInfoService.delete(ids) ? AjaxResult.success("鍒犻櫎鎴愬姛") : AjaxResult.error("鍒犻櫎澶辫触");
     }
 
     /**
@@ -107,8 +98,8 @@
      */
     @PostMapping("/export")
     @Operation(summary = "瀵煎嚭鍙戣揣淇℃伅")
-    public void export(HttpServletResponse response) {
-        List<ShippingInfo> list = shippingInfoMapper.listAll();
+    public void export(HttpServletResponse response, ShippingInfo req) {
+        List<ShippingInfo> list = shippingInfoMapper.listAll(req);
         ExcelUtil<ShippingInfo> util = new ExcelUtil<ShippingInfo>(ShippingInfo.class);
         util.exportExcel(response, list, "鍙戣揣淇℃伅");
     }
@@ -116,8 +107,8 @@
 
     @GetMapping("/getByCustomerName")
     @Operation(summary = "閫氳繃瀹㈡埛鍚嶇О鏌ヨ鍏宠仈鐨勫彂璐у崟鍙�")
-    public R<?> getByCustomerName(String customerName) {
-        return R.ok(shippingInfoService.getShippingInfoByCustomerName(customerName));
+    public AjaxResult getByCustomerName(String customerName) {
+        return AjaxResult.success(shippingInfoService.getShippingInfoByCustomerName(customerName));
     }
 
     @GetMapping("/getDateil/{id}")

--
Gitblit v1.9.3