no message
parent
5ac9257990
commit
714426db78
|
|
@ -205,15 +205,6 @@ public interface TaskService {
|
||||||
*/
|
*/
|
||||||
void materialPick();
|
void materialPick();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务轮询出库单叫料
|
|
||||||
*
|
|
||||||
* @param pick 出库单
|
|
||||||
*/
|
|
||||||
void callJlTask(Pick pick);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分配任务
|
* 分配任务
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import com.youchain.businessdata.service.dto.TaskDto;
|
||||||
import com.youchain.businessdata.service.dto.TaskQueryCriteria;
|
import com.youchain.businessdata.service.dto.TaskQueryCriteria;
|
||||||
import com.youchain.businessdata.service.mapstruct.TaskMapper;
|
import com.youchain.businessdata.service.mapstruct.TaskMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
@ -249,76 +250,6 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void callJlTask(Pick pick) {
|
|
||||||
|
|
||||||
//终点
|
|
||||||
Set<String> endPointList = new HashSet<>(Arrays.asList(pick.getCallPoint().split(",")));
|
|
||||||
|
|
||||||
//根据成品和单品分别生成叫料任务
|
|
||||||
if (BaseStatus.GD_TYPE_DP.equals(pick.getOrderType())) {
|
|
||||||
callDP(pick, endPointList);
|
|
||||||
} else {
|
|
||||||
callCT(pick, endPointList);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void callCT(Pick pick, Set<String> endPoints) {
|
|
||||||
|
|
||||||
List<Task> taskList = new ArrayList<>();
|
|
||||||
|
|
||||||
//根据目标托盘进行分组,每次最多送两个托盘
|
|
||||||
Map<String, List<Task>> groupMap = taskList.stream().collect(Collectors.groupingBy(Task::getDstStockCode));
|
|
||||||
for (Map.Entry<String, List<Task>> entry : groupMap.entrySet()) {
|
|
||||||
String dstStockCode = entry.getKey();//容器
|
|
||||||
List<Task> tasks = entry.getValue();//任务
|
|
||||||
for (String endPointCode : endPoints) {
|
|
||||||
if (agvTaskService.isStockAvailable(dstStockCode, BizStatus.CALL_PICK, "RACK_MOVE")) {
|
|
||||||
if (agvTaskService.findByEndSlotCode(endPointCode, BizStatus.CALL_PICK, "RACK_MOVE")) {
|
|
||||||
Stock stock = stockService.findByCode(dstStockCode);
|
|
||||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.CALL_PICK, stock, stock.getPoint().getCode(), endPointCode, "RACK_MOVE");
|
|
||||||
for (Task task : tasks) {
|
|
||||||
task.setCallAgvTaskId(agvTask.getId());
|
|
||||||
taskRepository.save(task);
|
|
||||||
}
|
|
||||||
agvTask.setLineSlotCode(pick.getCode());
|
|
||||||
agvTaskService.update(agvTask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void callDP(Pick pick, Set<String> endPoints) {
|
|
||||||
List<Task> taskList = this.findByPickAllTask(pick.getId());
|
|
||||||
if (taskList.isEmpty()) {
|
|
||||||
String logMessage = pick.getGdCode() + "工单没有进行翻包!";
|
|
||||||
if (!lastPollLogMessages.containsKey(logMessage)) {
|
|
||||||
logService.saveLogInfo(pick.getGdCode(), pick.getGdCode(), "/pick/callJlTask", logMessage, "生成叫料任务", 200, "info");
|
|
||||||
addLog(logMessage);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (Task task : taskList) {
|
|
||||||
for (String endPointCode : endPoints) {
|
|
||||||
if (agvTaskService.isStockAvailable(task.getDstStockCode(), BizStatus.CALL_PICK, "RACK_MOVE")) {
|
|
||||||
if (agvTaskService.findByEndSlotCode(endPointCode, BizStatus.CALL_PICK, "RACK_MOVE")) {
|
|
||||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.CALL_PICK, task.getDstStock(), task.getDstPointCode(), endPointCode, "RACK_MOVE");
|
|
||||||
agvTask.setLineSlotCode(pick.getCode());
|
|
||||||
agvTaskService.update(agvTask);
|
|
||||||
task.setCallAgvTaskId(agvTask.getId());
|
|
||||||
taskRepository.save(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String allocate(long id, double quantity) {
|
public String allocate(long id, double quantity) {
|
||||||
|
|
@ -367,17 +298,22 @@ public class TaskServiceImpl implements TaskService {
|
||||||
// 未分配数量
|
// 未分配数量
|
||||||
double unQty = quantity;
|
double unQty = quantity;
|
||||||
Set<String> tps = new HashSet<>();
|
Set<String> tps = new HashSet<>();
|
||||||
|
Map<Long, Point> containerPointMap = new HashMap<>(); // 记录每个容器对应的点位
|
||||||
for (Inventory inv : inventoryList) {
|
for (Inventory inv : inventoryList) {
|
||||||
// 判断托盘是否有任务
|
// 判断托盘是否有任务
|
||||||
synchronized (inv.getId()) {
|
synchronized (inv.getId()) {
|
||||||
|
if (unQty == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (this.existsByStock(pick.getCode(), inv.getStockCode()) >= 1) {
|
if (this.existsByStock(pick.getCode(), inv.getStockCode()) >= 1) {
|
||||||
tps.add(inv.getStockCode());
|
tps.add(inv.getStockCode());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询翻包区是否有空闲点位
|
//一个托盘对应一个点位
|
||||||
List<Point> pointList = pointService.queryPoints(null, BaseStatus.FREE, BaseStatus.BOX, boxAreaName);
|
Long stockId= inv.getStock().getId();
|
||||||
if (pointList.isEmpty()) {
|
Point endPoint = getEndPoint(stockId,containerPointMap, boxAreaName);
|
||||||
|
if(endPoint==null){
|
||||||
String logMessage = pick.getCode() + "明细分配失败," + (BaseStatus.GD_TYPE_CT.equals(pick.getOrderType()) ? "小件" : "大件") + "翻包区没有空闲点位!";
|
String logMessage = pick.getCode() + "明细分配失败," + (BaseStatus.GD_TYPE_CT.equals(pick.getOrderType()) ? "小件" : "大件") + "翻包区没有空闲点位!";
|
||||||
if (!lastPollLogMessages.containsKey(logMessage)) {
|
if (!lastPollLogMessages.containsKey(logMessage)) {
|
||||||
logService.saveLogInfo(pick.getCode(), pick.getCode(), "/pick/allocatePick", logMessage, "出库单分配", 200, "info");
|
logService.saveLogInfo(pick.getCode(), pick.getCode(), "/pick/allocatePick", logMessage, "出库单分配", 200, "info");
|
||||||
|
|
@ -385,23 +321,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
return logMessage;
|
return logMessage;
|
||||||
}
|
}
|
||||||
Point endPoint = null;
|
|
||||||
//大件一个明细可以对应多个点位;小件一个明细只能对应一个点位
|
|
||||||
if (BaseStatus.GD_TYPE_CT.equals(pick.getOrderType())) {
|
|
||||||
if (pickDetail.getPoint() == null) {
|
|
||||||
endPoint = pointList.get(0);
|
|
||||||
} else {
|
|
||||||
endPoint = pickDetail.getPoint();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
endPoint = pointList.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 起点
|
|
||||||
Point startPoint = inv.getPoint();
|
|
||||||
if (unQty == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// 库存可用数量
|
// 库存可用数量
|
||||||
allocateQty = inv.getQuantity() - inv.getQueuedQty();
|
allocateQty = inv.getQuantity() - inv.getQueuedQty();
|
||||||
if (allocateQty <= 0) {
|
if (allocateQty <= 0) {
|
||||||
|
|
@ -416,14 +336,15 @@ public class TaskServiceImpl implements TaskService {
|
||||||
unQty -= allocateQty;
|
unQty -= allocateQty;
|
||||||
/* 更新出库单明细状态*/
|
/* 更新出库单明细状态*/
|
||||||
pickDetail.setAllocatedQty(pickDetail.getAllocatedQty() + allocateQty);
|
pickDetail.setAllocatedQty(pickDetail.getAllocatedQty() + allocateQty);
|
||||||
pickDetail.setPoint(endPoint);
|
|
||||||
pickDetailService.update(pickDetail);
|
pickDetailService.update(pickDetail);
|
||||||
|
|
||||||
// 生成Task任务
|
// 生成Task任务
|
||||||
Task task = this.createTask(item, allocateQty, inv.getItemKey(), null, BizStatus.PICK, pickDetail, inv.getId(), inv.getStock(), startPoint, endPoint, null);
|
this.createTask(item, allocateQty, inv.getItemKey(), null, BizStatus.PICK, pickDetail, inv.getId(), inv.getStock(), inv.getPoint(), endPoint, null);
|
||||||
|
|
||||||
//占用点位
|
//占用点位
|
||||||
pointService.usedPoint(endPoint);
|
pointService.usedPoint(endPoint);
|
||||||
|
|
||||||
|
containerPointMap.put(stockId, endPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -434,6 +355,35 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取翻包区点位
|
||||||
|
private Point getEndPoint(Long stockId,Map<Long, Point> containerPointMap,String boxAreaName){
|
||||||
|
|
||||||
|
//查询翻包区是否有空闲点位
|
||||||
|
List<Point> pointList = pointService.queryPoints(null, BaseStatus.FREE, BaseStatus.BOX, boxAreaName);
|
||||||
|
if (CollectionUtils.isEmpty(pointList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point endPoint = null;
|
||||||
|
//大件一个托盘对应一个点位;小件一种物料一个点位
|
||||||
|
if (containerPointMap.containsKey(stockId)) {
|
||||||
|
endPoint = containerPointMap.get(stockId);
|
||||||
|
} else {
|
||||||
|
// 筛选出未使用的点位
|
||||||
|
List<Point> availablePoints = new ArrayList<>();
|
||||||
|
for (Point point : pointList) {
|
||||||
|
if (!containerPointMap.containsValue(point)) {
|
||||||
|
availablePoints.add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(availablePoints)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
endPoint = availablePoints.get(0);
|
||||||
|
}
|
||||||
|
return endPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 增加物料可替代性判断
|
// 增加物料可替代性判断
|
||||||
private boolean isReplaceableMaterial(String material) {
|
private boolean isReplaceableMaterial(String material) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.youchain.modules.quartz.task;
|
||||||
|
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.domain.Stock;
|
import com.youchain.basicdata.domain.Stock;
|
||||||
|
import com.youchain.basicdata.service.PointService;
|
||||||
import com.youchain.basicdata.service.StockService;
|
import com.youchain.basicdata.service.StockService;
|
||||||
import com.youchain.businessdata.domain.AgvTask;
|
import com.youchain.businessdata.domain.AgvTask;
|
||||||
import com.youchain.businessdata.service.AgvTaskService;
|
import com.youchain.businessdata.service.AgvTaskService;
|
||||||
|
|
@ -9,6 +10,7 @@ import com.youchain.businessdata.service.KMReService;
|
||||||
import com.youchain.businessdata.service.PickService;
|
import com.youchain.businessdata.service.PickService;
|
||||||
import com.youchain.businessdata.service.TaskService;
|
import com.youchain.businessdata.service.TaskService;
|
||||||
import com.youchain.exception.BadRequestException;
|
import com.youchain.exception.BadRequestException;
|
||||||
|
import com.youchain.utils.BaseStatus;
|
||||||
import com.youchain.utils.BizStatus;
|
import com.youchain.utils.BizStatus;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -39,6 +41,9 @@ public class blTask {
|
||||||
@Autowired
|
@Autowired
|
||||||
public KMReService kmReService;
|
public KMReService kmReService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public PointService pointService;
|
||||||
|
|
||||||
// 定义异常信息常量
|
// 定义异常信息常量
|
||||||
private static final String NO_EMPTY_SHELVES_ERROR_MSG = "没有备料任务!";
|
private static final String NO_EMPTY_SHELVES_ERROR_MSG = "没有备料任务!";
|
||||||
|
|
||||||
|
|
@ -62,11 +67,6 @@ public class blTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processAgvTask(AgvTask agvTask) {
|
private void processAgvTask(AgvTask agvTask) {
|
||||||
//目标点没有托盘继续下发下一个任务
|
|
||||||
String endSlotCode = agvTask.getEndSlotCode();
|
|
||||||
boolean isTaskFound = agvTaskService.findByCcEndSlotCode(endSlotCode, BizStatus.PICK, "FORKLIFT_MOVE");
|
|
||||||
if (isTaskFound) {
|
|
||||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskCcJson(agvTask));
|
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskCcJson(agvTask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.youchain.basicdata.domain.BigItem;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.vo.BarCodeVo;
|
import com.youchain.basicdata.vo.BarCodeVo;
|
||||||
import com.youchain.businessdata.domain.PickDetail;
|
import com.youchain.businessdata.domain.PickDetail;
|
||||||
|
import com.youchain.businessdata.domain.Task;
|
||||||
import com.youchain.exception.BadRequestException;
|
import com.youchain.exception.BadRequestException;
|
||||||
import com.youchain.utils.BaseStatus;
|
import com.youchain.utils.BaseStatus;
|
||||||
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
||||||
|
|
@ -26,14 +27,49 @@ public class EladminSystemApplicationTests {
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
static class Task {
|
||||||
String pointCode = "QXJL002";
|
private int id;
|
||||||
String currentCallPoint="QXJL001,QXJL002,QXJL001";
|
private String dstStockCode;
|
||||||
Set<String> callPointSet = new HashSet<>(Arrays.asList(currentCallPoint.split(",")));
|
|
||||||
callPointSet.add(pointCode);
|
|
||||||
String newCallPoint = String.join(",", callPointSet);
|
|
||||||
System.out.println(newCallPoint);
|
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDstStockCode() {
|
||||||
|
return dstStockCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task(int id, String dstStockCode) {
|
||||||
|
this.id = id;
|
||||||
|
this.dstStockCode = dstStockCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<Task> taskList = Arrays.asList(
|
||||||
|
new Task(1, "1001"),
|
||||||
|
new Task(2, "1001"),
|
||||||
|
new Task(3, "1002"),
|
||||||
|
new Task(4, "1002"),
|
||||||
|
new Task(5, "1003")
|
||||||
|
);
|
||||||
|
Map<String, List<Task>> groupMap = taskList.stream().collect(Collectors.groupingBy(Task::getDstStockCode,LinkedHashMap::new, Collectors.toList()));
|
||||||
|
|
||||||
|
if (groupMap.size() > 2) {
|
||||||
|
groupMap = groupMap.entrySet().stream()
|
||||||
|
.limit(2)
|
||||||
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
||||||
|
(existing, replacement) -> existing, LinkedHashMap::new));
|
||||||
|
|
||||||
|
}
|
||||||
|
// 打印结果
|
||||||
|
groupMap.forEach((key, tasks) -> {
|
||||||
|
System.out.println("Key: " + key);
|
||||||
|
tasks.forEach(task -> System.out.println(" Task ID: " + task.getId() + ", Group ID: " + task.getDstStockCode()));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(groupMap.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cc1() {
|
public void cc1() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue