feat(qrcodemaster): 添加装箱管理控制器实现装箱拆箱换箱功能
- 新增 QrCodeMasterController 控制器提供装箱管理相关接口 - 实现装箱绑码功能支持小码放入大码中 - 实现拆箱删除功能支持从箱中移除物料二维码 - 实现换箱功能支持库存地点内物料箱合并 - 添加扫码接口获取二维码详细信息 - 实现标签导出功能支持ZIP和PDF格式 - 提供包装箱和箱内物料信息查询接口 - 添加批次号一致性校验防止混批操作 - 实现物料匹配验证确保装箱准确性 - 完善状态流转控制防止非法操作 - 添加防重复装箱和跨工厂仓库限制 - 优化库存管理实现出入库自动处理
This commit is contained in:
parent
1fc36d7284
commit
981d1f4a96
|
|
@ -54,6 +54,7 @@ import java.util.zip.ZipOutputStream;
|
|||
|
||||
/**
|
||||
* 装箱管理
|
||||
*
|
||||
* @author: nflg
|
||||
* @date: 2022/3/17
|
||||
* @description:
|
||||
|
|
@ -133,16 +134,18 @@ public class QrCodeMasterController extends BaseController {
|
|||
@ApiMark(moduleName = "包装箱编码获取获取包装箱信息", apiName = "包装箱编码获取获取包装箱信息")
|
||||
public ApiResult<List<PackageInfoVO>> getPackageInfos(@Valid @RequestBody PackageQO request) {
|
||||
List<WmsPackageItem> wmsPackageItems = wmsPackageItemService.lambdaQuery()
|
||||
.eq(WmsPackageItem::getPackageId,request.getPackageId())
|
||||
.eq(WmsPackageItem::getPackageId, request.getPackageId())
|
||||
.list();
|
||||
if (CollectionUtil.isEmpty(wmsPackageItems)) {
|
||||
return ApiResult.success(Collections.emptyList());
|
||||
}
|
||||
List<String> barcodeCodes = wmsPackageItems.stream()
|
||||
.map(WmsPackageItem::getBarcodeCode)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
List<WmsQrCodeMaster> qrCodeMasterList = qrCodeMasterService.lambdaQuery()
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes)
|
||||
.list();
|
||||
List<PackageInfoVO> packageInfoVOS = Convert.toList(PackageInfoVO.class,qrCodeMasterList);
|
||||
List<PackageInfoVO> packageInfoVOS = Convert.toList(PackageInfoVO.class, qrCodeMasterList);
|
||||
packageInfoVOS.forEach(vo -> {
|
||||
WmsPackageItem item = wmsPackageItems.stream()
|
||||
.filter(p -> StrUtil.equals(p.getBarcodeCode(), vo.getBarcodeCode()))
|
||||
|
|
@ -164,7 +167,8 @@ public class QrCodeMasterController extends BaseController {
|
|||
*/
|
||||
private void smallBarcodeValidation(WmsQrCodeMaster qrCodeMaster,
|
||||
List<WmsQrCodeMaster> smallQrCodeMasters,
|
||||
BarCodeProcessStage processStage) {
|
||||
BarCodeProcessStage processStage,
|
||||
boolean equals) {
|
||||
boolean hasDuplicates = smallQrCodeMasters.stream()
|
||||
.map(WmsQrCodeMaster::getBarcodeCode)
|
||||
.collect(Collectors.toSet())
|
||||
|
|
@ -182,16 +186,25 @@ public class QrCodeMasterController extends BaseController {
|
|||
VUtil.trueThrowBusinessError(materialCodes.size() > 1).throwMessage("此箱码中包含多中物料");
|
||||
VUtil.trueThrowBusinessError(!materialCodes.get(0).equals(qrCodeMaster.getMaterialCode())).throwMessage("物料不匹配");
|
||||
//判断小码中是否又被使用过了
|
||||
Integer count = qrCodeMasterService.lambdaQuery()
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes)
|
||||
.eq(WmsQrCodeMaster::getProcessStage, processStage.getState())
|
||||
.count().intValue();
|
||||
VUtil.trueThrowBusinessError(count > 0).throwMessage("此箱码中包含已使用的物料二维码");
|
||||
Integer count1 = qrCodeMasterService.lambdaQuery()
|
||||
if (equals) {
|
||||
VUtil.trueThrowBusinessError(
|
||||
qrCodeMasterService.lambdaQuery()
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes)
|
||||
.ne(WmsQrCodeMaster::getProcessStage, processStage.getState())
|
||||
.exists()
|
||||
).throwMessage("此箱码中包含非【" + processStage.getDescription() + "】的物料二维码");
|
||||
} else {
|
||||
VUtil.trueThrowBusinessError(
|
||||
qrCodeMasterService.lambdaQuery()
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes)
|
||||
.eq(WmsQrCodeMaster::getProcessStage, processStage.getState())
|
||||
.exists()
|
||||
).throwMessage("此箱码中包含【" + processStage.getDescription() + "】的物料二维码");
|
||||
}
|
||||
VUtil.trueThrowBusinessError(qrCodeMasterService.lambdaQuery()
|
||||
.eq(WmsQrCodeMaster::getPackagingType, 1)
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes)
|
||||
.count().intValue();
|
||||
VUtil.trueThrowBusinessError(count1 > 0).throwMessage("存在箱子码(中码)");
|
||||
.in(WmsQrCodeMaster::getBarcodeCode, barcodeCodes).exists()
|
||||
).throwMessage("存在箱子码(中码)");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -225,10 +238,10 @@ public class QrCodeMasterController extends BaseController {
|
|||
}
|
||||
}
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isNotEmpty(differentBatchNos))
|
||||
.throwMessage("批次号不一致,不一致的物料条码号为:" + StrUtil.join(",",differentBatchNos));
|
||||
.throwMessage("批次号不一致,不一致的物料条码号为:" + StrUtil.join(",", differentBatchNos));
|
||||
|
||||
// 判断箱子的物料信息是否OK
|
||||
smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.Packaged);
|
||||
smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.Packaged, false);
|
||||
// 修改小码的所属关系
|
||||
for (WmsQrCodeMaster smallQrCodeMaster : smallQrCodeMasters) {
|
||||
smallQrCodeMaster.setParentBarcodeId(qrCodeMaster.getId());
|
||||
|
|
@ -281,6 +294,7 @@ public class QrCodeMasterController extends BaseController {
|
|||
/**
|
||||
* 换箱
|
||||
* 针对库存地点内的物料箱合并,修改物料的箱属性和库存
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -305,7 +319,7 @@ public class QrCodeMasterController extends BaseController {
|
|||
.in(WmsQrCodeMaster::getBarcodeCode, request.getItems())
|
||||
.list();
|
||||
// 判断箱子的物料信息是否OK
|
||||
smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.InBound);
|
||||
smallBarcodeValidation(qrCodeMaster, smallQrCodeMasters, BarCodeProcessStage.InBound, true);
|
||||
//校验批次号是否一致
|
||||
String masterbatchNo = qrCodeMaster.getBatchNo();
|
||||
Set<String> differentBatchNos = new HashSet<>();
|
||||
|
|
@ -319,11 +333,18 @@ public class QrCodeMasterController extends BaseController {
|
|||
.throwMessage("批次号不一致,不一致的物料条码号为:" + differentBatchNos);
|
||||
|
||||
// 只有同一个工厂的同一个库存地点的可以进行换箱
|
||||
Integer count1 = qrCodeMasterService.lambdaQuery()
|
||||
.eq(WmsQrCodeMaster::getFactoryCode, request.getFactoryCode())
|
||||
.eq(WmsQrCodeMaster::getStorageLocation, request.getStorageLocation())
|
||||
.count().intValue();
|
||||
VUtil.trueThrowBusinessError(count1 > 0).throwMessage("换箱只可以在相同的库存地点下进行");
|
||||
// Integer count1 = qrCodeMasterService.lambdaQuery()
|
||||
// .eq(WmsQrCodeMaster::getFactoryCode, request.getFactoryCode())
|
||||
// .eq(WmsQrCodeMaster::getStorageLocation, request.getStorageLocation())
|
||||
// .count().intValue();
|
||||
// VUtil.trueThrowBusinessError(count1 > 0).throwMessage("换箱只可以在相同的库存地点下进行");
|
||||
Set<String> factory = smallQrCodeMasters.stream().map(WmsQrCodeMaster::getFactoryCode).collect(Collectors.toSet());
|
||||
VUtil.trueThrowBusinessError(factory.size() > 1).throwMessage("换箱只可以在同一个工厂的库存地点下进行");
|
||||
Set<String> warehouse = smallQrCodeMasters.stream().map(WmsQrCodeMaster::getStorageLocation).collect(Collectors.toSet());
|
||||
VUtil.trueThrowBusinessError(warehouse.size() > 1).throwMessage("换箱只可以在同一个库存地点下进行");
|
||||
VUtil.trueThrowBusinessError(!StrUtil.equals(factory.iterator().next(), request.getFactoryCode())
|
||||
|| !StrUtil.equals(warehouse.iterator().next(), request.getStorageLocation())
|
||||
).throwMessage("物料所在仓库地点与选择的仓库地点不一致");
|
||||
// 区分状态
|
||||
// 1、新箱的状态,没有入过库;直接将明细物料退库,重新绑定
|
||||
if (processStage.equals(BarCodeProcessStage.Unpackaged)) {
|
||||
|
|
@ -381,6 +402,7 @@ public class QrCodeMasterController extends BaseController {
|
|||
|
||||
/**
|
||||
* 物料出入库统一扫码接口
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @author
|
||||
|
|
@ -417,9 +439,10 @@ public class QrCodeMasterController extends BaseController {
|
|||
* 换箱扫码接口
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @author
|
||||
* */
|
||||
* @return
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
@PostMapping("pda/changeScan")
|
||||
@ApiMark(moduleName = "换箱扫码", apiName = "扫码换箱箱子扫码信息")
|
||||
public ApiResult<QrCodeVO> changeScan(@Valid @RequestBody QRCodeSearchQO request) {
|
||||
|
|
@ -446,6 +469,7 @@ public class QrCodeMasterController extends BaseController {
|
|||
|
||||
/**
|
||||
* 导出标签图片为ZIP
|
||||
*
|
||||
* @param datas 二维码列表
|
||||
*/
|
||||
@PostMapping(value = "exportToZip", produces = "application/zip")
|
||||
|
|
@ -475,6 +499,7 @@ public class QrCodeMasterController extends BaseController {
|
|||
|
||||
/**
|
||||
* 导出标签图片为PDF
|
||||
*
|
||||
* @param datas 二维码列表
|
||||
*/
|
||||
@PostMapping("exportToPdf")
|
||||
|
|
|
|||
|
|
@ -3,20 +3,18 @@ package com.nflg.wms.repository.service.impl;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.wms.common.constant.BarCodeProcessStage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.pojo.dto.InventoryInDTO;
|
||||
import com.nflg.wms.common.pojo.dto.InventoryOutDTO;
|
||||
import com.nflg.wms.common.pojo.qo.FilterIdSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QrCodeItemSearchQO;
|
||||
import com.nflg.wms.common.pojo.vo.QrCodeItemVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.WmsQrCodeMaster;
|
||||
import com.nflg.wms.repository.entity.WmsTransferOrders;
|
||||
import com.nflg.wms.repository.mapper.WmsQrCodeMasterMapper;
|
||||
import com.nflg.wms.repository.service.IWmsInventoryService;
|
||||
import com.nflg.wms.repository.service.IWmsQrCodeMasterService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.wms.repository.service.IWmsTransferOrdersService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
|
|
@ -24,7 +22,6 @@ import org.springframework.retry.annotation.Retryable;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -100,24 +97,24 @@ public class WmsQrCodeMasterServiceImpl extends ServiceImpl<WmsQrCodeMasterMappe
|
|||
if (CollectionUtil.isNotEmpty(inBoundInventory)) {
|
||||
inventoryService.in(inBoundInventory);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(changeBeforeParentBarcodeCodes)) {
|
||||
changeBeforeParentBarcodeCodes.forEach(code -> {
|
||||
WmsQrCodeMaster qrCodeMaster = lambdaQuery()
|
||||
.eq(WmsQrCodeMaster::getId, code)
|
||||
.one();
|
||||
|
||||
if (qrCodeMaster != null) {
|
||||
List<WmsQrCodeMaster> smallQcodeMasters = lambdaQuery()
|
||||
.eq(WmsQrCodeMaster::getParentBarcodeId, code)
|
||||
.ne(WmsQrCodeMaster::getProcessStage, BarCodeProcessStage.InBound.getState())
|
||||
.list();
|
||||
if (CollectionUtil.isEmpty(smallQcodeMasters)) {
|
||||
qrCodeMaster.setProcessStage(BarCodeProcessStage.OutBound.getState());
|
||||
smallQrCodeMasters.add(qrCodeMaster);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// if (CollectionUtil.isNotEmpty(changeBeforeParentBarcodeCodes)) {
|
||||
// changeBeforeParentBarcodeCodes.forEach(code -> {
|
||||
// WmsQrCodeMaster qrCodeMaster = lambdaQuery()
|
||||
// .eq(WmsQrCodeMaster::getId, code)
|
||||
// .one();
|
||||
//
|
||||
// if (qrCodeMaster != null) {
|
||||
// List<WmsQrCodeMaster> smallQcodeMasters = lambdaQuery()
|
||||
// .eq(WmsQrCodeMaster::getParentBarcodeId, code)
|
||||
// .ne(WmsQrCodeMaster::getProcessStage, BarCodeProcessStage.InBound.getState())
|
||||
// .list();
|
||||
// if (CollectionUtil.isEmpty(smallQcodeMasters)) {
|
||||
// qrCodeMaster.setProcessStage(BarCodeProcessStage.OutBound.getState());
|
||||
// smallQrCodeMasters.add(qrCodeMaster);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//修改状态
|
||||
updateBarCode(smallQrCodeMasters);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue