package com.cf.imes.module.executor.service.order;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.cf.imes.framework.common.enums.DeletedCodeEnum;
import com.cf.imes.framework.common.enums.OrderPackageStatusEnum;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.Assert.AssertUtils;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import com.cf.imes.module.executor.controller.admin.manage.pack.vo.PackOrdersInfoRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.type.PartsByRoomBodyRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.type.PlateByGoodsDetRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.type.PlateByRoomBodyDetRespVO;
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsPrintRespVO;
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRemark;
import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsRespVO;
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderComponentRespVO;
import com.cf.imes.module.executor.controller.admin.ordercomponent.vo.OrderDetailComponentListReqVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateGoodsRespVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO;
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
import com.cf.imes.module.executor.dal.dataobject.goods.PlanActualGoodsModelDO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemTempDO;
import com.cf.imes.module.executor.dal.dataobject.orderParts.OrderPartsDO;
import com.cf.imes.module.executor.dal.dataobject.orderParts.PartsDO;
import com.cf.imes.module.executor.dal.dataobject.ordercomponent.OrderComponentDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateGoodDO;
import com.cf.imes.module.executor.dal.dataobject.rawgoods.RawGoodsDO;
import com.cf.imes.module.executor.dal.mysql.goods.GoodsMapper;
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
import com.cf.imes.module.executor.dal.mysql.orderBody.OrderBodyMapper;
import com.cf.imes.module.executor.dal.mysql.orderGroup.OrderGroupMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemBatchMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemTempBatchMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemTempMapper;
import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper;
import com.cf.imes.module.executor.dal.mysql.orderParts.PartsMapper;
import com.cf.imes.module.executor.dal.mysql.ordercomponent.OrderComponentMapper;
import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper;
import com.cf.imes.module.executor.dal.mysql.planitem.PlanItemMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
import com.cf.imes.module.executor.enums.CategoryEnum;
import com.cf.imes.module.executor.enums.DataTypeEnum;
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
import com.cf.imes.module.executor.enums.OrderStatusEnum;
import com.cf.imes.module.executor.enums.OrderTypeEnum;
import com.cf.imes.module.executor.service.customplateno.CustomPlateNoGenerateService;
import com.cf.imes.module.executor.service.manage.pack.PackService;
import com.cf.imes.module.executor.service.orderImport.OrderImportHandler;
import com.cf.imes.module.executor.service.orderImport.factory.OrderImportHandlerFactory;
import com.cf.imes.module.executor.service.ordercomponent.OrderComponentService;
import com.cf.imes.module.executor.util.deviseData.structure.FieldConstants;
import com.cf.imes.module.executor.util.deviseData.structure.PlateDetail;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataTypeVo;
import com.cf.imes.module.infra.api.file.FileApi;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.multipart.MultipartFile;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static com.cf.imes.framework.common.util.json.JsonUtils.unzipString;
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
import static com.cf.imes.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS;

/**
 * 订单表 order_{N} Service 实现类
 *
 * @author 晨丰科技
 */
@Service
@Validated
@Slf4j
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Resource
    private RawGoodsMapper rawGoodsMapper;

    @Resource
    private GoodsMapper goodsMapper;

    @Resource
    private OrderPartsMapper orderPartsMapper;

    @Resource
    private PlateMapper plateMapper;

    @Resource
    private PlanMapper planMapper;

    @Resource
    private PlateGoodMapper plateGoodMapper;

    @Resource
    private OrderBodyMapper orderBodyMapper;

    @Resource
    private OrderGroupMapper orderGroupMapper;

    @Resource
    private OrderItemMapper orderItemMapper;

    @Resource
    private PartsMapper partsMapper;

    @Resource
    private CustomPlateNoGenerateService customPlateNoGenerateService;

    @Resource
    private PlanItemMapper planItemMapper;

    @Resource
    private OrderComponentService orderComponentService;

    @Resource
    private OrderItemTempMapper orderItemTempMapper;

    @Resource
    private OrderItemBatchMapper orderItemBatchMapper;

    @Resource
    private OrderItemTempBatchMapper orderItemTempBatchMapper;

    @Resource
    @Lazy
    private PackService packService;

    @Resource
    private OrderComponentMapper orderComponentMapper;

    @Resource
    private OrderInfoVersionControlService orderInfoVersionControlService;

    private static final String SUBMIT_STATE = "1"; // 空订单 原生产系统


    public static final Double ZERO = 0.0;

    @Autowired
    private OrderImportHandlerFactory orderImportHandlerFactory;

    @Autowired
    private FileApi fileApi;

    @Override
    public Long createOrder(OrderSaveReqVO createReqVO) {
        Long parentId = createReqVO.getParentId();
        // 校验上级订单是否存在
        validateParentOrderExists(parentId);

        //验证自定义单号是否存在，业务员、拆单员是否存在
        validateCustomOrderNoExists(createReqVO.getCustomOrderNo());
        LocalDate orderDate = LocalDate.from(createReqVO.getOrderDate());
        LocalDate deliveryDate = LocalDate.from(createReqVO.getDeliveryDate());
        if (deliveryDate.isBefore(orderDate)) {
            // 将 deliveryDate 设置为 orderDate 后的第 30 天
            deliveryDate = orderDate.plusMonths(1);
        }
        createReqVO.setDeliveryDate(deliveryDate.atStartOfDay());
        // 插入
        OrderDO order = BeanUtils.toBean(createReqVO, OrderDO.class);
        // 默认api类型订单
        if(ObjectUtil.isNull(order.getDataType())) {
            order.setDataType(DataTypeEnum.API_IMPORT.getStatus());
        }
        // 订单类型
        order.setOrderType(getOrderType(parentId, createReqVO.getOrderType()));
        // 默认都是空单
        order.setStatus(OrderStatusEnum.EMPTY.getStatus());
        // 是否主单
        boolean isTop = ObjectUtil.equals(OrderTypeEnum.MAIN_ORDER.getStatus(), order.getOrderType());
        if (!isTop) {
            // 子单用父id
            order.setRootId(parentId);
        }

        orderMapper.insert(order);
        Long insertId = order.getId();

        if (isTop) {
            // 主单用自己
            order.setRootId(insertId);
            orderMapper.update(new LambdaUpdateWrapper<OrderDO>()
                    .set(OrderDO::getRootId, insertId)
                    .eq(OrderDO::getId, insertId)
            );
        }
        // 返回
        return insertId;
    }

    @Override
    public void updateOrder(OrderSaveReqVO updateReqVO) {
        // 校验存在, 订单未删除
        OrderDO orderDO = validateOrderExists(updateReqVO.getId(), getUserOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus());

        //验证自定义单号是否存在, 订单未删除
        validateCustomOrderNoExists(updateReqVO.getCustomOrderNo(), updateReqVO.getId());

        Long orderParentId = orderDO.getParentId();
        Long parentId = orderParentId == 0 ? null : orderParentId;
        // 校验上级订单是否存在
        validateParentOrderExists(parentId);

        // 发货日期校验
        LocalDate orderDate = LocalDate.from(updateReqVO.getOrderDate());
        LocalDate deliveryDate = LocalDate.from(updateReqVO.getDeliveryDate());
        if (deliveryDate.isBefore(orderDate)) {
            // 将 deliveryDate 设置为 orderDate 后的第 30 天
            deliveryDate = orderDate.plusMonths(1);
        }
        updateReqVO.setDeliveryDate(deliveryDate.atStartOfDay());
        // 更新
        OrderDO updateObj = BeanUtils.toBean(updateReqVO, OrderDO.class);
        if (updateReqVO.getCustomOrderNo() == null || updateReqVO.getCustomOrderNo().equals("")) {
            updateObj.setCustomOrderNo("");
        }
        if (updateReqVO.getSalesman() == null || updateReqVO.getSalesman().equals("")) {
            updateObj.setSalesman("");
        }
        if (updateReqVO.getSplitter() == null || updateReqVO.getSplitter().equals("")) {
            updateObj.setSplitter("");
        }
        if (updateReqVO.getRemark() == null || updateReqVO.getRemark().equals("")) {
            updateObj.setRemark("");
        }
        // 订单类型
        updateObj.setOrderType(getOrderType(parentId, updateReqVO.getOrderType()));
        // 不允许修改上级
        updateObj.setParentId(null);
        orderMapper.updateById(updateObj);
    }

    /**
     * 获取对应的订单类型
     *
     * @param parentId  父级订单id
     * @param orderType 入参订单类型
     * @return
     */
    private Integer getOrderType(Long parentId, Integer orderType) {
        if (ObjectUtil.isNotNull(parentId) && parentId != 0) {
            if (!OrderTypeEnum.isSubType(orderType)) {
                throw new ServiceException(ORDER_SUBTYPE_NOT_SUPPORT);
            }
        } else {
            return OrderTypeEnum.MAIN_ORDER.getStatus();
        }
        return orderType;
    }

    @Override
    public OrderDO getOrder(Long id) {
        return orderMapper.selectOrderOne(id, getUserOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus());
    }

    @Override
    public OrderDO getOrder(Long id, Long... organIds) {
        Long userOrganId = getUserOrganId();
        if (ObjectUtil.isNull(userOrganId) && ArrayUtil.isNotEmpty(organIds)) {
            userOrganId = organIds[0];
        }
        return orderMapper.selectOne(new LambdaQueryWrapper<OrderDO>()
                .eq(OrderDO::getId, id)
                .eq(OrderDO::getOrganId, userOrganId)
                .eq(OrderDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus()));
    }

    @Override
    public PageResult<OrderDO> getOrderPage(OrderPageReqVO pageReqVO) {
        return orderMapper.selectPage(pageReqVO.setOrganId(getUserOrganId()));
    }

    @Override
    public PageResult<OrderDO> getMainOrderPage(OrderPageReqVO pageReqVO) {
        IPage<OrderDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());

        // 删除展示平铺订单列表
        if (pageReqVO.getDeleted()) {
            return orderMapper.selectDeletedPage(pageReqVO);
        }

        // 1. 查询主单ID分页
        IPage<Long> pageResult = orderMapper.selectMainOrderIds(page, pageReqVO);
        Long pageResultTotal = pageResult.getTotal();
        List<Long> records = pageResult.getRecords();

        if (pageResultTotal == 0 || CollUtil.isEmpty(records)) {
            return PageResult.empty();
        }

        List<Long> orderIds = records;
        // 2. 查询主单
        List<OrderDO> orderDOS = orderMapper.selectByIds(orderIds);
        if (CollUtil.isEmpty(orderDOS)) {
            return new PageResult<>(Collections.emptyList(), pageResultTotal);
        }

        // 保持分页顺序
        Map<Long, Integer> sortMap = IntStream.range(0, orderIds.size())
                .boxed()
                .collect(Collectors.toMap(orderIds::get, Function.identity()));

        orderDOS.sort(Comparator.comparing(o -> sortMap.get(o.getId())));

        // 3. 查询子单
        List<Long> childIdList = orderMapper.selectChildIdList(pageReqVO, orderIds);
        if (CollUtil.isEmpty(childIdList)) {
            return new PageResult<>(orderDOS, pageResultTotal);
        }

        List<OrderDO> childList = orderMapper.selectByIds(childIdList);
        if (CollUtil.isEmpty(childList)) {
            return new PageResult<>(orderDOS, pageResultTotal);
        }

        // 4. parentId分组
        Map<Long, List<OrderDO>> childMap = childList.stream()
                .collect(Collectors.groupingBy(OrderDO::getParentId));

        // 5. 挂载子单
        for (OrderDO order : orderDOS) {
            order.setChild(childMap.get(order.getId()));
        }

        return new PageResult<>(orderDOS, pageResultTotal);
    }

    @Override
    public List<OrderBodyRespVO> getOrderBody(Long orderId, Integer deleted) {
        List<OrderBodyRespVO> bodyRespVOS = BeanUtil.copyToList(orderBodyMapper.selectList(orderId, deleted, getUserOrganId()), OrderBodyRespVO.class);
        // 获取文件 fileHash
        Set<Long> cadViewFileIds = bodyRespVOS.stream().map(OrderBodyRespVO::getCadViewFileId).collect(Collectors.toSet());
        if (CollUtil.isNotEmpty(cadViewFileIds)) {
            CommonResult<Map<Long, String>> fileHashMapByIdsResult = fileApi.getFileHashMapByIds(cadViewFileIds);
            if (fileHashMapByIdsResult.isSuccess()) {
                Map<Long, String> fileHashMapByIds = fileHashMapByIdsResult.getData();
                bodyRespVOS.forEach(body ->
                        body.setFileHash(fileHashMapByIds.get(body.getCadViewFileId()))
                );
            }
        }
        return bodyRespVOS;
    }

    @Override
    public List<OrderRoomBodyRespVO> getRoomAndBody(Long planId) {
        PlanDO planDO = planMapper.selectById(planId);

//        判断是否存在排单
        if (planDO == null) {
            throw new ServiceException(PLAN_NOT_EXISTS);
        }

        List<Long> orderIds = JSON.parseArray(planDO.getOrderNos()).toJavaList(Long.class);

        return orderBodyMapper.selectRoomAndBody(orderIds, getUserOrganId());
    }

    @Override
    public OrderModuleDetailRespVO getModule(Long orderId, Integer deleted) {
        // 柜体信息
        List<OrderModuleRespVO> orderModuleRespVOList = orderBodyMapper.selectModuleByOrderId(orderId, getUserOrganId(), deleted);

        Set<String> types = new HashSet<>();
        // 配件
        types.add(CategoryEnum.HARDWARE.getValue());
        types.add(CategoryEnum.EDGING.getValue());
        List<OrderPlatesDetailRespVO> orderItemDOS = orderItemMapper.selectPartsByOrderId(orderId, getUserOrganId(), deleted, types);

        // 部件
        OrderDetailComponentListReqVO componentListReqVO = new OrderDetailComponentListReqVO();
        componentListReqVO.setOrderId(orderId);
        componentListReqVO.setDeleted(deleted == 1 ? true : false);
        List<OrderComponentRespVO> orderComponentList = orderComponentService.getOrderComponentList(componentListReqVO);

        // 组件
        types.clear();
        types.add(CategoryEnum.ASSEMBLY.getValue());
        List<OrderPlatesDetailRespVO> orderComponentRespVOS = orderItemMapper.selectPartsByOrderId(orderId, getUserOrganId(), deleted, types);

        OrderModuleDetailRespVO orderModuleDetailRespVO = new OrderModuleDetailRespVO();
        orderModuleDetailRespVO.setModule(orderModuleRespVOList);
        orderModuleDetailRespVO.setParts(orderItemDOS);
        orderModuleDetailRespVO.setComponent(orderComponentRespVOS);
        orderModuleDetailRespVO.setSection(orderComponentList);
        return orderModuleDetailRespVO;
    }

    @Override
    public PageResult<OrderPlatesDetailReqVO> getPlatesDetail(Long orderId, Set<Long> roomIds, Set<Long> bodyIds, Set<Long> groupIds, String groupName, Integer pageNo, Integer pageSize, Integer deleted) {
        PageDTO<PlateRespVO> page = new PageDTO<>(pageNo, pageSize);

        IPage<PlateRespVO> plateRespVOPage = orderItemMapper.selectPlatesDetailByOrderId(page, orderId, roomIds, bodyIds, groupIds,
                groupName, getUserOrganId(), deleted);
        List<PlateRespVO> orderDetail = plateRespVOPage.getRecords();
        List<OrderPlatesDetailReqVO> platesDetailReqVOS = new ArrayList<>();
        for (PlateRespVO plateRespVO : orderDetail) {
            OrderPlatesDetailReqVO orderPlatesDetailReqVO = BeanUtils.toBean(plateRespVO, OrderPlatesDetailReqVO.class);
            String cadData = orderPlatesDetailReqVO.getCadData();
            if(StringUtils.isNotEmpty(cadData)) {
                orderPlatesDetailReqVO.setCadData(unzipString(cadData));
            }
            platesDetailReqVOS.add(orderPlatesDetailReqVO);
        }
        return new PageResult(platesDetailReqVOS, plateRespVOPage.getTotal());
    }

    @Override
    public PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Set<Long> roomId, Set<Long> bodyId, Set<Long> groupId, String name, Integer pageNo, Integer pageSize, Integer deleted, Set<String> types) {
        PageDTO<OrderPartsRespVO> page = new PageDTO<>(pageNo, pageSize);

        IPage<OrderPartsRespVO> orderDetail = orderItemMapper.selectPartsDetailByOrderId(page, orderId, roomId, bodyId, groupId, name, getUserOrganId(), deleted, types);

        orderDetail.getRecords().forEach(item -> {
            if (Objects.equals(item.getLength(), ZERO)) {
                item.setLength(null);
            }
        });

        return new PageResult(orderDetail.getRecords(), orderDetail.getTotal());
    }

    @Override
    public PageResult<OrderGoodsDetailRespVO> getGoodsDetail(Long orderId, Set<Long> roomId, Set<Long> bodyId, Set<Long> groupId, Set<Long> goodsId, Integer pageNo, Integer pageSize, Integer deleted) {
        PageDTO<OrderGoodsDetailRespVO> page = new PageDTO<>(pageNo, pageSize);

        IPage<OrderGoodsDetailRespVO> goodsDetail = orderItemMapper.selectGoodsDetailByOrderId(page, orderId, roomId, bodyId, groupId, goodsId, getUserOrganId(), deleted);

        return new PageResult(goodsDetail.getRecords(), goodsDetail.getTotal());
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateDeleteBody(Long orderId, Set<Long> roomIds, Long bodyId, Integer status) { // 要删除传1,还原传0
        Long organId = getUserOrganId();

        // 判断订单的状态和订单柜体对应的板材是否已经排单
        OrderDO orderDO = validateOrderStatus(orderId, roomIds, bodyId, organId);

        // 获取对应柜体id列表
        List<Long> bodyIds = validateOrderBodyExists(orderId, bodyId, organId, roomIds, OrderDeletedEnum.NOT_DELETED.getStatus());

        // 受影响的ordergoodsId
        List<Long> goodsIdDeleted = null;
        if (CollUtil.isNotEmpty(bodyIds)) {

            // 删除柜体
            orderBodyMapper.updateDeletedBody(bodyIds, organId, orderId);

            // 删除加工组
            orderGroupMapper.updateDeletedGroup(bodyIds, organId, orderId);


            List<PlateDO> plateDOList = plateMapper.selectNoDeletedPlate(orderId, bodyIds, organId);


            if (CollUtil.isNotEmpty(plateDOList)) {

                // 删除小板，大板，包裹，目前只要小板排单，就不能删除小板信息
                OrderServiceImpl o = (OrderServiceImpl) AopContext.currentProxy();
                goodsIdDeleted = o.updateDeletePlate(plateDOList, orderId, bodyIds);

            }

            // order_item记录临时表
            copyOrderItemToTemp(orderId, organId, bodyIds.stream().collect(Collectors.toSet()));

            // order_item删除记录
            orderItemMapper.delete(new LambdaQueryWrapper<OrderItemDO>()
                    .eq(OrderItemDO::getOrderId, orderId)
                    .in(OrderItemDO::getBodyId, bodyIds)
            );

        }

        // 更新影响的柜体的板件数量和面积
        orderInfoVersionControlService.updateOrderBodyPlateNum(bodyIds, true);
        // 更新影响的订单商品的板件数量和面积
        if (CollUtil.isNotEmpty(goodsIdDeleted)) {
            orderInfoVersionControlService.updateOrderGoodsPlateNumAndArea(goodsIdDeleted, true);
        }
        // 更新订单的板件数量和面积
        orderInfoVersionControlService.updateOrderPlateNumAndArea(orderDO, true);
    }

    /**
     * 复制订单明细到临时表
     *
     * @param orderId
     * @param organId
     * @param deleteIds
     */
    private void copyOrderItemToTemp(Long orderId, Long organId, Set<Long> deleteIds) {
        int pageSize = 1000;
        long lastId = 0L;

        while (true) {

            List<OrderItemDO> list =
                    orderItemMapper.selectOrderItemForTemp(orderId, organId, lastId, pageSize, deleteIds, null);

            if (CollUtil.isEmpty(list)) {
                break;
            }

            orderItemTempBatchMapper.insertBatchSomeColumn(BeanUtil.copyToList(list, OrderItemTempDO.class));

            lastId = list.get(list.size() - 1).getId();
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateRestoreBody(Long orderId, Set<Long> roomIds, Long bodyId, Integer status) { // 要删除传1,还原传0
        Long organId = getUserOrganId();

        // 校验订单
        OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId);

        AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);

        List<Long> bodyIds = validateOrderBodyExists(orderId, bodyId, organId, roomIds, OrderDeletedEnum.DELETED.getStatus());

        // 受影响的ordergoodsId
        Set<Long> goodsIdRestore = null;
        if (!bodyIds.isEmpty()){
            // 恢复柜体
            orderBodyMapper.updateNoDeletedBody(bodyIds, organId, orderId);

            // 恢复加工组
            orderGroupMapper.updateNoDeletedGroup(bodyIds, organId, orderId);

            // 查询柜体下删除的板件
            List<PlateDO> plateDOList = plateMapper.selectDeletedPlate(orderId, bodyIds, organId);

            // 小板还原
            if (CollUtil.isNotEmpty(plateDOList)) {

                // 还原小板，小板对应的大板信息
                OrderServiceImpl o = (OrderServiceImpl) AopContext.currentProxy();
                goodsIdRestore = o.updateRestorePlate(orderId, plateDOList);

            }

            // order_item恢复临时记录
            copyTempToOrderItem(orderId, organId, bodyIds.stream().collect(Collectors.toSet()));

            // order_item_temp删除记录
            orderItemTempMapper.delete(new LambdaQueryWrapper<OrderItemTempDO>()
                    .eq(OrderItemTempDO::getOrderId, orderId)
                    .in(OrderItemTempDO::getBodyId, bodyIds)
            );

        }

        List<PlateDO> plateDOS = plateMapper.selectPlateIsOptimized(Collections.singletonList(orderId), organId);

        if (CollUtil.isNotEmpty(plateDOS)) {
            return;
        }

        // 更新影响的柜体的板件数量和面积
        orderInfoVersionControlService.updateOrderBodyPlateNum(bodyIds, false);
        // 更新影响的订单商品的板件数量和面积
        if (CollUtil.isNotEmpty(goodsIdRestore)) {
            orderInfoVersionControlService.updateOrderGoodsPlateNumAndArea(goodsIdRestore, false);
        }
        // 更新订单的板件数量和面积
        orderInfoVersionControlService.updateOrderPlateNumAndArea(orderDO, false);
    }


    /**
     * 复制订单明细到临时表
     *
     * @param orderId
     * @param organId
     * @param deleteIds
     */
    private void copyTempToOrderItem(Long orderId, Long organId, Set<Long> deleteIds) {
        int pageSize = 1000;
        long lastId = 0L;

        while (true) {

            List<OrderItemTempDO> list =
                    orderItemTempMapper.selectOrderItemTempForItem(orderId, organId, lastId, pageSize, deleteIds, null);

            if (CollUtil.isEmpty(list)) {
                break;
            }

            orderItemBatchMapper.insertBatchSomeColumn(BeanUtil.copyToList(list, OrderItemDO.class));

            lastId = list.get(list.size() - 1).getId();
        }
    }



    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long importApiData(ApiDataTypeVo apiDataTypeVo) {
        OrderDO order = apiDataTypeVo.getOrderDO();
        if (order != null) {
            //判断是否已经导入
//            if (!validateOrderNoExists(order.getApiOrderId(), OrganContextHolder.getOrganId())) {
//                throw new ServiceException(ORDER_EXISTS);
//            }

            validateCustomOrderNoExists(order.getCustomOrderNo());
            String nickName = SecurityFrameworkUtils.getLoginUser().getNickname();
            if (order.getSalesman() == null || order.getSalesman().equals("")) {
                order.setSalesman(nickName);
            }
            if (order.getSplitter() == null || order.getSplitter().equals("")) {
                order.setSplitter(nickName);
            }

            if (order.getStatus() == 0) {
                orderMapper.insert(order);
                return order.getId();
            }
        }
        List<GoodsDO> goodsDO = new ArrayList<>(apiDataTypeVo.getMapGoodsDO().values());
        List<RawGoodsDO> rawGoodsDO = new ArrayList<>(apiDataTypeVo.getMapRawGoodsDO().values());
        List<OrderBodyDO> bodyDO = new ArrayList<>(apiDataTypeVo.getMapOrderBodyDO().values());
        List<OrderGroupDO> groupDO = new ArrayList<>(apiDataTypeVo.getMapOrderGroupDO().values());
        List<OrderPartsDO> partsDO = new ArrayList<>(apiDataTypeVo.getMapPartsInfos().values());
        List<PlateDO> plateDO = new ArrayList<>(apiDataTypeVo.getMapPlatesInfos().values());
        List<PlateDetail> plateDetail = new ArrayList<>(apiDataTypeVo.getMapPlateDetails().values());
        List<OrderItemDO> itemDO = apiDataTypeVo.getMapItem();
        List<OrderPartsRemark> partsRemark = new ArrayList<>(apiDataTypeVo.getMapPartRemarks().values());

        Map<String, List<?>> map = getPlateGoods(goodsDO);// 检验商品板材信息是否存在
        goodsDO = (List<GoodsDO>) map.get(FieldConstants.GOODS);
        List<PlateGoodDO> plateGoodDOS = (List<PlateGoodDO>) map.get(FieldConstants.PLATE_GOODS_LIST_KEY);
        // 配件信息
        List<PartsDO> partsDOS = getPartsGoods(partsDO);

        customPlateNoGenerateService.generateCustomPlateNo(order, plateDO, true);
        orderMapper.insert(order);
        List<OrderModelDO> orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class);

        if (orderModelDOs != null && !orderModelDOs.isEmpty()) {

            orderModelDOs.forEach(orderModelDO -> orderModelDO.setOrderId(order.getId()));
            // 保存大板的分类和实际ID和未优化
            saveOrderPlateModel(plateDO,goodsDO,orderModelDOs);

        }

        return order == null ? 0 : order.getId();
    }

    //    订单插入
    private void insertOrder(OrderDO orderDO, Integer index) {
        if (index == 0) {
            String nickName = Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getNickname();
            if (orderDO.getSalesman() == null || orderDO.getSalesman().equals("")) {
                orderDO.setSalesman(nickName);
            }
            if (orderDO.getSplitter() == null || orderDO.getSplitter().equals("")) {
                orderDO.setSplitter(nickName);
            }
            orderMapper.insert(orderDO);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void importExcelData(OrderDO orderDO, Integer index, Map<String, Object> listMap) {


        if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus())) {
            return;
        }


        List<RawGoodsDO> rawGoodsDO = (List<RawGoodsDO>) listMap.get(FieldConstants.RAW_GOODS);
        List<GoodsDO> goodsDO = (List<GoodsDO>) listMap.get(FieldConstants.GOODS);

        List<OrderBodyDO> bodyDO = (List<OrderBodyDO>) listMap.get(FieldConstants.BODY);
        List<OrderGroupDO> groupDO = (List<OrderGroupDO>) listMap.get(FieldConstants.GROUP);
        List<PlateDO> plateDO = (List<PlateDO>) listMap.get(FieldConstants.PLATE);
        List<OrderPartsDO> partsDO = (List<OrderPartsDO>) listMap.get(FieldConstants.PARTS);
        List<OrderItemDO> itemDO = (List<OrderItemDO>) listMap.get(FieldConstants.ITEM);
        List<OrderPartsRemark> orderPartsRemarks = (List<OrderPartsRemark>) listMap.get(FieldConstants.PARTS_REMARK);
        List<PlateDetail> plateDetail = (List<PlateDetail>) listMap.get(FieldConstants.PLATE_DETAIL);
        // 板材库匹配
        Map<String, List<?>> map = getPlateGoods(goodsDO);// 检验商品板材信息是否存在 excel
        goodsDO = (List<GoodsDO>) map.get(FieldConstants.GOODS);
        List<PlateGoodDO> plateGoodDOS = (List<PlateGoodDO>) map.get(FieldConstants.PLATE_GOODS_LIST_KEY);
        // 配件库匹配
        List<PartsDO> partsDOList = getPartsGoods(partsDO);

        if (index != 0) {
            roomCabinetProcessGroupMatch(orderDO.getId(), bodyDO, groupDO, itemDO);
            if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.EMPTY.getStatus())) {
                orderDO.setStatus(OrderStatusEnum.NEW_ORDER.getStatus());
                updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class));
            }
            if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.FINISH_PRODUCTION.getStatus())) {
                orderDO.setStatus(OrderStatusEnum.IN_PRODUCTION.getStatus());
                updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class));
            }
            if (Objects.equals(orderDO.getPackaged(), OrderPackageStatusEnum.PACKAGED.getStatus())) {
                orderDO.setPackaged(OrderPackageStatusEnum.PACKAGED.getStatus());
                updateOrder(BeanUtils.toBean(orderDO, OrderSaveReqVO.class));
            }
        }

        customPlateNoGenerateService.generateCustomPlateNo(orderDO, plateDO, index == 0);
        insertOrder(orderDO, index);

        if (plateDetail != null && !plateDetail.isEmpty()){
            List<OrderModelDO> orderModelDOs = BeanUtils.toBean(plateDetail, OrderModelDO.class);

            saveOrderPlateModel(plateDO,goodsDO,orderModelDOs);

        }


    }

    @Override
    public void exportTemplate(HttpServletResponse response, String value) {
        // path是指想要下载的文件的路径
        File file = new File(getSavePath() + File.separator + value);
        // 获取文件名
        String filename = file.getName();
        // 将文件写入输入流
        try (FileInputStream fis = new FileInputStream(file);
             OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
            byte[] buffer = new byte[fis.available()];
            fis.read(buffer);
            fis.close();

            response.reset();
            response.setCharacterEncoding("UTF-8");
            response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
            response.addHeader("Content-Length", "" + file.length());

            response.setContentType("application/octet-stream");
            outputStream.write(buffer);
            outputStream.flush();
        } catch (IOException ex) {
            throw new ServiceException(FILE_NOT_EXISTS);

        }
    }

    @Override
    public Map<String, Object> getPrintDataMap(Long orderId, String type, HttpServletResponse response) {
        // 查询订单
        OrderDO orderDO = orderMapper.selectOrderOne(orderId, OrganContextHolder.getOrganId());
        if (orderDO == null) {
            throw new ServiceException(ORDER_NOT_EXISTS);
        }
        return getDataByOrderIdAndType(orderDO, type, OrderDeletedEnum.NOT_DELETED.getStatus());
//        return getDataByOrderIdAndTypeDetail(orderDO, type, OrderDeletedEnum.NOT_DELETED.getStatus());
    }

    @Override
    public Boolean customOrderNoIsExists(String customOrderNo) {
        if (customOrderNo != null) {
            if (!customOrderNo.isEmpty()) {
                if (orderMapper.selectCount(new LambdaQueryWrapper<OrderDO>()
                        .eq(OrderDO::getCustomOrderNo, customOrderNo)
                        .eq(OrderDO::getDeleted, false)
                        .eq(OrderDO::getOrganId, OrganContextHolder.getOrganId())) > 0) {
                    return false;
                }
            }
        }
        return true;
    }

    @Override
    public List<ApiOrderRespVO> getApiOrderList(JSONObject orderList) {
        List<ApiOrderRespVO> apiOrderRespVOS = new ArrayList<>();
        JSONArray jsonArray = orderList.getJSONArray("data");
        if (jsonArray != null && jsonArray.size() > 0) {
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                int index = jsonObject.getString("order_no").indexOf("@N");
                String order_no = jsonObject.getString("order_no").substring(index + "@N".length());
                ApiOrderRespVO apiOrderRespVO = JSON.parseObject(jsonObject.toJSONString(), ApiOrderRespVO.class).setOrder_no(order_no);

//                判断是否已经导入
                if (validateOrderNoExists(apiOrderRespVO.getOrder_no(), OrganContextHolder.getOrganId())) {
                    if (!apiOrderRespVO.getOrder_state().equals(SUBMIT_STATE)) {
                        apiOrderRespVOS.add(apiOrderRespVO);
                    }
                }

            }
        }
        return apiOrderRespVOS;
    }

    @Override
    public PageResult<OrderOverdueRespVO> getOrderOverdue(PageParam pageParam) {
        LocalDate todayDate = LocalDate.now();
        PageDTO<OrderOverdueRespVO> page = new PageDTO<>(pageParam.getPageNo(), pageParam.getPageSize());
        // 查询超时单
        IPage<OrderOverdueRespVO> orderOverdueVOS = orderMapper.selectOrderOverdue(todayDate, OrganContextHolder.getOrganId(), page);
        return new PageResult<>(orderOverdueVOS.getRecords(), orderOverdueVOS.getTotal());
    }

    @Override
    public PageResult<OrderOverdueRespVO> getOrderNear(PageParam pageParam) {
        Long organId = OrganContextHolder.getOrganId();

        PageDTO<OrderOverdueRespVO> page = new PageDTO<>(pageParam.getPageNo(), pageParam.getPageSize());
        LocalDate tomorrow = LocalDate.now().plus(1, ChronoUnit.DAYS);
        // 查询预警单
        IPage<OrderOverdueRespVO> orderNearVOS = orderMapper.selectOrderNear(tomorrow, organId, page);
        List<OrderOverdueRespVO> records = orderNearVOS.getRecords();

        if (CollUtil.isNotEmpty(records)) {
            return new PageResult<>(records, orderNearVOS.getTotal());
        }

        return PageResult.empty();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer invalidOrder(Long orderId) {
        Integer notDeletedStatus = OrderDeletedEnum.NOT_DELETED.getStatus();
        Integer deletedStatus = OrderDeletedEnum.DELETED.getStatus();
        // 校验存在
        OrderDO orderDO = orderMapper.selectOrderOne(orderId, getUserOrganId(), notDeletedStatus);
        if (orderDO == null) {
            throw new ServiceException(ORDER_NOT_EXISTS);
        }
        // 状态校验
        if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.EMPTY.getStatus()) &&
                !Objects.equals(orderDO.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus())) {
            throw new ServiceException(ORDER_CAN_NOT_CANCEL);
        }

        // 是否主单
        boolean isMainOrder = Objects.equals(orderDO.getOrderType(), OrderTypeEnum.MAIN_ORDER.getStatus());
        if (isMainOrder) {
            // 主单：查询所有子单
            List<OrderDO> childOrders = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
                    .eq(OrderDO::getParentId, orderId)
                    .eq(OrderDO::getDeleted, notDeletedStatus));

            if (CollUtil.isNotEmpty(childOrders)) {
                // 作废：检查所有子单是否可作废
                boolean hasUncancellable = childOrders.stream().anyMatch(child ->
                        !Objects.equals(child.getStatus(), OrderStatusEnum.EMPTY.getStatus()) &&
                                !Objects.equals(child.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus()));
                if (hasUncancellable) {
                    throw new ServiceException(SUB_ORDER_CAN_NOT_CANCEL);
                }

                List<Long> allIds = new ArrayList<>();
                allIds.add(orderId);
                childOrders.forEach(child -> allIds.add(child.getId()));

                // 批量作废主子单
                return orderMapper.update(new LambdaUpdateWrapper<OrderDO>()
                        .in(OrderDO::getId, allIds)
                        .eq(OrderDO::getDeleted, notDeletedStatus)
                        .set(OrderDO::getDeleted, deletedStatus)
                );
            }
        }

        return orderMapper.update(new LambdaUpdateWrapper<OrderDO>()
                .eq(OrderDO::getId, orderId)
                .eq(OrderDO::getDeleted, notDeletedStatus)
                .set(OrderDO::getDeleted, deletedStatus)
        );
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer restoreOrder(Long orderId) {
        Integer notDeletedStatus = OrderDeletedEnum.NOT_DELETED.getStatus();
        Integer deletedStatus = OrderDeletedEnum.DELETED.getStatus();
        Long organId = getUserOrganId();

        OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId, deletedStatus);
        if (orderDO == null) {
            throw new ServiceException(ORDER_NOT_EXISTS);
        }

        boolean isMainOrder = Objects.equals(orderDO.getOrderType(), OrderTypeEnum.MAIN_ORDER.getStatus());
        if (isMainOrder) {
            // 主单：查询所有已作废的子单，一起还原
            List<OrderDO> deletedChildOrders = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
                    .eq(OrderDO::getParentId, orderId)
                    .eq(OrderDO::getOrganId, organId)
                    .eq(OrderDO::getDeleted, deletedStatus));

            if (CollUtil.isNotEmpty(deletedChildOrders)) {
                List<Long> allIds = new ArrayList<>();
                allIds.add(orderId);
                deletedChildOrders.forEach(child -> allIds.add(child.getId()));

                return orderMapper.update(new LambdaUpdateWrapper<OrderDO>()
                        .in(OrderDO::getId, allIds)
                        .eq(OrderDO::getOrganId, organId)
                        .eq(OrderDO::getDeleted, deletedStatus)
                        .set(OrderDO::getDeleted, notDeletedStatus)
                );
            }
        } else {
            // 子单：还原自身 + 对应主单，不还原其他子单
            Long parentId = orderDO.getParentId();
            List<Long> restoreIds = new ArrayList<>();
            restoreIds.add(orderId);
            restoreIds.add(parentId);

            return orderMapper.update(new LambdaUpdateWrapper<OrderDO>()
                    .in(OrderDO::getId, restoreIds)
                    .eq(OrderDO::getOrganId, organId)
                    .eq(OrderDO::getDeleted, deletedStatus)
                    .set(OrderDO::getDeleted, notDeletedStatus)
            );
        }

        // 主单无子单，直接还原
        return orderMapper.update(new LambdaUpdateWrapper<OrderDO>()
                .eq(OrderDO::getId, orderId)
                .eq(OrderDO::getOrganId, organId)
                .eq(OrderDO::getDeleted, deletedStatus)
                .set(OrderDO::getDeleted, notDeletedStatus)
        );
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void realDeletedOrder(Long orderId) {
        Long organId = getUserOrganId();
        Integer deletedStatus = OrderDeletedEnum.DELETED.getStatus();
        Integer notDeletedStatus = OrderDeletedEnum.NOT_DELETED.getStatus();

        OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId, deletedStatus);
        if (orderDO == null) {
            throw new ServiceException(ORDER_NOT_EXISTS);
        }

        boolean isMainOrder = Objects.equals(orderDO.getOrderType(), OrderTypeEnum.MAIN_ORDER.getStatus());
        if (isMainOrder) {
            // 检查是否存在未作废的子单
            long activeChildCount = orderMapper.selectCount(new LambdaQueryWrapper<OrderDO>()
                    .eq(OrderDO::getParentId, orderId)
                    .eq(OrderDO::getDeleted, notDeletedStatus));

            if (activeChildCount > 0) {
                throw new ServiceException(SUB_ORDER_CAN_NOT_CANCEL);
            }

            // 主单：连同所有子单一起删除
            List<OrderDO> childOrders = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
                    .eq(OrderDO::getParentId, orderId)
                    .eq(OrderDO::getDeleted, deletedStatus));

            if (CollUtil.isNotEmpty(childOrders)) {
                childOrders.forEach(child -> deleteOrderData(child.getId(), organId));
            }
        }

        deleteOrderData(orderId, organId);
    }

    /**
     * 删除订单数据
     *
     * @param orderId
     * @param organId
     */
    private void deleteOrderData(Long orderId, Long organId) {
        goodsMapper.deleteByOrderId(orderId, organId);
        orderItemMapper.deleteByOrderId(orderId, organId);
        orderBodyMapper.deleteByOrderId(orderId, organId);
        orderGroupMapper.deleteByOrderId(orderId, organId);
        orderPartsMapper.deleteByOrderId(orderId, organId);
        plateMapper.deleteByOrderId(orderId, organId);
        orderMapper.deleteOrder(orderId, organId);
    }

    /**
     * 订单是否存在判断
     *
     * @param id
     * @param organId
     * @param deleted
     * @return
     */
    private OrderDO validateOrderExists(Long id, Long organId, Integer deleted) {
        OrderDO orderDO = orderMapper.selectOrderOne(id, organId, deleted);
        if (orderDO == null) {
            throw new ServiceException(ORDER_NOT_EXISTS);
        }
        return orderDO;
    }

    /**
     * 校验父订单是否存在
     *
     * @param parentOrderId
     */
    private void validateParentOrderExists(Long parentOrderId) {
        if (ObjectUtil.isNull(parentOrderId)) {
            return;
        }
        AssertUtils.notEmpty(orderMapper.selectById(parentOrderId), PARENT_ORDER_NOT_EXISTS, parentOrderId);
    }

    //    验证自定义单号是否存在---去除本单
    private void validateCustomOrderNoExists(String customOrderNo, Long orderId) {
        if (customOrderNo != null) {
            if (!customOrderNo.isEmpty()) {
                if (orderMapper.selectCount(new LambdaQueryWrapper<OrderDO>()
                        .ne(OrderDO::getId, orderId)
                        .eq(OrderDO::getCustomOrderNo, customOrderNo)
                        .eq(OrderDO::getOrganId, OrganContextHolder.getOrganId())) > 0) {
                    throw new ServiceException(CUSTOM_ORDER_EXISTS);
                }
            }
        }
    }

    //    验证自定义单号是否存在---不去除本单，一般用在新建订单的时候用
    private void validateCustomOrderNoExists(String customOrderNo) {
        if (customOrderNo != null) {
            if (!customOrderNo.isEmpty()) {
                if (orderMapper.selectCount(new LambdaQueryWrapper<OrderDO>()
                        .eq(OrderDO::getCustomOrderNo, customOrderNo)
                        .eq(OrderDO::getOrganId, OrganContextHolder.getOrganId())) > 0) {
                    throw new ServiceException(CUSTOM_ORDER_EXISTS);
                }
            }
        }
    }

    /**
     * 校验查询柜体，优先bodyId下的所有柜体
     *
     * @param orderId
     * @param bodyId
     * @param organId
     * @param roomIds
     * @param deleted
     * @return
     */
    private List<Long> validateOrderBodyExists(Long orderId, Long bodyId, Long organId, Set<Long> roomIds, Integer deleted) {

        List<Long> bodyIds = new ArrayList<>();

        // 柜体id是否为空
        boolean bodyIdIsNull = ObjectUtil.isNotNull(bodyId);
        if (bodyIdIsNull) {
            Long bodyCount = orderBodyMapper.selectCount(new LambdaQueryWrapperX<OrderBodyDO>()
                    .eq(OrderBodyDO::getOrganId, organId)
                    .eqIfPresent(OrderBodyDO::getDeleted, deleted)
                    .eqIfPresent(OrderBodyDO::getOrderId, orderId)
                    .eqIfPresent(OrderBodyDO::getId, bodyId));

            if (bodyCount == 0) {
                throw new ServiceException(ORDER_BODY_NOT_EXISTS);
            }

            bodyIds.add(bodyId);
        }

        // 柜体id为空时查询房间下所有柜体id
        if (!bodyIdIsNull && CollUtil.isNotEmpty(roomIds)) {
            bodyIds.addAll(orderBodyMapper.selectBodyIdByRoomId(orderId, roomIds, organId, deleted));
        }

        return bodyIds;
    }

    private PlateGoodDO getPlateGood(String goodsId, Long organId) {
        List<PlateGoodDO> plateGoodDOs = plateGoodMapper.selectGoodOne(goodsId, organId);
        if (!plateGoodDOs.isEmpty()) {
            return plateGoodDOs.get(0);
        }
        return null;
    }

    // 配件匹配
    private List<PartsDO> getPartsGoods(List<OrderPartsDO> partsLists) {
        List<PartsDO> partsDOS = new ArrayList<>();

        for (OrderPartsDO partsDO : partsLists) {
            if (partsDO.getGoodsId() != null && !partsDO.getGoodsId().isEmpty()) { // 有goodsId
                PartsDO part = partsMapper.selectByGoodID(partsDO.getGoodsId(), OrganContextHolder.getOrganId());
                if (part == null) { // 不存在记录，存入数据库
                    partsDOS.add(BeanUtils.toBean(partsDO, PartsDO.class).setOrganId(OrganContextHolder.getOrganId()));

                }
            }
        }
        return partsDOS;
    }

//    private Map<String, List<?>> getPlateGoods(List<GoodsDO> goodsLists) { // order_goods list
//        Map<String, List<?>> map = new HashMap<>();
//        List<PlateGoodDO> plateGoodLists = new ArrayList<>();
//
//        if (goodsLists == null) {
//            return Collections.emptyMap();
//        }
//        for (GoodsDO goodsDO : goodsLists) {
//            PlateGoodDO plateGoodDO = null;
//            if (goodsDO.getGoodsId() != null && !goodsDO.getGoodsId().isEmpty()) { // 有goodsId，匹配goodsId
//                plateGoodDO = getPlateGood(goodsDO.getGoodsId(), OrganContextHolder.getOrganId());
//            }
//
//            // 直接匹配字段
//            List<PlateGoodDO> plateGoodDOS = plateGoodMapper.selectGood(goodsDO.getMaterial(), goodsDO.getColor(), goodsDO.getThickness(),
//                    goodsDO.getBrand(),goodsDO.getGoodsName(), OrganContextHolder.getOrganId());
//
//            if (plateGoodDO != null) {//存在板材
//                goodsDO.setGoodsId(plateGoodDO.getGoodsId());
//            } else if (plateGoodDOS != null && !plateGoodDOS.isEmpty()) { // 存在板材
//                goodsDO.setGoodsId(plateGoodDOS.get(0).getGoodsId());
//            } else { // 不存在板材
////                throw new ServiceException(ORDER_MATCH_NOT);
//                long plateNo = idWorker.nextId();
//                long obtainingTime = idWorker.obtainingTime();
//
//                String goodsId = goodsDO.getGoodsId() == null ? (obtainingTime) + Long.toString(plateNo).substring(2) : goodsDO.getGoodsId();
//                goodsDO.setGoodsId(goodsId);
//
//
//                Long plateGoods = (Long) identifierGenerator.nextId(null);
//
//                plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class)
//                        .setId(plateGoods)
//                        .setGoodsId(goodsId);
//
//                plateGoodLists.add(plateGoodDO);
//            }
//
//        }
//        map.put(FieldConstants.GOODS, goodsLists);
//        map.put(FieldConstants.PLATE_GOODS_LIST_KEY, plateGoodLists);
//        return map;
//    }

    private Map<String, List<?>> getPlateGoods(List<GoodsDO> goodsLists) { // order_goods list 不存在抛出错误
        Map<String, List<?>> map = new HashMap<>();
        List<PlateGoodDO> plateGoodLists = new ArrayList<>();

        if (goodsLists == null) {
            return Collections.emptyMap();
        }
        for (GoodsDO goodsDO : goodsLists) {
            List<PlateGoodDO> plateGoodDOs;

            if (goodsDO.getGoodsId() != null && !goodsDO.getGoodsId().isEmpty()) { // 有goodsId，匹配goodsId
                plateGoodDOs = plateGoodMapper.selectGoodOne(goodsDO.getGoodsId() , getUserOrganId());
            }else {
                plateGoodDOs = plateGoodMapper.selectGood(goodsDO.getMaterial(), goodsDO.getColor(), goodsDO.getThickness(),
                        goodsDO.getBrand(),goodsDO.getGoodsName(), OrganContextHolder.getOrganId());
            }

            // 直接匹配字段
            if (plateGoodDOs != null && !plateGoodDOs.isEmpty()) {//存在板材
                goodsDO.setGoodsId(plateGoodDOs.get(0).getGoodsId());
            } else { // 不存在板材
                throw new ServiceException(PLATE_ATTRIBUTE_NOT_EXIST, goodsDO.getGoodsId() == null ? "" : goodsDO.getGoodsId(), goodsDO.getGoodsName(), goodsDO.getMaterial(), goodsDO.getColor(), goodsDO.getThickness());

            }

        }
        map.put(FieldConstants.GOODS, goodsLists);
        map.put(FieldConstants.PLATE_GOODS_LIST_KEY, plateGoodLists);
        return map;
    }

    //    房间、柜体、加工组匹配
    public void roomCabinetProcessGroupMatch(Long orderId, List<OrderBodyDO> orderBodyList, List<OrderGroupDO> orderGroupList, List<OrderItemDO> orderItemDOList) {
        Map<String, List<OrderBodyDO>> roomMap = orderBodyList.stream().collect(Collectors.groupingBy(OrderBodyDO::getRoomName));

        // 查询所有房间柜体
        List<OrderBodyDO> orderBodyDOList = orderBodyMapper.selectList(orderId, DeletedCodeEnum.NOT_DELETED.getStatus(), OrganContextHolder.getOrganId());
        Map<String, List<OrderBodyDO>> roomOriginalMap = orderBodyDOList.stream().collect(Collectors.groupingBy(OrderBodyDO::getRoomName));
        // 查询所有的加工组
        List<OrderGroupDO> orderGroupDOList = orderGroupMapper.selectList(orderId, DeletedCodeEnum.NOT_DELETED.getStatus(), OrganContextHolder.getOrganId());
        Map<Long, Map<String, List<OrderGroupDO>>> groupOriginalMap = orderGroupDOList.stream().collect(Collectors.groupingBy(OrderGroupDO::getBodyId, Collectors.groupingBy(OrderGroupDO::getGroupTypeName)));

        // 需要修改的柜体表
        List<OrderBodyDO> updateBodyList = new ArrayList<>();
        // 需要修改的加工组表
        List<OrderGroupDO> updateGroupList = new ArrayList<>();


        roomMap.forEach((roomName, roomList) -> {
//            List<OrderBodyDO> sameOriginalRoomList = orderBodyMapper.selectByRoomName(orderId, roomName, OrganContextHolder.getOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus());
            List<OrderBodyDO> sameOriginalRoomList = roomOriginalMap.get(roomName);

            if (sameOriginalRoomList != null && sameOriginalRoomList.size() > 0) {
                Long roomId = roomList.get(0).getRoomId();

                Long OriginalRoomId = sameOriginalRoomList.get(0).getRoomId();

//                修改roomId （orderBody中）
                updateRoomIdInOrderBodies(orderBodyList, roomId, OriginalRoomId);
//                修改orderItem
                updateRoomIdInOrderItems(orderItemDOList, roomId, OriginalRoomId);

                Map<String, OrderBodyDO> bodyMap = roomList.stream()
                        .collect(Collectors.toMap(
                                OrderBodyDO::getName,
                                Function.identity()
                        )); // 新

                sameOriginalRoomList.forEach(originalRoomBody -> {
                    if (bodyMap.containsKey(originalRoomBody.getName())) {
                        OrderBodyDO newRoomBody = bodyMap.get(originalRoomBody.getName());

                        Long originalBodyId = originalRoomBody.getId();
                        Long bodyId = bodyMap.get(originalRoomBody.getName()).getId();
                        int multiNum = originalRoomBody.getMultiNum() + newRoomBody.getMultiNum();
                        int plateNum = originalRoomBody.getPlateNum() + newRoomBody.getPlateNum();
                        int unregularNum = originalRoomBody.getUnregularNum() + newRoomBody.getUnregularNum();

                        updateBodyList.add(originalRoomBody.setMultiNum(multiNum).setPlateNum(plateNum).setUnregularNum(unregularNum));
                        // 新增去除
                        orderBodyList.remove(newRoomBody);

                        // 修改orderItem
                        updateBodyIdInOrderItems(orderItemDOList, bodyId, originalBodyId);

                        // 修改group, 相同body的条件下，修改bodyId
                        updateGroupIdInOrderGroups(orderGroupList, bodyId, originalBodyId);

                    }
                });
            }
        });

        // 需要存的
        Map<Long, Map<String, List<OrderGroupDO>>> groupMap = orderGroupList.stream().collect(Collectors.groupingBy(OrderGroupDO::getBodyId, Collectors.groupingBy(OrderGroupDO::getGroupTypeName)));
        groupMap.forEach((bodyId, groupMapByBodyIdMap) -> {
            Map<String, List<OrderGroupDO>> groupOriginalMapByBodyId = groupOriginalMap.get(bodyId); //原来的
            if (groupOriginalMapByBodyId == null) {
                return;
            }
            groupOriginalMapByBodyId.forEach((groupTypeName, groupOriginalList) -> {

                if (groupMapByBodyIdMap.containsKey(groupTypeName)) {
                    List<OrderGroupDO> groupMapByBodyIdList = groupMapByBodyIdMap.get(groupTypeName);
                    groupMapByBodyIdList.forEach(group -> {
                        Long groupTypeId = group.getGroupTypeId();
                        Long OriginalGroupTypeId = groupOriginalList.get(0).getGroupTypeId();

                        // 修改group表中的groupTypeId
                        updateGroupTypeIdInOrderGroups(orderGroupList, groupTypeId, OriginalGroupTypeId);

                        Map<String, OrderGroupDO> groupByGroupNameMap = groupMapByBodyIdList.stream().collect(Collectors.toMap(
                                OrderGroupDO::getName,
                                Function.identity()
                        )); // type相同的时候找name相同
                        groupOriginalList.forEach(originalGroup -> {
                            if (groupByGroupNameMap.containsKey(originalGroup.getName())) {
                                OrderGroupDO newGroup = groupByGroupNameMap.get(originalGroup.getName());
                                Long originalGroupId = originalGroup.getId();
                                Long groupId = newGroup.getId();
                                int multiNum = originalGroup.getMultiNum() + newGroup.getMultiNum();
                                int plateNum = originalGroup.getPlateNum() + newGroup.getPlateNum();
                                int unregularNum = originalGroup.getUnregularNum() + newGroup.getUnregularNum();
                                updateGroupList.add(originalGroup.setMultiNum(multiNum).setPlateNum(plateNum).setUnregularNum(unregularNum)); // 修改新增

                                // 新增去除
                                orderGroupList.remove(newGroup);

                                // item修改
                                updateGroupIdInOrderItems(orderItemDOList, groupId, originalGroupId);
                            }
                        });
                    });
                }
            });
        });

        // 批量更新
        if (!updateBodyList.isEmpty()) {
            orderBodyMapper.updateBatch(updateBodyList);
        }
        if (!updateGroupList.isEmpty()) {
            orderGroupMapper.updateBatch(updateGroupList);
        }


    }

    private void updateRoomIdInOrderBodies(List<OrderBodyDO> orderBodyList, Long roomId, Long originalRoomId) {
        Map<Long, List<OrderBodyDO>> bodyMap = orderBodyList.stream().collect(Collectors.groupingBy(OrderBodyDO::getRoomId));
        if (bodyMap.containsKey(roomId)) {
            bodyMap.get(roomId).forEach(room -> {
                room.setRoomId(originalRoomId);
            });
        }
    }

    private void updateRoomIdInOrderItems(List<OrderItemDO> orderItemDOList, Long roomId, Long originalRoomId ) {
        Map<Long, List<OrderItemDO>> itemMap = orderItemDOList.stream().collect(Collectors.groupingBy(OrderItemDO::getRoomId));
        if (itemMap.containsKey(roomId)) {
            itemMap.get(roomId).forEach(item -> {
                item.setRoomId(originalRoomId);
            });
        }
    }

    private void updateBodyIdInOrderItems(List<OrderItemDO> orderItemDOList, Long bodyId , Long originalBodyId) {
        Map<Long, List<OrderItemDO>> itemMap = orderItemDOList.stream().collect(Collectors.groupingBy(OrderItemDO::getBodyId));
        if (itemMap.containsKey(bodyId)) {
            itemMap.get(bodyId).forEach(item -> {
                item.setBodyId(originalBodyId);
            });
        }
    }

    private void updateGroupIdInOrderGroups(List<OrderGroupDO> orderGroupDOList, Long bodyId , Long originalBodyId) {
        Map<Long, List<OrderGroupDO>> groupMap = orderGroupDOList.stream().collect(Collectors.groupingBy(OrderGroupDO::getBodyId));
        if (groupMap.containsKey(bodyId)) {
            groupMap.get(bodyId).forEach(group -> {
                group.setBodyId(originalBodyId);
            });
        }
    }

    private void updateGroupIdInOrderItems(List<OrderItemDO> orderItemDOList, Long groupId , Long originalGroupId) {
        Map<Long, List<OrderItemDO>> itemMap = orderItemDOList.stream() .filter(item -> item.getGroupId() != null)  // 过滤掉getGroupId为null的对象
                .collect(Collectors.groupingBy(OrderItemDO::getGroupId));
        if (itemMap.containsKey(groupId)) {
            itemMap.get(groupId).forEach(item -> {
                item.setGroupId(originalGroupId);
            });
        }
    }

    private void updateGroupTypeIdInOrderGroups(List<OrderGroupDO> orderGroupDOList, Long groupTypeId , Long originalGroupTypeId) {
        Map<Long, List<OrderGroupDO>> itemMap = orderGroupDOList.stream().collect(Collectors.groupingBy(OrderGroupDO::getGroupTypeId));
        if (itemMap.containsKey(groupTypeId)) {
            itemMap.get(groupTypeId).forEach(item -> {
                item.setGroupTypeId(originalGroupTypeId);
            });
        }
    }

    // 根据ype 与 orderId获取相关信息
    public Map<String, Object> getDataByOrderIdAndType(OrderDO orderDO, String type, Integer deleted) {
        String tableKey = "table";
        String plateCountKey = "plateCount";
        Map<String, Object> map = new HashMap<>();
        map.put("orderDO", orderDO);
        switch (type) {
            case "配件明细1-模板.xlsx":// 配件明细
                map.put("partsListDetail", orderPartsMapper.selectPartDetail(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"10\" data-t=\"s\" data-v=\"配件明细单\" id=\"sjs-A1\">配件明细单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\">订单号:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B2\">数据源</td><td data-t=\"s\" data-v=\"自定义单号:\" id=\"sjs-C2\">自定义单号:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D2\">数据源</td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F2\">数据源</td><td data-t=\"s\" data-v=\"订单日期:\" id=\"sjs-G2\">订单日期:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H2\">数据源</td><td id=\"sjs-I2\"></td><td id=\"sjs-J2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\">客户:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B3\">数据源</td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\">收货电话:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D3\">数据源</td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\">收货地址:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F3\">数据源</td><td data-t=\"s\" data-v=\"收货日期:\" id=\"sjs-G3\">收货日期:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H3\">数据源</td><td id=\"sjs-I3\"></td><td id=\"sjs-J3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td colspan=\"7\" data-t=\"s\" data-v=\"数据源\" id=\"sjs-B4\">数据源</td><td id=\"sjs-I4\"></td><td id=\"sjs-J4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td><td id=\"sjs-J5\"></td></tr><tr><td colspan=\"3\" data-t=\"s\" data-v=\"房间名数据源\" id=\"sjs-A6\">房间名数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"柜体名表数据源\" id=\"sjs-D6\">柜体名表数据源</td><td colspan=\"4\" id=\"sjs-G6\"></td></tr><tr><td data-t=\"s\" data-v=\"名称\" id=\"sjs-A7\">名称</td><td data-t=\"s\" data-v=\"品牌\" id=\"sjs-B7\">品牌</td><td data-t=\"s\" data-v=\"厂家\" id=\"sjs-C7\">厂家</td><td data-t=\"s\" data-v=\"型号\" id=\"sjs-D7\">型号</td><td data-t=\"s\" data-v=\"规格\" id=\"sjs-E7\">规格</td><td data-t=\"s\" data-v=\"数量\" id=\"sjs-F7\">数量</td><td data-t=\"s\" data-v=\"单位\" id=\"sjs-G7\">单位</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-H7\">备注</td><td id=\"sjs-I7\"></td><td id=\"sjs-J7\"></td></tr><tr><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-A8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-C8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-E8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-G8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H8\">数据源</td><td id=\"sjs-I8\"></td><td id=\"sjs-J8\"></td></tr><tr><td id=\"sjs-A9\"></td><td id=\"sjs-B9\"></td><td id=\"sjs-C9\"></td><td id=\"sjs-D9\"></td><td id=\"sjs-E9\"></td><td id=\"sjs-F9\"></td><td id=\"sjs-G9\"></td><td id=\"sjs-H9\"></td><td id=\"sjs-I9\"></td><td id=\"sjs-J9\"></td></tr><tr><td id=\"sjs-A10\"></td><td id=\"sjs-B10\"></td><td id=\"sjs-C10\"></td><td id=\"sjs-D10\"></td><td id=\"sjs-E10\"></td><td id=\"sjs-F10\"></td><td id=\"sjs-G10\"></td><td id=\"sjs-H10\"></td><td id=\"sjs-I10\"></td><td id=\"sjs-J10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td><td id=\"sjs-J11\"></td></tr><tr><td colspan=\"3\" id=\"sjs-A12\"></td><td colspan=\"3\" id=\"sjs-D12\"></td><td colspan=\"4\" id=\"sjs-G12\"></td></tr><tr><td id=\"sjs-A13\"></td><td id=\"sjs-B13\"></td><td id=\"sjs-C13\"></td><td id=\"sjs-D13\"></td><td id=\"sjs-E13\"></td><td id=\"sjs-F13\"></td><td id=\"sjs-G13\"></td><td id=\"sjs-H13\"></td><td id=\"sjs-I13\"></td><td id=\"sjs-J13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td><td id=\"sjs-J14\"></td></tr><tr><td colspan=\"8\" id=\"sjs-A15\"></td><td id=\"sjs-I15\"></td><td id=\"sjs-J15\"></td></tr><tr><td colspan=\"3\" id=\"sjs-A16\"></td><td colspan=\"3\" id=\"sjs-D16\"></td><td colspan=\"4\" id=\"sjs-G16\"></td></tr><tr><td id=\"sjs-A17\"></td><td id=\"sjs-B17\"></td><td id=\"sjs-C17\"></td><td id=\"sjs-D17\"></td><td id=\"sjs-E17\"></td><td id=\"sjs-F17\"></td><td id=\"sjs-G17\"></td><td id=\"sjs-H17\"></td><td id=\"sjs-I17\"></td><td id=\"sjs-J17\"></td></tr><tr><td id=\"sjs-A18\"></td><td id=\"sjs-B18\"></td><td id=\"sjs-C18\"></td><td id=\"sjs-D18\"></td><td id=\"sjs-E18\"></td><td id=\"sjs-F18\"></td><td id=\"sjs-G18\"></td><td id=\"sjs-H18\"></td><td id=\"sjs-I18\"></td><td id=\"sjs-J18\"></td></tr><tr><td colspan=\"8\" id=\"sjs-A19\"></td><td id=\"sjs-I19\"></td><td id=\"sjs-J19\"></td></tr><tr><td colspan=\"3\" id=\"sjs-A20\"></td><td colspan=\"3\" id=\"sjs-D20\"></td><td colspan=\"4\" id=\"sjs-G20\"></td></tr><tr><td id=\"sjs-A21\"></td><td id=\"sjs-B21\"></td><td id=\"sjs-C21\"></td><td id=\"sjs-D21\"></td><td id=\"sjs-E21\"></td><td id=\"sjs-F21\"></td><td id=\"sjs-G21\"></td><td id=\"sjs-H21\"></td><td id=\"sjs-I21\"></td><td id=\"sjs-J21\"></td></tr><tr><td id=\"sjs-A22\"></td><td id=\"sjs-B22\"></td><td id=\"sjs-C22\"></td><td id=\"sjs-D22\"></td><td id=\"sjs-E22\"></td><td id=\"sjs-F22\"></td><td id=\"sjs-G22\"></td><td id=\"sjs-H22\"></td><td id=\"sjs-I22\"></td><td id=\"sjs-J22\"></td></tr><tr><td id=\"sjs-A23\"></td><td id=\"sjs-B23\"></td><td id=\"sjs-C23\"></td><td id=\"sjs-D23\"></td><td id=\"sjs-E23\"></td><td id=\"sjs-F23\"></td><td id=\"sjs-G23\"></td><td id=\"sjs-H23\"></td><td id=\"sjs-I23\"></td><td id=\"sjs-J23\"></td></tr><tr><td id=\"sjs-A24\"></td><td id=\"sjs-B24\"></td><td id=\"sjs-C24\"></td><td id=\"sjs-D24\"></td><td id=\"sjs-E24\"></td><td id=\"sjs-F24\"></td><td id=\"sjs-G24\"></td><td id=\"sjs-H24\"></td><td id=\"sjs-I24\"></td><td id=\"sjs-J24\"></td></tr><tr><td id=\"sjs-A25\"></td><td id=\"sjs-B25\"></td><td id=\"sjs-C25\"></td><td id=\"sjs-D25\"></td><td id=\"sjs-E25\"></td><td id=\"sjs-F25\"></td><td id=\"sjs-G25\"></td><td id=\"sjs-H25\"></td><td id=\"sjs-I25\"></td><td id=\"sjs-J25\"></td></tr><tr><td colspan=\"8\" id=\"sjs-A26\"></td><td id=\"sjs-I26\"></td><td id=\"sjs-J26\"></td></tr><tr><td colspan=\"8\" id=\"sjs-A27\"></td><td id=\"sjs-I27\"></td><td id=\"sjs-J27\"></td></tr></table></body></html>");
                break;
            case "配件汇总1-模板.xlsx":// 配件汇总
                map.put("partsSummary", orderPartsMapper.selectPartAll(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"7\" data-t=\"s\" data-v=\"配件汇总单\" id=\"sjs-A1\">配件汇总单</td><td id=\"sjs-H1\"></td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\"><span style=\"font-size:10pt;\"><b>订单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B2\"></td><td data-t=\"s\" data-v=\"自定单号:\" id=\"sjs-C2\"><span style=\"font-size:10pt;\"><b>自定单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D2\"></td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td id=\"sjs-F2\"></td><td data-t=\"s\" data-v=\"订单日期：\" id=\"sjs-G2\"><span style=\"font-size:10pt;\"><b>订单日期</b></span><span style=\"font-size:10pt;\"><b>：</b></span></td><td id=\"sjs-H2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\"><span style=\"font-size:10pt;\"><b>客户</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B3\"></td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\"><span style=\"font-size:10pt;\"><b>收货电话</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D3\"></td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\"><span style=\"font-size:10pt;\"><b>收货地址</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-F3\"></td><td data-t=\"s\" data-v=\"收货日期：\" id=\"sjs-G3\"><span style=\"font-size:10pt;\"><b>收货日期：</b></span></td><td id=\"sjs-H3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td id=\"sjs-B4\"></td><td id=\"sjs-C4\"></td><td id=\"sjs-D4\"></td><td id=\"sjs-E4\"></td><td id=\"sjs-F4\"></td><td id=\"sjs-G4\"></td><td id=\"sjs-H4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td></tr><tr><td data-t=\"s\" data-v=\"名称\" id=\"sjs-A6\">名称</td><td data-t=\"s\" data-v=\"型号\" id=\"sjs-B6\">型号</td><td data-t=\"s\" data-v=\"规格\" id=\"sjs-C6\">规格</td><td data-t=\"s\" data-v=\"数量\" id=\"sjs-D6\">数量</td><td data-t=\"s\" data-v=\"单位\" id=\"sjs-E6\">单位</td><td data-t=\"s\" data-v=\"品牌\" id=\"sjs-F6\">品牌</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-G6\">备注</td><td id=\"sjs-H6\"></td></tr><tr><td id=\"sjs-A7\"></td><td id=\"sjs-B7\"></td><td id=\"sjs-C7\"></td><td id=\"sjs-D7\"></td><td id=\"sjs-E7\"></td><td id=\"sjs-F7\"></td><td id=\"sjs-G7\"></td><td id=\"sjs-H7\"></td></tr><tr><td id=\"sjs-A8\"></td><td id=\"sjs-B8\"></td><td id=\"sjs-C8\"></td><td id=\"sjs-D8\"></td><td id=\"sjs-E8\"></td><td id=\"sjs-F8\"></td><td id=\"sjs-G8\"></td><td id=\"sjs-H8\"></td></tr><tr><td id=\"sjs-A9\"></td><td id=\"sjs-B9\"></td><td id=\"sjs-C9\"></td><td id=\"sjs-D9\"></td><td id=\"sjs-E9\"></td><td id=\"sjs-F9\"></td><td id=\"sjs-G9\"></td><td id=\"sjs-H9\"></td></tr><tr><td id=\"sjs-A10\"></td><td id=\"sjs-B10\"></td><td id=\"sjs-C10\"></td><td id=\"sjs-D10\"></td><td id=\"sjs-E10\"></td><td id=\"sjs-F10\"></td><td id=\"sjs-G10\"></td><td id=\"sjs-H10\"></td></tr></table></body></html>");
                break;
            case "板材明细-按房间-模板.xlsx":
                map.put("plateListDetail", plateMapper.selectPlateGoodsList(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"13\" data-t=\"s\" data-v=\"板材明细单\" id=\"sjs-A1\">板材明细单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\"><span style=\"font-size:10pt;\"><b>订单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B2\"></td><td data-t=\"s\" data-v=\"自定单号:\" id=\"sjs-C2\"><span style=\"font-size:10pt;\"><b>自定单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D2\"></td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td id=\"sjs-F2\"></td><td data-t=\"s\" data-v=\"订单日期：\" id=\"sjs-G2\"><span style=\"font-size:10pt;\"><b>订单日期</b></span><span style=\"font-size:10pt;\"><b>：</b></span></td><td id=\"sjs-H2\"></td><td id=\"sjs-I2\"></td><td id=\"sjs-J2\"></td><td id=\"sjs-K2\"></td><td id=\"sjs-L2\"></td><td id=\"sjs-M2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\"><span style=\"font-size:10pt;\"><b>客户</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B3\"></td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\"><span style=\"font-size:10pt;\"><b>收货电话</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D3\"></td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\"><span style=\"font-size:10pt;\"><b>收货地址</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-F3\"></td><td data-t=\"s\" data-v=\"收货日期：\" id=\"sjs-G3\"><span style=\"font-size:10pt;\"><b>收货日期：</b></span></td><td id=\"sjs-H3\"></td><td id=\"sjs-I3\"></td><td id=\"sjs-J3\"></td><td id=\"sjs-K3\"></td><td id=\"sjs-L3\"></td><td id=\"sjs-M3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td id=\"sjs-B4\"></td><td id=\"sjs-C4\"></td><td id=\"sjs-D4\"></td><td id=\"sjs-E4\"></td><td id=\"sjs-F4\"></td><td id=\"sjs-G4\"></td><td id=\"sjs-H4\"></td><td id=\"sjs-I4\"></td><td id=\"sjs-J4\"></td><td id=\"sjs-K4\"></td><td id=\"sjs-L4\"></td><td id=\"sjs-M4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td><td id=\"sjs-J5\"></td><td id=\"sjs-K5\"></td><td id=\"sjs-L5\"></td><td id=\"sjs-M5\"></td></tr><tr><td data-t=\"s\" data-v=\"房间名数据源\" id=\"sjs-A6\">房间名数据源</td><td colspan=\"2\" data-t=\"s\" data-v=\"柜体数据源\" id=\"sjs-B6\">柜体数据源</td><td colspan=\"3\" id=\"sjs-D6\"></td><td colspan=\"3\" data-t=\"s\" data-v=\"列表条数表达式\" id=\"sjs-G6\">列表条数表达式</td><td id=\"sjs-J6\"></td><td id=\"sjs-K6\"></td><td id=\"sjs-L6\"></td><td id=\"sjs-M6\"></td></tr><tr><td data-t=\"s\" data-v=\"板编号\" id=\"sjs-A7\">板编号</td><td data-t=\"s\" data-v=\"板名称\" id=\"sjs-B7\">板名称</td><td data-t=\"s\" data-v=\"材料\" id=\"sjs-C7\">材料</td><td data-t=\"s\" data-v=\"颜色\" id=\"sjs-D7\">颜色</td><td data-t=\"s\" data-v=\"长\" id=\"sjs-E7\">长</td><td data-t=\"s\" data-v=\"宽\" id=\"sjs-F7\">宽</td><td data-t=\"s\" data-v=\"厚度\" id=\"sjs-G7\">厚度</td><td data-t=\"s\" data-v=\"面积\" id=\"sjs-H7\">面积</td><td data-t=\"s\" data-v=\"异形\" id=\"sjs-I7\">异形</td><td data-t=\"s\" data-v=\"造型\" id=\"sjs-J7\">造型</td><td data-t=\"s\" data-v=\"左/右/上/下\" id=\"sjs-K7\">左/右/上/下</td><td data-t=\"s\" data-v=\"开门类型\" id=\"sjs-L7\">开门类型</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-M7\">备注</td></tr><tr><td id=\"sjs-A8\"></td><td id=\"sjs-B8\"></td><td id=\"sjs-C8\"></td><td id=\"sjs-D8\"></td><td id=\"sjs-E8\"></td><td id=\"sjs-F8\"></td><td id=\"sjs-G8\"></td><td id=\"sjs-H8\"></td><td id=\"sjs-I8\"></td><td id=\"sjs-J8\"></td><td id=\"sjs-K8\"></td><td id=\"sjs-L8\"></td><td id=\"sjs-M8\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"小计：\" id=\"sjs-A9\">小计：</td><td colspan=\"2\" data-t=\"s\" data-v=\"小计面积表达式\" id=\"sjs-G9\">小计面积表达式</td><td id=\"sjs-I9\"></td><td id=\"sjs-J9\"></td><td id=\"sjs-K9\"></td><td id=\"sjs-L9\"></td><td id=\"sjs-M9\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"合计：\" id=\"sjs-A10\">合计：</td><td colspan=\"2\" data-t=\"s\" data-v=\"合计面积表达式\" id=\"sjs-G10\">合计面积表达式</td><td id=\"sjs-I10\"></td><td id=\"sjs-J10\"></td><td id=\"sjs-K10\"></td><td id=\"sjs-L10\"></td><td id=\"sjs-M10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td><td id=\"sjs-J11\"></td><td id=\"sjs-K11\"></td><td id=\"sjs-L11\"></td><td id=\"sjs-M11\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A12\"></td><td colspan=\"2\" id=\"sjs-G12\"></td><td colspan=\"5\" id=\"sjs-I12\"></td></tr><tr><td id=\"sjs-A13\"></td><td colspan=\"2\" id=\"sjs-B13\"></td><td colspan=\"3\" id=\"sjs-D13\"></td><td colspan=\"3\" id=\"sjs-G13\"></td><td id=\"sjs-J13\"></td><td id=\"sjs-K13\"></td><td id=\"sjs-L13\"></td><td id=\"sjs-M13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td><td id=\"sjs-J14\"></td><td id=\"sjs-K14\"></td><td id=\"sjs-L14\"></td><td id=\"sjs-M14\"></td></tr><tr><td id=\"sjs-A15\"></td><td id=\"sjs-B15\"></td><td id=\"sjs-C15\"></td><td id=\"sjs-D15\"></td><td id=\"sjs-E15\"></td><td id=\"sjs-F15\"></td><td id=\"sjs-G15\"></td><td id=\"sjs-H15\"></td><td id=\"sjs-I15\"></td><td id=\"sjs-J15\"></td><td id=\"sjs-K15\"></td><td id=\"sjs-L15\"></td><td id=\"sjs-M15\"></td></tr><tr><td id=\"sjs-A16\"></td><td id=\"sjs-B16\"></td><td id=\"sjs-C16\"></td><td id=\"sjs-D16\"></td><td id=\"sjs-E16\"></td><td id=\"sjs-F16\"></td><td id=\"sjs-G16\"></td><td id=\"sjs-H16\"></td><td id=\"sjs-I16\"></td><td id=\"sjs-J16\"></td><td id=\"sjs-K16\"></td><td id=\"sjs-L16\"></td><td id=\"sjs-M16\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A17\"></td><td colspan=\"2\" id=\"sjs-G17\"></td><td colspan=\"5\" id=\"sjs-I17\"></td></tr><tr><td id=\"sjs-A18\"></td><td colspan=\"2\" id=\"sjs-B18\"></td><td colspan=\"3\" id=\"sjs-D18\"></td><td colspan=\"3\" id=\"sjs-G18\"></td><td id=\"sjs-J18\"></td><td id=\"sjs-K18\"></td><td id=\"sjs-L18\"></td><td id=\"sjs-M18\"></td></tr><tr><td id=\"sjs-A19\"></td><td id=\"sjs-B19\"></td><td id=\"sjs-C19\"></td><td id=\"sjs-D19\"></td><td id=\"sjs-E19\"></td><td id=\"sjs-F19\"></td><td id=\"sjs-G19\"></td><td id=\"sjs-H19\"></td><td id=\"sjs-I19\"></td><td id=\"sjs-J19\"></td><td id=\"sjs-K19\"></td><td id=\"sjs-L19\"></td><td id=\"sjs-M19\"></td></tr><tr><td id=\"sjs-A20\"></td><td id=\"sjs-B20\"></td><td id=\"sjs-C20\"></td><td id=\"sjs-D20\"></td><td id=\"sjs-E20\"></td><td id=\"sjs-F20\"></td><td id=\"sjs-G20\"></td><td id=\"sjs-H20\"></td><td id=\"sjs-I20\"></td><td id=\"sjs-J20\"></td><td id=\"sjs-K20\"></td><td id=\"sjs-L20\"></td><td id=\"sjs-M20\"></td></tr><tr><td id=\"sjs-A21\"></td><td id=\"sjs-B21\"></td><td id=\"sjs-C21\"></td><td id=\"sjs-D21\"></td><td id=\"sjs-E21\"></td><td id=\"sjs-F21\"></td><td id=\"sjs-G21\"></td><td id=\"sjs-H21\"></td><td id=\"sjs-I21\"></td><td id=\"sjs-J21\"></td><td id=\"sjs-K21\"></td><td id=\"sjs-L21\"></td><td id=\"sjs-M21\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A22\"></td><td colspan=\"2\" id=\"sjs-G22\"></td><td colspan=\"5\" id=\"sjs-I22\"></td></tr><tr><td id=\"sjs-A23\"></td><td colspan=\"2\" id=\"sjs-B23\"></td><td colspan=\"3\" id=\"sjs-D23\"></td><td colspan=\"3\" id=\"sjs-G23\"></td><td id=\"sjs-J23\"></td><td id=\"sjs-K23\"></td><td id=\"sjs-L23\"></td><td id=\"sjs-M23\"></td></tr><tr><td id=\"sjs-A24\"></td><td id=\"sjs-B24\"></td><td id=\"sjs-C24\"></td><td id=\"sjs-D24\"></td><td id=\"sjs-E24\"></td><td id=\"sjs-F24\"></td><td id=\"sjs-G24\"></td><td id=\"sjs-H24\"></td><td id=\"sjs-I24\"></td><td id=\"sjs-J24\"></td><td id=\"sjs-K24\"></td><td id=\"sjs-L24\"></td><td id=\"sjs-M24\"></td></tr><tr><td id=\"sjs-A25\"></td><td id=\"sjs-B25\"></td><td id=\"sjs-C25\"></td><td id=\"sjs-D25\"></td><td id=\"sjs-E25\"></td><td id=\"sjs-F25\"></td><td id=\"sjs-G25\"></td><td id=\"sjs-H25\"></td><td id=\"sjs-I25\"></td><td id=\"sjs-J25\"></td><td id=\"sjs-K25\"></td><td id=\"sjs-L25\"></td><td id=\"sjs-M25\"></td></tr><tr><td id=\"sjs-A26\"></td><td id=\"sjs-B26\"></td><td id=\"sjs-C26\"></td><td id=\"sjs-D26\"></td><td id=\"sjs-E26\"></td><td id=\"sjs-F26\"></td><td id=\"sjs-G26\"></td><td id=\"sjs-H26\"></td><td id=\"sjs-I26\"></td><td id=\"sjs-J26\"></td><td id=\"sjs-K26\"></td><td id=\"sjs-L26\"></td><td id=\"sjs-M26\"></td></tr><tr><td id=\"sjs-A27\"></td><td id=\"sjs-B27\"></td><td id=\"sjs-C27\"></td><td id=\"sjs-D27\"></td><td id=\"sjs-E27\"></td><td id=\"sjs-F27\"></td><td id=\"sjs-G27\"></td><td id=\"sjs-H27\"></td><td id=\"sjs-I27\"></td><td id=\"sjs-J27\"></td><td id=\"sjs-K27\"></td><td id=\"sjs-L27\"></td><td id=\"sjs-M27\"></td></tr><tr><td id=\"sjs-A28\"></td><td id=\"sjs-B28\"></td><td id=\"sjs-C28\"></td><td id=\"sjs-D28\"></td><td id=\"sjs-E28\"></td><td id=\"sjs-F28\"></td><td id=\"sjs-G28\"></td><td id=\"sjs-H28\"></td><td id=\"sjs-I28\"></td><td id=\"sjs-J28\"></td><td id=\"sjs-K28\"></td><td id=\"sjs-L28\"></td><td id=\"sjs-M28\"></td></tr><tr><td id=\"sjs-A29\"></td><td id=\"sjs-B29\"></td><td id=\"sjs-C29\"></td><td id=\"sjs-D29\"></td><td id=\"sjs-E29\"></td><td id=\"sjs-F29\"></td><td id=\"sjs-G29\"></td><td id=\"sjs-H29\"></td><td id=\"sjs-I29\"></td><td id=\"sjs-J29\"></td><td id=\"sjs-K29\"></td><td id=\"sjs-L29\"></td><td id=\"sjs-M29\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A30\"></td><td colspan=\"2\" id=\"sjs-G30\"></td><td colspan=\"5\" id=\"sjs-I30\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A31\"></td><td colspan=\"2\" id=\"sjs-G31\"></td><td colspan=\"5\" id=\"sjs-I31\"></td></tr></table></body></html>");
                map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                break;
            case "板材明细-按板材-模板.xlsx":
                map.put("plateListDetail", plateMapper.selectPlateGoodsList(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"13\" data-t=\"s\" data-v=\"板材明细单\" id=\"sjs-A1\">板材明细单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\"><span style=\"font-size:10pt;\"><b>订单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B2\"></td><td data-t=\"s\" data-v=\"自定单号:\" id=\"sjs-C2\"><span style=\"font-size:10pt;\"><b>自定单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D2\"></td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td id=\"sjs-F2\"></td><td data-t=\"s\" data-v=\"订单日期：\" id=\"sjs-G2\"><span style=\"font-size:10pt;\"><b>订单日期</b></span><span style=\"font-size:10pt;\"><b>：</b></span></td><td id=\"sjs-H2\"></td><td id=\"sjs-I2\"></td><td id=\"sjs-J2\"></td><td id=\"sjs-K2\"></td><td id=\"sjs-L2\"></td><td id=\"sjs-M2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\"><span style=\"font-size:10pt;\"><b>客户</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B3\"></td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\"><span style=\"font-size:10pt;\"><b>收货电话</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D3\"></td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\"><span style=\"font-size:10pt;\"><b>收货地址</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-F3\"></td><td data-t=\"s\" data-v=\"收货日期：\" id=\"sjs-G3\"><span style=\"font-size:10pt;\"><b>收货日期：</b></span></td><td id=\"sjs-H3\"></td><td id=\"sjs-I3\"></td><td id=\"sjs-J3\"></td><td id=\"sjs-K3\"></td><td id=\"sjs-L3\"></td><td id=\"sjs-M3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td id=\"sjs-B4\"></td><td id=\"sjs-C4\"></td><td id=\"sjs-D4\"></td><td id=\"sjs-E4\"></td><td id=\"sjs-F4\"></td><td id=\"sjs-G4\"></td><td id=\"sjs-H4\"></td><td id=\"sjs-I4\"></td><td id=\"sjs-J4\"></td><td id=\"sjs-K4\"></td><td id=\"sjs-L4\"></td><td id=\"sjs-M4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td><td id=\"sjs-J5\"></td><td id=\"sjs-K5\"></td><td id=\"sjs-L5\"></td><td id=\"sjs-M5\"></td></tr><tr><td colspan=\"2\" data-t=\"s\" data-v=\"板材名称数据源\" id=\"sjs-A6\">板材名称数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"板材颜色数据源\" id=\"sjs-C6\">板材颜色数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"板材厚度数据源\" id=\"sjs-F6\">板材厚度数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"列表条数表达式\" id=\"sjs-I6\">列表条数表达式</td><td id=\"sjs-L6\"></td><td id=\"sjs-M6\"></td></tr><tr><td data-t=\"s\" data-v=\"房名\" id=\"sjs-A7\">房名</td><td data-t=\"s\" data-v=\"柜名\" id=\"sjs-B7\">柜名</td><td data-t=\"s\" data-v=\"板编号\" id=\"sjs-C7\">板编号</td><td data-t=\"s\" data-v=\"板名称\" id=\"sjs-D7\">板名称</td><td data-t=\"s\" data-v=\"长\" id=\"sjs-E7\">长</td><td data-t=\"s\" data-v=\"宽\" id=\"sjs-F7\">宽</td><td data-t=\"s\" data-v=\"厚度\" id=\"sjs-G7\">厚度</td><td data-t=\"s\" data-v=\"面积\" id=\"sjs-H7\">面积</td><td data-t=\"s\" data-v=\"异形\" id=\"sjs-I7\">异形</td><td data-t=\"s\" data-v=\"造型\" id=\"sjs-J7\">造型</td><td data-t=\"s\" data-v=\"左/右/上/下\" id=\"sjs-K7\">左/右/上/下</td><td data-t=\"s\" data-v=\"开门类型\" id=\"sjs-L7\">开门类型</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-M7\">备注</td></tr><tr><td id=\"sjs-A8\"></td><td id=\"sjs-B8\"></td><td id=\"sjs-C8\"></td><td id=\"sjs-D8\"></td><td id=\"sjs-E8\"></td><td id=\"sjs-F8\"></td><td id=\"sjs-G8\"></td><td id=\"sjs-H8\"></td><td id=\"sjs-I8\"></td><td id=\"sjs-J8\"></td><td id=\"sjs-K8\"></td><td id=\"sjs-L8\"></td><td id=\"sjs-M8\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"小计：\" id=\"sjs-A9\">小计：</td><td colspan=\"2\" data-t=\"s\" data-v=\"小计面积表达式\" id=\"sjs-G9\">小计面积表达式</td><td id=\"sjs-I9\"></td><td id=\"sjs-J9\"></td><td id=\"sjs-K9\"></td><td id=\"sjs-L9\"></td><td id=\"sjs-M9\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"合计：\" id=\"sjs-A10\">合计：</td><td colspan=\"2\" data-t=\"s\" data-v=\"合计面积表达式\" id=\"sjs-G10\">合计面积表达式</td><td id=\"sjs-I10\"></td><td id=\"sjs-J10\"></td><td id=\"sjs-K10\"></td><td id=\"sjs-L10\"></td><td id=\"sjs-M10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td><td id=\"sjs-J11\"></td><td id=\"sjs-K11\"></td><td id=\"sjs-L11\"></td><td id=\"sjs-M11\"></td></tr><tr><td id=\"sjs-A12\"></td><td id=\"sjs-B12\"></td><td id=\"sjs-C12\"></td><td id=\"sjs-D12\"></td><td id=\"sjs-E12\"></td><td id=\"sjs-F12\"></td><td id=\"sjs-G12\"></td><td id=\"sjs-H12\"></td><td id=\"sjs-I12\"></td><td id=\"sjs-J12\"></td><td id=\"sjs-K12\"></td><td id=\"sjs-L12\"></td><td id=\"sjs-M12\"></td></tr><tr><td id=\"sjs-A13\"></td><td id=\"sjs-B13\"></td><td id=\"sjs-C13\"></td><td id=\"sjs-D13\"></td><td id=\"sjs-E13\"></td><td id=\"sjs-F13\"></td><td id=\"sjs-G13\"></td><td id=\"sjs-H13\"></td><td id=\"sjs-I13\"></td><td id=\"sjs-J13\"></td><td id=\"sjs-K13\"></td><td id=\"sjs-L13\"></td><td id=\"sjs-M13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td><td id=\"sjs-J14\"></td><td id=\"sjs-K14\"></td><td id=\"sjs-L14\"></td><td id=\"sjs-M14\"></td></tr><tr><td id=\"sjs-A15\"></td><td id=\"sjs-B15\"></td><td id=\"sjs-C15\"></td><td id=\"sjs-D15\"></td><td id=\"sjs-E15\"></td><td id=\"sjs-F15\"></td><td id=\"sjs-G15\"></td><td id=\"sjs-H15\"></td><td id=\"sjs-I15\"></td><td id=\"sjs-J15\"></td><td id=\"sjs-K15\"></td><td id=\"sjs-L15\"></td><td id=\"sjs-M15\"></td></tr><tr><td id=\"sjs-A16\"></td><td id=\"sjs-B16\"></td><td id=\"sjs-C16\"></td><td id=\"sjs-D16\"></td><td id=\"sjs-E16\"></td><td id=\"sjs-F16\"></td><td id=\"sjs-G16\"></td><td id=\"sjs-H16\"></td><td id=\"sjs-I16\"></td><td id=\"sjs-J16\"></td><td id=\"sjs-K16\"></td><td id=\"sjs-L16\"></td><td id=\"sjs-M16\"></td></tr><tr><td id=\"sjs-A17\"></td><td id=\"sjs-B17\"></td><td id=\"sjs-C17\"></td><td id=\"sjs-D17\"></td><td id=\"sjs-E17\"></td><td id=\"sjs-F17\"></td><td id=\"sjs-G17\"></td><td id=\"sjs-H17\"></td><td id=\"sjs-I17\"></td><td id=\"sjs-J17\"></td><td id=\"sjs-K17\"></td><td id=\"sjs-L17\"></td><td id=\"sjs-M17\"></td></tr><tr><td id=\"sjs-A18\"></td><td id=\"sjs-B18\"></td><td id=\"sjs-C18\"></td><td id=\"sjs-D18\"></td><td id=\"sjs-E18\"></td><td id=\"sjs-F18\"></td><td id=\"sjs-G18\"></td><td id=\"sjs-H18\"></td><td id=\"sjs-I18\"></td><td id=\"sjs-J18\"></td><td id=\"sjs-K18\"></td><td id=\"sjs-L18\"></td><td id=\"sjs-M18\"></td></tr><tr><td id=\"sjs-A19\"></td><td id=\"sjs-B19\"></td><td id=\"sjs-C19\"></td><td id=\"sjs-D19\"></td><td id=\"sjs-E19\"></td><td id=\"sjs-F19\"></td><td id=\"sjs-G19\"></td><td id=\"sjs-H19\"></td><td id=\"sjs-I19\"></td><td id=\"sjs-J19\"></td><td id=\"sjs-K19\"></td><td id=\"sjs-L19\"></td><td id=\"sjs-M19\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A20\"></td><td colspan=\"2\" id=\"sjs-G20\"></td><td colspan=\"5\" id=\"sjs-I20\"></td></tr><tr><td colspan=\"2\" id=\"sjs-A21\"></td><td colspan=\"3\" id=\"sjs-C21\"></td><td colspan=\"3\" id=\"sjs-F21\"></td><td colspan=\"3\" id=\"sjs-I21\"></td><td id=\"sjs-L21\"></td><td id=\"sjs-M21\"></td></tr><tr><td id=\"sjs-A22\"></td><td id=\"sjs-B22\"></td><td id=\"sjs-C22\"></td><td id=\"sjs-D22\"></td><td id=\"sjs-E22\"></td><td id=\"sjs-F22\"></td><td id=\"sjs-G22\"></td><td id=\"sjs-H22\"></td><td id=\"sjs-I22\"></td><td id=\"sjs-J22\"></td><td id=\"sjs-K22\"></td><td id=\"sjs-L22\"></td><td id=\"sjs-M22\"></td></tr><tr><td id=\"sjs-A23\"></td><td id=\"sjs-B23\"></td><td id=\"sjs-C23\"></td><td id=\"sjs-D23\"></td><td id=\"sjs-E23\"></td><td id=\"sjs-F23\"></td><td id=\"sjs-G23\"></td><td id=\"sjs-H23\"></td><td id=\"sjs-I23\"></td><td id=\"sjs-J23\"></td><td id=\"sjs-K23\"></td><td id=\"sjs-L23\"></td><td id=\"sjs-M23\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A24\"></td><td colspan=\"2\" id=\"sjs-G24\"></td><td colspan=\"5\" id=\"sjs-I24\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A25\"></td><td colspan=\"2\" id=\"sjs-G25\"></td><td colspan=\"5\" id=\"sjs-I25\"></td></tr></table></body></html>");
                map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                break;
            case "板材汇总-按房间-模板.xlsx":
                map.put("plateSummary", plateMapper.selectPlateGoodsListSummary(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"9\" data-t=\"s\" data-v=\"板材汇总单\" id=\"sjs-A1\">板材汇总单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\"><span style=\"font-size:10pt;\"><b>订单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B2\"></td><td data-t=\"s\" data-v=\"自定单号:\" id=\"sjs-C2\"><span style=\"font-size:10pt;\"><b>自定单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D2\"></td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td id=\"sjs-F2\"></td><td data-t=\"s\" data-v=\"订单日期：\" id=\"sjs-G2\"><span style=\"font-size:10pt;\"><b>订单日期</b></span><span style=\"font-size:10pt;\"><b>：</b></span></td><td id=\"sjs-H2\"></td><td id=\"sjs-I2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\"><span style=\"font-size:10pt;\"><b>客户</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B3\"></td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\"><span style=\"font-size:10pt;\"><b>收货电话</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D3\"></td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\"><span style=\"font-size:10pt;\"><b>收货地址</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-F3\"></td><td data-t=\"s\" data-v=\"收货日期：\" id=\"sjs-G3\"><span style=\"font-size:10pt;\"><b>收货日期：</b></span></td><td id=\"sjs-H3\"></td><td id=\"sjs-I3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td id=\"sjs-B4\"></td><td id=\"sjs-C4\"></td><td id=\"sjs-D4\"></td><td id=\"sjs-E4\"></td><td id=\"sjs-F4\"></td><td id=\"sjs-G4\"></td><td id=\"sjs-H4\"></td><td id=\"sjs-I4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td></tr><tr><td data-t=\"s\" data-v=\"房间名称数据源\" id=\"sjs-A6\">房间名称数据源</td><td colspan=\"2\" data-t=\"s\" data-v=\"柜体数据源\" id=\"sjs-B6\">柜体数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"列表条数表达式\" id=\"sjs-D6\">列表条数表达式</td><td id=\"sjs-G6\"></td><td id=\"sjs-H6\"></td><td id=\"sjs-I6\"></td></tr><tr><td data-t=\"s\" data-v=\"板名称\" id=\"sjs-A7\">板名称</td><td data-t=\"s\" data-v=\"材料\" id=\"sjs-B7\">材料</td><td data-t=\"s\" data-v=\"颜色\" id=\"sjs-C7\">颜色</td><td data-t=\"s\" data-v=\"长\" id=\"sjs-D7\">长</td><td data-t=\"s\" data-v=\"宽\" id=\"sjs-E7\">宽</td><td data-t=\"s\" data-v=\"厚度\" id=\"sjs-F7\">厚度</td><td data-t=\"s\" data-v=\"数量\" id=\"sjs-G7\">数量</td><td data-t=\"s\" data-v=\"面积\" id=\"sjs-H7\">面积</td><td data-t=\"s\" data-v=\"开门类型\" id=\"sjs-I7\">开门类型</td></tr><tr><td id=\"sjs-A8\"></td><td id=\"sjs-B8\"></td><td id=\"sjs-C8\"></td><td id=\"sjs-D8\"></td><td id=\"sjs-E8\"></td><td id=\"sjs-F8\"></td><td id=\"sjs-G8\"></td><td id=\"sjs-H8\"></td><td id=\"sjs-I8\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"小计：\" id=\"sjs-A9\">小计：</td><td data-t=\"s\" data-v=\"数量表达式\" id=\"sjs-G9\">数量表达式</td><td data-t=\"s\" data-v=\"面积表达式\" id=\"sjs-H9\">面积表达式</td><td id=\"sjs-I9\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"合计：\" id=\"sjs-A10\">合计：</td><td data-t=\"s\" data-v=\"数量表达式\" id=\"sjs-G10\">数量表达式</td><td data-t=\"s\" data-v=\"面积表达式\" id=\"sjs-H10\">面积表达式</td><td id=\"sjs-I10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A12\"></td><td id=\"sjs-G12\"></td><td id=\"sjs-H12\"></td><td id=\"sjs-I12\"></td></tr><tr><td id=\"sjs-A13\"></td><td colspan=\"2\" id=\"sjs-B13\"></td><td colspan=\"3\" id=\"sjs-D13\"></td><td id=\"sjs-G13\"></td><td id=\"sjs-H13\"></td><td id=\"sjs-I13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td></tr><tr><td id=\"sjs-A15\"></td><td id=\"sjs-B15\"></td><td id=\"sjs-C15\"></td><td id=\"sjs-D15\"></td><td id=\"sjs-E15\"></td><td id=\"sjs-F15\"></td><td id=\"sjs-G15\"></td><td id=\"sjs-H15\"></td><td id=\"sjs-I15\"></td></tr><tr><td id=\"sjs-A16\"></td><td id=\"sjs-B16\"></td><td id=\"sjs-C16\"></td><td id=\"sjs-D16\"></td><td id=\"sjs-E16\"></td><td id=\"sjs-F16\"></td><td id=\"sjs-G16\"></td><td id=\"sjs-H16\"></td><td id=\"sjs-I16\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A17\"></td><td id=\"sjs-G17\"></td><td colspan=\"2\" id=\"sjs-H17\"></td></tr><tr><td id=\"sjs-A18\"></td><td colspan=\"2\" id=\"sjs-B18\"></td><td colspan=\"3\" id=\"sjs-D18\"></td><td id=\"sjs-G18\"></td><td id=\"sjs-H18\"></td><td id=\"sjs-I18\"></td></tr><tr><td id=\"sjs-A19\"></td><td id=\"sjs-B19\"></td><td id=\"sjs-C19\"></td><td id=\"sjs-D19\"></td><td id=\"sjs-E19\"></td><td id=\"sjs-F19\"></td><td id=\"sjs-G19\"></td><td id=\"sjs-H19\"></td><td id=\"sjs-I19\"></td></tr><tr><td id=\"sjs-A20\"></td><td id=\"sjs-B20\"></td><td id=\"sjs-C20\"></td><td id=\"sjs-D20\"></td><td id=\"sjs-E20\"></td><td id=\"sjs-F20\"></td><td id=\"sjs-G20\"></td><td id=\"sjs-H20\"></td><td id=\"sjs-I20\"></td></tr><tr><td id=\"sjs-A21\"></td><td id=\"sjs-B21\"></td><td id=\"sjs-C21\"></td><td id=\"sjs-D21\"></td><td id=\"sjs-E21\"></td><td id=\"sjs-F21\"></td><td id=\"sjs-G21\"></td><td id=\"sjs-H21\"></td><td id=\"sjs-I21\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A22\"></td><td id=\"sjs-G22\"></td><td colspan=\"2\" id=\"sjs-H22\"></td></tr><tr><td id=\"sjs-A23\"></td><td colspan=\"2\" id=\"sjs-B23\"></td><td colspan=\"3\" id=\"sjs-D23\"></td><td id=\"sjs-G23\"></td><td id=\"sjs-H23\"></td><td id=\"sjs-I23\"></td></tr><tr><td id=\"sjs-A24\"></td><td id=\"sjs-B24\"></td><td id=\"sjs-C24\"></td><td id=\"sjs-D24\"></td><td id=\"sjs-E24\"></td><td id=\"sjs-F24\"></td><td id=\"sjs-G24\"></td><td id=\"sjs-H24\"></td><td id=\"sjs-I24\"></td></tr><tr><td id=\"sjs-A25\"></td><td id=\"sjs-B25\"></td><td id=\"sjs-C25\"></td><td id=\"sjs-D25\"></td><td id=\"sjs-E25\"></td><td id=\"sjs-F25\"></td><td id=\"sjs-G25\"></td><td id=\"sjs-H25\"></td><td id=\"sjs-I25\"></td></tr><tr><td id=\"sjs-A26\"></td><td id=\"sjs-B26\"></td><td id=\"sjs-C26\"></td><td id=\"sjs-D26\"></td><td id=\"sjs-E26\"></td><td id=\"sjs-F26\"></td><td id=\"sjs-G26\"></td><td id=\"sjs-H26\"></td><td id=\"sjs-I26\"></td></tr><tr><td id=\"sjs-A27\"></td><td id=\"sjs-B27\"></td><td id=\"sjs-C27\"></td><td id=\"sjs-D27\"></td><td id=\"sjs-E27\"></td><td id=\"sjs-F27\"></td><td id=\"sjs-G27\"></td><td id=\"sjs-H27\"></td><td id=\"sjs-I27\"></td></tr><tr><td id=\"sjs-A28\"></td><td id=\"sjs-B28\"></td><td id=\"sjs-C28\"></td><td id=\"sjs-D28\"></td><td id=\"sjs-E28\"></td><td id=\"sjs-F28\"></td><td id=\"sjs-G28\"></td><td id=\"sjs-H28\"></td><td id=\"sjs-I28\"></td></tr><tr><td id=\"sjs-A29\"></td><td id=\"sjs-B29\"></td><td id=\"sjs-C29\"></td><td id=\"sjs-D29\"></td><td id=\"sjs-E29\"></td><td id=\"sjs-F29\"></td><td id=\"sjs-G29\"></td><td id=\"sjs-H29\"></td><td id=\"sjs-I29\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A30\"></td><td id=\"sjs-G30\"></td><td colspan=\"2\" id=\"sjs-H30\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A31\"></td><td id=\"sjs-G31\"></td><td colspan=\"2\" id=\"sjs-H31\"></td></tr></table></body></html>");
                map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                break;
            case "板材汇总-按板材-模板.xlsx":
                map.put("plateSummary", plateMapper.selectPlateGoodsListSummary(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"11\" data-t=\"s\" data-v=\"板材汇总单\" id=\"sjs-A1\">板材汇总单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\">订单号:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B2\">数据源</td><td data-t=\"s\" data-v=\"自定义单号:\" id=\"sjs-C2\">自定义单号:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D2\">数据源</td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F2\">数据源</td><td data-t=\"s\" data-v=\"订单日期:\" id=\"sjs-G2\">订单日期:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H2\">数据源</td><td id=\"sjs-I2\"></td><td id=\"sjs-J2\"></td><td id=\"sjs-K2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\">客户:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B3\">数据源</td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\">收货电话:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D3\">数据源</td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\">收货地址:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F3\">数据源</td><td data-t=\"s\" data-v=\"收货日期:\" id=\"sjs-G3\">收货日期:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H3\">数据源</td><td id=\"sjs-I3\"></td><td id=\"sjs-J3\"></td><td id=\"sjs-K3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td colspan=\"7\" data-t=\"s\" data-v=\"数据源\" id=\"sjs-B4\">数据源</td><td id=\"sjs-I4\"></td><td id=\"sjs-J4\"></td><td id=\"sjs-K4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td><td id=\"sjs-J5\"></td><td id=\"sjs-K5\"></td></tr><tr><td colspan=\"2\" data-t=\"s\" data-v=\"板材名称数据源\" id=\"sjs-A6\">板材名称数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"板材颜色数据源\" id=\"sjs-C6\">板材颜色数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"板材厚度数据源\" id=\"sjs-F6\">板材厚度数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"列表条数表达式\" id=\"sjs-I6\">列表条数表达式</td></tr><tr><td data-t=\"s\" data-v=\"房名\" id=\"sjs-A7\">房名</td><td data-t=\"s\" data-v=\"柜名\" id=\"sjs-B7\">柜名</td><td data-t=\"s\" data-v=\"板名称\" id=\"sjs-C7\">板名称</td><td data-t=\"s\" data-v=\"长\" id=\"sjs-D7\">长</td><td data-t=\"s\" data-v=\"宽\" id=\"sjs-E7\">宽</td><td data-t=\"s\" data-v=\"数量\" id=\"sjs-F7\">数量</td><td data-t=\"s\" data-v=\"面积\" id=\"sjs-G7\">面积</td><td data-t=\"s\" data-v=\"开门类型\" id=\"sjs-H7\">开门类型</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-I7\">备注</td><td id=\"sjs-J7\"></td><td id=\"sjs-K7\"></td></tr><tr><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-A8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-C8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-E8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-G8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-I8\">数据源</td><td id=\"sjs-J8\"></td><td id=\"sjs-K8\"></td></tr><tr><td colspan=\"5\" data-t=\"s\" data-v=\"小计：\" id=\"sjs-A9\">小计：</td><td data-t=\"s\" data-v=\"数量表达式\" id=\"sjs-F9\">数量表达式</td><td data-t=\"s\" data-v=\"面积表达式\" id=\"sjs-G9\">面积表达式</td><td id=\"sjs-H9\"></td><td id=\"sjs-I9\"></td><td id=\"sjs-J9\"></td><td id=\"sjs-K9\"></td></tr><tr><td colspan=\"5\" data-t=\"s\" data-v=\"合计：\" id=\"sjs-A10\">合计：</td><td data-t=\"s\" data-v=\"数量表达式\" id=\"sjs-F10\">数量表达式</td><td data-t=\"s\" data-v=\"面积表达式\" id=\"sjs-G10\">面积表达式</td><td id=\"sjs-H10\"></td><td id=\"sjs-I10\"></td><td id=\"sjs-J10\"></td><td id=\"sjs-K10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td><td id=\"sjs-J11\"></td><td id=\"sjs-K11\"></td></tr><tr><td id=\"sjs-A12\"></td><td id=\"sjs-B12\"></td><td id=\"sjs-C12\"></td><td id=\"sjs-D12\"></td><td id=\"sjs-E12\"></td><td id=\"sjs-F12\"></td><td id=\"sjs-G12\"></td><td id=\"sjs-H12\"></td><td id=\"sjs-I12\"></td><td id=\"sjs-J12\"></td><td id=\"sjs-K12\"></td></tr><tr><td id=\"sjs-A13\"></td><td id=\"sjs-B13\"></td><td id=\"sjs-C13\"></td><td id=\"sjs-D13\"></td><td id=\"sjs-E13\"></td><td id=\"sjs-F13\"></td><td id=\"sjs-G13\"></td><td id=\"sjs-H13\"></td><td id=\"sjs-I13\"></td><td id=\"sjs-J13\"></td><td id=\"sjs-K13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td><td id=\"sjs-J14\"></td><td id=\"sjs-K14\"></td></tr><tr><td id=\"sjs-A15\"></td><td id=\"sjs-B15\"></td><td id=\"sjs-C15\"></td><td colspan=\"2\" id=\"sjs-D15\"></td><td id=\"sjs-F15\"></td><td id=\"sjs-G15\"></td><td id=\"sjs-H15\"></td><td id=\"sjs-I15\"></td><td id=\"sjs-J15\"></td><td id=\"sjs-K15\"></td></tr><tr><td id=\"sjs-A16\"></td><td id=\"sjs-B16\"></td><td id=\"sjs-C16\"></td><td id=\"sjs-D16\"></td><td id=\"sjs-E16\"></td><td id=\"sjs-F16\"></td><td id=\"sjs-G16\"></td><td id=\"sjs-H16\"></td><td id=\"sjs-I16\"></td><td id=\"sjs-J16\"></td><td id=\"sjs-K16\"></td></tr><tr><td id=\"sjs-A17\"></td><td id=\"sjs-B17\"></td><td id=\"sjs-C17\"></td><td id=\"sjs-D17\"></td><td id=\"sjs-E17\"></td><td id=\"sjs-F17\"></td><td id=\"sjs-G17\"></td><td id=\"sjs-H17\"></td><td id=\"sjs-I17\"></td><td id=\"sjs-J17\"></td><td id=\"sjs-K17\"></td></tr><tr><td id=\"sjs-A18\"></td><td id=\"sjs-B18\"></td><td id=\"sjs-C18\"></td><td id=\"sjs-D18\"></td><td id=\"sjs-E18\"></td><td id=\"sjs-F18\"></td><td id=\"sjs-G18\"></td><td id=\"sjs-H18\"></td><td id=\"sjs-I18\"></td><td id=\"sjs-J18\"></td><td id=\"sjs-K18\"></td></tr><tr><td id=\"sjs-A19\"></td><td id=\"sjs-B19\"></td><td id=\"sjs-C19\"></td><td id=\"sjs-D19\"></td><td id=\"sjs-E19\"></td><td id=\"sjs-F19\"></td><td id=\"sjs-G19\"></td><td id=\"sjs-H19\"></td><td id=\"sjs-I19\"></td><td id=\"sjs-J19\"></td><td id=\"sjs-K19\"></td></tr><tr><td colspan=\"5\" id=\"sjs-A20\"></td><td id=\"sjs-F20\"></td><td colspan=\"2\" id=\"sjs-G20\"></td><td colspan=\"2\" id=\"sjs-I20\"></td><td id=\"sjs-K20\"></td></tr><tr><td colspan=\"2\" id=\"sjs-A21\"></td><td colspan=\"2\" id=\"sjs-C21\"></td><td colspan=\"4\" id=\"sjs-E21\"></td><td colspan=\"3\" id=\"sjs-I21\"></td></tr><tr><td id=\"sjs-A22\"></td><td id=\"sjs-B22\"></td><td id=\"sjs-C22\"></td><td id=\"sjs-D22\"></td><td id=\"sjs-E22\"></td><td id=\"sjs-F22\"></td><td id=\"sjs-G22\"></td><td id=\"sjs-H22\"></td><td id=\"sjs-I22\"></td><td id=\"sjs-J22\"></td><td id=\"sjs-K22\"></td></tr><tr><td id=\"sjs-A23\"></td><td id=\"sjs-B23\"></td><td id=\"sjs-C23\"></td><td id=\"sjs-D23\"></td><td id=\"sjs-E23\"></td><td id=\"sjs-F23\"></td><td id=\"sjs-G23\"></td><td id=\"sjs-H23\"></td><td id=\"sjs-I23\"></td><td id=\"sjs-J23\"></td><td id=\"sjs-K23\"></td></tr><tr><td id=\"sjs-A24\"></td><td id=\"sjs-B24\"></td><td id=\"sjs-C24\"></td><td id=\"sjs-D24\"></td><td id=\"sjs-E24\"></td><td id=\"sjs-F24\"></td><td id=\"sjs-G24\"></td><td id=\"sjs-H24\"></td><td id=\"sjs-I24\"></td><td id=\"sjs-J24\"></td><td id=\"sjs-K24\"></td></tr><tr><td id=\"sjs-A25\"></td><td id=\"sjs-B25\"></td><td id=\"sjs-C25\"></td><td id=\"sjs-D25\"></td><td id=\"sjs-E25\"></td><td id=\"sjs-F25\"></td><td id=\"sjs-G25\"></td><td id=\"sjs-H25\"></td><td id=\"sjs-I25\"></td><td id=\"sjs-J25\"></td><td id=\"sjs-K25\"></td></tr></table></body></html>");
                map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                break;
            default:
                throw new ServiceException(FILE_TYPE_ERR);
        }
        return map;
    }

    // 根据ype 与 orderId获取相关信息
    public Map<String, Object> getDataByOrderIdAndTypeDetail(OrderDO orderDO, String type, Integer deleted) {
        String tableKey = "table";
        String plateCountKey = "plateCount";
        Map<String, Object> map = new HashMap<>();
        map.put("orderDO", orderDO);
        switch (type) {
            case "配件明细1-模板.xlsx":// 配件明细
                // 以房间柜体为维度获取配件明细
                map.put("partsListDetail", getOrderGoods(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"10\" data-t=\"s\" data-v=\"配件明细单\" id=\"sjs-A1\">配件明细单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\">订单号:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B2\">数据源</td><td data-t=\"s\" data-v=\"自定义单号:\" id=\"sjs-C2\">自定义单号:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D2\">数据源</td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F2\">数据源</td><td data-t=\"s\" data-v=\"订单日期:\" id=\"sjs-G2\">订单日期:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H2\">数据源</td><td id=\"sjs-I2\"></td><td id=\"sjs-J2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\">客户:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B3\">数据源</td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\">收货电话:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D3\">数据源</td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\">收货地址:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F3\">数据源</td><td data-t=\"s\" data-v=\"收货日期:\" id=\"sjs-G3\">收货日期:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H3\">数据源</td><td id=\"sjs-I3\"></td><td id=\"sjs-J3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td colspan=\"7\" data-t=\"s\" data-v=\"数据源\" id=\"sjs-B4\">数据源</td><td id=\"sjs-I4\"></td><td id=\"sjs-J4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td><td id=\"sjs-J5\"></td></tr><tr><td colspan=\"3\" data-t=\"s\" data-v=\"房间名数据源\" id=\"sjs-A6\">房间名数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"柜体名表数据源\" id=\"sjs-D6\">柜体名表数据源</td><td colspan=\"4\" id=\"sjs-G6\"></td></tr><tr><td data-t=\"s\" data-v=\"名称\" id=\"sjs-A7\">名称</td><td data-t=\"s\" data-v=\"品牌\" id=\"sjs-B7\">品牌</td><td data-t=\"s\" data-v=\"厂家\" id=\"sjs-C7\">厂家</td><td data-t=\"s\" data-v=\"型号\" id=\"sjs-D7\">型号</td><td data-t=\"s\" data-v=\"规格\" id=\"sjs-E7\">规格</td><td data-t=\"s\" data-v=\"数量\" id=\"sjs-F7\">数量</td><td data-t=\"s\" data-v=\"单位\" id=\"sjs-G7\">单位</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-H7\">备注</td><td id=\"sjs-I7\"></td><td id=\"sjs-J7\"></td></tr><tr><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-A8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-C8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-E8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-G8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H8\">数据源</td><td id=\"sjs-I8\"></td><td id=\"sjs-J8\"></td></tr><tr><td id=\"sjs-A9\"></td><td id=\"sjs-B9\"></td><td id=\"sjs-C9\"></td><td id=\"sjs-D9\"></td><td id=\"sjs-E9\"></td><td id=\"sjs-F9\"></td><td id=\"sjs-G9\"></td><td id=\"sjs-H9\"></td><td id=\"sjs-I9\"></td><td id=\"sjs-J9\"></td></tr><tr><td id=\"sjs-A10\"></td><td id=\"sjs-B10\"></td><td id=\"sjs-C10\"></td><td id=\"sjs-D10\"></td><td id=\"sjs-E10\"></td><td id=\"sjs-F10\"></td><td id=\"sjs-G10\"></td><td id=\"sjs-H10\"></td><td id=\"sjs-I10\"></td><td id=\"sjs-J10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td><td id=\"sjs-J11\"></td></tr><tr><td colspan=\"3\" id=\"sjs-A12\"></td><td colspan=\"3\" id=\"sjs-D12\"></td><td colspan=\"4\" id=\"sjs-G12\"></td></tr><tr><td id=\"sjs-A13\"></td><td id=\"sjs-B13\"></td><td id=\"sjs-C13\"></td><td id=\"sjs-D13\"></td><td id=\"sjs-E13\"></td><td id=\"sjs-F13\"></td><td id=\"sjs-G13\"></td><td id=\"sjs-H13\"></td><td id=\"sjs-I13\"></td><td id=\"sjs-J13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td><td id=\"sjs-J14\"></td></tr><tr><td colspan=\"8\" id=\"sjs-A15\"></td><td id=\"sjs-I15\"></td><td id=\"sjs-J15\"></td></tr><tr><td colspan=\"3\" id=\"sjs-A16\"></td><td colspan=\"3\" id=\"sjs-D16\"></td><td colspan=\"4\" id=\"sjs-G16\"></td></tr><tr><td id=\"sjs-A17\"></td><td id=\"sjs-B17\"></td><td id=\"sjs-C17\"></td><td id=\"sjs-D17\"></td><td id=\"sjs-E17\"></td><td id=\"sjs-F17\"></td><td id=\"sjs-G17\"></td><td id=\"sjs-H17\"></td><td id=\"sjs-I17\"></td><td id=\"sjs-J17\"></td></tr><tr><td id=\"sjs-A18\"></td><td id=\"sjs-B18\"></td><td id=\"sjs-C18\"></td><td id=\"sjs-D18\"></td><td id=\"sjs-E18\"></td><td id=\"sjs-F18\"></td><td id=\"sjs-G18\"></td><td id=\"sjs-H18\"></td><td id=\"sjs-I18\"></td><td id=\"sjs-J18\"></td></tr><tr><td colspan=\"8\" id=\"sjs-A19\"></td><td id=\"sjs-I19\"></td><td id=\"sjs-J19\"></td></tr><tr><td colspan=\"3\" id=\"sjs-A20\"></td><td colspan=\"3\" id=\"sjs-D20\"></td><td colspan=\"4\" id=\"sjs-G20\"></td></tr><tr><td id=\"sjs-A21\"></td><td id=\"sjs-B21\"></td><td id=\"sjs-C21\"></td><td id=\"sjs-D21\"></td><td id=\"sjs-E21\"></td><td id=\"sjs-F21\"></td><td id=\"sjs-G21\"></td><td id=\"sjs-H21\"></td><td id=\"sjs-I21\"></td><td id=\"sjs-J21\"></td></tr><tr><td id=\"sjs-A22\"></td><td id=\"sjs-B22\"></td><td id=\"sjs-C22\"></td><td id=\"sjs-D22\"></td><td id=\"sjs-E22\"></td><td id=\"sjs-F22\"></td><td id=\"sjs-G22\"></td><td id=\"sjs-H22\"></td><td id=\"sjs-I22\"></td><td id=\"sjs-J22\"></td></tr><tr><td id=\"sjs-A23\"></td><td id=\"sjs-B23\"></td><td id=\"sjs-C23\"></td><td id=\"sjs-D23\"></td><td id=\"sjs-E23\"></td><td id=\"sjs-F23\"></td><td id=\"sjs-G23\"></td><td id=\"sjs-H23\"></td><td id=\"sjs-I23\"></td><td id=\"sjs-J23\"></td></tr><tr><td id=\"sjs-A24\"></td><td id=\"sjs-B24\"></td><td id=\"sjs-C24\"></td><td id=\"sjs-D24\"></td><td id=\"sjs-E24\"></td><td id=\"sjs-F24\"></td><td id=\"sjs-G24\"></td><td id=\"sjs-H24\"></td><td id=\"sjs-I24\"></td><td id=\"sjs-J24\"></td></tr><tr><td id=\"sjs-A25\"></td><td id=\"sjs-B25\"></td><td id=\"sjs-C25\"></td><td id=\"sjs-D25\"></td><td id=\"sjs-E25\"></td><td id=\"sjs-F25\"></td><td id=\"sjs-G25\"></td><td id=\"sjs-H25\"></td><td id=\"sjs-I25\"></td><td id=\"sjs-J25\"></td></tr><tr><td colspan=\"8\" id=\"sjs-A26\"></td><td id=\"sjs-I26\"></td><td id=\"sjs-J26\"></td></tr><tr><td colspan=\"8\" id=\"sjs-A27\"></td><td id=\"sjs-I27\"></td><td id=\"sjs-J27\"></td></tr></table></body></html>");
                break;
            case "配件汇总1-模板.xlsx":// 配件汇总
                map.put("partsSummary", orderPartsMapper.selectPartAll(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"7\" data-t=\"s\" data-v=\"配件汇总单\" id=\"sjs-A1\">配件汇总单</td><td id=\"sjs-H1\"></td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\"><span style=\"font-size:10pt;\"><b>订单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B2\"></td><td data-t=\"s\" data-v=\"自定单号:\" id=\"sjs-C2\"><span style=\"font-size:10pt;\"><b>自定单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D2\"></td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td id=\"sjs-F2\"></td><td data-t=\"s\" data-v=\"订单日期：\" id=\"sjs-G2\"><span style=\"font-size:10pt;\"><b>订单日期</b></span><span style=\"font-size:10pt;\"><b>：</b></span></td><td id=\"sjs-H2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\"><span style=\"font-size:10pt;\"><b>客户</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B3\"></td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\"><span style=\"font-size:10pt;\"><b>收货电话</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D3\"></td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\"><span style=\"font-size:10pt;\"><b>收货地址</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-F3\"></td><td data-t=\"s\" data-v=\"收货日期：\" id=\"sjs-G3\"><span style=\"font-size:10pt;\"><b>收货日期：</b></span></td><td id=\"sjs-H3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td id=\"sjs-B4\"></td><td id=\"sjs-C4\"></td><td id=\"sjs-D4\"></td><td id=\"sjs-E4\"></td><td id=\"sjs-F4\"></td><td id=\"sjs-G4\"></td><td id=\"sjs-H4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td></tr><tr><td data-t=\"s\" data-v=\"名称\" id=\"sjs-A6\">名称</td><td data-t=\"s\" data-v=\"型号\" id=\"sjs-B6\">型号</td><td data-t=\"s\" data-v=\"规格\" id=\"sjs-C6\">规格</td><td data-t=\"s\" data-v=\"数量\" id=\"sjs-D6\">数量</td><td data-t=\"s\" data-v=\"单位\" id=\"sjs-E6\">单位</td><td data-t=\"s\" data-v=\"品牌\" id=\"sjs-F6\">品牌</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-G6\">备注</td><td id=\"sjs-H6\"></td></tr><tr><td id=\"sjs-A7\"></td><td id=\"sjs-B7\"></td><td id=\"sjs-C7\"></td><td id=\"sjs-D7\"></td><td id=\"sjs-E7\"></td><td id=\"sjs-F7\"></td><td id=\"sjs-G7\"></td><td id=\"sjs-H7\"></td></tr><tr><td id=\"sjs-A8\"></td><td id=\"sjs-B8\"></td><td id=\"sjs-C8\"></td><td id=\"sjs-D8\"></td><td id=\"sjs-E8\"></td><td id=\"sjs-F8\"></td><td id=\"sjs-G8\"></td><td id=\"sjs-H8\"></td></tr><tr><td id=\"sjs-A9\"></td><td id=\"sjs-B9\"></td><td id=\"sjs-C9\"></td><td id=\"sjs-D9\"></td><td id=\"sjs-E9\"></td><td id=\"sjs-F9\"></td><td id=\"sjs-G9\"></td><td id=\"sjs-H9\"></td></tr><tr><td id=\"sjs-A10\"></td><td id=\"sjs-B10\"></td><td id=\"sjs-C10\"></td><td id=\"sjs-D10\"></td><td id=\"sjs-E10\"></td><td id=\"sjs-F10\"></td><td id=\"sjs-G10\"></td><td id=\"sjs-H10\"></td></tr></table></body></html>");
                break;
            case "板材明细-按房间-模板.xlsx":
                map.put("plateListDetail", getOrderBody(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"13\" data-t=\"s\" data-v=\"板材明细单\" id=\"sjs-A1\">板材明细单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\"><span style=\"font-size:10pt;\"><b>订单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B2\"></td><td data-t=\"s\" data-v=\"自定单号:\" id=\"sjs-C2\"><span style=\"font-size:10pt;\"><b>自定单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D2\"></td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td id=\"sjs-F2\"></td><td data-t=\"s\" data-v=\"订单日期：\" id=\"sjs-G2\"><span style=\"font-size:10pt;\"><b>订单日期</b></span><span style=\"font-size:10pt;\"><b>：</b></span></td><td id=\"sjs-H2\"></td><td id=\"sjs-I2\"></td><td id=\"sjs-J2\"></td><td id=\"sjs-K2\"></td><td id=\"sjs-L2\"></td><td id=\"sjs-M2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\"><span style=\"font-size:10pt;\"><b>客户</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B3\"></td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\"><span style=\"font-size:10pt;\"><b>收货电话</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D3\"></td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\"><span style=\"font-size:10pt;\"><b>收货地址</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-F3\"></td><td data-t=\"s\" data-v=\"收货日期：\" id=\"sjs-G3\"><span style=\"font-size:10pt;\"><b>收货日期：</b></span></td><td id=\"sjs-H3\"></td><td id=\"sjs-I3\"></td><td id=\"sjs-J3\"></td><td id=\"sjs-K3\"></td><td id=\"sjs-L3\"></td><td id=\"sjs-M3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td id=\"sjs-B4\"></td><td id=\"sjs-C4\"></td><td id=\"sjs-D4\"></td><td id=\"sjs-E4\"></td><td id=\"sjs-F4\"></td><td id=\"sjs-G4\"></td><td id=\"sjs-H4\"></td><td id=\"sjs-I4\"></td><td id=\"sjs-J4\"></td><td id=\"sjs-K4\"></td><td id=\"sjs-L4\"></td><td id=\"sjs-M4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td><td id=\"sjs-J5\"></td><td id=\"sjs-K5\"></td><td id=\"sjs-L5\"></td><td id=\"sjs-M5\"></td></tr><tr><td data-t=\"s\" data-v=\"房间名数据源\" id=\"sjs-A6\">房间名数据源</td><td colspan=\"2\" data-t=\"s\" data-v=\"柜体数据源\" id=\"sjs-B6\">柜体数据源</td><td colspan=\"3\" id=\"sjs-D6\"></td><td colspan=\"3\" data-t=\"s\" data-v=\"列表条数表达式\" id=\"sjs-G6\">列表条数表达式</td><td id=\"sjs-J6\"></td><td id=\"sjs-K6\"></td><td id=\"sjs-L6\"></td><td id=\"sjs-M6\"></td></tr><tr><td data-t=\"s\" data-v=\"板编号\" id=\"sjs-A7\">板编号</td><td data-t=\"s\" data-v=\"板名称\" id=\"sjs-B7\">板名称</td><td data-t=\"s\" data-v=\"材料\" id=\"sjs-C7\">材料</td><td data-t=\"s\" data-v=\"颜色\" id=\"sjs-D7\">颜色</td><td data-t=\"s\" data-v=\"长\" id=\"sjs-E7\">长</td><td data-t=\"s\" data-v=\"宽\" id=\"sjs-F7\">宽</td><td data-t=\"s\" data-v=\"厚度\" id=\"sjs-G7\">厚度</td><td data-t=\"s\" data-v=\"面积\" id=\"sjs-H7\">面积</td><td data-t=\"s\" data-v=\"异形\" id=\"sjs-I7\">异形</td><td data-t=\"s\" data-v=\"造型\" id=\"sjs-J7\">造型</td><td data-t=\"s\" data-v=\"左/右/上/下\" id=\"sjs-K7\">左/右/上/下</td><td data-t=\"s\" data-v=\"开门类型\" id=\"sjs-L7\">开门类型</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-M7\">备注</td></tr><tr><td id=\"sjs-A8\"></td><td id=\"sjs-B8\"></td><td id=\"sjs-C8\"></td><td id=\"sjs-D8\"></td><td id=\"sjs-E8\"></td><td id=\"sjs-F8\"></td><td id=\"sjs-G8\"></td><td id=\"sjs-H8\"></td><td id=\"sjs-I8\"></td><td id=\"sjs-J8\"></td><td id=\"sjs-K8\"></td><td id=\"sjs-L8\"></td><td id=\"sjs-M8\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"小计：\" id=\"sjs-A9\">小计：</td><td colspan=\"2\" data-t=\"s\" data-v=\"小计面积表达式\" id=\"sjs-G9\">小计面积表达式</td><td id=\"sjs-I9\"></td><td id=\"sjs-J9\"></td><td id=\"sjs-K9\"></td><td id=\"sjs-L9\"></td><td id=\"sjs-M9\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"合计：\" id=\"sjs-A10\">合计：</td><td colspan=\"2\" data-t=\"s\" data-v=\"合计面积表达式\" id=\"sjs-G10\">合计面积表达式</td><td id=\"sjs-I10\"></td><td id=\"sjs-J10\"></td><td id=\"sjs-K10\"></td><td id=\"sjs-L10\"></td><td id=\"sjs-M10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td><td id=\"sjs-J11\"></td><td id=\"sjs-K11\"></td><td id=\"sjs-L11\"></td><td id=\"sjs-M11\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A12\"></td><td colspan=\"2\" id=\"sjs-G12\"></td><td colspan=\"5\" id=\"sjs-I12\"></td></tr><tr><td id=\"sjs-A13\"></td><td colspan=\"2\" id=\"sjs-B13\"></td><td colspan=\"3\" id=\"sjs-D13\"></td><td colspan=\"3\" id=\"sjs-G13\"></td><td id=\"sjs-J13\"></td><td id=\"sjs-K13\"></td><td id=\"sjs-L13\"></td><td id=\"sjs-M13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td><td id=\"sjs-J14\"></td><td id=\"sjs-K14\"></td><td id=\"sjs-L14\"></td><td id=\"sjs-M14\"></td></tr><tr><td id=\"sjs-A15\"></td><td id=\"sjs-B15\"></td><td id=\"sjs-C15\"></td><td id=\"sjs-D15\"></td><td id=\"sjs-E15\"></td><td id=\"sjs-F15\"></td><td id=\"sjs-G15\"></td><td id=\"sjs-H15\"></td><td id=\"sjs-I15\"></td><td id=\"sjs-J15\"></td><td id=\"sjs-K15\"></td><td id=\"sjs-L15\"></td><td id=\"sjs-M15\"></td></tr><tr><td id=\"sjs-A16\"></td><td id=\"sjs-B16\"></td><td id=\"sjs-C16\"></td><td id=\"sjs-D16\"></td><td id=\"sjs-E16\"></td><td id=\"sjs-F16\"></td><td id=\"sjs-G16\"></td><td id=\"sjs-H16\"></td><td id=\"sjs-I16\"></td><td id=\"sjs-J16\"></td><td id=\"sjs-K16\"></td><td id=\"sjs-L16\"></td><td id=\"sjs-M16\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A17\"></td><td colspan=\"2\" id=\"sjs-G17\"></td><td colspan=\"5\" id=\"sjs-I17\"></td></tr><tr><td id=\"sjs-A18\"></td><td colspan=\"2\" id=\"sjs-B18\"></td><td colspan=\"3\" id=\"sjs-D18\"></td><td colspan=\"3\" id=\"sjs-G18\"></td><td id=\"sjs-J18\"></td><td id=\"sjs-K18\"></td><td id=\"sjs-L18\"></td><td id=\"sjs-M18\"></td></tr><tr><td id=\"sjs-A19\"></td><td id=\"sjs-B19\"></td><td id=\"sjs-C19\"></td><td id=\"sjs-D19\"></td><td id=\"sjs-E19\"></td><td id=\"sjs-F19\"></td><td id=\"sjs-G19\"></td><td id=\"sjs-H19\"></td><td id=\"sjs-I19\"></td><td id=\"sjs-J19\"></td><td id=\"sjs-K19\"></td><td id=\"sjs-L19\"></td><td id=\"sjs-M19\"></td></tr><tr><td id=\"sjs-A20\"></td><td id=\"sjs-B20\"></td><td id=\"sjs-C20\"></td><td id=\"sjs-D20\"></td><td id=\"sjs-E20\"></td><td id=\"sjs-F20\"></td><td id=\"sjs-G20\"></td><td id=\"sjs-H20\"></td><td id=\"sjs-I20\"></td><td id=\"sjs-J20\"></td><td id=\"sjs-K20\"></td><td id=\"sjs-L20\"></td><td id=\"sjs-M20\"></td></tr><tr><td id=\"sjs-A21\"></td><td id=\"sjs-B21\"></td><td id=\"sjs-C21\"></td><td id=\"sjs-D21\"></td><td id=\"sjs-E21\"></td><td id=\"sjs-F21\"></td><td id=\"sjs-G21\"></td><td id=\"sjs-H21\"></td><td id=\"sjs-I21\"></td><td id=\"sjs-J21\"></td><td id=\"sjs-K21\"></td><td id=\"sjs-L21\"></td><td id=\"sjs-M21\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A22\"></td><td colspan=\"2\" id=\"sjs-G22\"></td><td colspan=\"5\" id=\"sjs-I22\"></td></tr><tr><td id=\"sjs-A23\"></td><td colspan=\"2\" id=\"sjs-B23\"></td><td colspan=\"3\" id=\"sjs-D23\"></td><td colspan=\"3\" id=\"sjs-G23\"></td><td id=\"sjs-J23\"></td><td id=\"sjs-K23\"></td><td id=\"sjs-L23\"></td><td id=\"sjs-M23\"></td></tr><tr><td id=\"sjs-A24\"></td><td id=\"sjs-B24\"></td><td id=\"sjs-C24\"></td><td id=\"sjs-D24\"></td><td id=\"sjs-E24\"></td><td id=\"sjs-F24\"></td><td id=\"sjs-G24\"></td><td id=\"sjs-H24\"></td><td id=\"sjs-I24\"></td><td id=\"sjs-J24\"></td><td id=\"sjs-K24\"></td><td id=\"sjs-L24\"></td><td id=\"sjs-M24\"></td></tr><tr><td id=\"sjs-A25\"></td><td id=\"sjs-B25\"></td><td id=\"sjs-C25\"></td><td id=\"sjs-D25\"></td><td id=\"sjs-E25\"></td><td id=\"sjs-F25\"></td><td id=\"sjs-G25\"></td><td id=\"sjs-H25\"></td><td id=\"sjs-I25\"></td><td id=\"sjs-J25\"></td><td id=\"sjs-K25\"></td><td id=\"sjs-L25\"></td><td id=\"sjs-M25\"></td></tr><tr><td id=\"sjs-A26\"></td><td id=\"sjs-B26\"></td><td id=\"sjs-C26\"></td><td id=\"sjs-D26\"></td><td id=\"sjs-E26\"></td><td id=\"sjs-F26\"></td><td id=\"sjs-G26\"></td><td id=\"sjs-H26\"></td><td id=\"sjs-I26\"></td><td id=\"sjs-J26\"></td><td id=\"sjs-K26\"></td><td id=\"sjs-L26\"></td><td id=\"sjs-M26\"></td></tr><tr><td id=\"sjs-A27\"></td><td id=\"sjs-B27\"></td><td id=\"sjs-C27\"></td><td id=\"sjs-D27\"></td><td id=\"sjs-E27\"></td><td id=\"sjs-F27\"></td><td id=\"sjs-G27\"></td><td id=\"sjs-H27\"></td><td id=\"sjs-I27\"></td><td id=\"sjs-J27\"></td><td id=\"sjs-K27\"></td><td id=\"sjs-L27\"></td><td id=\"sjs-M27\"></td></tr><tr><td id=\"sjs-A28\"></td><td id=\"sjs-B28\"></td><td id=\"sjs-C28\"></td><td id=\"sjs-D28\"></td><td id=\"sjs-E28\"></td><td id=\"sjs-F28\"></td><td id=\"sjs-G28\"></td><td id=\"sjs-H28\"></td><td id=\"sjs-I28\"></td><td id=\"sjs-J28\"></td><td id=\"sjs-K28\"></td><td id=\"sjs-L28\"></td><td id=\"sjs-M28\"></td></tr><tr><td id=\"sjs-A29\"></td><td id=\"sjs-B29\"></td><td id=\"sjs-C29\"></td><td id=\"sjs-D29\"></td><td id=\"sjs-E29\"></td><td id=\"sjs-F29\"></td><td id=\"sjs-G29\"></td><td id=\"sjs-H29\"></td><td id=\"sjs-I29\"></td><td id=\"sjs-J29\"></td><td id=\"sjs-K29\"></td><td id=\"sjs-L29\"></td><td id=\"sjs-M29\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A30\"></td><td colspan=\"2\" id=\"sjs-G30\"></td><td colspan=\"5\" id=\"sjs-I30\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A31\"></td><td colspan=\"2\" id=\"sjs-G31\"></td><td colspan=\"5\" id=\"sjs-I31\"></td></tr></table></body></html>");
//                map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                break;
            case "板材明细-按板材-模板.xlsx":
                map.put("plateListDetail", getOrderPlate(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"13\" data-t=\"s\" data-v=\"板材明细单\" id=\"sjs-A1\">板材明细单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\"><span style=\"font-size:10pt;\"><b>订单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B2\"></td><td data-t=\"s\" data-v=\"自定单号:\" id=\"sjs-C2\"><span style=\"font-size:10pt;\"><b>自定单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D2\"></td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td id=\"sjs-F2\"></td><td data-t=\"s\" data-v=\"订单日期：\" id=\"sjs-G2\"><span style=\"font-size:10pt;\"><b>订单日期</b></span><span style=\"font-size:10pt;\"><b>：</b></span></td><td id=\"sjs-H2\"></td><td id=\"sjs-I2\"></td><td id=\"sjs-J2\"></td><td id=\"sjs-K2\"></td><td id=\"sjs-L2\"></td><td id=\"sjs-M2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\"><span style=\"font-size:10pt;\"><b>客户</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B3\"></td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\"><span style=\"font-size:10pt;\"><b>收货电话</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D3\"></td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\"><span style=\"font-size:10pt;\"><b>收货地址</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-F3\"></td><td data-t=\"s\" data-v=\"收货日期：\" id=\"sjs-G3\"><span style=\"font-size:10pt;\"><b>收货日期：</b></span></td><td id=\"sjs-H3\"></td><td id=\"sjs-I3\"></td><td id=\"sjs-J3\"></td><td id=\"sjs-K3\"></td><td id=\"sjs-L3\"></td><td id=\"sjs-M3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td id=\"sjs-B4\"></td><td id=\"sjs-C4\"></td><td id=\"sjs-D4\"></td><td id=\"sjs-E4\"></td><td id=\"sjs-F4\"></td><td id=\"sjs-G4\"></td><td id=\"sjs-H4\"></td><td id=\"sjs-I4\"></td><td id=\"sjs-J4\"></td><td id=\"sjs-K4\"></td><td id=\"sjs-L4\"></td><td id=\"sjs-M4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td><td id=\"sjs-J5\"></td><td id=\"sjs-K5\"></td><td id=\"sjs-L5\"></td><td id=\"sjs-M5\"></td></tr><tr><td colspan=\"2\" data-t=\"s\" data-v=\"板材名称数据源\" id=\"sjs-A6\">板材名称数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"板材颜色数据源\" id=\"sjs-C6\">板材颜色数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"板材厚度数据源\" id=\"sjs-F6\">板材厚度数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"列表条数表达式\" id=\"sjs-I6\">列表条数表达式</td><td id=\"sjs-L6\"></td><td id=\"sjs-M6\"></td></tr><tr><td data-t=\"s\" data-v=\"房名\" id=\"sjs-A7\">房名</td><td data-t=\"s\" data-v=\"柜名\" id=\"sjs-B7\">柜名</td><td data-t=\"s\" data-v=\"板编号\" id=\"sjs-C7\">板编号</td><td data-t=\"s\" data-v=\"板名称\" id=\"sjs-D7\">板名称</td><td data-t=\"s\" data-v=\"长\" id=\"sjs-E7\">长</td><td data-t=\"s\" data-v=\"宽\" id=\"sjs-F7\">宽</td><td data-t=\"s\" data-v=\"厚度\" id=\"sjs-G7\">厚度</td><td data-t=\"s\" data-v=\"面积\" id=\"sjs-H7\">面积</td><td data-t=\"s\" data-v=\"异形\" id=\"sjs-I7\">异形</td><td data-t=\"s\" data-v=\"造型\" id=\"sjs-J7\">造型</td><td data-t=\"s\" data-v=\"左/右/上/下\" id=\"sjs-K7\">左/右/上/下</td><td data-t=\"s\" data-v=\"开门类型\" id=\"sjs-L7\">开门类型</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-M7\">备注</td></tr><tr><td id=\"sjs-A8\"></td><td id=\"sjs-B8\"></td><td id=\"sjs-C8\"></td><td id=\"sjs-D8\"></td><td id=\"sjs-E8\"></td><td id=\"sjs-F8\"></td><td id=\"sjs-G8\"></td><td id=\"sjs-H8\"></td><td id=\"sjs-I8\"></td><td id=\"sjs-J8\"></td><td id=\"sjs-K8\"></td><td id=\"sjs-L8\"></td><td id=\"sjs-M8\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"小计：\" id=\"sjs-A9\">小计：</td><td colspan=\"2\" data-t=\"s\" data-v=\"小计面积表达式\" id=\"sjs-G9\">小计面积表达式</td><td id=\"sjs-I9\"></td><td id=\"sjs-J9\"></td><td id=\"sjs-K9\"></td><td id=\"sjs-L9\"></td><td id=\"sjs-M9\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"合计：\" id=\"sjs-A10\">合计：</td><td colspan=\"2\" data-t=\"s\" data-v=\"合计面积表达式\" id=\"sjs-G10\">合计面积表达式</td><td id=\"sjs-I10\"></td><td id=\"sjs-J10\"></td><td id=\"sjs-K10\"></td><td id=\"sjs-L10\"></td><td id=\"sjs-M10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td><td id=\"sjs-J11\"></td><td id=\"sjs-K11\"></td><td id=\"sjs-L11\"></td><td id=\"sjs-M11\"></td></tr><tr><td id=\"sjs-A12\"></td><td id=\"sjs-B12\"></td><td id=\"sjs-C12\"></td><td id=\"sjs-D12\"></td><td id=\"sjs-E12\"></td><td id=\"sjs-F12\"></td><td id=\"sjs-G12\"></td><td id=\"sjs-H12\"></td><td id=\"sjs-I12\"></td><td id=\"sjs-J12\"></td><td id=\"sjs-K12\"></td><td id=\"sjs-L12\"></td><td id=\"sjs-M12\"></td></tr><tr><td id=\"sjs-A13\"></td><td id=\"sjs-B13\"></td><td id=\"sjs-C13\"></td><td id=\"sjs-D13\"></td><td id=\"sjs-E13\"></td><td id=\"sjs-F13\"></td><td id=\"sjs-G13\"></td><td id=\"sjs-H13\"></td><td id=\"sjs-I13\"></td><td id=\"sjs-J13\"></td><td id=\"sjs-K13\"></td><td id=\"sjs-L13\"></td><td id=\"sjs-M13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td><td id=\"sjs-J14\"></td><td id=\"sjs-K14\"></td><td id=\"sjs-L14\"></td><td id=\"sjs-M14\"></td></tr><tr><td id=\"sjs-A15\"></td><td id=\"sjs-B15\"></td><td id=\"sjs-C15\"></td><td id=\"sjs-D15\"></td><td id=\"sjs-E15\"></td><td id=\"sjs-F15\"></td><td id=\"sjs-G15\"></td><td id=\"sjs-H15\"></td><td id=\"sjs-I15\"></td><td id=\"sjs-J15\"></td><td id=\"sjs-K15\"></td><td id=\"sjs-L15\"></td><td id=\"sjs-M15\"></td></tr><tr><td id=\"sjs-A16\"></td><td id=\"sjs-B16\"></td><td id=\"sjs-C16\"></td><td id=\"sjs-D16\"></td><td id=\"sjs-E16\"></td><td id=\"sjs-F16\"></td><td id=\"sjs-G16\"></td><td id=\"sjs-H16\"></td><td id=\"sjs-I16\"></td><td id=\"sjs-J16\"></td><td id=\"sjs-K16\"></td><td id=\"sjs-L16\"></td><td id=\"sjs-M16\"></td></tr><tr><td id=\"sjs-A17\"></td><td id=\"sjs-B17\"></td><td id=\"sjs-C17\"></td><td id=\"sjs-D17\"></td><td id=\"sjs-E17\"></td><td id=\"sjs-F17\"></td><td id=\"sjs-G17\"></td><td id=\"sjs-H17\"></td><td id=\"sjs-I17\"></td><td id=\"sjs-J17\"></td><td id=\"sjs-K17\"></td><td id=\"sjs-L17\"></td><td id=\"sjs-M17\"></td></tr><tr><td id=\"sjs-A18\"></td><td id=\"sjs-B18\"></td><td id=\"sjs-C18\"></td><td id=\"sjs-D18\"></td><td id=\"sjs-E18\"></td><td id=\"sjs-F18\"></td><td id=\"sjs-G18\"></td><td id=\"sjs-H18\"></td><td id=\"sjs-I18\"></td><td id=\"sjs-J18\"></td><td id=\"sjs-K18\"></td><td id=\"sjs-L18\"></td><td id=\"sjs-M18\"></td></tr><tr><td id=\"sjs-A19\"></td><td id=\"sjs-B19\"></td><td id=\"sjs-C19\"></td><td id=\"sjs-D19\"></td><td id=\"sjs-E19\"></td><td id=\"sjs-F19\"></td><td id=\"sjs-G19\"></td><td id=\"sjs-H19\"></td><td id=\"sjs-I19\"></td><td id=\"sjs-J19\"></td><td id=\"sjs-K19\"></td><td id=\"sjs-L19\"></td><td id=\"sjs-M19\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A20\"></td><td colspan=\"2\" id=\"sjs-G20\"></td><td colspan=\"5\" id=\"sjs-I20\"></td></tr><tr><td colspan=\"2\" id=\"sjs-A21\"></td><td colspan=\"3\" id=\"sjs-C21\"></td><td colspan=\"3\" id=\"sjs-F21\"></td><td colspan=\"3\" id=\"sjs-I21\"></td><td id=\"sjs-L21\"></td><td id=\"sjs-M21\"></td></tr><tr><td id=\"sjs-A22\"></td><td id=\"sjs-B22\"></td><td id=\"sjs-C22\"></td><td id=\"sjs-D22\"></td><td id=\"sjs-E22\"></td><td id=\"sjs-F22\"></td><td id=\"sjs-G22\"></td><td id=\"sjs-H22\"></td><td id=\"sjs-I22\"></td><td id=\"sjs-J22\"></td><td id=\"sjs-K22\"></td><td id=\"sjs-L22\"></td><td id=\"sjs-M22\"></td></tr><tr><td id=\"sjs-A23\"></td><td id=\"sjs-B23\"></td><td id=\"sjs-C23\"></td><td id=\"sjs-D23\"></td><td id=\"sjs-E23\"></td><td id=\"sjs-F23\"></td><td id=\"sjs-G23\"></td><td id=\"sjs-H23\"></td><td id=\"sjs-I23\"></td><td id=\"sjs-J23\"></td><td id=\"sjs-K23\"></td><td id=\"sjs-L23\"></td><td id=\"sjs-M23\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A24\"></td><td colspan=\"2\" id=\"sjs-G24\"></td><td colspan=\"5\" id=\"sjs-I24\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A25\"></td><td colspan=\"2\" id=\"sjs-G25\"></td><td colspan=\"5\" id=\"sjs-I25\"></td></tr></table></body></html>");
//                map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                break;
            case "板材汇总-按房间-模板.xlsx":
                map.put("plateSummary", plateMapper.selectPlateGoodsListSummary(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"9\" data-t=\"s\" data-v=\"板材汇总单\" id=\"sjs-A1\">板材汇总单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\"><span style=\"font-size:10pt;\"><b>订单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B2\"></td><td data-t=\"s\" data-v=\"自定单号:\" id=\"sjs-C2\"><span style=\"font-size:10pt;\"><b>自定单号</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D2\"></td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td id=\"sjs-F2\"></td><td data-t=\"s\" data-v=\"订单日期：\" id=\"sjs-G2\"><span style=\"font-size:10pt;\"><b>订单日期</b></span><span style=\"font-size:10pt;\"><b>：</b></span></td><td id=\"sjs-H2\"></td><td id=\"sjs-I2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\"><span style=\"font-size:10pt;\"><b>客户</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-B3\"></td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\"><span style=\"font-size:10pt;\"><b>收货电话</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-D3\"></td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\"><span style=\"font-size:10pt;\"><b>收货地址</b></span><span style=\"font-size:10pt;\"><b>:</b></span></td><td id=\"sjs-F3\"></td><td data-t=\"s\" data-v=\"收货日期：\" id=\"sjs-G3\"><span style=\"font-size:10pt;\"><b>收货日期：</b></span></td><td id=\"sjs-H3\"></td><td id=\"sjs-I3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td id=\"sjs-B4\"></td><td id=\"sjs-C4\"></td><td id=\"sjs-D4\"></td><td id=\"sjs-E4\"></td><td id=\"sjs-F4\"></td><td id=\"sjs-G4\"></td><td id=\"sjs-H4\"></td><td id=\"sjs-I4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td></tr><tr><td data-t=\"s\" data-v=\"房间名称数据源\" id=\"sjs-A6\">房间名称数据源</td><td colspan=\"2\" data-t=\"s\" data-v=\"柜体数据源\" id=\"sjs-B6\">柜体数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"列表条数表达式\" id=\"sjs-D6\">列表条数表达式</td><td id=\"sjs-G6\"></td><td id=\"sjs-H6\"></td><td id=\"sjs-I6\"></td></tr><tr><td data-t=\"s\" data-v=\"板名称\" id=\"sjs-A7\">板名称</td><td data-t=\"s\" data-v=\"材料\" id=\"sjs-B7\">材料</td><td data-t=\"s\" data-v=\"颜色\" id=\"sjs-C7\">颜色</td><td data-t=\"s\" data-v=\"长\" id=\"sjs-D7\">长</td><td data-t=\"s\" data-v=\"宽\" id=\"sjs-E7\">宽</td><td data-t=\"s\" data-v=\"厚度\" id=\"sjs-F7\">厚度</td><td data-t=\"s\" data-v=\"数量\" id=\"sjs-G7\">数量</td><td data-t=\"s\" data-v=\"面积\" id=\"sjs-H7\">面积</td><td data-t=\"s\" data-v=\"开门类型\" id=\"sjs-I7\">开门类型</td></tr><tr><td id=\"sjs-A8\"></td><td id=\"sjs-B8\"></td><td id=\"sjs-C8\"></td><td id=\"sjs-D8\"></td><td id=\"sjs-E8\"></td><td id=\"sjs-F8\"></td><td id=\"sjs-G8\"></td><td id=\"sjs-H8\"></td><td id=\"sjs-I8\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"小计：\" id=\"sjs-A9\">小计：</td><td data-t=\"s\" data-v=\"数量表达式\" id=\"sjs-G9\">数量表达式</td><td data-t=\"s\" data-v=\"面积表达式\" id=\"sjs-H9\">面积表达式</td><td id=\"sjs-I9\"></td></tr><tr><td colspan=\"6\" data-t=\"s\" data-v=\"合计：\" id=\"sjs-A10\">合计：</td><td data-t=\"s\" data-v=\"数量表达式\" id=\"sjs-G10\">数量表达式</td><td data-t=\"s\" data-v=\"面积表达式\" id=\"sjs-H10\">面积表达式</td><td id=\"sjs-I10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A12\"></td><td id=\"sjs-G12\"></td><td id=\"sjs-H12\"></td><td id=\"sjs-I12\"></td></tr><tr><td id=\"sjs-A13\"></td><td colspan=\"2\" id=\"sjs-B13\"></td><td colspan=\"3\" id=\"sjs-D13\"></td><td id=\"sjs-G13\"></td><td id=\"sjs-H13\"></td><td id=\"sjs-I13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td></tr><tr><td id=\"sjs-A15\"></td><td id=\"sjs-B15\"></td><td id=\"sjs-C15\"></td><td id=\"sjs-D15\"></td><td id=\"sjs-E15\"></td><td id=\"sjs-F15\"></td><td id=\"sjs-G15\"></td><td id=\"sjs-H15\"></td><td id=\"sjs-I15\"></td></tr><tr><td id=\"sjs-A16\"></td><td id=\"sjs-B16\"></td><td id=\"sjs-C16\"></td><td id=\"sjs-D16\"></td><td id=\"sjs-E16\"></td><td id=\"sjs-F16\"></td><td id=\"sjs-G16\"></td><td id=\"sjs-H16\"></td><td id=\"sjs-I16\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A17\"></td><td id=\"sjs-G17\"></td><td colspan=\"2\" id=\"sjs-H17\"></td></tr><tr><td id=\"sjs-A18\"></td><td colspan=\"2\" id=\"sjs-B18\"></td><td colspan=\"3\" id=\"sjs-D18\"></td><td id=\"sjs-G18\"></td><td id=\"sjs-H18\"></td><td id=\"sjs-I18\"></td></tr><tr><td id=\"sjs-A19\"></td><td id=\"sjs-B19\"></td><td id=\"sjs-C19\"></td><td id=\"sjs-D19\"></td><td id=\"sjs-E19\"></td><td id=\"sjs-F19\"></td><td id=\"sjs-G19\"></td><td id=\"sjs-H19\"></td><td id=\"sjs-I19\"></td></tr><tr><td id=\"sjs-A20\"></td><td id=\"sjs-B20\"></td><td id=\"sjs-C20\"></td><td id=\"sjs-D20\"></td><td id=\"sjs-E20\"></td><td id=\"sjs-F20\"></td><td id=\"sjs-G20\"></td><td id=\"sjs-H20\"></td><td id=\"sjs-I20\"></td></tr><tr><td id=\"sjs-A21\"></td><td id=\"sjs-B21\"></td><td id=\"sjs-C21\"></td><td id=\"sjs-D21\"></td><td id=\"sjs-E21\"></td><td id=\"sjs-F21\"></td><td id=\"sjs-G21\"></td><td id=\"sjs-H21\"></td><td id=\"sjs-I21\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A22\"></td><td id=\"sjs-G22\"></td><td colspan=\"2\" id=\"sjs-H22\"></td></tr><tr><td id=\"sjs-A23\"></td><td colspan=\"2\" id=\"sjs-B23\"></td><td colspan=\"3\" id=\"sjs-D23\"></td><td id=\"sjs-G23\"></td><td id=\"sjs-H23\"></td><td id=\"sjs-I23\"></td></tr><tr><td id=\"sjs-A24\"></td><td id=\"sjs-B24\"></td><td id=\"sjs-C24\"></td><td id=\"sjs-D24\"></td><td id=\"sjs-E24\"></td><td id=\"sjs-F24\"></td><td id=\"sjs-G24\"></td><td id=\"sjs-H24\"></td><td id=\"sjs-I24\"></td></tr><tr><td id=\"sjs-A25\"></td><td id=\"sjs-B25\"></td><td id=\"sjs-C25\"></td><td id=\"sjs-D25\"></td><td id=\"sjs-E25\"></td><td id=\"sjs-F25\"></td><td id=\"sjs-G25\"></td><td id=\"sjs-H25\"></td><td id=\"sjs-I25\"></td></tr><tr><td id=\"sjs-A26\"></td><td id=\"sjs-B26\"></td><td id=\"sjs-C26\"></td><td id=\"sjs-D26\"></td><td id=\"sjs-E26\"></td><td id=\"sjs-F26\"></td><td id=\"sjs-G26\"></td><td id=\"sjs-H26\"></td><td id=\"sjs-I26\"></td></tr><tr><td id=\"sjs-A27\"></td><td id=\"sjs-B27\"></td><td id=\"sjs-C27\"></td><td id=\"sjs-D27\"></td><td id=\"sjs-E27\"></td><td id=\"sjs-F27\"></td><td id=\"sjs-G27\"></td><td id=\"sjs-H27\"></td><td id=\"sjs-I27\"></td></tr><tr><td id=\"sjs-A28\"></td><td id=\"sjs-B28\"></td><td id=\"sjs-C28\"></td><td id=\"sjs-D28\"></td><td id=\"sjs-E28\"></td><td id=\"sjs-F28\"></td><td id=\"sjs-G28\"></td><td id=\"sjs-H28\"></td><td id=\"sjs-I28\"></td></tr><tr><td id=\"sjs-A29\"></td><td id=\"sjs-B29\"></td><td id=\"sjs-C29\"></td><td id=\"sjs-D29\"></td><td id=\"sjs-E29\"></td><td id=\"sjs-F29\"></td><td id=\"sjs-G29\"></td><td id=\"sjs-H29\"></td><td id=\"sjs-I29\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A30\"></td><td id=\"sjs-G30\"></td><td colspan=\"2\" id=\"sjs-H30\"></td></tr><tr><td colspan=\"6\" id=\"sjs-A31\"></td><td id=\"sjs-G31\"></td><td colspan=\"2\" id=\"sjs-H31\"></td></tr></table></body></html>");
                map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                break;
            case "板材汇总-按板材-模板.xlsx":
                map.put("plateSummary", plateMapper.selectPlateGoodsListSummary(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                map.put(tableKey, "<html><head><meta charset=\"utf-8\"/><title>SheetJS Table Export</title></head><body><table><tr><td colspan=\"11\" data-t=\"s\" data-v=\"板材汇总单\" id=\"sjs-A1\">板材汇总单</td></tr><tr><td data-t=\"s\" data-v=\"订单号:\" id=\"sjs-A2\">订单号:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B2\">数据源</td><td data-t=\"s\" data-v=\"自定义单号:\" id=\"sjs-C2\">自定义单号:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D2\">数据源</td><td data-t=\"s\" data-v=\"经销商:\" id=\"sjs-E2\">经销商:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F2\">数据源</td><td data-t=\"s\" data-v=\"订单日期:\" id=\"sjs-G2\">订单日期:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H2\">数据源</td><td id=\"sjs-I2\"></td><td id=\"sjs-J2\"></td><td id=\"sjs-K2\"></td></tr><tr><td data-t=\"s\" data-v=\"客户:\" id=\"sjs-A3\">客户:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B3\">数据源</td><td data-t=\"s\" data-v=\"收货电话:\" id=\"sjs-C3\">收货电话:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D3\">数据源</td><td data-t=\"s\" data-v=\"收货地址:\" id=\"sjs-E3\">收货地址:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F3\">数据源</td><td data-t=\"s\" data-v=\"收货日期:\" id=\"sjs-G3\">收货日期:</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H3\">数据源</td><td id=\"sjs-I3\"></td><td id=\"sjs-J3\"></td><td id=\"sjs-K3\"></td></tr><tr><td data-t=\"s\" data-v=\"备注:\" id=\"sjs-A4\">备注:</td><td colspan=\"7\" data-t=\"s\" data-v=\"数据源\" id=\"sjs-B4\">数据源</td><td id=\"sjs-I4\"></td><td id=\"sjs-J4\"></td><td id=\"sjs-K4\"></td></tr><tr><td id=\"sjs-A5\"></td><td id=\"sjs-B5\"></td><td id=\"sjs-C5\"></td><td id=\"sjs-D5\"></td><td id=\"sjs-E5\"></td><td id=\"sjs-F5\"></td><td id=\"sjs-G5\"></td><td id=\"sjs-H5\"></td><td id=\"sjs-I5\"></td><td id=\"sjs-J5\"></td><td id=\"sjs-K5\"></td></tr><tr><td colspan=\"2\" data-t=\"s\" data-v=\"板材名称数据源\" id=\"sjs-A6\">板材名称数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"板材颜色数据源\" id=\"sjs-C6\">板材颜色数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"板材厚度数据源\" id=\"sjs-F6\">板材厚度数据源</td><td colspan=\"3\" data-t=\"s\" data-v=\"列表条数表达式\" id=\"sjs-I6\">列表条数表达式</td></tr><tr><td data-t=\"s\" data-v=\"房名\" id=\"sjs-A7\">房名</td><td data-t=\"s\" data-v=\"柜名\" id=\"sjs-B7\">柜名</td><td data-t=\"s\" data-v=\"板名称\" id=\"sjs-C7\">板名称</td><td data-t=\"s\" data-v=\"长\" id=\"sjs-D7\">长</td><td data-t=\"s\" data-v=\"宽\" id=\"sjs-E7\">宽</td><td data-t=\"s\" data-v=\"数量\" id=\"sjs-F7\">数量</td><td data-t=\"s\" data-v=\"面积\" id=\"sjs-G7\">面积</td><td data-t=\"s\" data-v=\"开门类型\" id=\"sjs-H7\">开门类型</td><td data-t=\"s\" data-v=\"备注\" id=\"sjs-I7\">备注</td><td id=\"sjs-J7\"></td><td id=\"sjs-K7\"></td></tr><tr><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-A8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-B8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-C8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-D8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-E8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-F8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-G8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-H8\">数据源</td><td data-t=\"s\" data-v=\"数据源\" id=\"sjs-I8\">数据源</td><td id=\"sjs-J8\"></td><td id=\"sjs-K8\"></td></tr><tr><td colspan=\"5\" data-t=\"s\" data-v=\"小计：\" id=\"sjs-A9\">小计：</td><td data-t=\"s\" data-v=\"数量表达式\" id=\"sjs-F9\">数量表达式</td><td data-t=\"s\" data-v=\"面积表达式\" id=\"sjs-G9\">面积表达式</td><td id=\"sjs-H9\"></td><td id=\"sjs-I9\"></td><td id=\"sjs-J9\"></td><td id=\"sjs-K9\"></td></tr><tr><td colspan=\"5\" data-t=\"s\" data-v=\"合计：\" id=\"sjs-A10\">合计：</td><td data-t=\"s\" data-v=\"数量表达式\" id=\"sjs-F10\">数量表达式</td><td data-t=\"s\" data-v=\"面积表达式\" id=\"sjs-G10\">面积表达式</td><td id=\"sjs-H10\"></td><td id=\"sjs-I10\"></td><td id=\"sjs-J10\"></td><td id=\"sjs-K10\"></td></tr><tr><td id=\"sjs-A11\"></td><td id=\"sjs-B11\"></td><td id=\"sjs-C11\"></td><td id=\"sjs-D11\"></td><td id=\"sjs-E11\"></td><td id=\"sjs-F11\"></td><td id=\"sjs-G11\"></td><td id=\"sjs-H11\"></td><td id=\"sjs-I11\"></td><td id=\"sjs-J11\"></td><td id=\"sjs-K11\"></td></tr><tr><td id=\"sjs-A12\"></td><td id=\"sjs-B12\"></td><td id=\"sjs-C12\"></td><td id=\"sjs-D12\"></td><td id=\"sjs-E12\"></td><td id=\"sjs-F12\"></td><td id=\"sjs-G12\"></td><td id=\"sjs-H12\"></td><td id=\"sjs-I12\"></td><td id=\"sjs-J12\"></td><td id=\"sjs-K12\"></td></tr><tr><td id=\"sjs-A13\"></td><td id=\"sjs-B13\"></td><td id=\"sjs-C13\"></td><td id=\"sjs-D13\"></td><td id=\"sjs-E13\"></td><td id=\"sjs-F13\"></td><td id=\"sjs-G13\"></td><td id=\"sjs-H13\"></td><td id=\"sjs-I13\"></td><td id=\"sjs-J13\"></td><td id=\"sjs-K13\"></td></tr><tr><td id=\"sjs-A14\"></td><td id=\"sjs-B14\"></td><td id=\"sjs-C14\"></td><td id=\"sjs-D14\"></td><td id=\"sjs-E14\"></td><td id=\"sjs-F14\"></td><td id=\"sjs-G14\"></td><td id=\"sjs-H14\"></td><td id=\"sjs-I14\"></td><td id=\"sjs-J14\"></td><td id=\"sjs-K14\"></td></tr><tr><td id=\"sjs-A15\"></td><td id=\"sjs-B15\"></td><td id=\"sjs-C15\"></td><td colspan=\"2\" id=\"sjs-D15\"></td><td id=\"sjs-F15\"></td><td id=\"sjs-G15\"></td><td id=\"sjs-H15\"></td><td id=\"sjs-I15\"></td><td id=\"sjs-J15\"></td><td id=\"sjs-K15\"></td></tr><tr><td id=\"sjs-A16\"></td><td id=\"sjs-B16\"></td><td id=\"sjs-C16\"></td><td id=\"sjs-D16\"></td><td id=\"sjs-E16\"></td><td id=\"sjs-F16\"></td><td id=\"sjs-G16\"></td><td id=\"sjs-H16\"></td><td id=\"sjs-I16\"></td><td id=\"sjs-J16\"></td><td id=\"sjs-K16\"></td></tr><tr><td id=\"sjs-A17\"></td><td id=\"sjs-B17\"></td><td id=\"sjs-C17\"></td><td id=\"sjs-D17\"></td><td id=\"sjs-E17\"></td><td id=\"sjs-F17\"></td><td id=\"sjs-G17\"></td><td id=\"sjs-H17\"></td><td id=\"sjs-I17\"></td><td id=\"sjs-J17\"></td><td id=\"sjs-K17\"></td></tr><tr><td id=\"sjs-A18\"></td><td id=\"sjs-B18\"></td><td id=\"sjs-C18\"></td><td id=\"sjs-D18\"></td><td id=\"sjs-E18\"></td><td id=\"sjs-F18\"></td><td id=\"sjs-G18\"></td><td id=\"sjs-H18\"></td><td id=\"sjs-I18\"></td><td id=\"sjs-J18\"></td><td id=\"sjs-K18\"></td></tr><tr><td id=\"sjs-A19\"></td><td id=\"sjs-B19\"></td><td id=\"sjs-C19\"></td><td id=\"sjs-D19\"></td><td id=\"sjs-E19\"></td><td id=\"sjs-F19\"></td><td id=\"sjs-G19\"></td><td id=\"sjs-H19\"></td><td id=\"sjs-I19\"></td><td id=\"sjs-J19\"></td><td id=\"sjs-K19\"></td></tr><tr><td colspan=\"5\" id=\"sjs-A20\"></td><td id=\"sjs-F20\"></td><td colspan=\"2\" id=\"sjs-G20\"></td><td colspan=\"2\" id=\"sjs-I20\"></td><td id=\"sjs-K20\"></td></tr><tr><td colspan=\"2\" id=\"sjs-A21\"></td><td colspan=\"2\" id=\"sjs-C21\"></td><td colspan=\"4\" id=\"sjs-E21\"></td><td colspan=\"3\" id=\"sjs-I21\"></td></tr><tr><td id=\"sjs-A22\"></td><td id=\"sjs-B22\"></td><td id=\"sjs-C22\"></td><td id=\"sjs-D22\"></td><td id=\"sjs-E22\"></td><td id=\"sjs-F22\"></td><td id=\"sjs-G22\"></td><td id=\"sjs-H22\"></td><td id=\"sjs-I22\"></td><td id=\"sjs-J22\"></td><td id=\"sjs-K22\"></td></tr><tr><td id=\"sjs-A23\"></td><td id=\"sjs-B23\"></td><td id=\"sjs-C23\"></td><td id=\"sjs-D23\"></td><td id=\"sjs-E23\"></td><td id=\"sjs-F23\"></td><td id=\"sjs-G23\"></td><td id=\"sjs-H23\"></td><td id=\"sjs-I23\"></td><td id=\"sjs-J23\"></td><td id=\"sjs-K23\"></td></tr><tr><td id=\"sjs-A24\"></td><td id=\"sjs-B24\"></td><td id=\"sjs-C24\"></td><td id=\"sjs-D24\"></td><td id=\"sjs-E24\"></td><td id=\"sjs-F24\"></td><td id=\"sjs-G24\"></td><td id=\"sjs-H24\"></td><td id=\"sjs-I24\"></td><td id=\"sjs-J24\"></td><td id=\"sjs-K24\"></td></tr><tr><td id=\"sjs-A25\"></td><td id=\"sjs-B25\"></td><td id=\"sjs-C25\"></td><td id=\"sjs-D25\"></td><td id=\"sjs-E25\"></td><td id=\"sjs-F25\"></td><td id=\"sjs-G25\"></td><td id=\"sjs-H25\"></td><td id=\"sjs-I25\"></td><td id=\"sjs-J25\"></td><td id=\"sjs-K25\"></td></tr></table></body></html>");
                map.put(plateCountKey, plateMapper.countPlateByOrderId(orderDO.getId(), OrganContextHolder.getOrganId(), deleted));
                break;
            default:
                throw new ServiceException(FILE_TYPE_ERR);
        }
        return map;
    }

    // 以房间柜体为维度获取配件明细
    private List<PartsByRoomBodyRespVO> getOrderGoods(Long orderId, Long organId, Integer deleted) {
        List<PartsByRoomBodyRespVO>  partsByRoomBodyRespVOS = new ArrayList<>();
        // 获取房间柜体
        List<OrderBodyDO> orderBodyDOList = orderBodyMapper.selectList(orderId, deleted, organId);
        for (OrderBodyDO orderBodyDO : orderBodyDOList) {
            List<OrderPartsPrintRespVO> orderPartsDOList = orderPartsMapper.selectOrderPartsListByBody(orderId, organId, deleted, orderBodyDO.getRoomId(),orderBodyDO.getId());
            if (orderPartsDOList.isEmpty()) {
                continue;
            }
            partsByRoomBodyRespVOS.add(PartsByRoomBodyRespVO.builder()
                    .roomName(orderBodyDO.getRoomName())
                    .bodyName(orderBodyDO.getName())
                    .partsRespVO(orderPartsDOList)
                    .total(orderPartsDOList.stream().mapToDouble(OrderPartsPrintRespVO::getPrice).sum())
                    .build());
        }
        return partsByRoomBodyRespVOS;
    }

    // 以房间柜体为维度获取板材明细
    private List<PlateByRoomBodyDetRespVO> getOrderBody(Long orderId, Long organId, Integer deleted) {
        List<PlateByRoomBodyDetRespVO> plateByRoomBodyDetRespVOS = new ArrayList<>();
        // 获取房间柜体
        List<OrderBodyDO> orderBodyDOList = orderBodyMapper.selectList(orderId, deleted, organId);
        for (OrderBodyDO orderBodyDO : orderBodyDOList) {
            List<PlateGoodsRespVO> plateDOList = plateMapper.selectOrderPlateList(orderId, organId, deleted, orderBodyDO.getRoomId(), orderBodyDO.getId(),null);
            if (plateDOList.isEmpty()) {
                continue;
            }
            plateByRoomBodyDetRespVOS.add(PlateByRoomBodyDetRespVO.builder()
                    .roomName(orderBodyDO.getRoomName())
                    .bodyName(orderBodyDO.getName())
                    .plateRespVO(plateDOList)
                    .totalArea(plateDOList.stream()
                            .map(PlateGoodsRespVO::getArea)
                            .reduce(BigDecimal.ZERO, BigDecimal::add))
                    .number(plateDOList.size())
                    .build());
        }
        return plateByRoomBodyDetRespVOS;
    }

    // 板材信息为维度获取板材明细
    private List<PlateByGoodsDetRespVO> getOrderPlate(Long orderId, Long organId, Integer deleted) {
        List<PlateByGoodsDetRespVO> plateByGoodsDetRespVOS = new ArrayList<>();
        // 获得板材信息
        List<GoodsDO> plateDOList = goodsMapper.selectGoodsByOrderId(orderId, organId, deleted);
        for (GoodsDO goodsDO : plateDOList) {
            List<PlateGoodsRespVO> plateGoodsRespVOS = plateMapper.selectOrderPlateList(orderId, organId, deleted, null, null, goodsDO.getId());
            if (plateGoodsRespVOS.isEmpty()) {
                continue;
            }
            plateByGoodsDetRespVOS.add(PlateByGoodsDetRespVO.builder()
                    .goodsId(goodsDO.getGoodsId())
                    .name(goodsDO.getGoodsName())
                    .color(goodsDO.getColor())
                    .thickness(goodsDO.getThickness())
                    .plateRespVO(plateGoodsRespVOS)
                    .totalArea(plateGoodsRespVOS.stream()
                    .map(PlateGoodsRespVO::getArea)
                    .reduce(BigDecimal.ZERO, BigDecimal::add))
                    .number(plateGoodsRespVOS.size())
                    .build());
        }
        return plateByGoodsDetRespVOS;
    }
    //    判断是否已经导入
    private boolean validateOrderNoExists(String orderNo, Long organId) {
        if (orderMapper.selectCount(new LambdaQueryWrapper<OrderDO>()
                .eq(OrderDO::getApiOrderId, orderNo)
                .eq(OrderDO::getDeleted, false)
                .eq(OrderDO::getOrganId, organId)) > 0) {
            return false;
        }
        return true;
    }

    /**
     * 校验订单状态  和  是否排单
     *
     * @param orderId
     * @param roomIds
     * @param bodyId
     * @param organId
     */
    private OrderDO validateOrderStatus(Long orderId, Set<Long> roomIds, Long bodyId, Long organId) {
        // 校验存在
        OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId);
        if (orderDO == null)
            throw new ServiceException(ORDER_NOT_EXISTS);

        if (CollUtil.isEmpty(roomIds) && ObjectUtils.isEmpty(bodyId)) {
            throw new ServiceException(ORDER_BODY_DEL_NO_TARGET);
        }

        // 判断小板是否已开料，已开料不允许删除
        Boolean orderPlanExist = CollUtil.isNotEmpty(orderItemMapper.selectExistOrderPlan(orderId, roomIds, bodyId, organId));

        AssertUtils.notEquals(Boolean.FALSE, orderPlanExist, PLATE_IS_PLAN);

        return orderDO;
    }


    /**
     * 删除小板，大板，包裹
     *
     * @param plateDOList
     * @param orderId
     * @param bodyIds
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public List<Long> updateDeletePlate(List<PlateDO> plateDOList, Long orderId ,List<Long> bodyIds) {
        Long organId = getUserOrganId();

        Set<Long> goodsIds = new HashSet<>();

        // 分批删除小板
        List<List<PlateDO>> plateSplit = CollUtil.split(plateDOList, 500);
        for (List<PlateDO> plateBatch : plateSplit) {
            // 板件id列表
            List<Long> plateIdBatch = plateBatch.stream().map(PlateDO::getId).toList();
            // 记录商品id列表
            goodsIds.addAll(plateBatch.stream().map(PlateDO::getGoodsId).toList());
            // 删除小板
            plateMapper.updateDeletedPlate(plateIdBatch, organId, orderId);
        }


        // 删除包裹,只需删除，无需还原
        List<OrderItemDO> orderItemDOS = orderItemMapper.selectPackId(orderId, bodyIds, organId);

        if(CollUtil.isNotEmpty(orderItemDOS)) {
            // 条件下涉及到的包裹号
            List<Long> packIds = orderItemDOS.stream().map(OrderItemDO::getPackageId).distinct().toList();

            // 包裹号和订单号的对应关系
            Map<String, List<Long>> orderIdsByPackageNo = packService.getOrderIdsByPackageNo(packIds);

            Set<String> needDeletePackNoSet = new HashSet<>();

            for (Map.Entry<String, List<Long>> entry : orderIdsByPackageNo.entrySet()) {
                String packNoKey = entry.getKey();
                List<Long> orderIds = entry.getValue();

                // 当这个包裹只属于这个订单时，删除这个包裹
                if (CollUtil.isNotEmpty(orderIds) && orderIds.size() == 1 && ObjectUtil.equals(orderId, orderIds.get(0))) {
                    needDeletePackNoSet.add(packNoKey);
                }
            }

            if (CollUtil.isNotEmpty(needDeletePackNoSet)) {
                // 删除订单下对应编号的包裹
                packService.deletePackageByPackageNo(orderId, needDeletePackNoSet);

                // 重置明细的包裹编号
                orderItemMapper.deletePackList(orderId, needDeletePackNoSet, organId);

                OrderDO orderDO = orderMapper.selectById(orderId);

                AssertUtils.notEmpty(orderDO, ORDER_NOT_EXISTS);

                orderDO.setPackaged(OrderPackageStatusEnum.UNPACKED.getStatus());

                orderMapper.updateById(orderDO);
            }
        }

        // 查询商品id下还有的板件
        List<PlateDO> goodsPlateList = plateMapper.selectPlateDeletedStatus(orderId, goodsIds, organId);
        Set<Long> goodsIdNotAllDeletedSet = goodsPlateList.stream().map(PlateDO::getGoodsId).collect(Collectors.toSet());

        // 获取删除掉的板件所属商品id 和 还有未删除的商品id的差集
        List<Long> goodsIdDeleted = goodsIds.stream()
                .filter(id -> !goodsIdNotAllDeletedSet.contains(id))
                .toList();

        if (CollUtil.isNotEmpty(goodsIdDeleted)) {
            // 删除大板
            goodsMapper.updateDeletedById(orderId, goodsIdDeleted, organId);
        }

        return goodsIds.stream().toList();
    }


    /**
     * 还原小板，小板对应的大板信息
     *
     * @param orderId
     * @param plateDOList
     */
    @Transactional(rollbackFor = Exception.class)
    public Set<Long> updateRestorePlate(Long orderId, List<PlateDO> plateDOList) {
        Long organId = getUserOrganId();

        Set<Long> goodsIds = new HashSet<>();

        // 分批删除小板
        List<List<PlateDO>> plateSplit = CollUtil.split(plateDOList, 1000);
        for (List<PlateDO> plateBatch : plateSplit) {
            // 板件id列表
            List<Long> plateIdBatch = plateBatch.stream().map(PlateDO::getId).toList();
            // 记录商品id列表
            goodsIds.addAll(plateBatch.stream().map(PlateDO::getGoodsId).toList());
            // 删除小板
            plateMapper.updateNoDeletedPlate(plateIdBatch, organId, orderId);
        }

        // 还原大板
        List<GoodsDO> goodsDOS = goodsMapper.selectGoodsListByStatus(orderId, goodsIds, organId);
        if (!goodsDOS.isEmpty()) {
            goodsMapper.updateBatch(goodsDOS.stream().map(m -> m.setDeleted(false)).toList());
        }
        return goodsIds;
    }



    private void saveOrderPlateModel(List<PlateDO> plateDO, List<GoodsDO> goodsDO, List<OrderModelDO> orderModelDOs) {

        // 板材造型数据添加 大板分类ID，实际ID
        List<OrderGoodsPlateIds> orderGoodsPlateIds = BeanUtils.toBean(plateDO, OrderGoodsPlateIds.class);
        orderGoodsPlateIds.forEach(f->
                f.setActualGoodsId(goodsDO.stream().filter(g->g.getId().equals(f.getGoodsId())).map(GoodsDO::getGoodsId).toList().get(0))
        );
        orderModelDOs.forEach(f->{
            f.setGoodsId(orderGoodsPlateIds.stream().filter(fo->fo.getId().equals(f.getPlateId())).map(OrderGoodsPlateIds::getActualGoodsId).toList().get(0));
            f.setPlateGoodsId(orderGoodsPlateIds.stream().filter(fo->fo.getId().equals(f.getPlateId())).map(OrderGoodsPlateIds::getGoodsId).toList().get(0));

        });

    }

    @Override
    public void orderImportAsync(OrderImportAsyncReqVO importAsyncReqVO, MultipartFile file) {
        // 根据导入类型和工厂（预留）获取处理类
        OrderImportHandler orderImportHandler = orderImportHandlerFactory.getOrderImportHandler(importAsyncReqVO.getType(), null);
        // 如果是补板校验订单存在
        Long orderId = importAsyncReqVO.getOrderId();
        if (ObjectUtil.isNotNull(orderId)) {
            Optional.ofNullable(getOrder(orderId)).orElseThrow(() -> new ServiceException(ORDER_IMPORT_ORDER_NOT_EXISTS, orderId));
        }
        // 准备前置数据，准备完成发送消息消费解析临时表
        orderImportHandler.prepareAndConvert(importAsyncReqVO, file);
    }




    @Override
    public OrderAllData getOrderAllData(Long orderId, Long planId) {


        if (Objects.isNull(orderId) && Objects.isNull(planId)) {
            throw new ServiceException(ORDER_PLAN_ID_NOT_NULL);
        }

        if (!Objects.isNull(orderId) && !Objects.isNull(planId)) {
            throw new ServiceException(ORDER_PLAN_ID_IS_ONE);
        }

        Long organId = getUserOrganId();

        List<Long> orderIds = new ArrayList<>();

        OrderAllData orderAllData = new OrderAllData();

        List<OrderModelDO> orderModelDOS;

        List<LabelOrderPlateData> labelOrderPlateData;

        if(planId != null){

            PlanDO planDO = planMapper.selectById(planId);
            AssertUtils.notEmpty(planDO,PLAN_NOT_EXISTS);

            orderAllData.setPlan(planDO);

            String orderNos = Optional.ofNullable(planDO.getOrderNos()).orElse("[]");

            orderIds.addAll(JSON.parseArray(orderNos).toJavaList(Long.class).stream().distinct().toList());

            // 板材信息
            labelOrderPlateData = planItemMapper.selectLabelOrderPlateDataByPlanId(planId,organId);

            List<Long> plateIdList = labelOrderPlateData.stream().map(LabelOrderPlateData::getPlateId).distinct().toList();

            // 小板造型信息
            orderModelDOS = new ArrayList<>();

        }else {

            OrderDO orderDO = orderMapper.selectById(orderId);
            AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);

            orderIds.add(orderId);

            // 板材信息
            labelOrderPlateData = plateMapper.selectLabelOrderPlateDataByOrderId(orderId,organId);

            orderModelDOS = new ArrayList<>();
        }


        AssertUtils.notEmpty(orderIds, ORDER_PLAN_ORDERS_EMPTY);


        // 订单信息
        List<LabelOrderData> labelOrderData = orderMapper.selectLabelOrderData(orderIds, organId);

        List<Long> packIds = labelOrderPlateData.stream().map(LabelOrderPlateData::getPackageNo).distinct().toList();

        List<Long> rawGoodsId = labelOrderPlateData.stream().map(LabelOrderPlateData::getRawGoodsId).distinct().toList();

        List<Long> planIdList = labelOrderPlateData.stream().map(LabelOrderPlateData::getPlanId).distinct().toList();


        // 配件信息
        List<LabelOrderPartsData> labelOrderPartsData = orderPartsMapper.selectLabelOrderPartsData(orderIds, organId);

        labelOrderPartsData.forEach(f->{
            f.setCount(f.getNum().stream().reduce(BigDecimal.ZERO, BigDecimal::add));

            f.setNum(null);
            f.setBodyId(null);
            f.setRoomId(null);
            f.setGroupId(null);
        });


        // 包裹信息
        if(CollUtil.isNotEmpty(packIds)) {

            getLabelOrderPackData(packIds,organId,orderIds,labelOrderPlateData,orderAllData);

        }


        // 补充实际选择的大板信息-即生产的信息
        if(CollUtil.isNotEmpty(planIdList)){

            List<PlanActualGoodsModelDO> actualGoodsModelDOS = new ArrayList<>();

            if(CollUtil.isNotEmpty(actualGoodsModelDOS)) {
                labelOrderPlateData.forEach(f -> {
                    f.setActualGoodsName(actualGoodsModelDOS.stream().filter(a -> a.getPlanId().equals(f.getPlanId())).findFirst().orElse(new PlanActualGoodsModelDO()).getGoodsName());
                    f.setActualGoodsColor(actualGoodsModelDOS.stream().filter(a -> a.getPlanId().equals(f.getPlanId())).findFirst().orElse(new PlanActualGoodsModelDO()).getColor());
                    f.setActualGoodsMaterial(actualGoodsModelDOS.stream().filter(a -> a.getPlanId().equals(f.getPlanId())).findFirst().orElse(new PlanActualGoodsModelDO()).getMaterial());
                    f.setActualGoodsThickness(actualGoodsModelDOS.stream().filter(a -> a.getPlanId().equals(f.getPlanId())).findFirst().orElse(new PlanActualGoodsModelDO()).getThickness().doubleValue());
                });
            }
        }


        // 查询设计的大板信息
        List<RawGoodsDO> rawGoodsDOS = rawGoodsMapper.selectBatchIds(rawGoodsId);


        // 补充小板缺少的信息
        labelOrderPlateData.forEach(f->{

            // 补充缺少的订单信息
            f.setOrderDate(labelOrderData.stream().filter(o->o.getOrderNo().equals(f.getOrderId())).findFirst().orElse(new LabelOrderData()).getOrderDate());
            f.setDeliveryDate(labelOrderData.stream().filter(o->o.getOrderNo().equals(f.getOrderId())).findFirst().orElse(new LabelOrderData()).getDeliveryDate());
            f.setCustomOrderNo(labelOrderData.stream().filter(o->o.getOrderNo().equals(f.getOrderId())).findFirst().orElse(new LabelOrderData()).getCustomOrderNo());

            // 补充缺少设计的大板信息
            f.setRawGoodsName(rawGoodsDOS.stream().filter(r->r.getId().equals(f.getRawGoodsId())).findFirst().orElse(new RawGoodsDO()).getGoodsName());
            f.setRawGoodsColor(rawGoodsDOS.stream().filter(r->r.getId().equals(f.getRawGoodsId())).findFirst().orElse(new RawGoodsDO()).getColor());
            f.setRawGoodsMaterial(rawGoodsDOS.stream().filter(r->r.getId().equals(f.getRawGoodsId())).findFirst().orElse(new RawGoodsDO()).getMaterial());
            f.setRawGoodsSpec(rawGoodsDOS.stream().filter(r->r.getId().equals(f.getRawGoodsId())).findFirst().orElse(new RawGoodsDO()).getSpec());
            f.setRawGoodsThickness(rawGoodsDOS.stream().filter(r->r.getId().equals(f.getRawGoodsId())).findFirst().orElse(new RawGoodsDO()).getThickness());

        });

        orderAllData.setOrderList(labelOrderData);
        orderAllData.setPlateDataList(labelOrderPlateData);
        orderAllData.setPartsDataList(labelOrderPartsData);
        orderAllData.setPlateModels(orderModelDOS);

        return orderAllData;

    }




    // 获取包裹信息
    private void getLabelOrderPackData(List<Long> packIds,
                                       Long organId,
                                       List<Long> orderIds,
                                       List<LabelOrderPlateData> labelOrderPlateData,
                                       OrderAllData orderAllData){

//        // 板材包裹信息
//        List<LabelOrderPackData> labelOrderPackData = orderPackageMapper.selectLabelOrderPackData(packIds, organId);
//
//        labelOrderPackData.forEach(f -> f.setPackNum(f.getPackageInfos().size()));
//
//        // 查询是否有 配件 类型包裹
//        List<LabelOrderPackData> partPackList = orderPackageMapper.selectPartPack(orderIds, getUserOrganId(), OrderPackageTypeEnum.PARTS.getType(),OrderPackageStatusEnum.PACKAGED.getStatus());
//
//        if(CollUtil.isNotEmpty(partPackList)){
//
//            partPackList.forEach(f->f.setPackNum(f.getPackageInfos().size()));
//
//            // 板材包裹为空时，且配件包裹不为空，需要加入配件包裹的信息
//            if(CollUtil.isEmpty(labelOrderPackData)){
//                partPackList.forEach(f->labelOrderPackData.add(LabelOrderPackData.builder().orderNo(f.getOrderNo()).build()));
//            }
//
//
//            // 添加缺少的配件包裹信息
//            labelOrderPackData.forEach(f-> {
//                Integer packNum = partPackList.stream()
//                        .filter(p -> f.getOrderNo().equals(p.getOrderNo()))
//                        .mapToInt(p -> p.getPackNum() != null ? p.getPackNum() : 0)
//                        .sum();
//
//                f.setPackNum( Optional.ofNullable(f.getPackNum()).orElse(0) + packNum);
//
//                f.setPackageInfos(Optional.ofNullable(f.getPackageInfos()).orElse(new ArrayList<>()));
//
//                f.getPackageInfos().addAll(partPackList.stream()
//                        .filter(p->p.getOrderNo().equals(f.getOrderNo()))
//                        .map(LabelOrderPackData::getPackageInfos)
//                        .findAny().orElse(new ArrayList<>()));
//            });
//        }
//
//
//        List<OrderPackagDO> packageDOS = orderPackageMapper.selectPackListByIds(packIds,getUserOrganId());
//
//        labelOrderPlateData.forEach(f->
//                f.setPackageSerialNo(
//                        packageDOS.stream()
//                                .filter(o->o.getId().equals(f.getPackageNo()))
//                                .findFirst()
//                                .orElse(new OrderPackagDO()).getPackageNo()));
//
//        orderAllData.setPackDataList(labelOrderPackData);


    }


    @Override
    public List<Long> getFatherAndSonOrderIds(List<Long> orderIds) {
        if (CollUtil.isEmpty(orderIds)) {
            return Collections.emptyList();
        }

        // 查数据库（过滤掉不存在/已删除）
        List<OrderDO> orders = orderMapper.selectByIds(orderIds);
        if (CollUtil.isEmpty(orders)) {
            return Collections.emptyList();
        }

        // 用 Set 去重
        Set<Long> allIds = orders.stream()
                .map(OrderDO::getId)
                .collect(Collectors.toSet());

        // 收集父ID
        Set<Long> parentIds = orders.stream()
                .map(OrderDO::getParentId)
                .filter(id -> ObjectUtil.notEqual(id, OrderDO.PARENT_ID_ROOT))
                .collect(Collectors.toSet());

        if (CollUtil.isNotEmpty(parentIds)) {
            // 再查一遍父订单（避免父也被删除）
            List<OrderDO> parentOrders = orderMapper.selectByIds(parentIds);

            if (CollUtil.isNotEmpty(parentOrders)) {
                parentOrders.stream()
                        .map(OrderDO::getId)
                        .forEach(allIds::add);
            }
        }

        return new ArrayList<>(allIds);
    }

    @Override
    public List<PackOrdersInfoRespVO> getPackOrdersInfo(List<Long> orderIds) {
        // 查询订单
        List<OrderDO> orderDOS = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
                .in(OrderDO::getId, orderIds)
                .eq(OrderDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
                .select(OrderDO::getId, OrderDO::getCustomOrderNo, OrderDO::getAddress)
        );
        return BeanUtil.copyToList(orderDOS, PackOrdersInfoRespVO.class);
    }

    @Override
    public List<OrderPrintInfoRespVO> getOrderPrintInfo(List<Long> orderIds) {
        // 查询订单
        List<OrderDO> orderDOS = orderMapper.selectList(new LambdaQueryWrapper<OrderDO>()
                .in(OrderDO::getId, orderIds)
                .eq(OrderDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
                .select(OrderDO::getId, OrderDO::getOrderDate, OrderDO::getDeliveryDate, OrderDO::getOrderType, OrderDO::getCustomOrderNo
                        , OrderDO::getCustomer, OrderDO::getAddress, OrderDO::getPhoneNumber, OrderDO::getDealer, OrderDO::getDealerPhoneNumber
                        , OrderDO::getSalesman, OrderDO::getSplitter, OrderDO::getRemark)
        );
        return BeanUtil.copyToList(orderDOS, OrderPrintInfoRespVO.class);
    }

    @Override
    @DS("imes_prod")
    @Transactional(
            rollbackFor = Exception.class,
            propagation = Propagation.REQUIRES_NEW)
    public void expireByOrganId(Long organId) {
        try {
            List<Long> orderDOList = orderMapper.selectOrderListByUpdateTime(organId);

            if (CollUtil.isNotEmpty(orderDOList)) {
                // 每10条订单删除一次
                List<List<Long>> split = CollUtil.split(orderDOList, 10);
                // 订单各种组成每1000条删除一次，直到完全删除
                for (List<Long> orderIdBatch : split) {
                    goodsClean(orderIdBatch);
                    orderBodyClean(orderDOList);
                    orderGroupClean(orderDOList);
                    orderPartsClean(orderDOList);
                    orderItemClean(orderDOList);
                    plateClean(orderDOList);
                    orderComponentClean(orderDOList);
                    orderClean(orderDOList);
                }
            }

        } catch (Exception e) {
            log.error("订单作废30天清理异常，组织{}", organId, e);
        }
    }

    /**
     * 物理删除订单材质
     *
     * @param orderIds
     */
    public void goodsClean(List<Long> orderIds) {
        while (true) {
            List<Long> ids = goodsMapper.selectList(
                            Wrappers.<GoodsDO>lambdaQuery()
                                    .select(GoodsDO::getId)
                                    .in(GoodsDO::getOrderId, orderIds)
                                    .last("limit 1000")
                    ).stream()
                    .map(GoodsDO::getId)
                    .toList();
            if (ids.isEmpty()) {
                break;
            }

            goodsMapper.physicalDeleteByOrderIds(ids);
        }
    }

    /**
     * 物理删除订单柜体
     *
     * @param orderIds
     */
    public void orderBodyClean(List<Long> orderIds) {
        while (true) {
            List<Long> ids = orderBodyMapper.selectList(
                            Wrappers.<OrderBodyDO>lambdaQuery()
                                    .select(OrderBodyDO::getId)
                                    .in(OrderBodyDO::getOrderId, orderIds)
                                    .last("limit 1000")
                    ).stream()
                    .map(OrderBodyDO::getId)
                    .toList();
            if (ids.isEmpty()) {
                break;
            }

            orderBodyMapper.physicalDeleteByOrderIds(ids);
        }
    }

    /**
     * 物理删除订单加工组
     *
     * @param orderIds
     */
    public void orderGroupClean(List<Long> orderIds) {
        while (true) {
            List<Long> ids = orderGroupMapper.selectList(
                            Wrappers.<OrderGroupDO>lambdaQuery()
                                    .select(OrderGroupDO::getId)
                                    .in(OrderGroupDO::getOrderId, orderIds)
                                    .last("limit 1000")
                    ).stream()
                    .map(OrderGroupDO::getId)
                    .toList();
            if (ids.isEmpty()) {
                break;
            }

            orderGroupMapper.physicalDeleteByOrderIds(ids);
        }
    }

    /**
     * 物理删除订单配件
     *
     * @param orderIds
     */
    public void orderPartsClean(List<Long> orderIds) {
        while (true) {
            List<Long> ids = orderPartsMapper.selectList(
                            Wrappers.<OrderPartsDO>lambdaQuery()
                                    .select(OrderPartsDO::getId)
                                    .in(OrderPartsDO::getOrderId, orderIds)
                                    .last("limit 1000")
                    ).stream()
                    .map(OrderPartsDO::getId)
                    .toList();
            if (ids.isEmpty()) {
                break;
            }

            orderPartsMapper.physicalDeleteByOrderIds(ids);
        }
    }

    /**
     * 物理删除订单关联明细
     *
     * @param orderIds
     */
    public void orderItemClean(List<Long> orderIds) {
        while (true) {
            List<Long> ids = orderItemMapper.selectList(
                            Wrappers.<OrderItemDO>lambdaQuery()
                                    .select(OrderItemDO::getId)
                                    .in(OrderItemDO::getOrderId, orderIds)
                                    .last("limit 1000")
                    ).stream()
                    .map(OrderItemDO::getId)
                    .toList();
            if (ids.isEmpty()) {
                break;
            }

            orderItemMapper.physicalDeleteByOrderIds(ids);
        }
    }

    /**
     * 物理删除订单板件
     *
     * @param orderIds
     */
    public void plateClean(List<Long> orderIds) {
        while (true) {
            List<Long> ids = plateMapper.selectList(
                            Wrappers.<PlateDO>lambdaQuery()
                                    .select(PlateDO::getId)
                                    .in(PlateDO::getOrderId, orderIds)
                                    .last("limit 1000")
                    ).stream()
                    .map(PlateDO::getId)
                    .toList();
            if (ids.isEmpty()) {
                break;
            }

            plateMapper.physicalDeleteByOrderIds(ids);
        }
    }

    /**
     * 物理删除订单部件
     *
     * @param orderIds
     */
    public void orderComponentClean(List<Long> orderIds) {
        while (true) {
            List<Long> ids = orderComponentMapper.selectList(
                            Wrappers.<OrderComponentDO>lambdaQuery()
                                    .select(OrderComponentDO::getId)
                                    .in(OrderComponentDO::getOrderId, orderIds)
                                    .last("limit 1000")
                    ).stream()
                    .map(OrderComponentDO::getId)
                    .toList();
            if (ids.isEmpty()) {
                break;
            }

            orderComponentMapper.physicalDeleteByOrderIds(ids);
        }
    }

    /**
     * 物理删除订单
     *
     * @param orderIds
     */
    public void orderClean(List<Long> orderIds) {
        while (true) {
            List<Long> ids = orderMapper.selectList(
                            Wrappers.<OrderDO>lambdaQuery()
                                    .select(OrderDO::getId)
                                    .in(OrderDO::getId, orderIds)
                                    .last("limit 1000")
                    ).stream()
                    .map(OrderDO::getId)
                    .toList();
            if (ids.isEmpty()) {
                break;
            }

            orderMapper.physicalDeleteByOrderIds(ids);
        }
    }
}