代码更新:
1.增加任务下发时的逻辑 2.修改or().eq的写法
This commit is contained in:
parent
ebb2dd3b72
commit
061ef4050e
|
|
@ -7,6 +7,7 @@ public enum ConfigMapKeyEnum {
|
|||
URL_WCS_PICK_TASK("URL_WCS_PICK_TASK"),
|
||||
URL_WCS_E_TASK("URL_WCS_E_TASK"),
|
||||
URL_WCS_DISPOSE_VEHICLE("URL_WCS_DISPOSE_VEHICLE"),
|
||||
CREATE_WORK("CREATE_WORK"),
|
||||
START_WORK("START_WORK"),
|
||||
SEND_TASK("SEND_TASK"),
|
||||
MAX_VEHICLE_NUMS("MAX_VEHICLE_NUMS"),
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ public class JobComponent {
|
|||
@Scheduled(fixedDelay = 2000)
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
public void createWork() {
|
||||
String startWork = configMap.get(ConfigMapKeyEnum.START_WORK.getConfigKey());
|
||||
if (StringUtils.isEmpty(startWork) || !startWork.equals("1")) {
|
||||
String createWork = configMap.get(ConfigMapKeyEnum.CREATE_WORK.getConfigKey());
|
||||
if (StringUtils.isEmpty(createWork) || !createWork.equals("1")) {
|
||||
return;
|
||||
}
|
||||
// 轮询工作站台,判断是否需要下发任务
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class StockController {
|
|||
for (Stock stock : stocks) {
|
||||
sumNum = sumNum.add(stock.getGoodsRelated().getRemainNum());
|
||||
}
|
||||
// 没有库存
|
||||
// 设定数量
|
||||
stockVo.setRemainNum(sumNum);
|
||||
logger.info("物料{}无库存", stockQuery.getGoodsId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1178,8 +1178,7 @@ public class TaskController {
|
|||
GoodsToStation goodsToStation = goodsToStationService.getOne(new LambdaQueryWrapper<GoodsToStation>()
|
||||
.eq(GoodsToStation::getWorkStation, workFlow.getWorkStation())
|
||||
.eq(GoodsToStation::getGoodsId, workFlow.getGoodsId())
|
||||
.eq(GoodsToStation::getDistributeStatus, 0)
|
||||
.or().eq(GoodsToStation::getDistributeStatus, 1)
|
||||
.lt(GoodsToStation::getDistributeStatus, 2)
|
||||
.last("limit 1"));
|
||||
if (goodsToStation != null) {
|
||||
// 更新站台要料数量
|
||||
|
|
|
|||
|
|
@ -1,10 +1,73 @@
|
|||
package com.wms.entity.app.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class StockUpdateRecordQuery extends PageQuery {
|
||||
|
||||
/**
|
||||
* 记录编号
|
||||
*/
|
||||
@JsonProperty("recordId")
|
||||
private String recordId;
|
||||
/**
|
||||
* 库存编号
|
||||
*/
|
||||
@JsonProperty("stockId")
|
||||
private String stockId;
|
||||
/**
|
||||
* 料箱编号
|
||||
*/
|
||||
@JsonProperty("vehicleId")
|
||||
private String vehicleId;
|
||||
/**
|
||||
* 料号
|
||||
*/
|
||||
@JsonProperty("goodsId")
|
||||
private String goodsId;
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@JsonProperty("goodsName")
|
||||
private String goodsName;
|
||||
/**
|
||||
* 原来库位
|
||||
*/
|
||||
@JsonProperty("locationBefore")
|
||||
private String locationBefore;
|
||||
/**
|
||||
* 后来库位
|
||||
*/
|
||||
@JsonProperty("locationAfter")
|
||||
private String locationAfter;
|
||||
/**
|
||||
* 原来数量
|
||||
*/
|
||||
@JsonProperty("quantityBefore")
|
||||
private BigDecimal quantityBefore;
|
||||
/**
|
||||
* 后来数量
|
||||
*/
|
||||
@JsonProperty("quantityAfter")
|
||||
private BigDecimal quantityAfter;
|
||||
/**
|
||||
* 原因
|
||||
*/
|
||||
@JsonProperty("reason")
|
||||
private String reason;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonProperty("updateTime")
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
@JsonProperty("updateUser")
|
||||
private String updateUser;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,52 +12,52 @@ import java.time.LocalDateTime;
|
|||
@Data
|
||||
public class StockUpdateRecordVo {
|
||||
/**
|
||||
* 库存编号
|
||||
* 记录编号
|
||||
*/
|
||||
@JsonProperty("record_id")
|
||||
@JsonProperty("recordId")
|
||||
private String recordId;
|
||||
/**
|
||||
* 库位ID
|
||||
* 库存编号
|
||||
*/
|
||||
@JsonProperty("stock_id")
|
||||
@JsonProperty("stockId")
|
||||
private String stockId;
|
||||
/**
|
||||
* 库位ID
|
||||
* 料箱编号
|
||||
*/
|
||||
@JsonProperty("vehicle_id")
|
||||
@JsonProperty("vehicleId")
|
||||
private String vehicleId;
|
||||
/**
|
||||
* 库位ID
|
||||
* 料号
|
||||
*/
|
||||
@JsonProperty("goods_id")
|
||||
@JsonProperty("goodsId")
|
||||
private String goodsId;
|
||||
/**
|
||||
* 库位ID
|
||||
* 物料名称
|
||||
*/
|
||||
@JsonProperty("goods_name")
|
||||
@JsonProperty("goodsName")
|
||||
private String goodsName;
|
||||
/**
|
||||
* 库位ID
|
||||
* 原来库位
|
||||
*/
|
||||
@JsonProperty("location_before")
|
||||
@JsonProperty("locationBefore")
|
||||
private String locationBefore;
|
||||
/**
|
||||
* 库位ID
|
||||
* 后来库位
|
||||
*/
|
||||
@JsonProperty("location_after")
|
||||
@JsonProperty("locationAfter")
|
||||
private String locationAfter;
|
||||
/**
|
||||
* 库位ID
|
||||
* 原来数量
|
||||
*/
|
||||
@JsonProperty("quantity_before")
|
||||
@JsonProperty("quantityBefore")
|
||||
private BigDecimal quantityBefore;
|
||||
/**
|
||||
* 库位ID
|
||||
* 后来数量
|
||||
*/
|
||||
@JsonProperty("quantity_after")
|
||||
@JsonProperty("quantityAfter")
|
||||
private BigDecimal quantityAfter;
|
||||
/**
|
||||
* 库位ID
|
||||
* 原因
|
||||
*/
|
||||
@JsonProperty("reason")
|
||||
private String reason;
|
||||
|
|
|
|||
|
|
@ -46,37 +46,49 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
private final TaskService taskService;// 任务服务
|
||||
private final PickTaskService pickTaskService;// 拣选任务服务
|
||||
private final OutsideVehiclesService outsideVehiclesService;// 流转中箱子服务
|
||||
|
||||
/**
|
||||
* 发送正常的任务
|
||||
*/
|
||||
@Override
|
||||
public void sendCommonTasks() throws Exception {
|
||||
try {
|
||||
String max_vehicle_nums = configMap.get(ConfigMapKeyEnum.MAX_VEHICLE_NUMS.getConfigKey());
|
||||
String max_wcs_accept_nums = configMap.get(ConfigMapKeyEnum.MAX_WCS_ACCEPT_NUMS.getConfigKey());
|
||||
if (StringUtils.isEmpty(max_vehicle_nums) || StringUtils.isEmpty(max_wcs_accept_nums)) {
|
||||
logger.error("配置未生成");
|
||||
return;
|
||||
}
|
||||
int maxVehicleNums = Integer.parseInt(max_vehicle_nums);
|
||||
int maxWcsAcceptNums = Integer.parseInt(max_wcs_accept_nums);
|
||||
List<String> outsideVehicles = outsideVehiclesService.selectDistinctVehicles();
|
||||
if (outsideVehicles == null || outsideVehicles.isEmpty()) {
|
||||
outsideVehicles = Collections.emptyList();
|
||||
}
|
||||
int remainVehicleNums = maxVehicleNums - outsideVehicles.size();
|
||||
|
||||
// 检索任务表---新建未下发的任务
|
||||
LambdaQueryWrapper<Task> waitForDistributeTaskQuery = new LambdaQueryWrapper<Task>()
|
||||
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode());
|
||||
List<Task> allTasks = taskService.list(waitForDistributeTaskQuery);
|
||||
// 需要发送给wcs的任务列表
|
||||
List<WcsTaskRequest> request = new ArrayList<>();
|
||||
// 已经下发的任务组列表
|
||||
List<String> taskGroupIds = new ArrayList<>();
|
||||
// 本次生成的环线任务
|
||||
List<String> pickVehicleIds = new ArrayList<>();
|
||||
if (!allTasks.isEmpty()) {
|
||||
String max_vehicle_nums = configMap.get(ConfigMapKeyEnum.MAX_VEHICLE_NUMS.getConfigKey());
|
||||
String max_wcs_accept_nums = configMap.get(ConfigMapKeyEnum.MAX_WCS_ACCEPT_NUMS.getConfigKey());
|
||||
if (StringUtils.isEmpty(max_vehicle_nums) || StringUtils.isEmpty(max_wcs_accept_nums)) {
|
||||
logger.error("配置未生成");
|
||||
return;
|
||||
}
|
||||
int maxVehicleNums = Integer.parseInt(max_vehicle_nums);
|
||||
int maxWcsAcceptNums = Integer.parseInt(max_wcs_accept_nums);
|
||||
List<String> outsideVehicles = outsideVehiclesService.selectDistinctVehicles();
|
||||
if (outsideVehicles == null || outsideVehicles.isEmpty()) {
|
||||
outsideVehicles = Collections.emptyList();
|
||||
}
|
||||
int remainVehicleNums = maxVehicleNums - outsideVehicles.size();
|
||||
|
||||
// 需要发送给wcs的任务列表
|
||||
List<WcsTaskRequest> request = new ArrayList<>();
|
||||
// 已经下发的任务组列表
|
||||
List<String> taskGroupIds = new ArrayList<>();
|
||||
// 本次生成的环线任务
|
||||
List<String> pickVehicleIds = new ArrayList<>();
|
||||
// 查找所有已经出库的站台拣选任务
|
||||
List<PickTask> standPickTasks = pickTaskService.list();
|
||||
// 生成一个Map,计算每个站台已经出库的拣选任务
|
||||
Map<String, Integer> outPickTaskMap = new HashMap<>();
|
||||
standPickTasks.forEach(pickTask -> {
|
||||
if (!Objects.equals(pickTask.getPickStatus(), PickTaskStatusEnum.TEMP.getCode())) {
|
||||
outPickTaskMap.put(pickTask.getStandId(),
|
||||
outPickTaskMap.getOrDefault(pickTask.getStandId(), 0) + 1);
|
||||
}
|
||||
});
|
||||
// 这里单独处理站台拣选出库以外的任务
|
||||
for (Task task : allTasks) {
|
||||
if (taskGroupIds.size() >= maxWcsAcceptNums) {
|
||||
// 每次给wcs下发数量
|
||||
|
|
@ -93,15 +105,8 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
}
|
||||
}
|
||||
if (Objects.equals(task.getTaskType(), TaskType.OUT.getCode())
|
||||
&& task.getIsPicking() == 1 && StringUtils.isNotEmpty(task.getPickStand())) {
|
||||
// 去站台的拣选任务
|
||||
if (!pickVehicleIds.contains(task.getVehicleId())) {
|
||||
if (pickVehicleIds.size() >= remainVehicleNums) {
|
||||
continue;
|
||||
} else {
|
||||
pickVehicleIds.add(task.getVehicleId());
|
||||
}
|
||||
}
|
||||
&& task.getIsPicking() == 1 && StringUtils.isNotEmpty(task.getPickStand())) {
|
||||
continue;
|
||||
}
|
||||
// 创建发送的任务
|
||||
WcsTaskRequest tempTask = new WcsTaskRequest();
|
||||
|
|
@ -121,6 +126,88 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
// 已经发送过的任务组
|
||||
taskGroupIds.add(task.getTaskGroup());
|
||||
}
|
||||
// 处理站台拣选出库任务
|
||||
while (taskGroupIds.size() < maxWcsAcceptNums && pickVehicleIds.size() < remainVehicleNums) {
|
||||
// 先找出目前数量最少的站台
|
||||
String standId = outPickTaskMap.entrySet().stream()
|
||||
.min(Comparator.comparingInt(Map.Entry::getValue))
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse("");
|
||||
List<String> vehicleIds;
|
||||
if (StringUtils.isNotEmpty(standId)) {
|
||||
// 查找这个站台未下发的料箱
|
||||
vehicleIds = standPickTasks.stream()
|
||||
.filter(pickTask -> pickTask.getStandId().equals(standId) && pickTask.getPickStatus().equals(PickTaskStatusEnum.TEMP.getCode()) && !pickVehicleIds.contains(pickTask.getVehicleId()))
|
||||
.map(PickTask::getVehicleId)
|
||||
.distinct()
|
||||
.toList();
|
||||
if (vehicleIds.isEmpty()) {
|
||||
outPickTaskMap.remove(standId);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
vehicleIds = standPickTasks.stream()
|
||||
.filter(pickTask -> pickTask.getPickStatus().equals(PickTaskStatusEnum.TEMP.getCode()) && !pickVehicleIds.contains(pickTask.getVehicleId()))
|
||||
.map(PickTask::getVehicleId)
|
||||
.distinct()
|
||||
.toList();
|
||||
if (vehicleIds.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 生成箱子-站台数量的Map
|
||||
Map<String, Integer> vehicleStandsMap = new HashMap<>();
|
||||
standPickTasks.forEach(pickTask -> {
|
||||
if (vehicleIds.contains(pickTask.getVehicleId())) {
|
||||
vehicleStandsMap.put(pickTask.getVehicleId(),
|
||||
vehicleStandsMap.getOrDefault(pickTask.getVehicleId(), 0) + 1);
|
||||
}
|
||||
});
|
||||
// 先找出目前数量最多的料箱
|
||||
String vehicleId = vehicleStandsMap.entrySet().stream()
|
||||
.max(Comparator.comparingInt(Map.Entry::getValue))
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse("");
|
||||
// 更新每个站台的拣选箱数量
|
||||
List<String> standIds = standPickTasks.stream()
|
||||
.filter(pickTask -> pickTask.getVehicleId().equals(vehicleId))
|
||||
.map(PickTask::getStandId)
|
||||
.distinct()
|
||||
.toList();
|
||||
if (!standIds.isEmpty()) {
|
||||
standIds.forEach(tempStandId -> outPickTaskMap.put(tempStandId, outPickTaskMap.getOrDefault(tempStandId, 0) + 1));
|
||||
}
|
||||
// 找到这个箱子的任务
|
||||
List<Task> outPickTasks = allTasks.stream().filter(task ->
|
||||
task.getVehicleId().equals(vehicleId) && Objects.equals(task.getTaskType(), TaskType.OUT.getCode())
|
||||
&& task.getIsPicking() == 1 && StringUtils.isNotEmpty(task.getPickStand())).toList();
|
||||
for (Task task : outPickTasks) {
|
||||
if (taskGroupIds.contains(task.getTaskGroup())) {
|
||||
// 该任务组已经下发
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(task.getPreTask())) {// 当前任务具有前置任务
|
||||
// 查询一下前置的任务有没有存在,存在则不下发
|
||||
if (taskService.exists(new LambdaQueryWrapper<Task>().eq(Task::getTaskId, task.getPreTask()))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 创建发送的任务
|
||||
WcsTaskRequest tempTask = new WcsTaskRequest();
|
||||
tempTask.setTaskId(task.getTaskGroup());
|
||||
tempTask.setTaskType(task.getTaskType());
|
||||
tempTask.setOrigin(task.getOrigin());
|
||||
tempTask.setDestination(task.getDestination());
|
||||
tempTask.setVehicleNo(task.getVehicleId());
|
||||
tempTask.setVehicleSize(task.getVehicleSize());
|
||||
tempTask.setWeight(task.getWeight());
|
||||
tempTask.setPriority(task.getTaskPriority());
|
||||
request.add(tempTask);
|
||||
// 已经发送过的任务组
|
||||
taskGroupIds.add(task.getTaskGroup());
|
||||
}
|
||||
pickVehicleIds.add(vehicleId);
|
||||
}
|
||||
if (request.size() == 0) {
|
||||
// 没有新任务发送
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -473,6 +473,10 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
if (!Objects.equals(pickStatus, PickTaskStatusEnum.TEMP.getCode()) && !Objects.equals(pickStatus, PickTaskStatusEnum.NEW.getCode())) {
|
||||
return;
|
||||
}
|
||||
// 这里查询所有暂存的任务
|
||||
List<PickTask> tempPickTasks = pickTaskService.list(new LambdaQueryWrapper<PickTask>()
|
||||
.eq(PickTask::getPickStatus, PickTaskStatusEnum.TEMP.getCode()));
|
||||
List<String> tempPickVehicles = tempPickTasks.stream().map(PickTask::getVehicleId).distinct().toList();
|
||||
// 拣选任务暂存列表
|
||||
List<PickTask> pickTasks = new ArrayList<>();
|
||||
vehicleIds.forEach(vehicleId -> {
|
||||
|
|
@ -481,7 +485,11 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
tempPickTask.setPickTaskId(generateId("PICK_"));
|
||||
tempPickTask.setVehicleId(vehicleId);
|
||||
tempPickTask.setStandId(workStation);
|
||||
tempPickTask.setPickStatus(pickStatus);
|
||||
if (tempPickVehicles.contains(vehicleId)) {
|
||||
tempPickTask.setPickStatus(PickTaskStatusEnum.TEMP.getCode());
|
||||
} else {
|
||||
tempPickTask.setPickStatus(pickStatus);
|
||||
}
|
||||
tempPickTask.setLastUpdateTime(LocalDateTime.now());
|
||||
pickTasks.add(tempPickTask);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -191,8 +191,7 @@ public class WorkServiceImplements implements IWorkService {
|
|||
// 查站台要料表---未分配以及分配但未完全分配
|
||||
List<GoodsToStation> goodsToStationList = goodsToStationService.list(new LambdaQueryWrapper<GoodsToStation>()
|
||||
.eq(GoodsToStation::getWorkStation, workStation)
|
||||
.eq(GoodsToStation::getDistributeStatus, 0)
|
||||
.or().eq(GoodsToStation::getDistributeStatus, 1));
|
||||
.lt(GoodsToStation::getDistributeStatus, 2));
|
||||
if (goodsToStationList == null || goodsToStationList.isEmpty()) {
|
||||
// 查询是否还有这个站台的拣选任务
|
||||
if (!pickTaskService.exists(new LambdaQueryWrapper<PickTask>()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user