|  |  | 
 |  |  | } from 'react-admin'; | 
 |  |  | import { Box, Typography, Card, Stack, Drawer } from '@mui/material'; | 
 |  |  | import { styled } from '@mui/material/styles'; | 
 |  |  | import TaskCreate from "./TaskCreate"; | 
 |  |  | import TaskPanel from "./TaskPanel"; | 
 |  |  | import EmptyData from "../components/EmptyData"; | 
 |  |  | import MyCreateButton from "../components/MyCreateButton"; | 
 |  |  | import MyExportButton from '../components/MyExportButton'; | 
 |  |  | import SwapVertIcon from '@mui/icons-material/SwapVert'; | 
 |  |  | import AlignVerticalTopIcon from '@mui/icons-material/AlignVerticalTop'; | 
 |  |  | import TaskAltIcon from '@mui/icons-material/TaskAlt'; | 
 |  |  | import CancelIcon from '@mui/icons-material/Cancel'; | 
 |  |  | import PageDrawer from "../components/PageDrawer"; | 
 |  |  | import TaskPanel from "./TaskPanel"; | 
 |  |  | import MyField from "../components/MyField"; | 
 |  |  | import ConfirmButton from "../components/ConfirmButton"; | 
 |  |  | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
 |  |  | 
 |  |  |                 title={"menu.task"} | 
 |  |  |                 empty={false} | 
 |  |  |                 filters={filters} | 
 |  |  |                 sort={{ field: "create_time", order: "desc" }} | 
 |  |  |                 sort={{ field: "sort", order: "desc" }} | 
 |  |  |                 actions={( | 
 |  |  |                     <TopToolbar> | 
 |  |  |                         <FilterButton /> | 
 |  |  | 
 |  |  |             > | 
 |  |  |                 <StyledDatagrid | 
 |  |  |                     preferenceKey='task' | 
 |  |  |                     bulkActionButtons={ | 
 |  |  |                         <> | 
 |  |  |                             <BulkResortButton /> | 
 |  |  |                             <BulkCancelButton /> | 
 |  |  |                             <BulkDeleteButton mutationMode={OPERATE_MODE} /> | 
 |  |  |                         </> | 
 |  |  |                     bulkActionButtons={false | 
 |  |  |                         // <> | 
 |  |  |                         //     <BulkResortButton /> | 
 |  |  |                         //     <BulkCancelButton /> | 
 |  |  |                         //     <BulkDeleteButton mutationMode={OPERATE_MODE} /> | 
 |  |  |                         // </> | 
 |  |  |                     } | 
 |  |  |                     rowClick={false} | 
 |  |  |                     expand={false} | 
 |  |  |                     expand={<TaskPanel />} | 
 |  |  |                     expandSingle={true} | 
 |  |  |                     omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status', 'sort']} | 
 |  |  |                     omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status']} | 
 |  |  |                 > | 
 |  |  |                     <NumberField source="id" /> | 
 |  |  |                     <TextField source="taskCode" label="table.field.task.taskCode" /> | 
 |  |  | 
 |  |  |                         <CancelButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> | 
 |  |  |                         <CheckButton /> | 
 |  |  |                         <PickButton /> | 
 |  |  |                         <SetTopButton /> | 
 |  |  |                     </WrapperField> | 
 |  |  |                 </StyledDatagrid> | 
 |  |  |             </List> | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     return ( | 
 |  |  |         (record.taskStatus == 1 || record.taskStatus == 101) && (record.taskType == 1 || record.taskType == 101 || record.taskType == 10 || record.taskType == 103 || record.taskType == 11 ) ? | 
 |  |  |         (record.taskStatus == 1 || record.taskStatus == 101) && (record.taskType == 1 || record.taskType == 101 || record.taskType == 10 || record.taskType == 103 || record.taskType == 11) ? | 
 |  |  |             <Button | 
 |  |  |                 onClick={clickCancel} | 
 |  |  |                 label="toolbar.cancel"> | 
 |  |  | 
 |  |  |             refresh(); | 
 |  |  |         } else { | 
 |  |  |             notify(msg); | 
 |  |  |         } | 
 |  |  |         }  | 
 |  |  |     } | 
 |  |  |     return ( | 
 |  |  |         <Button | 
 |  |  |             onClick={clickTop} | 
 |  |  |             label="toolbar.top"> | 
 |  |  |             <AlignVerticalTopIcon /> | 
 |  |  |         </Button> | 
 |  |  |         (record.taskStatus == 1 || record.taskStatus == 101) && (record.taskType == 1 || record.taskType == 101 || record.taskType == 10 || record.taskType == 103 || record.taskType == 11) ? | 
 |  |  |             <Button | 
 |  |  |                 onClick={clickTop} | 
 |  |  |                 label="toolbar.top"> | 
 |  |  |                 <AlignVerticalTopIcon /> | 
 |  |  |             </Button> | 
 |  |  |         : | 
 |  |  |         <></> | 
 |  |  |     ) | 
 |  |  | } | 
 |  |  |  | 
 
 |  |  | 
 |  |  | //    private String locType; | 
 |  |  |  | 
 |  |  |     private Long user; | 
 |  |  |  | 
 |  |  |     private String orgLoc; | 
 |  |  | //    private Integer locType2; //库位类型 | 
 |  |  | //    private Integer locType3; //库位类型 | 
 |  |  | } | 
 
 |  |  | 
 |  |  |         //根据立库类型获取获取库位 | 
 |  |  |         if (warehouseArea.getType().equals(WarehType.WAREHOUSE_TYPE_CRN.val)) { | 
 |  |  |             //堆垛机 | 
 |  |  |             dto = getLocNoCrn(deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType()); | 
 |  |  |             dto = getLocNoCrn(param.getOrgLoc(),deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType()); | 
 |  |  |  | 
 |  |  |         } else if (warehouseArea.getType().equals(WarehType.WAREHOUSE_TYPE_FOUR_DIRECTIONS.val)) { | 
 |  |  |             //四向库 | 
 |  |  | 
 |  |  |         return dto; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private InTaskMsgDto getLocNoCrn(DeviceBind deviceBind, Long area, Integer sourceStaNo, String matnr, String batch, LocTypeDto locTypeDto, int times, Integer ioType) { | 
 |  |  |     private InTaskMsgDto getLocNoCrn(String orgLoc,DeviceBind deviceBind, Long area, Integer sourceStaNo, String matnr, String batch, LocTypeDto locTypeDto, int times, Integer ioType) { | 
 |  |  |         if (Cools.isEmpty(matnr)) {  //物料号 | 
 |  |  |             matnr = ""; | 
 |  |  |         } | 
 |  |  | 
 |  |  |             throw new CoolException("无可用堆垛机"); | 
 |  |  |         } | 
 |  |  |         //入库靠近摆放 | 
 |  |  |         if (ioType == 1 && deviceBind.getBeSimilar().equals("1") && !Cools.isEmpty(matnr)) { | 
 |  |  |         if (ioType == 1 && deviceBind.getBeSimilar().equals("1") && !Cools.isEmpty(matnr) && Cools.isEmpty(orgLoc)) { | 
 |  |  |             if (nearRow != curRow) { | 
 |  |  |                 List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getMatnrCode, matnr)); | 
 |  |  |                 for (LocItem locItem : locItems) { | 
 |  |  | 
 |  |  |                     .orderByAsc(Loc::getLev) | 
 |  |  |                     .orderByAsc(Loc::getCol) | 
 |  |  |             ); | 
 |  |  |             Loc orgMoveLoc = null; | 
 |  |  |             if (!Cools.isEmpty(orgLoc)) { | 
 |  |  |                 orgMoveLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, orgLoc)); | 
 |  |  |             } | 
 |  |  |             for (Loc locMast1 : locMasts) { | 
 |  |  |                 if (!LocUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { | 
 |  |  |                     continue; | 
 |  |  | 
 |  |  |                             .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) | 
 |  |  |                             .eq(Loc::getAreaId, area) | 
 |  |  |                     ); | 
 |  |  |  | 
 |  |  |                     if (!Cools.isEmpty(locMast2)) { | 
 |  |  |                         if (null != orgMoveLoc){ | 
 |  |  |                             if (!locMast2.getChannel().equals(orgMoveLoc.getChannel())) { | 
 |  |  |                                 break; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                         loc = locMast2; | 
 |  |  |                         break; | 
 |  |  |                     } | 
 |  |  | 
 |  |  |                             .in(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type, LocStsType.LOC_STS_TYPE_F.type) | 
 |  |  |                             .eq(Loc::getAreaId, area) | 
 |  |  |                     ); | 
 |  |  |  | 
 |  |  |                     if (!Cools.isEmpty(locMast2)) { | 
 |  |  |                         if (null != orgMoveLoc){ | 
 |  |  |                             if (!locMast2.getChannel().equals(orgMoveLoc.getChannel())) { | 
 |  |  |                                 break; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                         loc = locMast1; | 
 |  |  |                         break; | 
 |  |  |                     } else { | 
 |  |  | 
 |  |  |                                 .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) | 
 |  |  |                                 .eq(Loc::getAreaId, area) | 
 |  |  |                         ); | 
 |  |  |  | 
 |  |  |                         if (!Cools.isEmpty(locMast2)) { | 
 |  |  |                             if (null != orgMoveLoc){ | 
 |  |  |                                 if (!locMast2.getChannel().equals(orgMoveLoc.getChannel())) { | 
 |  |  |                                     break; | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                             loc = locMast2; | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  | 
 |  |  |                                 .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) | 
 |  |  |                                 .eq(Loc::getAreaId, area) | 
 |  |  |                         ); | 
 |  |  |  | 
 |  |  |                         if (!Cools.isEmpty(locMast2)) { | 
 |  |  |                             if (null != orgMoveLoc){ | 
 |  |  |                                 if (!locMast2.getChannel().equals(orgMoveLoc.getChannel())) { | 
 |  |  |                                     break; | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                             loc = locMast2; | 
 |  |  |                             break; | 
 |  |  |                         } else { | 
 |  |  | 
 |  |  |                                     .in(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type, LocStsType.LOC_STS_TYPE_D.type) | 
 |  |  |                                     .eq(Loc::getAreaId, area) | 
 |  |  |                             ); | 
 |  |  |  | 
 |  |  |                             if (!Cools.isEmpty(locMast2)) { | 
 |  |  |                                 if (null != orgMoveLoc){ | 
 |  |  |                                     if (!locMast2.getChannel().equals(orgMoveLoc.getChannel())) { | 
 |  |  |                                         break; | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |                                 loc = locMast1; | 
 |  |  |                                 break; | 
 |  |  |                             } | 
 |  |  | 
 |  |  |             // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归 | 
 |  |  |             if (times < rowCount * 2) { | 
 |  |  |                 times = times + 1; | 
 |  |  |                 return getLocNoCrn(deviceBind, area, sourceStaNo, matnr, batch, locTypeDto, times, ioType); | 
 |  |  |                 return getLocNoCrn(orgLoc,deviceBind, area, sourceStaNo, matnr, batch, locTypeDto, times, ioType); | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |             // 2.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位 | 
 |  |  |             if (locTypeDto.getLocType1() < 3) { | 
 |  |  |                 int i = locTypeDto.getLocType1() + 1; | 
 |  |  |                 locTypeDto.setLocType1(i); | 
 |  |  |                 return getLocNoCrn(deviceBind, area, sourceStaNo, matnr, batch, locTypeDto, 0, ioType); | 
 |  |  |                 return getLocNoCrn(orgLoc,deviceBind, area, sourceStaNo, matnr, batch, locTypeDto, 0, ioType); | 
 |  |  |             } | 
 |  |  |             throw new CoolException("没有空库位"); | 
 |  |  |         } | 
 
 |  |  | 
 |  |  | package com.vincent.rsf.server.common.constant; | 
 |  |  |  | 
 |  |  | import io.swagger.models.auth.In; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 系统常量 | 
 |  |  |  * Created by vincent on 2019-10-29 15:55 | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     public static final String TASK_TYPE_OUT_PICK = "pick"; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 排序默认值 | 
 |  |  |      */ | 
 |  |  |     public static final Integer TASK_SORT_DEFAULT_VALUE =  49; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 排序最大值 | 
 |  |  |      */ | 
 |  |  |     public static final Integer TASK_SORT_MAX_VALUE =  999; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 排序最小值 | 
 |  |  |      */ | 
 |  |  |     public static final Integer TASK_SORT_MIN_VALUE =  0; | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<Task, BaseParam> pageParam = new PageParam<>(baseParam, Task.class); | 
 |  |  |         QueryWrapper<Task> queryWrapper = pageParam.buildWrapper(true); | 
 |  |  |         queryWrapper.orderByDesc("sort"); | 
 |  |  |         return R.ok().add(taskService.page(pageParam, queryWrapper)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:task:update')") | 
 |  |  |     @ApiOperation("完成任务") | 
 |  |  |     @PostMapping("/task/complete/{id}") | 
 |  |  |     public R completeTask(@PathVariable String id) throws Exception { | 
 |  |  |         if (Objects.isNull(id)) { | 
 |  |  |     public R completeTask(@PathVariable Long id) throws Exception { | 
 |  |  |         if (Cools.isEmpty(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)); | 
 |  |  |         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() + "未执行完成!"); | 
 |  |  | //                } | 
 |  |  | //            } | 
 |  |  |             task.setTaskStatus(task.getTaskType() < 100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.COMPLETE_OUT.id); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (!taskService.updateBatchById(tasks)) { | 
 |  |  |             return R.error("完成任务失败"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return R.ok("完成任务成功"); | 
 |  |  |         return R.ok("完成任务成功").add(taskService.operateComplete(id, getLoginUserId())); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 拣料出库(用于测试拣料出库) | 
 |  |  | 
 |  |  |             throw new CoolException("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         try { | 
 |  |  |             taskService.taskToTop(id); | 
 |  |  |             taskService.taskToTop(id, getLoginUserId()); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             logger.error("UNK", e); | 
 |  |  |             throw new CoolException(e.getMessage()); | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     void complateInTask(List<Task> tasks) throws Exception; | 
 |  |  |  | 
 |  |  |     Task taskToTop(Long id) throws Exception; | 
 |  |  |     Task taskToTop(Long id, Long loginUserId) throws Exception; | 
 |  |  |  | 
 |  |  |     Task operateComplete(Long id, Long loginUserId); | 
 |  |  | } | 
 
 |  |  | 
 |  |  |                     .setTaskCode(ruleCode) | 
 |  |  |                     .setParentId(moveTask.getId()) | 
 |  |  |                     .setTargSite(siteNo) | 
 |  |  |                     .setSort(Short.valueOf("49")) | 
 |  |  |                     .setSort(Constants.TASK_SORT_DEFAULT_VALUE) | 
 |  |  |                     .setUpdateBy(loginUserId) | 
 |  |  |                     .setCreateBy(loginUserId) | 
 |  |  |                     .setCreateTime(new Date()) | 
 |  |  | 
 |  |  |                 Double useQty = Math.round((outQty + workQty) * 10000) / 10000.0; | 
 |  |  |                 if (orgQty.compareTo(useQty) > 0) { | 
 |  |  |                     //拣料出库 | 
 |  |  |  | 
 |  |  |                     DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() | 
 |  |  |                             .eq(DeviceSite::getSite, siteNo) | 
 |  |  |                             .eq(DeviceSite::getChannel, loc.getChannel()) | 
 |  |  | 
 |  |  |             if (!taskService.save(task)) { | 
 |  |  |                 throw new CoolException("任务创建失败!!"); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!Objects.isNull(moveTask.getId())) { | 
 |  |  |                 moveTask.setParentId(task.getId()); | 
 |  |  |                 if (!taskService.saveOrUpdate(moveTask)) { | 
 |  |  |                     throw new CoolException("任务信息修改失败!!"); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             List<TaskItem> taskItems = new ArrayList<>(); | 
 |  |  |             listMap.get(key).forEach(item -> { | 
 |  |  |                 TaskItem taskItem = new TaskItem(); | 
 |  |  | 
 |  |  |             throw new CoolException("源库位不存在!!"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (orgLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type) | 
 |  |  |                 || orgLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) | 
 |  |  |                 || orgLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_X.type ) ) { | 
 |  |  |             throw new CoolException("源库位有任务正在执行中..."); | 
 |  |  |         } | 
 |  |  | //        if (orgLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type) | 
 |  |  | //                || orgLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) | 
 |  |  | //                || orgLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_X.type ) ) { | 
 |  |  | //            throw new CoolException("源库位有任务正在执行中..."); | 
 |  |  | //        } | 
 |  |  |  | 
 |  |  |         orgLoc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); | 
 |  |  |  | 
 |  |  | 
 |  |  |             } | 
 |  |  |             TaskInParam param = new TaskInParam(); | 
 |  |  |             param.setIoType(TaskType.TASK_TYPE_OUT.type) | 
 |  |  |                     .setOrgLoc(map.getOrgLoc()) | 
 |  |  |                     .setSourceStaNo(Integer.parseInt(deviceSite.getSite())) | 
 |  |  |                     .setLocType1(Integer.parseInt(orgLoc.getType())); | 
 |  |  |                     .setLocType1(Integer.parseInt(orgLoc.getType()) | 
 |  |  |                     ); | 
 |  |  |             InTaskMsgDto locNo = null; | 
 |  |  |             try { | 
 |  |  |                 locNo = wcsService.getLocNo(param); | 
 |  |  | 
 |  |  |                 .setTaskType(TaskType.TASK_TYPE_LOC_MOVE.type) | 
 |  |  |                 .setTargLoc(targetLoc.getCode()) | 
 |  |  |                 .setUpdateBy(loginUserId) | 
 |  |  |                 .setSort(Short.valueOf("49")) | 
 |  |  |                 .setSort(Constants.TASK_SORT_DEFAULT_VALUE) | 
 |  |  |                 .setUpdateTime(new Date()) | 
 |  |  |                 .setTaskStatus(TaskStsType.GENERATE_IN.id) | 
 |  |  |                 .setTaskStatus(TaskStsType.GENERATE_OUT.id) | 
 |  |  |                 .setBarcode(orgLoc.getBarcode()); | 
 |  |  |  | 
 |  |  |         if (!taskService.save(task)) { | 
 |  |  | 
 |  |  |                         .setSourceCode(item.getLocCode()) | 
 |  |  |                         .setSource(item.getId()) | 
 |  |  |                         .setUpdateTime(new Date()) | 
 |  |  |                         .setOrderType(OrderType.ORDER_IN.type) | 
 |  |  |                         .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER_IN.type)); | 
 |  |  |                         .setOrderType(OrderType.ORDER_OUT.type) | 
 |  |  |                         .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER.type)); | 
 |  |  |                 taskItems.add(taskItem); | 
 |  |  |             } | 
 |  |  |             if (!taskItemService.saveBatch(taskItems)) { | 
 
 |  |  | 
 |  |  | import com.vincent.rsf.server.api.entity.dto.InTaskMsgDto; | 
 |  |  | import com.vincent.rsf.server.api.service.WcsService; | 
 |  |  | import com.vincent.rsf.server.common.constant.Constants; | 
 |  |  | import com.vincent.rsf.server.manager.controller.params.LocToTaskParams; | 
 |  |  | import com.vincent.rsf.server.manager.enums.*; | 
 |  |  | import com.vincent.rsf.framework.common.R; | 
 |  |  | import com.vincent.rsf.framework.exception.CoolException; | 
 |  |  | 
 |  |  |      * 任务置顶 | 
 |  |  |      * | 
 |  |  |      * @param id | 
 |  |  |      * @param loginUserId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public Task taskToTop(Long id) throws Exception { | 
 |  |  |     public Task taskToTop(Long id, Long loginUserId) 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("任务已处执行状态不可一键置顶!!"); | 
 |  |  |         } | 
 |  |  |         //判断浅库位任务,修改任务优先级 | 
 |  |  |         modiftyTaskSort(tasks, loginUserId); | 
 |  |  |  | 
 |  |  |         if (!LocUtils.isShallowLoc(tasks.getOrgLoc())) { | 
 |  |  |             String shallowLoc = LocUtils.getShallowLoc(tasks.getOrgLoc()); | 
 |  |  |         if (!taskService.updateById(tasks)) { | 
 |  |  |             throw new CoolException("置顶失败!!"); | 
 |  |  |         } | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 手动完成任务 | 
 |  |  |      * | 
 |  |  |      * @param id | 
 |  |  |      * @param loginUserId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public Task operateComplete(Long id, Long loginUserId) { | 
 |  |  |         List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); | 
 |  |  |         Task task = taskService.getOne(new LambdaQueryWrapper<Task>() | 
 |  |  |                 .eq(Task::getId, id) | 
 |  |  |                 .in(Task::getTaskStatus, longs)); | 
 |  |  |  | 
 |  |  |         if (Objects.isNull(task)) { | 
 |  |  |             throw new CoolException("当前任务正在执行中,不可取消!!"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         modiftyTaskSort(task, loginUserId); | 
 |  |  |  | 
 |  |  |         // | 
 |  |  |  | 
 |  |  |         task.setTaskStatus(task.getTaskType() < 100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.COMPLETE_OUT.id); | 
 |  |  |         if (!this.updateById(task)) { | 
 |  |  |             throw new CoolException("完成任务失败"); | 
 |  |  |         } | 
 |  |  |         return task; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改任务优先级 | 
 |  |  |      * | 
 |  |  |      * @param task | 
 |  |  |      * @param loginUserId | 
 |  |  |      */ | 
 |  |  |     private Task modiftyTaskSort(Task task, Long loginUserId) { | 
 |  |  |         String curLoc; | 
 |  |  |         if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { | 
 |  |  |             curLoc = task.getTargLoc(); | 
 |  |  |         } else { | 
 |  |  |             curLoc = task.getOrgLoc(); | 
 |  |  |         } | 
 |  |  |         //深库位先出情况 | 
 |  |  |         if (!LocUtils.isShallowLoc(curLoc)) { | 
 |  |  |             //深库位 | 
 |  |  |             String shallowLoc = LocUtils.getShallowLoc(curLoc); | 
 |  |  |             if (StringUtils.isBlank(shallowLoc)) { | 
 |  |  |                 throw new CoolException("数据异常,请联系管理员!"); | 
 |  |  |             } | 
 |  |  |             Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc)); | 
 |  |  |             if (Objects.isNull(loc)) { | 
 |  |  |                 throw new CoolException("数据错误,库位不存在!!"); | 
 |  |  | 
 |  |  |                         .or() | 
 |  |  |                         .eq(Task::getTargLoc, loc.getCode())); | 
 |  |  |                 if (Objects.isNull(serviceOne)) { | 
 |  |  |                     tasks.setSort(999); | 
 |  |  |                     task.setSort(Constants.TASK_SORT_MAX_VALUE); | 
 |  |  |                 } else { | 
 |  |  |                     int i = serviceOne.getSort() - 1; | 
 |  |  |                     tasks.setSort(i); | 
 |  |  |                     task.setSort(i); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  | //            else if (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) { | 
 |  |  | //                //如果为在库状态,生成移库任务 | 
 |  |  | //                LocToTaskParams params = new LocToTaskParams(); | 
 |  |  | //                params.setOrgLoc(curLoc); | 
 |  |  | //                //生成移深库位任务 | 
 |  |  | //                Task moveTask = locItemService.genMoveTask(params, loginUserId); | 
 |  |  | //                moveTask.setTaskType(task.getSort() + 1); | 
 |  |  | // | 
 |  |  | //                return moveTask; | 
 |  |  | //            } | 
 |  |  |         } else { | 
 |  |  |             //浅库位,判断深对应深库位是否为空,如果为空生成一个移库任务,将托盘送入深库位 | 
 |  |  |             String deepLoc = LocUtils.getDeepLoc(curLoc); | 
 |  |  |             if (StringUtils.isBlank(deepLoc)) { | 
 |  |  |                 throw new CoolException("数据异常,请联系管理员!"); | 
 |  |  |             } | 
 |  |  |             Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, deepLoc)); | 
 |  |  |             if (Objects.isNull(loc)) { | 
 |  |  |                 throw new CoolException("数据错误,库位不存在!!"); | 
 |  |  |             } | 
 |  |  |             //判断深库位是否为空 | 
 |  |  |             if (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { | 
 |  |  |                 LocToTaskParams params = new LocToTaskParams(); | 
 |  |  |                 params.setOrgLoc(curLoc).setTarLoc(deepLoc); | 
 |  |  |                 //生成移深库位任务 | 
 |  |  |                 locItemService.genMoveTask(params, loginUserId); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (!taskService.updateById(tasks)) { | 
 |  |  |             throw new CoolException("置顶失败!!"); | 
 |  |  |         } | 
 |  |  |         return null; | 
 |  |  |         return task; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     public R removeTask(Long[] ids, Long loginUserId) { | 
 |  |  |         List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); | 
 |  |  |         List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type, TaskType.TASK_TYPE_EMPITY_IN.type, TaskType.TASK_TYPE_EMPITY_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type); | 
 |  |  |         List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type,TaskType.TASK_TYPE_PICK_AGAIN_OUT.type, | 
 |  |  |                 TaskType.TASK_TYPE_CHECK_OUT.type,  TaskType.TASK_TYPE_EMPITY_IN.type, TaskType.TASK_TYPE_LOC_MOVE.type, | 
 |  |  |                 TaskType.TASK_TYPE_EMPITY_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type); | 
 |  |  |         List<Task> tasks = this.list(new LambdaQueryWrapper<Task>() | 
 |  |  |                 .in(Task::getTaskType, list) | 
 |  |  |                 .in(Task::getId, ids).in(Task::getTaskStatus, longs)); | 
 |  |  | 
 |  |  |             throw new CoolException("任务已处执行状态不可取消!!"); | 
 |  |  |         } | 
 |  |  |         for (Task task : tasks) { | 
 |  |  |             //取消移库任务 | 
 |  |  |             if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type) && task.getTaskStatus().equals(TaskStsType.GENERATE_OUT.id)) { | 
 |  |  |                 if (!locService.update(new LambdaUpdateWrapper<Loc>() | 
 |  |  |                         .eq(Loc::getCode, task.getOrgLoc()) | 
 |  |  |                         .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type))) { | 
 |  |  |                     throw new CoolException("源库位状态修改失败!!"); | 
 |  |  |                 } | 
 |  |  |                 if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()).set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type))) { | 
 |  |  |                     throw new CoolException("移库目标库位状态修改失败!!"); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 Task outTask = taskService.getById(task.getParentId()); | 
 |  |  |                 if (!Objects.isNull(outTask)) { | 
 |  |  |                     LocToTaskParams params = new LocToTaskParams(); | 
 |  |  |                     params.setOrgLoc(task.getOrgLoc()).setSiteNo(task.getOrgSite()); | 
 |  |  |                     //生成移深库位任务 | 
 |  |  |                     Task moveTask = locItemService.genMoveTask(params, loginUserId); | 
 |  |  |                     moveTask.setSort(task.getSort() + 1).setParentId(outTask.getId()); | 
 |  |  |                     if (!this.updateById(moveTask)) { | 
 |  |  |                         throw new CoolException("任务信息修改失败!!"); | 
 |  |  |                     } | 
 |  |  |                     outTask.setParentId(moveTask.getId()); | 
 |  |  |                     if (!this.updateById(outTask)) { | 
 |  |  |                         throw new CoolException("任务信息修改失败!!"); | 
 |  |  |  | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 } else { | 
 |  |  |                     throw new CoolException("无法生成新的移库任务,取消失败!!"); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.val)) { | 
 |  |  |                 BasStation basStation = null; | 
 |  |  |                 if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) { | 
 |  |  | 
 |  |  |                         || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) | 
 |  |  |                         || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type) | 
 |  |  |                         || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) | 
 |  |  |                         || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type) | 
 |  |  |                 ) { | 
 |  |  |                         || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)) { | 
 |  |  |                     basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() | 
 |  |  |                             .eq(BasStation::getStationName, task.getTargLoc()) | 
 |  |  |                             .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type)); |