From 89ffb9fded4da0fbac9a14d4979aa7623b0a78f0 Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期一, 28 七月 2025 20:47:00 +0800
Subject: [PATCH] 工装管理基础代码

---
 src/main/java/org/jeecg/modules/tms/controller/TmsToolInboundController.java |  316 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 316 insertions(+), 0 deletions(-)

diff --git a/src/main/java/org/jeecg/modules/tms/controller/TmsToolInboundController.java b/src/main/java/org/jeecg/modules/tms/controller/TmsToolInboundController.java
new file mode 100644
index 0000000..8d9bb68
--- /dev/null
+++ b/src/main/java/org/jeecg/modules/tms/controller/TmsToolInboundController.java
@@ -0,0 +1,316 @@
+package org.jeecg.modules.tms.controller;
+
+import org.jeecg.common.system.query.QueryGenerator;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.tms.vo.TmsToolInboundRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.tms.entity.TmsToolInboundDetail;
+import org.jeecg.modules.tms.entity.TmsToolInbound;
+import org.jeecg.modules.tms.service.ITmsToolInboundService;
+import org.jeecg.modules.tms.service.ITmsToolInboundDetailService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+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.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+ /**
+ * @Description: 宸ヨ鍏ュ簱
+ * @Author: jeecg-boot
+ * @Date:   2025-07-28
+ * @Version: V1.0
+ */
+@Api(tags="宸ヨ鍏ュ簱")
+@RestController
+@RequestMapping("/tms/tmsToolInbound")
+@Slf4j
+public class TmsToolInboundController extends JeecgController<TmsToolInbound, ITmsToolInboundService> {
+
+	@Autowired
+	private ITmsToolInboundService tmsToolInboundService;
+
+	@Autowired
+	private ITmsToolInboundDetailService tmsToolInboundDetailService;
+
+
+	/*---------------------------------涓昏〃澶勭悊-begin-------------------------------------*/
+
+	/**
+	 * 鍒嗛〉鍒楄〃鏌ヨ
+	 * @param tmsToolInbound
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	//@AutoLog(value = "宸ヨ鍏ュ簱-鍒嗛〉鍒楄〃鏌ヨ")
+	@ApiOperation(value="宸ヨ鍏ュ簱-鍒嗛〉鍒楄〃鏌ヨ", notes="宸ヨ鍏ュ簱-鍒嗛〉鍒楄〃鏌ヨ")
+	@GetMapping(value = "/list")
+	public Result<IPage<TmsToolInbound>> queryPageList(TmsToolInbound tmsToolInbound,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<TmsToolInbound> queryWrapper = QueryGenerator.initQueryWrapper(tmsToolInbound, req.getParameterMap());
+		Page<TmsToolInbound> page = new Page<TmsToolInbound>(pageNo, pageSize);
+		IPage<TmsToolInbound> pageList = tmsToolInboundService.page(page, queryWrapper);
+		return Result.OK(pageList);
+	}
+
+	/**
+     *   娣诲姞
+     * @param tmsToolInbound
+     * @return
+     */
+    @AutoLog(value = "宸ヨ鍏ュ簱-娣诲姞")
+    @ApiOperation(value="宸ヨ鍏ュ簱-娣诲姞", notes="宸ヨ鍏ュ簱-娣诲姞")
+    //@RequiresPermissions("org.jeecg.modules:tms_tool_inbound:add")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody TmsToolInboundRequest tmsToolInboundRequest) {
+        try {
+            tmsToolInboundService.add(tmsToolInboundRequest);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return Result.OK("娣诲姞鎴愬姛锛�");
+    }
+
+    /**
+     *  缂栬緫
+     * @param tmsToolInbound
+     * @return
+     */
+    @AutoLog(value = "宸ヨ鍏ュ簱-缂栬緫")
+    @ApiOperation(value="宸ヨ鍏ュ簱-缂栬緫", notes="宸ヨ鍏ュ簱-缂栬緫")
+    //@RequiresPermissions("org.jeecg.modules:tms_tool_inbound:edit")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+    public Result<String> edit(@RequestBody TmsToolInboundRequest tmsToolInboundRequest) {
+        try {
+            tmsToolInboundService.update(tmsToolInboundRequest);
+        } catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+        return Result.OK("缂栬緫鎴愬姛!");
+    }
+
+    /**
+     * 閫氳繃id鍒犻櫎
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "宸ヨ鍏ュ簱-閫氳繃id鍒犻櫎")
+    @ApiOperation(value="宸ヨ鍏ュ簱-閫氳繃id鍒犻櫎", notes="宸ヨ鍏ュ簱-閫氳繃id鍒犻櫎")
+    //@RequiresPermissions("org.jeecg.modules:tms_tool_inbound:delete")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+        tmsToolInboundService.delMain(id);
+        return Result.OK("鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "宸ヨ鍏ュ簱-鎵归噺鍒犻櫎")
+    @ApiOperation(value="宸ヨ鍏ュ簱-鎵归噺鍒犻櫎", notes="宸ヨ鍏ュ簱-鎵归噺鍒犻櫎")
+    //@RequiresPermissions("org.jeecg.modules:tms_tool_inbound:deleteBatch")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+        this.tmsToolInboundService.delBatchMain(Arrays.asList(ids.split(",")));
+        return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 瀵煎嚭
+     * @return
+     */
+    //@RequiresPermissions("org.jeecg.modules:tms_tool_inbound:exportXls")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, TmsToolInbound tmsToolInbound) {
+        return super.exportXls(request, tmsToolInbound, TmsToolInbound.class, "宸ヨ鍏ュ簱");
+    }
+
+    /**
+     * 瀵煎叆
+     * @return
+     */
+    //@RequiresPermissions("org.jeecg.modules:tms_tool_inbound:importExcel")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, TmsToolInbound.class);
+    }
+	/*---------------------------------涓昏〃澶勭悊-end-------------------------------------*/
+	
+
+    /*--------------------------------瀛愯〃澶勭悊-宸ヨ鍏ュ簱鏄庣粏-begin----------------------------------------------*/
+	/**
+	 * 閫氳繃涓昏〃ID鏌ヨ
+	 * @return
+	 */
+	//@AutoLog(value = "宸ヨ鍏ュ簱鏄庣粏-閫氳繃涓昏〃ID鏌ヨ")
+	@ApiOperation(value="宸ヨ鍏ュ簱鏄庣粏-閫氳繃涓昏〃ID鏌ヨ", notes="宸ヨ鍏ュ簱鏄庣粏-閫氳繃涓昏〃ID鏌ヨ")
+	@GetMapping(value = "/listTmsToolInboundDetailByMainId")
+    public Result<IPage<TmsToolInboundDetail>> listTmsToolInboundDetailByMainId(TmsToolInboundDetail tmsToolInboundDetail,
+                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                    HttpServletRequest req) {
+		Map<String, String[]> parameterMap = req.getParameterMap();
+		QueryWrapper<TmsToolInboundDetail> queryWrapper = QueryGenerator.initQueryWrapper(tmsToolInboundDetail, parameterMap);
+        Page<TmsToolInboundDetail> page = new Page<TmsToolInboundDetail>(pageNo, pageSize);
+        IPage<TmsToolInboundDetail> pageList = tmsToolInboundDetailService.queryPageList(page, parameterMap);
+        return Result.OK(pageList);
+    }
+
+	/**
+	 * 娣诲姞
+	 * @param tmsToolInboundDetail
+	 * @return
+	 */
+	@AutoLog(value = "宸ヨ鍏ュ簱鏄庣粏-娣诲姞")
+	@ApiOperation(value="宸ヨ鍏ュ簱鏄庣粏-娣诲姞", notes="宸ヨ鍏ュ簱鏄庣粏-娣诲姞")
+	@PostMapping(value = "/addTmsToolInboundDetail")
+	public Result<String> addTmsToolInboundDetail(@RequestBody TmsToolInboundDetail tmsToolInboundDetail) {
+		tmsToolInboundDetailService.save(tmsToolInboundDetail);
+		return Result.OK("娣诲姞鎴愬姛锛�");
+	}
+
+    /**
+	 * 缂栬緫
+	 * @param tmsToolInboundDetail
+	 * @return
+	 */
+	@AutoLog(value = "宸ヨ鍏ュ簱鏄庣粏-缂栬緫")
+	@ApiOperation(value="宸ヨ鍏ュ簱鏄庣粏-缂栬緫", notes="宸ヨ鍏ュ簱鏄庣粏-缂栬緫")
+	@RequestMapping(value = "/editTmsToolInboundDetail", method = {RequestMethod.PUT,RequestMethod.POST})
+	public Result<String> editTmsToolInboundDetail(@RequestBody TmsToolInboundDetail tmsToolInboundDetail) {
+		tmsToolInboundDetailService.updateById(tmsToolInboundDetail);
+		return Result.OK("缂栬緫鎴愬姛!");
+	}
+
+	/**
+	 * 閫氳繃id鍒犻櫎
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "宸ヨ鍏ュ簱鏄庣粏-閫氳繃id鍒犻櫎")
+	@ApiOperation(value="宸ヨ鍏ュ簱鏄庣粏-閫氳繃id鍒犻櫎", notes="宸ヨ鍏ュ簱鏄庣粏-閫氳繃id鍒犻櫎")
+	@DeleteMapping(value = "/deleteTmsToolInboundDetail")
+	public Result<String> deleteTmsToolInboundDetail(@RequestParam(name="id",required=true) String id) {
+		tmsToolInboundDetailService.removeById(id);
+		return Result.OK("鍒犻櫎鎴愬姛!");
+	}
+
+	/**
+	 * 鎵归噺鍒犻櫎
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "宸ヨ鍏ュ簱鏄庣粏-鎵归噺鍒犻櫎")
+	@ApiOperation(value="宸ヨ鍏ュ簱鏄庣粏-鎵归噺鍒犻櫎", notes="宸ヨ鍏ュ簱鏄庣粏-鎵归噺鍒犻櫎")
+	@DeleteMapping(value = "/deleteBatchTmsToolInboundDetail")
+	public Result<String> deleteBatchTmsToolInboundDetail(@RequestParam(name="ids",required=true) String ids) {
+	    this.tmsToolInboundDetailService.removeByIds(Arrays.asList(ids.split(",")));
+		return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
+	}
+
+    /**
+     * 瀵煎嚭
+     * @return
+     */
+    @RequestMapping(value = "/exportTmsToolInboundDetail")
+    public ModelAndView exportTmsToolInboundDetail(HttpServletRequest request, TmsToolInboundDetail tmsToolInboundDetail) {
+		 // Step.1 缁勮鏌ヨ鏉′欢
+		 QueryWrapper<TmsToolInboundDetail> queryWrapper = QueryGenerator.initQueryWrapper(tmsToolInboundDetail, request.getParameterMap());
+		 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+		 // Step.2 鑾峰彇瀵煎嚭鏁版嵁
+		 List<TmsToolInboundDetail> pageList = tmsToolInboundDetailService.list(queryWrapper);
+		 List<TmsToolInboundDetail> exportList = null;
+
+		 // 杩囨护閫変腑鏁版嵁
+		 String selections = request.getParameter("selections");
+		 if (oConvertUtils.isNotEmpty(selections)) {
+			 List<String> selectionList = Arrays.asList(selections.split(","));
+			 exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
+		 } else {
+			 exportList = pageList;
+		 }
+
+		 // Step.3 AutoPoi 瀵煎嚭Excel
+		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+		 //姝ゅ璁剧疆鐨刦ilename鏃犳晥,鍓嶇浼氶噸鏇存柊璁剧疆涓�涓�
+		 mv.addObject(NormalExcelConstants.FILE_NAME, "宸ヨ鍏ュ簱鏄庣粏");
+		 mv.addObject(NormalExcelConstants.CLASS, TmsToolInboundDetail.class);
+		 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("宸ヨ鍏ュ簱鏄庣粏鎶ヨ〃", "瀵煎嚭浜�:" + sysUser.getRealname(), "宸ヨ鍏ュ簱鏄庣粏"));
+		 mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
+		 return mv;
+    }
+
+    /**
+     * 瀵煎叆
+     * @return
+     */
+    @RequestMapping(value = "/importTmsToolInboundDetail/{mainId}")
+    public Result<?> importTmsToolInboundDetail(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
+		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+       // 鑾峰彇涓婁紶鏂囦欢瀵硅薄
+			 MultipartFile file = entity.getValue();
+			 ImportParams params = new ImportParams();
+			 params.setTitleRows(2);
+			 params.setHeadRows(1);
+			 params.setNeedSave(true);
+			 try {
+				 List<TmsToolInboundDetail> list = ExcelImportUtil.importExcel(file.getInputStream(), TmsToolInboundDetail.class, params);
+				 for (TmsToolInboundDetail temp : list) {
+                    temp.setOrderId(mainId);
+				 }
+				 long start = System.currentTimeMillis();
+				 tmsToolInboundDetailService.saveBatch(list);
+				 log.info("娑堣�楁椂闂�" + (System.currentTimeMillis() - start) + "姣");
+				 return Result.OK("鏂囦欢瀵煎叆鎴愬姛锛佹暟鎹鏁帮細" + list.size());
+			 } catch (Exception e) {
+				 log.error(e.getMessage(), e);
+				 return Result.error("鏂囦欢瀵煎叆澶辫触:" + e.getMessage());
+			 } finally {
+				 try {
+					 file.getInputStream().close();
+				 } catch (IOException e) {
+					 e.printStackTrace();
+				 }
+			 }
+		 }
+		 return Result.error("鏂囦欢瀵煎叆澶辫触锛�");
+    }
+
+    /*--------------------------------瀛愯〃澶勭悊-宸ヨ鍏ュ簱鏄庣粏-end----------------------------------------------*/
+
+
+
+
+}

--
Gitblit v1.9.3