rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java
@@ -1,6 +1,7 @@ package com.vincent.rsf.server.manager.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.vincent.rsf.framework.common.Cools; @@ -19,6 +20,8 @@ import com.vincent.rsf.server.system.service.impl.ConfigServiceImpl; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; @@ -29,6 +32,8 @@ @RestController public class TaskController extends BaseController { public static final Logger logger = LoggerFactory.getLogger(TaskController.class); @Autowired private TaskService taskService; @@ -47,7 +52,9 @@ public R page(@RequestBody Map<String, Object> map) { BaseParam baseParam = buildParam(map, BaseParam.class); PageParam<Task, BaseParam> pageParam = new PageParam<>(baseParam, Task.class); return R.ok().add(taskService.page(pageParam, pageParam.buildWrapper(true))); QueryWrapper<Task> queryWrapper = pageParam.buildWrapper(true); queryWrapper.orderByDesc("sort"); return R.ok().add(taskService.page(pageParam, queryWrapper)); } @PreAuthorize("hasAuthority('manager:task:list')") @@ -137,14 +144,13 @@ List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() .eq(Task::getId, id) .in(Task::getTaskStatus, longs)); for (Task task : tasks) { if (StringUtils.isNotBlank(task.getParentId() + "")) { Task task1 = taskService.getById(task.getParentId()); if (!Objects.isNull(task1) && task1.getTaskType().equals(TaskStsType.UPDATED_IN.id)) { throw new CoolException("父任务:" + task1.getTaskCode() + "未执行完成!"); } } // if (StringUtils.isNotBlank(task.getParentId() + "")) { // Task task1 = taskService.getById(task.getParentId()); // if (!Objects.isNull(task1) && task1.getTaskType().equals(TaskStsType.UPDATED_IN.id)) { // throw new CoolException("父任务:" + task1.getTaskCode() + "未执行完成!"); // } // } task.setTaskStatus(task.getTaskType() < 100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.COMPLETE_OUT.id); } @@ -205,21 +211,15 @@ @PreAuthorize("hasAuthority('manager:task:update')") @ApiOperation("任务出库置顶") @PostMapping("/task/top/{id}") public R setTop(@PathVariable String id) { public R setTop(@PathVariable Long id) { if (Objects.isNull(id)) { throw new CoolException("参数不能为空!!"); } List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getId, id).in(Task::getTaskStatus, longs)); if (tasks.isEmpty()) { throw new CoolException("任务已处执行状态不可一键置顶!!"); } try { if (!taskService.update(new LambdaUpdateWrapper<Task>().set(Task::getSort, 100).eq(Task::getId, id))) { throw new CoolException("置顶失败!!"); } } catch (Exception ex) { return R.error("任务异常,无法完成!!"); taskService.taskToTop(id); } catch (Exception e) { logger.error("UNK", e); throw new CoolException(e.getMessage()); } return R.ok(); } rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Task.java
@@ -122,7 +122,7 @@ * 优先级 */ @ApiModelProperty(value= "优先级") private Short sort; private Integer sort; /** * 异常编码 @@ -199,7 +199,7 @@ public Task() {} public Task(String taskCode,Integer taskStatus,Integer taskType,String orgLoc,String targLoc,String barcode,String robotCode,Short exceStatus,String expDesc,Short sort,String expCode,Date startTime,Date endTime,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { public Task(String taskCode,Integer taskStatus,Integer taskType,String orgLoc,String targLoc,String barcode,String robotCode,Short exceStatus,String expDesc,Integer sort,String expCode,Date startTime,Date endTime,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { this.taskCode = taskCode; this.taskStatus = taskStatus; this.taskType = taskType; rsf-server/src/main/java/com/vincent/rsf/server/manager/service/TaskService.java
@@ -24,4 +24,6 @@ Task pickOrCheckTask(Long id, String oType) throws Exception; void complateInTask(List<Task> tasks) throws Exception; Task taskToTop(Long id) throws Exception; } rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
@@ -98,6 +98,7 @@ .setTaskCode(ruleCode) .setParentId(moveTask.getId()) .setTargSite(siteNo) .setSort(Short.valueOf("49")) .setUpdateBy(loginUserId) .setCreateBy(loginUserId) .setCreateTime(new Date()) @@ -283,6 +284,7 @@ .setTaskType(TaskType.TASK_TYPE_LOC_MOVE.type) .setTargLoc(targetLoc.getCode()) .setUpdateBy(loginUserId) .setSort(Short.valueOf("49")) .setUpdateTime(new Date()) .setTaskStatus(TaskStsType.GENERATE_IN.id) .setBarcode(orgLoc.getBarcode()); rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -206,8 +206,8 @@ if (!locService.update(new LambdaUpdateWrapper<Loc>() .eq(Loc::getCode, task.getTargLoc()) .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type) .set(Loc::getUpdateBy, loginUserId) .set(Loc::getUpdateTime, new Date()) .set(Loc::getUpdateBy, loginUserId) .set(Loc::getUpdateTime, new Date()) .set(Loc::getBarcode, pakin.getBarcode()))) { throw new CoolException("库位预约失败!!"); } @@ -410,6 +410,47 @@ } } /** * 任务置顶 * * @param id * @return */ @Override @Transactional(rollbackFor = Exception.class) public Task taskToTop(Long id) throws Exception { List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); Task tasks = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getId, id).in(Task::getTaskStatus, longs)); if (Objects.isNull(tasks)) { throw new CoolException("任务已处执行状态不可一键置顶!!"); } if (!LocUtils.isShallowLoc(tasks.getOrgLoc())) { String shallowLoc = LocUtils.getShallowLoc(tasks.getOrgLoc()); Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc)); if (Objects.isNull(loc)) { throw new CoolException("数据错误,库位不存在!!"); } if (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) || loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) { Task serviceOne = taskService.getOne(new LambdaQueryWrapper<Task>() .eq(Task::getOrgLoc, loc.getCode()) .or() .eq(Task::getTargLoc, loc.getCode())); if (Objects.isNull(serviceOne)) { tasks.setSort(999); } else { int i = serviceOne.getSort() - 1; tasks.setSort(i); } } } if (!taskService.updateById(tasks)) { throw new CoolException("置顶失败!!"); } return null; } @Transactional(rollbackFor = Exception.class) public void moveInStock(Task task, Long loginUserId) { if (Objects.isNull(task)) { @@ -448,31 +489,30 @@ if (!locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, task.getOrgLoc()))) { throw new CoolException("源库位明细删除失败!"); } } /**修改库位状态为F.在库*/ if (!locService.update(new LambdaUpdateWrapper<Loc>() .set(Loc::getBarcode, task.getBarcode()) .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type) .set(Loc::getUpdateBy, loginUserId) .set(Loc::getUpdateTime, new Date()) .eq(Loc::getCode, task.getTargLoc()))) { .set(Loc::getBarcode, task.getBarcode()) .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type) .set(Loc::getUpdateBy, loginUserId) .set(Loc::getUpdateTime, new Date()) .eq(Loc::getCode, task.getTargLoc()))) { throw new CoolException("库位状态修改失败!!"); } if (!locService.update(new LambdaUpdateWrapper<Loc>() .set(Loc::getBarcode, null) .set(Loc::getUpdateBy, loginUserId) .set(Loc::getUpdateTime, new Date()) .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) .set(Loc::getBarcode, null) .set(Loc::getUpdateBy, loginUserId) .set(Loc::getUpdateTime, new Date()) .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) .eq(Loc::getCode, task.getOrgLoc()))) { throw new CoolException("库位状态修改失败!!"); } if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()) .set(Task::getUpdateBy, loginUserId) .set(Task::getUpdateTime, new Date()) .set(Task::getUpdateBy, loginUserId) .set(Task::getUpdateTime, new Date()) .set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) { throw new CoolException("任务状态修改失败!!"); } @@ -857,8 +897,8 @@ if (!locService.update(new LambdaUpdateWrapper<Loc>() .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) .set(Loc::getBarcode, null) .set(Loc::getUpdateBy, loginUserId) .set(Loc::getUpdateTime, new Date()) .set(Loc::getUpdateBy, loginUserId) .set(Loc::getUpdateTime, new Date()) .eq(Loc::getId, loc.getId()))) { throw new CoolException("库位状态修改失败!!"); } @@ -1028,7 +1068,7 @@ if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>() .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val) .set(WaitPakin::getUpdateBy, loginUserId) .set(WaitPakin::getUpdateBy, loginUserId) .eq(WaitPakin::getId, pakinItem.getPakinId()))) { throw new CoolException("组拖状态修改失败!!"); }