chen.lin
昨天 98d88ac8caf7f0991d741079474c262f1e252927
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -4,12 +4,14 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.CoercionAction;
import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.DateUtils;
import com.vincent.rsf.server.api.config.RemotesInfoProperties;
import com.vincent.rsf.server.api.controller.erp.params.InOutResultReportParam;
import com.vincent.rsf.server.api.controller.erp.params.TaskInParam;
import com.vincent.rsf.server.api.entity.CommonResponse;
import com.vincent.rsf.server.api.entity.constant.RcsConstant;
@@ -26,6 +28,7 @@
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.api.utils.LocUtils;
import com.vincent.rsf.server.manager.controller.params.GenerateTaskParams;
import com.vincent.rsf.server.manager.entity.CloudWmsNotifyLog;
import com.vincent.rsf.server.manager.entity.*;
import com.vincent.rsf.server.manager.mapper.TaskMapper;
import com.vincent.rsf.server.manager.service.*;
@@ -124,6 +127,10 @@
    private RestTemplate restTemplate;
    @Autowired
    private RemotesInfoProperties.RcsApi rcsApi;
    @Autowired
    private CloudWmsNotifyLogService cloudWmsNotifyLogService;
    @Autowired
    private WarehouseService warehouseService;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -460,16 +467,18 @@
        if (success.compareAndSet(false, true)) {
            Long loginUserId = SystemAuthUtils.getLoginUserId();
            for (Task task : tasks) {
                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
                    //1.入库
                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)) {
                    //1.入库、54.并板再入库
                    complateInstock(task, loginUserId);
                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                    //53.拣料再入库
                    //57.盘点再入库
                    //53.拣料再入库、57.盘点再入库
                    pickComplateInStock(task, loginUserId);
                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
                    //移库
                    //11.库格移载
                    moveInStock(task, loginUserId);
                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
                    //10.空板入库:与普通入库共用一个完成逻辑(若有组托则更新组托/库位并上报云仓)
                    complateInstock(task, loginUserId);
                }
            }
        }
@@ -805,7 +814,11 @@
                .set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
            throw new CoolException("任务状态修改失败!!");
        }
        // 9.1 入/出库结果上报:库格移载完成后通知云仓(与定时任务闭环一致)
        List<TaskItem> moveTaskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
        if (!moveTaskItems.isEmpty()) {
            reportInOutResultToCloud(task, loc, moveTaskItems, null, true);
        }
    }
