package com.hdkj.lt.bf.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdkj.lt.base.exception.BusinessException;
import com.hdkj.lt.bf.constants.TransferSchemeConstants;
import com.hdkj.lt.bf.entity.FhzgPlanPowerCut;
import com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeCheckCountResultDTO;
import com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeDTO;
import com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeTransferSituationDTO;
import com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeUpdateReqDTO;
import com.hdkj.lt.bf.mapper.FhzgPlanTransferSchemeMapper;
import com.hdkj.lt.bf.service.*;
import com.hdkj.lt.core.bizms.modle.dto.TransferSchemeEvaluationReqDTO;
import com.hdkj.lt.core.bizms.modle.po.plan.FhzgPlanAwaitTransferUsers;
import com.hdkj.lt.core.bizms.modle.po.plan.FhzgPlanTransferScheme;
import com.hdkj.lt.core.bizms.modle.po.plan.FhzgPlanTransferSchemeUsers;
import com.hdkj.lt.modle.dto.jsty.AllSwitchInfoListDTO;
import com.hdkj.lt.modle.dto.jsty.XferPlanDTO;
import com.hdkj.lt.utils.math.DecimalUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author luorui
 * @date 2025/5/14 16:37
 * 计划停电转供方案查询
 */
@Service
@Slf4j
public class FhzgPlanTransferSchemeServiceImpl extends ServiceImpl<FhzgPlanTransferSchemeMapper, FhzgPlanTransferScheme> implements FhzgPlanTransferSchemeService {

    @Autowired
    FhzgPlanTransferSchemeMapper fhzgPlanTransferSchemeMapper;

    @Autowired
    FhzgPlanTransferSchemeLoopCloseCheckService fhzgPlanTransferSchemeLoopCloseCheckService;

    @Autowired
    FhzgPlanTransferSchemeFinalStateCheckService fhzgPlanTransferSchemeFinalStateCheckService;

    @Autowired
    FhzgPlanPowerCutService fhzgPlanPowerCutService;

    @Autowired
    FhzgPlanAwaitTransferUsersService fhzgPlanAwaitTransferUsersService;

    @Autowired
    FhzgPlanTransferSchemeUsersService fhzgPlanTransferSchemeUsersService;


    /**
     * @author luorui
     * @date 2025/5/14 16:57
     * @discription 根据计划和，方案类型（推荐方案/校验失败方案） 查询方案列表
     * 1.根据计划和方案类型（推荐方案/校验失败方案）查询出组合方案id集合
     * 2.根据组合方案id集合 查询出来子方案集合
     * 3.将子方案按组合方案id分组分别统计字段属性
     **/
    @Override
    public List<FhzgPlanTransferSchemeDTO> getTransferSchemeListByPlanId(FhzgPlanTransferScheme fhzgPlanTransferScheme) {
        Long planId = fhzgPlanTransferScheme.getPlanId();
        String schemeType = fhzgPlanTransferScheme.getSchemeType();
        if (Objects.isNull(planId)) {
            throw new BusinessException("计划编码不能为空");
        }
//        if (StrUtil.isBlank(schemeType)) {
//            throw new BusinessException("计划类型不能为空");//推荐、校验不通过
//        }
        log.info("查询请求参数planId：{}，schemeType：{}", planId, schemeType);
        /**1.根据计划和方案类型（推荐方案/校验失败方案）查询出组合方案id集合*/
        List<FhzgPlanTransferSchemeDTO> fhzgPlanTransferSchemeDTOList = fhzgPlanTransferSchemeMapper.getFhzgPlanTransferSchemeByPlanId(fhzgPlanTransferScheme);
        fhzgPlanTransferSchemeDTOList.forEach(i->i.setFeasibleTransfer(i.getFeasibleTransfer().multiply(new BigDecimal("1000"))));
        return fhzgPlanTransferSchemeDTOList;
    }

