Commit abfce442660a074f69b282ea9cd495a4cfe0f16a
1 parent
88ae8a42
agv任务新增和修改判断容器状态
Showing
3 changed files
with
60 additions
and
3 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/controller/AgvTaskController.java
... | ... | @@ -79,9 +79,9 @@ public class AgvTaskController extends JeecgController<AgvTask, IAgvTaskService> |
79 | 79 | @AutoLog(value = "AGV任务-编辑") |
80 | 80 | @ApiOperation(value = "AGV任务-编辑", notes = "AGV任务-编辑") |
81 | 81 | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
82 | - public Result<String> edit(@RequestBody AgvTask agvTask) { | |
83 | - agvTaskService.updateById(agvTask); | |
84 | - return Result.OK("编辑成功!"); | |
82 | + public Result<String> edit(@RequestBody AgvTask agvTask, HttpServletRequest req) { | |
83 | + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); | |
84 | + return agvTaskService.editAgvTask(agvTask,warehouseCode); | |
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java
... | ... | @@ -38,4 +38,8 @@ public interface IAgvTaskService extends IService<AgvTask> { |
38 | 38 | public AgvTask getAgvTaskBuFromPort(String fromPortCode, String warehouseCode); |
39 | 39 | |
40 | 40 | public AgvTask getAgvTaskBuToPort(String toPortCode, String warehouseCode); |
41 | + | |
42 | + public AgvTask getAgvTaskById(Integer agvTaskId, String warehouseCode); | |
43 | + | |
44 | + public Result editAgvTask(AgvTask agvTask,String warehouseCode); | |
41 | 45 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java
... | ... | @@ -15,6 +15,7 @@ import org.jeecg.modules.wms.task.agvTask.mapper.AgvTaskMapper; |
15 | 15 | import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService; |
16 | 16 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
17 | 17 | import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; |
18 | +import org.jeecg.utils.StringUtils; | |
18 | 19 | import org.jeecg.utils.constant.QuantityConstant; |
19 | 20 | import org.springframework.stereotype.Service; |
20 | 21 | import org.springframework.transaction.annotation.Transactional; |
... | ... | @@ -45,6 +46,17 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl |
45 | 46 | |
46 | 47 | @Override |
47 | 48 | public Result addAgvTask(AgvTask agvTask, String warehouseCode) { |
49 | + String containerCode = agvTask.getContainerCode(); | |
50 | + if (StringUtils.isEmpty(containerCode)) { | |
51 | + return Result.error("生成AGV任务,容器号不能为空"); | |
52 | + } | |
53 | + Container containerByCode = containerService.getContainerByCode(containerCode, warehouseCode); | |
54 | + if (containerByCode == null) { | |
55 | + return Result.error("生成AGV任务,容器号:" + containerCode + "未找到"); | |
56 | + } | |
57 | + if (!containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode)) { | |
58 | + throw new JeecgBootException("生成AGV任务,锁定容器失败:" + containerCode); | |
59 | + } | |
48 | 60 | agvTask.setWarehouseCode(warehouseCode); |
49 | 61 | agvTask.setTaskType(QuantityConstant.AGV_TYPE_TAKE_AND_RELEASE); |
50 | 62 | agvTask.setStatus(QuantityConstant.AGV_TASK_STATUS_BUILD); |
... | ... | @@ -212,4 +224,45 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl |
212 | 224 | AgvTask agvTask = getOne(agvTaskLambdaQueryWrapper); |
213 | 225 | return agvTask; |
214 | 226 | } |
227 | + | |
228 | + @Override | |
229 | + public AgvTask getAgvTaskById(Integer agvTaskId, String warehouseCode) { | |
230 | + LambdaQueryWrapper<AgvTask> agvTaskLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
231 | + agvTaskLambdaQueryWrapper.eq(AgvTask::getId, agvTaskId).eq(AgvTask::getWarehouseCode, warehouseCode); | |
232 | + AgvTask agvTask = getOne(agvTaskLambdaQueryWrapper); | |
233 | + return agvTask; | |
234 | + } | |
235 | + | |
236 | + @Override | |
237 | + @Transactional(rollbackFor = JeecgBootException.class) | |
238 | + public Result editAgvTask(AgvTask agvTask, String warehouseCode) { | |
239 | + if (agvTask == null) { | |
240 | + return Result.error("AGV任务信息为空"); | |
241 | + } | |
242 | + if (getById(agvTask) == null) { | |
243 | + return Result.error("根据ID没有找到agv任务"); | |
244 | + } | |
245 | + if (agvTask.getStatus() > QuantityConstant.AGV_TASK_STATUS_BUILD) { | |
246 | + return Result.error("任务已经下发,不可以修改"); | |
247 | + } | |
248 | + String containerCode = agvTask.getContainerCode(); | |
249 | + if (StringUtils.isEmpty(containerCode)) { | |
250 | + return Result.error("修改AGV任务,容器号不能为空"); | |
251 | + } | |
252 | + AgvTask agvTaskByCode = getAgvTaskById(agvTask.getId(), warehouseCode); | |
253 | + Container containerByCode = containerService.getContainerByCode(containerCode, warehouseCode); | |
254 | + if (containerByCode == null) { | |
255 | + return Result.error("修改AGV任务,容器号:" + containerCode + "未找到"); | |
256 | + } | |
257 | + if (!containerService.updateStatus(agvTaskByCode.getContainerCode(), QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) { | |
258 | + throw new JeecgBootException("修改AGV任务,解锁原容器失败:" + agvTaskByCode.getContainerCode()); | |
259 | + } | |
260 | + if (!containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode)) { | |
261 | + throw new JeecgBootException("修改AGV任务,锁定容器失败:" + containerCode); | |
262 | + } | |
263 | + if (!updateById(agvTask)) { | |
264 | + throw new JeecgBootException("修改AGV任务失败!"); | |
265 | + } | |
266 | + return Result.OK("修改AGV任务成功"); | |
267 | + } | |
215 | 268 | } |
... | ... |