出库AGV接口任务回调,删除库存,添加库存日志,更新Task,更新PickDetail

main
bbl\baobl 2024-03-12 18:22:44 +08:00
parent bb46759a8a
commit 7c61611963
6 changed files with 67 additions and 16 deletions

View File

@ -65,7 +65,8 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
*/
@Query(value = "SELECT t FROM Task t WHERE t.agvTask.id=?1 and t.taskStatus=?2")
List<Task> getAgvTaskList(Integer agvTaskId,String taskStatus);
@Query(value = "SELECT t FROM Task t WHERE t.agvTask.id=?1")
List<Task> getAgvTaskList(Integer agvTaskId);
/**
*
*/

View File

@ -104,4 +104,10 @@ public interface InventoryService {
* @return
*/
Inventory asnAddInventory(List<Map<String,Object>> taskListMap);
/**
*
* @param taskList
*/
void pickDelInventory(List<Task> taskList);
}

View File

@ -103,7 +103,7 @@ public interface PickDetailService {
/**
*
*/
void cancelAllocate(long id,double quantity) ;
ApiResult cancelAllocate(long id,double quantity) ;
ApiResult cancelAllocate(Long[] ids);
/**

View File

@ -465,7 +465,6 @@ public class AgvTaskServiceImpl implements AgvTaskService {
AgvTask agvTask=agvTaskRepository.getById(Integer.valueOf(taskCode));
// task库存任务
// List<Task> tasks=taskRepository.getAgvTaskList(agvTask.getId(),BizStatus.ASN);
List<Map<String,Object>> taskMapList=taskRepository.findByAgvTask(agvTask.getId(),"ASN",1l);
Point startPoint=null;
Point endPoint=null;
if (status.equals("1")){
@ -485,11 +484,19 @@ public class AgvTaskServiceImpl implements AgvTaskService {
pointRepository.save(endPoint);
agvTask.setStatus(BizStatus.FINISH);
agvTask.setEndTime(new Timestamp((new Date()).getTime()));
if (taskMapList.size()>0){
// 生成库存
Inventory inventory = inventoryService.asnAddInventory(taskMapList);
if (agvTask.getJobType().equals(BizStatus.ASN)) {
List<Map<String,Object>> taskMapList=taskRepository.findByAgvTask(agvTask.getId(),"ASN",1l);
if (taskMapList.size()>0) {
/** 入库任务回调 生成库存*/
Inventory inventory = inventoryService.asnAddInventory(taskMapList);
}
}
if (agvTask.getJobType().equals(BizStatus.PICK)) {
List<Task> taskList=taskRepository.getAgvTaskList(agvTask.getId());
/** 出库任务回调 生成删除库存*/
inventoryService.pickDelInventory(taskList);
}
} else if (status.equals("4")) {
// 取消任务
}
@ -679,10 +686,10 @@ public class AgvTaskServiceImpl implements AgvTaskService {
List<Task> taskList=taskRepository.findByItemType(BizStatus.RECEIVING,1,"SMGS");
for (int i = 0; i < taskList.size(); i++) {
Task task=taskList.get(i);
//新Task任务
//新Task任务
ApiResult success = taskService.getAsnTask(point, task);
if (success != null) return success;
AgvTask agvTask=addAgvTask("叉车搬运", "半成品托盘", task.getSrcPoint().getCode(), point.getCode(), BizStatus.OPEN, "ASN2");
AgvTask agvTask = addAgvTask(BizStatus.AGV, task.getSrcPoint().getStorageType(), task.getSrcPoint().getCode(),task.getDstPoint().getCode() , BizStatus.OPEN, BizStatus.ASN);
task.setAgvTask(agvTask);
taskRepository.save(task);
}

View File

@ -22,6 +22,7 @@ import com.youchain.basicdata.domain.Stock;
import com.youchain.basicdata.repository.PointRepository;
import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.repository.ItemKeyRepository;
import com.youchain.businessdata.repository.PickDetailRepository;
import com.youchain.businessdata.repository.TaskRepository;
import com.youchain.businessdata.service.InventoryLogService;
import com.youchain.businessdata.service.dto.*;
@ -61,6 +62,7 @@ public class InventoryServiceImpl implements InventoryService {
private final InventoryRepository inventoryRepository;
private final InventoryLogService inventoryLogService;
private final InventoryMapper inventoryMapper;
private final PickDetailRepository pickDetailRepository;
private final EntityManager entityManager;
private final ItemKeyRepository itemKeyRepository;
private final TaskRepository taskRepository;
@ -244,6 +246,29 @@ public class InventoryServiceImpl implements InventoryService {
return null;
}
@Override
public void pickDelInventory(List<Task> taskList) {
//删除库存
for (int i = 0; i < taskList.size(); i++) {
/** 书安心Task表*/
Task task=taskList.get(i);
task.setTaskStatus(BizStatus.PICK_ALL);
task.setMoveQty(task.getPlanQty());
taskRepository.save(task);
/** 刷新出库单明细表*/
PickDetail pickDetail=task.getPickDetail();
pickDetail.setPickedQty(task.getMoveQty());
if (pickDetail.getAllocatedQty()>=pickDetail.getPickedQty()){
pickDetail.setStatus(BizStatus.PICK_ALL);
}
pickDetailRepository.save(pickDetail);
/** 添加库存日志,删除库存*/
Inventory inventory=task.getInventory();
inventoryLogService.storeInventoryLog(BizStatus.PICK_DOWN,BizStatus.REDUCE,inventory.getItemKey().getPropC3(),inventory.getItemKey(),task.getSrcPoint(),task.getDstPoint(),null,null,inventory.getQuantity(),task.getMoveQty(), task.getItemKey().getPropC6(),null,inventory.getId(),"");
inventoryRepository.delete(inventory);
}
}
public List<Object[]> queryItemStock(){
String hql = "select inv.itemKey.item.code,max(inv.itemKey.item.name),count(inv.id) " +
" from Inventory inv where 1=1 and inv.quantity>0 group by inv.itemKey.item.code order by inv.itemKey.item.code";

View File

@ -188,7 +188,11 @@ public class PickDetailServiceImpl implements PickDetailService {
task.setDept(dept);
task.setInventory(inv);
taskRepository.save(task);
//生成AGV任务
AgvTask agvTask = agvTaskService.addAgvTask(BizStatus.AGV, startPoint.getStorageType(), startPoint.getCode(),endPoint.getCode() , BizStatus.OPEN, BizStatus.PICK);
//更新Task任务 写入关联AGV
task.setAgvTask(agvTask);
taskRepository.save(task);
}
}else {
return ApiResult.fail(500, item.getCode()+"料号,无库存", "");
@ -336,7 +340,7 @@ public class PickDetailServiceImpl implements PickDetailService {
@Override
@Transactional(rollbackFor = Exception.class)
public void cancelAllocate(long id, double quantity){
public ApiResult cancelAllocate(long id, double quantity){
PickDetailDto pickDetailDto = findById(id);
PickDetail pd = toEntity(pickDetailDto);
@ -346,7 +350,15 @@ public class PickDetailServiceImpl implements PickDetailService {
Inventory inv = inventoryRepository.findById(task.getInventory().getId()).get();
inv.setQueuedQty(inv.getQueuedQty() - task.getPlanQty());
inventoryRepository.save(inv);
//删除AgvTask任务
if (task.getAgvTask()!=null){
AgvTask agvTask=task.getAgvTask();
if (agvTask.getStatus().equals(BizStatus.OPEN)){
agvTaskRepository.delete(agvTask);
}else {
return ApiResult.fail(400, "搬运任务已执行", null);
}
}
//删除Task
taskRepository.delete(task);
@ -355,18 +367,18 @@ public class PickDetailServiceImpl implements PickDetailService {
pd.setStatus(BizStatus.OPEN);
}
pickDetailRepository.save(pd);
}
return ApiResult.fail(200, "操作成功", null);
}
@Override
public ApiResult cancelAllocate(Long[] ids) {
ApiResult apiResult=new ApiResult();
for (int i = 0; i < ids.length; i++) {
PickDetail pickDetail=pickDetailRepository.getById(ids[i]);
cancelAllocate(pickDetail.getId(), pickDetail.getOrderQty());
apiResult = cancelAllocate(pickDetail.getId(), pickDetail.getOrderQty());
}
return ApiResult.fail(200, "操作成功", "");
return apiResult;
}
@Override