From 80e8110e4f3a132ee2819f2560a661c6f6693fcf Mon Sep 17 00:00:00 2001
From: houjie <714924425@qq.com>
Date: 星期三, 30 八月 2023 18:51:59 +0800
Subject: [PATCH] 备件调整  导入导出

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparePart.java                         |   25 +-
 lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparesPartInventoryController.java |   79 ++++++
 lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparesPartInventory.java               |   25 +-
 lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparePartController.java           |  468 +++++++++++++++++++-------------------
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/SparePartImportVo.java                   |   74 ++++++
 5 files changed, 407 insertions(+), 264 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/SparePartImportVo.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/SparePartImportVo.java
new file mode 100644
index 0000000..dd465c5
--- /dev/null
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/SparePartImportVo.java
@@ -0,0 +1,74 @@
+package org.jeecg.modules.eam.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.math.BigDecimal;
+
+/**
+ * @author lnl
+ */
+@Data
+@Accessors(chain = true)
+public class SparePartImportVo {
+
+    @Excel(name = "澶囦欢缂栫爜")
+    private String num;
+
+    @Excel(name="澶囦欢鍚嶇О")
+    private String name;
+
+    @Excel(name="鍨嬪彿")
+    private String model;
+
+    @Excel(name="瑙勬牸")
+    private String specification;
+
+    @Excel(name="鍒堕�犲晢" ,dicCode = "id",dictTable="mom_base_constructor",dicText="name")
+    private String constructorId;
+
+    @Excel(name="鍗曚綅" ,dicCode = "id",dictTable="mom_base_unit",dicText="name")
+    private String mainUnitId;
+
+
+    @Excel(name = "鎵规绠$悊鏍囪瘑", width = 15)
+    private Integer batchManagedFlag;
+
+
+    @Excel(name = "鏈夋晥鏈熺鐞嗘爣璇�", width = 15)
+    private Integer validityManagedFlag;
+
+
+    @Excel(name = "鏈夋晥鏈�", width = 15)
+    private Integer validityPeriod;
+
+    @Excel(name = "鏈夋晥鏈熷崟浣�", width = 15,dictTable="mom_base_unit",dicText="name")
+    private String validityPeriodUnitId;
+
+    @Excel(name = "搴撳瓨涓婇檺鍒�", width = 15)
+    private Integer inventoryUpperLimit;
+
+    @Excel(name = "搴撳瓨涓嬮檺鍒�", width = 15)
+    private Integer inventoryLowerLimit;
+
+    @Excel(name = "搴撳瓨棰勮涓嬮檺", width = 15)
+    private Integer inventoryWarnLimit;
+
+    @Excel(name = "缁忔祹璁㈣揣閲�", width = 15)
+    private Integer economicOrderQuantity;
+
+
+    @Excel(name = "閲囪喘鎻愬墠鏈�", width = 15)
+    private Integer purchaseLeadTime;
+
+
+    @Excel(name = "绉熸埛id", width = 15)
+    private String tenantId;
+
+
+
+
+}
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparePartController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparePartController.java
index bfdd198..b569717 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparePartController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparePartController.java
@@ -1,271 +1,277 @@
 package org.jeecg.modules.spare.controller;
 
-import java.math.BigDecimal;
-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 com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.base.entity.SysUpload;
-import org.jeecg.common.system.base.entity.SysUploadRela;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.eam.model.InspectionCycleVo;
-import org.jeecg.modules.spare.entity.SparePart;
-import org.jeecg.modules.spare.entity.SparesPartInventory;
-import org.jeecg.modules.spare.service.ISparePartService;
-
 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.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.spare.entity.SparePart;
+import org.jeecg.modules.spare.entity.SparesPartInventory;
+import org.jeecg.modules.spare.service.ISparePartService;
 import org.jeecg.modules.spare.service.ISparesPartInventoryService;
 import org.jeecg.modules.spare.vo.AuxiliaryUnitVo;
 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.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.io.IOException;
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
  * @Description: mom_eam_spare_part
  * @Author: jeecg-boot
