diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/controller/MdBaseMaterialController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/controller/MdBaseMaterialController.java index e8656c7..ab0df32 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/controller/MdBaseMaterialController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/controller/MdBaseMaterialController.java @@ -79,7 +79,7 @@ public class MdBaseMaterialController { @PostMapping("/excelImport") @Log("excel导入") public ResponseEntity excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) { - wmsToMesService.excelImport(file, request); + mdBaseMaterialService.excelImport(file, request); return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/IMdBaseMaterialService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/IMdBaseMaterialService.java index 09a7453..f37aa03 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/IMdBaseMaterialService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/IMdBaseMaterialService.java @@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.nl.common.domain.query.PageQuery; import org.nl.wms.database.material.service.dao.MdBaseMaterial; import org.nl.wms.database.material.service.dto.MdBaseMaterialQuery; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import java.util.Map; import java.util.Set; @@ -62,4 +64,6 @@ public interface IMdBaseMaterialService extends IService { * @return */ IPage queryByInventory(MdBaseMaterialQuery whereJson, PageQuery page); + + void excelImport(MultipartFile file, HttpServletRequest request); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/impl/MdBaseMaterialServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/impl/MdBaseMaterialServiceImpl.java index 255f468..b389694 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/impl/MdBaseMaterialServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/impl/MdBaseMaterialServiceImpl.java @@ -3,6 +3,8 @@ package org.nl.wms.database.material.service.impl; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.poi.excel.ExcelReader; +import cn.hutool.poi.excel.ExcelUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -19,7 +21,11 @@ import org.nl.wms.database.material.service.dto.MdBaseMaterialQuery; import org.nl.wms.ext.mes.service.dao.mapper.MesRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import java.io.InputStream; import java.util.List; import java.util.Map; import java.util.Set; @@ -117,4 +123,26 @@ public class MdBaseMaterialServiceImpl extends ServiceImpl> read = excelReader.read(1, excelReader.getRowCount()); + // 循环获取的数据 + for (int i = 0; i < read.size(); i++) { + } + } + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java index 4e2bb45..cbbad47 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java @@ -196,5 +196,5 @@ public interface WmsToMesService { */ void addScrap(ScrapDto entity); - void excelImport(MultipartFile file, HttpServletRequest request); + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java index fdeeb2c..0d0d23a 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java @@ -519,27 +519,6 @@ public class WmsToMesServiceImpl implements WmsToMesService { mesRequestMapper.reportSemiProductGXPF(semiProductGXPFDo); } - @Override - @Transactional(rollbackFor = Exception.class) - public void excelImport(MultipartFile file, HttpServletRequest request) { - if (file.isEmpty()) { - throw new BadRequestException("文件为空,请添加数据后重新导入"); - } - // 1.获取上传文件输入流 - InputStream inputStream = null; - try { - inputStream = file.getInputStream(); - } catch (Exception e) { - e.printStackTrace(); - } - // 调用用 hutool 方法读取数据 默认调用第一个sheet - ExcelReader excelReader = ExcelUtil.getReader(inputStream); - // 从第二行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列 - List> read = excelReader.read(1, excelReader.getRowCount()); - // 循环获取的数据 - for (int i = 0; i < read.size(); i++) { - } - } /** * 转换