    /**
     * @author luorui
     * @date 2025/5/15 15:53
     * @discription 更新停电计划下的方案状态未选定/取消选定
     * <p>
     * <p>
     * 1.如果是选定切换成未选定，更新当前这条数据
     * 2.查询计划下的所有校验通过的组合方案Id
     * 3.如果是未选定切换成选定，更新当前数据为选定，同事更新其他数据为未选定
     * 4.更新对应的计划数据的状态
     **/
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public Integer updateSchemeState(FhzgPlanTransferSchemeUpdateReqDTO fhzgPlanTransferSchemeUpdateReqDTO) {
        Long id = fhzgPlanTransferSchemeUpdateReqDTO.getId();
        Long planId = fhzgPlanTransferSchemeUpdateReqDTO.getPlanId();
        String schemeState = fhzgPlanTransferSchemeUpdateReqDTO.getSchemeState();
        if (Objects.isNull(id)) {
            throw new BusinessException("主键不能为空");
        }
        if (Objects.isNull(planId)) {
            throw new BusinessException("计划类型不能为空");
        }
        if (StrUtil.isBlank(schemeState)) {
            throw new BusinessException("方案选定状态不能为空");
        }
        Integer result = 0;
        switch (schemeState) {
            case TransferSchemeConstants.SchemeState.UN_CHOOSE:
                /**1如果是选定切换成未选定，更新当前这条数据*/
                result = fhzgPlanTransferSchemeMapper.updateFhzgPlanTransferSchemeState(id, schemeState);
                //更新计划的方案状态为"未选定"
                updateSchemeState(planId, TransferSchemeConstants.SchemeState.UN_CHOOSE);
                break;
            case TransferSchemeConstants.SchemeState.CHOOSE:
                result = fhzgPlanTransferSchemeMapper.updateFhzgPlanTransferSchemeState(id, schemeState);//更新当前方案为选定
                /**2.查询计划下的所有校验通过的组合方案Id*/
                FhzgPlanTransferScheme fhzgPlanTransferScheme = new FhzgPlanTransferScheme();
                fhzgPlanTransferScheme.setPlanId(planId);
                List<FhzgPlanTransferSchemeDTO> fhzgPlanTransferSchemeCheckResultDTOList = fhzgPlanTransferSchemeMapper.getFhzgPlanTransferSchemeByPlanId(fhzgPlanTransferScheme);
                if (CollUtil.isNotEmpty(fhzgPlanTransferSchemeCheckResultDTOList)) {
                    Set<Long> idSet = fhzgPlanTransferSchemeCheckResultDTOList.stream().map(FhzgPlanTransferSchemeDTO::getId).collect(Collectors.toSet());
                    /** 3.如果是未选定切换成选定，更新当前数据为选定，同事更新其他数据为未选定*/
                    idSet.remove(id);//排除当前id
                    //更新其他方案为未选定
                    if (CollUtil.isNotEmpty(idSet)) {
                        fhzgPlanTransferSchemeMapper.updateFhzgPlanTransferSchemeStateBatch(idSet, TransferSchemeConstants.SchemeState.UN_CHOOSE);
                    }
                }
                //更新计划的方案状态为"已选定"
                updateSchemeState(planId, TransferSchemeConstants.SchemeState.CHOOSE);
                break;
            default:
                throw new BusinessException("方案选定状态不能枚举不正确");
        }
        return result;
    }

    private Integer updateSchemeState(Long planId, String schemeState) {
        FhzgPlanPowerCut obj = new FhzgPlanPowerCut();
        obj.setId(planId);
        obj.setSchemeState(schemeState);
        return fhzgPlanPowerCutService.updateSchemeState(obj);
    }

