add:组盘页面新增导入组盘信息
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
package org.nl.config.excel.group;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GroupExcelDTO {
|
||||||
|
|
||||||
|
@ExcelProperty("载具编码")
|
||||||
|
private String storagevehicle_code;
|
||||||
|
|
||||||
|
@ExcelProperty("物料编码")
|
||||||
|
private String material_code;
|
||||||
|
|
||||||
|
@ExcelProperty("批次")
|
||||||
|
private String pcsn;
|
||||||
|
|
||||||
|
@ExcelProperty("组盘数量")
|
||||||
|
private BigDecimal qty;
|
||||||
|
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ExcelProperty("供应商编码")
|
||||||
|
private String supp_code;
|
||||||
|
|
||||||
|
@ExcelProperty("生产日期")
|
||||||
|
private String produce_time;
|
||||||
|
|
||||||
|
@ExcelProperty("烘干次数")
|
||||||
|
private Integer bake_num;
|
||||||
|
|
||||||
|
@ExcelProperty("品质类型")
|
||||||
|
private String quality_type;
|
||||||
|
|
||||||
|
@ExcelProperty("料箱类型")
|
||||||
|
private String box_type;
|
||||||
|
|
||||||
|
@ExcelProperty("机台编码")
|
||||||
|
private String device_code;
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package org.nl.config.excel.group;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.common.exception.BadRequestException;
|
||||||
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.MdCsSupplierbase;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||||
|
import org.nl.wms.basedata_manage.service.impl.MdCsSupplierbaseServiceImpl;
|
||||||
|
import org.nl.wms.basedata_manage.service.impl.MdMeMaterialbaseServiceImpl;
|
||||||
|
import org.nl.wms.warehouse_management.service.dao.GroupPlate;
|
||||||
|
import org.nl.wms.warehouse_management.service.impl.MdPbGroupplateServiceImpl;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class GroupExcelListener extends AnalysisEventListener<GroupExcelDTO> {
|
||||||
|
|
||||||
|
// 存储解析的数据
|
||||||
|
private List<GroupExcelDTO> dataList = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(GroupExcelDTO userDTO, AnalysisContext analysisContext) {
|
||||||
|
dataList.add(userDTO);
|
||||||
|
// 调用插入逻辑
|
||||||
|
saveData();
|
||||||
|
// 清空缓存
|
||||||
|
dataList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
// 处理最后一批数据
|
||||||
|
saveData();
|
||||||
|
log.info("Excel解析完成,共处理{}条数据", dataList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实际逻辑(替换为mybatis/dao操作)
|
||||||
|
*/
|
||||||
|
private void saveData() {
|
||||||
|
if (!dataList.isEmpty()) {
|
||||||
|
for (GroupExcelDTO dto : dataList) {
|
||||||
|
// 基础校验
|
||||||
|
checkData(dto);
|
||||||
|
GroupPlate groupPlate = JSONObject.parseObject(JSONObject.toJSONString(dto), GroupPlate.class);
|
||||||
|
|
||||||
|
MdMeMaterialbaseServiceImpl iMdMeMaterialbaseService = SpringContextHolder.getBean(MdMeMaterialbaseServiceImpl.class);
|
||||||
|
MdMeMaterialbase materDao = iMdMeMaterialbaseService.getByCode(dto.getMaterial_code());
|
||||||
|
groupPlate.setMaterial_id(materDao.getMaterial_id());
|
||||||
|
MdCsSupplierbaseServiceImpl iMdCsSupplierbaseService = SpringContextHolder.getBean(MdCsSupplierbaseServiceImpl.class);
|
||||||
|
MdCsSupplierbase suppDao = iMdCsSupplierbaseService.getByCode(dto.getSupp_code());
|
||||||
|
groupPlate.setSupp_code(suppDao.getSupp_code());
|
||||||
|
|
||||||
|
SpringContextHolder.getBean(MdPbGroupplateServiceImpl.class).create(groupPlate);
|
||||||
|
}
|
||||||
|
log.info("批量组盘{}条数据", dataList.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkData(GroupExcelDTO dto) {
|
||||||
|
if (ObjectUtil.isEmpty(dto.getStoragevehicle_code())) {
|
||||||
|
throw new BadRequestException("载具编码不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(dto.getPcsn())) {
|
||||||
|
throw new BadRequestException("批次不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(dto.getQty())) {
|
||||||
|
throw new BadRequestException("组盘数量不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(dto.getProduce_time())) {
|
||||||
|
throw new BadRequestException("生产日期不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(dto.getBake_num())) {
|
||||||
|
throw new BadRequestException("烘干次数不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(dto.getQuality_type())) {
|
||||||
|
throw new BadRequestException("品质类型不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(dto.getBox_type())) {
|
||||||
|
throw new BadRequestException("料箱类型不能为空!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,6 +109,7 @@ public class GroupController {
|
|||||||
@Log("导入数据")
|
@Log("导入数据")
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
public ResponseEntity<Object> importExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
public ResponseEntity<Object> importExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||||
return new ResponseEntity<>(iMdPbGroupplateService.importExcel(file, request),HttpStatus.OK);
|
iMdPbGroupplateService.importExcel(file, request);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import org.nl.wms.warehouse_management.service.dao.GroupPlate;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -60,6 +59,7 @@ public interface IMdPbGroupplateService extends IService<GroupPlate> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询物料集合
|
* 查询物料集合
|
||||||
|
*
|
||||||
* @return List<MdMeMaterialbase>
|
* @return List<MdMeMaterialbase>
|
||||||
*/
|
*/
|
||||||
List<MdMeMaterialbase> queryMaterList();
|
List<MdMeMaterialbase> queryMaterList();
|
||||||
@@ -92,15 +92,16 @@ public interface IMdPbGroupplateService extends IService<GroupPlate> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 打印物料标签后删除
|
* 打印物料标签后删除
|
||||||
|
*
|
||||||
* @param dto 实体类
|
* @param dto 实体类
|
||||||
*/
|
*/
|
||||||
void printDelete(GroupPlate dto);
|
void printDelete(GroupPlate dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入excel
|
* 导入excel
|
||||||
|
*
|
||||||
* @param file : 文件
|
* @param file : 文件
|
||||||
* @param request post请求
|
* @param request post请求
|
||||||
* @return ArrayList<JSONObject>
|
|
||||||
*/
|
*/
|
||||||
ArrayList<JSONObject> importExcel(MultipartFile file, HttpServletRequest request);
|
void importExcel(MultipartFile file, HttpServletRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ package org.nl.wms.warehouse_management.service.impl;
|
|||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.poi.excel.ExcelReader;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
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;
|
||||||
@@ -12,9 +11,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.common.exception.BadRequestException;
|
import org.nl.common.exception.BadRequestException;
|
||||||
import org.nl.common.utils.CodeUtil;
|
|
||||||
import org.nl.common.utils.SecurityUtils;
|
import org.nl.common.utils.SecurityUtils;
|
||||||
import org.nl.config.IdUtil;
|
import org.nl.config.IdUtil;
|
||||||
|
import org.nl.config.excel.group.GroupExcelDTO;
|
||||||
|
import org.nl.config.excel.group.GroupExcelListener;
|
||||||
import org.nl.wms.basedata_manage.service.IMdCsSupplierbaseService;
|
import org.nl.wms.basedata_manage.service.IMdCsSupplierbaseService;
|
||||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||||
import org.nl.wms.basedata_manage.service.IMdPbMeasureunitService;
|
import org.nl.wms.basedata_manage.service.IMdPbMeasureunitService;
|
||||||
@@ -28,17 +28,17 @@ import org.nl.wms.warehouse_management.enums.IOSEnum;
|
|||||||
import org.nl.wms.warehouse_management.service.IMdPbGroupplateService;
|
import org.nl.wms.warehouse_management.service.IMdPbGroupplateService;
|
||||||
import org.nl.wms.warehouse_management.service.dao.GroupPlate;
|
import org.nl.wms.warehouse_management.service.dao.GroupPlate;
|
||||||
import org.nl.wms.warehouse_management.service.dao.mapper.MdPbGroupplateMapper;
|
import org.nl.wms.warehouse_management.service.dao.mapper.MdPbGroupplateMapper;
|
||||||
import org.nl.wms.warehouse_management.service.dto.GroupPlateDto;
|
|
||||||
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.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.InputStream;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.util.HashSet;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -110,8 +110,8 @@ public class MdPbGroupplateServiceImpl extends ServiceImpl<MdPbGroupplateMapper,
|
|||||||
MdMeMaterialbase mater = iMdMeMaterialbaseService.getById(dto.getMaterial_id());
|
MdMeMaterialbase mater = iMdMeMaterialbaseService.getById(dto.getMaterial_id());
|
||||||
DateTime parse = DateUtil.parse(dto.getProduce_time().substring(0, 10));
|
DateTime parse = DateUtil.parse(dto.getProduce_time().substring(0, 10));
|
||||||
String quality_time = DateUtil.offsetDay(parse, mater.getQuality_time()).toString();
|
String quality_time = DateUtil.offsetDay(parse, mater.getQuality_time()).toString();
|
||||||
dto.setQuality_time(quality_time.substring(0,10));
|
dto.setQuality_time(quality_time.substring(0, 10));
|
||||||
dto.setProduce_time(dto.getProduce_time().substring(0,10));
|
dto.setProduce_time(dto.getProduce_time().substring(0, 10));
|
||||||
dto.setCreate_id(SecurityUtils.getCurrentUserId());
|
dto.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||||
dto.setCreate_name(SecurityUtils.getCurrentNickName());
|
dto.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||||
dto.setCreate_time(DateUtil.now());
|
dto.setCreate_time(DateUtil.now());
|
||||||
@@ -124,8 +124,8 @@ public class MdPbGroupplateServiceImpl extends ServiceImpl<MdPbGroupplateMapper,
|
|||||||
MdMeMaterialbase mater = iMdMeMaterialbaseService.getById(dto.getMaterial_id());
|
MdMeMaterialbase mater = iMdMeMaterialbaseService.getById(dto.getMaterial_id());
|
||||||
DateTime parse = DateUtil.parse(dto.getProduce_time().substring(0, 10));
|
DateTime parse = DateUtil.parse(dto.getProduce_time().substring(0, 10));
|
||||||
String quality_time = DateUtil.offsetDay(parse, mater.getQuality_time()).toString();
|
String quality_time = DateUtil.offsetDay(parse, mater.getQuality_time()).toString();
|
||||||
dto.setQuality_time(quality_time.substring(0,10));
|
dto.setQuality_time(quality_time.substring(0, 10));
|
||||||
dto.setProduce_time(dto.getProduce_time().substring(0,10));
|
dto.setProduce_time(dto.getProduce_time().substring(0, 10));
|
||||||
this.updateById(dto);
|
this.updateById(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ public class MdPbGroupplateServiceImpl extends ServiceImpl<MdPbGroupplateMapper,
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void printDelete(GroupPlate dto) {
|
public void printDelete(GroupPlate dto) {
|
||||||
if(ObjectUtil.isNotEmpty(dto.getOut_type()) && ObjectUtil.isNotEmpty(dto.getIs_need_delete())) {
|
if (ObjectUtil.isNotEmpty(dto.getOut_type()) && ObjectUtil.isNotEmpty(dto.getIs_need_delete())) {
|
||||||
if (dto.getOut_type().equals(IOSEnum.OUT_BILL_TYPE.code("烘干出库")) && dto.getIs_need_delete().equals(IOSConstant.ONE)) {
|
if (dto.getOut_type().equals(IOSEnum.OUT_BILL_TYPE.code("烘干出库")) && dto.getIs_need_delete().equals(IOSConstant.ONE)) {
|
||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
set.add(dto.getGroup_id());
|
set.add(dto.getGroup_id());
|
||||||
@@ -180,59 +180,18 @@ public class MdPbGroupplateServiceImpl extends ServiceImpl<MdPbGroupplateMapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ArrayList<JSONObject> importExcel(MultipartFile file, HttpServletRequest request) {
|
public void importExcel(MultipartFile file, HttpServletRequest request) {
|
||||||
// 1.获取上传文件输入流
|
|
||||||
InputStream inputStream = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
inputStream = file.getInputStream();
|
if (file.isEmpty()) {
|
||||||
} catch (Exception e) {
|
throw new BadRequestException("文件不能为空!");
|
||||||
|
}
|
||||||
|
// 读取Excel(逐行解析,自动触发监听器)
|
||||||
|
EasyExcel.read(file.getInputStream(), GroupExcelDTO.class, new GroupExcelListener())
|
||||||
|
.sheet()
|
||||||
|
.doRead();
|
||||||
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
throw new BadRequestException("导入失败!" + e.getMessage());
|
||||||
}
|
}
|
||||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
|
|
||||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
|
||||||
|
|
||||||
for (int i = 0; i < read.size(); i++) {
|
|
||||||
List list = read.get(i);
|
|
||||||
// 载具编码
|
|
||||||
String storagevehicle_code = list.get(0).toString();
|
|
||||||
// 物料编码
|
|
||||||
String material_code = list.get(1).toString();
|
|
||||||
// 批次
|
|
||||||
String pcsn = list.get(2).toString();
|
|
||||||
// 组盘数量
|
|
||||||
String qty = list.get(3).toString();
|
|
||||||
// 备注
|
|
||||||
String remark = list.get(4).toString();
|
|
||||||
// 供应商编码
|
|
||||||
String supp_code = list.get(5).toString();
|
|
||||||
// 生产日期
|
|
||||||
String produce_time = list.get(6).toString();
|
|
||||||
// 烘干次数
|
|
||||||
String bake_num = list.get(7).toString();
|
|
||||||
// 品质类型
|
|
||||||
String quality_type = list.get(8).toString();
|
|
||||||
// 料箱类型
|
|
||||||
String box_type = list.get(9).toString();
|
|
||||||
// 机台编码
|
|
||||||
String device_code = list.get(10).toString();
|
|
||||||
|
|
||||||
GroupPlate groupPlate = new GroupPlate();
|
|
||||||
groupPlate.setStoragevehicle_code(storagevehicle_code);
|
|
||||||
MdMeMaterialbase materDao = iMdMeMaterialbaseService.getByCode(material_code);
|
|
||||||
groupPlate.setMaterial_id(materDao.getMaterial_id());
|
|
||||||
groupPlate.setPcsn(pcsn);
|
|
||||||
groupPlate.setQty(BigDecimal.valueOf(Double.parseDouble(qty)));
|
|
||||||
groupPlate.setRemark(remark);
|
|
||||||
MdCsSupplierbase suppDao = iMdCsSupplierbaseService.getByCode(supp_code);
|
|
||||||
groupPlate.setSupp_code(suppDao.getSupp_code());
|
|
||||||
groupPlate.setProduce_time(produce_time);
|
|
||||||
groupPlate.setBake_num(Integer.parseInt(bake_num));
|
|
||||||
groupPlate.setQuality_type(quality_type);
|
|
||||||
groupPlate.setBox_type(box_type);
|
|
||||||
groupPlate.setDevice_code(device_code);
|
|
||||||
this.create(groupPlate);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ export default {
|
|||||||
formdata.append('file', this.file1.raw)
|
formdata.append('file', this.file1.raw)
|
||||||
// excelImport:请求接口 formdata:传递参数
|
// excelImport:请求接口 formdata:传递参数
|
||||||
crudGroup.excelImport(formdata).then((res) => {
|
crudGroup.excelImport(formdata).then((res) => {
|
||||||
|
this.crud.toQuery()
|
||||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||||
this.$emit('tableChanged', res)
|
|
||||||
this.$emit('update:dialogShow', false)
|
this.$emit('update:dialogShow', false)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
>
|
>
|
||||||
物料标签
|
物料标签
|
||||||
</el-button>
|
</el-button>
|
||||||
<!-- <el-button
|
<el-button
|
||||||
slot="left"
|
slot="left"
|
||||||
class="filter-item"
|
class="filter-item"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
@click="Import"
|
@click="Import"
|
||||||
>
|
>
|
||||||
组盘信息导入
|
组盘信息导入
|
||||||
</el-button>-->
|
</el-button>
|
||||||
</crudOperation>
|
</crudOperation>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
|
|||||||
Reference in New Issue
Block a user