package com.muchinfo.mtp3century.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.muchinfo.mtp3century.service.ITradingMarketSetService;
import com.muchinfo.mtp3century.utils.AjaxResult;
import com.muchinfo.mtp3common.enumtype.Constants;
import com.muchinfo.mtp3common.enumtype.MessageType;
import com.muchinfo.mtp3common.vo.PageResult;
import com.muchinfo.mtp3interface.mapper.*;
import com.muchinfo.mtp3pojos.entity.*;
import com.muchinfo.mtp3pojos.vo.tradingmarket.QuoteSourceGroupRunStepParam;
import com.muchinfo.mtp3pojos.vo.tradingmarket.TradingGroupSetResult;
import com.muchinfo.mtp3pojos.vo.tradingmarket.TradingMarketSetGroupConfigParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;

@Service
public class TradingMarketSetServiceImpl implements ITradingMarketSetService {

    private final Logger log = LoggerFactory.getLogger(this.getClass());
    @Resource
    private ISummertimegroupMapper iSummertimegroupMapper;
    @Resource
    private IQuotesourcegroupMapper iQuotesourcegroupMapper;
    @Resource
    private ISummertimegroupconfigMapper iSummertimegroupconfigMapper;
    @Resource
    private IGoodsgroupMapper iGoodsgroupMapper;
    @Resource
    private IExternalexchangeMapper iExternalexchangeMapper;
    @Resource
    private IQuotesourcegrouprunstepMapper iQuotesourcegrouprunstepMapper;

    @Override
    public PageResult<Summertimegroup> querysummertimegroup(Integer pageNum, Integer pageSize, HttpServletRequest request) {
        PageResult<Summertimegroup> pageResult = new PageResult<>();
        IPage<Summertimegroup> page = new Page<>(pageNum, pageSize);
        IPage<Summertimegroup> resultIPage = iSummertimegroupMapper.selectPage(page, new QueryWrapper<>());
        pageResult.setCode(Constants.Success_Code_Design);
        pageResult.setMessage(AjaxResult.dealMsg(MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language")));
        pageResult.setPages(resultIPage.getPages());
        pageResult.setCurrent(resultIPage.getCurrent());
        pageResult.setTotal(resultIPage.getTotal());
        pageResult.setPageSize(resultIPage.getSize());
        pageResult.setData(resultIPage.getRecords());
        return pageResult;
    }

    @Override
    public AjaxResult summertimegroupAdd(Summertimegroup param, HttpServletRequest request) {
        //验证名称
        Summertimegroup g = iSummertimegroupMapper.selectOne(new QueryWrapper<Summertimegroup>().eq("groupName", param.getGroupname()));
        if (g != null) {
            if (param.getAutoid() == null || !param.getAutoid().equals(g.getAutoid())) {
                return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM049.getCode(), request.getHeader("Accept-Language"));
            }
        }

        if (param.getAutoid() == null) {
            iSummertimegroupMapper.insert(param);
        } else {
            Summertimegroup summertimegroup = iSummertimegroupMapper.selectOne(new QueryWrapper<Summertimegroup>().eq("autoid", param.getAutoid()));
            summertimegroup.setGroupname(param.getGroupname());
            iSummertimegroupMapper.updateById(summertimegroup);
        }
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public AjaxResult deleteGroup(Long autoId, HttpServletRequest request) {
        Summertimegroup timeGroup = iSummertimegroupMapper.selectOne(new QueryWrapper<Summertimegroup>().eq("autoid", autoId));
        //查询行情源分组中是否引用此夏令时分组 若引用，则不能删除
        List<Quotesourcegroup> quoteSourceGroupLsit = iQuotesourcegroupMapper.selectList(new QueryWrapper<Quotesourcegroup>()
                .eq("summerTimeGroupId", timeGroup.getAutoid()));
        if (CollectionUtils.isNotEmpty(quoteSourceGroupLsit)) {
            return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM050.getCode(), request.getHeader("Accept-Language"));
        }
        //查询此分组下是否存在时间配置 如无，直接删除，否则返回提示
        List<Summertimegroupconfig> summerTimeGroupConfig = iSummertimegroupconfigMapper.selectList(new QueryWrapper<Summertimegroupconfig>()
                .eq("groupid", timeGroup.getAutoid()));
        if (CollectionUtils.isNotEmpty(summerTimeGroupConfig)) {
            return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM051.getCode(), request.getHeader("Accept-Language"));
        }
        iSummertimegroupMapper.deleteById(timeGroup);
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public PageResult<Summertimegroupconfig> queryConfig(TradingMarketSetGroupConfigParam param, HttpServletRequest request) {
        PageResult<Summertimegroupconfig> pageResult = new PageResult<>();
        IPage<Summertimegroupconfig> page = new Page<>(param.getPageNum(), param.getPageSize());
        IPage<Summertimegroupconfig> resultIPage = iSummertimegroupconfigMapper.selectPage(page, new QueryWrapper<Summertimegroupconfig>()
                .eq("groupid", param.getAoutid())
                .eq("groupname", param.getGroupName())
                .orderByDesc("groupid"));
        pageResult.setCode(Constants.Success_Code_Design);
        pageResult.setMessage(AjaxResult.dealMsg(MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language")));
        pageResult.setPages(resultIPage.getPages());
        pageResult.setCurrent(resultIPage.getCurrent());
        pageResult.setTotal(resultIPage.getTotal());
        pageResult.setPageSize(resultIPage.getSize());
        pageResult.setData(resultIPage.getRecords());
        return pageResult;
    }

    @Override
    public AjaxResult summertimegroupConfigAdd(Summertimegroupconfig param, HttpServletRequest request) {
        //验证时间
        Summertimegroupconfig g = iSummertimegroupconfigMapper.selectOne(new QueryWrapper<Summertimegroupconfig>()
                .eq("groupid", param.getGroupid())
                .eq("summeryear", param.getSummeryear()));
        if (g != null) {
            if (param.getOldSummerYear() != null) {
                if (param.getSummeryear() == null || !param.getOldSummerYear().equals(g.getSummeryear())) {
                    return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM052.getCode(), request.getHeader("Accept-Language"));
                }
            } else {
                return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM052.getCode(), request.getHeader("Accept-Language"));
            }
        }

        if (param.getOldSummerYear() == null) {
            iSummertimegroupconfigMapper.insert(param);
        } else {
            Summertimegroupconfig summertimegroup = iSummertimegroupconfigMapper.selectOne(new QueryWrapper<Summertimegroupconfig>()
                    .eq("groupid", param.getGroupid())
                    .eq("summeryear", param.getSummeryear()));
            summertimegroup.setSummeryear(param.getSummeryear());
            summertimegroup.setStartdate(param.getStartdate());
            summertimegroup.setEnddate(param.getEnddate());
            iSummertimegroupconfigMapper.update(summertimegroup, new QueryWrapper<Summertimegroupconfig>()
                    .eq("groupid", param.getGroupid())
                    .eq("summeryear", param.getSummeryear()));
        }
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public AjaxResult deleteGroupConfig(Long groupId, Integer summeryear, HttpServletRequest request) {
        iSummertimegroupconfigMapper.delete(new QueryWrapper<Summertimegroupconfig>()
                .eq("groupid", groupId)
                .eq("summeryear", summeryear));
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public PageResult<Quotesourcegroup> quoteSourceGroup(Integer pageNum, Integer pageSize, HttpServletRequest request) {
        PageResult<Quotesourcegroup> pageResult = new PageResult<>();
        IPage<Quotesourcegroup> page = new Page<>(pageNum, pageSize);
        IPage<Quotesourcegroup> resultIPage = iQuotesourcegroupMapper.quoteSourceGroup(page);
        pageResult.setCode(Constants.Success_Code_Design);
        pageResult.setMessage(AjaxResult.dealMsg(MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language")));
        pageResult.setPages(resultIPage.getPages());
        pageResult.setCurrent(resultIPage.getCurrent());
        pageResult.setTotal(resultIPage.getTotal());
        pageResult.setPageSize(resultIPage.getSize());
        pageResult.setData(resultIPage.getRecords());
        return pageResult;
    }

    @Override
    public AjaxResult<Summertimegroup> queryAllSummerTimeGroup(HttpServletRequest request) {
        List<Summertimegroup> list = iSummertimegroupMapper.selectList(new QueryWrapper<>());
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"), list);
    }

    @Override
    public AjaxResult quoteSourceGroupAdd(Quotesourcegroup param, HttpServletRequest request) {
        Quotesourcegroup quotesourcegroup = iQuotesourcegroupMapper.selectOne(new QueryWrapper<Quotesourcegroup>()
                .eq("groupCode", param.getGroupcode()));
        if (quotesourcegroup != null) {
            if (param.getFlag() == 2) {
                if (quotesourcegroup.getAutoid().intValue() != param.getAutoid().intValue()) {
                    return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM053.getCode(), request.getHeader("Accept-Language"));
                }
            } else {
                return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM053.getCode(), request.getHeader("Accept-Language"));
            }
        }

        if (param.getAutoid() == null) {
            iQuotesourcegroupMapper.insert(param);
        } else {
            Quotesourcegroup group = iQuotesourcegroupMapper.selectOne(new QueryWrapper<Quotesourcegroup>().eq("autoid", param.getAutoid()));
            group.setGroupname(param.getGroupname());
            group.setGroupcode(param.getGroupcode());
            group.setRemark(param.getRemark());
            group.setSummertimegroupid(param.getSummertimegroupid());
            iQuotesourcegroupMapper.updateById(group);
        }
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public AjaxResult quoteSourceGroupDelete(Long autoId, HttpServletRequest request) {
        Long usize = iGoodsgroupMapper.selectCount(new QueryWrapper<Goodsgroup>()
                .eq("quoteSourceGroupId", autoId)
                .eq("goodsgroupstatus", 1)
        );
        if (usize != null && usize > 0) {
            return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM054.getCode(), request.getHeader("Accept-Language"));
        }
        iQuotesourcegroupMapper.deleteById(autoId);
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public PageResult<Externalexchange> externalexchange(Integer pageNum, Integer pageSize, HttpServletRequest request) {
        PageResult<Externalexchange> pageResult = new PageResult<>();
        IPage<Externalexchange> page = new Page<>(pageNum, pageSize);
        IPage<Externalexchange> resultIPage = iExternalexchangeMapper.selectPage(page, new QueryWrapper<>());
        pageResult.setCode(Constants.Success_Code_Design);
        pageResult.setMessage(AjaxResult.dealMsg(MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language")));
        pageResult.setPages(resultIPage.getPages());
        pageResult.setCurrent(resultIPage.getCurrent());
        pageResult.setTotal(resultIPage.getTotal());
        pageResult.setPageSize(resultIPage.getSize());
        pageResult.setData(resultIPage.getRecords());
        return pageResult;
    }

    @Override
    public AjaxResult externalexchangeadd(Externalexchange param, HttpServletRequest request) {
        if (param.getAutoid() != null) {
            Externalexchange exchange = iExternalexchangeMapper.selectOne(new QueryWrapper<Externalexchange>()
                    .eq("autoid", param.getAutoid()));
            exchange.setUpdatetime(new Date());
            iExternalexchangeMapper.updateById(exchange);
        } else {
            List<Externalexchange> l = iExternalexchangeMapper.selectList(new QueryWrapper<Externalexchange>()
                    .eq("exexchangecode", param.getExexchangecode()));
            if (CollectionUtils.isNotEmpty(l)) {
                return AjaxResult.error(Constants.Error_Code_Design, MessageType.ORGAN_ERROR_CODE_013.getCode(), request.getHeader("Accept-Language"));
            }
            param.setUpdatetime(new Date());
            iExternalexchangeMapper.insert(param);
        }
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public AjaxResult externalexchangedel(Long autoId, HttpServletRequest request) {
        Long gsize = iGoodsgroupMapper.selectCount(new QueryWrapper<Goodsgroup>().eq("exexchangeid", autoId));
        if (gsize != null && gsize > 0) {
            return AjaxResult.error(Constants.Error_Code_Design, MessageType.MESSAGE_ERROR_CODE_SYSTEM055.getCode(), request.getHeader("Accept-Language"));
        }
        iExternalexchangeMapper.deleteById(autoId);
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public AjaxResult<Quotesourcegroup> quoteSourceGroupAll(HttpServletRequest request) {
        List<Quotesourcegroup> list = iQuotesourcegroupMapper.selectList(new QueryWrapper<>());
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"), list);
    }

    @Override
    public PageResult<TradingGroupSetResult> quoteSourceGroupRunStep(Integer pageNum, Integer pageSize, HttpServletRequest request) {
        PageResult<TradingGroupSetResult> pageResult = new PageResult<>();
        IPage<TradingGroupSetResult> page = new Page<>(pageNum, pageSize);
        IPage<TradingGroupSetResult> resultIPage = iQuotesourcegroupMapper.quoteSourceGroupRunStep(page);
        pageResult.setCode(Constants.Success_Code_Design);
        pageResult.setMessage(AjaxResult.dealMsg(MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language")));
        pageResult.setPages(resultIPage.getPages());
        pageResult.setCurrent(resultIPage.getCurrent());
        pageResult.setTotal(resultIPage.getTotal());
        pageResult.setPageSize(resultIPage.getSize());
        pageResult.setData(resultIPage.getRecords());
        return pageResult;
    }

    @Override
    public AjaxResult quotecopy(HttpServletRequest request, Long source, Long target) {
        //查出源行情源的所有运行计划
        List<Quotesourcegrouprunstep> sourceList = iQuotesourcegrouprunstepMapper.selectList(new QueryWrapper<Quotesourcegrouprunstep>()
                .eq("groupid", source));
        //删除行情源分组的所有计划
        iQuotesourcegrouprunstepMapper.delete(new QueryWrapper<Quotesourcegrouprunstep>().eq("groupid", target));
        //循环将源行情源分组的运行计划插入到目标市场
        if (CollectionUtils.isNotEmpty(sourceList)) {
            for (Quotesourcegrouprunstep mrsd : sourceList) {
                Quotesourcegrouprunstep mrs = new Quotesourcegrouprunstep();
                BeanUtils.copyProperties(mrsd, mrs);
                mrs.setGroupid(target);
                iQuotesourcegrouprunstepMapper.insert(mrs);
            }
        }
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    @Override
    public AjaxResult<Quotesourcegroup> quoteSourceGroupRunStepDetail(Long autoId, HttpServletRequest request) {
        Quotesourcegroup quoteSourceGroup = iQuotesourcegroupMapper.selectOne(new QueryWrapper<Quotesourcegroup>().eq("autoid",autoId));

        List<Quotesourcegrouprunstep> list = iQuotesourcegrouprunstepMapper.selectList(new QueryWrapper<Quotesourcegrouprunstep>()
                .eq("autoid", autoId));
        Map<Integer, List<Quotesourcegrouprunstep>> group = new HashMap<>();
        for(Quotesourcegrouprunstep item:list){
            if(item !=null && item.getTradeweekday() !=null){
                if(group.containsKey(item.getTradeweekday())){
                    group.get(item.getTradeweekday()).add(item);
                }else{
                    List<Quotesourcegrouprunstep> list_ = new ArrayList<>();
                    list_.add(item);
                    group.put(item.getTradeweekday(), list_);
                }
            }
        }
        if(group.containsKey(1)){
            group.put(1,quoteSort(group.get(1)));
        }
        quoteSourceGroup.setGroup(group);
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"), quoteSourceGroup);
    }

    @Override
    public AjaxResult editSave(HttpServletRequest request, QuoteSourceGroupRunStepParam param) {
        //删除旧数据
        iQuotesourcegrouprunstepMapper.delete(new QueryWrapper<Quotesourcegrouprunstep>().eq("groupId", param.getGroupId()));

        if(CollectionUtils.isNotEmpty(param.getQuoteSourceGroupRunStep())) {
            //根据归属日分组
            int sectionid = 0; //时间段号
            Map<Integer, List<Quotesourcegrouprunstep>> group = new HashMap<>();
            for (Quotesourcegrouprunstep item : param.getQuoteSourceGroupRunStep()) {
                if (item != null && item.getTradeweekday() != null) {
                    item.setGroupid(param.getGroupId());
                    //-1:上日 0:当日 1:次日
                    if (item.getTradeweekday().equals(item.getStartweekday())) {
                        item.setStartflag(0);
                    }
                    if (item.getTradeweekday().equals(item.getEndweekday())) {
                        item.setEndflag(0);
                    }

                    if (item.getTradeweekday() == 1) {
                        //  5 6 0 1 2
                        //上日
                        if (item.getStartweekday() == 5 || item.getStartweekday() == 6 || item.getStartweekday() == 0) {
                            item.setStartflag(-1);
                        }
                        if (item.getEndweekday() == 5 || item.getEndweekday() == 6 || item.getEndweekday() == 0) {
                            item.setEndflag(-1);
                        }
                        //次日
                        if (item.getStartweekday() == 2) {
                            item.setStartflag(1);
                        }
                        if (item.getEndweekday() == 2) {
                            item.setEndflag(1);
                        }
                    } else if (item.getTradeweekday() == 5) {
                        //0 1 4 5 6
                        //上日
                        if (item.getStartweekday() == 5
                                || item.getStartweekday() == 4
                                || item.getStartweekday() == 1
                                || item.getStartweekday() == 0) {
                            item.setStartflag(-1);
                        }
                        if (item.getStartweekday() == 5
                                || item.getStartweekday() == 4
                                || item.getStartweekday() == 1
                                || item.getStartweekday() == 0) {
                            item.setEndflag(-1);
                        }
                        //次日
                        if (item.getTradeweekday() < item.getStartweekday()) {
                            item.setStartflag(1);
                        }
                        if (item.getTradeweekday() < item.getEndweekday()) {
                            item.setEndflag(1);
                        }

                    } else {
                        if (item.getTradeweekday() == 6) {//5 6 0
                            //上日
                            if (item.getStartweekday() == 5) {
                                item.setStartflag(-1);
                            }
                            if (item.getEndweekday() == 5) {
                                item.setEndflag(-1);
                            }

                            //次日
                            if (item.getStartweekday() == 0) {
                                item.setStartflag(1);
                            }
                            if (item.getEndweekday() == 0) {
                                item.setEndflag(1);
                            }

                        } else if (item.getTradeweekday() == 0) {//  6 0 1
                            //上日
                            if (item.getStartweekday() == 6) {
                                item.setStartflag(-1);
                            }
                            if (item.getEndweekday() == 6) {
                                item.setEndflag(-1);
                            }

                            //次日
                            if (item.getStartweekday() == 1) {
                                item.setStartflag(1);
                            }
                            if (item.getEndweekday() == 1) {
                                item.setEndflag(1);
                            }
                        } else {
                            //上日
                            if (item.getTradeweekday() > item.getStartweekday()) {
                                item.setStartflag(-1);
                            }
                            if (item.getTradeweekday() > item.getEndweekday()) {
                                item.setEndflag(-1);
                            }
                            //次日
                            if (item.getTradeweekday() < item.getStartweekday()) {
                                item.setStartflag(1);
                            }
                            if (item.getTradeweekday() < item.getEndweekday()) {
                                item.setEndflag(1);
                            }
                        }
                    }

                    if (group.containsKey(item.getTradeweekday())) {
                        if (item.getRunstep() == 0) {
                            item.setSectionid(0);//清盘结算时间  时间段好为0
                        } else {
                            item.setSectionid(++sectionid);////每个交易日的时间段号 ，都从1开始，然后递增
                        }
                        group.get(item.getTradeweekday()).add(item);
                    } else {
                        List<Quotesourcegrouprunstep> list = new ArrayList<>();
                        sectionid = 1; //每个交易日的时间段号 ，都从1开始
                        if (item.getRunstep() == 0) {
                            item.setSectionid(0);
                        } else {
                            item.setSectionid(sectionid);
                        }
                        list.add(item);
                        group.put(item.getTradeweekday(), list);
                    }
                }
            }

            //保存数据，每组都增加 开市、休市记录
            for (Map.Entry<Integer, List<Quotesourcegrouprunstep>> entry : group.entrySet()) {
                List<Quotesourcegrouprunstep> list = entry.getValue();
                int j = list.size() - 1;
                for (int i = 0; i <= j; i++) {
                    Quotesourcegrouprunstep det = list.get(i);
                    iQuotesourcegrouprunstepMapper.insert(det);
                }
            }
        }
        return AjaxResult.success(Constants.Success_Code_Design, MessageType.MESSAGE_CODE_SYSTEM001.getCode(), request.getHeader("Accept-Language"));
    }

    private List<Quotesourcegrouprunstep> quoteSort(List<Quotesourcegrouprunstep> parm){
        if(parm.isEmpty()){
            return parm;
        }
        List<Quotesourcegrouprunstep> newList=new ArrayList<>();
        for(Quotesourcegrouprunstep st:parm){
            if(st.getSectionid()!=0&&(st.getStartweekday()==5||st.getStartweekday()==6||st.getStartweekday()==7)){
                newList.add(st);
            }
        }
        for(Quotesourcegrouprunstep st:parm){
            if(st.getSectionid()!=0&&(st.getStartweekday()==5||st.getStartweekday()==6||st.getStartweekday()==7)){

            }else{
                newList.add(st);
            }
        }
        return newList;
    }
}
