no message
parent
e5cd7979ad
commit
755b86ace9
|
|
@ -153,7 +153,7 @@ public class KMReServiceImpl implements KMReService {
|
||||||
* @param json 接口json
|
* @param json 接口json
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void sendAgvTaskToContainer(String url, String json) {
|
public void sendAgvTaskToContainer(String url, String json) {
|
||||||
Dict dict = dictRepository.findDictByDescription("OPEN");
|
Dict dict = dictRepository.findDictByDescription("OPEN");
|
||||||
if (dict != null) {
|
if (dict != null) {
|
||||||
String resultJson = HttpPostUtil.sendPostReq(url, json);
|
String resultJson = HttpPostUtil.sendPostReq(url, json);
|
||||||
|
|
@ -179,7 +179,7 @@ public class KMReServiceImpl implements KMReService {
|
||||||
* @param agvTasks 任务
|
* @param agvTasks 任务
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized String sendAgvTaskCcJson(AgvTask agvTasks) {
|
public String sendAgvTaskCcJson(AgvTask agvTasks) {
|
||||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||||
|
|
||||||
Map<String, Object> objMap = new LinkedHashMap<>();
|
Map<String, Object> objMap = new LinkedHashMap<>();
|
||||||
|
|
@ -231,7 +231,7 @@ public class KMReServiceImpl implements KMReService {
|
||||||
* @param agvTasks 任务
|
* @param agvTasks 任务
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized String sendAgvTaskHjJson(AgvTask agvTasks) {
|
public String sendAgvTaskHjJson(AgvTask agvTasks) {
|
||||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||||
|
|
||||||
Map<String, Object> objMap = new LinkedHashMap<>();
|
Map<String, Object> objMap = new LinkedHashMap<>();
|
||||||
|
|
@ -260,7 +260,7 @@ public class KMReServiceImpl implements KMReService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized String sendAgvTaskGtJson(AgvTask agvTask) {
|
public String sendAgvTaskGtJson(AgvTask agvTask) {
|
||||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||||
Map<String, Object> objMap = new LinkedHashMap<>();
|
Map<String, Object> objMap = new LinkedHashMap<>();
|
||||||
objMap.put("orgId", agvTask.getId());//库存组织 ID(或工厂代码,供应商代码)
|
objMap.put("orgId", agvTask.getId());//库存组织 ID(或工厂代码,供应商代码)
|
||||||
|
|
@ -321,7 +321,7 @@ public class KMReServiceImpl implements KMReService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void sendAgvTask(AgvTask agvTasks, String json) {
|
public void sendAgvTask(AgvTask agvTasks, String json) {
|
||||||
Dict dict = dictRepository.findDictByName("OPEN");
|
Dict dict = dictRepository.findDictByName("OPEN");
|
||||||
String resultJson = "";
|
String resultJson = "";
|
||||||
if (dict != null) {
|
if (dict != null) {
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ public class MesServiceImpl implements MesService {
|
||||||
return pickDetail;
|
return pickDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void moveCpOffUp(String pointCode) {
|
private void moveCpOffUp(String pointCode) {
|
||||||
// 从成品入库缓存区查询空车;没有在从成品入库区查询空车;
|
// 从成品入库缓存区查询空车;没有在从成品入库区查询空车;
|
||||||
List<Stock> emptyStockList = stockService.findByFreeOrUsedStock(AreaNameDic.CPRKHCQ, BaseStatus.FREE);
|
List<Stock> emptyStockList = stockService.findByFreeOrUsedStock(AreaNameDic.CPRKHCQ, BaseStatus.FREE);
|
||||||
if (emptyStockList.isEmpty()) {
|
if (emptyStockList.isEmpty()) {
|
||||||
|
|
@ -273,12 +273,14 @@ public class MesServiceImpl implements MesService {
|
||||||
//创建Agv任务
|
//创建Agv任务
|
||||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Up, emptyStock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Up, emptyStock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
||||||
// 更新点位状态
|
// 更新点位状态
|
||||||
pointService.usedPoint(endPoint);
|
synchronized (this) {
|
||||||
|
pointService.usedPoint(endPoint);
|
||||||
|
}
|
||||||
//下发任务
|
//下发任务
|
||||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskHjJson(agvTask));
|
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);
|
List<Stock> fullStockList = stockService.findByFreeOrUsedStock(AreaNameDic.CPXXHC, BaseStatus.USED);
|
||||||
if (!fullStockList.isEmpty()) {
|
if (!fullStockList.isEmpty()) {
|
||||||
|
|
@ -294,10 +296,13 @@ public class MesServiceImpl implements MesService {
|
||||||
if (agvTaskService.findByEndSlotCode(endPoint.getCode(), BizStatus.Cp_Off_Line, "RACK_MOVE")) {
|
if (agvTaskService.findByEndSlotCode(endPoint.getCode(), BizStatus.Cp_Off_Line, "RACK_MOVE")) {
|
||||||
//创建Agv任务
|
//创建Agv任务
|
||||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Line, fullStock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.Cp_Off_Line, fullStock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
||||||
// 更新点位状态
|
synchronized (this) {
|
||||||
pointService.usedPoint(endPoint);
|
// 更新点位状态
|
||||||
//占用容器
|
pointService.usedPoint(endPoint);
|
||||||
stockService.usedStock(fullStock, srcPoint, BaseStatus.USED);
|
//占用容器
|
||||||
|
stockService.usedStock(fullStock, srcPoint, BaseStatus.USED);
|
||||||
|
}
|
||||||
|
|
||||||
//下发任务
|
//下发任务
|
||||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskHjJson(agvTask));
|
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskHjJson(agvTask));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public synchronized void allocatePick(Pick pick) {
|
public void allocatePick(Pick pick) {
|
||||||
|
|
||||||
//目标库位
|
//目标库位
|
||||||
Point endPoint = null;
|
Point endPoint = null;
|
||||||
|
|
@ -192,15 +192,17 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 更新出库单状态*/
|
/* 更新出库单状态*/
|
||||||
pickService.refreshPickStatus(pick);
|
synchronized (this) {
|
||||||
|
pickService.refreshPickStatus(pick);
|
||||||
|
|
||||||
if (BizStatus.ALLOCATE.equals(pick.getStatus()) || BizStatus.ASSIGN.equals(pick.getStatus())) {
|
if (BizStatus.ALLOCATE.equals(pick.getStatus()) || BizStatus.ASSIGN.equals(pick.getStatus())) {
|
||||||
//绑定点位
|
//绑定点位
|
||||||
pick.setPoint(endPoint);
|
pick.setPoint(endPoint);
|
||||||
pickService.update(pick);
|
pickService.update(pick);
|
||||||
|
|
||||||
//占用点位
|
//占用点位
|
||||||
pointService.usedPoint(endPoint);
|
pointService.usedPoint(endPoint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -213,29 +215,35 @@ public class TaskServiceImpl implements TaskService {
|
||||||
public void materialPick(Pick pick) {
|
public void materialPick(Pick pick) {
|
||||||
AgvTask agvTask = null;
|
AgvTask agvTask = null;
|
||||||
List<Task> taskList = this.findByPickNotAllTask(pick.getId());
|
List<Task> taskList = this.findByPickNotAllTask(pick.getId());
|
||||||
for (Task task : taskList) {
|
synchronized (this) {
|
||||||
/*生成搬运任务*/
|
for (Task task : taskList) {
|
||||||
List<AgvTask> agvTaskList = agvTaskService.findRepeat(task.getSrcStockCode(), task.getSrcPointCode(), task.getDstPointCode());
|
/*生成搬运任务*/
|
||||||
if (agvTaskList.isEmpty()) {
|
List<AgvTask> agvTaskList = agvTaskService.findRepeat(task.getSrcStockCode(), task.getSrcPointCode(), task.getDstPointCode());
|
||||||
//创建任务
|
if (agvTaskList.isEmpty()) {
|
||||||
agvTask = agvTaskService.createAgvTask(BizStatus.PICK, task.getSrcStock(), task.getSrcPoint().getCode(), task.getDstPoint().getCode(), "FORKLIFT_MOVE");
|
//创建任务
|
||||||
|
agvTask = agvTaskService.createAgvTask(BizStatus.PICK, task.getSrcStock(), task.getSrcPoint().getCode(), task.getDstPoint().getCode(), "FORKLIFT_MOVE");
|
||||||
|
|
||||||
//终点占用
|
//终点占用
|
||||||
pointService.usedPoint(task.getDstPoint());
|
pointService.usedPoint(task.getDstPoint());
|
||||||
} else {
|
} else {
|
||||||
agvTask = agvTaskList.get(0);
|
agvTask = agvTaskList.get(0);
|
||||||
}
|
}
|
||||||
task.setAgvTask(agvTask);
|
task.setAgvTask(agvTask);
|
||||||
task.setTaskStatus(agvTask.getStatus());
|
task.setTaskStatus(agvTask.getStatus());
|
||||||
taskRepository.save(task);
|
taskRepository.save(task);
|
||||||
|
|
||||||
|
|
||||||
/* //叫料区是否有空车,呼叫到备料缓存区
|
/* //叫料区是否有空车,呼叫到备料缓存区
|
||||||
this.callEmptyStock(task.getPickDetail().getItem().getGoodType());*/
|
this.callEmptyStock(task.getPickDetail().getItem().getGoodType());*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*更新出库单状态*/
|
/*更新出库单状态*/
|
||||||
pick.setStatus(BizStatus.PICKUP);
|
synchronized (this) {
|
||||||
pickService.update(pick);
|
pick.setStatus(BizStatus.PICKUP);
|
||||||
|
pickService.update(pick);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -263,18 +271,19 @@ public class TaskServiceImpl implements TaskService {
|
||||||
Point endPoint = pointList.get(0);
|
Point endPoint = pointList.get(0);
|
||||||
|
|
||||||
//有任务则直接返回
|
//有任务则直接返回
|
||||||
if(!agvTaskService.findByEndSlotCode(endPoint.getCode(),BizStatus.CALL_RETURN,"RACK_MOVE")){
|
if (!agvTaskService.findByEndSlotCode(endPoint.getCode(), BizStatus.CALL_RETURN, "RACK_MOVE")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//终点占用
|
//终点占用
|
||||||
pointService.usedPoint(endPoint);
|
synchronized (this) {
|
||||||
|
pointService.usedPoint(endPoint);
|
||||||
|
}
|
||||||
|
|
||||||
//创建任务
|
//创建任务
|
||||||
agvTaskService.createAgvTask(BizStatus.CALL_RETURN, stock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
agvTaskService.createAgvTask(BizStatus.CALL_RETURN, stock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -286,7 +295,6 @@ public class TaskServiceImpl implements TaskService {
|
||||||
if (pick.getCallPoint() == null) {
|
if (pick.getCallPoint() == null) {
|
||||||
throw new BadRequestException(pick.getGdCode() + "工单没有叫料请求!");
|
throw new BadRequestException(pick.getGdCode() + "工单没有叫料请求!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//起点
|
//起点
|
||||||
Point srcPoint = pick.getStock().getPoint();
|
Point srcPoint = pick.getStock().getPoint();
|
||||||
|
|
||||||
|
|
@ -303,25 +311,28 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
//绑定任务
|
//绑定任务
|
||||||
List<Task> taskList = this.findByPickAllTask(pick.getId());
|
List<Task> taskList = this.findByPickAllTask(pick.getId());
|
||||||
for (Task task : taskList) {
|
synchronized (this) {
|
||||||
task.setCallAgvTaskId(agvTask.getId());
|
for (Task task : taskList) {
|
||||||
taskRepository.save(task);
|
task.setCallAgvTaskId(agvTask.getId());
|
||||||
|
taskRepository.save(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
//起点占用
|
||||||
|
pointService.usedPoint(srcPoint);
|
||||||
|
|
||||||
|
//终点占用
|
||||||
|
pointService.usedPoint(endPoint);
|
||||||
|
|
||||||
|
//更新出库单状态为叫料中
|
||||||
|
pick.setStatus(BizStatus.SHIP_PART);
|
||||||
|
pickService.update(pick);
|
||||||
}
|
}
|
||||||
|
|
||||||
//起点占用
|
|
||||||
pointService.usedPoint(srcPoint);
|
|
||||||
|
|
||||||
//终点占用
|
|
||||||
pointService.usedPoint(endPoint);
|
|
||||||
|
|
||||||
//更新出库单状态为叫料中
|
|
||||||
pick.setStatus(BizStatus.SHIP_PART);
|
|
||||||
pickService.update(pick);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@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);
|
PickDetail pickDetail = pickDetailService.findById(id);
|
||||||
|
|
||||||
|
|
@ -343,37 +354,40 @@ public class TaskServiceImpl implements TaskService {
|
||||||
//未分配数量
|
//未分配数量
|
||||||
double unQty = quantity;
|
double unQty = quantity;
|
||||||
Set<String> tps = new HashSet<>();
|
Set<String> tps = new HashSet<>();
|
||||||
for (Inventory inv : inventoryList) {
|
synchronized (this) {
|
||||||
//判断托盘是否有任务
|
for (Inventory inv : inventoryList) {
|
||||||
if (this.existsByStock(pick.getCode(), inv.getStockCode()) >= 1) {
|
//判断托盘是否有任务
|
||||||
tps.add(inv.getStockCode());
|
if (this.existsByStock(pick.getCode(), inv.getStockCode()) >= 1) {
|
||||||
continue;
|
tps.add(inv.getStockCode());
|
||||||
}
|
continue;
|
||||||
//起点
|
}
|
||||||
Point startPoint = inv.getPoint();
|
//起点
|
||||||
if (unQty == 0) {
|
Point startPoint = inv.getPoint();
|
||||||
break;
|
if (unQty == 0) {
|
||||||
}
|
break;
|
||||||
//库存可用数量
|
}
|
||||||
allocateQty = inv.getQuantity() - inv.getQueuedQty();
|
//库存可用数量
|
||||||
if (allocateQty <= 0) {
|
allocateQty = inv.getQuantity() - inv.getQueuedQty();
|
||||||
continue;
|
if (allocateQty <= 0) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unQty < allocateQty) {
|
||||||
|
allocateQty = unQty;
|
||||||
|
}
|
||||||
|
inv.setQueuedQty(inv.getQueuedQty() + allocateQty);
|
||||||
|
inventoryService.update(inv);
|
||||||
|
unQty -= allocateQty;
|
||||||
|
/* 更新出库单明细状态*/
|
||||||
|
pickDetail.setAllocatedQty(pickDetail.getAllocatedQty() + allocateQty);
|
||||||
|
pickDetailService.update(pickDetail);
|
||||||
|
|
||||||
|
//生成Task任务
|
||||||
|
this.createTask(item, allocateQty, inv.getItemKey(), null, BizStatus.PICK, pickDetail, inv.getId(), inv.getStock(), startPoint, endPoint, null);
|
||||||
|
|
||||||
if (unQty < allocateQty) {
|
|
||||||
allocateQty = unQty;
|
|
||||||
}
|
}
|
||||||
inv.setQueuedQty(inv.getQueuedQty() + allocateQty);
|
|
||||||
inventoryService.update(inv);
|
|
||||||
unQty -= allocateQty;
|
|
||||||
/* 更新出库单明细状态*/
|
|
||||||
pickDetail.setAllocatedQty(pickDetail.getAllocatedQty() + allocateQty);
|
|
||||||
pickDetailService.update(pickDetail);
|
|
||||||
|
|
||||||
//生成Task任务
|
|
||||||
this.createTask(item, allocateQty, inv.getItemKey(), null, BizStatus.PICK, pickDetail, inv.getId(), inv.getStock(), startPoint, endPoint, null);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tps.isEmpty()) {
|
if (tps.isEmpty()) {
|
||||||
return pick.getCode() + "出库单中" + item.getCode() + "物料分配成功!";
|
return pick.getCode() + "出库单中" + item.getCode() + "物料分配成功!";
|
||||||
}
|
}
|
||||||
|
|
@ -382,62 +396,68 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public synchronized void cancelAllocate(long id, double quantity) {
|
public void cancelAllocate(long id, double quantity) {
|
||||||
PickDetail pd = pickDetailService.findById(id);
|
PickDetail pd = pickDetailService.findById(id);
|
||||||
List<Task> tasks = this.findByPickDetailNotAllTask(id);
|
List<Task> tasks = this.findByPickDetailNotAllTask(id);
|
||||||
for (Task task : tasks) {
|
synchronized (this) {
|
||||||
//根据task找到对应的库存
|
for (Task task : tasks) {
|
||||||
Inventory inv = inventoryService.findById(task.getInvId());
|
//根据task找到对应的库存
|
||||||
inv.setQueuedQty(inv.getQueuedQty() - pd.getAllocatedQty());
|
Inventory inv = inventoryService.findById(task.getInvId());
|
||||||
inventoryService.update(inv);
|
inv.setQueuedQty(inv.getQueuedQty() - pd.getAllocatedQty());
|
||||||
|
inventoryService.update(inv);
|
||||||
|
|
||||||
//删除Task
|
//删除Task
|
||||||
taskRepository.delete(task);
|
taskRepository.delete(task);
|
||||||
|
|
||||||
|
pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
|
||||||
|
if (pd.getAllocatedQty() == 0) {
|
||||||
|
pd.setStatus(BizStatus.OPEN);
|
||||||
|
}
|
||||||
|
pickDetailService.update(pd);
|
||||||
|
|
||||||
pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
|
|
||||||
if (pd.getAllocatedQty() == 0) {
|
|
||||||
pd.setStatus(BizStatus.OPEN);
|
|
||||||
}
|
}
|
||||||
pickDetailService.update(pd);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public synchronized void pickConfirm(Long taskId, double pickedQuantity) {
|
public void pickConfirm(Long taskId, double pickedQuantity) {
|
||||||
Task task = this.findById(taskId);
|
Task task = this.findById(taskId);
|
||||||
|
if (task.getInvId() == null) {
|
||||||
|
throw new BadRequestException("未找到库存相应记录!");
|
||||||
|
}
|
||||||
if (task.getPlanQty() > task.getMoveQty()) {
|
if (task.getPlanQty() > task.getMoveQty()) {
|
||||||
PickDetail pickDetail = task.getPickDetail();
|
PickDetail pickDetail = task.getPickDetail();
|
||||||
task.setMoveQty(pickedQuantity);
|
|
||||||
task.setTaskStatus(BizStatus.FINISH);
|
|
||||||
taskRepository.save(task);
|
|
||||||
|
|
||||||
if (task.getInvId() == null) {
|
|
||||||
throw new BadRequestException("未找到库存相应记录!");
|
|
||||||
}
|
|
||||||
Inventory inv = inventoryService.findById(task.getInvId());
|
Inventory inv = inventoryService.findById(task.getInvId());
|
||||||
inv.setQuantity(inv.getQuantity() - pickedQuantity);
|
synchronized (this) {
|
||||||
inv.setQueuedQty(inv.getQueuedQty() - pickedQuantity);
|
task.setMoveQty(pickedQuantity);
|
||||||
inventoryService.update(inv);
|
task.setTaskStatus(BizStatus.FINISH);
|
||||||
|
taskRepository.save(task);
|
||||||
|
|
||||||
//释放容器
|
inv.setQuantity(inv.getQuantity() - pickedQuantity);
|
||||||
stockService.usedStock(inv.getStock(), inv.getPoint(), BaseStatus.FREE);
|
inv.setQueuedQty(inv.getQueuedQty() - pickedQuantity);
|
||||||
|
inventoryService.update(inv);
|
||||||
|
|
||||||
if (inv.getQuantity() <= 0) {
|
//释放容器
|
||||||
inventoryService.deleteAll(new Long[]{inv.getId()});
|
stockService.usedStock(inv.getStock(), inv.getPoint(), BaseStatus.FREE);
|
||||||
|
|
||||||
|
if (inv.getQuantity() <= 0) {
|
||||||
|
inventoryService.deleteAll(new Long[]{inv.getId()});
|
||||||
|
}
|
||||||
|
|
||||||
|
//回写拣货数量
|
||||||
|
pickDetail.setPickedQty(pickDetail.getPickedQty() + pickedQuantity);
|
||||||
|
pickDetailService.update(pickDetail);
|
||||||
|
|
||||||
|
//刷新状态
|
||||||
|
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(), "");
|
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);
|
|
||||||
|
|
||||||
//刷新状态
|
|
||||||
pickService.refreshPickStatus(pickDetail.getPick());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -445,7 +465,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public synchronized void pickBarBack(long taskId, double pickedQuantity) {
|
public void pickBarBack(long taskId, double pickedQuantity) {
|
||||||
Task task = findById(taskId);
|
Task task = findById(taskId);
|
||||||
PickDetail pickDetail = task.getPickDetail();
|
PickDetail pickDetail = task.getPickDetail();
|
||||||
if (task.getInvId() == null) {
|
if (task.getInvId() == null) {
|
||||||
|
|
@ -455,28 +475,30 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
//退回库存
|
//退回库存
|
||||||
double srcQty = inv.getQueuedQty();
|
double srcQty = inv.getQueuedQty();
|
||||||
inv.setQueuedQty(inv.getQueuedQty() + pickedQuantity);
|
synchronized (this) {
|
||||||
inv.setQuantity(inv.getQuantity() + pickedQuantity);
|
inv.setQueuedQty(inv.getQueuedQty() + pickedQuantity);
|
||||||
inventoryService.update(inv);
|
inv.setQuantity(inv.getQuantity() + pickedQuantity);
|
||||||
|
inventoryService.update(inv);
|
||||||
|
|
||||||
|
|
||||||
|
//退回Task
|
||||||
|
task.setMoveQty(task.getMoveQty() - pickedQuantity);
|
||||||
|
taskRepository.save(task);
|
||||||
|
|
||||||
|
//退回拣货数量
|
||||||
|
pickDetail.setPickedQty(pickDetail.getPickedQty() - pickedQuantity);
|
||||||
|
pickDetailService.update(pickDetail);
|
||||||
|
|
||||||
|
//更新出库单状态
|
||||||
|
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(), "");
|
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);
|
|
||||||
taskRepository.save(task);
|
|
||||||
|
|
||||||
//退回拣货数量
|
|
||||||
pickDetail.setPickedQty(pickDetail.getPickedQty() - pickedQuantity);
|
|
||||||
pickDetailService.update(pickDetail);
|
|
||||||
|
|
||||||
//更新出库单状态
|
|
||||||
pickService.refreshPickStatus(pickDetail.getPick());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
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 task = new Task();
|
||||||
task.setItem(item);
|
task.setItem(item);
|
||||||
|
|
@ -515,13 +537,17 @@ public class TaskServiceImpl implements TaskService {
|
||||||
throw new BadRequestException(orderNumber + "箱号库存数量不足,请更换箱号!");
|
throw new BadRequestException(orderNumber + "箱号库存数量不足,请更换箱号!");
|
||||||
}
|
}
|
||||||
Inventory srcinventory = inventoryService.findById(task.getInvId());
|
Inventory srcinventory = inventoryService.findById(task.getInvId());
|
||||||
srcinventory.setQueuedQty(srcinventory.getQueuedQty() - task.getPlanQty());
|
synchronized (srcinventory) {
|
||||||
inventoryService.update(srcinventory);
|
synchronized (dstinventory) {
|
||||||
dstinventory.setQueuedQty(dstinventory.getQueuedQty() + task.getPlanQty());
|
srcinventory.setQueuedQty(srcinventory.getQueuedQty() - task.getPlanQty());
|
||||||
inventoryService.update(dstinventory);
|
inventoryService.update(srcinventory);
|
||||||
task.setInvId(dstinventory.getId());
|
dstinventory.setQueuedQty(dstinventory.getQueuedQty() + task.getPlanQty());
|
||||||
task.setItemKey(dstinventory.getItemKey());
|
inventoryService.update(dstinventory);
|
||||||
taskRepository.save(task);
|
task.setInvId(dstinventory.getId());
|
||||||
|
task.setItemKey(dstinventory.getItemKey());
|
||||||
|
taskRepository.save(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -530,9 +556,16 @@ public class TaskServiceImpl implements TaskService {
|
||||||
public void moveInventory(Task task, Stock dstStock, double moveQty) {
|
public void moveInventory(Task task, Stock dstStock, double moveQty) {
|
||||||
//将占用数量移位,原库存回库内
|
//将占用数量移位,原库存回库内
|
||||||
Inventory inventory = inventoryService.findById(task.getInvId());
|
Inventory inventory = inventoryService.findById(task.getInvId());
|
||||||
inventory.setQueuedQty(inventory.getQueuedQty() - moveQty);
|
synchronized (inventory) {
|
||||||
inventory.setQuantity(inventory.getQuantity() - moveQty);
|
inventory.setQueuedQty(inventory.getQueuedQty() - moveQty);
|
||||||
inventoryService.update(inventory);
|
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);
|
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);
|
pickDetail.setPickedQty(pickDetail.getPickedQty() + moveQty);
|
||||||
pickDetailService.update(pickDetail);
|
pickDetailService.update(pickDetail);
|
||||||
|
|
||||||
//删除库存
|
|
||||||
if (inventory.getQuantity() <= 0) {
|
|
||||||
inventoryService.deleteAll(new Long[]{inventory.getId()});
|
|
||||||
}
|
|
||||||
|
|
||||||
//容器占用
|
//容器占用
|
||||||
stockService.usedStock(dstStock, dstStock.getPoint(), BaseStatus.USED);
|
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(), "");
|
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