    /**
     * @author luorui
     * @date 2025/5/16 15:01
     * @discription 查询停电计划下的推荐方案和不通过方案数量
     **/
    @Override
    public List<FhzgPlanTransferSchemeCheckCountResultDTO> getTransferSchemeCheckResultCountByPlanId(FhzgPlanTransferScheme fhzgPlanTransferScheme) {
        if (Objects.isNull(fhzgPlanTransferScheme.getPlanId())) {
            throw new BusinessException("停电计划planId为空");
        }
        List<FhzgPlanTransferSchemeCheckCountResultDTO> countResultDTOList = new ArrayList<>();
        FhzgPlanTransferSchemeCheckCountResultDTO resultSafe = new FhzgPlanTransferSchemeCheckCountResultDTO();
        resultSafe.setSchemeCheck(TransferSchemeConstants.SchemeType.SAFE);
        resultSafe.setCount(0);
        countResultDTOList.add(resultSafe);
        FhzgPlanTransferSchemeCheckCountResultDTO resultUnsafe = new FhzgPlanTransferSchemeCheckCountResultDTO();
        resultUnsafe.setSchemeCheck(TransferSchemeConstants.SchemeType.UNSAFE);
        resultUnsafe.setCount(0);
        countResultDTOList.add(resultUnsafe);
        //方案类型schemeType：1-推荐方案，0-校验失败方案。判断方式：区域方案只要有一个方案安全校验通过则组合方案为推荐方案，否则为校验失败方案
        List<FhzgPlanTransferSchemeCheckCountResultDTO> fhzgPlanTransferSchemeCheckResultDTOList = fhzgPlanTransferSchemeMapper.countSchemeCheckByPlanId(fhzgPlanTransferScheme);
        if (CollUtil.isNotEmpty(fhzgPlanTransferSchemeCheckResultDTOList)) {
            Map<String, Integer> countResultMap = fhzgPlanTransferSchemeCheckResultDTOList.stream().collect(Collectors.toMap(FhzgPlanTransferSchemeCheckCountResultDTO::getSchemeCheck, FhzgPlanTransferSchemeCheckCountResultDTO::getCount, (k1, k2) -> k1));
            countResultDTOList.forEach(e -> {
                Integer count = countResultMap.get(e.getSchemeCheck());
                e.setCount(Objects.isNull(count) ? 0 : count);
            });
        }
//        FhzgPlanTransferSchemeCheckResultDTO fhzgPlanTransferSchemeCheckResultDTO = fhzgPlanTransferSchemeMapper.countSchemeTypeByPlanId(fhzgPlanTransferScheme);
//        Integer countCheckTrue = fhzgPlanTransferSchemeCheckResultDTO.getCountCheckTrue();
//        Integer countCheckFalse = fhzgPlanTransferSchemeCheckResultDTO.getCountCheckFalse();
//        List<FhzgPlanTransferSchemeCheckCountResultDTO> countResultDTOList = new ArrayList<>();
//        FhzgPlanTransferSchemeCheckCountResultDTO resultSafe = new FhzgPlanTransferSchemeCheckCountResultDTO();
//        resultSafe.setSchemeCheck(TransferSchemeConstants.SchemeType.SAFE);
//        resultSafe.setCount(Objects.isNull(countCheckTrue) ? 0 : countCheckTrue);
//        countResultDTOList.add(resultSafe);
//        FhzgPlanTransferSchemeCheckCountResultDTO resultUnsafe = new FhzgPlanTransferSchemeCheckCountResultDTO();
//        resultUnsafe.setSchemeCheck(TransferSchemeConstants.SchemeType.UNSAFE);
//        resultUnsafe.setCount(Objects.isNull(countCheckFalse) ? 0 : countCheckFalse);
//        countResultDTOList.add(resultUnsafe);
        return countResultDTOList;
    }

