no message
parent
46236c69d9
commit
b31e2f2e27
|
|
@ -70,14 +70,6 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
|
||||||
@Query("from Task t where t.pickDetail.id =:pickDetailId and t.planQty > t.moveQty")
|
@Query("from Task t where t.pickDetail.id =:pickDetailId and t.planQty > t.moveQty")
|
||||||
List<Task> findByPickDetailNotAllTask(Long pickDetailId);
|
List<Task> findByPickDetailNotAllTask(Long pickDetailId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据出库单明细查询已完成的Task集合
|
|
||||||
*
|
|
||||||
* @param pickDetailId 出库明细ID
|
|
||||||
*/
|
|
||||||
@Query("from Task t where t.pickDetail.id =:pickDetailId and t.planQty = t.moveQty")
|
|
||||||
List<Task> findByPickDetailAllTask(Long pickDetailId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询任务列表
|
* 查询任务列表
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import com.youchain.annotation.Log;
|
||||||
import com.youchain.businessdata.domain.Task;
|
import com.youchain.businessdata.domain.Task;
|
||||||
import com.youchain.businessdata.service.TaskService;
|
import com.youchain.businessdata.service.TaskService;
|
||||||
import com.youchain.businessdata.service.dto.TaskQueryCriteria;
|
import com.youchain.businessdata.service.dto.TaskQueryCriteria;
|
||||||
|
import com.youchain.exception.handler.ApiResult;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
@ -29,12 +30,16 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
|
||||||
* @author houjianlan
|
* @author houjianlan
|
||||||
|
* @website https://eladmin.vip
|
||||||
* @date 2023-08-16
|
* @date 2023-08-16
|
||||||
**/
|
**/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
@ -45,6 +50,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
public class TaskController {
|
public class TaskController {
|
||||||
|
|
||||||
private final TaskService taskService;
|
private final TaskService taskService;
|
||||||
|
|
||||||
@Log("导出数据")
|
@Log("导出数据")
|
||||||
@ApiOperation("导出数据")
|
@ApiOperation("导出数据")
|
||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
|
|
@ -99,4 +105,18 @@ public class TaskController {
|
||||||
taskService.deleteAll(ids);
|
taskService.deleteAll(ids);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/cancelAllocate")
|
||||||
|
@Log("手工取消")
|
||||||
|
@ApiOperation("手工取消")
|
||||||
|
@AnonymousAccess
|
||||||
|
public ResponseEntity<Object> cancelAllocate(long pickDetailId, double quantity) {
|
||||||
|
try {
|
||||||
|
taskService.cancelAllocate(pickDetailId, quantity);
|
||||||
|
return new ResponseEntity<>(ApiResult.success(OK.value(), "", ""), HttpStatus.OK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), e.getMessage(), ""), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,12 +145,6 @@ public interface TaskService {
|
||||||
*/
|
*/
|
||||||
List<Task> findByPickDetailNotAllTask(Long pickDetailId);
|
List<Task> findByPickDetailNotAllTask(Long pickDetailId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据出库单明细查询已完成的Task集合
|
|
||||||
*
|
|
||||||
* @param pickDetailId 明细ID
|
|
||||||
*/
|
|
||||||
List<Task> findByPickDetailAllTask(Long pickDetailId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询任务集合
|
* 查询任务集合
|
||||||
|
|
@ -174,10 +168,6 @@ public interface TaskService {
|
||||||
*/
|
*/
|
||||||
void materialPick();
|
void materialPick();
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务轮询叫料反空车至备料缓存区
|
|
||||||
*/
|
|
||||||
void callEmptyStock(Point point);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务轮询出库单叫料
|
* 定时任务轮询出库单叫料
|
||||||
|
|
@ -215,7 +205,7 @@ public interface TaskService {
|
||||||
*
|
*
|
||||||
* @param taskId 任务ID
|
* @param taskId 任务ID
|
||||||
*/
|
*/
|
||||||
void pickBarBack(long taskId, double pickedQuantity) throws Exception;
|
void pickBarBack(long taskId, double pickedQuantity);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,11 @@ public class AgvTaskServiceImpl implements AgvTaskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AgvTask findById(Long id) {
|
public AgvTask findById(Long id) {
|
||||||
return agvTaskRepository.findById(id).orElseGet(AgvTask::new);
|
AgvTask agvTask = agvTaskRepository.findById(id).orElseGet(AgvTask::new);
|
||||||
|
if (agvTask.getId() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return agvTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -206,7 +210,6 @@ public class AgvTaskServiceImpl implements AgvTaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryWeeklyTaskCounts() {
|
public Map<String, Object> queryWeeklyTaskCounts() {
|
||||||
List<Object[]> objectList = agvTaskRepository.queryWeeklyTaskCounts();
|
List<Object[]> objectList = agvTaskRepository.queryWeeklyTaskCounts();
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import com.youchain.basicdata.service.ItemService;
|
||||||
import com.youchain.basicdata.service.PointService;
|
import com.youchain.basicdata.service.PointService;
|
||||||
import com.youchain.basicdata.service.StockService;
|
import com.youchain.basicdata.service.StockService;
|
||||||
import com.youchain.businessdata.domain.Inventory;
|
import com.youchain.businessdata.domain.Inventory;
|
||||||
|
import com.youchain.businessdata.domain.InventoryLog;
|
||||||
import com.youchain.businessdata.domain.ItemKey;
|
import com.youchain.businessdata.domain.ItemKey;
|
||||||
import com.youchain.businessdata.service.InventoryLogService;
|
import com.youchain.businessdata.service.InventoryLogService;
|
||||||
import com.youchain.businessdata.service.ItemKeyService;
|
import com.youchain.businessdata.service.ItemKeyService;
|
||||||
|
|
@ -90,7 +91,11 @@ public class InventoryServiceImpl implements InventoryService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Inventory findById(Long id) {
|
public Inventory findById(Long id) {
|
||||||
return inventoryRepository.findById(id).orElseGet(Inventory::new);
|
Inventory inventory = inventoryRepository.findById(id).orElseGet(Inventory::new);
|
||||||
|
if (inventory.getId() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,11 @@ public class PickDetailServiceImpl implements PickDetailService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PickDetail findById(Long id) {
|
public PickDetail findById(Long id) {
|
||||||
return pickDetailRepository.findById(id).orElseGet(PickDetail::new);
|
PickDetail pickDetail = pickDetailRepository.findById(id).orElseGet(PickDetail::new);
|
||||||
|
if (pickDetail.getId() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return pickDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,12 @@ public class PickServiceImpl implements PickService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public Pick findById(Long id) {
|
public Pick findById(Long id) {
|
||||||
return pickRepository.findById(id).orElseGet(Pick::new);
|
Pick pick = pickRepository.findById(id).orElseGet(Pick::new);
|
||||||
|
if (pick.getId() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return pick;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,11 @@ public class TaskServiceImpl implements TaskService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task findById(Long id) {
|
public Task findById(Long id) {
|
||||||
return taskRepository.findById(id).orElseGet(Task::new);
|
Task task = taskRepository.findById(id).orElseGet(Task::new);
|
||||||
|
if (task.getId() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -155,11 +159,6 @@ public class TaskServiceImpl implements TaskService {
|
||||||
return taskRepository.findByPickDetailNotAllTask(pickDetailId);
|
return taskRepository.findByPickDetailNotAllTask(pickDetailId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Task> findByPickDetailAllTask(Long pickDetailId) {
|
|
||||||
return taskRepository.findByPickDetailAllTask(pickDetailId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Task> findTaskByContains(String taskType, String taskStatus, String srcStockCode) {
|
public List<Task> findTaskByContains(String taskType, String taskStatus, String srcStockCode) {
|
||||||
return taskRepository.findTaskByContains(taskType, taskStatus, srcStockCode);
|
return taskRepository.findTaskByContains(taskType, taskStatus, srcStockCode);
|
||||||
|
|
@ -223,39 +222,6 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void callEmptyStock(Point point) {
|
|
||||||
String dstAreaCode = AreaNameDic.XJJLQ.equals(point.getArea().getName()) ? AreaNameDic.XJFBCQ : AreaNameDic.DJFBCQ;
|
|
||||||
|
|
||||||
//容器
|
|
||||||
Stock stock = stockService.findByPointCode(point.getCode());
|
|
||||||
if (stock == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//起点
|
|
||||||
Point srcPoint = stock.getPoint();
|
|
||||||
|
|
||||||
//终点
|
|
||||||
List<Point> pointList = pointService.queryPoints(null, BaseStatus.FREE, BaseStatus.BOX, dstAreaCode);
|
|
||||||
if (pointList.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Point endPoint = pointList.get(0);
|
|
||||||
|
|
||||||
//有任务则直接返回
|
|
||||||
if (!agvTaskService.findByEndSlotCode(endPoint.getCode(), BizStatus.JL_Back, "RACK_MOVE")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//终点占用
|
|
||||||
pointService.usedPoint(endPoint);
|
|
||||||
|
|
||||||
//创建任务
|
|
||||||
agvTaskService.createAgvTask(BizStatus.JL_Back, stock, srcPoint.getCode(), endPoint.getCode(), "RACK_MOVE");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callJlTask(Pick pick) {
|
public void callJlTask(Pick pick) {
|
||||||
|
|
@ -434,17 +400,25 @@ public class TaskServiceImpl implements TaskService {
|
||||||
for (Task task : tasks) {
|
for (Task task : tasks) {
|
||||||
//根据task找到对应的库存
|
//根据task找到对应的库存
|
||||||
Inventory inv = inventoryService.findById(task.getInvId());
|
Inventory inv = inventoryService.findById(task.getInvId());
|
||||||
inv.setQueuedQty(inv.getQueuedQty() - pd.getAllocatedQty());
|
if (inv != null) {
|
||||||
|
inv.setQueuedQty(inv.getQueuedQty() - quantity);
|
||||||
inventoryService.update(inv);
|
inventoryService.update(inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(task.getAgvTask()!=null){
|
||||||
|
AgvTask agvTask= agvTaskService.findById(task.getAgvTask().getId());
|
||||||
|
if(agvTask!=null){
|
||||||
|
agvTaskService.deleteAll(new Long[]{agvTask.getId()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//删除Task
|
//删除Task
|
||||||
taskRepository.delete(task);
|
taskRepository.delete(task);
|
||||||
|
|
||||||
pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
|
pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
|
||||||
if (pd.getAllocatedQty() == 0) {
|
|
||||||
pd.setStatus(BizStatus.OPEN);
|
|
||||||
}
|
|
||||||
pickDetailService.update(pd);
|
pickDetailService.update(pd);
|
||||||
|
|
||||||
|
pickService.refreshPickStatus(pd.getPick());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -497,18 +471,21 @@ public class TaskServiceImpl implements TaskService {
|
||||||
public 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) {
|
double srcQty = 0;
|
||||||
throw new BadRequestException("未找到库存相应记录!");
|
Inventory inv = null;
|
||||||
}
|
if (task.getInvId() != null) {
|
||||||
Inventory inv = inventoryService.findById(task.getInvId());
|
inv = inventoryService.findById(task.getInvId());
|
||||||
|
if (inv != null) {
|
||||||
//退回库存
|
//退回库存
|
||||||
double srcQty = inv.getQueuedQty();
|
srcQty = inv.getQueuedQty();
|
||||||
synchronized (inv) {
|
synchronized (inv) {
|
||||||
inv.setQueuedQty(inv.getQueuedQty() + pickedQuantity);
|
inv.setQueuedQty(inv.getQueuedQty() + pickedQuantity);
|
||||||
inv.setQuantity(inv.getQuantity() + pickedQuantity);
|
inv.setQuantity(inv.getQuantity() + pickedQuantity);
|
||||||
inventoryService.update(inv);
|
inventoryService.update(inv);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//退回Task
|
//退回Task
|
||||||
task.setMoveQty(task.getMoveQty() - pickedQuantity);
|
task.setMoveQty(task.getMoveQty() - pickedQuantity);
|
||||||
|
|
@ -521,9 +498,9 @@ public class TaskServiceImpl implements TaskService {
|
||||||
//更新出库单状态
|
//更新出库单状态
|
||||||
pickService.refreshPickStatus(pickDetail.getPick());
|
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 == null ? null : inv.getId(), "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue