no message
parent
e5cd7979ad
commit
755b86ace9
|
|
@ -153,7 +153,7 @@ public class KMReServiceImpl implements KMReService {
|
|||
* @param json 接口json
|
||||
*/
|
||||
@Override
|
||||
public synchronized void sendAgvTaskToContainer(String url, String json) {
|
||||
public void sendAgvTaskToContainer(String url, String json) {
|
||||
Dict dict = dictRepository.findDictByDescription("OPEN");
|
||||
if (dict != null) {
|
||||
String resultJson = HttpPostUtil.sendPostReq(url, json);
|
||||
|
|
@ -179,7 +179,7 @@ public class KMReServiceImpl implements KMReService {
|
|||
* @param agvTasks 任务
|
||||
*/
|
||||
@Override
|
||||
public synchronized String sendAgvTaskCcJson(AgvTask agvTasks) {
|
||||
public String sendAgvTaskCcJson(AgvTask agvTasks) {
|
||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||
|
||||
Map<String, Object> objMap = new LinkedHashMap<>();
|
||||
|
|
@ -231,7 +231,7 @@ public class KMReServiceImpl implements KMReService {
|
|||
* @param agvTasks 任务
|
||||
*/
|
||||
@Override
|
||||
public synchronized String sendAgvTaskHjJson(AgvTask agvTasks) {
|
||||
public String sendAgvTaskHjJson(AgvTask agvTasks) {
|
||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||
|
||||
Map<String, Object> objMap = new LinkedHashMap<>();
|
||||
|
|
@ -260,7 +260,7 @@ public class KMReServiceImpl implements KMReService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized String sendAgvTaskGtJson(AgvTask agvTask) {
|
||||
public String sendAgvTaskGtJson(AgvTask agvTask) {
|
||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||
Map<String, Object> objMap = new LinkedHashMap<>();
|
||||
objMap.put("orgId", agvTask.getId());//库存组织 ID(或工厂代码,供应商代码)
|
||||
|
|
@ -321,7 +321,7 @@ public class KMReServiceImpl implements KMReService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized void sendAgvTask(AgvTask agvTasks, String json) {
|
||||
public void sendAgvTask(AgvTask agvTasks, String json) {
|
||||
Dict dict = dictRepository.findDictByName("OPEN");
|
||||
String resultJson = "";
|
||||
if (dict != null) {
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ public class MesServiceImpl implements MesService {
|
|||
return pickDetail;
|
||||
}
|
||||
|
||||
private synchronized void moveCpOffUp(String pointCode) {
|
||||
private void moveCpOffUp(String pointCode) {
|
||||
// 从成品入库缓存区查询空车;没有在从成品入库区查询空车;
|
||||
List<Stock> emptyStockList = stockService.findByFreeOrUsedStock(AreaNameDic.CPRKHCQ, BaseStatus.FREE);
|
||||
if (emptyStockList.isEmpty()) {
|
||||
|
|
@ -273,12 +273,14 @@ public class MesServiceImpl implements MesService {
|
|||
//创建Agv任务
|
||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Up, emptyStock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
||||
// 更新点位状态
|
||||
synchronized (this) {
|
||||
pointService.usedPoint(endPoint);
|
||||
}
|
||||
//下发任务
|
||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskHjJson(agvTask));
|
||||
}
|
||||
|
||||
private synchronized void moveCpOffLine(TransTask transTask) {
|
||||
private void moveCpOffLine(TransTask transTask) {
|
||||
//查询下线缓存区是否有满货架;
|
||||
List<Stock> fullStockList = stockService.findByFreeOrUsedStock(AreaNameDic.CPXXHC, BaseStatus.USED);
|
||||
if (!fullStockList.isEmpty()) {
|
||||
|
|
@ -294,10 +296,13 @@ public class MesServiceImpl implements MesService {
|
|||
if (agvTaskService.findByEndSlotCode(endPoint.getCode(), BizStatus.Cp_Off_Line, "RACK_MOVE")) {
|
||||
//创建Agv任务
|
||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Line, fullStock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
||||
synchronized (this) {
|
||||
// 更新点位状态
|
||||
pointService.usedPoint(endPoint);
|
||||
//占用容器
|
||||
stockService.usedStock(fullStock, srcPoint, BaseStatus.USED);
|
||||
}
|
||||
|
||||
//下发任务
|
||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskHjJson(agvTask));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized void allocatePick(Pick pick) {
|
||||
public void allocatePick(Pick pick) {
|
||||
|
||||
//目标库位
|
||||
Point endPoint = null;
|
||||
|
|
@ -192,6 +192,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
/* 更新出库单状态*/
|
||||
synchronized (this) {
|
||||
pickService.refreshPickStatus(pick);
|
||||
|
||||
if (BizStatus.ALLOCATE.equals(pick.getStatus()) || BizStatus.ASSIGN.equals(pick.getStatus())) {
|
||||
|
|
@ -202,6 +203,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
//占用点位
|
||||
pointService.usedPoint(endPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//保存日志
|
||||
|
|
@ -213,6 +215,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
public void materialPick(Pick pick) {
|
||||
AgvTask agvTask = null;
|
||||
List<Task> taskList = this.findByPickNotAllTask(pick.getId());
|
||||
synchronized (this) {
|
||||
for (Task task : taskList) {
|
||||
/*生成搬运任务*/
|
||||
List<AgvTask> agvTaskList = agvTaskService.findRepeat(task.getSrcStockCode(), task.getSrcPointCode(), task.getDstPointCode());
|
||||
|
|
@ -233,11 +236,16 @@ public class TaskServiceImpl implements TaskService {
|
|||
/* //叫料区是否有空车,呼叫到备料缓存区
|
||||
this.callEmptyStock(task.getPickDetail().getItem().getGoodType());*/
|
||||
}
|
||||
}
|
||||
|
||||
/*更新出库单状态*/
|
||||
synchronized (this) {
|
||||
pick.setStatus(BizStatus.PICKUP);
|
||||
pickService.update(pick);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void callEmptyStock(String goodType) {
|
||||
|
|
@ -268,13 +276,14 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
//终点占用
|
||||
synchronized (this) {
|
||||
pointService.usedPoint(endPoint);
|
||||
}
|
||||
|
||||
//创建任务
|
||||
agvTaskService.createAgvTask(BizStatus.CALL_RETURN, stock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -286,7 +295,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
if (pick.getCallPoint() == null) {
|
||||
throw new BadRequestException(pick.getGdCode() + "工单没有叫料请求!");
|
||||
}
|
||||
|
||||
//起点
|
||||
Point srcPoint = pick.getStock().getPoint();
|
||||
|
||||
|
|
@ -303,6 +311,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
//绑定任务
|
||||
List<Task> taskList = this.findByPickAllTask(pick.getId());
|
||||
synchronized (this) {
|
||||
for (Task task : taskList) {
|
||||
task.setCallAgvTaskId(agvTask.getId());
|
||||
taskRepository.save(task);
|
||||
|
|
@ -319,9 +328,11 @@ public class TaskServiceImpl implements TaskService {
|
|||
pickService.update(pick);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized String allocate(long id, double quantity, Point endPoint) {
|
||||
public String allocate(long id, double quantity, Point endPoint) {
|
||||
//出库明细
|
||||
PickDetail pickDetail = pickDetailService.findById(id);
|
||||
|
||||
|
|
@ -343,6 +354,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
//未分配数量
|
||||
double unQty = quantity;
|
||||
Set<String> tps = new HashSet<>();
|
||||
synchronized (this) {
|
||||
for (Inventory inv : inventoryList) {
|
||||
//判断托盘是否有任务
|
||||
if (this.existsByStock(pick.getCode(), inv.getStockCode()) >= 1) {
|
||||
|
|
@ -374,6 +386,8 @@ public class TaskServiceImpl implements TaskService {
|
|||
this.createTask(item, allocateQty, inv.getItemKey(), null, BizStatus.PICK, pickDetail, inv.getId(), inv.getStock(), startPoint, endPoint, null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (tps.isEmpty()) {
|
||||
return pick.getCode() + "出库单中" + item.getCode() + "物料分配成功!";
|
||||
}
|
||||
|
|
@ -382,9 +396,10 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized void cancelAllocate(long id, double quantity) {
|
||||
public void cancelAllocate(long id, double quantity) {
|
||||
PickDetail pd = pickDetailService.findById(id);
|
||||
List<Task> tasks = this.findByPickDetailNotAllTask(id);
|
||||
synchronized (this) {
|
||||
for (Task task : tasks) {
|
||||
//根据task找到对应的库存
|
||||
Inventory inv = inventoryService.findById(task.getInvId());
|
||||
|
|
@ -401,23 +416,26 @@ public class TaskServiceImpl implements TaskService {
|
|||
pickDetailService.update(pd);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized void pickConfirm(Long taskId, double pickedQuantity) {
|
||||
public void pickConfirm(Long taskId, double pickedQuantity) {
|
||||
Task task = this.findById(taskId);
|
||||
if (task.getInvId() == null) {
|
||||
throw new BadRequestException("未找到库存相应记录!");
|
||||
}
|
||||
if (task.getPlanQty() > task.getMoveQty()) {
|
||||
PickDetail pickDetail = task.getPickDetail();
|
||||
Inventory inv = inventoryService.findById(task.getInvId());
|
||||
synchronized (this) {
|
||||
task.setMoveQty(pickedQuantity);
|
||||
task.setTaskStatus(BizStatus.FINISH);
|
||||
taskRepository.save(task);
|
||||
|
||||
if (task.getInvId() == null) {
|
||||
throw new BadRequestException("未找到库存相应记录!");
|
||||
}
|
||||
Inventory inv = inventoryService.findById(task.getInvId());
|
||||
inv.setQuantity(inv.getQuantity() - pickedQuantity);
|
||||
inv.setQueuedQty(inv.getQueuedQty() - pickedQuantity);
|
||||
inventoryService.update(inv);
|
||||
|
|
@ -429,9 +447,6 @@ public class TaskServiceImpl implements TaskService {
|
|||
inventoryService.deleteAll(new Long[]{inv.getId()});
|
||||
}
|
||||
|
||||
//添加库存日志
|
||||
inventoryLogService.createInventoryLog(BizStatus.PICK_DOWN, BizStatus.REDUCE, task.getPickDetail().getPo(), task.getItemKey(), task.getSrcPoint(), task.getDstPoint(), task.getSrcStock(), task.getDstStock(), inv.getQuantity(), pickedQuantity, BizStatus.PICK, task.getId(), inv.getId(), "");
|
||||
|
||||
//回写拣货数量
|
||||
pickDetail.setPickedQty(pickDetail.getPickedQty() + pickedQuantity);
|
||||
pickDetailService.update(pickDetail);
|
||||
|
|
@ -440,12 +455,17 @@ public class TaskServiceImpl implements TaskService {
|
|||
pickService.refreshPickStatus(pickDetail.getPick());
|
||||
}
|
||||
|
||||
//添加库存日志
|
||||
inventoryLogService.createInventoryLog(BizStatus.PICK_DOWN, BizStatus.REDUCE, task.getPickDetail().getPo(), task.getItemKey(), task.getSrcPoint(), task.getDstPoint(), task.getSrcStock(), task.getDstStock(), inv.getQuantity(), pickedQuantity, BizStatus.PICK, task.getId(), inv.getId(), "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized void pickBarBack(long taskId, double pickedQuantity) {
|
||||
public void pickBarBack(long taskId, double pickedQuantity) {
|
||||
Task task = findById(taskId);
|
||||
PickDetail pickDetail = task.getPickDetail();
|
||||
if (task.getInvId() == null) {
|
||||
|
|
@ -455,13 +475,11 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
//退回库存
|
||||
double srcQty = inv.getQueuedQty();
|
||||
synchronized (this) {
|
||||
inv.setQueuedQty(inv.getQueuedQty() + pickedQuantity);
|
||||
inv.setQuantity(inv.getQuantity() + pickedQuantity);
|
||||
inventoryService.update(inv);
|
||||
|
||||
//添加库存日志
|
||||
inventoryLogService.createInventoryLog(BizStatus.PICK_CANCEL, BizStatus.ADD, task.getPickDetail().getPo(), task.getItemKey(), task.getDstPoint(), task.getSrcPoint(), task.getSrcStock(), task.getDstStock(), srcQty, pickedQuantity, BizStatus.PICK, task.getId(), inv.getId(), "");
|
||||
|
||||
|
||||
//退回Task
|
||||
task.setMoveQty(task.getMoveQty() - pickedQuantity);
|
||||
|
|
@ -473,10 +491,14 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
//更新出库单状态
|
||||
pickService.refreshPickStatus(pickDetail.getPick());
|
||||
|
||||
}
|
||||
//添加库存日志
|
||||
inventoryLogService.createInventoryLog(BizStatus.PICK_CANCEL, BizStatus.ADD, task.getPickDetail().getPo(), task.getItemKey(), task.getDstPoint(), task.getSrcPoint(), task.getSrcStock(), task.getDstStock(), srcQty, pickedQuantity, BizStatus.PICK, task.getId(), inv.getId(), "");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Task createTask(Item item, Double quantity, ItemKey itemKey, AsnDetail asnDetail, String taskType, PickDetail pickDetail, Long invId, Stock stock, Point srcPoint, Point dstPoint, AgvTask agvTask) {
|
||||
Task task = new Task();
|
||||
task.setItem(item);
|
||||
|
|
@ -515,6 +537,8 @@ public class TaskServiceImpl implements TaskService {
|
|||
throw new BadRequestException(orderNumber + "箱号库存数量不足,请更换箱号!");
|
||||
}
|
||||
Inventory srcinventory = inventoryService.findById(task.getInvId());
|
||||
synchronized (srcinventory) {
|
||||
synchronized (dstinventory) {
|
||||
srcinventory.setQueuedQty(srcinventory.getQueuedQty() - task.getPlanQty());
|
||||
inventoryService.update(srcinventory);
|
||||
dstinventory.setQueuedQty(dstinventory.getQueuedQty() + task.getPlanQty());
|
||||
|
|
@ -522,6 +546,8 @@ public class TaskServiceImpl implements TaskService {
|
|||
task.setInvId(dstinventory.getId());
|
||||
task.setItemKey(dstinventory.getItemKey());
|
||||
taskRepository.save(task);
|
||||
}
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
|
|
@ -530,10 +556,17 @@ public class TaskServiceImpl implements TaskService {
|
|||
public void moveInventory(Task task, Stock dstStock, double moveQty) {
|
||||
//将占用数量移位,原库存回库内
|
||||
Inventory inventory = inventoryService.findById(task.getInvId());
|
||||
synchronized (inventory) {
|
||||
inventory.setQueuedQty(inventory.getQueuedQty() - moveQty);
|
||||
inventory.setQuantity(inventory.getQuantity() - moveQty);
|
||||
inventoryService.update(inventory);
|
||||
|
||||
//删除库存
|
||||
if (inventory.getQuantity() <= 0) {
|
||||
inventoryService.deleteAll(new Long[]{inventory.getId()});
|
||||
}
|
||||
}
|
||||
|
||||
//生成新库存
|
||||
Inventory newInventory = inventoryService.createInventory(inventory.getItemKey(), dstStock.getPoint(), dstStock, inventory.getDept(), moveQty);
|
||||
|
||||
|
|
@ -549,13 +582,11 @@ public class TaskServiceImpl implements TaskService {
|
|||
pickDetail.setPickedQty(pickDetail.getPickedQty() + moveQty);
|
||||
pickDetailService.update(pickDetail);
|
||||
|
||||
//删除库存
|
||||
if (inventory.getQuantity() <= 0) {
|
||||
inventoryService.deleteAll(new Long[]{inventory.getId()});
|
||||
}
|
||||
|
||||
//容器占用
|
||||
synchronized (dstStock) {
|
||||
stockService.usedStock(dstStock, dstStock.getPoint(), BaseStatus.USED);
|
||||
}
|
||||
|
||||
//库存日志
|
||||
inventoryLogService.createInventoryLog(BizStatus.MOVE, BizStatus.ADD, task.getPickDetail().getPo(), task.getItemKey(), task.getDstPoint(), dstStock.getPoint(), task.getSrcStock(), dstStock, 0d, moveQty, BizStatus.PICK, task.getId(), newInventory.getId(), "");
|
||||
|
|
|
|||
Loading…
Reference in New Issue