    /**
     * @author luorui
     * @date 2025/5/26 16:59
     * @discription 查询方案的转供情况
     **/
    @Override
    public FhzgPlanTransferSchemeTransferSituationDTO getTransferSchemeSituationById(TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        Long planId = transferSchemeEvaluationReqDTO.getPlanId();
        Long schemeId = transferSchemeEvaluationReqDTO.getSchemeId();
        if (Objects.isNull(planId)) {
            throw new BusinessException("计划编码不能为空planId");
        }
        if (Objects.isNull(schemeId)) {
            throw new BusinessException("方案编码不能为空schemeId");
        }
        //1.查询待转供用户信息
        //2.查询损失用户信息
        //3.待转供数据 - 损失的数据 = 可转供的数据
        Map<String, Object> planIdColumnMap = new HashMap<>();
        planIdColumnMap.put("plan_id", planId);
        List<FhzgPlanAwaitTransferUsers> awaitTransferUserList = fhzgPlanAwaitTransferUsersService.getBaseMapper().selectByMap(planIdColumnMap);
        Map<String, Object> schemeIdColumnMap = new HashMap<>();
        schemeIdColumnMap.put("scheme_id", schemeId);
        List<FhzgPlanTransferSchemeUsers> schemeUsersList = fhzgPlanTransferSchemeUsersService.getBaseMapper().selectByMap(schemeIdColumnMap);

        //方案的损失用户(不可转供户数)
        Long loseUsers = schemeUsersList.stream().filter(e -> StrUtil.equals(e.getDataType(), "1")).count();
        //不可转供负荷
        BigDecimal loseLoad = schemeUsersList.stream().filter(e -> StrUtil.equals(e.getDataType(), "1")).filter(e -> !Objects.isNull(e.getActivePower())).map(FhzgPlanTransferSchemeUsers::getActivePower).reduce(BigDecimal.ZERO, BigDecimal::add);
        //不可转供重要用户
        Long nonCriticalUser = schemeUsersList.stream().filter(e -> StrUtil.equals(e.getDataType(), "1") && StrUtil.equals(e.getIsCriticalUser(), "1")).count();
        //不可转供重要用户负荷
        BigDecimal nonCriticalUserLoad = schemeUsersList.stream().filter(e -> StrUtil.equals(e.getDataType(), "1") && StrUtil.equals(e.getIsCriticalUser(), "1")).filter(e -> !Objects.isNull(e.getActivePower())).map(FhzgPlanTransferSchemeUsers::getActivePower).reduce(BigDecimal.ZERO, BigDecimal::add);
        //不可转供敏感用户
        Long nonSensitiveUser = schemeUsersList.stream().filter(e -> StrUtil.equals(e.getDataType(), "1") && StrUtil.equals(e.getIsSensitiveUser(), "1")).count();
        //不可转供敏感用户负荷
        BigDecimal nonSensitiveUserLoad = schemeUsersList.stream().filter(e -> StrUtil.equals(e.getDataType(), "1") && StrUtil.equals(e.getIsSensitiveUser(), "1")).filter(e -> !Objects.isNull(e.getActivePower())).map(FhzgPlanTransferSchemeUsers::getActivePower).reduce(BigDecimal.ZERO, BigDecimal::add);
        //可转供重要用户  待转供重要用户-不可转供重要
        Long awaitCriticalUser = awaitTransferUserList.stream().filter(e -> StrUtil.equals(e.getIsCriticalUser(), "1")).count();
        Long canCriticalUser = awaitCriticalUser - nonCriticalUser;
        //可转供重要用户 负荷  待转供重要负荷-损失重要负荷
        BigDecimal awaitCriticalLoad = awaitTransferUserList.stream().filter(e -> StrUtil.equals(e.getIsCriticalUser(), "1")).filter(e -> !Objects.isNull(e.getUserLoads())).map(FhzgPlanAwaitTransferUsers::getUserLoads).reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal canCriticalLoad = awaitCriticalLoad == null ? null : awaitCriticalLoad.subtract(nonCriticalUserLoad);

        //可转供敏感用户 待转供敏感用户-不可转供敏感
        Long awaitSensitiveUser = awaitTransferUserList.stream().filter(e -> StrUtil.equals(e.getIsSensitiveUser(), "1")).count();
        Long canSensitiveUser = awaitSensitiveUser - nonSensitiveUser;

        //可转供敏感用户 负荷  待转供敏感负荷-损失敏感负荷
        BigDecimal awaitSensitiveLoad = awaitTransferUserList.stream().filter(e -> StrUtil.equals(e.getIsSensitiveUser(), "1")).filter(e -> !Objects.isNull(e.getUserLoads())).map(FhzgPlanAwaitTransferUsers::getUserLoads).reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal canSensitiveLoad = awaitSensitiveLoad == null ? null : awaitSensitiveLoad.subtract(nonSensitiveUserLoad);

        //可转供户数 待转供用户-损失用户
        Integer awaitUsers = awaitTransferUserList.size();
        Long canTransferUser = awaitUsers - loseUsers;
        //可转供负荷 待转供负荷-损失负荷
        BigDecimal awaitLoad = awaitTransferUserList.stream().filter(e -> !Objects.isNull(e.getUserLoads())).map(FhzgPlanAwaitTransferUsers::getUserLoads).reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal canLoad = awaitLoad == null ? null : awaitLoad.subtract(loseLoad);

        //不可转供保电用户数
        Long nonProtectUser = schemeUsersList.stream().filter(e -> StrUtil.equals(e.getDataType(), "1") && StrUtil.equals(e.getIsProtectPower(), "1")).count();
        //不可转供保电用户负荷
        BigDecimal nonProtectLoad = schemeUsersList.stream().filter(e -> StrUtil.equals(e.getDataType(), "1") && StrUtil.equals(e.getIsProtectPower(), "1")).filter(e -> !Objects.isNull(e.getActivePower())).map(FhzgPlanTransferSchemeUsers::getActivePower).reduce(BigDecimal.ZERO, BigDecimal::add);

        //可转供保电用户数
        Long canTansferProtectUsers = awaitTransferUserList.stream().filter(e -> StrUtil.equals(e.getIsProtectPower(), "1")).count() - nonProtectUser;
        //可转供保电用户负荷
        BigDecimal canTansferProtectLoad = awaitTransferUserList.stream().filter(e -> StrUtil.equals(e.getIsProtectPower(), "1")).filter(e -> !Objects.isNull(e.getUserLoads())).map(FhzgPlanAwaitTransferUsers::getUserLoads).reduce(BigDecimal.ZERO, BigDecimal::add).subtract(nonProtectLoad);


        FhzgPlanTransferSchemeTransferSituationDTO fhzgPlanTransferSchemeTransferSituationDTO = new FhzgPlanTransferSchemeTransferSituationDTO();
        fhzgPlanTransferSchemeTransferSituationDTO.setTransferableLoad(canLoad.multiply(new BigDecimal("1000")));//可转供负荷
        fhzgPlanTransferSchemeTransferSituationDTO.setTransferableUsers(canTransferUser == null ? 0 : canTransferUser.intValue());//可转供户数
        fhzgPlanTransferSchemeTransferSituationDTO.setSensitiveTransferableLoad(canSensitiveLoad.multiply(new BigDecimal("1000"))); //可转供敏感用户负荷
        fhzgPlanTransferSchemeTransferSituationDTO.setSensitiveTransferableUsers(canSensitiveUser == null ? 0 : canSensitiveUser.intValue()); //可转供敏感户数
        fhzgPlanTransferSchemeTransferSituationDTO.setImportantTransferableLoad(canCriticalLoad.multiply(new BigDecimal("1000")));//可转供重要负荷
        fhzgPlanTransferSchemeTransferSituationDTO.setImportantTransferableUsers(canCriticalUser == null ? 0 : canCriticalUser.intValue()); //可转供重要户数
        fhzgPlanTransferSchemeTransferSituationDTO.setNonTransferableLoad(loseLoad.multiply(new BigDecimal("1000"))); //不可转供负荷
        fhzgPlanTransferSchemeTransferSituationDTO.setNonTransferableUsers(loseUsers == null ? 0 : loseUsers.intValue());//不可转供户数
        fhzgPlanTransferSchemeTransferSituationDTO.setSensitiveNonTransferableLoad(nonSensitiveUserLoad.multiply(new BigDecimal("1000")));//不可转供敏感用户负荷
        fhzgPlanTransferSchemeTransferSituationDTO.setSensitiveNonTransferableUsers(nonSensitiveUser == null ? 0 : nonSensitiveUser.intValue());//不可转供敏感户数
        fhzgPlanTransferSchemeTransferSituationDTO.setImportantNonTransferableLoad(nonCriticalUserLoad.multiply(new BigDecimal("1000"))); //不可转供重要负荷
        fhzgPlanTransferSchemeTransferSituationDTO.setImportantNonTransferableUsers(nonCriticalUser == null ? 0 : nonCriticalUser.intValue());  //不可转供重要户数

        fhzgPlanTransferSchemeTransferSituationDTO.setSecuredTransferableUsers(canTansferProtectUsers == null ? 0 : canTansferProtectUsers.intValue());
        fhzgPlanTransferSchemeTransferSituationDTO.setSecuredTransferableLoad(canTansferProtectLoad.multiply(new BigDecimal("1000")));
        fhzgPlanTransferSchemeTransferSituationDTO.setSecuredNonTransferableUsers(nonProtectUser == null ? 0 : nonProtectUser.intValue());
        fhzgPlanTransferSchemeTransferSituationDTO.setSecuredNonTransferableLoad(nonProtectLoad.multiply(new BigDecimal("1000")));

        fhzgPlanTransferSchemeTransferSituationDTO.setSchemeId(schemeId);
        //损失户数
        fhzgPlanTransferSchemeTransferSituationDTO.setLoseUsers(loseUsers);
        return fhzgPlanTransferSchemeTransferSituationDTO;
    }


