|
|
|
@ -604,11 +604,17 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
sysStockDetailService.removeByIds(detailList.stream().map(x -> x.getId()).collect(Collectors.toList())); |
|
|
|
sysStockDetailService.removeByIds(detailList.stream().map(x -> x.getId()).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
//堆垛机非自动完成状态后,把redis中的ID删除,代表此任务已经完成
|
|
|
|
//堆垛机非自动完成状态后,把redis中的ID删除,代表此任务已经完成
|
|
|
|
Object taskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOut); |
|
|
|
|
|
|
|
Long orderNo = updList.get(0).getOrderNo(); |
|
|
|
Long orderNo = updList.get(0).getOrderNo(); |
|
|
|
if (taskOutId !=null && String.valueOf(taskOutId).equals(orderNo.toString())){ |
|
|
|
Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); |
|
|
|
|
|
|
|
if (oneTaskOutId !=null && String.valueOf(oneTaskOutId).equals(orderNo.toString())){ |
|
|
|
log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo); |
|
|
|
log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo); |
|
|
|
redisTemplate.delete(RedisConstant.redisTaskOut); |
|
|
|
redisTemplate.delete(RedisConstant.redisTaskOutOne); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object twoTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutTwo); |
|
|
|
|
|
|
|
if (twoTaskOutId !=null && String.valueOf(twoTaskOutId).equals(orderNo.toString())){ |
|
|
|
|
|
|
|
log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo); |
|
|
|
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskOutTwo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//出库成功写入wcs异常点位为0
|
|
|
|
//出库成功写入wcs异常点位为0
|
|
|
|
@ -1013,20 +1019,12 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
if (container == null) { |
|
|
|
if (container == null) { |
|
|
|
return Result.err().msg("托盘不存在"); |
|
|
|
return Result.err().msg("托盘不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果没有指定计划类型 就默认是入库
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(planType)) { |
|
|
|
|
|
|
|
planType = PlanTypeEnum.IN.getValue(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//正在执行入库计划,如果有多个入库则取最新一次入库的;
|
|
|
|
//正在执行入库计划,如果有多个入库则取最新一次入库的;
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> eq = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
LambdaQueryWrapper<BusinOutInPlan> eq = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
.eq(BusinOutInPlan::getContainerCode, containerCode) |
|
|
|
.eq(BusinOutInPlan::getContainerCode, containerCode) |
|
|
|
.in(BusinOutInPlan::getPlanStatus,PlanStatusEnum.WAIT.getValue(),PlanStatusEnum.DOING.getValue()) |
|
|
|
.in(BusinOutInPlan::getPlanStatus,PlanStatusEnum.WAIT.getValue(),PlanStatusEnum.DOING.getValue()) |
|
|
|
//.eq(BusinOutInPlan::getPlanStatus, PlanStatusEnum.WAIT.getValue())
|
|
|
|
|
|
|
|
.in(BusinOutInPlan::getType,PlanTypeEnum.IN.getValue(),PlanTypeEnum.BACK.getValue(),PlanTypeEnum.INV_BACK.getValue(),PlanTypeEnum.EMPTY_IN.getValue()) |
|
|
|
.in(BusinOutInPlan::getType,PlanTypeEnum.IN.getValue(),PlanTypeEnum.BACK.getValue(),PlanTypeEnum.INV_BACK.getValue(),PlanTypeEnum.EMPTY_IN.getValue()) |
|
|
|
.orderByDesc(BusinOutInPlan::getCreateTime) |
|
|
|
.orderByDesc(BusinOutInPlan::getCreateTime) |
|
|
|
// .eq(BusinOutInPlan::getType, planType)
|
|
|
|
|
|
|
|
// .last("limit 1")
|
|
|
|
|
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
List<BusinOutInPlan> ones = this.list(eq); |
|
|
|
List<BusinOutInPlan> ones = this.list(eq); |
|
|
|
@ -1043,7 +1041,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
} |
|
|
|
} |
|
|
|
PlanOrderLocationVo vo = new PlanOrderLocationVo(); |
|
|
|
PlanOrderLocationVo vo = new PlanOrderLocationVo(); |
|
|
|
if (one.getType().equals(PlanTypeEnum.INV_BACK.getValue())){ |
|
|
|
if (one.getType().equals(PlanTypeEnum.INV_BACK.getValue())){ |
|
|
|
List<BusinStockInv> businStockInvs = iBusinStockInvService.queryStockInvList(one.getOrderNo().toString()); |
|
|
|
List<BusinStockInv> businStockInvs = iBusinStockInvService.queryStockInvList(one.getDirection().toString()); //存的盘点单号
|
|
|
|
long qtySum = businStockInvs.stream().mapToLong(x -> x.getQty().longValue()).sum(); |
|
|
|
long qtySum = businStockInvs.stream().mapToLong(x -> x.getQty().longValue()).sum(); |
|
|
|
long invQtySum = businStockInvs.stream().mapToLong(x -> x.getInvQty().longValue()).sum(); |
|
|
|
long invQtySum = businStockInvs.stream().mapToLong(x -> x.getInvQty().longValue()).sum(); |
|
|
|
if (qtySum == invQtySum && qtySum !=0 && qtySum !=0){ |
|
|
|
if (qtySum == invQtySum && qtySum !=0 && qtySum !=0){ |
|
|
|
@ -1122,25 +1120,16 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
|
|
// 根据当前的托盘查询库存数据
|
|
|
|
// 根据当前的托盘查询库存数据
|
|
|
|
List<SysStockDetail> detailList = redisCache.getCacheList(RedisLockConstants.containerCode + "_" + container.getContainerCode()); |
|
|
|
List<SysStockDetail> detailList = redisCache.getCacheList(RedisLockConstants.containerCode + "_" + container.getContainerCode()); |
|
|
|
// List<SysStockDetail> detailList = sysStockDetailService.getByContainerId(container.getId());
|
|
|
|
|
|
|
|
/*if (CollectionUtils.isEmpty(detailList)) { |
|
|
|
|
|
|
|
log.info("不需要处理数据了 = {}", container); |
|
|
|
|
|
|
|
isEmpty = true; |
|
|
|
|
|
|
|
//return Result.err().data(StringUtils.EMPTY);
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
//去掉库存为0的
|
|
|
|
//去掉库存为0的
|
|
|
|
List<SysStockDetail> newDetailList=null; |
|
|
|
List<SysStockDetail> newDetailList=null; |
|
|
|
if ( !CollectionUtils.isEmpty(detailList) ){ |
|
|
|
if ( !CollectionUtils.isEmpty(detailList) ){ |
|
|
|
newDetailList = detailList.stream().filter(x -> x.getQty().add(x.getInQty()).add(x.getOutQty()).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList()); |
|
|
|
newDetailList = detailList.stream().filter(x -> x.getQty().add(x.getInQty()).add(x.getOutQty()).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(newDetailList)) { |
|
|
|
if (CollectionUtils.isEmpty(newDetailList)) { |
|
|
|
isEmpty = true; |
|
|
|
isEmpty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("是否是空托盘了 = {}", isEmpty); |
|
|
|
log.info("是否是空托盘了 = {}", isEmpty); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BusinOutInPlan> inPlans = new ArrayList<>(); |
|
|
|
List<BusinOutInPlan> inPlans = new ArrayList<>(); |
|
|
|
Long no = IntIdUtil.generateIntId();; |
|
|
|
Long no = IntIdUtil.generateIntId();; |
|
|
|
|
|
|
|
|
|
|
|
@ -1166,11 +1155,6 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
if (CollectionUtils.isEmpty(inPlans)) { |
|
|
|
if (CollectionUtils.isEmpty(inPlans)) { |
|
|
|
//新增空托盘信息
|
|
|
|
//新增空托盘信息
|
|
|
|
BusinOutInPlan plan = initReturnPlan(container.getId(), container.getContainerCode(), no); |
|
|
|
BusinOutInPlan plan = initReturnPlan(container.getId(), container.getContainerCode(), no); |
|
|
|
//设置第一个模具即可 因为是空托盘了()TODO 需要测试
|
|
|
|
|
|
|
|
/* SysStockDetail stockDetail = detailList.get(0); |
|
|
|
|
|
|
|
plan.setMoldBarcode("") |
|
|
|
|
|
|
|
.setMoldId(stockDetail.getMoldId()) |
|
|
|
|
|
|
|
.setMoldNo(stockDetail.getMoldNo());*/ |
|
|
|
|
|
|
|
inPlans.add(plan); |
|
|
|
inPlans.add(plan); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1178,10 +1162,6 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
if (isEmpty) { |
|
|
|
if (isEmpty) { |
|
|
|
location = sysStockDetailService.findLocationByContainer(container.getContainerCode(), SecurityUtils.erpBranchId); |
|
|
|
location = sysStockDetailService.findLocationByContainer(container.getContainerCode(), SecurityUtils.erpBranchId); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//找货位
|
|
|
|
|
|
|
|
/*List<String> moldBarcodeList = newDetailList.stream().map(x -> x.getBarcode()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<BaseMold> baseMoldBarcodeList = baseMoldService.queryByMoldBarcodeList(moldBarcodeList);*/ |
|
|
|
|
|
|
|
//baseMoldBarcodeList 一定都有库存的
|
|
|
|
|
|
|
|
location = sysStockDetailService.findLocationByContainer(container.getContainerCode(),SecurityUtils.erpBranchId); |
|
|
|
location = sysStockDetailService.findLocationByContainer(container.getContainerCode(),SecurityUtils.erpBranchId); |
|
|
|
} |
|
|
|
} |
|
|
|
if (location == null) { |
|
|
|
if (location == null) { |
|
|
|
@ -1193,17 +1173,6 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
inPlans.forEach(x -> x.setLocationId(finalLocation.getId())); |
|
|
|
inPlans.forEach(x -> x.setLocationId(finalLocation.getId())); |
|
|
|
this.saveBatch(inPlans); |
|
|
|
this.saveBatch(inPlans); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//老数据需要清空 新货位先预占然后在实际回库的时候进行更新
|
|
|
|
|
|
|
|
// sysStockDetailService.removeByIds(detailList.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
// detailList.forEach(detail -> {
|
|
|
|
|
|
|
|
// detail.setQty(BigDecimal.ZERO)
|
|
|
|
|
|
|
|
// .setInQty(BigDecimal.ZERO)
|
|
|
|
|
|
|
|
// .setOutQty(BigDecimal.ZERO)
|
|
|
|
|
|
|
|
// .setContainerId(0L)
|
|
|
|
|
|
|
|
// .setContainerCode("-");
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// sysStockDetailService.updateBatchById(detailList);
|
|
|
|
|
|
|
|
//增加预库存
|
|
|
|
//增加预库存
|
|
|
|
if (!isEmpty) { |
|
|
|
if (!isEmpty) { |
|
|
|
sysStockDetailService.addStockByIn(inPlans, location, false); |
|
|
|
sysStockDetailService.addStockByIn(inPlans, location, false); |
|
|
|
|