- * @Date:   2023-06-20
+ * @Date: 2023-06-20
  * @Version: V1.0
  */
-@Api(tags="mom_eam_spare_part")
+@Api(tags = "mom_eam_spare_part")
 @RestController
 @RequestMapping("/spare/sparePart")
 @Slf4j
 public class SparePartController extends JeecgController<SparePart, ISparePartService> {
-	@Autowired
-	private ISparePartService sparePartService;
+    @Autowired
+    private ISparePartService sparePartService;
 
-	 @Autowired
-	private ISparesPartInventoryService sparesPartInventoryService;
-	
-	/**
-	 * 鍒嗛〉鍒楄〃鏌ヨ
-	 *
-	 * @param sparePart
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	//@AutoLog(value = "mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ")
-	@ApiOperation(value="mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ", notes="mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ")
-	@GetMapping(value = "/list")
-	public Result<IPage<SparePart>> queryPageList(SparePart sparePart,
-								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-								   HttpServletRequest req) {
-		QueryWrapper<SparePart> queryWrapper = QueryGenerator.initQueryWrapper(sparePart, req.getParameterMap());
-		Page<SparePart> page = new Page<SparePart>(pageNo, pageSize);
-		IPage<SparePart> pageList = sparePartService.page(page, queryWrapper);
-		for (SparePart record : pageList.getRecords()) {
-			String mainUnitId = record.getMainUnitId();
-			List<AuxiliaryUnitVo> auxiliaryUnits = sparePartService.getAuxiliaryUnits(mainUnitId);
-			record.setAuxiliaryUnits(auxiliaryUnits);
-		}
-		return Result.OK(pageList);
-	}
-
-	 /**
-	  * 鍒嗛〉鍒楄〃鏌ヨ
-	  * 澶囦欢搴撳瓨灞曠ず椤�
-	  */
-	 @ApiOperation(value="mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ", notes="mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ")
-	 @GetMapping(value = "/sparePartInventoryList")
-	 public Result<IPage<SparePart>> sparePartInventoryList(SparePart sparePart,
-												   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-												   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-												   HttpServletRequest req) {
-		 QueryWrapper<SparePart> queryWrapper = QueryGenerator.initQueryWrapper(sparePart, req.getParameterMap());
-		 Page<SparePart> page = new Page<SparePart>(pageNo, pageSize);
-		 IPage<SparePart> pageList = sparePartService.page(page, queryWrapper);
-		 for (SparePart record : pageList.getRecords()) {
-			 String sparePartId = record.getId();
-
-			 QueryWrapper<SparesPartInventory> wrapper = new QueryWrapper<>();
-			 wrapper.eq("spare_part_id", sparePartId)
-					 .eq("del_flag", 0);
-			 wrapper.select("sum(main_quantity) as totalMainQuantity");
-			 Map<String, Object> map = sparesPartInventoryService.getMap(wrapper);
-			 BigDecimal totalMainQuantity = new BigDecimal(0);
-			 if (map != null) {
-				 totalMainQuantity = (BigDecimal)map.get("totalMainQuantity");
-			 }
-			 record.setTotalMainQuantity(totalMainQuantity);
-
-			 wrapper.eq("spare_part_id", sparePartId)
-					 .eq("del_flag", 0);
-			 wrapper.select("sum(auxiliary_quantity) as totalAuxiliaryQuantity");
-			 Map<String, Object> map2 = sparesPartInventoryService.getMap(wrapper);
-			 BigDecimal totalAuxiliaryQuantity = new BigDecimal(0);
-			 if (map != null) {
-				 totalAuxiliaryQuantity = (BigDecimal)map2.get("totalAuxiliaryQuantity");
-			 }
-			 record.setTotalAuxiliaryQuantity(totalAuxiliaryQuantity);
-
-		 }
-		 return Result.OK(pageList);
-	 }
-
-	
-	/**
-	 *   娣诲姞
-	 *
-	 * @param sparePart
-	 * @return
-	 */
-	@AutoLog(value = "mom_eam_spare_part-娣诲姞")
-	@ApiOperation(value="mom_eam_spare_part-娣诲姞", notes="mom_eam_spare_part-娣诲姞")
-	//@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:add")
-	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody SparePart sparePart) {
-		sparePartService.save(sparePart);
-		return Result.OK("娣诲姞鎴愬姛锛�");
-	}
-	
-	/**
-	 *  缂栬緫
-	 *
-	 * @param sparePart
-	 * @return
-	 */
-	@AutoLog(value = "mom_eam_spare_part-缂栬緫")
-	@ApiOperation(value="mom_eam_spare_part-缂栬緫", notes="mom_eam_spare_part-缂栬緫")
-	//@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:edit")
-	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody SparePart sparePart) {
-		sparePartService.updateById(sparePart);
-		return Result.OK("缂栬緫鎴愬姛!");
-	}
-	
-	/**
-	 *   閫氳繃id鍒犻櫎
-	 *
-	 * @param id
-	 * @return
-	 */
-	@AutoLog(value = "mom_eam_spare_part-閫氳繃id鍒犻櫎")
-	@ApiOperation(value="mom_eam_spare_part-閫氳繃id鍒犻櫎", notes="mom_eam_spare_part-閫氳繃id鍒犻櫎")
-	//@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:delete")
-	@DeleteMapping(value = "/delete")
-	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
-		sparePartService.removeById(id);
-		return Result.OK("鍒犻櫎鎴愬姛!");
-	}
-	
-	/**
-	 *  鎵归噺鍒犻櫎
-	 *
-	 * @param ids
-	 * @return
-	 */
-	@AutoLog(value = "mom_eam_spare_part-鎵归噺鍒犻櫎")
-	@ApiOperation(value="mom_eam_spare_part-鎵归噺鍒犻櫎", notes="mom_eam_spare_part-鎵归噺鍒犻櫎")
-	//@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:deleteBatch")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		this.sparePartService.removeByIds(Arrays.asList(ids.split(",")));
-		return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
-	}
-	
-	/**
-	 * 閫氳繃id鏌ヨ
-	 *
-	 * @param id
-	 * @return
-	 */
-	//@AutoLog(value = "mom_eam_spare_part-閫氳繃id鏌ヨ")
-	@ApiOperation(value="mom_eam_spare_part-閫氳繃id鏌ヨ", notes="mom_eam_spare_part-閫氳繃id鏌ヨ")
-	@GetMapping(value = "/queryById")
-	public Result<SparePart> queryById(@RequestParam(name="id",required=true) String id) {
-		SparePart sparePart = sparePartService.getById(id);
-		if(sparePart==null) {
-			return Result.error("鏈壘鍒板搴旀暟鎹�");
-		}
-		return Result.OK(sparePart);
-	}
+    @Autowired
+    private ISparesPartInventoryService sparesPartInventoryService;
 
     /**
-    * 瀵煎嚭excel
-    *
-    * @param request
-    * @param sparePart
-    */
-    //@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:exportXls")
+     * 鍒嗛〉鍒楄〃鏌ヨ
+     *
+     * @param sparePart
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ", notes = "mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ")
+    @GetMapping(value = "/list")
+    public Result<IPage<SparePart>> queryPageList(SparePart sparePart,
+                                                  @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                  HttpServletRequest req) {
+        QueryWrapper<SparePart> queryWrapper = QueryGenerator.initQueryWrapper(sparePart, req.getParameterMap());
+        Page<SparePart> page = new Page<SparePart>(pageNo, pageSize);
+        IPage<SparePart> pageList = sparePartService.page(page, queryWrapper);
+        for (SparePart record : pageList.getRecords()) {
+            String mainUnitId = record.getMainUnitId();
+            List<AuxiliaryUnitVo> auxiliaryUnits = sparePartService.getAuxiliaryUnits(mainUnitId);
+            record.setAuxiliaryUnits(auxiliaryUnits);
+        }
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 鍒嗛〉鍒楄〃鏌ヨ
+     * 澶囦欢搴撳瓨灞曠ず椤�
+     */
+    @ApiOperation(value = "mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ", notes = "mom_eam_spare_part-鍒嗛〉鍒楄〃鏌ヨ")
+    @GetMapping(value = "/sparePartInventoryList")
+    public Result<IPage<SparePart>> sparePartInventoryList(SparePart sparePart,
+                                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                           HttpServletRequest req) {
+        QueryWrapper<SparePart> queryWrapper = QueryGenerator.initQueryWrapper(sparePart, req.getParameterMap());
+        Page<SparePart> page = new Page<SparePart>(pageNo, pageSize);
+        IPage<SparePart> pageList = sparePartService.page(page, queryWrapper);
+        for (SparePart record : pageList.getRecords()) {
+            String sparePartId = record.getId();
+
+            QueryWrapper<SparesPartInventory> wrapper = new QueryWrapper<>();
+            wrapper.eq("spare_part_id", sparePartId)
+                    .eq("del_flag", 0);
+            wrapper.select("sum(main_quantity) as totalMainQuantity");
+            Map<String, Object> map = sparesPartInventoryService.getMap(wrapper);
+            BigDecimal totalMainQuantity = new BigDecimal(0);
+            if (map != null) {
+                totalMainQuantity = (BigDecimal) map.get("totalMainQuantity");
+            }
+            record.setTotalMainQuantity(totalMainQuantity);
+
+            wrapper.eq("spare_part_id", sparePartId)
+                    .eq("del_flag", 0);
+            wrapper.select("sum(auxiliary_quantity) as totalAuxiliaryQuantity");
+            Map<String, Object> map2 = sparesPartInventoryService.getMap(wrapper);
+            BigDecimal totalAuxiliaryQuantity = new BigDecimal(0);
+            if (map != null) {
+                totalAuxiliaryQuantity = (BigDecimal) map2.get("totalAuxiliaryQuantity");
+            }
+            record.setTotalAuxiliaryQuantity(totalAuxiliaryQuantity);
+
+        }
+        return Result.OK(pageList);
+    }
+
+
+    /**
+     * 娣诲姞
+     *
+     * @param sparePart
+     * @return
+     */
+    @AutoLog(value = "mom_eam_spare_part-娣诲姞")
+    @ApiOperation(value = "mom_eam_spare_part-娣诲姞", notes = "mom_eam_spare_part-娣诲姞")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody SparePart sparePart) {
+        sparePartService.save(sparePart);
+        return Result.OK("娣诲姞鎴愬姛锛�");
+    }
+
+    /**
+     * 缂栬緫
+     *
+     * @param sparePart
+     * @return
+     */
+    @AutoLog(value = "mom_eam_spare_part-缂栬緫")
+    @ApiOperation(value = "mom_eam_spare_part-缂栬緫", notes = "mom_eam_spare_part-缂栬緫")
+    //@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:edit")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody SparePart sparePart) {
+        sparePartService.updateById(sparePart);
+        return Result.OK("缂栬緫鎴愬姛!");
+    }
+
+    /**
+     * 閫氳繃id鍒犻櫎
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "mom_eam_spare_part-閫氳繃id鍒犻櫎")
+    @ApiOperation(value = "mom_eam_spare_part-閫氳繃id鍒犻櫎", notes = "mom_eam_spare_part-閫氳繃id鍒犻櫎")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        sparePartService.removeById(id);
+        return Result.OK("鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "mom_eam_spare_part-鎵归噺鍒犻櫎")
+    @ApiOperation(value = "mom_eam_spare_part-鎵归噺鍒犻櫎", notes = "mom_eam_spare_part-鎵归噺鍒犻櫎")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.sparePartService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 閫氳繃id鏌ヨ
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "mom_eam_spare_part-閫氳繃id鏌ヨ", notes = "mom_eam_spare_part-閫氳繃id鏌ヨ")
+    @GetMapping(value = "/queryById")
+    public Result<SparePart> queryById(@RequestParam(name = "id", required = true) String id) {
+        SparePart sparePart = sparePartService.getById(id);
+        if (sparePart == null) {
+            return Result.error("鏈壘鍒板搴旀暟鎹�");
+        }
+        return Result.OK(sparePart);
+    }
+
+    /**
+     * 瀵煎嚭excel
+     *
+     * @param request
+     * @param sparePart
+     */
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, SparePart sparePart) {
         return super.exportXls(request, sparePart, SparePart.class, "mom_eam_spare_part");
     }
 
     /**
-      * 閫氳繃excel瀵煎叆鏁版嵁
-    *
-    * @param request
-    * @param response
-    * @return
-    */
-    //@RequiresPermissions("mom_eam_spare_part:importExcel")
+     * 閫氳繃excel瀵煎叆鏁版嵁
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, SparePart.class);
+        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<SparePart> list = ExcelImportUtil.importExcel(file.getInputStream(), SparePart.class, params);
+                long start = System.currentTimeMillis();
+                sparePartService.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("鏂囦欢瀵煎叆澶辫触锛�");
     }
 
-	 /**
-	  * 閫氳繃璁惧澶囦欢鑾峰彇閫傞厤鐨勮澶�
-	  * qsw 2023-6-21
-	  */
-	 @GetMapping("getSpareContactEquipmentList")
-	 public Result<?> getSpareContactEquipmentList(@RequestParam("pageNo") Integer pageNo,
-												   @RequestParam("pageSize") Integer pageSize,
-												   @RequestParam Map<String, Object> params) {
-		 IPage<Map<String, Object>> spareContactEquipmentList = sparePartService.getSpareContactEquipmentList(pageNo, pageSize, params);
-		 return Result.ok(spareContactEquipmentList);
-	 }
+    /**
+     * 閫氳繃璁惧澶囦欢鑾峰彇閫傞厤鐨勮澶�
+     * qsw 2023-6-21
+     */
+    @GetMapping("getSpareContactEquipmentList")
+    public Result<?> getSpareContactEquipmentList(@RequestParam("pageNo") Integer pageNo,
+                                                  @RequestParam("pageSize") Integer pageSize,
+                                                  @RequestParam Map<String, Object> params) {
+        IPage<Map<String, Object>> spareContactEquipmentList = sparePartService.getSpareContactEquipmentList(pageNo, pageSize, params);
+        return Result.ok(spareContactEquipmentList);
+    }
 
-	 /**
-	  * 鏍规嵁涓诲崟浣嶈幏鍙栬緟鍗曚綅
-	  * qsw 2023-6-23
-	  */
-	 @GetMapping("getAuxiliaryUnits")
-	 public Result<?> getAuxiliaryUnits(@RequestParam(name = "mainUnitId", required = true) String mainUnitId) {
-		 List<AuxiliaryUnitVo> auxiliaryUnits = sparePartService.getAuxiliaryUnits(mainUnitId);
-		 return Result.ok(auxiliaryUnits);
-	 }
+    /**
+     * 鏍规嵁涓诲崟浣嶈幏鍙栬緟鍗曚綅
+     * qsw 2023-6-23
+     */
+    @GetMapping("getAuxiliaryUnits")
+    public Result<?> getAuxiliaryUnits(@RequestParam(name = "mainUnitId", required = true) String mainUnitId) {
+        List<AuxiliaryUnitVo> auxiliaryUnits = sparePartService.getAuxiliaryUnits(mainUnitId);
+        return Result.ok(auxiliaryUnits);
+    }
 
-	 /**
-	  * 鏍规嵁涓诲崟浣嶃�佽緟鍗曚綅鑾峰彇 鍞竴鎹㈢畻姣斾緥
-	  * qsw 2023-6-28
-	  */
-	 @GetMapping("getConversionRatio")
-	 public Result<?> getConversionRatio(@RequestParam(name = "mainUnitId", required = true) String mainUnitId,@RequestParam(name = "auxiliaryUnitId", required = true) String auxiliaryUnitId) {
-		 List<String> conversionRatio = sparePartService.getConversionRatio(mainUnitId, auxiliaryUnitId);
-		 if(conversionRatio.size()>0){
-			 return Result.ok(conversionRatio.get(0));
-		 }else{
-			 return Result.ok("");
-		 }
-	 }
+    /**
+     * 鏍规嵁涓诲崟浣嶃�佽緟鍗曚綅鑾峰彇 鍞竴鎹㈢畻姣斾緥
+     * qsw 2023-6-28
+     */
+    @GetMapping("getConversionRatio")
+    public Result<?> getConversionRatio(@RequestParam(name = "mainUnitId", required = true) String mainUnitId, @RequestParam(name = "auxiliaryUnitId", required = true) String auxiliaryUnitId) {
+        List<String> conversionRatio = sparePartService.getConversionRatio(mainUnitId, auxiliaryUnitId);
+        if (conversionRatio.size() > 0) {
+            return Result.ok(conversionRatio.get(0));
+        } else {
+            return Result.ok("");
+        }
+    }
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparesPartInventoryController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparesPartInventoryController.java
index 7701b65..6a9aa12 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparesPartInventoryController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparesPartInventoryController.java
@@ -10,19 +10,21 @@
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.eam.entity.MaintenanceOrderActualWorkingHour;
 import org.jeecg.modules.spare.entity.SparePart;
 import org.jeecg.modules.spare.entity.SparesPartInventory;
 import org.jeecg.modules.spare.service.ISparePartService;
 import org.jeecg.modules.spare.service.ISparesPartInventoryService;
-import org.jeecg.modules.spare.vo.AuxiliaryUnitVo;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.entity.ImportParams;
 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 javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.math.BigDecimal;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -167,11 +169,74 @@
      * @param response
      * @return
      */
-
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, SparesPartInventory.class);
+    /**
+     * 瀵煎叆
+     *
+     * @return
+     */
+    @RequestMapping(value = "/importExcel/{mainId}")
+    public Result<?> importExcel(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<SparesPartInventory> list = ExcelImportUtil.importExcel(file.getInputStream(), SparesPartInventory.class, params);
+                for (SparesPartInventory temp : list) {
+                    temp.setId(mainId);
+                }
+                long start = System.currentTimeMillis();
+                sparesPartInventoryService.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("鏂囦欢瀵煎叆澶辫触锛�");
     }
+   /* @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        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<SparesPartInventory> list = ExcelImportUtil.importExcel(file.getInputStream(), SparesPartInventory.class, params);
+                long start = System.currentTimeMillis();
+                sparesPartInventoryService.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("鏂囦欢瀵煎叆澶辫触锛�");
+    }*/
 
 
     /**
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparePart.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparePart.java
index 16bf5f5..0986f12 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparePart.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparePart.java
@@ -35,7 +35,6 @@
     private static final long serialVersionUID = 1L;
 
 	/**澶囦欢鍒嗙被id*/
