|
|
|
|
@ -135,17 +135,21 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
throw new RuntimeException("入库业务处理中,请稍后再试"); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
log.info("请求入库的参数{}",bo); |
|
|
|
|
log.info("请求入库的参数{}", bo); |
|
|
|
|
String containerCode = bo.getContainerCode(); |
|
|
|
|
//判断添加的托盘是否有未完成的入库记录
|
|
|
|
|
if (StringUtils.isBlank(containerCode)) { |
|
|
|
|
return Result.err().msg("托盘编码不得为空"); |
|
|
|
|
} |
|
|
|
|
//判断添加的托盘是否有未完成的入库记录,如果有直接取消
|
|
|
|
|
BusinOutInPlan businOutInPlan = this.getOrderByContainerCode(containerCode, PlanTypeEnum.IN.getValue()); |
|
|
|
|
if (businOutInPlan!=null){ |
|
|
|
|
return Result.err().msg("此托盘存在相关未完成入库任务单据:"+businOutInPlan.getOrderNo()); |
|
|
|
|
if (businOutInPlan != null) { |
|
|
|
|
businOutInPlan.setPlanStatus(PlanStatusEnum.CANCEL.getValue()); |
|
|
|
|
this.updateById(businOutInPlan); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BusinOutInPlan businOutInPlanOut = this.getOrderByContainerCode(containerCode, PlanTypeEnum.OUT.getValue()); |
|
|
|
|
if (businOutInPlanOut!=null){ |
|
|
|
|
return Result.err().msg("此托盘存在相关未完成的出库任务单据:"+businOutInPlan.getOrderNo()); |
|
|
|
|
if (businOutInPlanOut != null) { |
|
|
|
|
return Result.err().msg("此托盘存在相关未完成的出库任务单据:" + businOutInPlan.getOrderNo()); |
|
|
|
|
} |
|
|
|
|
BaseContainer container = baseContainerService.queryContainerByCode(containerCode); |
|
|
|
|
if (container == null) { |
|
|
|
|
@ -154,7 +158,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
String containerType = container.getContainerType(); |
|
|
|
|
String moldType = bo.getMoldType(); |
|
|
|
|
|
|
|
|
|
if (!containerType.equals(moldType)){ |
|
|
|
|
if (!containerType.equals(moldType)) { |
|
|
|
|
return Result.err().msg("模具类型同托盘类型不匹配"); |
|
|
|
|
} |
|
|
|
|
//模具类型是高模具,不能放到托盘类型是低托盘类型的托盘上
|
|
|
|
|
@ -172,14 +176,15 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
return Result.err().msg("条码不存在,请重新扫描"); |
|
|
|
|
} |
|
|
|
|
//计算托盘上的模具是否超出标准数量
|
|
|
|
|
Double targetPoint = Double.valueOf(isysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.moldDieWeight)); |
|
|
|
|
double sumWeight = baseMoldBarcodeList.stream().mapToDouble(x -> x.getWeight()==null ?0:x.getWeight()).sum(); |
|
|
|
|
if (sumWeight>targetPoint){ |
|
|
|
|
Double targetPoint = Double.valueOf(isysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.moldDieWeight)); |
|
|
|
|
double sumWeight = baseMoldBarcodeList.stream().mapToDouble(x -> x.getWeight() == null ? 0 : x.getWeight()).sum(); |
|
|
|
|
if (sumWeight > targetPoint) { |
|
|
|
|
return Result.err().msg("模具重量超出标准重量"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<BusinOutInPlan> inPlans = new ArrayList<>(); |
|
|
|
|
Long no = IntIdUtil.generateIntId();; |
|
|
|
|
Long no = IntIdUtil.generateIntId(); |
|
|
|
|
; |
|
|
|
|
for (String moldBarcode : moldBarcodeList) { |
|
|
|
|
BaseMold barcode = baseMoldBarcodeList.stream().filter(x -> x.getBarCode().equals(moldBarcode)).findFirst().orElse(null); |
|
|
|
|
if (barcode == null) { |
|
|
|
|
@ -211,7 +216,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//找货位
|
|
|
|
|
StockDetailLocationVo location = sysStockDetailService.findLocationByContainer(container.getContainerCode(), SecurityUtils.erpBranchId); |
|
|
|
|
StockDetailLocationVo location = sysStockDetailService.findLocationByContainer(container.getContainerCode(), SecurityUtils.erpBranchId); |
|
|
|
|
if (location == null) { |
|
|
|
|
return Result.err().msg("没有可入库的货位"); |
|
|
|
|
} |
|
|
|
|
@ -233,9 +238,9 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
redisCache.deleteObject(RedisLockConstants.containerCode + "_" + bo.getContainerCode()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
return Result.err().msg("模具库入库异常,"+e.getMessage()); |
|
|
|
|
}finally { |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return Result.err().msg("模具库入库异常," + e.getMessage()); |
|
|
|
|
} finally { |
|
|
|
|
//释放锁
|
|
|
|
|
lockTemplate.releaseLock(lockInfo); |
|
|
|
|
} |
|
|
|
|
@ -245,22 +250,27 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取托盘是否有未完成的入库任务 |
|
|
|
|
* @param containerCode |
|
|
|
|
* |
|
|
|
|
* @param containerCode |
|
|
|
|
* @param planType |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private BusinOutInPlan getOrderByContainerCode(String containerCode, String planType){ |
|
|
|
|
private BusinOutInPlan getOrderByContainerCode(String containerCode, String planType) { |
|
|
|
|
|
|
|
|
|
// 如果没有指定计划类型 就默认是入库
|
|
|
|
|
if (StringUtils.isBlank(planType)) { |
|
|
|
|
planType = PlanTypeEnum.IN.getValue(); |
|
|
|
|
} |
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> wq = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
.eq(BusinOutInPlan::getContainerCode, containerCode) |
|
|
|
|
.eq(BusinOutInPlan::getType, planType) |
|
|
|
|
.notIn(BusinOutInPlan::getPlanStatus,PlanStatusEnum.FINISH.getValue(),PlanStatusEnum.CANCEL.getValue()) |
|
|
|
|
.orderByDesc(BusinOutInPlan::getCreateTime) |
|
|
|
|
.last("limit 1"); |
|
|
|
|
// 如果没有指定计划类型 就默认是入库
|
|
|
|
|
if (StringUtils.isBlank(planType)) { |
|
|
|
|
planType = PlanTypeEnum.IN.getValue(); |
|
|
|
|
} |
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> wq = new LambdaQueryWrapper<BusinOutInPlan>(); |
|
|
|
|
wq.eq(BusinOutInPlan::getContainerCode, containerCode); |
|
|
|
|
if (planType.equals(PlanTypeEnum.IN.getValue())) { |
|
|
|
|
wq.in(BusinOutInPlan::getType, planType, PlanTypeEnum.BACK.getValue()); |
|
|
|
|
} else { |
|
|
|
|
wq.eq(BusinOutInPlan::getType, planType); |
|
|
|
|
} |
|
|
|
|
wq.notIn(BusinOutInPlan::getPlanStatus, PlanStatusEnum.FINISH.getValue(), PlanStatusEnum.CANCEL.getValue()); |
|
|
|
|
wq.orderByDesc(BusinOutInPlan::getCreateTime); |
|
|
|
|
wq.last("limit 1"); |
|
|
|
|
BusinOutInPlan one = this.getOne(wq); |
|
|
|
|
return one; |
|
|
|
|
} |
|
|
|
|
@ -270,7 +280,8 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
public Result<Boolean> addInPlanByEmpty(List<BusinInPlanEmptyAddBo> bos) { |
|
|
|
|
List<BusinOutInPlan> inPlans = new ArrayList<>(); |
|
|
|
|
for (BusinInPlanEmptyAddBo bo : bos) { |
|
|
|
|
Long orderNo = IntIdUtil.generateIntId();; |
|
|
|
|
Long orderNo = IntIdUtil.generateIntId(); |
|
|
|
|
; |
|
|
|
|
BusinOutInPlan inPlan = new BusinOutInPlan(); |
|
|
|
|
inPlan.setOrderNo(orderNo); |
|
|
|
|
inPlan.setContainerId(bo.getContainerId()); |
|
|
|
|
@ -279,13 +290,13 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
inPlan.setPlanStatus(PlanStatusEnum.WAIT.getValue()); |
|
|
|
|
inPlan.setQty(BigDecimal.ZERO); |
|
|
|
|
inPlan.setBranchId(3L); |
|
|
|
|
StockDetailLocationVo location = sysStockDetailService.findLocationByContainer(bo.getContainerCode(), SecurityUtils.erpBranchId); |
|
|
|
|
StockDetailLocationVo location = sysStockDetailService.findLocationByContainer(bo.getContainerCode(), SecurityUtils.erpBranchId); |
|
|
|
|
inPlan.setLocationId(location.getId()); |
|
|
|
|
inPlan.setLayer(1); |
|
|
|
|
inPlans.add(inPlan); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return this.saveBatch(inPlans)?Result.ok():Result.err().msg("空托入库失败"); |
|
|
|
|
return this.saveBatch(inPlans) ? Result.ok() : Result.err().msg("空托入库失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -302,18 +313,19 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//验证计划出库的条码是否已存在计划
|
|
|
|
|
List<BusinOutInPlan> businOutInPlans = queryByMoldBarcodeList(moldBarcodeList,PlanTypeEnum.INPLAN.getValue()); |
|
|
|
|
List<BusinOutInPlan> businOutInPlans = queryByMoldBarcodeList(moldBarcodeList, PlanTypeEnum.INPLAN.getValue()); |
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
if(businOutInPlans.size()>0){ |
|
|
|
|
if (businOutInPlans.size() > 0) { |
|
|
|
|
for (BusinOutInPlan businOutInPlan : businOutInPlans) { |
|
|
|
|
sb.append(businOutInPlan.getMoldNo()); |
|
|
|
|
sb.append("/"); |
|
|
|
|
} |
|
|
|
|
return Result.err().msg(sb.substring(0,sb.length()-1)+"已存在入库计划"); |
|
|
|
|
return Result.err().msg(sb.substring(0, sb.length() - 1) + "已存在入库计划"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<BusinOutInPlan> inPlans = new ArrayList<>(); |
|
|
|
|
Long no = IntIdUtil.generateIntId();; |
|
|
|
|
Long no = IntIdUtil.generateIntId(); |
|
|
|
|
; |
|
|
|
|
for (String moldBarcode : moldBarcodeList) { |
|
|
|
|
BaseMold barcode = baseMoldBarcodeList.stream().filter(x -> x.getBarCode().equals(moldBarcode)).findFirst().orElse(null); |
|
|
|
|
if (barcode == null) { |
|
|
|
|
@ -331,7 +343,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
inPlan.setPlanTime(bo.getPlanTime()); |
|
|
|
|
inPlans.add(inPlan); |
|
|
|
|
} |
|
|
|
|
return this.saveOrUpdateBatch(inPlans)?Result.ok():Result.err(); |
|
|
|
|
return this.saveOrUpdateBatch(inPlans) ? Result.ok() : Result.err(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -345,22 +357,22 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
@Override |
|
|
|
|
public Result<Boolean> callEmptyContainer() { |
|
|
|
|
return null; |
|
|
|
|
// return callEmptyLocationNotContainerCode(null);
|
|
|
|
|
// return callEmptyLocationNotContainerCode(null);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Result<Boolean> callEmptyContainerByQty(BaseContainerCallBo bo) { |
|
|
|
|
//如果呼叫指定的托盘,先判断是否已有未执行的任务
|
|
|
|
|
if (bo.getContainerCode() != null){ |
|
|
|
|
if (bo.getContainerCode() != null) { |
|
|
|
|
BusinOutInPlan businOutInPlan = this.getOrderByContainerCode(bo.getContainerCode(), PlanTypeEnum.CALL.getValue()); |
|
|
|
|
if (businOutInPlan != null ){ |
|
|
|
|
if (businOutInPlan != null) { |
|
|
|
|
return Result.err().msg("此托盘已呼叫,等待出库"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
StockDetailMoldVo vo = sysStockDetailService.findLocationNotContainerCode(bo); |
|
|
|
|
if (vo == null) { |
|
|
|
|
return Result.err().msg("没有可容纳所需数量的托盘:"+bo.getModlQty()); |
|
|
|
|
return Result.err().msg("没有可容纳所需数量的托盘:" + bo.getModlQty()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -369,7 +381,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
//更新货位库存状态为预占
|
|
|
|
|
List<SysStockDetail> sysStockDetails = sysStockDetailService.getByContainerId(containerId); |
|
|
|
|
if (sysStockDetails !=null && sysStockDetails.size()>0){ |
|
|
|
|
if (sysStockDetails != null && sysStockDetails.size() > 0) { |
|
|
|
|
for (SysStockDetail sysStockDetail : sysStockDetails) { |
|
|
|
|
sysStockDetail.setOutQty(new BigDecimal("-1")); |
|
|
|
|
sysStockDetailService.updateById(sysStockDetail); |
|
|
|
|
@ -379,7 +391,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
Long orderNo = IntIdUtil.generateIntId(); |
|
|
|
|
//新增呼叫空托盘单据,BusinOutInPlan
|
|
|
|
|
BusinOutInPlan businOutInPlan = initCallPlan(containerId, containerCode, orderNo,bo.getModlQty()); |
|
|
|
|
BusinOutInPlan businOutInPlan = initCallPlan(containerId, containerCode, orderNo, bo.getModlQty()); |
|
|
|
|
businOutInPlan.setLocationId(vo.getId()); |
|
|
|
|
businOutInPlan.setDetailId(vo.getId()); |
|
|
|
|
businOutInPlan.setLayer(bo.getLayer()); |
|
|
|
|
@ -393,7 +405,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
detailVo.setOrderNo(orderNo); |
|
|
|
|
detailVo.setBranchId(vo.getBranchId()); |
|
|
|
|
//给堆垛机下命令
|
|
|
|
|
Result result = wmsCallWcsUtil.callOutStock(detailVo,bo.getLayer()); |
|
|
|
|
Result result = wmsCallWcsUtil.callOutStock(detailVo, bo.getLayer()); |
|
|
|
|
if (Result.isOk(result)) { |
|
|
|
|
//正常更新单据状态为:出库中
|
|
|
|
|
businOutInPlan.setPlanStatus(PlanStatusEnum.DOING.getValue()); |
|
|
|
|
@ -402,7 +414,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
//更新当前出库的托盘状态为,空托出库中
|
|
|
|
|
// BaseContainer baseContainer = baseContainerService.getById(containerId);
|
|
|
|
|
// baseContainer.setStatus(ContainerStausEnum.CALL.getValue());
|
|
|
|
|
return this.save(businOutInPlan)?Result.ok():Result.err(); |
|
|
|
|
return this.save(businOutInPlan) ? Result.ok() : Result.err(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -446,7 +458,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//重新找高货位
|
|
|
|
|
StockDetailLocationVo location = sysStockDetailService.findLocationByContainer(list.get(0).getContainerCode(), list.get(0).getBranchId()); |
|
|
|
|
StockDetailLocationVo location = sysStockDetailService.findLocationByContainer(list.get(0).getContainerCode(), list.get(0).getBranchId()); |
|
|
|
|
if (location == null) { |
|
|
|
|
return Result.err().msg("没有可入库的货位"); |
|
|
|
|
} |
|
|
|
|
@ -494,7 +506,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("入库失败清理的信息{}",list); |
|
|
|
|
log.info("入库失败清理的信息{}", list); |
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> wrapper = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
.eq(BusinOutInPlan::getOrderNo, orderNo) |
|
|
|
|
.last("limit 1"); |
|
|
|
|
@ -504,17 +516,16 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
if ((one.getType().equals(PlanTypeEnum.BACK.getValue()) && StringUtils.isNotEmpty(one.getMoldNo())) |
|
|
|
|
|| one.getType().equals(PlanTypeEnum.IN.getValue()) |
|
|
|
|
|| one.getType().equals(PlanTypeEnum.INV_BACK.getValue())){ |
|
|
|
|
|| one.getType().equals(PlanTypeEnum.INV_BACK.getValue())) { |
|
|
|
|
List<SysStockDetail> sysStockDetails = sysStockDetailService.getByContainerId(containerId); |
|
|
|
|
boolean b = sysStockDetailService.removeByIds(sysStockDetails.stream().map(x -> x.getId()).collect(Collectors.toList())); |
|
|
|
|
if (b){ |
|
|
|
|
log.info("清理预占入库库存成功{}",sysStockDetails); |
|
|
|
|
}else { |
|
|
|
|
log.info("清理预占入库库存失败{}",sysStockDetails); |
|
|
|
|
if (b) { |
|
|
|
|
log.info("清理预占入库库存成功{}", sysStockDetails); |
|
|
|
|
} else { |
|
|
|
|
log.info("清理预占入库库存失败{}", sysStockDetails); |
|
|
|
|
} |
|
|
|
|
return b; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -533,7 +544,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
if (null == lockInfo) { |
|
|
|
|
throw new RuntimeException("业务处理中,请稍后再试"); |
|
|
|
|
} |
|
|
|
|
Integer layer=0; |
|
|
|
|
Integer layer = 0; |
|
|
|
|
try { |
|
|
|
|
List<BusinOutInPlan> updList = new ArrayList<>(); |
|
|
|
|
for (BusinOutPlanConfirmBo bo : bos) { |
|
|
|
|
@ -548,12 +559,12 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
if (!plan.getPlanStatus().equals(PlanStatusEnum.DOING.getValue())) { |
|
|
|
|
return Result.err().msg("出库计划状态异常"); |
|
|
|
|
} |
|
|
|
|
layer=plan.getLayer(); |
|
|
|
|
layer = plan.getLayer(); |
|
|
|
|
plan.setPlanStatus(PlanStatusEnum.FINISH.getValue()); |
|
|
|
|
updList.add(plan); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("要删除的库存明细:"+JsonUtil.toJSONString(updList)); |
|
|
|
|
log.info("要删除的库存明细:" + JsonUtil.toJSONString(updList)); |
|
|
|
|
|
|
|
|
|
//如果存在相同的托盘中的有待出库的任务 就需要更新为执行中
|
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> in = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
@ -562,20 +573,20 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
.in(BusinOutInPlan::getContainerId, updList.stream().map(x -> x.getContainerId()).collect(Collectors.toList())); |
|
|
|
|
List<BusinOutInPlan> list = list(in); |
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
|
log.info("此托盘有待执行的任务{}",list); |
|
|
|
|
log.info("此托盘有待执行的任务{}", list); |
|
|
|
|
list.forEach(x -> x.setPlanStatus(PlanStatusEnum.DOING.getValue())); |
|
|
|
|
this.updateBatchById(list); |
|
|
|
|
|
|
|
|
|
//把待执行的任务状态改为成功
|
|
|
|
|
LambdaQueryWrapper<SysThirdExceptionRequest> ster = new LambdaQueryWrapper<SysThirdExceptionRequest>() |
|
|
|
|
.eq(SysThirdExceptionRequest::getStatus, ThirdApiStatusEnum.fail.getValue()) |
|
|
|
|
.in(SysThirdExceptionRequest::getCode, list.stream().map(x -> x.getOrderNo()).collect(Collectors.toList())); |
|
|
|
|
.eq(SysThirdExceptionRequest::getStatus, ThirdApiStatusEnum.fail.getValue()) |
|
|
|
|
.in(SysThirdExceptionRequest::getCode, list.stream().map(x -> x.getOrderNo()).collect(Collectors.toList())); |
|
|
|
|
List<SysThirdExceptionRequest> sterList = sysThirdExceptionRequestService.list(ster); |
|
|
|
|
if (CollectionUtils.isNotEmpty(sterList)){ |
|
|
|
|
if (CollectionUtils.isNotEmpty(sterList)) { |
|
|
|
|
//待执行的任务信息
|
|
|
|
|
log.info("待执行的任务信息{}",sterList); |
|
|
|
|
sterList.forEach(x ->x.setStatus(ThirdApiStatusEnum.success.getValue())); |
|
|
|
|
sysThirdExceptionRequestService.updateBatchById(sterList); |
|
|
|
|
log.info("待执行的任务信息{}", sterList); |
|
|
|
|
sterList.forEach(x -> x.setStatus(ThirdApiStatusEnum.success.getValue())); |
|
|
|
|
sysThirdExceptionRequestService.updateBatchById(sterList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.updateBatchById(updList); |
|
|
|
|
@ -588,9 +599,9 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
List<BusinOutInPlan> containerTask = list(new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
.eq(BusinOutInPlan::getType, PlanTypeEnum.OUT.getValue()) |
|
|
|
|
.notIn(BusinOutInPlan::getPlanStatus, PlanStatusEnum.FINISH.getValue(),PlanStatusEnum.CANCEL.getValue()) |
|
|
|
|
.notIn(BusinOutInPlan::getPlanStatus, PlanStatusEnum.FINISH.getValue(), PlanStatusEnum.CANCEL.getValue()) |
|
|
|
|
.eq(BusinOutInPlan::getContainerId, entry.getKey())); |
|
|
|
|
log.info("未完成的托盘任务信息{}",containerTask); |
|
|
|
|
log.info("未完成的托盘任务信息{}", containerTask); |
|
|
|
|
String containerCode = entry.getValue().get(0).getContainerCode(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(containerTask)) { |
|
|
|
|
log.info("托盘还有任务没有完成 = {}", containerCode); |
|
|
|
|
@ -608,14 +619,14 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
//堆垛机非自动完成状态后,把redis中的ID删除,代表此任务已经完成
|
|
|
|
|
Long orderNo = updList.get(0).getOrderNo(); |
|
|
|
|
Object oneTaskOutId = redisTemplate.opsForValue().get(RedisConstant.redisTaskOutOne); |
|
|
|
|
if (oneTaskOutId !=null && String.valueOf(oneTaskOutId).equals(orderNo.toString())){ |
|
|
|
|
log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo); |
|
|
|
|
if (oneTaskOutId != null && String.valueOf(oneTaskOutId).equals(orderNo.toString())) { |
|
|
|
|
log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:", orderNo); |
|
|
|
|
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); |
|
|
|
|
if (twoTaskOutId != null && String.valueOf(twoTaskOutId).equals(orderNo.toString())) { |
|
|
|
|
log.info("出库完成时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:", orderNo); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskOutTwo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -623,27 +634,27 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
outEliminateAlarms(layer); |
|
|
|
|
Long containerId = updList.get(0).getContainerId(); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisOutBound + containerId); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.info("出库确认异常 手动回滚 {}", bos+e.getMessage()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.info("出库确认异常 手动回滚 {}", bos + e.getMessage()); |
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
}finally { |
|
|
|
|
} finally { |
|
|
|
|
lockTemplate.releaseLock(lockInfo); |
|
|
|
|
} |
|
|
|
|
return Result.ok(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void outEliminateAlarms(Integer layer){ |
|
|
|
|
Long plcId =51L; |
|
|
|
|
public void outEliminateAlarms(Integer layer) { |
|
|
|
|
Long plcId = 51L; |
|
|
|
|
PlcOperate plcOperate_dps = plcInit.getPlcOperate_dps(); |
|
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
|
List<WcsPlcProperty> propertyList = (List<WcsPlcProperty>) redisTemplate.opsForValue().get(RedisConstant.redisPlcProperty + plcId); |
|
|
|
|
if (propertyList == null || propertyList.size() == 0) { |
|
|
|
|
propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(plcId); |
|
|
|
|
} |
|
|
|
|
if (propertyList !=null && propertyList.size()>0){ |
|
|
|
|
String oneWcsErrExit = "", twoWcsErrExit = "",oneWcsExitOutExit="",twoWcsExitOutExit=""; |
|
|
|
|
String oneWcsErrExitVt = "", twoWcsErrExitVt = "",oneWcsExitOutExitVt="",twoWcsExitOutExitVt=""; |
|
|
|
|
if (propertyList != null && propertyList.size() > 0) { |
|
|
|
|
String oneWcsErrExit = "", twoWcsErrExit = "", oneWcsExitOutExit = "", twoWcsExitOutExit = ""; |
|
|
|
|
String oneWcsErrExitVt = "", twoWcsErrExitVt = "", oneWcsExitOutExitVt = "", twoWcsExitOutExitVt = ""; |
|
|
|
|
for (WcsPlcProperty plcProperty : propertyList) { |
|
|
|
|
String pointType = plcProperty.getPointType(); |
|
|
|
|
//请求分配
|
|
|
|
|
@ -655,13 +666,13 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
twoWcsErrExitVt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("oneExitOut")) { |
|
|
|
|
oneWcsExitOutExit = plcProperty.getAddress(); |
|
|
|
|
oneWcsExitOutExitVt= plcProperty.getValueType(); |
|
|
|
|
oneWcsExitOutExitVt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("twoExitOut")) { |
|
|
|
|
twoWcsExitOutExit = plcProperty.getAddress(); |
|
|
|
|
twoWcsExitOutExitVt = plcProperty.getValueType(); |
|
|
|
|
} |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
if (layer ==1){ |
|
|
|
|
if (layer == 1) { |
|
|
|
|
//出库拣货尚未拣货时写入异常给plc
|
|
|
|
|
Map<String, Integer> oneWcsErrExitMap = new HashMap<>(1); |
|
|
|
|
oneWcsErrExitMap.put(oneWcsErrExitVt, 0); |
|
|
|
|
@ -677,7 +688,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
} else { |
|
|
|
|
log.info("1楼出库确认后消除报警信息,写入点位失败{}", allMap); |
|
|
|
|
} |
|
|
|
|
}else if (layer == 2){ |
|
|
|
|
} else if (layer == 2) { |
|
|
|
|
//2楼出库尚未拣货时,写入异常给plc
|
|
|
|
|
Map<String, Integer> twoWcsErrExitMap = new HashMap<>(1); |
|
|
|
|
twoWcsErrExitMap.put(twoWcsErrExitVt, 0); |
|
|
|
|
@ -733,12 +744,12 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
//选择的物料是否存在正在执行的出库任务,排除已完成和作废的
|
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> outWrapper = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
.eq(BusinOutInPlan::getType, PlanTypeEnum.OUT.getValue()) |
|
|
|
|
.eq(BusinOutInPlan::getMoldBarcode,moldBarcode) |
|
|
|
|
.notIn(BusinOutInPlan::getPlanStatus,PlanStatusEnum.FINISH.getValue(),PlanStatusEnum.CANCEL.getValue()) |
|
|
|
|
.eq(BusinOutInPlan::getMoldBarcode, moldBarcode) |
|
|
|
|
.notIn(BusinOutInPlan::getPlanStatus, PlanStatusEnum.FINISH.getValue(), PlanStatusEnum.CANCEL.getValue()) |
|
|
|
|
.last("limit 1"); |
|
|
|
|
BusinOutInPlan one = this.getOne(outWrapper); |
|
|
|
|
if (one != null){ |
|
|
|
|
return Result.err().msg("Outbound in progress, no need to issue outbound task:"+one.getMoldNo()); |
|
|
|
|
if (one != null) { |
|
|
|
|
return Result.err().msg("Outbound in progress, no need to issue outbound task:" + one.getMoldNo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BusinOutInPlan outPlan = new BusinOutInPlan(); |
|
|
|
|
@ -762,8 +773,8 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
containerId = data.getContainerId(); |
|
|
|
|
Integer layer = (Integer) redisTemplate.opsForValue().get(RedisConstant.redisOutBound + containerId); |
|
|
|
|
if (layer != null) { |
|
|
|
|
if(!bo.getLayer().equals(layer)){ |
|
|
|
|
return Result.err().msg("此托盘已存在"+layer+"层的出库任务!"); |
|
|
|
|
if (!bo.getLayer().equals(layer)) { |
|
|
|
|
return Result.err().msg("此托盘已存在" + layer + "层的出库任务!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
outPlan.setLocationId(data.getLocationId()); |
|
|
|
|
@ -782,15 +793,16 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
} |
|
|
|
|
Map<Long, List<BusinOutInPlan>> listMap = outPlans.stream().collect(Collectors.groupingBy(BusinOutInPlan::getLocationId)); |
|
|
|
|
for (Map.Entry<Long, List<BusinOutInPlan>> entry : listMap.entrySet()) { |
|
|
|
|
Long orderNo = IntIdUtil.generateIntId();; |
|
|
|
|
Long orderNo = IntIdUtil.generateIntId(); |
|
|
|
|
; |
|
|
|
|
entry.getValue().forEach(x -> x.setOrderNo(orderNo)); |
|
|
|
|
} |
|
|
|
|
this.saveBatch(outPlans); |
|
|
|
|
|
|
|
|
|
Integer index = 0; |
|
|
|
|
for (Map.Entry<Long, List<BusinOutInPlan>> entry : listMap.entrySet()) { |
|
|
|
|
// Long orderNo = IntIdUtil.generateIntId();;
|
|
|
|
|
// entry.getValue().forEach(x -> x.setOrderNo(orderNo));
|
|
|
|
|
// Long orderNo = IntIdUtil.generateIntId();;
|
|
|
|
|
// entry.getValue().forEach(x -> x.setOrderNo(orderNo));
|
|
|
|
|
|
|
|
|
|
SysStockDetailVo vo = stockDetailVos.stream().filter(x -> x.getLocationId().equals(entry.getKey())).findFirst().orElse(null); |
|
|
|
|
OutStockDetailVo detailVo = new OutStockDetailVo(); |
|
|
|
|
@ -805,7 +817,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
log.info("开始调用wcs下发任务 = {}", detailVo); |
|
|
|
|
//由于堆垛机只能执行一个任务、所以这里只能第一个任务下发、其他的任务进行轮询
|
|
|
|
|
if (index.equals(0)) { |
|
|
|
|
Result result = wmsCallWcsUtil.outStock(detailVo, true,bo.getLayer()); |
|
|
|
|
Result result = wmsCallWcsUtil.outStock(detailVo, true, bo.getLayer()); |
|
|
|
|
if (!Result.isOk(result)) { |
|
|
|
|
entry.getValue().forEach(x -> x.setPlanStatus(PlanStatusEnum.WAIT.getValue())); |
|
|
|
|
} else { |
|
|
|
|
@ -821,7 +833,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
} |
|
|
|
|
this.updateBatchById(outPlans); |
|
|
|
|
//存入redis
|
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisOutBound + containerId,bo.getLayer()); |
|
|
|
|
redisTemplate.opsForValue().set(RedisConstant.redisOutBound + containerId, bo.getLayer()); |
|
|
|
|
} finally { |
|
|
|
|
//释放锁
|
|
|
|
|
lockTemplate.releaseLock(lockInfo); |
|
|
|
|
@ -840,20 +852,20 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//验证计划入库的条码是否已存在计划
|
|
|
|
|
List<BusinOutInPlan> businOutInPlans = queryByMoldBarcodeList(moldBarcodeList,PlanTypeEnum.OUTPLAN.getValue()); |
|
|
|
|
List<BusinOutInPlan> businOutInPlans = queryByMoldBarcodeList(moldBarcodeList, PlanTypeEnum.OUTPLAN.getValue()); |
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
if(businOutInPlans.size()>0){ |
|
|
|
|
if (businOutInPlans.size() > 0) { |
|
|
|
|
for (BusinOutInPlan businOutInPlan : businOutInPlans) { |
|
|
|
|
sb.append(businOutInPlan.getMoldNo()); |
|
|
|
|
sb.append("/"); |
|
|
|
|
} |
|
|
|
|
return Result.err().msg(sb.substring(0,sb.length()-1)+"已存在出库计划"); |
|
|
|
|
return Result.err().msg(sb.substring(0, sb.length() - 1) + "已存在出库计划"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//根据所做的出库模具,查询模具所在的托盘,根据所在的托盘生成不同的单据
|
|
|
|
|
List<SysStockDetail> sysStockDetails = sysStockDetailService.queryByMoldBarcodeLocationList(moldBarcodeList); |
|
|
|
|
|
|
|
|
|
Long oldLocationId =0L; |
|
|
|
|
Long oldLocationId = 0L; |
|
|
|
|
List<BusinOutInPlan> outPlans = new ArrayList<>(); |
|
|
|
|
Long orderNo = 0L; |
|
|
|
|
for (SysStockDetail sysStockDetail : sysStockDetails) { |
|
|
|
|
@ -874,8 +886,8 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
outPlan.setPlanStatus(PlanStatusEnum.WAIT.getValue()); |
|
|
|
|
outPlan.setLayer(bo.getLayer()); |
|
|
|
|
|
|
|
|
|
if (!oldLocationId.equals(locationId)){ |
|
|
|
|
orderNo=IntIdUtil.generateIntId(); |
|
|
|
|
if (!oldLocationId.equals(locationId)) { |
|
|
|
|
orderNo = IntIdUtil.generateIntId(); |
|
|
|
|
BaseLocation baseLocation = baseLocationService.getById(locationId); |
|
|
|
|
STKMoveBo moveBo = new STKMoveBo(); |
|
|
|
|
moveBo.setTaskId(orderNo); |
|
|
|
|
@ -883,18 +895,18 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
moveBo.setFromColumn(baseLocation.getLocationColumn()); |
|
|
|
|
moveBo.setFromLayer(baseLocation.getLayer()); |
|
|
|
|
thirdExceptionRequestService.addException(orderNo.toString(), ThirdApiTypeEnum.wcsOutTask, JSONObject.toJSONString(moveBo), |
|
|
|
|
"出库计划", false,bo.getPlanTime(),bo.getLayer()); |
|
|
|
|
"出库计划", false, bo.getPlanTime(), bo.getLayer()); |
|
|
|
|
} |
|
|
|
|
outPlan.setOrderNo(orderNo); |
|
|
|
|
outPlans.add(outPlan); |
|
|
|
|
oldLocationId=locationId; |
|
|
|
|
oldLocationId = locationId; |
|
|
|
|
|
|
|
|
|
sysStockDetailService.subtractStockByOut(outPlan, sysStockDetail.getId(), false); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
this.saveBatch(outPlans); |
|
|
|
|
} catch (Exception e){ |
|
|
|
|
log.error("新增出库计划失败:"+e.getMessage()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("新增出库计划失败:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
return Result.ok(); |
|
|
|
|
} |
|
|
|
|
@ -953,17 +965,17 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
// 预占库存取消
|
|
|
|
|
LambdaQueryWrapper<SysStockDetail> wrapper = new LambdaQueryWrapper<SysStockDetail>().eq(SysStockDetail::getBarcode, one.getMoldBarcode()) |
|
|
|
|
.eq(SysStockDetail::getLocationId,one.getLocationId()) |
|
|
|
|
.eq(SysStockDetail::getContainerId,one.getContainerId()); |
|
|
|
|
.eq(SysStockDetail::getLocationId, one.getLocationId()) |
|
|
|
|
.eq(SysStockDetail::getContainerId, one.getContainerId()); |
|
|
|
|
SysStockDetail sysStockDetail = sysStockDetailService.getOne(wrapper); |
|
|
|
|
boolean b = true; |
|
|
|
|
if(sysStockDetail != null){ |
|
|
|
|
if (sysStockDetail != null) { |
|
|
|
|
b = sysStockDetailService.removeById(sysStockDetail.getId()); |
|
|
|
|
} |
|
|
|
|
if (b){ |
|
|
|
|
log.info("入库取消,删除预占库存成功"+JsonUtil.toJSONString(sysStockDetail)); |
|
|
|
|
}else { |
|
|
|
|
log.info("入库取消,删除预占库存失败"+JsonUtil.toJSONString(sysStockDetail)); |
|
|
|
|
if (b) { |
|
|
|
|
log.info("入库取消,删除预占库存成功" + JsonUtil.toJSONString(sysStockDetail)); |
|
|
|
|
} else { |
|
|
|
|
log.info("入库取消,删除预占库存失败" + JsonUtil.toJSONString(sysStockDetail)); |
|
|
|
|
} |
|
|
|
|
return Result.ok(); |
|
|
|
|
} |
|
|
|
|
@ -973,7 +985,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public Result<Boolean> outCancel(Long id) { |
|
|
|
|
BusinOutInPlan one = getById(id); |
|
|
|
|
log.info("取消出库计划数据{}",one); |
|
|
|
|
log.info("取消出库计划数据{}", one); |
|
|
|
|
if (one == null) { |
|
|
|
|
return Result.err().msg("计划不存在"); |
|
|
|
|
} |
|
|
|
|
@ -986,32 +998,32 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
// 预占库存取消
|
|
|
|
|
LambdaQueryWrapper<SysStockDetail> wrapper = new LambdaQueryWrapper<SysStockDetail>() |
|
|
|
|
.eq(SysStockDetail::getBarcode, one.getMoldBarcode()) |
|
|
|
|
.eq(SysStockDetail::getLocationId,one.getLocationId()) |
|
|
|
|
.eq(SysStockDetail::getContainerId,one.getContainerId()); |
|
|
|
|
.eq(SysStockDetail::getLocationId, one.getLocationId()) |
|
|
|
|
.eq(SysStockDetail::getContainerId, one.getContainerId()); |
|
|
|
|
SysStockDetail sysStockDetail = sysStockDetailService.getOne(wrapper); |
|
|
|
|
sysStockDetail.setOutQty(BigDecimal.ZERO); |
|
|
|
|
log.info("取消出库预占库存信息{}",sysStockDetail); |
|
|
|
|
log.info("取消出库预占库存信息{}", sysStockDetail); |
|
|
|
|
|
|
|
|
|
boolean b = sysStockDetailService.updateById(sysStockDetail); |
|
|
|
|
if (b){ |
|
|
|
|
log.info("出库取消,更新预占库存成功"+JsonUtil.toJSONString(sysStockDetail)); |
|
|
|
|
}else { |
|
|
|
|
log.info("出库取消,更新预占库存失败"+JsonUtil.toJSONString(sysStockDetail)); |
|
|
|
|
if (b) { |
|
|
|
|
log.info("出库取消,更新预占库存成功" + JsonUtil.toJSONString(sysStockDetail)); |
|
|
|
|
} else { |
|
|
|
|
log.info("出库取消,更新预占库存失败" + JsonUtil.toJSONString(sysStockDetail)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//判断整个出库任务是否还有模具,如果没有,则把定时的数据改为成功
|
|
|
|
|
Long orderNo = one.getOrderNo(); |
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> planWrapper = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
.eq(BusinOutInPlan::getOrderNo,orderNo); |
|
|
|
|
.eq(BusinOutInPlan::getOrderNo, orderNo); |
|
|
|
|
List<BusinOutInPlan> list = this.list(planWrapper); |
|
|
|
|
log.info("要取消的出库任务{}",list); |
|
|
|
|
log.info("要取消的出库任务{}", list); |
|
|
|
|
List<BusinOutInPlan> collect = list.stream().filter(x -> !x.getPlanStatus().equals(PlanStatusEnum.CANCEL.getValue())).collect(Collectors.toList()); |
|
|
|
|
log.info("要取消的任务,过滤掉已取消的{}",collect); |
|
|
|
|
log.info("要取消的任务,过滤掉已取消的{}", collect); |
|
|
|
|
//整个单子都是取消状态,则把定时任务给取消掉
|
|
|
|
|
if (collect !=null && collect.size() ==0){ |
|
|
|
|
if (collect != null && collect.size() == 0) { |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<SysThirdExceptionRequest> sysWrapper = new LambdaQueryWrapper<SysThirdExceptionRequest>() |
|
|
|
|
.eq(SysThirdExceptionRequest::getCode,orderNo); |
|
|
|
|
.eq(SysThirdExceptionRequest::getCode, orderNo); |
|
|
|
|
SysThirdExceptionRequest requestServiceOne = sysThirdExceptionRequestService.getOne(sysWrapper); |
|
|
|
|
requestServiceOne.setStatus(ThirdApiStatusEnum.success.getValue()); |
|
|
|
|
requestServiceOne.setResponseBody("出库计划全部取消"); |
|
|
|
|
@ -1039,10 +1051,9 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
//正在执行入库计划,如果有多个入库则取最新一次入库的;
|
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> eq = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
.eq(BusinOutInPlan::getContainerCode, containerCode) |
|
|
|
|
.in(BusinOutInPlan::getPlanStatus,PlanStatusEnum.WAIT.getValue(),PlanStatusEnum.DOING.getValue()) |
|
|
|
|
.in(BusinOutInPlan::getType,PlanTypeEnum.IN.getValue(),PlanTypeEnum.BACK.getValue(),PlanTypeEnum.INV_BACK.getValue(),PlanTypeEnum.EMPTY_IN.getValue()) |
|
|
|
|
.orderByDesc(BusinOutInPlan::getCreateTime) |
|
|
|
|
; |
|
|
|
|
.in(BusinOutInPlan::getPlanStatus, PlanStatusEnum.WAIT.getValue(), PlanStatusEnum.DOING.getValue()) |
|
|
|
|
.in(BusinOutInPlan::getType, PlanTypeEnum.IN.getValue(), PlanTypeEnum.BACK.getValue(), PlanTypeEnum.INV_BACK.getValue(), PlanTypeEnum.EMPTY_IN.getValue()) |
|
|
|
|
.orderByDesc(BusinOutInPlan::getCreateTime); |
|
|
|
|
|
|
|
|
|
List<BusinOutInPlan> ones = this.list(eq); |
|
|
|
|
//如果没有查到相关任务,则新增入库计划
|
|
|
|
|
@ -1057,20 +1068,20 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
return Result.err().msg("货位不存在"); |
|
|
|
|
} |
|
|
|
|
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.getDirection().toString()); //存的盘点单号
|
|
|
|
|
long qtySum = businStockInvs.stream().mapToLong(x -> x.getQty().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) { |
|
|
|
|
vo.setType(location.getType()); |
|
|
|
|
}else if (qtySum != invQtySum && invQtySum ==0){ |
|
|
|
|
} else if (qtySum != invQtySum && invQtySum == 0) { |
|
|
|
|
vo.setType(LocationPlanTypeEnum.EMPTY.getValue()); |
|
|
|
|
}else if (qtySum != invQtySum && invQtySum !=0){ |
|
|
|
|
} else if (qtySum != invQtySum && invQtySum != 0) { |
|
|
|
|
vo.setType(location.getType()); |
|
|
|
|
}else if(qtySum ==invQtySum && qtySum==0 && qtySum ==0){ |
|
|
|
|
} else if (qtySum == invQtySum && qtySum == 0 && qtySum == 0) { |
|
|
|
|
vo.setType(LocationPlanTypeEnum.EMPTY.getValue()); |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
BigDecimal qty = ones.stream().map(x -> x.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
vo.setType(qty.compareTo(BigDecimal.ZERO) == 0 ? LocationPlanTypeEnum.EMPTY.getValue() : location.getType()); |
|
|
|
|
} |
|
|
|
|
@ -1125,11 +1136,11 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
//判断是否有已出库未完成的单据,状态:已完成,类型等于出库
|
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> eq = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
.eq(BusinOutInPlan::getContainerId, container.getId()) |
|
|
|
|
.notIn(BusinOutInPlan::getPlanStatus,PlanStatusEnum.FINISH.getValue(),PlanStatusEnum.CANCEL.getValue()) |
|
|
|
|
.notIn(BusinOutInPlan::getPlanStatus, PlanStatusEnum.FINISH.getValue(), PlanStatusEnum.CANCEL.getValue()) |
|
|
|
|
.eq(BusinOutInPlan::getType, PlanTypeEnum.OUT.getValue()); |
|
|
|
|
List<BusinOutInPlan> list = list(eq); |
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
|
log.info("存在对应的任务没有拣货完成 {}",list); |
|
|
|
|
log.info("存在对应的任务没有拣货完成 {}", list); |
|
|
|
|
return Result.err().msg("存在对应的任务没有拣货完成"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1138,8 +1149,8 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
// 根据当前的托盘查询库存数据
|
|
|
|
|
List<SysStockDetail> detailList = redisCache.getCacheList(RedisLockConstants.containerCode + "_" + container.getContainerCode()); |
|
|
|
|
//去掉库存为0的
|
|
|
|
|
List<SysStockDetail> newDetailList=null; |
|
|
|
|
if ( !CollectionUtils.isEmpty(detailList) ){ |
|
|
|
|
List<SysStockDetail> newDetailList = null; |
|
|
|
|
if (!CollectionUtils.isEmpty(detailList)) { |
|
|
|
|
newDetailList = detailList.stream().filter(x -> x.getQty().add(x.getInQty()).add(x.getOutQty()).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
if (CollectionUtils.isEmpty(newDetailList)) { |
|
|
|
|
@ -1148,10 +1159,11 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
log.info("是否是空托盘了 = {}", isEmpty); |
|
|
|
|
|
|
|
|
|
List<BusinOutInPlan> inPlans = new ArrayList<>(); |
|
|
|
|
Long no = IntIdUtil.generateIntId();; |
|
|
|
|
Long no = IntIdUtil.generateIntId(); |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
//托盘内的数据重新入库
|
|
|
|
|
if ( !CollectionUtils.isEmpty(detailList) ) { |
|
|
|
|
if (!CollectionUtils.isEmpty(detailList)) { |
|
|
|
|
for (SysStockDetail stockDetail : newDetailList) { |
|
|
|
|
BusinOutInPlan inPlan = new BusinOutInPlan(); |
|
|
|
|
inPlan.setOrderNo(no); |
|
|
|
|
@ -1179,7 +1191,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
if (isEmpty) { |
|
|
|
|
location = sysStockDetailService.findLocationByContainer(container.getContainerCode(), SecurityUtils.erpBranchId); |
|
|
|
|
} else { |
|
|
|
|
location = sysStockDetailService.findLocationByContainer(container.getContainerCode(),SecurityUtils.erpBranchId); |
|
|
|
|
location = sysStockDetailService.findLocationByContainer(container.getContainerCode(), SecurityUtils.erpBranchId); |
|
|
|
|
} |
|
|
|
|
if (location == null) { |
|
|
|
|
return Result.err().msg("没有可入库的货位"); |
|
|
|
|
@ -1208,7 +1220,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private BusinOutInPlan initCallPlan(Long containerId, String containerCode, Long no,String moldQty) { |
|
|
|
|
private BusinOutInPlan initCallPlan(Long containerId, String containerCode, Long no, String moldQty) { |
|
|
|
|
//空托盘
|
|
|
|
|
BusinOutInPlan inPlan = new BusinOutInPlan(); |
|
|
|
|
inPlan.setOrderNo(no); |
|
|
|
|
@ -1216,8 +1228,8 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
inPlan.setContainerCode(containerCode); |
|
|
|
|
inPlan.setType(PlanTypeEnum.CALL.getValue()); |
|
|
|
|
inPlan.setPlanStatus(PlanStatusEnum.WAIT.getValue()); |
|
|
|
|
if(StringUtils.isEmpty(moldQty)){ |
|
|
|
|
moldQty="1"; |
|
|
|
|
if (StringUtils.isEmpty(moldQty)) { |
|
|
|
|
moldQty = "1"; |
|
|
|
|
} |
|
|
|
|
inPlan.setQty(BigDecimal.valueOf(Double.valueOf(moldQty))); |
|
|
|
|
inPlan.setBranchId(SecurityUtils.getCurrentBranchId()); |
|
|
|
|
@ -1246,7 +1258,7 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Result<Boolean> wcsActualAddStock(WcsAddStockCallbackBo bo) { |
|
|
|
|
log.info("实际添加库存 参数 = {}",bo); |
|
|
|
|
log.info("实际添加库存 参数 = {}", bo); |
|
|
|
|
|
|
|
|
|
//获取订单,状态出入库中
|
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> wrapper = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
@ -1297,24 +1309,24 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
log.info("托盘中的模具信息,未过滤之前的:" + sysStockDetails); |
|
|
|
|
|
|
|
|
|
List<SysStockDetail> collect = sysStockDetails.stream().filter(x -> x.getMoldId() != null).collect(Collectors.toList()); |
|
|
|
|
log.info("过滤掉模具编号为空的数据存入Redis中"+collect); |
|
|
|
|
log.info("过滤掉模具编号为空的数据存入Redis中" + collect); |
|
|
|
|
|
|
|
|
|
if(collect.size()>0) { |
|
|
|
|
if (collect.size() > 0) { |
|
|
|
|
redisCache.setCacheList(RedisLockConstants.containerCode + "_" + data.getContainerCode(), sysStockDetails); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sysStockDetails.size() > 0) { |
|
|
|
|
for (SysStockDetail sysStockDetail : sysStockDetails) { |
|
|
|
|
log.info("获取的库存明细Id:"+sysStockDetail.getId()); |
|
|
|
|
log.info("获取的库存明细Id:" + sysStockDetail.getId()); |
|
|
|
|
boolean b = sysStockDetailService.removeById(sysStockDetail.getId()); |
|
|
|
|
if (b){ |
|
|
|
|
log.info("托盘出库清理成功"+sysStockDetail.getContainerCode()); |
|
|
|
|
if (b) { |
|
|
|
|
log.info("托盘出库清理成功" + sysStockDetail.getContainerCode()); |
|
|
|
|
//空托出库时,把货位状态改为空闲
|
|
|
|
|
baseLocationVo.setLocationStatus(LocationStausEnum.FREE.getValue()); |
|
|
|
|
baseLocationService.updateById(baseLocationVo); |
|
|
|
|
}else { |
|
|
|
|
log.info("托盘出库清理失败"+sysStockDetail.getContainerCode()); |
|
|
|
|
} else { |
|
|
|
|
log.info("托盘出库清理失败" + sysStockDetail.getContainerCode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -1327,15 +1339,15 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
|
|
|
|
|
//更新库位状态:计算库位上的模具数量是否满位,半位
|
|
|
|
|
//返回结果为,可容纳模具数量-已放模具数量只差,等于0:满位;不等于6 3 则是半位
|
|
|
|
|
log.info("需要处理的库位信息ID:"+locationId); |
|
|
|
|
String locationStatus="0"; |
|
|
|
|
log.info("需要处理的库位信息ID:" + locationId); |
|
|
|
|
String locationStatus = "0"; |
|
|
|
|
|
|
|
|
|
Integer locationMoldQty = sysStockDetailService.getLocationMoldQty(locationId); |
|
|
|
|
if (locationMoldQty ==null){ |
|
|
|
|
if (locationMoldQty == null) { |
|
|
|
|
//空托盘
|
|
|
|
|
locationStatus=LocationStausEnum.EMPTY.getValue(); |
|
|
|
|
}else { |
|
|
|
|
locationStatus=LocationStausEnum.STOCK.getValue(); |
|
|
|
|
locationStatus = LocationStausEnum.EMPTY.getValue(); |
|
|
|
|
} else { |
|
|
|
|
locationStatus = LocationStausEnum.STOCK.getValue(); |
|
|
|
|
// if (locationMoldQty==0){
|
|
|
|
|
// locationStatus=LocationStausEnum.FULL.getValue();
|
|
|
|
|
// }else if (locationMoldQty !=6 || locationMoldQty !=3){
|
|
|
|
|
@ -1404,19 +1416,19 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
return Result.err().msg("任务已经完成或者不存在该任务"); |
|
|
|
|
} |
|
|
|
|
BusinOutInPlan businOutInPlan = list.get(0); |
|
|
|
|
if (businOutInPlan.getType().equals(PlanTypeEnum.OUT.getValue())){ |
|
|
|
|
if (businOutInPlan.getType().equals(PlanTypeEnum.OUT.getValue())) { |
|
|
|
|
log.info("获取的是出库任务,不需要更新状态"); |
|
|
|
|
return Result.err().msg("获取的是出库任务,不需要更新状态"); |
|
|
|
|
return Result.err().msg("获取的是出库任务,不需要更新状态"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//取消入库时,如果已给堆垛机下发任务,则删除redis信息
|
|
|
|
|
// redisCache.deleteObject(RedisConstant.redisReqWare + orderNo);
|
|
|
|
|
if (planStatus.equals(PlanStatusEnum.CANCEL.getValue())){ |
|
|
|
|
redisTemplate.delete(RedisConstant.redisContainer+orderNo); |
|
|
|
|
// redisCache.deleteObject(RedisConstant.redisReqWare + orderNo);
|
|
|
|
|
if (planStatus.equals(PlanStatusEnum.CANCEL.getValue())) { |
|
|
|
|
redisTemplate.delete(RedisConstant.redisContainer + orderNo); |
|
|
|
|
//堆垛机非自动完成状态后,把redis中的ID删除,代表此任务已经完成
|
|
|
|
|
Object taskInId = redisTemplate.opsForValue().get(RedisConstant.redisTaskIn); |
|
|
|
|
if (taskInId !=null && String.valueOf(taskInId).equals(orderNo.toString())){ |
|
|
|
|
log.info("手动处理入库时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:",orderNo); |
|
|
|
|
if (taskInId != null && String.valueOf(taskInId).equals(orderNo.toString())) { |
|
|
|
|
log.info("手动处理入库时判断redis中的数据是否还存在,存在则删除,删除redis中的出库任务状态记录:", orderNo); |
|
|
|
|
redisTemplate.delete(RedisConstant.redisTaskIn); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -1474,16 +1486,13 @@ public class BusinOutInPlanServiceImpl extends ServiceImpl<BusinOutInPlanMapper, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<BusinOutInPlan> queryByMoldBarcodeList(List<String> moldBarcodeList,String planType) { |
|
|
|
|
public List<BusinOutInPlan> queryByMoldBarcodeList(List<String> moldBarcodeList, String planType) { |
|
|
|
|
LambdaQueryWrapper<BusinOutInPlan> wrapper = new LambdaQueryWrapper<BusinOutInPlan>() |
|
|
|
|
.in(BusinOutInPlan::getMoldBarcode, moldBarcodeList) |
|
|
|
|
.eq(BusinOutInPlan::getType,planType) |
|
|
|
|
.eq(BusinOutInPlan::getPlanStatus,PlanStatusEnum.WAIT.getValue()); |
|
|
|
|
.eq(BusinOutInPlan::getType, planType) |
|
|
|
|
.eq(BusinOutInPlan::getPlanStatus, PlanStatusEnum.WAIT.getValue()); |
|
|
|
|
return this.list(wrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|