From ffa5afb4e38d577c85813f48e41696f0c569c7a7 Mon Sep 17 00:00:00 2001
From: cuijian <cuijian@xalxzn.com>
Date: 星期二, 01 七月 2025 18:09:57 +0800
Subject: [PATCH] 质量-检验工具,检验项目

---
 src/main/java/org/jeecg/modules/base/controller/SupplierController.java |  351 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 200 insertions(+), 151 deletions(-)

diff --git a/src/main/java/org/jeecg/modules/base/controller/SupplierController.java b/src/main/java/org/jeecg/modules/base/controller/SupplierController.java
index 6ed75b9..c46995b 100644
--- a/src/main/java/org/jeecg/modules/base/controller/SupplierController.java
+++ b/src/main/java/org/jeecg/modules/base/controller/SupplierController.java
@@ -1,177 +1,226 @@
 package org.jeecg.modules.base.controller;
 
+import java.io.File;
+import java.net.URLEncoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.base.entity.Supplier;
+import org.jeecg.modules.base.service.ISupplierService;
+
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.aspect.annotation.AutoLog;
+
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.jeecg.common.system.base.controller.JeecgController;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.base.entity.Supplier;
-import org.jeecg.modules.base.entity.SupplierCategory;
-import org.jeecg.modules.base.service.ISupplierCategoryService;
-import org.jeecg.modules.base.service.ISupplierService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.jeecg.common.aspect.annotation.AutoLog;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Arrays;
-import java.util.List;
-
-/**
-* @Description: 渚涘簲鍟�
-* @Author: jeecg-boot
-* @Date:   2023-03-10
-* @Version: V1.0
-*/
-@Api(tags="渚涘簲鍟�")
+ /**
+ * @Description: 渚涘簲鍟嗙鐞�
+ * @Author: jeecg-boot
+ * @Date:   2025-06-24
+ * @Version: V1.0
+ */
+@Api(tags="渚涘簲鍟嗙鐞�")
 @RestController
-@RequestMapping("/eam/supplier")
+@RequestMapping("/base/supplier")
 @Slf4j
 public class SupplierController extends JeecgController<Supplier, ISupplierService> {
-    @Autowired
-    private ISupplierService inspectionProjectService;
-    @Autowired
-    private ISupplierCategoryService inspectionProjectCategoryService;
-
+	@Autowired
+	private ISupplierService supplierService;
+	
+	/**
+	 * 鍒嗛〉鍒楄〃鏌ヨ
+	 *
+	 * @param supplier
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	//@AutoLog(value = "渚涘簲鍟嗙鐞�-鍒嗛〉鍒楄〃鏌ヨ")
+	@ApiOperation(value="渚涘簲鍟嗙鐞�-鍒嗛〉鍒楄〃鏌ヨ", notes="渚涘簲鍟嗙鐞�-鍒嗛〉鍒楄〃鏌ヨ")
+	@GetMapping(value = "/list")
+	public Result<IPage<Supplier>> queryPageList(Supplier supplier,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<Supplier> queryWrapper = QueryGenerator.initQueryWrapper(supplier, req.getParameterMap());
+		Page<Supplier> page = new Page<Supplier>(pageNo, pageSize);
+		IPage<Supplier> pageList = supplierService.page(page, queryWrapper);
+		return Result.OK(pageList);
+	}
+	
+	/**
+	 *   娣诲姞
+	 *
+	 * @param supplier
+	 * @return
+	 */
+	@AutoLog(value = "渚涘簲鍟嗙鐞�-娣诲姞")
+	@ApiOperation(value="渚涘簲鍟嗙鐞�-娣诲姞", notes="渚涘簲鍟嗙鐞�-娣诲姞")
+	//@RequiresPermissions("org.jeecg.modules:base_supplier:add")
+	@PostMapping(value = "/add")
+	public Result<String> add(@RequestBody Supplier supplier) {
+		supplier.setSupplierStatus(CommonConstant.STATUS_1);
+		supplierService.save(supplier);
+		return Result.OK("娣诲姞鎴愬姛锛�");
+	}
+	
+	/**
+	 *  缂栬緫
+	 *
+	 * @param supplier
+	 * @return
+	 */
+	@AutoLog(value = "渚涘簲鍟嗙鐞�-缂栬緫")
+	@ApiOperation(value="渚涘簲鍟嗙鐞�-缂栬緫", notes="渚涘簲鍟嗙鐞�-缂栬緫")
+	//@RequiresPermissions("org.jeecg.modules:base_supplier:edit")
+	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+	public Result<String> edit(@RequestBody Supplier supplier) {
+		supplierService.updateById(supplier);
+		return Result.OK("缂栬緫鎴愬姛!");
+	}
+	
+	/**
+	 *   閫氳繃id鍒犻櫎
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "渚涘簲鍟嗙鐞�-閫氳繃id鍒犻櫎")
+	@ApiOperation(value="渚涘簲鍟嗙鐞�-閫氳繃id鍒犻櫎", notes="渚涘簲鍟嗙鐞�-閫氳繃id鍒犻櫎")
+	//@RequiresPermissions("org.jeecg.modules:base_supplier:delete")
+	@DeleteMapping(value = "/delete")
+	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+		supplierService.removeById(id);
+		return Result.OK("鍒犻櫎鎴愬姛!");
+	}
+	
+	/**
+	 *  鎵归噺鍒犻櫎
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "渚涘簲鍟嗙鐞�-鎵归噺鍒犻櫎")
+	@ApiOperation(value="渚涘簲鍟嗙鐞�-鎵归噺鍒犻櫎", notes="渚涘簲鍟嗙鐞�-鎵归噺鍒犻櫎")
+	//@RequiresPermissions("org.jeecg.modules:base_supplier:deleteBatch")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		this.supplierService.removeByIds(Arrays.asList(ids.split(",")));
+		return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
+	}
+	
+	/**
+	 * 閫氳繃id鏌ヨ
+	 *
+	 * @param id
+	 * @return
+	 */
+	//@AutoLog(value = "渚涘簲鍟嗙鐞�-閫氳繃id鏌ヨ")
+	@ApiOperation(value="渚涘簲鍟嗙鐞�-閫氳繃id鏌ヨ", notes="渚涘簲鍟嗙鐞�-閫氳繃id鏌ヨ")
+	@GetMapping(value = "/queryById")
+	public Result<Supplier> queryById(@RequestParam(name="id",required=true) String id) {
+		Supplier supplier = supplierService.getById(id);
+		if(supplier==null) {
+			return Result.error("鏈壘鍒板搴旀暟鎹�");
+		}
+		return Result.OK(supplier);
+	}
 
     /**
-     * 鍒嗛〉鍒楄〃鏌ヨ
-     *
-     * @param inspectionProject
-     * @param pageNo
-     * @param pageSize
-     * @param req
-     * @return
-     */
-    @ApiOperation(value="渚涘簲鍟�-鍒嗛〉鍒楄〃鏌ヨ", notes="渚涘簲鍟�-鍒嗛〉鍒楄〃鏌ヨ")
-    @GetMapping(value = "/list")
-    public Result<IPage<Supplier>> queryPageList(Supplier inspectionProject,
-                                                          @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-                                                          @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-                                                          HttpServletRequest req) {
-        QueryWrapper<Supplier> queryWrapper = QueryGenerator.initQueryWrapper(inspectionProject, req.getParameterMap());
-        Page<Supplier> page = new Page<Supplier>(pageNo, pageSize);
-        IPage<Supplier> pageList = inspectionProjectService.page(page, queryWrapper);
-        List<Supplier> records = pageList.getRecords();
-        for (Supplier record : records) {
-            String inspectionProjectTypeId = record.getSupplierCategoryId();
-            SupplierCategory inspectionProjectCategory = inspectionProjectCategoryService.getById(inspectionProjectTypeId);
-            if(inspectionProjectCategory != null ){
-                record.setSupplierCategoryNumName(inspectionProjectCategory.getNum()+"/"+ inspectionProjectCategory.getName());
-            }else{
-                record.setSupplierCategoryNumName("/");
-            }
-
-        }
-        return Result.OK(pageList);
-    }
-
-    /**
-     *   娣诲姞
-     *
-     * @param inspectionProject
-     * @return
-     */
-    @AutoLog(value = "渚涘簲鍟�-娣诲姞")
-    @ApiOperation(value="渚涘簲鍟�-娣诲姞", notes="渚涘簲鍟�-娣诲姞")
-    @PostMapping(value = "/add")
-    public Result<String> add(@RequestBody Supplier inspectionProject) {
-        inspectionProjectService.save(inspectionProject);
-        return Result.OK("娣诲姞鎴愬姛锛�");
-    }
-
-    /**
-     *  缂栬緫
-     *
-     * @param inspectionProject
-     * @return
-     */
-    @AutoLog(value = "渚涘簲鍟�-缂栬緫")
-    @ApiOperation(value="渚涘簲鍟�-缂栬緫", notes="渚涘簲鍟�-缂栬緫")
-    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-    public Result<String> edit(@RequestBody Supplier inspectionProject) {
-        inspectionProjectService.updateById(inspectionProject);
-        return Result.OK("缂栬緫鎴愬姛!");
-    }
-
-    /**
-     *   閫氳繃id鍒犻櫎
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "渚涘簲鍟�-閫氳繃id鍒犻櫎")
-    @ApiOperation(value="渚涘簲鍟�-閫氳繃id鍒犻櫎", notes="渚涘簲鍟�-閫氳繃id鍒犻櫎")
-    @DeleteMapping(value = "/delete")
-    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
-        Supplier inspectionProject = inspectionProjectService.getById(id);
-        inspectionProject.setDelFlag(1);
-        inspectionProjectService.updateById(inspectionProject);
-        return Result.OK("鍒犻櫎鎴愬姛!");
-    }
-
-    /**
-     *  鎵归噺鍒犻櫎
-     *
-     * @param ids
-     * @return
-     */
-    @AutoLog(value = "渚涘簲鍟�-鎵归噺鍒犻櫎")
-    @ApiOperation(value="渚涘簲鍟�-鎵归噺鍒犻櫎", notes="渚涘簲鍟�-鎵归噺鍒犻櫎")
-    @DeleteMapping(value = "/deleteBatch")
-    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-        List<String> idList = Arrays.asList(ids.split(","));
-        for (String id : idList) {
-            Supplier inspectionProject = inspectionProjectService.getById(id);
-            inspectionProject.setDelFlag(1);
-            inspectionProjectService.updateById(inspectionProject);
-        }
-        return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
-    }
-
-    /**
-     * 閫氳繃id鏌ヨ
-     *
-     * @param id
-     * @return
-     */
-    @ApiOperation(value="渚涘簲鍟�-閫氳繃id鏌ヨ", notes="渚涘簲鍟�-閫氳繃id鏌ヨ")
-    @GetMapping(value = "/queryById")
-    public Result<Supplier> queryById(@RequestParam(name="id",required=true) String id) {
-        Supplier inspectionProject = inspectionProjectService.getById(id);
-        if(inspectionProject==null) {
-            return Result.error("鏈壘鍒板搴旀暟鎹�");
-        }
-        return Result.OK(inspectionProject);
-    }
-
-    /**
-     * 瀵煎嚭excel
-     *
-     * @param request
-     * @param inspectionProject
-     */
+    * 瀵煎嚭excel
+    *
+    * @param request
+    * @param supplier
+    */
+    //@RequiresPermissions("org.jeecg.modules:base_supplier:exportXls")
     @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, Supplier inspectionProject) {
-        return super.exportXls(request, inspectionProject, Supplier.class, "mom_base_supplier");
+    public ModelAndView exportXls(HttpServletRequest request, Supplier supplier) {
+        return super.exportXls(request, supplier, Supplier.class, "渚涘簲鍟嗙鐞�");
     }
 
     /**
-     * 閫氳繃excel瀵煎叆鏁版嵁
-     *
-     * @param request
-     * @param response
-     * @return
-     */
+      * 閫氳繃excel瀵煎叆鏁版嵁
+    *
+    * @param request
+    * @param response
+    * @return
+    */
+    //@RequiresPermissions("base_supplier:importExcel")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
         return super.importExcel(request, response, Supplier.class);
     }
 
