package com.gyee.alarm.service;


import cn.hutool.core.bean.BeanUtil;
import com.gyee.alarm.init.CacheContext;
import com.gyee.alarm.model.auto.*;
import com.gyee.alarm.model.vo.TokenVo;
import com.gyee.alarm.service.auto.ISysUserService;
import com.gyee.alarm.util.DateUtils;
import com.gyee.common.model.StringUtils;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class TokenService {
    @Resource
    private ISysUserService sysUserService;


    public static Map<String, List<ProBasicEquipment>> sessionWtMap = new ConcurrentHashMap<>();
    public static Map<String, List<ProBasicPowerstation>> sessionWpMap = new ConcurrentHashMap<>();
    public static Map<String,  List<ProBasicSubStation> > sessionSubMap = new ConcurrentHashMap<>();
    public static Map<String, List<ProBasicWeatherStation>> sessionWeMap = new ConcurrentHashMap<>();

    public static Map<String, TokenVo> sessionMap=  new ConcurrentHashMap<>();

    public  List<ProBasicEquipment>  getWtls(HttpServletRequest request ) {



        List<ProBasicEquipment> wtlist = new ArrayList<>();
        for(ProBasicEquipment wt:CacheContext.wtls)
        {
            ProBasicEquipment newWt=  new ProBasicEquipment();
            BeanUtil.copyProperties( wt,newWt);
            wtlist.add(newWt);
        }
        return wtlist;
    }

    public  List<ProBasicPowerstation>  getWpls(HttpServletRequest request )
    {


        List<ProBasicPowerstation> wplist=new ArrayList<>();

        List<ProBasicPowerstation> wpls=CacheContext.wpls;
        for(ProBasicPowerstation wp:wpls)
        {
            ProBasicPowerstation newWp=  new ProBasicPowerstation();
            BeanUtil.copyProperties(wp, newWp);
            wplist.add(newWp);
        }
        return wplist;
    }

    public  List<ProBasicSubStation>  getSubwpls(HttpServletRequest request )
    {

        List<ProBasicSubStation> wplist=new ArrayList<>();

        for(ProBasicSubStation subStation:CacheContext.subwpls)
        {
            ProBasicSubStation newSub=  new ProBasicSubStation();
            BeanUtil.copyProperties(subStation, newSub);
            wplist.add(newSub);
        }
        return wplist;
    }


    public   List<ProBasicWeatherStation>  getWeawpls (HttpServletRequest request )
    {

        List<ProBasicWeatherStation> wplist=new ArrayList<>();

        for(ProBasicWeatherStation weatherStation:CacheContext.weawpls)
        {
            ProBasicWeatherStation newWeb=  new ProBasicWeatherStation();
            BeanUtil.copyProperties(weatherStation, newWeb);
            wplist.add(newWeb);
        }
        return wplist;
    }
}
