|
|
|
|
@ -25,16 +25,20 @@ |
|
|
|
|
*/ |
|
|
|
|
package org.springblade.desk.logistics.service.impl; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.desk.logistics.pojo.entity.Location; |
|
|
|
|
import org.springblade.desk.logistics.pojo.entity.Station; |
|
|
|
|
import org.springblade.desk.logistics.pojo.entity.Task; |
|
|
|
|
import org.springblade.desk.logistics.pojo.entity .WeighData; |
|
|
|
|
import org.springblade.desk.logistics.service.IPipelineService; |
|
|
|
|
import org.springblade.desk.logistics.service.IStationService; |
|
|
|
|
import org.springblade.desk.logistics.service.ITaskService; |
|
|
|
|
import org.springblade.desk.logistics.service.*; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 工艺能力表 服务实现类 |
|
|
|
|
@ -52,6 +56,12 @@ public class PipelineServiceImpl implements IPipelineService { |
|
|
|
|
@Autowired |
|
|
|
|
IStationService stationService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
ILocationService locationService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
IOrderBoxService orderBoxService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean verifyConveyorBoxWeighing(String boxBarcode, BigDecimal actualWeight, BigDecimal ratedWeight, Integer returnStatus) { |
|
|
|
|
|
|
|
|
|
@ -60,7 +70,11 @@ public class PipelineServiceImpl implements IPipelineService { |
|
|
|
|
// 2. 保存称重数据
|
|
|
|
|
taskService.savePipelineWeigh(boxBarcode,actualWeight, Task.STATUS_RETURNED); |
|
|
|
|
|
|
|
|
|
// todo 3.超重处理,解绑
|
|
|
|
|
// 3.超重处理,解绑
|
|
|
|
|
R ret = orderBoxService.boxOrderUnbind(boxBarcode); |
|
|
|
|
if(!ret.isSuccess()){ |
|
|
|
|
throw new ServiceException("解绑失败: "+boxBarcode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
@ -88,25 +102,121 @@ public class PipelineServiceImpl implements IPipelineService { |
|
|
|
|
return task.getWeight(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean receiveBoxArriveConveyorEnd(String boxBarcode) { |
|
|
|
|
// 1. 基础校验
|
|
|
|
|
Task task = taskService.getBoxBarcode(boxBarcode); |
|
|
|
|
if (null == task) { |
|
|
|
|
throw new ServiceException("查询不到该物料箱: " + boxBarcode); |
|
|
|
|
} |
|
|
|
|
if(null == task.getStationId()){ |
|
|
|
|
throw new ServiceException("查询不到站点信息: "+boxBarcode); |
|
|
|
|
|
|
|
|
|
// 2. 判断站点是否有预占(是否站点没满)
|
|
|
|
|
if (null != task.getStationId()) { |
|
|
|
|
// 站点没满,有预占 - 送往指定站点
|
|
|
|
|
return handlePreOccupiedStation(boxBarcode, task.getStationId()); |
|
|
|
|
} else { |
|
|
|
|
// 站点已满,无预占 - 需要找空闲站点或库位
|
|
|
|
|
return handleNoPreOccupiedStation(task); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询站点 判断站点是否为空闲
|
|
|
|
|
Station station = stationService.getById(task.getStationId()); |
|
|
|
|
/** |
|
|
|
|
* 处理有预占的情况(站点没满)- 直接送往指定站点 |
|
|
|
|
*/ |
|
|
|
|
private boolean handlePreOccupiedStation(String boxBarcode, Long stationId) { |
|
|
|
|
Station station = stationService.getById(stationId); |
|
|
|
|
if (null == station) { |
|
|
|
|
log.error("预占站点不存在:{}", stationId); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//证明预占用
|
|
|
|
|
if(Station.PRE_STATUS_OCCUPIED.equals(station.getStationStatus())){ |
|
|
|
|
// 校验站点状态是否为预占用
|
|
|
|
|
if (!Station.PRE_STATUS_OCCUPIED.equals(station.getStationStatus())) { |
|
|
|
|
log.error("站点状态不是预占用,无法送往:{}", station.getStationCode()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("站点有预占,将物料箱送往指定站点:{}", station.getStationCode()); |
|
|
|
|
// TODO 查询站点位置并调用AGV小车送往站点
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理无预占的情况(站点已满)- 找空闲站点或库位 |
|
|
|
|
* @param task |
|
|
|
|
*/ |
|
|
|
|
private boolean handleNoPreOccupiedStation(Task task) { |
|
|
|
|
// 查找空闲站点
|
|
|
|
|
Long wcId = task.getWcId(); |
|
|
|
|
|
|
|
|
|
if (null != wcId) { |
|
|
|
|
// 尝试找空闲站点
|
|
|
|
|
String freeStationCode = findFreeStationCode(wcId); |
|
|
|
|
if (null != freeStationCode) { |
|
|
|
|
log.info("找到空闲站点:{},将物料箱送往该站点", freeStationCode); |
|
|
|
|
// TODO 调用AGV小车送往空闲站点
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 没有空闲站点,走库位逻辑
|
|
|
|
|
log.info("无空闲站点,尝试将物料箱移入库位"); |
|
|
|
|
return handleLocationLogic(task.getBoxBarcode()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查找空闲站点编码 |
|
|
|
|
*/ |
|
|
|
|
private String findFreeStationCode(Long wcId) { |
|
|
|
|
List<Station> stationList = stationService.selectByWcId(wcId); |
|
|
|
|
if (CollectionUtils.isEmpty(stationList)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 过滤出状态为空闲的站点
|
|
|
|
|
List<Station> freeStations = stationList.stream() |
|
|
|
|
.filter(sn -> sn.getStationStatus().equals(Station.STATUS_FREE)) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(freeStations)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return freeStations.get(0).getStationCode(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理库位逻辑 |
|
|
|
|
*/ |
|
|
|
|
private boolean handleLocationLogic(String boxBarcode) { |
|
|
|
|
// 1. 查询空闲库位
|
|
|
|
|
List<Location> freeLocations = locationService.selectByLocationStatus(Location.STATUS_FREE); |
|
|
|
|
if (CollectionUtils.isEmpty(freeLocations)) { |
|
|
|
|
log.warn("没有空闲库位可用,物料箱:{}", boxBarcode); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
String targetLocationCode = freeLocations.get(0).getLocationCode(); |
|
|
|
|
log.info("找到空闲库位:{}", targetLocationCode); |
|
|
|
|
|
|
|
|
|
// 2. 查询库位梳齿架子
|
|
|
|
|
List<Location> combLocations = locationService.selectByStatus(1); |
|
|
|
|
if (CollectionUtils.isEmpty(combLocations)) { |
|
|
|
|
log.warn("没有可用的库位梳齿架子,物料箱:{}", boxBarcode); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
String combLocationCode = combLocations.get(0).getLocationCode(); |
|
|
|
|
log.info("找到库位梳齿架子:{}", combLocationCode); |
|
|
|
|
|
|
|
|
|
// 3. 两步操作
|
|
|
|
|
log.info("第一步:AGV将物料箱从输送线放入梳齿架子:{}", combLocationCode); |
|
|
|
|
// TODO 调用AGV小车 将输送线物资放入梳齿架子
|
|
|
|
|
|
|
|
|
|
log.info("第二步:CTU将物料箱从梳齿架子送往库位:{}", targetLocationCode); |
|
|
|
|
// TODO 调用CTU 将梳齿架子物资放入库位
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|