1
23 小时以前 c2ead3c7e7f1db81b6fc961e0f037abd0e8a4e2c
lsh#
2个文件已修改
218 ■■■■■ 已修改文件
rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/WcsTaskReportParam.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java 215 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/params/WcsTaskReportParam.java
@@ -37,4 +37,7 @@
    @ApiModelProperty("消息数据")
    private String data;
    @ApiModelProperty("类别")
    private Integer type = 0;
}
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -586,112 +586,137 @@
        if (Objects.isNull(basStation)) {
            throw new CoolException("站点不存在!!");
        }
        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(basStation.getStationName()));
        if (Cools.isEmpty(deviceBind)) {
            throw new CoolException("库位规则未知");
        List<WarehouseAreas> warehouseAreasList = new ArrayList<>();
        if (basStation.getIsWcs() == 1){
            DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(basStation.getStationName()));
            if (Cools.isEmpty(deviceBind)) {
                throw new CoolException("库位规则未知");
            }
            WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
            if (Cools.isEmpty(warehouseArea)) {
                throw new CoolException("未找到所属库区信息");
            }
            warehouseAreasList.add(warehouseArea);
        } else {
            List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class);
            if (areaList.isEmpty()) {
                throw new CoolException("当前站点库区未配置");
            }
            warehouseAreasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().in(WarehouseAreas::getId,areaList));
        }
        WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
        if (Cools.isEmpty(warehouseArea)) {
        if (Cools.isEmpty(warehouseAreasList) || warehouseAreasList.size() == 0) {
            throw new CoolException("未找到所属库区信息");
        }
        /**获取组拖*/
        List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                .in(WaitPakin::getId, ids)
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        if (waitPakins.isEmpty()) {
            throw new CoolException("请检查组拖状态是否完成!!");
        }
        waitPakins.forEach(pakin -> {
            //验证基础信息
            checkStaStatus(pakin.getBarcode(),basStation.getStationName(),warehouseArea.getId().toString());
        final String[] errMsg = {""};
        for (WarehouseAreas warehouseArea : warehouseAreasList) {
            /**获取组拖*/
            List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
            List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                    .in(WaitPakin::getId, ids)
                    .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
            if (waitPakins.isEmpty()) {
                throw new CoolException("请检查组拖状态是否完成!!");
            }
            boolean sign = true;
            for (WaitPakin pakin : waitPakins) {//验证基础信息
                try {
                    checkStaStatus(pakin.getBarcode(), basStation.getStationName(), warehouseArea.getId().toString());
                } catch (Exception e) {
                    errMsg[0] = errMsg[0] + e.getMessage();
                    sign = false;
                    break;
                }
//            BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
//                    .eq(BasContainer::getCode, pakin.getBarcode()));
//            if (Objects.isNull(container)) {
//                throw new CoolException("容器未维护入库,请维护后再操作!!");
//            }
            /**获取库位*/
            String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(),null,rowList);
            if (Cools.isEmpty(targetLoc)) {
                throw new CoolException("该站点对应库区未找到库位");
            }
            List<TaskItem> taskItems = new ArrayList<>();
            String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
            if (StringUtils.isBlank(ruleCode)) {
                throw new CoolException("编码错误:请确认编码「SYS_TASK_CODE」是否已生成!!");
            }
            String staNoEnd = basStation.getStationName();
            if (basStation.getIsWcs()!=0){
                staNoEnd = "B102";
            }
            Task task = new Task();
            task.setTaskCode(ruleCode)
                    .setTaskStatus(TaskStsType.WCS_EXECUTE_IN.id)
                    .setTaskType(TaskType.TASK_TYPE_IN.type)
                    .setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val)
                    .setTargLoc(targetLoc)
                    .setBarcode(pakin.getBarcode())
                    .setOrgSite(basStation.getStationName())
                    .setTargSite(staNoEnd)
                    .setCreateBy(loginUserId)
                    .setUpdateBy(loginUserId);
            if (!this.save(task)) {
                throw new CoolException("任务保存失败!!");
            }
            if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
                throw new CoolException("库位预约失败!!");
            }
            /**获取组拖明细**/
            List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
            if (waitPakinItems.isEmpty()) {
                throw new CoolException("数据错误:组拖明细不存在");
            }
            waitPakinItems.forEach(item -> {
                TaskItem taskItem = new TaskItem();
                BeanUtils.copyProperties(item, taskItem);
                taskItem.setTaskId(task.getId())
                        .setOrderType(OrderType.ORDER_IN.type)
                        .setSource(item.getId())
                        .setTrackCode(item.getTrackCode())
                        .setPlatItemId(item.getPlatItemId())
                        .setPlatOrderCode(item.getPlatOrderCode())
                        .setPlatWorkCode(item.getPlatWorkCode())
                        .setProjectCode(item.getProjectCode())
                        .setCreateBy(loginUserId)
                        .setUpdateBy(loginUserId)
                        .setExtendFields(item.getExtendFields())
                        .setOrderId(item.getAsnId())
                        .setOrderItemId(item.getAsnItemId());
                taskItems.add(taskItem);
            });
            if (!taskItemService.saveBatch(taskItems)) {
                throw new CoolException("任务明细保存失败!!");
            }
            waitPakinItems.forEach(item -> {
                if (!waitPakinItemService.update(new LambdaUpdateWrapper<WaitPakinItem>()
                        .set(WaitPakinItem::getWorkQty, item.getAnfme())
                        .eq(WaitPakinItem::getId, item.getId()))) {
                    throw new CoolException("组托明细修执行数量修改失败!!");
                /**获取库位*/
                String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), null, rowList);
                if (Cools.isEmpty(targetLoc)) {
                    throw new CoolException("该站点对应库区未找到库位");
                }
            });
        });
        if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
                .in(WaitPakin::getId, ids)
                .set(WaitPakin::getUpdateBy, loginUserId)
                .set(WaitPakin::getCreateBy, loginUserId)
                .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
            throw new CoolException("组拖状态修改失败!!");
                List<TaskItem> taskItems = new ArrayList<>();
                String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
                if (StringUtils.isBlank(ruleCode)) {
                    throw new CoolException("编码错误:请确认编码「SYS_TASK_CODE」是否已生成!!");
                }
                String staNoEnd = basStation.getStationName();
                if (basStation.getIsWcs() != 0) {
                    staNoEnd = "B102";
                }
                Task task = new Task();
                task.setTaskCode(ruleCode)
                        .setTaskStatus(TaskStsType.WCS_EXECUTE_IN.id)
                        .setTaskType(TaskType.TASK_TYPE_IN.type)
                        .setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val)
                        .setTargLoc(targetLoc)
                        .setBarcode(pakin.getBarcode())
                        .setOrgSite(basStation.getStationName())
                        .setTargSite(staNoEnd)
                        .setCreateBy(loginUserId)
                        .setUpdateBy(loginUserId);
                if (!this.save(task)) {
                    throw new CoolException("任务保存失败!!");
                }
                if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
                    throw new CoolException("库位预约失败!!");
                }
                /**获取组拖明细**/
                List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
                if (waitPakinItems.isEmpty()) {
                    throw new CoolException("数据错误:组拖明细不存在");
                }
                waitPakinItems.forEach(item -> {
                    TaskItem taskItem = new TaskItem();
                    BeanUtils.copyProperties(item, taskItem);
                    taskItem.setTaskId(task.getId())
                            .setOrderType(OrderType.ORDER_IN.type)
                            .setSource(item.getId())
                            .setTrackCode(item.getTrackCode())
                            .setPlatItemId(item.getPlatItemId())
                            .setPlatOrderCode(item.getPlatOrderCode())
                            .setPlatWorkCode(item.getPlatWorkCode())
                            .setProjectCode(item.getProjectCode())
                            .setCreateBy(loginUserId)
                            .setUpdateBy(loginUserId)
                            .setExtendFields(item.getExtendFields())
                            .setOrderId(item.getAsnId())
                            .setOrderItemId(item.getAsnItemId());
                    taskItems.add(taskItem);
                });
                if (!taskItemService.saveBatch(taskItems)) {
                    throw new CoolException("任务明细保存失败!!");
                }
                waitPakinItems.forEach(item -> {
                    if (!waitPakinItemService.update(new LambdaUpdateWrapper<WaitPakinItem>()
                            .set(WaitPakinItem::getWorkQty, item.getAnfme())
                            .eq(WaitPakinItem::getId, item.getId()))) {
                        throw new CoolException("组托明细修执行数量修改失败!!");
                    }
                });
            }
            if (!sign){
                continue;
            }
            if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
                    .in(WaitPakin::getId, ids)
                    .set(WaitPakin::getUpdateBy, loginUserId)
                    .set(WaitPakin::getCreateBy, loginUserId)
                    .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
                throw new CoolException("组拖状态修改失败!!");
            }
            return R.ok("任务生成完毕!");
        }
        return R.ok("任务生成完毕!");
        String msg = "未找库位" + Arrays.toString(errMsg);
        throw new CoolException(msg);
    }
    /**