package com.pqs9900.controller.business;

import java.io.File;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.njcn.enums.ProjectEnum;
import com.njcn.pojo.commons.RedisDB;
import com.njcn.pojo.system.SubSystem;
import com.njcn.service.system.SystemService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.AppConfig;
import com.njcn.utils.PubUtils;
import com.njcn.utils.SerializeUtil;
import com.njcn.utils.XssFilterUtil;
import com.njcn.utils.redis.JedisManager;

import cn.hutool.core.io.FileUtil;


/**
 * @author hongawen
 * @date 2018/3/26 22:41
 */
@Controller
@RequestMapping("business")
public class BusinessController {

    @Autowired
    private AppConfig appConfig;

    @Resource
    private SystemService systemService;

    @Autowired
    JedisManager jedisManager;
    @GetMapping("/voltageMain")
    public ModelAndView voltageMain() {
        TokenManager.getSession().setAttribute("sysType", "1cfcd6e2-c5fe-4b15-988a-32b90f1170c1");
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.setViewName("main");
        //判断是否需要显示切换系统以及待切换的系统信息
        List<SubSystem> subSystems=systemService.getActiveSystem();
        boolean displayFlag=false;
        for(SubSystem subSystem:subSystems){
            if(!subSystem.getSystemEName().equalsIgnoreCase(ProjectEnum.PQS9200.getItem())&&!subSystem.getSystemEName().equalsIgnoreCase(ProjectEnum.PQS9300.getItem())){

                displayFlag=true;
                modelAndView.addObject("item",subSystem.getSystemEName());
                modelAndView.addObject("name",subSystem.getSystemEName().toUpperCase()+subSystem.getSystemName());
            }
        }
        modelAndView.addObject("displayFlag",displayFlag);
        return modelAndView;
    }

    @GetMapping("/powerMain")
    public ModelAndView powerMain() {
        TokenManager.getSession().setAttribute("sysType", "983f9dfe-4f9a-4c96-89d8-7d425a1f1d6c");
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.setViewName("main");
        //判断是否需要显示切换系统以及待切换的系统信息
        List<SubSystem> subSystems=systemService.getActiveSystem();
        boolean displayFlag=false;
        for(SubSystem subSystem:subSystems){
            if(!subSystem.getSystemEName().equalsIgnoreCase(ProjectEnum.PQS9000.getItem())&&!subSystem.getSystemEName().equalsIgnoreCase(ProjectEnum.PQS9300.getItem())){
                displayFlag=true;
                modelAndView.addObject("item",subSystem.getSystemEName());
                modelAndView.addObject("name",subSystem.getSystemEName().toUpperCase()+subSystem.getSystemName());
            }
        }
        modelAndView.addObject("displayFlag",displayFlag);
        return modelAndView;
    }
    /**
     * 系统管理员
     *
     * @param request
     * @return
     */

    // 跳转用户管理页面
    @RequestMapping(value = "user")
    public String user(HttpServletRequest request) {
        return "business/settings/userManage";
    }

    // 跳转角色管理页面
    @RequestMapping(value = "role")
    public String role(HttpServletRequest request) {
        return "business/settings/roleManage";
    }

    // 跳转变压器台账页面
    @RequestMapping(value = "addTrans")
    public String addTrans(HttpServletRequest request) {
        return "business/settings/addTrans";
    }

    // 跳转变压器台账页面
    @RequestMapping(value = "tflgploy")
    public String tflgploy(HttpServletRequest request) {
        return "business/settings/tfLgPloy";
    }

    // 跳转网站信息页面
    @RequestMapping(value = "webinfo")
    public String webinfo(HttpServletRequest request) {
        return "business/settings/webInfo";
    }

    // 跳转资源信息页面
    @RequestMapping(value = "managelist")
    public String managelist(HttpServletRequest request) {
        return "business/settings/manageList";
    }

