Browse Source

rev:路径

master
gengby 6 months ago
parent
commit
c116b7a41c
  1. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/controller/MdBaseMaterialController.java
  2. 4
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/IMdBaseMaterialService.java
  3. 28
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/service/impl/MdBaseMaterialServiceImpl.java
  4. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java
  5. 21
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java

2
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") @PostMapping("/excelImport")
@Log("excel导入") @Log("excel导入")
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) { public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
wmsToMesService.excelImport(file, request); mdBaseMaterialService.excelImport(file, request);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
} }

4
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.common.domain.query.PageQuery;
import org.nl.wms.database.material.service.dao.MdBaseMaterial; import org.nl.wms.database.material.service.dao.MdBaseMaterial;
import org.nl.wms.database.material.service.dto.MdBaseMaterialQuery; 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.Map;
import java.util.Set; import java.util.Set;
@ -62,4 +64,6 @@ public interface IMdBaseMaterialService extends IService<MdBaseMaterial> {
* @return * @return
*/ */
IPage<MdBaseMaterial> queryByInventory(MdBaseMaterialQuery whereJson, PageQuery page); IPage<MdBaseMaterial> queryByInventory(MdBaseMaterialQuery whereJson, PageQuery page);
void excelImport(MultipartFile file, HttpServletRequest request);
} }

28
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.date.DateUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.nl.wms.ext.mes.service.dao.mapper.MesRequestMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -117,4 +123,26 @@ public class MdBaseMaterialServiceImpl extends ServiceImpl<MdBaseMaterialMapper,
return pages; return pages;
} }
@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<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
// 循环获取的数据
for (int i = 0; i < read.size(); i++) {
}
}
} }

2
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 addScrap(ScrapDto entity);
void excelImport(MultipartFile file, HttpServletRequest request);
} }

21
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); 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<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
// 循环获取的数据
for (int i = 0; i < read.size(); i++) {
}
}
/** /**
* 转换 * 转换

Loading…
Cancel
Save