    /**
     * @author luorui
     * @date 2025/5/15 14:49
     * @discription 计算组合属性字段值
     **/
    private List<FhzgPlanTransferSchemeDTO> calculateAttr(List<FhzgPlanTransferSchemeDTO> fhzgPlanTransferSchemeDTOList) {
        List<FhzgPlanTransferSchemeDTO> combinationSchemeDTOList = new ArrayList<>();
        if (CollUtil.isNotEmpty(fhzgPlanTransferSchemeDTOList)) {
            //分组统计 ，开关动作次数，负荷恢复，损失时户
            Map<Long, FhzgPlanTransferSchemeDTO> resultMap = fhzgPlanTransferSchemeDTOList.stream().collect(Collectors.groupingBy(FhzgPlanTransferSchemeDTO::getId, Collectors.collectingAndThen(
                    Collectors.toList(), list -> {
                        //开关动作次数
                        Integer switchOperationCount = list.stream().mapToInt(FhzgPlanTransferSchemeDTO::getSwitchOperationCount).sum();
                        //负荷恢复,累加feasibleTransfer/累加totalTransfer
                        BigDecimal feasibleTransfer = list.stream().map(FhzgPlanTransferSchemeDTO::getFeasibleTransfer).reduce(BigDecimal.ZERO, BigDecimal::add);
                        BigDecimal totalTransfer = list.stream().map(FhzgPlanTransferSchemeDTO::getTotalTransfer).reduce(BigDecimal.ZERO, BigDecimal::add);
                        BigDecimal loadRecovery = DecimalUtils.divide(totalTransfer, feasibleTransfer, 2, RoundingMode.HALF_UP);
                        //损失时户 累加
                        BigDecimal lossCustHours = list.stream().map(FhzgPlanTransferSchemeDTO::getLossCustHours).reduce(BigDecimal.ZERO, BigDecimal::add);

                        FhzgPlanTransferSchemeDTO fhzgPlanTransferSchemeDTO = new FhzgPlanTransferSchemeDTO();
                        fhzgPlanTransferSchemeDTO.setSwitchOperationCount(switchOperationCount);
                        fhzgPlanTransferSchemeDTO.setLoadRecovery(loadRecovery);
                        fhzgPlanTransferSchemeDTO.setLossCustHours(lossCustHours);
                        fhzgPlanTransferSchemeDTO.setId(list.get(0).getId());
                        fhzgPlanTransferSchemeDTO.setSchemeState(list.get(0).getSchemeState());
                        fhzgPlanTransferSchemeDTO.setPlanId(list.get(0).getPlanId());
                        return fhzgPlanTransferSchemeDTO;
                    }
            )));
            combinationSchemeDTOList = new ArrayList<>(resultMap.values());
        }
        return combinationSchemeDTOList;
    }

    @Override
    public List<AllSwitchInfoListDTO> getAllSwitchBySchemeId(Long schemeId) {
        FhzgPlanTransferScheme planScheme = this.getById(schemeId);
        String rowJson = planScheme.getRowJson();
        XferPlanDTO xferPlanDTO = JSON.parseObject(rowJson, XferPlanDTO.class);
        return xferPlanDTO.getAllSwitchInfoList();
    }
}