@@ -904,7 +917,8 @@
        if (!taskService.updateById(task)) {
            throw new CoolException("任务状态修改失败!!");
        }
        // 9.1 入/出库结果上报:拣料再入库/盘点再入库完成后通知云仓(与定时任务闭环一致)
        reportInOutResultToCloud(task, loc, taskItems, null, true);
    }
    /**
@@ -1369,6 +1383,15 @@
            });
            log.debug("[拣料入库] 即将扣减库位 locId={}, locCode={}", loc.getId(), loc.getCode());
            subtractLocItemByTaskItems(loc, taskItems, SystemAuthUtils.getLoginUserId());
            // 料箱已全部用完则不生成拣货入库单,仅完结出库
            double totalRemaining = taskItems.stream().mapToDouble(ti -> ti.getAnfme() != null && ti.getAnfme().compareTo(0.0) > 0 ? ti.getAnfme() : 0.0).sum();
            if (totalRemaining <= 0.0) {
                task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type);
                task.setTaskStatus(TaskStsType.UPDATED_OUT.id);
                this.updateById(task);
                locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
                return task;
            }
        }
        tempLocs.forEach(working -> {
@@ -1464,6 +1487,137 @@
    }
    /**
     * 同箱码下多条 200 拣料出库一次性处理:按相同物料合计扣减库位、更新出库单/库存明细、生成一张拣料入库单(有余量时)、更新库位状态
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void processPickOutBarcodeAll200(List<Task> all200Tasks) {
        if (all200Tasks == null || all200Tasks.isEmpty()) {
            return;
        }
        Task first = all200Tasks.get(0);
        if (!TaskType.TASK_TYPE_PICK_AGAIN_OUT.type.equals(first.getTaskType()) || !TaskStsType.UPDATED_OUT.id.equals(first.getTaskStatus())) {
            throw new CoolException("非拣料出库200任务,不可批量处理");
        }
        List<Long> taskIds = all200Tasks.stream().map(Task::getId).collect(Collectors.toList());
        List<TaskItem> allItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, taskIds));
        if (allItems.isEmpty()) {
            throw new CoolException("任务明细为空");
        }
        Long loginUserId = SystemAuthUtils.getLoginUserId();
        if (loginUserId == null) {
            loginUserId = 1L;
        }
        String orgLoc = first.getOrgLoc();
        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, orgLoc));
        if (loc == null) {
            throw new CoolException("库位不存在:" + orgLoc);
        }
        // 按物料+批次+票号汇总已拣数量
        Map<String, List<TaskItem>> byKey = allItems.stream().collect(Collectors.groupingBy(ti ->
                (ti.getMatnrId() != null ? ti.getMatnrId() : "") + "_" + (ti.getBatch() != null ? ti.getBatch() : "") + "_" + (ti.getFieldsIndex() != null ? ti.getFieldsIndex() : "")));
        List<TaskItem> aggregatedForDeduct = new ArrayList<>();
        Map<String, Double> remainderByKey = new LinkedHashMap<>();
        for (Map.Entry<String, List<TaskItem>> e : byKey.entrySet()) {
            List<TaskItem> group = e.getValue();
            double totalQty = group.stream().mapToDouble(ti -> ti.getQty() != null && ti.getQty() > 0 ? ti.getQty() : (ti.getAnfme() != null ? ti.getAnfme() : 0)).sum();
            TaskItem rep = group.get(0);
            TaskItem forDeduct = new TaskItem();
            forDeduct.setMatnrId(rep.getMatnrId()).setBatch(rep.getBatch()).setFieldsIndex(rep.getFieldsIndex()).setQty(totalQty);
            aggregatedForDeduct.add(forDeduct);
            LambdaQueryWrapper<LocItem> qw = new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()).eq(LocItem::getMatnrId, rep.getMatnrId());
            if (StringUtils.isNotBlank(rep.getBatch())) qw.eq(LocItem::getBatch, rep.getBatch());
            else qw.and(w -> w.isNull(LocItem::getBatch).or().eq(LocItem::getBatch, ""));
            if (StringUtils.isNotBlank(rep.getFieldsIndex())) qw.eq(LocItem::getFieldsIndex, rep.getFieldsIndex());
            else qw.and(w -> w.isNull(LocItem::getFieldsIndex).or().eq(LocItem::getFieldsIndex, ""));
            LocItem li = locItemService.getOne(qw);
            double remainder = (li != null && li.getAnfme() != null ? li.getAnfme() : 0) - totalQty;
            if (remainder > 0) {
                remainderByKey.put(e.getKey(), remainder);
            }
        }
        subtractLocItemByTaskItems(loc, aggregatedForDeduct, loginUserId);
        // 按 source 分组更新出库单并写库存流水
        Map<Long, List<TaskItem>> bySource = allItems.stream().collect(Collectors.groupingBy(TaskItem::getSource));
        for (Map.Entry<Long, List<TaskItem>> e : bySource.entrySet()) {
            Long key = e.getKey();
            List<TaskItem> items = e.getValue();
            if (first.getResource() != null && first.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) {
                WaveItem waveItem = waveItemService.getById(key);
                if (waveItem != null) {
                    try {
                        saveOutStockItem(items, null, waveItem, null, loginUserId);
                    } catch (Exception ex) {
                        throw new CoolException(ex.getMessage());
                    }
                }
            } else if (first.getResource() != null && first.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) {
                WkOrderItem orderItem = asnOrderItemService.getById(key);
                if (orderItem != null) {
                    try {
                        saveOutStockItem(items, orderItem, null, null, loginUserId);
                    } catch (Exception ex) {
                        throw new CoolException(ex.getMessage());
                    }
                }
            }
        }
        // 有余量则生成一张拣料入库单
        if (!remainderByKey.isEmpty()) {
            Task pickInTask = new Task();
            pickInTask.setTaskCode(SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, first));
            pickInTask.setTaskType(TaskType.TASK_TYPE_PICK_IN.type);
            pickInTask.setTaskStatus(TaskStsType.GENERATE_IN.id);
            pickInTask.setBarcode(first.getBarcode());
            pickInTask.setOrgLoc(orgLoc);
            pickInTask.setTargLoc(orgLoc);
            pickInTask.setOrgSite(first.getTargSite());
            pickInTask.setTargSite(first.getTargSite());
            pickInTask.setResource(first.getResource());
            if (!this.save(pickInTask)) {
                throw new CoolException("拣料入库任务创建失败");
            }
            List<LocItemWorking> workings = new ArrayList<>();
            for (Map.Entry<String, Double> re : remainderByKey.entrySet()) {
                String k = re.getKey();
                Double rem = re.getValue();
                if (rem == null || rem <= 0) continue;
                List<TaskItem> group = byKey.get(k);
                if (group == null || group.isEmpty()) continue;
                TaskItem rep = group.get(0);
                TaskItem ti = new TaskItem();
                ti.setTaskId(pickInTask.getId());
                ti.setMatnrId(rep.getMatnrId()).setMaktx(rep.getMaktx()).setMatnrCode(rep.getMatnrCode());
                ti.setBatch(rep.getBatch()).setFieldsIndex(rep.getFieldsIndex()).setUnit(rep.getUnit()).setSpec(rep.getSpec()).setModel(rep.getModel());
                ti.setAnfme(rem).setQty(0.0);
                taskItemService.save(ti);
                LocItemWorking w = new LocItemWorking();
                w.setTaskId(pickInTask.getId());
                w.setLocId(loc.getId());
                w.setLocCode(loc.getCode());
                w.setMatnrId(rep.getMatnrId()).setMaktx(rep.getMaktx()).setMatnrCode(rep.getMatnrCode());
                w.setBatch(rep.getBatch()).setFieldsIndex(rep.getFieldsIndex()).setUnit(rep.getUnit());
                w.setAnfme(rem);
                workings.add(w);
            }
            if (!workings.isEmpty()) {
                locItemWorkingService.saveBatch(workings);
            }
            loc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
            locService.updateById(loc);
        } else {
            loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
            loc.setBarcode(null);
            loc.setUpdateBy(loginUserId);
            loc.setUpdateTime(new Date());
            locService.updateById(loc);
        }
        for (Long tid : taskIds) {
            locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, tid));
        }
    }
    /**
     * @author Ryan
     * @date 2025/5/20
     * @description: 完成出库任务,更新出库库存信息
@@ -1479,7 +1633,35 @@
        if (Objects.isNull(loc)) {
            throw new CoolException("库位不存在!!");
        }
        // 空板出库:无任务明细,不需要 PDA 拣货确认,RCS 回调后直接完成库位更新并置为 UPDATED_OUT
        if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)) {
            List<TaskItem> emptyItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
            if (emptyItems.isEmpty()) {
                if (!LocStsType.LOC_STS_TYPE_R.type.equals(loc.getUseStatus())) {
                    log.warn("空板出库任务{}的库位{}状态不是R.出库预约,跳过", task.getId(), loc.getCode());
                    return;
                }
                if (!locService.update(new LambdaUpdateWrapper<Loc>()
                        .eq(Loc::getId, loc.getId())
                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                        .set(Loc::getBarcode, null)
                        .set(Loc::getUpdateBy, loginUserId)
                        .set(Loc::getUpdateTime, new Date()))) {
                    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::getTaskStatus, TaskStsType.UPDATED_OUT.id))) {
                    throw new CoolException("空板出库任务状态更新失败!!");
                }
                log.info("[空板出库] 任务{} RCS回调后已直接完成库位更新,无需PDA确认", task.getTaskCode());
                return;
            }
        }
        List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
        if (taskItems.isEmpty()) {
            throw new CoolException("任务明细不存在!!");
@@ -1557,11 +1739,11 @@
                    if (Objects.isNull(waveItem)) {
                        throw new CoolException("波次明细不存在!!");
                    }
//                    try {
//                        saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId);
//                    } catch (Exception e) {
//                        throw new CoolException(e.getMessage());
//                    }
                    try {
                        saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId);
                    } catch (Exception e) {
                        throw new CoolException(e.getMessage());
                    }
                } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) {
                    WkOrderItem orderItem = asnOrderItemService.getById(key);
                    if (Objects.isNull(orderItem)) {
@@ -1596,15 +1778,8 @@
        
        // 根据任务类型更新库位状态
        if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
            /**修改为库位状态为S.预约入库,保留原有库位*/
            if (!locService.update(new LambdaUpdateWrapper<Loc>()
                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
                    .set(Loc::getBarcode, null)
                    .set(Loc::getUpdateBy, loginUserId)
                    .set(Loc::getUpdateTime, new Date())
                    .eq(Loc::getId, loc.getId()))) {
                throw new CoolException("库位状态修改失败!!");
            }
            // 拣料出库/盘点出库:在未生成拣料入库单之前保持 R.预约出库,否则下发任务时查不到该库位(只查 F+R)导致“库存不足”
            // 等 PDA 确认并生成拣料入库任务时,再在 pickOrCheckTask 中将目标库位改为 S.预约入库
        } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
            // 全版出库:不更新库位状态为O,等待PDA快速拣货确认时再更新
            // 库位状态保持原样(R.出库预约状态)
