|
|
|
|
@ -30,8 +30,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@ -96,14 +96,15 @@ public class WmsInstockDetailServiceImpl implements IWmsInstockDetailService {
|
|
|
|
|
MPJLambdaWrapper<WmsInstockDetail> lqw = JoinWrappers.lambda(WmsInstockDetail.class)
|
|
|
|
|
.selectAll(WmsInstockDetail.class)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 关联表查询物料大类名称
|
|
|
|
|
.select(BaseMaterialCategory::getMaterialCategoryName)
|
|
|
|
|
.leftJoin(BaseMaterialCategory.class, BaseMaterialCategory::getMaterialCategoryId, WmsInstockDetail::getMaterialCategoryId)
|
|
|
|
|
|
|
|
|
|
.select(BaseMaterialInfo::getInspectionRequest)//质检要求(0必检,1免检)
|
|
|
|
|
//质检要求(0必检,1免检)
|
|
|
|
|
.select(BaseMaterialInfo::getInspectionRequest)
|
|
|
|
|
.leftJoin(BaseMaterialInfo.class, BaseMaterialInfo::getMaterialId, WmsInstockDetail::getMaterialId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getIsInspection()), WmsInstockDetail::getIsInspection, bo.getIsInspection())
|
|
|
|
|
.eq(bo.getInstockQty() != null, WmsInstockDetail::getInstockQty, bo.getInstockQty())
|
|
|
|
|
|
|
|
|
|
@ -120,6 +121,11 @@ public class WmsInstockDetailServiceImpl implements IWmsInstockDetailService {
|
|
|
|
|
.like(StringUtils.isNotBlank(bo.getUnitName()), WmsInstockDetail::getUnitName, bo.getUnitName())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getCodeYesNo()), WmsInstockDetail::getCodeYesNo, bo.getCodeYesNo())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getMaterialCategoryId()), WmsInstockDetail::getMaterialCategoryId, bo.getMaterialCategoryId())
|
|
|
|
|
//新增
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getInspectionRequest()), BaseMaterialInfo::getInspectionRequest, bo.getInspectionRequest())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getIsAgv()), WmsInstockDetail::getIsAgv, bo.getIsAgv())//agv
|
|
|
|
|
.eq(bo.getCompleteQty() != null, WmsInstockDetail::getCompleteQty, bo.getCompleteQty())//agv
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getAgvStatus()), WmsInstockDetail::getAgvStatus, bo.getAgvStatus())//agv
|
|
|
|
|
.orderByDesc(WmsInstockDetail::getCreateTime);
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
@ -230,70 +236,42 @@ public class WmsInstockDetailServiceImpl implements IWmsInstockDetailService {
|
|
|
|
|
String baseOrder = generateOrder(printSeq);
|
|
|
|
|
BigDecimal totalPackaged = BigDecimal.ZERO;
|
|
|
|
|
if (splitInt > 1) {
|
|
|
|
|
// 分包逻辑 - 支持平均分包和自定义分包两种模式
|
|
|
|
|
// 分包逻辑 - 统一处理模式
|
|
|
|
|
List<Integer> packageQtyList = bo.getPackageQtyList();
|
|
|
|
|
String packageMode = bo.getPackageMode();
|
|
|
|
|
|
|
|
|
|
// 默认为平均分包模式
|
|
|
|
|
if (packageMode == null) {
|
|
|
|
|
packageMode = "average";
|
|
|
|
|
|
|
|
|
|
// 验证分包数据
|
|
|
|
|
if (packageQtyList == null || packageQtyList.size() != splitInt) {
|
|
|
|
|
throw new ServiceException("分包数量列表与分包数量不匹配");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("custom".equals(packageMode) && packageQtyList != null && packageQtyList.size() == splitInt) {
|
|
|
|
|
// 自定义模式:使用用户指定的每包数量
|
|
|
|
|
BigDecimal totalCustomQty = packageQtyList.stream()
|
|
|
|
|
.map(BigDecimal::valueOf)
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
if (totalCustomQty.compareTo(remaining) > 0) {
|
|
|
|
|
throw new ServiceException("每包数量总计不能超过剩余数量");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= splitInt; i++) {
|
|
|
|
|
String order = baseOrder + String.format("%03d", i);
|
|
|
|
|
String batchCode = generateBatchCode(bo, bo.getBatchCode(), order);
|
|
|
|
|
|
|
|
|
|
BigDecimal currentPackageQty = BigDecimal.valueOf(packageQtyList.get(i - 1));
|
|
|
|
|
|
|
|
|
|
WmsInstockPrint print = new WmsInstockPrint();
|
|
|
|
|
BeanUtils.copyProperties(bo, print);
|
|
|
|
|
print.setBatchCode(batchCode);
|
|
|
|
|
print.setApportionQty(currentPackageQty);
|
|
|
|
|
print.setMaterialQty(1L); // 每个包打印1份
|
|
|
|
|
print.setInboundStatus("0"); // 入库状态(0-待入库,1-已入库,2-入库中)
|
|
|
|
|
|
|
|
|
|
wmsInstockPrintService.insertWmsInstockPrint(print);
|
|
|
|
|
|
|
|
|
|
totalPackaged = totalPackaged.add(currentPackageQty);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 平均分包模式(默认模式)或自定义模式但数据不完整
|
|
|
|
|
if ("average".equals(packageMode) || packageQtyList == null || packageQtyList.size() != splitInt) {
|
|
|
|
|
// 使用平均分包逻辑
|
|
|
|
|
if (remaining.compareTo(split) < 0 || remaining.remainder(split).compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
throw new ServiceException("无法平均分包,剩余数量不能被平均分配");
|
|
|
|
|
}
|
|
|
|
|
BigDecimal per = remaining.divide(split, 0, RoundingMode.DOWN);
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= splitInt; i++) {
|
|
|
|
|
String order = baseOrder + String.format("%03d", i);
|
|
|
|
|
String batchCode = generateBatchCode(bo, bo.getBatchCode(), order);
|
|
|
|
|
|
|
|
|
|
WmsInstockPrint print = new WmsInstockPrint();
|
|
|
|
|
BeanUtils.copyProperties(bo, print);
|
|
|
|
|
print.setBatchCode(batchCode);
|
|
|
|
|
print.setApportionQty(per);
|
|
|
|
|
print.setMaterialQty(1L); // 每个包打印1份
|
|
|
|
|
print.setInboundStatus("0"); // 入库状态(0-待入库,1-已入库,2-入库中)
|
|
|
|
|
|
|
|
|
|
wmsInstockPrintService.insertWmsInstockPrint(print);
|
|
|
|
|
|
|
|
|
|
totalPackaged = totalPackaged.add(per);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 使用自定义数量但数据验证失败
|
|
|
|
|
throw new ServiceException("自定义分包数量数据验证失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证每包数量总计是否等于入库数量
|
|
|
|
|
BigDecimal totalCustomQty = packageQtyList.stream()
|
|
|
|
|
.map(BigDecimal::valueOf)
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
if (totalCustomQty.compareTo(detail.getInstockQty()) != 0) {
|
|
|
|
|
throw new ServiceException("分包数量总计必须等于入库数量" + detail.getInstockQty() + ",当前总计:" + totalCustomQty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 遍历packageQtyList创建打印记录
|
|
|
|
|
for (int i = 1; i <= splitInt; i++) {
|
|
|
|
|
String order = baseOrder + String.format("%03d", i);
|
|
|
|
|
String batchCode = generateBatchCode(bo, bo.getBatchCode(), order);
|
|
|
|
|
|
|
|
|
|
BigDecimal currentPackageQty = BigDecimal.valueOf(packageQtyList.get(i - 1));
|
|
|
|
|
|
|
|
|
|
WmsInstockPrint print = new WmsInstockPrint();
|
|
|
|
|
BeanUtils.copyProperties(bo, print);
|
|
|
|
|
print.setBatchCode(batchCode);
|
|
|
|
|
print.setApportionQty(currentPackageQty);
|
|
|
|
|
print.setMaterialQty(1L); // 每个包打印1份
|
|
|
|
|
print.setInboundStatus("0"); // 入库状态(0-待入库,1-已入库,2-入库中)
|
|
|
|
|
print.setCreateBy(LoginHelper.getUsername());
|
|
|
|
|
print.setCreateTime(new Date());
|
|
|
|
|
|
|
|
|
|
wmsInstockPrintService.insertWmsInstockPrint(print);
|
|
|
|
|
|
|
|
|
|
totalPackaged = totalPackaged.add(currentPackageQty);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 重复打印逻辑(split == 1)
|
|
|
|
|
@ -371,4 +349,14 @@ public class WmsInstockDetailServiceImpl implements IWmsInstockDetailService {
|
|
|
|
|
// }
|
|
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 启动AGV
|
|
|
|
|
* @param bo
|
|
|
|
|
* @return boolean
|
|
|
|
|
* 暂时默认启动成功
|
|
|
|
|
*/
|
|
|
|
|
private Boolean actionAGV(WmsInstockDetailBo bo) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|