no message
parent
3fb4165a16
commit
e82330aa52
|
|
@ -83,7 +83,7 @@ public class KMReSController {
|
|||
Task task = getFirstTask(agvTask.getId());
|
||||
agvTaskService.agvTaskCallback(agvTask, task, missionStatus);
|
||||
|
||||
CompletableFuture<Void> returnMoFuture = CompletableFuture.runAsync(() -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
returnMo(task.getBillCode());// 回传MO信息
|
||||
});
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ public class KMReSController {
|
|||
Task task = getFirstTask(agvTask.getId());
|
||||
agvTaskService.agvTaskCallback(agvTask, missionStatus, containerCode);
|
||||
|
||||
CompletableFuture<Void> returnIssueFuture = CompletableFuture.runAsync(() -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
|
||||
returnIssue(task);// 叫料结果回传
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.youchain.businessdata.rest;
|
|||
|
||||
import com.youchain.annotation.AnonymousAccess;
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.appupdate.inputJson.MissionStateCallback;
|
||||
import com.youchain.businessdata.inputJson.*;
|
||||
import com.youchain.businessdata.service.MlsService;
|
||||
import com.youchain.exception.handler.ApiResult;
|
||||
|
|
@ -12,12 +11,15 @@ import lombok.RequiredArgsConstructor;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
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.OK;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
|
@ -146,14 +147,14 @@ public class MlsServiceImpl implements MlsService {
|
|||
}
|
||||
}
|
||||
|
||||
CompletableFuture<Void> orderFutureCreate = CompletableFuture.runAsync(() -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
//批量新增订单
|
||||
if (!ordersToCreate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(ordersToCreate);
|
||||
}
|
||||
});
|
||||
|
||||
CompletableFuture<Void> orderFutureUpdate = CompletableFuture.runAsync(() -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
//批量更新订单
|
||||
if (!ordersToUpdate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchUpdate(ordersToUpdate);
|
||||
|
|
@ -316,14 +317,14 @@ public class MlsServiceImpl implements MlsService {
|
|||
}
|
||||
}
|
||||
|
||||
CompletableFuture<Void> moFutureCreate = CompletableFuture.runAsync(() -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
//批量新增Mo票
|
||||
if (!mosToCreate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(mosToCreate);
|
||||
}
|
||||
});
|
||||
|
||||
CompletableFuture<Void> moFutureUpdate = CompletableFuture.runAsync(() -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
//批量更新Mo票
|
||||
if (!mosToUpdate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchUpdate(mosToUpdate);
|
||||
|
|
@ -400,48 +401,50 @@ public class MlsServiceImpl implements MlsService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void getIssueInfo(IssueInfo issueInfo) {
|
||||
String taskNumber = issueInfo.getTaskNumber();//任务号
|
||||
// 指定Set的类型
|
||||
if (issueInfo == null) {
|
||||
throw new IllegalArgumentException("传入的 IssueInfo 对象为空");
|
||||
}
|
||||
|
||||
Set<String> workOrderNameSet = issueInfo.getWorkOrderName();
|
||||
if (workOrderNameSet.isEmpty()) {
|
||||
if (workOrderNameSet == null || workOrderNameSet.isEmpty()) {
|
||||
throw new IllegalArgumentException("没有获取到工单号!");
|
||||
}
|
||||
|
||||
CompletableFuture<List<Inventory>> inventoryListFuture = CompletableFuture.supplyAsync(() -> {
|
||||
|
||||
List<Inventory> inventoryList = inventoryService.findInvByBillCode(workOrderNameSet);//根据工单号查询库存信息
|
||||
if (inventoryList.isEmpty()) {
|
||||
|
||||
return inventoryList;
|
||||
});
|
||||
|
||||
if (inventoryListFuture.join().isEmpty()) {
|
||||
throw new RuntimeException("无库存信息!");
|
||||
}
|
||||
|
||||
inventoryListFuture.thenAccept((result) -> {
|
||||
//目标点
|
||||
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<>();
|
||||
|
||||
for (Inventory inv : inventoryList) {
|
||||
for (Inventory inv : result) {
|
||||
//根据库存信息生成叫料任务
|
||||
Stock stock = inv.getStock();//容器
|
||||
Point startPoint = inv.getPoint();//起始点位
|
||||
ItemKey itemKey = inv.getItemKey();
|
||||
Item item = inv.getItemKey().getItem();
|
||||
|
||||
//更新库存信息
|
||||
inventoryToUpdate.add(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());
|
||||
PickDetail pd = createPickDetail(item, inv.getBillCode(), itemKey.getPropC1(), inv.getQuantity());
|
||||
pickDetailToCreate.add(pd);
|
||||
|
||||
//生成搬运任务
|
||||
|
|
@ -449,10 +452,137 @@ public class MlsServiceImpl implements MlsService {
|
|||
agvTaskToCreate.add(agvTask);
|
||||
|
||||
//生成Task
|
||||
Task task = createTask(item, itemKey, pd, inv.getBillCode(), stock, startPoint, endPoint, agvTask, inv);
|
||||
taskToCreate.add(task);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void processInventory(Inventory inv, Point endPoint) {
|
||||
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));
|
||||
|
||||
// 批量生成agv任务
|
||||
batchCreateOrUpdate.batchCreate(Collections.singletonList(agvTask));
|
||||
|
||||
// 批量生成任务
|
||||
batchCreateOrUpdate.batchCreate(Collections.singletonList(task));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新库存信息
|
||||
*
|
||||
* @param inventory
|
||||
* @return
|
||||
*/
|
||||
public Inventory updateInventory(Inventory inventory) {
|
||||
inventory.setQueuedQty(inventory.getQuantity());
|
||||
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);
|
||||
|
|
@ -468,49 +598,7 @@ public class MlsServiceImpl implements MlsService {
|
|||
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> pickDetailFuture = inventoryFuture.thenRun(() -> {
|
||||
//批量生成叫料明细
|
||||
if (!pickDetailToCreate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(pickDetailToCreate);
|
||||
}
|
||||
});
|
||||
|
||||
CompletableFuture<Void> agvTaskFuture = pickDetailFuture.thenRun(() -> {
|
||||
// 批量生成agv任务
|
||||
if (!agvTaskToCreate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(agvTaskToCreate);
|
||||
}
|
||||
});
|
||||
|
||||
CompletableFuture<Void> taskFuture = agvTaskFuture.thenRun(() -> {
|
||||
// 批量生成任务
|
||||
if (!taskToCreate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(taskToCreate);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新库存信息
|
||||
*
|
||||
* @param inventory
|
||||
* @return
|
||||
*/
|
||||
private Inventory updateInventory(Inventory inventory) {
|
||||
inventory.setQueuedQty(inventory.getQuantity());
|
||||
return inventory;
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue