货位一键出库代码测试调整

main
judy 1 year ago
parent 154bbbab61
commit 2a3a304077
  1. 2
      shkj-wms/src/main/java/com/shkj/wms/domain/BusinDataTaskGoods.java
  2. 170
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java

@ -69,4 +69,6 @@ public class BusinDataTaskGoods implements Serializable {
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
private String createBy;
}

@ -514,91 +514,103 @@ public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, B
* 4.
*/
BaseLocationVo baseLocationVo = iBaseLocationService.queryLocationByCode(locationCode);
if (baseLocationVo == null){
return Result.err().msg("未查询到货位信息,请确认!"+locationCode);
}
if (baseLocationVo.getLocationStatus().equals("4") || baseLocationVo.getLocationStatus().equals("0")){
return Result.err().msg("此货位出库中或已出库,请确认!"+locationCode+" 库位状态:"+baseLocationVo.getLocationStatus());
}
List<SysStockDetailVo> sysStockDetailVoList =null;
//检查货位是否是双深位
Result<Boolean> booleanResult = checkIsSleep(baseLocationVo);
if (!Result.isOk(booleanResult)){
return booleanResult;
}
//确认出库的货位是否有库存信息
Result<List<SysStockDetailVo>> stockListResult = iSysStockDetailService.queryByLocation(baseLocationVo.getId());
if (Result.isOk(stockListResult)){
sysStockDetailVoList = stockListResult.getData();
if (sysStockDetailVoList == null && sysStockDetailVoList.size() ==0 ){
return Result.err().msg("此货位未查询到保险杠信息,请确认!"+locationCode);
try {
BaseLocationVo baseLocationVo = iBaseLocationService.queryLocationByCode(locationCode);
if (baseLocationVo == null){
return Result.err().msg("未查询到货位信息,请确认!"+locationCode);
}
if (baseLocationVo.getLocationStatus().equals("4") || baseLocationVo.getLocationStatus().equals("0")){
return Result.err().msg("此货位出库中或已出库,请确认!"+locationCode+" 库位状态:"+baseLocationVo.getLocationStatus());
}
List<SysStockDetailVo> sysStockDetailVoList =null;
//检查货位是否是双深位
Result<Boolean> booleanResult = checkIsSleep(baseLocationVo);
if (!Result.isOk(booleanResult)){
return booleanResult;
}
//确认出库的货位是否有库存信息
Result<List<SysStockDetailVo>> stockListResult = iSysStockDetailService.queryByLocation(baseLocationVo.getId());
if (Result.isOk(stockListResult)){
sysStockDetailVoList = stockListResult.getData();
if (sysStockDetailVoList == null && sysStockDetailVoList.size() ==0 ){
return Result.err().msg("此货位未查询到保险杠信息,请确认!"+locationCode);
}
}
}
//预占库存
baseLocationVo.setLocationStatus("4");
BaseLocation baseLocation = BeanUtil.toBean(baseLocationVo, BaseLocation.class);
iBaseLocationService.updateById(baseLocation);
//需要搬运到的码头信息
String toPoint = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.abnormal_out_point);
String[] toPoints = toPoint.split("、");
List<BasePoint> pointList = iBasePointService.list(new LambdaQueryWrapper<BasePoint>()
.in(BasePoint::getPointNo, toPoints)
.eq(BasePoint::getIsOccupy,"0")
);
String taskPath="";
if (pointList !=null && pointList.size()>0){
taskPath=pointList.get(0).getPointNo();
}
if (StringUtils.isEmpty(taskPath)){
return Result.err().msg("搬运码头无空闲,不可出库");
}
//生成作业任务
int index=0;
List<BusinDataTaskGoods> taskGoodsList = new ArrayList<>();
List<SysStockDetail> sysStockDetails = new ArrayList<>();
for (SysStockDetailVo sysStockDetailVo : sysStockDetailVoList) {
Long taskId=0L;
if(index ==0) {
BusinDataTask task = new BusinDataTask();
task.setTaskType(TaskTypeEnum.named_loc.getValue());
task.setPriority("2");
task.setIsTop("0");
task.setBatch(sysStockDetailVo.getBatch());
task.setTaskStatus(TaskStatusEnum.wait_put.getValue());
task.setIsUrgent("0");
task.setCreateTime(DateUtils.getNowDate());
task.setTaskPath(taskPath);
task.setDistinction("1");
task.setContainerId(sysStockDetailVo.getContainerCode());
task.setFromRow(baseLocationVo.getLocationRow());
task.setFromLayer(baseLocationVo.getLayer());
task.setFromColumn(baseLocationVo.getLocationColumn());
task.setTunnel(baseLocationVo.getTunnel());
businDataTaskMapper.insertBusinDataTask(task);
taskId = task.getId();
index++;
//需要搬运到的码头信息
String toPoint = sysParameterService.selectConfigByKey(ParameterConstants.ParameterSystem.abnormal_out_point);
String[] toPoints = toPoint.split("、");
List<BasePoint> pointList = iBasePointService.list(new LambdaQueryWrapper<BasePoint>()
.in(BasePoint::getPointNo, toPoints)
.eq(BasePoint::getIsOccupy,"0")
.eq(BasePoint::getIsActive,"1")
);
String taskPath="";
if (pointList !=null && pointList.size()==0){
return Result.err().msg("搬运码头无空闲,不可出库");
}
//保险杠信息
BusinDataTaskGoods taskGoods = new BusinDataTaskGoods();
taskGoods.setGoodsNo(sysStockDetailVo.getGoodsNo());
taskGoods.setTaskCode(taskId);
taskGoods.setIsPunching(sysStockDetailVo.getIsPuch());
taskGoods.setBranchId(SecurityUtils.getCurrentBranchId());
taskGoodsList.add(taskGoods);
BasePoint basePoint = pointList.get(0);
taskPath= basePoint.getPointNo();
//预占码头信息
basePoint.setIsOccupy("1");
iBasePointService.updateBasePoint(basePoint);
//预占库存
baseLocationVo.setLocationStatus("4");
BaseLocation baseLocation = BeanUtil.toBean(baseLocationVo, BaseLocation.class);
iBaseLocationService.updateById(baseLocation);
//生成作业任务
int index=0;
List<BusinDataTaskGoods> taskGoodsList = new ArrayList<>();
List<SysStockDetail> sysStockDetails = new ArrayList<>();
Long taskId=0L;
for (SysStockDetailVo sysStockDetailVo : sysStockDetailVoList) {
if(index ==0) {
BusinDataTask task = new BusinDataTask();
task.setTaskType(TaskTypeEnum.named_loc.getValue());
task.setPriority("2");
task.setIsTop("0");
task.setBatch(sysStockDetailVo.getBatch());
task.setTaskStatus(TaskStatusEnum.wait_put.getValue());
task.setIsUrgent("0");
task.setCreateTime(DateUtils.getNowDate());
task.setTaskPath(taskPath);
task.setDistinction("1");
task.setContainerId(sysStockDetailVo.getContainerCode());
task.setFromRow(baseLocationVo.getLocationRow());
task.setFromLayer(baseLocationVo.getLayer());
task.setFromColumn(baseLocationVo.getLocationColumn());
task.setTunnel(baseLocationVo.getTunnel());
task.setLocationId(baseLocationVo.getId());
this.save(task);
taskId = task.getId();
index++;
}
//出库预占
sysStockDetailVo.setOutQty(sysStockDetailVo.getQty().intValue());
SysStockDetail sysStockDetail = BeanUtil.toBean(sysStockDetailVo, SysStockDetail.class);
sysStockDetail.setOutTime(DateUtils.getNowDate());
sysStockDetails.add(sysStockDetail);
//保险杠信息
BusinDataTaskGoods taskGoods = new BusinDataTaskGoods();
taskGoods.setGoodsNo(sysStockDetailVo.getGoodsNo());
taskGoods.setQrCode(sysStockDetailVo.getQrCode());
taskGoods.setTaskCode(taskId);
taskGoods.setIsPunching(sysStockDetailVo.getIsPuch());
taskGoods.setBranchId(SecurityUtils.getCurrentBranchId());
taskGoods.setCreateBy(SecurityUtils.getUsername());
taskGoodsList.add(taskGoods);
//出库预占
sysStockDetailVo.setOutQty(sysStockDetailVo.getQty().intValue());
SysStockDetail sysStockDetail = BeanUtil.toBean(sysStockDetailVo, SysStockDetail.class);
sysStockDetail.setOutTime(DateUtils.getNowDate());
sysStockDetails.add(sysStockDetail);
}
iSysStockDetailService.updateBatchById(sysStockDetails);
return iBusinDataTaskGoodsService.saveBatch(taskGoodsList)?Result.ok():Result.err().msg("指定货位出库失败");
}catch (Exception e){
log.error("指定货位出库失败:"+e.getMessage());
return Result.err().msg("指定货位出库失败");
}
iSysStockDetailService.updateBatchById(sysStockDetails);
return iBusinDataTaskGoodsService.saveBatch(taskGoodsList)?Result.ok():Result.err().msg("指定货位出库失败");
}
@Override

Loading…
Cancel
Save