    // 跳转资源信息页面
    @RequestMapping(value = "updateManage")
    public String updateManage(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/settings/updateManageList";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    // 跳转到终端维护日志列表
    @GetMapping(value = "terminallog")
    public String terminallog() {
        return "business/device/terminalLogManage";
    }

    //跳转到暂降推送消息日志列表
    @GetMapping(value = "eventlog")
    public String eventlog() {
        return "business/device/eventLogManage";
    }

    // 跳转到数据字典页面
    @RequestMapping(value = "dictype")
    public String dicType(HttpServletRequest request) {
        return "business/settings/dicTypeManage";
    }

    // 跳转到部门管理页面
    @RequestMapping(value = "depets")
    public String depets(HttpServletRequest request) {
        return "business/settings/deptsManage";
    }

    // 跳转机构管理页面
    @RequestMapping(value = "sys")
    public String organization(HttpServletRequest request) {
        return "business/settings/sysManage";
    }

    //跳转到拓扑数据导入页面
    @RequestMapping(value = "importgridtop")
    public String importGridTop(HttpServletRequest request) {
        return "business/settings/importGridTop";
    }

    // 跳转角色列表页面
    @RequestMapping("rolelist")
    public String roleList(HttpServletRequest request) {
        return "business/audit/roleList";
    }

    // 跳转定时器管理界面
    @RequestMapping("timermanage")
    public String timerManage(HttpServletRequest request) {
        return "business/audit/timerManage";
    }

    /**
     * 跳转到新增用户
     */
    @RequestMapping("addUser")
    public String addUser(HttpServletRequest request) {
        return "business/settings/addUser";
    }

    /**
     * 跳转到新增配置
     */
    @RequestMapping("addSys")
    public String addSys(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/settings/addSys";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    @RequestMapping("terminalmaintenance")
    public String terminalmaintenance(HttpServletRequest request) {
        return "business/terminal/terminalMaintenance";
    }

    @GetMapping("offlinedata")
    public String offlinedata() {
        return "business/terminal/offlineData";
    }

    @GetMapping("offpoint")
    public String offpoint() {
        return "business/terminal/offpoint";
    }

    @GetMapping("adddownevent")
    public String downEvents() {
        return "business/terminal/addDownEvent";
    }

    @GetMapping("uploadwave")
    public String uploadWave() {
        return "business/terminal/uploadWave";
    }

    /**
     * 跳转到修改配置
     */
    @RequestMapping("updateSys")
    public String updateSys(HttpServletRequest request) {
        return "business/settings/updateSys";
    }

    /**
     * 跳转到修改用户
     */
    @RequestMapping("updateUser")
    public String updateUser(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/settings/updateUser";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    /**
     * 跳转到修改密码
     */
    @RequestMapping("updatePassWord")
    public String updatePassWord(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/settings/updatePassWord";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    /**
     * 跳转到修改密码
     */
    @RequestMapping("updateAppPassWord")
    public String updateAppPassWord(HttpServletRequest request) {
        return "business/settings/updateAppPassWord";
    }

    /**
     * 跳转新增角色
     */
    @RequestMapping("addrole")
    public String addRole(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/audit/addRole";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    /***
     * 跳转到新增部门
     */
    @RequestMapping("addDept")
    public String addDept(HttpServletRequest request) {
        return "business/settings/addDepts";
    }

    /***
     * 跳转到修改部门
     */
    @RequestMapping("updateDept")
    public String updateDept(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/settings/updateDepts";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    /***
     * 跳转到绑定监测点
     */
    @RequestMapping("deptsLine")
    public String deptsLine(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/settings/deptsLine";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    /***
     * 跳转到新增字典
     */
    @RequestMapping("addData")
    public String addData(HttpServletRequest request) {
        return "business/settings/addData";
    }

    @RequestMapping("updateTrans")
    public String updateTrans(HttpServletRequest request) {
        return "business/settings/updateTrans";
    }

    /***
     * 跳转到新增通用字典
     */
    @RequestMapping("addTypeData")
    public String addTypeData(HttpServletRequest request) {
        return "business/settings/addType";
    }

    /***
     * 跳转到新增通用字典
     */
    @RequestMapping("updateData")
    public String updateData(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/settings/updateData";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    /***
     * 跳转到修改通用字典
     */
    @RequestMapping("updateType")
    public String updateType(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/settings/updateType";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    /**
     * 跳转新增资源
     */
    @RequestMapping("addpermission")
    public String addpermission(HttpServletRequest request) {
        return "business/audit/addPermission";
    }

    /**
     * 跳转资源列表
     */
    @RequestMapping("permissonlist")
    public String permissonList(HttpServletRequest request) {
        return "business/audit/permissionList";
    }

    /**
     * 跳转用户角色分配页面
     */
    @RequestMapping("roledistribute")
    public String roledistribute(HttpServletRequest request) {
        return "business/audit/roleDistribute";
    }

    @RequestMapping("menu")
    public String menu(HttpServletRequest request) {
        return "business/audit/menu";
    }

    @RequestMapping("addChildMenu")
    public String addChildMenu(HttpServletRequest request) {
        return "business/audit/addChildMenu";
    }

    @RequestMapping("menuConfig")
    public String menuConfig(HttpServletRequest request) {
        return "business/audit/menuConfig";
    }

    @RequestMapping("addConfig")
    public String addConfig(HttpServletRequest request) {
        return "business/audit/addConfig";
    }

    /**
     * 跳转分配角色页面
     */
    @RequestMapping("destributerole")
    public String destributerole(HttpServletRequest request) {
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "business/audit/destributeRole";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }

    }

    /**
     * 跳转分配资源页面
     */
    @RequestMapping("permissiondistribute")
    public String permissiondistribute(HttpServletRequest request) {
        return "business/audit/permissionDistribute";
    }

    /**
     * 跳转已有资源页面
     */
    @RequestMapping("viewpermission")
    public String viewpermission(HttpServletRequest request) {
        return "business/audit/viewPermission";
    }

    /**
     * 跳转分配资源页面
     */
    @RequestMapping("destributepermission")
    public String destributepermission(HttpServletRequest request) {
        return "business/audit/destributePermission";
    }

    /**
     * 跳转到上传资源
     */
    @RequestMapping("uploadManageList")
    public String uploadManageList(HttpServletRequest request) {
        return "business/settings/uploadManageList";
    }

    //读取配置文件
    @GetMapping("getWebsocketPort")
    @ResponseBody
    public String getWebSocketPort() {
        return appConfig.getSocketPort();
    }

    //跳转到变压器台账
    @RequestMapping(value = "transformer")
    public String transformer(HttpServletRequest request) {
        return "business/settings/transFormer";
    }

    //跳转到变压器台账
    @RequestMapping(value = "tfLgAss")
    public String tfLgAss(HttpServletRequest request) {
        return "business/settings/tfLgAss";
    }

    //跳转报告界面
    @RequestMapping(value = "addrpdata")
    public String addRPData(HttpServletRequest request) {
        return "business/report/addRPData";
    }

    //跳转excel报表配置界面
    @GetMapping("addexceldata")
    public String addExcelData() {
        return "business/report/addExcelData";
    }

    //跳转excel报表模板界面
    @GetMapping("showexcelploy")
    public String showExcelploy() {
        return "business/report/showExcelPloy";
    }

    //跳转excel报表模板界面
    @GetMapping("addexcelploy")
    public String addExcelploy() {
        return "business/report/addExcelPloy";
    }

    //跳转离线数据解析状态界面
    @GetMapping("translatestate")
    public String translateState() {
        return "business/terminal/translatestate";
    }

    //跳转报告界面
    @RequestMapping(value = "modrpdata")
    public String modRpData(HttpServletRequest request, HttpSession session,String rdIndex) {
    	rdIndex = XssFilterUtil.dealString(rdIndex);
        session.setAttribute("rdIndex", rdIndex);
        return "business/report/modRPDate";
    }

    //跳转报告界面
    @RequestMapping(value = "addrpploy")
    public String addRPPloy(HttpServletRequest request) {
        return "business/report/addRPPloy";
    }

    //跳转区域报告界面
    @RequestMapping(value = "areaploy")
    public String areaPloy(HttpServletRequest request) {
        return "business/report/areaPloy";
    }

    //跳转报告界面
    @RequestMapping(value = "arearpdata")
    public String areaRPData(HttpServletRequest request) {
        return "business/report/areaRPData";
    }

    //跳转新增区域报告界面
    @RequestMapping(value = "addareaploy")
    public String addAreaPloy(HttpServletRequest request) {
        return "business/report/addAreaPloy";
    }

    //跳转报告界面
    @RequestMapping(value = "addareanode")
    public String addareaNode(HttpServletRequest request) {
        return "business/report/addAreaNode";
    }

    //跳转区域模板修改界面
    @RequestMapping(value = "modarearpploy")
    public String modAreaRpPloy(HttpServletRequest request, HttpSession session,String rpIndex) {
    	rpIndex = XssFilterUtil.dealString(rpIndex);
        session.setAttribute("rpIndex", rpIndex);
        return "business/report/modAreaRpPloy";
    }

    //跳转报告界面
    @RequestMapping(value = "modrpploy")
    public String modRpPloy(HttpServletRequest request, HttpSession session,String rpIndex) {
    	rpIndex = XssFilterUtil.dealString(rpIndex);
        session.setAttribute("rpIndex", rpIndex);
        return "business/report/modRpPloy";
    }

    //跳转到修改变压器策略页面
    @RequestMapping(value = "updatePloy")
    public String updatePloy(HttpServletRequest request, HttpSession session,String rpIndex) {
    	rpIndex = XssFilterUtil.dealString(rpIndex);
        session.setAttribute("rpIndex", rpIndex);
        return "business/settings/updatePloy";
    }

    //跳转报告界面
    @RequestMapping(value = "addnode")
    public String addNode(HttpServletRequest request) {
        return "business/report/addNode";
    }

    //跳转新增报告界面
    @RequestMapping(value = "addploy")
    public String addPloy(HttpServletRequest request) {
        return "business/report/addPloy";
    }

    //跳转变压器策略界面
    @RequestMapping(value = "addtflgploy")
    public String addtflgploy(HttpServletRequest request) {
        return "business/settings/addtflgPloy";
    }
    //*************用户、部门、权限、数据字典等*************************end

    /**
     * 跳转台账管理
     */
    @RequestMapping(value = "devmanage")
    public String devmanage(HttpServletRequest request) {
        return "business/device/devmanage";
    }

    /**
     * 跳转台账管理
     */
    @RequestMapping(value = "gwdevmanage")
    public String gwdevmanage(HttpServletRequest request) {
        return "business/device/gwdevmanage";
    }

    //跳转新增终端
    @RequestMapping(value = "adddevice")
    public String addDevice(HttpServletRequest request, HttpSession session,String gdIndex,String subIndex) {
    	gdIndex = XssFilterUtil.dealString(gdIndex);
    	subIndex = XssFilterUtil.dealString(subIndex);
        session.setAttribute("gdIndex", gdIndex);
        session.setAttribute("subIndex", subIndex);
        return "business/device/addDev";
    }

    /**
     * 终端程序版本管理页面跳转
     */
    @RequestMapping(value = "deviceversion")
    public String deviceversion(HttpServletRequest request) {
        return "business/device/deviceVersion";
    }

    /**
     * 终端程序版本管理页面升级
     */
    @RequestMapping(value = "deviceversionup")
    public String deviceVersionUp(HttpServletRequest request) {
        return "business/device/deviceVersionUp";
    }

    /**
     * 终端版本维护
     */
    @RequestMapping(value = "versionmanger")
    public String versionmanger(HttpServletRequest request) {
        return "business/device/versionManger";
    }
    /**
     * 终端版本维护新增修改
     */
    @RequestMapping(value = "versionadd")
    public String versionadd(HttpServletRequest request) {
        return "business/device/versionAddUpdate";
    }

    /**
     * 电镀参数读取页面跳转
     */
    @RequestMapping(value = "electparam")
    public String electparam(HttpServletRequest request) {
        return "business/device/electParam";
    }
    /**
     * 终端性能展示页面跳转
     */
    @RequestMapping(value = "deviceproperty")
    public String deviceproperty(HttpServletRequest request) {
        return "business/device/deviceProperty";
    }

    /**
     * 终端性能展示页面跳转
     */
    @RequestMapping(value = "deviceopen")
    public String deviceopen(HttpServletRequest request) {
        return "business/device/devicePropertyOpen";
    }

    /**
    * @Author chendaofei
    * @Description 流量详情跳转
    * @Date 9:52 2020/8/3
    **/
    @RequestMapping(value = "flowdetail")
    public String flowdetail(HttpServletRequest request) {
        return "business/device/deviceFlowDetail";
    }

    /**
     * 跳转终端运行日志
     * @author cdf
     * @date 2022/6/17
     */
    @RequestMapping(value = "todevlogs")
    public String devRunFlagLogs(HttpServletRequest request) {
        return "business/device/devRunFlagLogs";
    }

    /**
     * @Author chendaofei
     * @Description 流量套餐管理页面跳转
     * @Date 9:52 2020/8/3
     **/
    @RequestMapping(value = "flowcombo")
    public String flowcombo(HttpServletRequest request) {
        return "business/device/terComboManager";
    }

    /**
     * @Author chendaofei
     * @Description 流量套餐策略管理
     * @Date 9:52 2020/8/3
     **/
    @RequestMapping(value = "flowstrategy")
    public String flowstrategy(HttpServletRequest request) {
        return "business/device/terStrategyManager";
    }

    /**
     * @Author chendaofei
     * @Description 终端状态管理页面
     * @Date 9:52 2020/8/3
     **/
    @RequestMapping(value = "termainstate")
    public String termainstate(HttpServletRequest request) {
        return "business/device/termainState";
    }

    /**
     * @Author chendaofei
     * @Description 流量套餐管理主页面跳转
     * @Date 9:52 2020/8/3
     **/
    @RequestMapping(value = "flowcombamain")
    public String flowcombamain(HttpServletRequest request) {
        return "business/device/flowCombaMain";
    }

    /**
     * @Author chendaofei
     * @Description 流量套餐新增修改弹框
     * @Date 9:52 2020/8/3
     **/
    @RequestMapping(value = "flowcommainopen")
    public String flowCombaMainOpen(HttpServletRequest request) {
        return "business/device/flowCombaMainOpen";
    }



    /**
     * @Author chendaofei
     * @Description 流量策略主页面跳转
     * @Date 9:52 2020/8/3
     **/
    @RequestMapping(value = "flowstratemain")
    public String flowstratemain(HttpServletRequest request) {
        return "business/device/flowStrategyMain";
    }


    /**
     * @Author chendaofei
     * @Description 流量策略新增修改页面跳转
     * @Date 9:52 2020/8/3
     **/
    @RequestMapping(value = "flowstrategyopen")
    public String flowstrategyOpen(HttpServletRequest request) {
        return "business/device/flowStrategyOpen";
    }

    /**
     * @Author chendaofei
     * @Description 流量策略新增修改页面跳转
     * @Date 9:52 2020/8/3
     **/
    @RequestMapping(value = "flowopentwo")
    public String flowstrategyOpenTwo(HttpServletRequest request) {
        return "business/device/flowStrategyOpenTwo";
    }


    /**
    * @Author chendaofei
    * @Description 终端定值管理主页面跳转
    * @Date 15:46 2020/9/3
    **/
    @RequestMapping(value = "terminalfixed")
    public String terminalfixed(HttpServletRequest request) {
        return "business/terminal/terminalFixed";
    }

    @RequestMapping(value = "addnodeinfo")
    public String addnodeinfo(HttpServletRequest request) {
        return "business/device/addNodeInfo";
    }


    /**
    * @Author chendaofei
    * @Description 流量统计主页面跳转
    * @Date 18:46 2020/10/9
    **/
    @RequestMapping(value = "flowstatistics")
    public String flowstatistics(HttpServletRequest request) {
        return "business/device/flowStatistics";
    }

    /**
     * 跳转终端升级详情展示页面
     */
    @RequestMapping(value = "terminalupdetail")
    public String terminalUpDetail(HttpServletRequest request) {
        return "business/device/terminalUpDetail";
    }

    /**
     * 跳转前置机信息
     */
    @RequestMapping(value = "nodeinfo")
    public String nodeinfo(HttpServletRequest request) {
        return "business/device/nodeInfo";
    }

    /**
     * 修改前置机信息
     */
    @RequestMapping(value = "modnode")
    public String modnode(HttpServletRequest request, HttpSession session,String nodeIndex) {
    	nodeIndex = XssFilterUtil.dealString(nodeIndex);
        session.setAttribute("nodeIndex", nodeIndex);
        return "business/device/modNode";
    }

    /**
     * 跳转消息推送
     */
    @RequestMapping(value = "pushinfo")
    public String pushinfo(HttpServletRequest request) {
        return "business/device/pushInfo";
    }

    /**
     * 审核管理员
     */
    @RequestMapping(value = "examiner")
    public String examiner(HttpServletRequest request) {
        return "business/settings/examinerMange";
    }

    /**
     * 审计管理员
     */
    @RequestMapping(value = "sj")
    public String sj(HttpServletRequest request) {
        return "business/settings/UserLogManger";
    }

    @RequestMapping(value = "chart")
    public String chart(HttpServletRequest request) {
        return "business/settings/userLogChart";
    }

    @RequestMapping(value = "sjtj")
    public String sjtj(HttpServletRequest request) {
        return "business/settings/sjtj";
    }

    // 当前在线用户统计
    @RequestMapping(value = "online")
    public String online(HttpServletRequest request) {
        return "business/settings/online";
    }

    @RequestMapping(value = "loginmanage")
    public String loginmanage(HttpServletRequest request) {
        return "business/settings/userLoginManage";
    }

    /**
     * 跳转告警界面
     */
    @RequestMapping(value = "warnwin")
    public String warnwin(HttpServletRequest request) {
        return "business/settings/warnwin";
    }

    /**
     * 跳转告警界面
     */
    @RequestMapping(value = "seriouswin")
    public String seriouswin(HttpServletRequest request, HttpSession session,String size) {
    	size = XssFilterUtil.dealString(size);
        session.setAttribute("size", size);
        return "business/settings/seriouswin";
    }

    /**
     * 跳转404页面
     */
    @RequestMapping(value = "404")
    public String notFound(HttpServletRequest request) {
        return "business/error/404";
    }

    /**
     * 导入终端
     */
    @RequestMapping(value = "importdev")
    public String importdev(HttpServletRequest request) {
        return "business/device/importdev";
    }

    /****************************综合管理*****************start*/

    /**
     * sysacoding '系统检测'
     */
    @RequestMapping(value = "sysacoding")
    public String sysacoding(HttpServletRequest request) {
        return "business/module/sysacoding";
    }

    /**
     * 'modulerunning','模块运行状态'
     */
    @RequestMapping(value = "modulerunning")
    public String modulerunning(HttpServletRequest request) {
        return "business/module/modulerunning";
    }

    /**
     * 'databaserunning','数据库运行状态'
     */
    @RequestMapping(value = "databaserunning")
    public String databaserunning(HttpServletRequest request) {
        return "business/module/databaserunning";
    }

    /**
     * 'databaserunning','数据缺失情况'
     */
    @RequestMapping(value = "dataloss")
    public String dataloss(HttpServletRequest request) {
        return "business/module/dataloss";
    }

    /**
     * 'communicationtraffic','通讯流量记录'
     */
    @RequestMapping(value = "communicationtraffic")
    public String communicationtraffic(HttpServletRequest request) {
        return "business/module/communicationtraffic";
    }

    /**
     * 'vpncommunication','VPN通讯状态'
     */
    @RequestMapping(value = "vpncommunication")
    public String vpncommunication(HttpServletRequest request) {
        return "business/module/vpncommunication";
    }

    /**
     * 'serverrunning','服务器运行状态'
     */
    @RequestMapping(value = "serverrunning")
    public String serverrunning(HttpServletRequest request) {
        return "business/module/serverrunning";
    }


    /****************************综合管理*****************end*/
    /**
     * @Author denghuajun
     * @Description //TODO 终端维护 start
     * @Date 2018/10/11 21:52
     **/
    //定值管理
    @RequestMapping(value = "dzgl")
    public String dzgl(HttpServletRequest request) {
        return "business/terminal/dzgl";
    }

    //内部定值修改
    @RequestMapping(value = "dzglin")
    public String dzglin(HttpServletRequest request, HttpSession session,String pvIndex) {
    	pvIndex = XssFilterUtil.dealString(pvIndex);
        session.setAttribute("pvIndex", pvIndex);
        return "business/terminal/dzglin";
    }

    //wifi无线信号
    @RequestMapping(value = "wifi")
    public String wifi(HttpServletRequest request) {
        return "business/terminal/wifi";
    }

    //录波管理
    @RequestMapping(value = "lbgl")
    public String lbgl(HttpServletRequest request) {
        return "business/terminal/lbgl";
    }

    //sntp对时文件的上传
    @RequestMapping(value = "sntp")
    public String sntp(HttpServletRequest request) {
        return "business/terminal/sntp";
    }

    //ping、telnet
    @RequestMapping(value = "pingtel")
    public String pingtel(HttpServletRequest request) {
        return "business/terminal/pingtel";
    }

    //系统日志
    @RequestMapping(value = "syslog")
    public String syslog(HttpServletRequest request) {
        return "business/terminal/syslog";
    }

    //装置状态
    @RequestMapping(value = "devicestate")
    public String devicestate(HttpServletRequest request) {
        return "business/terminal/devicestate";
    }

    //复位装置
    @RequestMapping(value = "restoration")
    public String restoration(HttpServletRequest request) {
        return "business/terminal/restoration";
    }

    //数据补招
    @RequestMapping(value = "dataadd")
    public String dataadd(HttpServletRequest request) {
        return "business/terminal/dataadd";
    }

    //终端辅助
    @RequestMapping(value = "devfz")
    public String devfz(HttpServletRequest request) {
        return "business/terminal/devfz";
    }

    /**************************end************************/

    @GetMapping(value = "offlinetree")
    public String offlinetree() {
        return "business/terminal/offLineTree";
    }

    @GetMapping(value = "viewwave")
    public String viewwave() {
        FileUtil.clean(new File(appConfig.getTmppath() + File.separator+"waveTemp"));
        return "business/terminal/viewWave";
    }

    @GetMapping(value = "viewWaveData")
    public String viewWaveData() {
        return "business/terminal/waveform";
    }

    //告警信息
    @GetMapping(value = "alarm")
    public String alarm() {
        return "business/state/alarmInfoManage";
    }

    //终端状态
    @GetMapping(value = "devstate")
    public String devstate() {
        return "business/state/devStateManage";
    }

    @GetMapping(value = "devStateinfo")
    public String devStateinfo() {
        return "business/state/devStateInfo";
    }

    //通讯流量
    @GetMapping(value = "flow")
    public String flow() {
        return "business/state/flowManage";
    }

    @GetMapping(value = "monthyeardayflow")
    public String monthyeardayflow()

    {
        return "business/state/monthyeardayflow";
    }

    //服务器状态
    @GetMapping(value = "server")
    public String server() {
        return "business/state/serverStateManage";
    }

    //中间件状态
    @GetMapping(value = "middrun")
    public String middrun() {
        return "business/state/middRunManage";
    }


    @GetMapping("managers")
    public String managers(){
        return "business/root/managers";
    }

    @GetMapping("managesystem")
    public String manageSystem(){
        return "business/root/manageSystem";
    }

    //app用户
    @GetMapping("appUser")
    public String appUser(){
        return "business/settings/appUserManage";
    }

    /**
     * 跳转到新增app用户
     */
    @RequestMapping("addAppUser")
    public String addAppUser(HttpServletRequest request) {
        return "business/settings/addAppUser";
    }

    /**
     * 跳转到修改app用户
     */
    @RequestMapping("updateAppUser")
    public String updateAppUser(HttpServletRequest request) {
        return "business/settings/updateAppUser";
    }

    /**
     * 跳转到短信查询页面
     */
    @RequestMapping(value = "message")
    public String queryMessage(HttpServletRequest request){
        return "message/queryMessage";
    }

    /**
     * 跳转到短信配置页面
     */
    @RequestMapping("messageconf")
    public String messageConf(HttpServletRequest request){return "message/messageConf"; }

    /**
     * 跳转到模拟短信发送页面
     */
    @RequestMapping("virtualsend")
    public String virtualSend(HttpServletRequest request){return "message/virtualSend"; }

    /**
     * 跳转到添加短信时间段模板页面
     */
    @RequestMapping("msgtime")
    public String msgtime(HttpServletRequest request){
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        	return "message/addTimeTemplate";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }

    /**
     * 跳转到添加短信类型模板页面
     */
    @RequestMapping("msgtype")
    public String msgtype(HttpServletRequest request){
        String ip = PubUtils.getIpAddr(request);
        String username = TokenManager.getToken().getLoginName();

        byte[] value = jedisManager.getValueByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        String key = SerializeUtil.deserialize(value, String.class);
        if(key.equals("success")){
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
        	return "message/addTypeTemplate";
        }else{
            jedisManager.deleteByKey(RedisDB.SHORT_TIME_QUERY, SerializeUtil.serialize(username + ip));
            return "auth/unauthorized";
        }
    }


   /**
   * web工具相关页面跳转
   **/
   @RequestMapping("xbcsv")
   public String csvexport(HttpServletRequest request)
   {
       return "business/webtool/xbcsv";
   }

    /**
     * web工具完整性手动工具
     **/
    @RequestMapping("datacomplet")
    public String datacomplet(HttpServletRequest request){return "business/webtool/datacomplet"; }

    /**
     * 导出csv文件主题页面部分
     **/
    @RequestMapping("xbcsvmain")
    public String xbcsvmain(HttpServletRequest request){return "business/webtool/xbcsvmain"; }

    /**
     * 数据完整性手动操作右边页面
     **/
    @RequestMapping("datacompletmain")
    public String datacompletmain(HttpServletRequest request){return "business/webtool/datacompletmain"; }

    /***
     * 跳转到中间件详情
     */
    @RequestMapping("middRunDetail")
    public String middRunDetail(HttpServletRequest request){return "business/state/middRunDetail"; }

    /***
     * 新增中间件
     */
    @RequestMapping("saveMiddRun")
    public String saveMiddRun(HttpServletRequest request){return "business/state/saveMiddRun"; }

    /***
     * 修改中间件
     */
    @RequestMapping("updateMiddRun")
    public String updateMiddRun(HttpServletRequest request){return "business/state/updateMiddRun"; }

    /***
     * 跳转到服务器详情
     */
    @RequestMapping("serverStateDetail")
    public String serverStateDetail(HttpServletRequest request){return "business/state/serverStateDetail"; }

    /***
     * 跳转到新增服务器
     */
    @RequestMapping("saveServer")
    public String saveServer(HttpServletRequest request){return "business/state/saveServer"; }

    /***
     * 跳转到修改服务器
     */
    @RequestMapping("updateServer")
    public String updateServer(HttpServletRequest request){return "business/state/updateServer"; }

    /**
     * 跳转到告警提示
     */
    @RequestMapping("alarmwindow")
    public String tipwindow(HttpServletRequest request) {
        return "business/state/alarmwindow";
    }

    /**
     * 跳转查看终端升级日志
     */
    @RequestMapping("toupdetail")
    public String toupdetail(HttpServletRequest request) {
        return "business/device/toupdetail";
    }

    /**
     * create by: xu yang
     * description: ftp
     * create time: 2021/8/16 12:30
     */
    @RequestMapping(value = "ftp")
    public String ftp(HttpServletRequest request) {
        return "business/terminal/ftp";
    }

    @RequestMapping(value = "alarmdetail")
    public String alarmdetail(HttpServletRequest request) {
        return "business/state/alarmInfoDetail";
    }


    /**
     * 跳转监测点评分页面
     */
    @RequestMapping(value = "linemark")
    public String lineMark(HttpServletRequest request) {
        return "business/linedata/lineMark";
    }
    /**
     * 跳转监测点评分页面
     */
    @RequestMapping(value = "onlinerate")
    public String onlinerate(HttpServletRequest request) {
        return "business/linedata/onlineRate";
    }

    @RequestMapping(value = "onlineratecld")
    public String onlineRateCld(HttpServletRequest request) {
        return "business/linedata/onlineRateCld";
    }

    @RequestMapping(value = "areaonlinerate")
    public String areaOnlinerate(HttpServletRequest request) {
        return "business/linedata/areaOnlineRate";
    }

    @RequestMapping(value = "dataintegrity")
    public String onlinestrategy(HttpServletRequest request) {
        return "business/linedata/dataIntegrity";
    }

    @RequestMapping(value = "areadataintegrity")
    public String areaDataIntegrity(HttpServletRequest request) {
        return "business/linedata/areaDataIntegrality";
    }

    /**
     * 跳转终端运行异常页面
     */
    @RequestMapping(value = "terminalrunstrategy")
    public String terminalRunException(HttpServletRequest request) {
        return "business/linedata/terminalRunStrategy";
    }

    @RequestMapping(value = "terminalrunexception")
    public String runException(HttpServletRequest request){
        return "business/linedata/terminalRunException";
    }

    /**
     * 跳转终端运行通告详情页面
     */
    @RequestMapping(value = "terminalrundetail")
    public String terminalrunDetail(HttpServletRequest request){
        return "business/linedata/terminalRunDetail";
    }

    /**
     * 跳转终端运行通告详情页面
     */
    @RequestMapping(value = "terminalrundetailes")
    public String terminalrundetailes(HttpServletRequest request){
        return "business/linedata/terminalRunDetailes";
    }

    /**
     * 跳转终端运行通告详情页面弹框
     */
    @RequestMapping(value = "terminalrundetailopen")
    public String terminalrundetailopen(HttpServletRequest request){
        return "business/linedata/terminalRunDetailOpen";
    }

    /**
     * 跳转数据完整性（单个监测点未达标）
     */
    @RequestMapping(value = "dataIntegrityStatis")
    public String dataIntegrityStatis(HttpServletRequest request){
        return "business/linedata/dataIntegrityStatis";
    }

    /**
     * 跳转到半月报页面
     * @author cdf
     * @date 2022/5/7
     */
    @RequestMapping(value = "halfreport")
    public String halfreport(HttpServletRequest request){
        return "business/linedata/halfReport";
    }


    /**
     * 检测点评分权重
     * @author cdf
     * @date 2023/8/15
     */
    @RequestMapping(value = "linemarkweight")
    public String linemarkweight(HttpServletRequest request){
        return "business/linedata/lineMarkWeight";
    }


    /**
     * 检测点评分权重
     * @author cdf
     * @date 2023/8/15
     */
    @RequestMapping(value = "deviceunit")
    public String deviceunit(HttpServletRequest request){
        return "business/device/deviceUnit";
    }

    /**
     *  跳转到时间选择控件
     */
    @RequestMapping("timerange")
    public String timeRange() {
        return "business/webtool/timeRange";
    }

}
