From d3a5c4420a7daf89bc9832f22ca8ed9d7e1adaf9 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 27 三月 2026 17:34:32 +0800
Subject: [PATCH] yys 1.完善销售下单,生成生产订单
---
src/main/java/com/ruoyi/basic/controller/ProductController.java | 80 +++++++++++++++++++++++++++++++++++++--
1 files changed, 75 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/controller/ProductController.java b/src/main/java/com/ruoyi/basic/controller/ProductController.java
index d042cb6..22dc714 100644
--- a/src/main/java/com/ruoyi/basic/controller/ProductController.java
+++ b/src/main/java/com/ruoyi/basic/controller/ProductController.java
@@ -1,18 +1,32 @@
package com.ruoyi.basic.controller;
-import com.ruoyi.basic.dto.ProductDto;
-import com.ruoyi.basic.dto.ProductModelDto;
-import com.ruoyi.basic.dto.ProductTreeDto;
+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.dto.*;
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.basic.service.IProductModelService;
import com.ruoyi.basic.service.IProductService;
+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.production.pojo.ProductProcess;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.service.ISalesLedgerProductService;
+import com.ruoyi.sales.service.ISalesLedgerService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
import java.util.List;
@RestController
@@ -23,8 +37,16 @@
private IProductService productService;
private IProductModelService productModelService;
+ @Autowired
+ private ISalesLedgerProductService salesLedgerProductService;
-
+ /**
+ * 鍒嗛〉鏌ヨ
+ */
+ @GetMapping("/listPage")
+ public AjaxResult listPage(Page page, ProductAndModelDto productDto) {
+ return productService.listPage(page, productDto);
+ }
/**
* 鏌ヨ浜у搧
*/
@@ -55,7 +77,7 @@
*/
@Log(title = "浜у搧瑙勬牸鍨嬪彿", businessType = BusinessType.INSERT)
@PostMapping("/addOrEditProductModel")
- public AjaxResult addOrEditProductModel(@RequestBody ProductModelDto productModelDto) {
+ public AjaxResult addOrEditProductModel(@RequestBody ProductModelDto productModelDto) throws IOException {
return toAjax(productModelService.addOrEditProductModel(productModelDto));
}
@@ -64,9 +86,17 @@
*/
@Log(title = "浜у搧", businessType = BusinessType.DELETE)
@DeleteMapping("/delProduct")
+ @Transactional(rollbackFor = Exception.class)
public AjaxResult remove(@RequestBody Long[] ids) {
if (ids == null || ids.length == 0) {
return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
+ }
+ // 妫�鏌ユ槸鍚︽湁閿�鍞晢鍝佽褰曞叧鑱旇浜у搧
+ LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.in(SalesLedgerProduct::getProductModelId, ids);
+ List<SalesLedgerProduct> salesLedgerProductList = salesLedgerProductService.list(queryWrapper);
+ if (CollectionUtils.isNotEmpty(salesLedgerProductList)) {
+ return AjaxResult.error("璇ヤ骇鍝佸瓨鍦ㄩ攢鍞�/閲囪喘璁板綍锛屼笉鑳藉垹闄�");
}
return toAjax(productService.delProductByIds(ids));
}
@@ -80,6 +110,46 @@
if (ids == null || ids.length == 0) {
return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
}
+ // 妫�鏌ユ槸鍚︽湁閿�鍞晢鍝佽褰曞叧鑱旇浜у搧瑙勬牸鍨嬪彿
+ LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.in(SalesLedgerProduct::getProductModelId, ids);
+ List<SalesLedgerProduct> salesLedgerProductList = salesLedgerProductService.list(queryWrapper);
+ if (salesLedgerProductList.size() > 0) {
+ return AjaxResult.error("璇ヤ骇鍝佽鏍煎瀷鍙峰瓨鍦ㄩ攢鍞�/閲囪喘璁板綍锛屼笉鑳藉垹闄�");
+ }
return toAjax(productModelService.delProductModel(ids));
}
+
+ /**
+ * 鏍规嵁id鏌ヨ浜у搧瑙勬牸鍒嗛〉鏌ヨ
+ */
+ @GetMapping("/modelListPage")
+ public IPage<ProductModel> selectModelListPage(Page page, ProductDto productDto) {
+ return productModelService.modelListPage(page, productDto);
+ }
+
+ @ApiOperation("鍒嗛〉鏌ヨ鎵�鏈変骇鍝佸瀷鍙�")
+ @GetMapping("/pageModel")
+ public IPage<ProductModel> listPageProductModel(Page<ProductModel> page, ProductModel productModel) {
+ return productService.listPageProductModel(page, productModel);
+ }
+
+ /**
+ * 瀵煎叆浜у搧
+ */
+ @Log(title = "瀵煎叆浜у搧",businessType = BusinessType.IMPORT)
+ @PostMapping("import")
+ public AjaxResult importProduct(MultipartFile file) {
+ return AjaxResult.success(productModelService.importProduct(file));
+ }
+
+ /**
+ * 涓嬭浇妯℃澘
+ */
+ @ApiOperation("涓嬭浇妯℃澘")
+ @PostMapping("downloadTemplate")
+ public void downloadTemplate(HttpServletResponse response) {
+ ExcelUtil<ProductModelExcelCopyDto> util = new ExcelUtil<ProductModelExcelCopyDto>(ProductModelExcelCopyDto.class);
+ util.importTemplateExcel(response, "浜у搧瀵煎叆妯℃澘");
+ }
}
--
Gitblit v1.9.3