-	@Excel(name = "澶囦欢鍒嗙被id", width = 15)
     @ApiModelProperty(value = "澶囦欢鍒嗙被id")
     private java.lang.String sparePartCategoryId;
 	/**澶囦欢缂栫爜*/
@@ -59,23 +58,22 @@
     @ApiModelProperty(value = "瑙勫垯")
     private java.lang.String specification;
 	/**鍒堕�犲晢*/
-	@Excel(name = "鍒堕�犲晢", width = 15)
+	@Excel(name = "鍒堕�犲晢", width = 15,dictTable="mom_base_constructor",dicText="name")
     @ApiModelProperty(value = "鍒堕�犲晢")
     @Dict(dicCode = "id",dictTable="mom_base_constructor",dicText="name")
     private java.lang.String constructorId;
 	/**涓诲崟浣峣d*/
-	@Excel(name = "涓诲崟浣峣d", width = 15)
+	@Excel(name = "涓诲崟浣�", width = 15,dicCode = "id",dictTable="mom_base_unit",dicText="name")
     @ApiModelProperty(value = "涓诲崟浣峣d")
     @Dict(dicCode = "id",dictTable="mom_base_unit",dicText="name")
     private java.lang.String mainUnitId;
 	/**杈呭崟浣峣d*/
-	@Excel(name = "杈呭崟浣峣d", width = 15)
+
     @ApiModelProperty(value = "杈呭崟浣峣d")
     @Dict(dicCode = "id",dictTable="mom_base_unit",dicText="name")
     private java.lang.String auxiliaryUnitId;
 
     /**鎹㈢畻姣斾緥*/
-    @Excel(name = "鎹㈢畻姣斾緥", width = 15)
     @ApiModelProperty(value = "鎹㈢畻姣斾緥")
     private java.lang.String conversionRatio;
 
@@ -92,7 +90,7 @@
     @ApiModelProperty(value = "鏈夋晥鏈�")
     private java.lang.Integer validityPeriod;
 	/**鏈夋晥鏈熷崟浣�*/
-	@Excel(name = "鏈夋晥鏈熷崟浣�", width = 15)
+	@Excel(name = "鏈夋晥鏈熷崟浣�", width = 15,dictTable="mom_base_unit",dicText="name")
     @ApiModelProperty(value = "鏈夋晥鏈熷崟浣�")
     @Dict(dicCode = "id",dictTable="mom_base_unit",dicText="name")
     private java.lang.String validityPeriodUnitId;
@@ -122,32 +120,33 @@
     @ApiModelProperty(value = "绉熸埛id")
     private java.lang.String tenantId;
 	/**鍒犻櫎鐘舵��(0-姝e父,1-宸插垹闄�)*/
-	@Excel(name = "鍒犻櫎鐘舵��(0-姝e父,1-宸插垹闄�)", width = 15)
+
+
     @ApiModelProperty(value = "鍒犻櫎鐘舵��(0-姝e父,1-宸插垹闄�)")
     @TableLogic
     private Integer delFlag = CommonConstant.DEL_FLAG_0;
 	/**澶囨敞*/
-	@Excel(name = "澶囨敞", width = 15)
+
     @ApiModelProperty(value = "澶囨敞")
     private java.lang.String remark;
 	/**澶囩敤瀛楁1*/