@@ -1627,6 +1802,8 @@
                .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
            throw new CoolException("库存状态更新失败!!");
        }
        // 9.1 入/出库结果上报:出库完成后通知云仓
        reportInOutResultToCloud(task, loc, taskItems, null, false);
//        if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
//            if (!this.update(new LambdaUpdateWrapper<Task>()
@@ -1687,8 +1864,35 @@
                .setUpdateTime(new Date())
                .setAnfme(sum);
        if (!Objects.isNull(waveItem)) {
            //TODO 生成波次时需要将波次号写入单据,通过物料,批次,动态字段等唯一值反查单据信息
            // 波次出库:更新出库单完成数量及出库单明细执行数量
            stock.setSourceId(waveItem.getId()).setType(OrderType.ORDER_OUT.type);
            Long orderId = waveItem.getOrderId();
            if (orderId != null) {
                WkOrder wkOrder = asnOrderService.getById(orderId);
                if (wkOrder != null) {
                    Double curQty = wkOrder.getQty() != null ? wkOrder.getQty() : 0.0;
                    Double newQty = QuantityUtils.roundToScale(curQty + sum);
                    wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val).setQty(newQty);
                    if (!asnOrderService.updateById(wkOrder)) {
                        throw new CoolException("出库单完成数量更新失败!!");
                    }
                }
                // 按出库单明细汇总本次任务数量,更新各明细 workQty
                Map<Long, Double> sumByOrderItemId = taskItems.stream()
                        .filter(ti -> ti.getOrderItemId() != null)
                        .collect(Collectors.groupingBy(TaskItem::getOrderItemId,
                                Collectors.summingDouble(ti -> ti.getAnfme() != null ? ti.getAnfme() : 0.0)));
                for (Map.Entry<Long, Double> e : sumByOrderItemId.entrySet()) {
                    WkOrderItem oi = outStockItemService.getById(e.getKey());
                    if (oi != null) {
                        Double wq = oi.getWorkQty() != null ? oi.getWorkQty() : 0.0;
                        oi.setWorkQty(QuantityUtils.roundToScale(wq + e.getValue()));
                        if (!outStockItemService.updateById(oi)) {
                            throw new CoolException("出库单明细执行数量更新失败!!");
                        }
                    }
                }
            }
        } else if (!Objects.isNull(orderItem) && StringUtils.isNotBlank(orderItem.getId() + "")) {
            WkOrder wkOrder = asnOrderService.getById(orderItem.getOrderId());
            Double qty = Math.round((wkOrder.getQty() + sum) * 1000000) / 1000000.0;
@@ -2213,7 +2417,7 @@
            List<TaskItem> items = orderMap.get(key);
            //保存入出库明细
            saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId);
            //移出收货区库存, 修改组托状态(只有当source不为null时才需要移除收货区库存)
            // DirectWaitPakin 启用时组托来自收货区,入库完成后移出收货区库存;未启用时 source 为 null 不执行
            if (Objects.nonNull(pakinItem.getSource())) {
                removeReceiptStock(pakinItem, loginUserId);
            }