+
+	 @AutoLog(value = "渚涘簲鍟�-鍚敤&绂佺敤")
+	 @ApiOperation(value = "渚涘簲鍟�-鍚敤&绂佺敤", notes = "渚涘簲鍟�-鍚敤&绂佺敤")
+	 @PutMapping(value = "/active")
+	 public Result<?> active(@RequestParam(name = "id", required = true) String id) {
+		 Supplier supplier = supplierService.getById(id);
+		 if (CommonConstant.STATUS_1.equals(supplier.getSupplierStatus())) {
+			 supplier.setSupplierStatus(CommonConstant.STATUS_0);
+		 } else {
+			 supplier.setSupplierStatus(CommonConstant.STATUS_1);
+		 }
+		 supplierService.updateById(supplier);
+		 return Result.ok("鎿嶄綔鎴愬姛锛�");
+	 }
+
+	 /**
+	  * 瀵煎叆妯℃澘涓嬭浇
+	  *
+	  */
+	 @RequestMapping(value = "/loadTemplate")
+	 public void loadTemplate(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+		 Map<String,String[]> req = request.getParameterMap();
+		 Workbook workbook = WorkbookFactory.create(new File("D:\\opt\\upFiles\\渚涘簲鍟嗕俊鎭鍏ユā鏉�.xlsx"));
+		 //瀵煎嚭Workbook
+		 //璁剧疆鍝嶅簲澶�
+		 String fileName = "渚涘簲鍟嗕俊鎭鍏ユā鏉�.xlsx";
+		 // 瀵规枃浠跺悕杩涜URL缂栫爜锛岄槻姝腑鏂囦贡鐮�
+		 String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
+		 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+		 response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName);
+		 // 灏哤orkbook鍐欏叆鍝嶅簲杈撳嚭娴�
+		 try { // try-with-resources鑷姩鍏抽棴璧勬簮
+			 workbook.write(response.getOutputStream());
+			 response.flushBuffer();
+		 } catch (IOException e) {
+			 // 寮傚父澶勭悊锛堝璁板綍鏃ュ織锛�
+			 throw new IOException("涓嬭浇妯℃澘澶辫触", e);
+		 }
+
+	 }
+
 }

--
Gitblit v1.9.3