-	@Excel(name = "澶囩敤瀛楁1", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁1")
     private java.lang.String uda1;
 	/**澶囩敤瀛楁2*/
-	@Excel(name = "澶囩敤瀛楁2", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁2")
     private java.lang.String uda2;
 	/**澶囩敤瀛楁3*/
-	@Excel(name = "澶囩敤瀛楁3", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁3")
     private java.lang.String uda3;
 	/**澶囩敤瀛楁4*/
-	@Excel(name = "澶囩敤瀛楁4", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁4")
     private java.lang.String uda4;
 	/**澶囩敤瀛楁5*/
-	@Excel(name = "澶囩敤瀛楁5", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁5")
     private java.lang.String uda5;
 
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparesPartInventory.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparesPartInventory.java
index 7b5386f..d6dde01 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparesPartInventory.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/spare/entity/SparesPartInventory.java
@@ -27,7 +27,6 @@
     /**
      * 澶囦欢id
      */
-    @Excel(name = "澶囦欢id", width = 15)
     @ApiModelProperty(value = "澶囦欢id")
     private java.lang.String sparePartId;
     /**
@@ -54,36 +53,36 @@
     /**
      * 鍒堕�犲晢
      */
-    @Excel(name = "鍒堕�犲晢", width = 15)
+    @Excel(name = "鍒堕�犲晢", width = 15,dictTable = "mom_base_constructor", dicCode = "id", dicText = "name")
     @ApiModelProperty(value = "鍒堕�犲晢")
     @Dict(dictTable = "mom_base_constructor", dicCode = "id", dicText = "name")
     private java.lang.String constructorId;
     /**
      * 涓诲崟浣峣d
      */
-    @Excel(name = "涓诲崟浣峣d", width = 15)
+    @Excel(name = "涓诲崟浣峣d", width = 15,dictTable = "mom_base_unit", dicCode = "id", dicText = "name")
     @ApiModelProperty(value = "涓诲崟浣峣d")
     @Dict(dictTable = "mom_base_unit", dicCode = "id", dicText = "name")
     private java.lang.String mainUnitId;
     /**
      * 杈呭崟浣峣d
      */
-    @Excel(name = "杈呭崟浣峣d", width = 15)
+
     @ApiModelProperty(value = "杈呭崟浣峣d")
     @Dict(dictTable = "mom_base_unit", dicCode = "id", dicText = "name")
     private java.lang.String auxiliaryUnitId;
 
-    @Excel(name = "浠撳簱id", width = 15)
+    @Excel(name = "浠撳簱id", width = 15,dictTable = "mom_base_warehouse", dicCode = "id", dicText = "name")
     @ApiModelProperty(value = "浠撳簱id")
     @Dict(dictTable = "mom_base_warehouse", dicCode = "id", dicText = "name")
     private java.lang.String warehouseId;
 
-    @Excel(name = "搴撳尯id", width = 15)
+    @Excel(name = "搴撳尯id", width = 15,dictTable = "mom_base_warehouse_area", dicCode = "id", dicText = "name")
     @ApiModelProperty(value = "搴撳尯id")
     @Dict(dictTable = "mom_base_warehouse_area", dicCode = "id", dicText = "name")
     private java.lang.String warehouseAreaId;
 
-    @Excel(name = "搴撲綅id", width = 15)
+    @Excel(name = "搴撲綅id", width = 15,dictTable = "mom_base_warehouse_location", dicCode = "id", dicText = "name")
     @ApiModelProperty(value = "搴撲綅id")
     @Dict(dictTable = "mom_base_warehouse_location", dicCode = "id", dicText = "name")
     private java.lang.String warehouseLocationId;
@@ -96,7 +95,6 @@
     /**
      * 杈呮暟閲�
      */
-    @Excel(name = "杈呮暟閲�", width = 15)
     @ApiModelProperty(value = "杈呮暟閲�")
     private java.lang.Double auxiliaryQuantity;
 
@@ -113,6 +111,7 @@
      * 渚涘簲鍟唅d
      */
     @Excel(name = "渚涘簲鍟唅d", width = 15)
+    @Dict(dictTable = "mom_base_supplier", dicCode = "id", dicText = "name")
     @ApiModelProperty(value = "渚涘簲鍟唅d")
     private String supplierId;
 
@@ -154,31 +153,31 @@
     /**
      * 澶囩敤瀛楁1
      */
-    @Excel(name = "澶囩敤瀛楁1", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁1")
     private java.lang.String sparesUda1;
     /**
      * 澶囩敤瀛楁2
      */
-    @Excel(name = "澶囩敤瀛楁2", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁2")
     private java.lang.String sparesUda2;
     /**
      * 澶囩敤瀛楁3
      */
-    @Excel(name = "澶囩敤瀛楁3", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁3")
     private java.lang.String sparesUda3;
     /**
      * 澶囩敤瀛楁4
      */
-    @Excel(name = "澶囩敤瀛楁4", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁4")
     private java.lang.String sparesUda4;
     /**
      * 澶囩敤瀛楁5
      */
-    @Excel(name = "澶囩敤瀛楁5", width = 15)
+
     @ApiModelProperty(value = "澶囩敤瀛楁5")
     private java.lang.String sparesUda5;
 

--
Gitblit v1.9.3