@@ -2240,6 +2444,8 @@
        if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
            throw new CoolException("任务状态修改失败!!");
        }
        // 9.1 入/出库结果上报:入库完成后通知云仓
        reportInOutResultToCloud(task, loc, taskItems, pkinItemIds, true);
    }
    /**
@@ -2311,12 +2517,12 @@
                locItemWrapper.and(wrapper -> wrapper.isNull(LocItem::getBatch).or().eq(LocItem::getBatch, ""));
            }
            
            // 票号匹配:如果taskItem有票号,则必须匹配;如果taskItem没有票号,则查询票号为null或空字符串的记录
            if (StringUtils.isNotBlank(taskItem.getFieldsIndex())) {
                locItemWrapper.eq(LocItem::getFieldsIndex, taskItem.getFieldsIndex());
            } else {
                locItemWrapper.and(wrapper -> wrapper.isNull(LocItem::getFieldsIndex).or().eq(LocItem::getFieldsIndex, ""));
            }
            // 票号暂不使用,不按票号匹配,只查票号为 null 或空的库位明细
            // if (StringUtils.isNotBlank(taskItem.getFieldsIndex())) {
            //     locItemWrapper.eq(LocItem::getFieldsIndex, taskItem.getFieldsIndex());
            // } else {
            locItemWrapper.and(wrapper -> wrapper.isNull(LocItem::getFieldsIndex).or().eq(LocItem::getFieldsIndex, ""));
            // }
            
            LocItem locItem = locItemService.getOne(locItemWrapper);
            if (Objects.isNull(locItem)) {
@@ -2408,4 +2614,72 @@
            }
        }
    }
    /**
     * 9.1 入/出库结果上报待办
     * @param isInbound true 入库完成,false 出库完成
     * @param pkinItemIds 入库时组托明细 ID 集合,用于查 asnCode 作为 orderNo;出库时传 null,用 taskItem.platOrderCode
     */
    private void reportInOutResultToCloud(Task task, Loc loc, List<TaskItem> taskItems, Set<Long> pkinItemIds, boolean isInbound) {
        try {
            String locId = isInbound ? task.getTargLoc() : task.getOrgLoc();
            String wareHouseId = null;
            if (loc.getWarehouseId() != null) {
                Warehouse wh = warehouseService.getById(loc.getWarehouseId());
                if (wh != null) {
                    wareHouseId = wh.getCode();
                }
            }
            if (wareHouseId == null) {
                log.warn("入/出库结果上报待办跳过:仓库编码为空,taskId={}", task.getId());
                return;
            }
            Map<Long, String> sourceToOrderNo = new HashMap<>();
            if (isInbound && pkinItemIds != null && !pkinItemIds.isEmpty()) {
                List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().in(WaitPakinItem::getId, pkinItemIds));
                for (WaitPakinItem p : pakinItems) {
                    if (p.getAsnCode() != null) {
                        sourceToOrderNo.put(p.getId(), p.getAsnCode());
                    }
                }
            }
            ObjectMapper om = new ObjectMapper();
            Date now = new Date();
            for (TaskItem item : taskItems) {
                String orderNo = isInbound ? sourceToOrderNo.get(item.getSource()) : (item.getPlatOrderCode() != null ? item.getPlatOrderCode() : item.getPlatWorkCode());
                if (orderNo == null && isInbound) {
                    orderNo = item.getPlatOrderCode() != null ? item.getPlatOrderCode() : item.getPlatWorkCode();
                }
                if (orderNo == null || item.getMatnrCode() == null) {
                    continue;
                }
                InOutResultReportParam param = new InOutResultReportParam()
                        .setOrderNo(orderNo)
                        .setPlanNo(item.getPlatWorkCode())
                        .setLineId(item.getPlatItemId())
                        .setWareHouseId(wareHouseId)
                        .setLocId(locId)
                        .setMatNr(item.getMatnrCode())
                        .setQty(item.getAnfme() != null ? String.valueOf(item.getAnfme()) : "0")
                        .setBatch(item.getBatch());
                try {
                    String requestBody = om.writeValueAsString(param);
                    CloudWmsNotifyLog notifyLog = new CloudWmsNotifyLog()
                            .setReportType(cloudWmsNotifyLogService.getReportTypeInOutResult())
                            .setRequestBody(requestBody)
                            .setNotifyStatus(cloudWmsNotifyLogService.getNotifyStatusPending())
                            .setRetryCount(0)
                            .setBizRef("taskId=" + task.getId() + ",orderNo=" + orderNo)
                            .setCreateTime(now)
                            .setUpdateTime(now);
                    cloudWmsNotifyLogService.fillFromConfig(notifyLog);
                    cloudWmsNotifyLogService.save(notifyLog);
                } catch (JsonProcessingException e) {
                    log.warn("入/出库结果上报待办落库失败(不影响主流程),taskId={},orderNo={}:{}", task.getId(), orderNo, e.getMessage());
                }
            }
        } catch (Exception e) {
            log.warn("入/出库结果上报待办失败,taskId={},isInbound={}:{}", task.getId(), isInbound, e.getMessage());
        }
    }
}