no message
parent
3fb4165a16
commit
e82330aa52
|
|
@ -83,7 +83,7 @@ public class KMReSController {
|
||||||
Task task = getFirstTask(agvTask.getId());
|
Task task = getFirstTask(agvTask.getId());
|
||||||
agvTaskService.agvTaskCallback(agvTask, task, missionStatus);
|
agvTaskService.agvTaskCallback(agvTask, task, missionStatus);
|
||||||
|
|
||||||
CompletableFuture<Void> returnMoFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
returnMo(task.getBillCode());// 回传MO信息
|
returnMo(task.getBillCode());// 回传MO信息
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +96,7 @@ public class KMReSController {
|
||||||
Task task = getFirstTask(agvTask.getId());
|
Task task = getFirstTask(agvTask.getId());
|
||||||
agvTaskService.agvTaskCallback(agvTask, missionStatus, containerCode);
|
agvTaskService.agvTaskCallback(agvTask, missionStatus, containerCode);
|
||||||
|
|
||||||
CompletableFuture<Void> returnIssueFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
|
|
||||||
returnIssue(task);// 叫料结果回传
|
returnIssue(task);// 叫料结果回传
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.youchain.businessdata.rest;
|
||||||
|
|
||||||
import com.youchain.annotation.AnonymousAccess;
|
import com.youchain.annotation.AnonymousAccess;
|
||||||
import com.youchain.annotation.Log;
|
import com.youchain.annotation.Log;
|
||||||
import com.youchain.appupdate.inputJson.MissionStateCallback;
|
|
||||||
import com.youchain.businessdata.inputJson.*;
|
import com.youchain.businessdata.inputJson.*;
|
||||||
import com.youchain.businessdata.service.MlsService;
|
import com.youchain.businessdata.service.MlsService;
|
||||||
import com.youchain.exception.handler.ApiResult;
|
import com.youchain.exception.handler.ApiResult;
|
||||||
|
|
@ -12,12 +11,15 @@ import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -146,14 +147,14 @@ public class MlsServiceImpl implements MlsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletableFuture<Void> orderFutureCreate = CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
//批量新增订单
|
//批量新增订单
|
||||||
if (!ordersToCreate.isEmpty()) {
|
if (!ordersToCreate.isEmpty()) {
|
||||||
batchCreateOrUpdate.batchCreate(ordersToCreate);
|
batchCreateOrUpdate.batchCreate(ordersToCreate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CompletableFuture<Void> orderFutureUpdate = CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
//批量更新订单
|
//批量更新订单
|
||||||
if (!ordersToUpdate.isEmpty()) {
|
if (!ordersToUpdate.isEmpty()) {
|
||||||
batchCreateOrUpdate.batchUpdate(ordersToUpdate);
|
batchCreateOrUpdate.batchUpdate(ordersToUpdate);
|
||||||
|
|
@ -316,14 +317,14 @@ public class MlsServiceImpl implements MlsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletableFuture<Void> moFutureCreate = CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
//批量新增Mo票
|
//批量新增Mo票
|
||||||
if (!mosToCreate.isEmpty()) {
|
if (!mosToCreate.isEmpty()) {
|
||||||
batchCreateOrUpdate.batchCreate(mosToCreate);
|
batchCreateOrUpdate.batchCreate(mosToCreate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CompletableFuture<Void> moFutureUpdate = CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
//批量更新Mo票
|
//批量更新Mo票
|
||||||
if (!mosToUpdate.isEmpty()) {
|
if (!mosToUpdate.isEmpty()) {
|
||||||
batchCreateOrUpdate.batchUpdate(mosToUpdate);
|
batchCreateOrUpdate.batchUpdate(mosToUpdate);
|
||||||
|
|
@ -400,106 +401,157 @@ public class MlsServiceImpl implements MlsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void getIssueInfo(IssueInfo issueInfo) {
|
public void getIssueInfo(IssueInfo issueInfo) {
|
||||||
String taskNumber = issueInfo.getTaskNumber();//任务号
|
if (issueInfo == null) {
|
||||||
// 指定Set的类型
|
throw new IllegalArgumentException("传入的 IssueInfo 对象为空");
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> workOrderNameSet = issueInfo.getWorkOrderName();
|
Set<String> workOrderNameSet = issueInfo.getWorkOrderName();
|
||||||
if (workOrderNameSet.isEmpty()) {
|
if (workOrderNameSet == null || workOrderNameSet.isEmpty()) {
|
||||||
throw new IllegalArgumentException("没有获取到工单号!");
|
throw new IllegalArgumentException("没有获取到工单号!");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Inventory> inventoryList = inventoryService.findInvByBillCode(workOrderNameSet);//根据工单号查询库存信息
|
CompletableFuture<List<Inventory>> inventoryListFuture = CompletableFuture.supplyAsync(() -> {
|
||||||
if (inventoryList.isEmpty()) {
|
|
||||||
|
List<Inventory> inventoryList = inventoryService.findInvByBillCode(workOrderNameSet);//根据工单号查询库存信息
|
||||||
|
|
||||||
|
return inventoryList;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (inventoryListFuture.join().isEmpty()) {
|
||||||
throw new RuntimeException("无库存信息!");
|
throw new RuntimeException("无库存信息!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//目标点
|
inventoryListFuture.thenAccept((result) -> {
|
||||||
Point endPoint = redisObjectUtils.getObjectFromCache("ckjbk", () -> pointService.findByCode(null, null, null, "出库接驳口", null),
|
//目标点
|
||||||
"系统无此点位!");
|
Point endPoint = redisObjectUtils.getObjectFromCache("ckjbk", () -> pointService.findByCode(null, null, null, "出库接驳口", null),
|
||||||
|
"系统无此点位!");
|
||||||
|
|
||||||
|
List<Inventory> inventoryToUpdate = new ArrayList<>();
|
||||||
|
List<PickDetail> pickDetailToCreate = new ArrayList<>();
|
||||||
|
List<AgvTask> agvTaskToCreate = new ArrayList<>();
|
||||||
|
List<Task> taskToCreate = new ArrayList<>();
|
||||||
|
|
||||||
List<Inventory> inventoryToUpdate = new ArrayList<>();
|
for (Inventory inv : result) {
|
||||||
List<PickDetail> pickDetailToCreate = new ArrayList<>();
|
//根据库存信息生成叫料任务
|
||||||
List<AgvTask> agvTaskToCreate = new ArrayList<>();
|
Stock stock = inv.getStock();//容器
|
||||||
List<Task> taskToCreate = new ArrayList<>();
|
Point startPoint = inv.getPoint();//起始点位
|
||||||
|
ItemKey itemKey = inv.getItemKey();
|
||||||
|
Item item = inv.getItemKey().getItem();
|
||||||
|
|
||||||
for (Inventory inv : inventoryList) {
|
//更新库存信息
|
||||||
//根据库存信息生成叫料任务
|
inventoryToUpdate.add(updateInventory(inv));
|
||||||
Stock stock = inv.getStock();//容器
|
|
||||||
Point startPoint = inv.getPoint();//起始点位
|
|
||||||
Item item = inv.getItemKey().getItem();
|
|
||||||
|
|
||||||
//更新库存信息
|
//生成出库明细
|
||||||
inventoryToUpdate.add(updateInventory(inv));
|
PickDetail pd = createPickDetail(item, inv.getBillCode(), itemKey.getPropC1(), inv.getQuantity());
|
||||||
|
pickDetailToCreate.add(pd);
|
||||||
|
|
||||||
//生成出库明细
|
//生成搬运任务
|
||||||
PickDetail pd = new PickDetail();
|
AgvTask agvTask = new AgvTask(BizStatus.PICK, stock.getCode(), startPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "PICKER_MOVE");
|
||||||
pd.setItem(item);
|
agvTaskToCreate.add(agvTask);
|
||||||
pd.setPo(inv.getBillCode());
|
|
||||||
pd.setPropC1(inv.getItemKey().getPropC1());
|
|
||||||
pd.setLineNo(1l);
|
|
||||||
pd.setOrderQty(inv.getQuantity());
|
|
||||||
pd.setAllocatedQty(inv.getQuantity());
|
|
||||||
pd.setStatus(BizStatus.ALLOCATE);
|
|
||||||
pd.setDept(item.getDept());
|
|
||||||
pickDetailToCreate.add(pd);
|
|
||||||
|
|
||||||
//生成搬运任务
|
//生成Task
|
||||||
AgvTask agvTask = new AgvTask(BizStatus.PICK, stock.getCode(), startPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "PICKER_MOVE");
|
Task task = createTask(item, itemKey, pd, inv.getBillCode(), stock, startPoint, endPoint, agvTask, inv);
|
||||||
agvTaskToCreate.add(agvTask);
|
taskToCreate.add(task);
|
||||||
|
|
||||||
//生成Task
|
|
||||||
Task task = new Task();
|
|
||||||
task.setItem(item);
|
|
||||||
task.setItemKey(inv.getItemKey());
|
|
||||||
task.setPickDetail(pd);
|
|
||||||
task.setBillCode(taskNumber);
|
|
||||||
task.setSrcStock(stock);
|
|
||||||
task.setDstStock(stock);
|
|
||||||
task.setSrcPoint(startPoint);
|
|
||||||
task.setDstPoint(endPoint);
|
|
||||||
task.setSrcStockCode(stock.getCode());
|
|
||||||
task.setSrcPointCode(startPoint.getCode());
|
|
||||||
task.setDstPointCode(endPoint.getCode());
|
|
||||||
task.setInvStatus(inv.getStatus());
|
|
||||||
task.setTaskType(BizStatus.PICK);
|
|
||||||
task.setTaskStatus(BizStatus.OPEN);
|
|
||||||
task.setPlanQty(inv.getQuantity());
|
|
||||||
task.setInvId(inv.getId());
|
|
||||||
task.setDept(item.getDept());
|
|
||||||
task.setAgvTask(agvTask);
|
|
||||||
taskToCreate.add(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
CompletableFuture<Void> inventoryFuture = CompletableFuture.runAsync(() -> {
|
|
||||||
//批量更新库存信息
|
|
||||||
if (!inventoryToUpdate.isEmpty()) {
|
|
||||||
batchCreateOrUpdate.batchUpdate(inventoryToUpdate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompletableFuture<Void> inventoryFuture = CompletableFuture.runAsync(() -> {
|
||||||
|
//批量更新库存信息
|
||||||
|
if (!inventoryToUpdate.isEmpty()) {
|
||||||
|
batchCreateOrUpdate.batchUpdate(inventoryToUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
CompletableFuture<Void> pickDetailFuture = inventoryFuture.thenAccept(result2 -> {
|
||||||
|
//批量生成叫料明细
|
||||||
|
if (!pickDetailToCreate.isEmpty()) {
|
||||||
|
batchCreateOrUpdate.batchCreate(pickDetailToCreate);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
CompletableFuture<Void> agvTaskFuture = pickDetailFuture.thenAccept(result3 -> {
|
||||||
|
// 批量生成agv任务
|
||||||
|
if (!agvTaskToCreate.isEmpty()) {
|
||||||
|
batchCreateOrUpdate.batchCreate(agvTaskToCreate);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
CompletableFuture<Void> taskFuture = agvTaskFuture.thenAccept(result4 -> {
|
||||||
|
// 批量生成任务
|
||||||
|
if (!taskToCreate.isEmpty()) {
|
||||||
|
batchCreateOrUpdate.batchCreate(taskToCreate);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
CompletableFuture.allOf(inventoryFuture, pickDetailFuture, agvTaskFuture, taskFuture).join();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
CompletableFuture<Void> pickDetailFuture = inventoryFuture.thenRun(() -> {
|
}
|
||||||
//批量生成叫料明细
|
|
||||||
if (!pickDetailToCreate.isEmpty()) {
|
private void processInventory(Inventory inv, Point endPoint) {
|
||||||
batchCreateOrUpdate.batchCreate(pickDetailToCreate);
|
Stock stock = inv.getStock();
|
||||||
}
|
Point startPoint = inv.getPoint();
|
||||||
});
|
Item item = inv.getItemKey().getItem();
|
||||||
|
|
||||||
|
// 更新库存信息
|
||||||
|
Inventory updatedInv = updateInventory(inv);
|
||||||
|
|
||||||
|
// 生成出库明细
|
||||||
|
PickDetail pd = new PickDetail();
|
||||||
|
pd.setItem(item);
|
||||||
|
pd.setPo(inv.getBillCode());
|
||||||
|
pd.setPropC1(inv.getItemKey().getPropC1());
|
||||||
|
pd.setLineNo(1L);
|
||||||
|
pd.setOrderQty(inv.getQuantity());
|
||||||
|
pd.setAllocatedQty(inv.getQuantity());
|
||||||
|
pd.setStatus(BizStatus.ALLOCATE);
|
||||||
|
pd.setDept(item.getDept());
|
||||||
|
|
||||||
|
// 生成搬运任务
|
||||||
|
AgvTask agvTask = new AgvTask(BizStatus.PICK, stock.getCode(), startPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "PICKER_MOVE");
|
||||||
|
|
||||||
|
// 生成Task
|
||||||
|
Task task = new Task();
|
||||||
|
task.setItem(item);
|
||||||
|
task.setItemKey(inv.getItemKey());
|
||||||
|
task.setPickDetail(pd);
|
||||||
|
task.setBillCode(inv.getBillCode());
|
||||||
|
task.setSrcStock(stock);
|
||||||
|
task.setDstStock(stock);
|
||||||
|
task.setSrcPoint(startPoint);
|
||||||
|
task.setDstPoint(endPoint);
|
||||||
|
task.setSrcStockCode(stock.getCode());
|
||||||
|
task.setSrcPointCode(startPoint.getCode());
|
||||||
|
task.setDstPointCode(endPoint.getCode());
|
||||||
|
task.setInvStatus(inv.getStatus());
|
||||||
|
task.setTaskType(BizStatus.PICK);
|
||||||
|
task.setTaskStatus(BizStatus.OPEN);
|
||||||
|
task.setPlanQty(inv.getQuantity());
|
||||||
|
task.setInvId(inv.getId());
|
||||||
|
task.setDept(item.getDept());
|
||||||
|
task.setAgvTask(agvTask);
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
|
// 批量更新库存信息
|
||||||
|
batchCreateOrUpdate.batchUpdate(Collections.singletonList(updatedInv));
|
||||||
|
|
||||||
|
// 批量生成叫料明细
|
||||||
|
batchCreateOrUpdate.batchCreate(Collections.singletonList(pd));
|
||||||
|
|
||||||
CompletableFuture<Void> agvTaskFuture = pickDetailFuture.thenRun(() -> {
|
|
||||||
// 批量生成agv任务
|
// 批量生成agv任务
|
||||||
if (!agvTaskToCreate.isEmpty()) {
|
batchCreateOrUpdate.batchCreate(Collections.singletonList(agvTask));
|
||||||
batchCreateOrUpdate.batchCreate(agvTaskToCreate);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
CompletableFuture<Void> taskFuture = agvTaskFuture.thenRun(() -> {
|
|
||||||
// 批量生成任务
|
// 批量生成任务
|
||||||
if (!taskToCreate.isEmpty()) {
|
batchCreateOrUpdate.batchCreate(Collections.singletonList(task));
|
||||||
batchCreateOrUpdate.batchCreate(taskToCreate);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -508,11 +560,47 @@ public class MlsServiceImpl implements MlsService {
|
||||||
* @param inventory
|
* @param inventory
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Inventory updateInventory(Inventory inventory) {
|
public Inventory updateInventory(Inventory inventory) {
|
||||||
inventory.setQueuedQty(inventory.getQuantity());
|
inventory.setQueuedQty(inventory.getQuantity());
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PickDetail createPickDetail(Item item, String po, String propC1, Double orderQty) {
|
||||||
|
PickDetail pickDetail = new PickDetail();
|
||||||
|
pickDetail.setItem(item);
|
||||||
|
pickDetail.setPo(po);
|
||||||
|
pickDetail.setPropC1(propC1);
|
||||||
|
pickDetail.setLineNo(1L);
|
||||||
|
pickDetail.setOrderQty(orderQty);
|
||||||
|
pickDetail.setAllocatedQty(orderQty);
|
||||||
|
pickDetail.setStatus(BizStatus.ALLOCATE);
|
||||||
|
pickDetail.setDept(item.getDept());
|
||||||
|
return pickDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task createTask(Item item, ItemKey itemKey, PickDetail pd, String taskNumber, Stock stock, Point startPoint, Point endPoint, AgvTask agvTask, Inventory inv) {
|
||||||
|
Task task = new Task();
|
||||||
|
task.setItem(item);
|
||||||
|
task.setItemKey(itemKey);
|
||||||
|
task.setPickDetail(pd);
|
||||||
|
task.setBillCode(taskNumber);
|
||||||
|
task.setSrcStock(stock);
|
||||||
|
task.setDstStock(stock);
|
||||||
|
task.setSrcPoint(startPoint);
|
||||||
|
task.setDstPoint(endPoint);
|
||||||
|
task.setSrcStockCode(stock.getCode());
|
||||||
|
task.setSrcPointCode(startPoint.getCode());
|
||||||
|
task.setDstPointCode(endPoint.getCode());
|
||||||
|
task.setInvStatus(inv.getStatus());
|
||||||
|
task.setTaskType(BizStatus.PICK);
|
||||||
|
task.setTaskStatus(BizStatus.OPEN);
|
||||||
|
task.setPlanQty(inv.getQuantity());
|
||||||
|
task.setInvId(inv.getId());
|
||||||
|
task.setDept(item.getDept());
|
||||||
|
task.setAgvTask(agvTask);
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mo票回传
|
* Mo票回传
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue