package com.prolog.eis.service.logic.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.prolog.eis.common.util.PrologStringUtils;
import com.prolog.eis.constants.redisKey.RedisKey;
import com.prolog.eis.dao.out.OrderLogMapper;
import com.prolog.eis.dto.dps.BaseDpsConstants;
import com.prolog.eis.dto.dps.DpsLightLabelCall;
import com.prolog.eis.dto.dps.DpsLightLabelInfoCall;
import com.prolog.eis.dto.dps.DpsSendListDto;
import com.prolog.eis.dto.item.ItemSyncVO;
import com.prolog.eis.dto.wcs.WcsCarDto;
import com.prolog.eis.dto.wcs.WcsCarryBackDto;
import com.prolog.eis.dto.wcs.WcsCarryTaskDto;
import com.prolog.eis.dto.wcs.WcsGirdDto;
import com.prolog.eis.enums.base.BaseStatusEnum;
import com.prolog.eis.model.out.BizOutboundTaskDetailDismantle;
import com.prolog.eis.model.out.BizOutboundTaskDetailItem;
import com.prolog.eis.model.out.BizOutboundTaskDetailItemHis;
import com.prolog.eis.model.out.BizOutboundTaskDismantleSupply;
import com.prolog.eis.model.outbound.BizOutboundTask;
import com.prolog.eis.model.outbound.OrderLog;
import com.prolog.eis.model.outbound.PrintTask;
import com.prolog.eis.model.shelves.AllotmentTaskRecord;
import com.prolog.eis.model.shelves.AllotmentTaskRecordHis;
import com.prolog.eis.model.shelves.GridInfo;
import com.prolog.eis.service.dps.DpsLightLabelReported;
import com.prolog.eis.service.logic.WcsTaskService;
import com.prolog.eis.service.out.*;
import com.prolog.eis.service.shelves.AllotmentTaskRecordHisService;
import com.prolog.eis.service.shelves.AllotmentTaskRecordService;
import com.prolog.eis.service.shelves.GridInfoService;
import com.prolog.eis.service.shelves.ItemService;
import com.prolog.eis.service.wcs.WcsCarryTaskService;
import com.prolog.framework.beans.BeanUtils;
import com.prolog.framework.core.exception.PrologException;
import com.prolog.framework.core.restriction.Criteria;
import com.prolog.framework.core.restriction.Restrictions;
import com.prolog.framework.utils.AssertUtils;
import com.prolog.eis.utils.MapUtils;
import com.prolog.framework.utils.ObjectUtils;
import com.prolog.framework.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author zmr
 * @description: 出库任务表-服务实现类
 * @date 2023-07-06 11:36
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class WcsTaskServiceImpl implements WcsTaskService {

    private final BizOutboundTaskService bizOutboundTaskService;
    private final GridInfoService gridInfoService;
    private final ItemService itemService;
    private final BizOutboundTaskDetailDismantleService bizOutboundTaskDetailDismantleService;
    private final AllotmentTaskRecordService allotmentTaskRecordService;
    private final AllotmentTaskRecordHisService allotmentTaskRecordHisService;
    private final WcsCarryTaskService wcsCarryTaskService;
    private final DpsLightLabelReported dpsLightLabelReported;
    private final BizOutboundTaskDismantleSupplyService bizOutboundTaskDismantleSupplyService;
    private final BizOutboundTaskDetailItemService bizOutboundTaskDetailItemService;
    private final BizOutboundTaskDetailItemHisService outboundTaskDetailItemHisService;
    private final RedisTemplate redisTemplate;
    private final PrintTaskService printTaskService;
    private final OrderLogMapper orderLogMapper;


    /**
     * 交叉带分拣机mcs搬运任务发送
     *
     * @param allotmentTaskRecord
     */
    @Override
    public void sendMcsCarryTask(AllotmentTaskRecord allotmentTaskRecord) {
        try {
            WcsCarryTaskDto wcsCarryTaskDto = new WcsCarryTaskDto();
            wcsCarryTaskDto.setTaskid(PrologStringUtils.newGUID());
            wcsCarryTaskDto.setFromloc(allotmentTaskRecord.getAllotmentNo());
            wcsCarryTaskDto.setTolocList(allotmentTaskRecord.getGirdNo().split(","));
            if (!StringUtils.isEmpty(allotmentTaskRecord.getItemId())) {
                ItemSyncVO itemBaseInfoVO = itemService.queryItemMst(Arrays.asList(allotmentTaskRecord.getItemId())).stream().findFirst().orElse(null);
                if (!Objects.isNull(itemBaseInfoVO)) {
                    wcsCarryTaskDto.setItemname(itemBaseInfoVO.getItemName());
                }
            }
            if (allotmentTaskRecord.getQty().compareTo(BigDecimal.ZERO) == 0) {
                allotmentTaskRecord.setQty(BigDecimal.ONE);
            }
            if (StringUtils.isBlank(wcsCarryTaskDto.getItemname())) {
                wcsCarryTaskDto.setItemname("票据");
            }
            wcsCarryTaskDto.setQty(allotmentTaskRecord.getQty());
            wcsCarryTaskService.execute(wcsCarryTaskDto);
            allotmentTaskRecord.setWcsTaskId(wcsCarryTaskDto.getTaskid());
            allotmentTaskRecord.setErrorMsg("发送成功");
            allotmentTaskRecord.setSendStatus(1);
        } catch (Exception e) {
            allotmentTaskRecord.setSendStatus(2);
            allotmentTaskRecord.setErrorMsg(e.getMessage());
        }
        allotmentTaskRecord.setTaskIssueDate(new Date());
        allotmentTaskRecordService.update(allotmentTaskRecord);
    }

    /**
     * WCS落格回告
     * 根据taskid 查询当前发送记录
     * 修改记录状态
     * 判断订单是否全部落格（查看订单是否缺货或待补货，根据订单记录复核数量和拆零表计算数量做对比）
     * 如果缺货 1.缺货数量 + 复核数量  = 计划数量   为已全部落格   绑定单据是否全部落格   亮红灯
     * 如果为待补货 等待 订单补货
     *
     * @param wcsCarryBackDto
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void carryFinishBack(WcsCarryBackDto wcsCarryBackDto) {
        List<AllotmentTaskRecord> recordList = allotmentTaskRecordService.findByMap(null);
        AllotmentTaskRecord allotmentTaskRecord = recordList.stream().filter(o -> o.getWcsTaskId().equals(wcsCarryBackDto.getTaskid()) && o.getSendStatus() == 1).findFirst().orElse(null);
        AssertUtils.isNotTrue(ObjectUtils.isNull(allotmentTaskRecord), String.format("回告任务号错误,任务号：【%s】", wcsCarryBackDto.getTaskid()));
        BizOutboundTask bizOutboundTask = bizOutboundTaskService.findById(allotmentTaskRecord.getOutboundId());
        AssertUtils.isNotTrue(bizOutboundTask == null, "订单未查询到");

        if (wcsCarryBackDto.getStatus() == 1) {
            AssertUtils.isNotTrue(!allotmentTaskRecord.getGirdNo().equals(wcsCarryBackDto.getAcutoloc()), "实际落格格口和指定格口不符！");
        }
        //修改当前记录状态
        allotmentTaskRecord.setLogeGirdNo(wcsCarryBackDto.getAcutoloc());
        allotmentTaskRecord.setFallLatticeDate(new Date());
        allotmentTaskRecord.setLogeStatus(wcsCarryBackDto.getStatus());
        allotmentTaskRecordService.update(allotmentTaskRecord);

        //修改订单拆零
        if (allotmentTaskRecord.getDismantleId() != null) {
            List<AllotmentTaskRecord> tempList = recordList.stream().filter(o -> o.getDismantleId() != null && o.getDismantleId().equals(allotmentTaskRecord.getDismantleId())
                    && o.getLogeStatus() == 1 && o.getAllotmentType() == 0).collect(Collectors.toList());
            BigDecimal dismantleFhSum = tempList.stream().map(AllotmentTaskRecord::getQty)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            BizOutboundTaskDetailDismantle dismantle = bizOutboundTaskDetailDismantleService.findById(allotmentTaskRecord.getDismantleId());
            BigDecimal sjNum = dismantle.getPlanQty().subtract(dismantle.getLackQty()).subtract(dismantle.getOfferShowQty());
            //已落格数量  =  拆零计划数量  - 缺货数量   //当前详情已全部落格
            if (sjNum.compareTo(dismantleFhSum) == 0) {
                //当前拆零详情已全部落格
                dismantle.setStatus(BaseStatusEnum.STATUS_GRID.getCode());
                bizOutboundTaskDetailDismantleService.update(dismantle);
            }
        }
        //查询此订单所有绑定的格口
        List<GridInfo> gridInfoList = gridInfoService.findByMap(MapUtils.put(GridInfo::getOrderId, bizOutboundTask.getId()).getMap());
        //获取此次落格的格口
        GridInfo gridInfo = gridInfoList.stream().filter(item -> StrUtil.equals(item.getGridNo(), allotmentTaskRecord.getGirdNo())).findFirst().get();
        //校验此格口是否全部供包
        if (gridInfo.getSupplyFlag() == 0) {
            return;
        }
        //校验此格口是否已全部落格
        long notCount = recordList.stream().filter(item -> Objects.equals(item.getOutboundId(), bizOutboundTask.getId()) && StrUtil.equals(item.getGirdNo(), gridInfo.getGridNo()) && Arrays.asList(0, 2, 3).contains(item.getLogeStatus())).count();
        if (notCount > 0) {
            return;
        }
        //票据供包的格口需要等待票据落格
        if (gridInfo.getBillFlag() == 1 && !checkBill(bizOutboundTask, recordList)) {
            return;
        }
        //此订单最后绑定的格口需要等待补货任务完成
        if (gridInfo.getLastFlag() == 1 && !checkSupply(bizOutboundTask)) {
            return;
        }
        BigDecimal totalSum = recordList.stream().filter(o -> o.getOutboundId().equals(allotmentTaskRecord.getOutboundId())
                        && StrUtil.equals(o.getGirdNo(), gridInfo.getGridNo())
                        && o.getAllotmentType() == 0 && o.getLogeStatus() > 0).map(AllotmentTaskRecord::getQty)
                .reduce(BigDecimal.ZERO, BigDecimal::add);

        doScanLabelAndPrint(bizOutboundTask, allotmentTaskRecord, totalSum, gridInfo);
        gridInfo.setFallGrid(1);
        gridInfo.setUpdateTime(new Date());
        gridInfoService.update(gridInfo);

        //校验此订单所有供包是否已全部落格
        long count = gridInfoList.stream().filter(item -> item.getFallGrid() == 0).count();
        if (count == 0 && bizOutboundTask.getStatus().equals(BaseStatusEnum.STATUS_OFFER.getCode())) {
            bizOutboundTaskService.updateById(bizOutboundTask.getId(), MapUtils.put(BizOutboundTask::getExtend3, "1").getMap());
            //供包记录转历史
//            toHis(recordList, bizOutboundTask.getId());
        }
    }

    private boolean checkSupply(BizOutboundTask bizOutboundTask) {
        //存在待补货的数据
        long supplyCount = bizOutboundTaskDismantleSupplyService.findCountByMap(MapUtils.put(BizOutboundTaskDismantleSupply::getOutboundId, bizOutboundTask.getId()).getMap());
        if (supplyCount > 0) {
            return false;
        }
        return true;
    }

    private boolean checkBill(BizOutboundTask bizOutboundTask, List<AllotmentTaskRecord> recordList) {
        recordList = recordList.stream().filter(o -> o.getOutboundId().equals(bizOutboundTask.getId())).collect(Collectors.toList());
        //判断对应的票据是否落格
        if (!StringUtils.isEmpty(bizOutboundTask.getIsPrintQuality()) && bizOutboundTask.getIsPrintQuality().equals("1")) {
            //首营、质检需要打印  是否落格
            Long qualityCount = recordList.stream().filter(o -> o.getAllotmentType() == 1).count();
            if (qualityCount == 0) {
                return false;
            }
        }
        if (!StringUtils.isEmpty(bizOutboundTask.getIsPrintInvoice()) && bizOutboundTask.getIsPrintInvoice().equals("1")) {
            //发票、清单需要打印  是否落格
            Long invoiceCount = recordList.stream().filter(o -> o.getAllotmentType() == 2).count();
            if (invoiceCount == 0) {
                return false;
            }
        }
        return true;
    }

    private void doScanLabelAndPrint(BizOutboundTask bizOutboundTask, AllotmentTaskRecord allotmentTaskRecord, BigDecimal totalSum, GridInfo gridInfo) {
        //全部落格点亮标签
        String lightColor = BaseDpsConstants.green;
        if (gridInfo.getLastFlag() == 1) {
            if (bizOutboundTask.getLackState() == 1) {
                //是否缺货）—亮红灯—
                lightColor = BaseDpsConstants.red;
            }
            //查询订单是否有物料详情（亮白灯）
            long count = bizOutboundTaskDetailItemService.findCountByMap(MapUtils.put(BizOutboundTaskDetailItem::getOutboundId, bizOutboundTask.getId()).getMap());
            if (count > 0) {
                //亮白灯
                lightColor = BaseDpsConstants.blue;
            }
        }

        GridInfo oneByMap = gridInfoService.findOneByMap(MapUtils.put(GridInfo::getGridNo, allotmentTaskRecord.getLogeGirdNo()).getMap());
        doScanLabel(allotmentTaskRecord.getLogeGirdNo(), totalSum.stripTrailingZeros().toPlainString(), oneByMap.getHeadLabelLoc(), lightColor);

        //打印面单
        if (Arrays.asList(BaseDpsConstants.blue, BaseDpsConstants.green).contains(lightColor)) {
            PrintTask printTask = new PrintTask();
            printTask.setPrintCount(0);
            printTask.setGridNo(oneByMap.getGridNo());
            printTask.setCreateTime(new Date());
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.SECOND, 5);
            printTask.setUpdateTime(calendar.getTime());
            printTask.setStatus(0);
            printTask.setWmsOutTaskId(bizOutboundTask.getId());
            printTask.setType(1);
            printTaskService.save(printTask);
        }
    }

    private void toHis(List<AllotmentTaskRecord> recordList, Integer id) {
        List<AllotmentTaskRecord> tempList = recordList.stream().filter(o -> o.getOutboundId().equals(id)).collect(Collectors.toList());
        List<AllotmentTaskRecordHis> hisList = new ArrayList<>();
        AllotmentTaskRecordHis allotmentTaskRecordHis = null;
        for (AllotmentTaskRecord record : tempList) {
            allotmentTaskRecordHis = new AllotmentTaskRecordHis();
            BeanUtils.copyProperties(record, allotmentTaskRecordHis);
            hisList.add(allotmentTaskRecordHis);
        }
        allotmentTaskRecordHisService.saveBatch(hisList);
        allotmentTaskRecordService.deleteByMap(MapUtils.put(AllotmentTaskRecord::getOutboundId, id).getMap());
    }

    private boolean checkIfFinished(BizOutboundTask bizOutboundTask, List<AllotmentTaskRecord> recordList) {
        if (bizOutboundTask.getStatus().equals(BaseStatusEnum.STATUS_OFFER.getCode())) {
            recordList = recordList.stream().filter(o -> o.getOutboundId().equals(bizOutboundTask.getId())).collect(Collectors.toList());
            Long count = recordList.stream().filter(o -> o.getLogeStatus() == 0).count();
            //判断订单记录是否全部落格
            if (count == 0) {
                //判断对应的票据是否落格
                if (!StringUtils.isEmpty(bizOutboundTask.getIsPrintQuality()) && bizOutboundTask.getIsPrintQuality().equals("1")) {
                    //首营、质检需要打印  是否落格
                    Long qualityCount = recordList.stream().filter(o -> o.getAllotmentType() == 1).count();
                    if (qualityCount == 0) {
                        return false;
                    }
                }
                if (!StringUtils.isEmpty(bizOutboundTask.getIsPrintInvoice()) && bizOutboundTask.getIsPrintInvoice().equals("1")) {
                    //发票、清单需要打印  是否落格
                    Long invoiceCount = recordList.stream().filter(o -> o.getAllotmentType() == 2).count();
                    if (invoiceCount == 0) {
                        return false;
                    }
                }
                //存在待补货的数据
                long supplyCount = bizOutboundTaskDismantleSupplyService.findCountByMap(MapUtils.put(BizOutboundTaskDismantleSupply::getOutboundId, bizOutboundTask.getId()).getMap());
                if (supplyCount > 0) {
                    return false;
                }
                return true;
            }
        }
        return false;
    }


    /**
     * @param stationNo  格口号
     * @param content    内容  BaseDpsConstants
     * @param locationId 电子标签地址
     */
    private void doScanLabel(String stationNo, String content, String locationId, String lightColor) {
        DpsLightLabelCall dataObject = new DpsLightLabelCall();
        dataObject.setStationNo(stationNo);
        List<DpsLightLabelInfoCall> list = new ArrayList<>();
        DpsLightLabelInfoCall dpsLightLabelInfoCall = new DpsLightLabelInfoCall();
        dpsLightLabelInfoCall.setLocationId(locationId);
        dpsLightLabelInfoCall.setContent(content);
        dpsLightLabelInfoCall.setLightColor(lightColor);
        list.add(dpsLightLabelInfoCall);
        dataObject.setList(list);
        try {
            dpsLightLabelReported.execute(dataObject);
        } catch (Exception e) {
            log.error("点亮dps头部标签失败:" + e.getMessage(), e);
        }
    }


    /**
     * WCS格口状态上报
     *
     * @param wcsGirdDto
     */
    @Override
    public void girdStatusSync(WcsGirdDto wcsGirdDto) {
        Criteria criteria = new Criteria(GridInfo.class);
        criteria.setRestriction(Restrictions.eq("gridNo", wcsGirdDto.getToloc()));
        gridInfoService.updateMapByCriteria(MapUtils.put(GridInfo::getStatus, wcsGirdDto.getStatus()).getMap(), criteria);
    }

    /**
     * WCS小车运行状态上报
     *
     * @param wcsCarDto
     */
    @Override
    public void carStatusSync(WcsCarDto wcsCarDto) {

    }

    /**
     * dps拍灯回告
     *
     * @param dpsSendListDto
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void exeuteTaskReported(DpsSendListDto dpsSendListDto) {
        GridInfo gridInfo = gridInfoService.findOneByMap(MapUtils.put(GridInfo::getGridNo, dpsSendListDto.getStationNo()).getMap());
        if (gridInfo.getOrderId() != null) {
            if (Objects.isNull(gridInfo.getFallGrid()) || Objects.equals(gridInfo.getFallGrid(), 0)) {
                throw new PrologException("此格口供包未全部落格，不可拍灯");
            }
            //格口释放
            BizOutboundTask outboundTask = bizOutboundTaskService.findById(gridInfo.getOrderId());
            orderLogMapper.save(OrderLog.builder()
                    .orderId(outboundTask.getId().toString())
                    .orderNo(outboundTask.getBillNo())
                    .type("格口释放")
                    .remark("释放的格口：" + gridInfo.getGridNo())
                    .createTime(new Date())
                    .build());
            Criteria criteria = new Criteria(GridInfo.class);
            criteria.setRestriction(Restrictions.eq("gridNo", dpsSendListDto.getStationNo()));
            gridInfoService.updateMapByCriteria(MapUtils.put(GridInfo::getOrderId, null).put(GridInfo::getApplyVolume, BigDecimal.ZERO)
                    .put(GridInfo::getSupplyFlag, 0).put(GridInfo::getFallGrid, 0).put(GridInfo::getBillFlag, 0)
                    .put(GridInfo::getLastFlag, 0).put(GridInfo::getScanFinish, 0).getMap(), criteria);
            redisTemplate.delete(RedisKey.GRID_BIND_KEY + dpsSendListDto.getStationNo());

            List<GridInfo> gridInfoList = gridInfoService.findByMap(MapUtils.put(GridInfo::getOrderId, gridInfo.getOrderId()).getMap());
            if (CollectionUtil.isEmpty(gridInfoList) && outboundTask.getStatus() >= BaseStatusEnum.STATUS_OFFER.getCode()) {
                //校验当前订单是否完成
                List<BizOutboundTaskDetailDismantle> dismantleList = bizOutboundTaskDetailDismantleService.findByMap(MapUtils.put(BizOutboundTaskDetailDismantle::getOutboundId, gridInfo.getOrderId()).getMap());
                long count = dismantleList.stream().filter(o -> o.getType() == 2 && o.getStatus() < BaseStatusEnum.STATUS_GRID.getCode()).count();
                AssertUtils.isNotTrue(count > 0, "拆零订单还未完成，不可拍灯");
                AssertUtils.isNotTrue(redisTemplate.hasKey("CL:SUPPER:" + gridInfo.getOrderId()), "拆零补货订单还未完成，不可拍灯");

                AssertUtils.isNotTrue(Objects.isNull(outboundTask.getExtend3()), "票据未全部落格");
                List<BizOutboundTaskDetailDismantle> outboundTaskDetailDismantleList = bizOutboundTaskDetailDismantleService.findByMap(com.prolog.eis.utils.MapUtils.put(BizOutboundTaskDetailDismantle::getOutboundId, gridInfo.getOrderId()).getMap());
                List<BizOutboundTaskDetailDismantle> collect = outboundTaskDetailDismantleList.stream().filter(item -> item.getType() == 1).collect(Collectors.toList());


                //修改此订单拆零已全部完成
                List<BizOutboundTaskDetailDismantle> collect2 = outboundTaskDetailDismantleList.stream().filter(item -> item.getType() == 2).collect(Collectors.toList());
                Criteria criteria1 = new Criteria(BizOutboundTaskDetailDismantle.class);
                criteria1.restrictionBuilder().in(BizOutboundTaskDetailDismantle::getId, collect2.stream().map(BizOutboundTaskDetailDismantle::getId).collect(Collectors.toList())).build();
                bizOutboundTaskDetailDismantleService.updateMapByCriteria(MapUtils.put(BizOutboundTaskDetailDismantle::getStatus, 20).put(BizOutboundTaskDetailDismantle::getUpdateTime, LocalDateTime.now()).getMap(), criteria1);
                //供包记录处理
                this.handleAllotmentTask(dpsSendListDto.getStationNo(), outboundTask.getId());
                //判断零发整是否完成
                long count1 = collect.stream().filter(item -> item.getStatus() < 12).count();
                if (count1 == 0) {
                    bizOutboundTaskService.outboundToHis(outboundTask);
                }
                List<BizOutboundTaskDetailItem> outboundTaskDetailItems = bizOutboundTaskDetailItemService.findByMap(MapUtils.put(BizOutboundTaskDetailItem::getOutboundId, gridInfo.getOrderId()).getMap());
                for (BizOutboundTaskDetailItem outboundTaskDetailItem : outboundTaskDetailItems) {
                    BizOutboundTaskDetailItemHis outboundTaskDetailItemHis = new BizOutboundTaskDetailItemHis();
                    org.springframework.beans.BeanUtils.copyProperties(outboundTaskDetailItem, outboundTaskDetailItemHis);
                    outboundTaskDetailItemHisService.save(outboundTaskDetailItemHis);
                    bizOutboundTaskDetailItemService.deleteById(outboundTaskDetailItem.getId());
                }
            }
        }
    }

    private void handleAllotmentTask(String girdNo, Integer outBoundId) {
        List<AllotmentTaskRecord> recordList = allotmentTaskRecordService.findByMap(MapUtils
                .put(AllotmentTaskRecord::getGirdNo, girdNo)
                .put(AllotmentTaskRecord::getOutboundId, outBoundId)
                .getMap());

        Criteria allotmentCriteria = new Criteria(AllotmentTaskRecord.class);
        allotmentCriteria.restrictionBuilder()
                .in(AllotmentTaskRecord::getId, recordList.stream().map(AllotmentTaskRecord::getId).collect(Collectors.toList()))
                .build();
        allotmentTaskRecordService.updateMapByCriteria(MapUtils.put(AllotmentTaskRecord::getBeatLightTime, LocalDateTime.now()).getMap(), allotmentCriteria);

        //供包记录转历史
        toHis(recordList, outBoundId);
    }
}
