代码更新:
1. 增加物料和工站配置的导入功能。 2. 完善DBS与工单的导入,修复导入多余数据的bug。
This commit is contained in:
parent
861376cf11
commit
eff71a19c2
|
|
@ -15,9 +15,7 @@ import com.wms.entity.app.vo.FileVo;
|
||||||
import com.wms.entity.table.*;
|
import com.wms.entity.table.*;
|
||||||
import com.wms.service.*;
|
import com.wms.service.*;
|
||||||
import com.wms.utils.StringUtils;
|
import com.wms.utils.StringUtils;
|
||||||
import com.wms.utils.excel.listener.UploadDbsListener;
|
import com.wms.utils.excel.listener.*;
|
||||||
import com.wms.utils.excel.listener.UploadKateOrdersListener;
|
|
||||||
import com.wms.utils.excel.listener.UploadStocksListener;
|
|
||||||
import com.wms.utils.excel.style.ExcelContentStyle;
|
import com.wms.utils.excel.style.ExcelContentStyle;
|
||||||
import com.wms.utils.excel.vo.*;
|
import com.wms.utils.excel.vo.*;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
@ -61,6 +59,8 @@ public class ExcelController {
|
||||||
private final KateDBSLastService kateDbsLastService;// Dbs上次记录服务
|
private final KateDBSLastService kateDbsLastService;// Dbs上次记录服务
|
||||||
private final KateOrdersService kateOrdersService;// 工单服务
|
private final KateOrdersService kateOrdersService;// 工单服务
|
||||||
private final KateOrdersLastService kateOrdersLastService;// 工单上次服务
|
private final KateOrdersLastService kateOrdersLastService;// 工单上次服务
|
||||||
|
private final GoodsService goodsService;// 物料服务
|
||||||
|
private final WorkStationConfigService workStationConfigService;// 工站配置服务
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入库存信息
|
* 导入库存信息
|
||||||
|
|
@ -112,7 +112,7 @@ public class ExcelController {
|
||||||
// 移库Dbs表中的内容
|
// 移库Dbs表中的内容
|
||||||
kateDbsService.remove(new LambdaQueryWrapper<>());
|
kateDbsService.remove(new LambdaQueryWrapper<>());
|
||||||
// 导入excel
|
// 导入excel
|
||||||
EasyExcel.read(file.getInputStream(), KateDbsExcelVo.class, new UploadDbsListener(kateDbsService, kateDbsLastService, fileVo.getUserName())).sheet().doRead();
|
EasyExcel.read(file.getInputStream(), KateDbsExcelVo.class, new UploadDbsListener(kateDbsService, kateDbsLastService, fileVo.getUserName())).sheet().headRowNumber(8).doRead();
|
||||||
// 添加导入记录
|
// 添加导入记录
|
||||||
uploadRecordService.save(UploadRecord.ofFileVo(fileVo, "DBS"));
|
uploadRecordService.save(UploadRecord.ofFileVo(fileVo, "DBS"));
|
||||||
response.setCode(ResponseCode.OK.getCode());
|
response.setCode(ResponseCode.OK.getCode());
|
||||||
|
|
@ -129,7 +129,7 @@ public class ExcelController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入DBS
|
* 导入工单
|
||||||
*
|
*
|
||||||
* @param file 文件
|
* @param file 文件
|
||||||
* @return 导入结果
|
* @return 导入结果
|
||||||
|
|
@ -158,6 +158,66 @@ public class ExcelController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入物料
|
||||||
|
*
|
||||||
|
* @param file 文件
|
||||||
|
* @return 导入结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/uploadGoods")
|
||||||
|
@ResponseBody
|
||||||
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
|
public String uploadGoods(@RequestPart("file") MultipartFile file, @RequestPart("obj") FileVo fileVo) {
|
||||||
|
logger.info("导入物料,请求ip:{},文件详情:{}", getIpAddr(servletRequest), convertJsonString(fileVo));
|
||||||
|
ResponseEntity response = new ResponseEntity();
|
||||||
|
try {
|
||||||
|
// 导入excel
|
||||||
|
EasyExcel.read(file.getInputStream(), GoodsExcelVo.class, new UploadGoodsListener(goodsService, fileVo.getUserName())).sheet("基本信息").doRead();
|
||||||
|
// 添加导入记录
|
||||||
|
uploadRecordService.save(UploadRecord.ofFileVo(fileVo, "GOODS"));
|
||||||
|
response.setCode(ResponseCode.OK.getCode());
|
||||||
|
response.setMessage("导入物料成功。");
|
||||||
|
return convertJsonString(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("导入物料异常:{}", convertJsonString(e));
|
||||||
|
// 回滚事务
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
response.setCode(ResponseCode.ERROR.getCode());
|
||||||
|
response.setMessage("导入物料异常。");
|
||||||
|
return convertJsonString(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入工站配置
|
||||||
|
*
|
||||||
|
* @param file 文件
|
||||||
|
* @return 导入结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/uploadStationConfig")
|
||||||
|
@ResponseBody
|
||||||
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
|
public String uploadStationConfig(@RequestPart("file") MultipartFile file, @RequestPart("obj") FileVo fileVo) {
|
||||||
|
logger.info("导入工站配置,请求ip:{},文件详情:{}", getIpAddr(servletRequest), convertJsonString(fileVo));
|
||||||
|
ResponseEntity response = new ResponseEntity();
|
||||||
|
try {
|
||||||
|
// 导入excel
|
||||||
|
EasyExcel.read(file.getInputStream(), StationConfigExcelVo.class, new UploadStationConfigListener(workStationConfigService, fileVo.getUserName())).sheet("工站配置").doRead();
|
||||||
|
// 添加导入记录
|
||||||
|
uploadRecordService.save(UploadRecord.ofFileVo(fileVo, "STATION-CONFIG_"));
|
||||||
|
response.setCode(ResponseCode.OK.getCode());
|
||||||
|
response.setMessage("导入工站配置。");
|
||||||
|
return convertJsonString(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("导入工站配置异常:{}", convertJsonString(e));
|
||||||
|
// 回滚事务
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
response.setCode(ResponseCode.ERROR.getCode());
|
||||||
|
response.setMessage("导入工站配置异常。");
|
||||||
|
return convertJsonString(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出库存数据
|
* 导出库存数据
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.wms.entity.table.KateDBS;
|
||||||
import com.wms.entity.table.KateDBSLast;
|
import com.wms.entity.table.KateDBSLast;
|
||||||
import com.wms.service.KateDBSLastService;
|
import com.wms.service.KateDBSLastService;
|
||||||
import com.wms.service.KateDBSService;
|
import com.wms.service.KateDBSService;
|
||||||
|
import com.wms.utils.StringUtils;
|
||||||
import com.wms.utils.excel.vo.KateDbsExcelVo;
|
import com.wms.utils.excel.vo.KateDbsExcelVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -56,7 +57,13 @@ public class UploadDbsListener implements ReadListener<KateDbsExcelVo> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void invoke(KateDbsExcelVo kateDbsExcelVo, AnalysisContext analysisContext) {
|
public void invoke(KateDbsExcelVo kateDbsExcelVo, AnalysisContext analysisContext) {
|
||||||
cachedDataList.add(kateDbsExcelVo);
|
if (kateDbsExcelVo.getWorkSequence() != null
|
||||||
|
&& StringUtils.isNotEmpty(kateDbsExcelVo.getWorkOrder())
|
||||||
|
&& StringUtils.isNotEmpty(kateDbsExcelVo.getMachineNo())
|
||||||
|
&& kateDbsExcelVo.getPlanStartDate() != null) {
|
||||||
|
// 符合条件的数据
|
||||||
|
cachedDataList.add(kateDbsExcelVo);
|
||||||
|
}
|
||||||
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
||||||
if (cachedDataList.size() >= BATCH_COUNT) {
|
if (cachedDataList.size() >= BATCH_COUNT) {
|
||||||
logger.info("已经导入{}条数据,开始存储数据库!", cachedDataList.size());
|
logger.info("已经导入{}条数据,开始存储数据库!", cachedDataList.size());
|
||||||
|
|
@ -96,6 +103,7 @@ public class UploadDbsListener implements ReadListener<KateDbsExcelVo> {
|
||||||
KateDBS oldKateDbs = new KateDBS();
|
KateDBS oldKateDbs = new KateDBS();
|
||||||
oldKateDbs.setDbsId(kateDbsLast.getDbsId());
|
oldKateDbs.setDbsId(kateDbsLast.getDbsId());
|
||||||
oldKateDbs.setWorkSequence(kateDbsExcelVo.getWorkSequence());
|
oldKateDbs.setWorkSequence(kateDbsExcelVo.getWorkSequence());
|
||||||
|
oldKateDbs.setMachineNo(kateDbsExcelVo.getMachineNo());
|
||||||
oldKateDbs.setWorkOrder(kateDbsExcelVo.getWorkOrder());
|
oldKateDbs.setWorkOrder(kateDbsExcelVo.getWorkOrder());
|
||||||
oldKateDbs.setPlanStartDate(kateDbsExcelVo.getPlanStartDate());
|
oldKateDbs.setPlanStartDate(kateDbsExcelVo.getPlanStartDate());
|
||||||
oldKateDbs.setDbsStatus(kateDbsLast.getDbsStatus());
|
oldKateDbs.setDbsStatus(kateDbsLast.getDbsStatus());
|
||||||
|
|
@ -107,6 +115,7 @@ public class UploadDbsListener implements ReadListener<KateDbsExcelVo> {
|
||||||
KateDBS newKateDbs = new KateDBS();
|
KateDBS newKateDbs = new KateDBS();
|
||||||
newKateDbs.setDbsId(generateId("DBS_"));
|
newKateDbs.setDbsId(generateId("DBS_"));
|
||||||
newKateDbs.setWorkSequence(kateDbsExcelVo.getWorkSequence());
|
newKateDbs.setWorkSequence(kateDbsExcelVo.getWorkSequence());
|
||||||
|
newKateDbs.setMachineNo(kateDbsExcelVo.getMachineNo());
|
||||||
newKateDbs.setWorkOrder(kateDbsExcelVo.getWorkOrder());
|
newKateDbs.setWorkOrder(kateDbsExcelVo.getWorkOrder());
|
||||||
newKateDbs.setPlanStartDate(kateDbsExcelVo.getPlanStartDate());
|
newKateDbs.setPlanStartDate(kateDbsExcelVo.getPlanStartDate());
|
||||||
newKateDbs.setDbsStatus(0);
|
newKateDbs.setDbsStatus(0);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.wms.utils.excel.listener;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.read.listener.ReadListener;
|
||||||
|
import com.alibaba.excel.util.ListUtils;
|
||||||
|
import com.wms.entity.table.Goods;
|
||||||
|
import com.wms.service.GoodsService;
|
||||||
|
import com.wms.utils.StringUtils;
|
||||||
|
import com.wms.utils.excel.vo.GoodsExcelVo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.wms.utils.StringUtils.convertJsonString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传DBS监听
|
||||||
|
*/
|
||||||
|
public class UploadGoodsListener implements ReadListener<GoodsExcelVo> {
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
/**
|
||||||
|
* 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收
|
||||||
|
*/
|
||||||
|
private static final int BATCH_COUNT = 100;
|
||||||
|
/**
|
||||||
|
* 保存数据总数
|
||||||
|
*/
|
||||||
|
private int SAVE_COUNT = 0;
|
||||||
|
private List<GoodsExcelVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
||||||
|
private final GoodsService goodsService;// Dbs服务
|
||||||
|
private final String uploadUser;// 用户
|
||||||
|
public UploadGoodsListener(GoodsService goodsService, String uploadUser) {
|
||||||
|
this.goodsService = goodsService;
|
||||||
|
this.uploadUser = uploadUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||||
|
logger.error("处理物料数据发生异常:{}", convertJsonString(exception));
|
||||||
|
ReadListener.super.onException(exception, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 这个每一条数据解析都会来调用
|
||||||
|
*
|
||||||
|
* @param goodsExcelVo one row value. It is same as {@link AnalysisContext#readRowHolder()}
|
||||||
|
* @param analysisContext context
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void invoke(GoodsExcelVo goodsExcelVo, AnalysisContext analysisContext) {
|
||||||
|
if (StringUtils.isNotEmpty(goodsExcelVo.getGoodsId())) {
|
||||||
|
// 符合条件的数据
|
||||||
|
cachedDataList.add(goodsExcelVo);
|
||||||
|
}
|
||||||
|
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
||||||
|
if (cachedDataList.size() >= BATCH_COUNT) {
|
||||||
|
logger.info("已经导入{}条数据,开始存储数据库!", cachedDataList.size());
|
||||||
|
saveData();
|
||||||
|
// 存储完成清理 list
|
||||||
|
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有数据解析完成了 都会来调用
|
||||||
|
*
|
||||||
|
* @param analysisContext context
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
saveData();
|
||||||
|
logger.info("此次共保存{}条数据。", SAVE_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储数据
|
||||||
|
*/
|
||||||
|
private void saveData() {
|
||||||
|
// 开始存储数据
|
||||||
|
List<Goods> goodsList = new ArrayList<>();
|
||||||
|
for (GoodsExcelVo goodsExcelVo : cachedDataList) {
|
||||||
|
Goods currentGoods = BeanUtil.copyProperties(goodsExcelVo, Goods.class);
|
||||||
|
currentGoods.setLastUpdateTime(LocalDateTime.now());
|
||||||
|
currentGoods.setLastUpdateUser(uploadUser);
|
||||||
|
goodsList.add(currentGoods);
|
||||||
|
}
|
||||||
|
goodsService.saveOrUpdateBatch(goodsList);
|
||||||
|
// 打印保存数量
|
||||||
|
SAVE_COUNT += goodsList.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -63,8 +63,15 @@ public class UploadKateOrdersListener implements ReadListener<KateOrdersExcelVo>
|
||||||
public void invoke(KateOrdersExcelVo kateOrdersExcelVo, AnalysisContext analysisContext) {
|
public void invoke(KateOrdersExcelVo kateOrdersExcelVo, AnalysisContext analysisContext) {
|
||||||
String slocFilterString = configMap.get(ConfigMapKeyEnum.SLOC_FILTER_STRING.getConfigKey());
|
String slocFilterString = configMap.get(ConfigMapKeyEnum.SLOC_FILTER_STRING.getConfigKey());
|
||||||
if (StringUtils.isNotEmpty(slocFilterString) && Objects.equals(kateOrdersExcelVo.getSLoc(), slocFilterString)) {
|
if (StringUtils.isNotEmpty(slocFilterString) && Objects.equals(kateOrdersExcelVo.getSLoc(), slocFilterString)) {
|
||||||
// 符合筛选条件的才能添加
|
// 符合筛选字符串
|
||||||
cachedDataList.add(kateOrdersExcelVo);
|
if (StringUtils.isNotEmpty(kateOrdersExcelVo.getWorkOrder())
|
||||||
|
&& StringUtils.isNotEmpty(kateOrdersExcelVo.getGoodsId())
|
||||||
|
&& StringUtils.isNotEmpty(kateOrdersExcelVo.getSLoc())
|
||||||
|
&& StringUtils.isNotEmpty(kateOrdersExcelVo.getSupplyArea())
|
||||||
|
&& kateOrdersExcelVo.getRequirementQuantity() != null) {
|
||||||
|
// 符合条件
|
||||||
|
cachedDataList.add(kateOrdersExcelVo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
||||||
if (cachedDataList.size() >= BATCH_COUNT) {
|
if (cachedDataList.size() >= BATCH_COUNT) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
package com.wms.utils.excel.listener;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.read.listener.ReadListener;
|
||||||
|
import com.alibaba.excel.util.ListUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.wms.entity.table.KateDBS;
|
||||||
|
import com.wms.entity.table.KateDBSLast;
|
||||||
|
import com.wms.entity.table.WorkStationConfig;
|
||||||
|
import com.wms.service.KateDBSLastService;
|
||||||
|
import com.wms.service.KateDBSService;
|
||||||
|
import com.wms.service.WorkStationConfigService;
|
||||||
|
import com.wms.utils.StringUtils;
|
||||||
|
import com.wms.utils.excel.vo.KateDbsExcelVo;
|
||||||
|
import com.wms.utils.excel.vo.StationConfigExcelVo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.wms.utils.StringUtils.convertJsonString;
|
||||||
|
import static com.wms.utils.WmsUtils.generateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传DBS监听
|
||||||
|
*/
|
||||||
|
public class UploadStationConfigListener implements ReadListener<StationConfigExcelVo> {
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
/**
|
||||||
|
* 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收
|
||||||
|
*/
|
||||||
|
private static final int BATCH_COUNT = 100;
|
||||||
|
/**
|
||||||
|
* 保存数据总数
|
||||||
|
*/
|
||||||
|
private int SAVE_COUNT = 0;
|
||||||
|
private List<StationConfigExcelVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
||||||
|
private final WorkStationConfigService workStationConfigService;// 工站配置服务
|
||||||
|
private final String uploadUser;// 用户
|
||||||
|
public UploadStationConfigListener(WorkStationConfigService workStationConfigService, String uploadUser) {
|
||||||
|
this.workStationConfigService = workStationConfigService;
|
||||||
|
this.uploadUser = uploadUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||||
|
logger.error("处理工站配置数据发生异常:{}", convertJsonString(exception));
|
||||||
|
ReadListener.super.onException(exception, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 这个每一条数据解析都会来调用
|
||||||
|
*
|
||||||
|
* @param stationConfigExcelVo one row value. It is same as {@link AnalysisContext#readRowHolder()}
|
||||||
|
* @param analysisContext context
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void invoke(StationConfigExcelVo stationConfigExcelVo, AnalysisContext analysisContext) {
|
||||||
|
if (StringUtils.isNotEmpty(stationConfigExcelVo.getWorkStation())) {
|
||||||
|
// 符合条件的数据
|
||||||
|
cachedDataList.add(stationConfigExcelVo);
|
||||||
|
}
|
||||||
|
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
||||||
|
if (cachedDataList.size() >= BATCH_COUNT) {
|
||||||
|
logger.info("已经导入{}条数据,开始存储数据库!", cachedDataList.size());
|
||||||
|
saveData();
|
||||||
|
// 存储完成清理 list
|
||||||
|
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有数据解析完成了 都会来调用
|
||||||
|
*
|
||||||
|
* @param analysisContext context
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
saveData();
|
||||||
|
logger.info("此次共保存{}条数据。", SAVE_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储数据
|
||||||
|
*/
|
||||||
|
private void saveData() {
|
||||||
|
// 存储数据
|
||||||
|
List<WorkStationConfig> stationConfigList = new ArrayList<>();
|
||||||
|
for (StationConfigExcelVo stationConfigExcelVo : cachedDataList) {
|
||||||
|
WorkStationConfig stationConfig = BeanUtil.copyProperties(stationConfigExcelVo, WorkStationConfig.class);
|
||||||
|
stationConfig.setConfigId(generateId("STATION-CONFIG_"));
|
||||||
|
stationConfig.setLastUpdateTime(LocalDateTime.now());
|
||||||
|
stationConfig.setLastUpdateUser(uploadUser);
|
||||||
|
stationConfigList.add(stationConfig);
|
||||||
|
}
|
||||||
|
workStationConfigService.saveOrUpdateBatch(stationConfigList);
|
||||||
|
// 打印数量
|
||||||
|
SAVE_COUNT += stationConfigList.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
146
src/main/java/com/wms/utils/excel/vo/GoodsExcelVo.java
Normal file
146
src/main/java/com/wms/utils/excel/vo/GoodsExcelVo.java
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
package com.wms.utils.excel.vo;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||||
|
import com.wms.entity.app.dto.extend.KanbanEntity;
|
||||||
|
import com.wms.entity.table.Goods;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料excel
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GoodsExcelVo {
|
||||||
|
/**
|
||||||
|
* 物料编号
|
||||||
|
*/
|
||||||
|
@ExcelProperty("料号")
|
||||||
|
private String goodsId;
|
||||||
|
/**
|
||||||
|
* 物料名称/描述
|
||||||
|
*/
|
||||||
|
@ExcelProperty("描述")
|
||||||
|
private String goodsName;
|
||||||
|
/**
|
||||||
|
* 单位
|
||||||
|
*/
|
||||||
|
@ExcelProperty("单位")
|
||||||
|
private String goodsUnit = "PC";
|
||||||
|
/**
|
||||||
|
* 物料分类
|
||||||
|
*/
|
||||||
|
@ExcelProperty("物料分类")
|
||||||
|
private String goodsType;
|
||||||
|
/**
|
||||||
|
* 供应商分类
|
||||||
|
*/
|
||||||
|
@ExcelProperty("供应商分类")
|
||||||
|
private String providerType;
|
||||||
|
/**
|
||||||
|
* 重量
|
||||||
|
*/
|
||||||
|
@ExcelProperty("重量")
|
||||||
|
private BigDecimal weight;
|
||||||
|
/**
|
||||||
|
* 重量单位
|
||||||
|
*/
|
||||||
|
@ExcelProperty("重量单位")
|
||||||
|
private String weightUnit;
|
||||||
|
/**
|
||||||
|
* 每盒数量
|
||||||
|
*/
|
||||||
|
@ExcelProperty("每盒数量")
|
||||||
|
private BigDecimal quantityPerBox;
|
||||||
|
/**
|
||||||
|
* 拆包方式
|
||||||
|
*/
|
||||||
|
@ExcelProperty("拆包方式")
|
||||||
|
private String unpackingType;
|
||||||
|
/**
|
||||||
|
* 料箱类型
|
||||||
|
*/
|
||||||
|
@ExcelProperty("料箱类型")
|
||||||
|
private String vehicleType;
|
||||||
|
/**
|
||||||
|
* 料箱类型描述
|
||||||
|
*/
|
||||||
|
@ExcelProperty("料箱类型描述")
|
||||||
|
private String vehicleTypeDescription;
|
||||||
|
/**
|
||||||
|
* 料箱类型
|
||||||
|
*/
|
||||||
|
@ExcelProperty("料箱类型2")
|
||||||
|
private String goodsInVehicleType;
|
||||||
|
/**
|
||||||
|
* 补料方式
|
||||||
|
* PULL:有看板
|
||||||
|
* PUSH:无看板
|
||||||
|
*/
|
||||||
|
@ExcelProperty("补料方式")
|
||||||
|
private String feedingType;
|
||||||
|
/**
|
||||||
|
* 每个看板包含物料数量
|
||||||
|
*/
|
||||||
|
@ExcelProperty("看板QTY")
|
||||||
|
private BigDecimal quantityPerKanban;
|
||||||
|
/**
|
||||||
|
* 看板的数量
|
||||||
|
*/
|
||||||
|
@ExcelProperty("Number of kanban")
|
||||||
|
private BigDecimal kanbanNum;
|
||||||
|
/**
|
||||||
|
* 看板详细信息
|
||||||
|
*/
|
||||||
|
@ExcelProperty("看板")
|
||||||
|
private List<KanbanEntity> kanbanList;
|
||||||
|
/**
|
||||||
|
* 补货点
|
||||||
|
*/
|
||||||
|
@ExcelProperty("补货点")
|
||||||
|
private BigDecimal feedingValue;
|
||||||
|
/**
|
||||||
|
* 备注1
|
||||||
|
*/
|
||||||
|
@ExcelProperty("备注1")
|
||||||
|
private String remark1;
|
||||||
|
/**
|
||||||
|
* 备注2
|
||||||
|
*/
|
||||||
|
@ExcelProperty("备注2")
|
||||||
|
private String remark2;
|
||||||
|
/**
|
||||||
|
* 备注3
|
||||||
|
*/
|
||||||
|
@ExcelProperty("备注3")
|
||||||
|
private String remark3;
|
||||||
|
/**
|
||||||
|
* 数据来源
|
||||||
|
*/
|
||||||
|
@ExcelProperty("数据来源")
|
||||||
|
private String dataSource;
|
||||||
|
/**
|
||||||
|
* 最后更新日期
|
||||||
|
*/
|
||||||
|
@ExcelProperty("最近更新时间")
|
||||||
|
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime lastUpdateTime;
|
||||||
|
/**
|
||||||
|
* 最近更新用户
|
||||||
|
*/
|
||||||
|
@ExcelProperty("最近更新用户")
|
||||||
|
private String lastUpdateUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从数据库实体转换为excel对象
|
||||||
|
* @param goodsPo 数据库实体
|
||||||
|
* @return excel对象
|
||||||
|
*/
|
||||||
|
public static GoodsExcelVo of(Goods goodsPo) {
|
||||||
|
return BeanUtil.copyProperties(goodsPo, GoodsExcelVo.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.wms.utils.excel.vo;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||||
|
import com.wms.entity.table.WorkStationConfig;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工站配置Vo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StationConfigExcelVo {
|
||||||
|
/**
|
||||||
|
* 配置id
|
||||||
|
*/
|
||||||
|
@ExcelProperty("配置id")
|
||||||
|
private String configId;
|
||||||
|
/**
|
||||||
|
* 工作站台
|
||||||
|
*/
|
||||||
|
@ExcelProperty("工站")
|
||||||
|
private String workStation;
|
||||||
|
/**
|
||||||
|
* 小盒子---对面工单表里面的小工位
|
||||||
|
*/
|
||||||
|
@ExcelProperty("小盒子#")
|
||||||
|
private String smallBox;
|
||||||
|
/**
|
||||||
|
* 机型
|
||||||
|
*/
|
||||||
|
@ExcelProperty("机型")
|
||||||
|
private String model;
|
||||||
|
/**
|
||||||
|
* 工位
|
||||||
|
*/
|
||||||
|
@ExcelProperty("工位")
|
||||||
|
private String workCenter;
|
||||||
|
/**
|
||||||
|
* 工位大盒子
|
||||||
|
*/
|
||||||
|
@ExcelProperty("工位大盒子#")
|
||||||
|
private String bigBox;
|
||||||
|
/**
|
||||||
|
* 车辆
|
||||||
|
*/
|
||||||
|
@ExcelProperty("车辆")
|
||||||
|
private String vehicle;
|
||||||
|
/**
|
||||||
|
* 线边架/车位置
|
||||||
|
*/
|
||||||
|
@ExcelProperty("线边架/车位置")
|
||||||
|
private String vehicleLocation;
|
||||||
|
/**
|
||||||
|
* 开工时间调整
|
||||||
|
*/
|
||||||
|
@ExcelProperty("开工时间调整")
|
||||||
|
private Integer startDateAdjust = 0;
|
||||||
|
/**
|
||||||
|
* 最近更新时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty("最近更新时间")
|
||||||
|
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime lastUpdateTime;
|
||||||
|
/**
|
||||||
|
* 最近更新用户
|
||||||
|
*/
|
||||||
|
@ExcelProperty("最近更新用户")
|
||||||
|
private String lastUpdateUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从数据库实体转换为excel对象
|
||||||
|
* @param stationConfigPo 数据库实体
|
||||||
|
* @return excel对象
|
||||||
|
*/
|
||||||
|
public static StationConfigExcelVo of(WorkStationConfig stationConfigPo) {
|
||||||
|
return BeanUtil.copyProperties(stationConfigPo, StationConfigExcelVo.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,20 +8,20 @@ spring:
|
||||||
# 主库
|
# 主库
|
||||||
master:
|
master:
|
||||||
# 卡特数据库服务器
|
# 卡特数据库服务器
|
||||||
# url: jdbc:mysql://10.90.36.71:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
url: jdbc:mysql://10.90.36.71:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
# username: developer
|
username: developer
|
||||||
# password: developer
|
password: developer
|
||||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
# 宝开服务器--内网
|
# 宝开服务器--内网
|
||||||
# url: jdbc:mysql://192.168.3.254:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
# url: jdbc:mysql://192.168.3.254:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
# username: coder
|
# username: coder
|
||||||
# password: coder
|
# password: coder
|
||||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
# # 本地环境
|
# # 本地环境
|
||||||
url: jdbc:mysql://localhost:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
# url: jdbc:mysql://localhost:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
username: developer
|
# username: developer
|
||||||
password: developer
|
# password: developer
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
# 从库
|
# 从库
|
||||||
# slave_1:
|
# slave_1:
|
||||||
# url: jdbc:mysql://localhost:3306/wms_aaa?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
# url: jdbc:mysql://localhost:3306/wms_aaa?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user