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

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.enums.OrderPackageTypeEnum;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
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.id.core.util.SnowflakeIdWorker3rd;
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.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.plan.vo.OrderRespVOCopy;
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.orderParts.OrderPartsDO;
import com.cf.imes.module.executor.dal.dataobject.orderParts.PartsDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.executor.dal.dataobject.pack.OrderPackageDO;
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.OrderItemMapper;
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.pack.OrderPackageMapper;
import com.cf.imes.module.executor.dal.mysql.pack.OrderPrepackagedMapper;
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.service.customplateno.CustomPlateNoGenerateService;
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.plan.PlanService;
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.elasticsearch.EsUtils;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataTypeVo;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
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.executor.enums.EsIndexEnum.*;
import static com.cf.imes.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORDER_PLAN_DATA_ERROR;

/**
 * 生产单表 order_{N} Service 实现类
 *
 * @author 晨丰科技
 */
@Service
@Validated
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 OrderPackageMapper orderPackageMapper;

    @Resource
    private OrderPrepackagedMapper orderPrepackagedMapper;

    @Resource
    private OrderInputProcessor orderInputProcessor;

    @Resource
    private IdentifierGenerator identifierGenerator;

    @Resource
    private SnowflakeIdWorker3rd idWorker;

    @Resource
    private PartsMapper partsMapper;

    @Resource
    private CustomPlateNoGenerateService customPlateNoGenerateService;


    @Resource
    private PlanItemMapper planItemMapper;


    @Resource
    private EsUtils esUtils;


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


    public static final Double ZERO = 0.0;

    @Resource
    private PlanService planService;

    @Autowired
    private OrderImportHandlerFactory orderImportHandlerFactory;

    @Override
    public Long createOrder(OrderSaveReqVO createReqVO) {
        //校验手机号是否合法
        validatePhoneNumber(createReqVO.getPhoneNumber());

        //验证自定义单号是否存在，业务员、拆单员是否存在
        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);
        order.setId((Long)identifierGenerator.nextId(null));
        // 默认api类型生产单
        if(ObjectUtil.isNull(order.getDataType())) {
            order.setDataType(DataTypeEnum.API_IMPORT.getStatus());
        }
        orderMapper.insert(order);
        // 返回
        return order.getId();
    }

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

        //校验手机号是否合法
        validatePhoneNumber(updateReqVO.getPhoneNumber());

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

        // 发货日期校验
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        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("");
        }
        orderMapper.updateById(updateObj);
    }

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

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

    @Override
    public List<OrderBodyRespVO> getOrderBody(Long orderId, Integer deleted) {
        return BeanUtils.toBean(orderBodyMapper.selectList(orderId, deleted, getUserOrganId()), OrderBodyRespVO.class);
    }

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

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

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

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

    @Override
    public Map<String, Object> 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);

        // 板材
        List<OrderGoodsRespVO> orderGoodsRespVOS = orderItemMapper.selectGoodsByOrderId(orderId, getUserOrganId(), deleted);

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

        Map<String, Object> map = new HashMap<>();
        map.put("module", orderModuleRespVOList);
        map.put("parts", orderItemDOS);
        map.put("goods", orderGoodsRespVOS);
        map.put("component", orderComponentRespVOS);
        return map;
    }

    @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<OrderRespVOCopy> 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 = BeanUtils.toBean(orderDetail, OrderPlatesDetailReqVO.class);
        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<OrderRespVOCopy> 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

        // 判断生产单的状态和生产单柜体对应的板材是否已经排单
        validateOrderStatus(orderId, roomIds, bodyId, getUserOrganId());

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


        if (!bodyIds.isEmpty()){

            orderBodyMapper.updateDeletedBody(bodyIds, getUserOrganId(), orderId);// 柜体

            orderGroupMapper.updateDeletedGroup(bodyIds, getUserOrganId(), orderId);// 加工组

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


            if (!plateDOList.isEmpty()) {

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

            }

            // 删除配件信息
            List<Long> partsList = orderPartsMapper.selectPartsIdListByBodyId(bodyIds, getUserOrganId(), orderId);

            if (!partsList.isEmpty()){
                // 判断是否含有重复的配件
                Iterator<Long> iterator = partsList.iterator();
                while (iterator.hasNext()) {
                    Long id = iterator.next(); // 配件id判断是否重复
                    // 判断不符合删除配件的规则
                    Integer partsCount = orderItemMapper.countPartsNotId(orderId, new HashSet<>(bodyIds), id, getUserOrganId(), 0);
                    if (partsCount > 0){
                        iterator.remove();
                    }
                }
            }
            if (!partsList.isEmpty()) {
                orderPartsMapper.updateDeletedParts(partsList, getUserOrganId(),orderId);
            }

        }

        int bodyCount = orderBodyMapper.selectBodyCountByDeleted(orderId, getUserOrganId(), 0);

        // 生产单柜体数量判断
        if ( bodyCount == 0  ) {
            orderMapper.updateOrderStatus(orderId, OrderStatusEnum.EMPTY.getStatus(), getUserOrganId());
        }

    }







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

        // 校验存在
        OrderDO orderDO = orderMapper.selectOrderOne(orderId, getUserOrganId());

        AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);


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


        if (!bodyIds.isEmpty()){

            orderBodyMapper.updateNoDeletedBody(bodyIds, getUserOrganId(), orderId);// 柜体
            orderGroupMapper.updateNoDeletedGroup(bodyIds, getUserOrganId(), orderId);// 加工组

            List<PlateDO> plateDOList = plateMapper.selectDeletedPlate(orderId, bodyIds, getUserOrganId());

            // 小板还原
            if (!plateDOList.isEmpty()) {

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

            }

            List<Long> partsList = orderPartsMapper.selectPartsIdListByBodyId(bodyIds, getUserOrganId(), orderId); // 配件
            if (partsList != null && !partsList.isEmpty()){
                orderPartsMapper.updateNoDeletedParts(partsList, getUserOrganId(),orderId);
            }

        }

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

        if(!plateDOS.isEmpty()){
            return;
        }

        int bodyCount = orderBodyMapper.selectBodyCountByDeleted(orderId, getUserOrganId(), 0);

        // 生产单柜体数量判断
        if ( bodyCount != 0  ) {
            orderMapper.updateOrderStatus(orderId, OrderStatusEnum.NEW_ORDER.getStatus(), getUserOrganId());
        }


    }






    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long importApiData(ApiDataTypeVo apiDataTypeVo) {
        OrderDO order = apiDataTypeVo.getOrderDO();
        if (order != null) {
            //判断是否已经导入
//            if (!validateOrderNoExists(order.getApiOrderId(), OrganContextHolder.getOrganId())) {
//                throw exception(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);
        orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, itemDO, goodsDO, plateGoodDOS, partsDOS);
        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);
            orderInputProcessor.batchSaveModel(orderModelDOs);

        }
        if (!partsRemark.isEmpty()) {
            orderInputProcessor.batchSaveOrderPartsModel(partsRemark);
        }

        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);
        orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, itemDO, goodsDO, plateGoodDOS, partsDOList);

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

            saveOrderPlateModel(plateDO,goodsDO,orderModelDOs);
            orderInputProcessor.batchSaveModel(orderModelDOs);

        }
        if (orderPartsRemarks != null && !orderPartsRemarks.isEmpty()) {
            orderInputProcessor.batchSaveOrderPartsModel(orderPartsRemarks);
        }


    }

    @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)) {
            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());
            OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
            response.setContentType("application/octet-stream");
            outputStream.write(buffer);
            outputStream.flush();
        } catch (IOException ex) {
            throw exception(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 exception(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<OrderOverdueRespVO>(orderOverdueVOS.getRecords(), orderOverdueVOS.getTotal());
    }

    @Override
    public PageResult<OrderOverdueRespVO> getOrderNear(PageParam pageParam) {
        PageDTO<OrderOverdueRespVO> page = new PageDTO<>(pageParam.getPageNo(), pageParam.getPageSize());
        LocalDate tomorrow = LocalDate.now().plus(1, ChronoUnit.DAYS);
        // 查询预警单
        IPage<OrderOverdueRespVO> orderNearVOS = orderMapper.selectOrderNear(tomorrow, OrganContextHolder.getOrganId(), page);
        return new PageResult<OrderOverdueRespVO>(orderNearVOS.getRecords(), orderNearVOS.getTotal());
    }

    @Override
    public Integer updateOrderDel(Long orderId, Integer deleted) {
        Integer index = deleted == 1 ? 0 : 1;
        // 校验存在
        OrderDO orderDO = orderMapper.selectOrderOne(orderId, getUserOrganId(), index);
        if (orderDO == null)
            throw exception(ORDER_NOT_EXISTS);
        // 状态排除
        if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.EMPTY.getStatus()) &&
                !Objects.equals(orderDO.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus()))
            throw exception(ORDER_NOT_CANCEL);
        return orderMapper.updateOrderDeleted(orderId, deleted, getUserOrganId());
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void realDeletedOrder(Long orderId) {
        validateOrderExists(orderId, getUserOrganId(), OrderDeletedEnum.DELETED.getStatus());

        // 作废 生产单表，body，group，goods，parts，plate，raw_goods，
        rawGoodsMapper.deleteByOrderId(orderId, getUserOrganId());
        goodsMapper.deleteByOrderId(orderId, getUserOrganId());
        orderItemMapper.deleteByOrderId(orderId, getUserOrganId());
        orderBodyMapper.deleteByOrderId(orderId, getUserOrganId());
        orderGroupMapper.deleteByOrderId(orderId, getUserOrganId());

        orderPartsMapper.deleteByOrderId(orderId, getUserOrganId());
        plateMapper.deleteByOrderId(orderId, getUserOrganId());

        orderMapper.deleteOrder(orderId, getUserOrganId()); // 生产单删除

//        删除板材的造型数据 es
        orderInputProcessor.deleteByOrderId(orderId, ORDER_PLATE_MODEL.getIndex());
//        删除备注信息 es
        orderInputProcessor.deleteByOrderId(orderId, ORDER_PARTS_REMARK_MODEL.getIndex());

    }

    //    生产单是否存在判断
    private void validateOrderExists(Long id, Long organId, Integer deleted) {
        OrderDO orderDO = orderMapper.selectOrderOne(id, organId, deleted);
        if (orderDO == null) {
            throw exception(ORDER_NOT_EXISTS);
        }
    }

    //    校验手机号是否合法
    private void validatePhoneNumber(String phoneNumber) {
        // 定义手机号正则表达式
        String regex = "^1[3-9]\\d{9}$";

        // 编译正则表达式
        Pattern pattern = Pattern.compile(regex);

        // 创建 Matcher 对象
        Matcher matcher = pattern.matcher(phoneNumber);

        // 判断手机号是否匹配正则表达式
        if (!matcher.matches()) {
            throw exception(PHONE_NOT_LAWFUL);
        }
    }

    //    验证自定义单号是否存在---去除本单
    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::getDeleted, false)
                        .eq(OrderDO::getOrganId, OrganContextHolder.getOrganId())) > 0) {
                    throw exception(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::getDeleted, false)
                        .eq(OrderDO::getOrganId, OrganContextHolder.getOrganId())) > 0) {
                    throw exception(CUSTOM_ORDER_EXISTS);
                }
            }
        }
    }

    //    验证柜体是否存在
    private List<Long> validateOrderBodyExists(Long orderId, Long bodyId, Long organId, Set<Long> roomIds, Integer deleted) {

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

        if (roomIds != null && !roomIds.isEmpty()) {
            bodyIds.addAll(orderBodyMapper.selectBodyIdByRoomId(orderId, roomIds, getUserOrganId(),deleted));
        }

        if (bodyId != null && bodyId != 0) {
            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 exception(ORDER_BODY_NOT_EXISTS);
            }

            bodyIds.add(bodyId);
        }

        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 exception(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 exception(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 exception(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 exception(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;
    }

    //    判断生产单状态是否符合(如果已开料，不允许删除)
    private void validateOrderStatus(Long orderId,Set<Long> roomIds, Long bodyId, Long organId) {
        // 校验存在
        OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId);
        if (orderDO == null)
            throw exception(ORDER_NOT_EXISTS);


        if (ObjectUtils.isEmpty(roomIds) && ObjectUtils.isEmpty(bodyId)) {
            throw exception(ORDER_ERROR);
        }

        // 判断小板是否已开料，已开料不允许删除
        List<Long> planIds = orderItemMapper.selectOrderPlanList(orderId,roomIds,bodyId,organId);

        AssertUtils.empty(planIds, PLATE_IS_PLAN);

//        if(CollUtil.isNotEmpty(planIds)) {
//
//            List<PlanDO> planDOS = planMapper.selectPlanStatus(planIds, organId);
//
//            AssertUtils.empty(planDOS, ORDER_PLAN_ERROR);
//
//        }

    }




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


        List<Long> plateIds = plateDOList.stream().map(PlateDO::getId).toList();

        List<Long> goodsIds = plateDOList.stream().map(PlateDO::getGoodsId).distinct().toList();

        // 删除小板的信息 和 排单小板关联表中的小板信息
        plateMapper.updateDeletedPlate(plateIds, getUserOrganId(), orderId);


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

        if(CollUtil.isNotEmpty(orderItemDOS)) {

            List<Long> packIds = orderItemDOS.stream().map(OrderItemDO::getPackageId).distinct().toList();

            orderPackageMapper.updatePackList(orderId, packIds, getUserOrganId());

            orderItemMapper.deletePackList(orderId, packIds, getUserOrganId());

            orderPrepackagedMapper.deletePacked(orderId, getUserOrganId());

            OrderDO orderDO = orderMapper.selectById(orderId);

            AssertUtils.notEmpty(orderDO,ORDER_NOT_EXISTS);

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

            orderMapper.updateById(orderDO);

        }

        // 删除大板
        List<PlateDO> goodsList = plateMapper.selectPlateDeletedStatus(orderId, goodsIds, getUserOrganId());

        List<Long> goodsIdList = goodsList.stream().map(PlateDO::getGoodsId).distinct().toList();

        List<Long> goodsIdDeleted = Stream.concat(
                        goodsIds.stream().filter(str -> !goodsIdList.contains(str)),
                        goodsIdList.stream().filter(str -> !goodsIds.contains(str)))
                .toList();

        if (!goodsIdDeleted.isEmpty()) {

            goodsMapper.updateDeletedById(orderId,goodsIdDeleted, getUserOrganId());

        }


//        if (CollUtil.isNotEmpty(planIds)) {
//
//            planItemMapper.delete(new LambdaQueryWrapperX<PlanItemDO>()
//                    .eq(PlanItemDO::getOrganId, getUserOrganId())
//                    .eq(PlanItemDO::getOrderId, orderId)
//                    .in(PlanItemDO::getPlateId, plateIds)
//                    .in(PlanItemDO::getPlanId, planIds));
//
//            // 删除小板信息需要确认：优化画图的信息是否都在 余料的那个字段里
//
//            // 判断删除的柜体对应的板材是否和排单板材一样
//            List<GoodsDO> goodsDOS = goodsMapper.selectPlanGoodsListByPlanIdList(null,planIds, getUserOrganId());
//
//            // 一样，同时删除排单的信息
//            if (goodsDOS.isEmpty()) {
//                planService.deletePlan(planIds);
//            } else {
//                // 只要有排单，不管删除的柜体的板材数和排单数一样，都要删除排单对应的优化数据（不用这种写法进行删除时，有时会报错，原因目前还没找到）
//                esUtils.deleteEsDocument("planId",planIds,ORDER_REMAIN_PLATE_MODEL);
//            }
//
//        }


    }




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

        List<Long> plateIds = plateDOList.stream().map(PlateDO::getId).toList();

        List<Long> goodsIds = plateDOList.stream().map(PlateDO::getGoodsId).distinct().toList();


        plateMapper.updateNoDeletedPlate(plateIds, getUserOrganId(), orderId);


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


//        // 当大板对应的小板已经排单时，新建相同类型的大板，并将其他未排单的小板对应的大板ID修改为新的大板ID
//        List<GoodsDO> goodsDOList = goodsMapper.selectNoPlanGoodsList(orderId, goodsIds, getUserOrganId());
//
//        List<GoodsDO> goodsList = BeanUtils.toBean(goodsDOList, GoodsDO.class);
//
//        if (!goodsDOList.isEmpty()) {
//
//            // 新增的大板信息
//            List<GoodsDO> list = goodsDOList.stream()
//                    .peek(m -> {
//                        m.setId(null);
//                        m.setPlanId(0L);
//                        m.setCreateTime(LocalDateTime.now());
//                        m.setUpdateTime(LocalDateTime.now());
//                    })
//                    .toList();
//
//            goodsMapper.insertBatch(list);
//
//            // 构建新的数据集，保存新的大板ID和旧的大板ID，大板的实际ID关联这两个信息
//            List<OrderGoodsIds> orderGoodsIds = BeanUtils.toBean(list, OrderGoodsIds.class);
//
//            List<OrderGoodsIds> orderGoodsIdsList = new ArrayList<>();
//
//            for (GoodsDO goodsDO : goodsList) {
//                orderGoodsIdsList.addAll(orderGoodsIds.stream()
//                        .filter(f -> f.getGoodsId().equals(goodsDO.getGoodsId()))
//                        .map(m -> m.setOldId(goodsDO.getId())).toList());
//
//            }
//
//            // 需要修改的小板为未排单的部分，无论其是否删除，都需要修改，但只需修改大板ID即可，其他信息无需修改
//            List<PlateDO> plateDOS = plateMapper.selectNoPlanPlate(orderId, goodsIds, getUserOrganId());
//
//            List<PlateDO> plateList = new ArrayList<>();
//
//            for (OrderGoodsIds ids : orderGoodsIdsList) {
//
//                plateList.addAll(plateDOS.stream()
//                        .filter(f -> f.getGoodsId().equals(ids.getOldId()))
//                        .peek(m -> {
//                            m.setGoodsId(ids.getId());
//                        })
//                        .toList());
//            }
//
//            plateMapper.updateBatch(plateList);
//
//        }

    }



    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.setId(f.getPlateId().toString());
            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(() -> ServiceExceptionUtil.exception(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 exception(ORDER_PLAN_ID_NOT_NULL);
        }

        if (!Objects.isNull(orderId) && !Objects.isNull(planId)) {
            throw exception(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 = esUtils.getEsDocument("orderId","plateId", orderIds,plateIdList, plateIdList.size(), ORDER_PLATE_MODEL.getIndex(), OrderModelDO.class);

        }else {

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

            orderIds.add(orderId);

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

            orderModelDOS = esUtils.getEsDocumentByScroll("orderId", orderIds,1000, ORDER_PLATE_MODEL.getIndex(), OrderModelDO.class);
        }


        AssertUtils.notEmpty(orderIds,ORDER_PLAN_DATA_ERROR);


        // 生产单信息
        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 = esUtils.getEsDocument("planId", planIdList, planIdList.size(), PLAN_ACTUAL_GOODS_MODEL.getIndex(), PlanActualGoodsModelDO.class);

            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<OrderPackageDO> packageDOS = orderPackageMapper.selectPackListByIds(packIds,getUserOrganId());

        labelOrderPlateData.forEach(f->
                f.setPackageSerialNo(
                        packageDOS.stream()
                                .filter(o->o.getId().equals(f.getPackageNo()))
                                .findFirst()
                                .orElse(new OrderPackageDO()).getPackageNo()));

        orderAllData.setPackDataList(labelOrderPackData);


    }


}