<%--
  Created by IntelliJ IDEA.
  User: HuaJunD
  Date: 2018/10/11
  Time: 14:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title>定值管理</title>
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="stylesheet" href="${ctx}/css/plugin/bootstrap/bootstrap.min.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/jquery/jquery-ui.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/datatimepicker/bootstrap-datetimepicker.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/metroStyle/metroStyle.css">
    <link rel="stylesheet" href="${ctx}/css/basic.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/fontawesome/font-awesome.min.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/datatables/datatables.bootstrap.css">
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
            background-color: #F9F9F9 !important;
        }

        .dg-sub b.red {

            border-bottom: solid 1px #98af9f;
            font-weight: bold;
        }

        .dg-sub b {
            padding: 2px 5px;
            color: #666;
            font-weight: normal;
        }

        @media screen and (min-width: 1000px) and (max-width: 1400px) and (max-height: 500px) {
            #tj {
                min-height: 500px;
            }
        }

        .nav > li > a {
            padding: 3px 15px;
        }

        ul {
            padding: 0 2px;
            border: 1px solid #696969;
            border-radius: 4px;
        }

        .btn {
            padding: 0px 5px;
        }
    </style>
</head>
<body class="pd5">
<div class="fr">
    <button type="button" id="insidevalueDescribe"
            class="btn themeBGColor fl mr5 f12">读取内部定值
    </button>
    <button type="button" id="outervalueDescribe"
            class="btn themeBGColor fl f12 mr5">读取外部定值
    </button>

    <%--    <button type="button" id="insidevalue"--%>
    <%--            class="btn themeBGColor  mr5 f12">校验内部定值--%>
    <%--    </button>--%>
    <%--    <button type="button" id="outervalue"--%>
    <%--            class="btn themeBGColor  f12 mr5">校验外部定值--%>
    <%--    </button>--%>
</div>
<div class="form-group  mr10  " style="margin-bottom: 3px">
    <%--用于内外定值的改正--%>
    <%--定值导航菜单--%>
    <div class="container-fluid" style="margin-top: 1%;" id="outI">
        <ul class="nav nav-pills nav-justified mt10" id="qualifiedTab">
            <li class="active"><a href="#frequency" data-toggle="tab" id="allData">基本定值</a></li>
            <li><a href="#frequency" data-toggle="tab" id="vuDev">谐波电流</a></li>
            <li><a href="#frequency" data-toggle="tab" id="frequencyDeviation">谐波电压</a></li>
            <li><a href="#frequency" data-toggle="tab" id="vthd">间谐波定值</a></li>
        </ul>
    </div>
    <li style="list-style-type:none;text-align: center" id="tlt"></li>
    <%--核心内容--%>
    <div id="isupdateTable">
        <table id="usertId" class="table table-striped table-bordered dataTable no-footer width100">
            <thead>
            <tr role="row">
                <th class="text-center">序号</th>
                <th class="text-center">定值名称</th>
                <th class="text-center">当前定值</th>
                <th class="text-center">定值范围</th>
            </tr>
            </thead>
        </table>
    </div>
    <div id="isupdateTables" style="display: none">
        <table id="usertIds" class="table table-striped table-bordered dataTable no-footer width100">
            <thead>
            <tr role="row">
                <th class="text-center">序号</th>
                <th class="text-center">定值名称</th>
                <th class="text-center">当前定值</th>
                <th class="text-center">修改定值</th>
                <th class="text-center">定值范围</th>
            </tr>
            </thead>
        </table>
    </div>
    <%--用于修改定值--%>
    <div style="text-align: center">
        <button type="button" id="updateConValues"
                class="btn themeBGColor  ml5 f12 " disabled><i class='fa fa-pencil-square-o'></i>修改定值
        </button>
        <button type="button" id="updateValue" class="btn themeBGColor  ml5 f12" style="display: none"><i
                class='fa fa-pencil-square-o'></i>下发定值
        </button>
    </div>
</div>
<input type="hidden" id="lineIndex" name="lineIndex">
<input type="hidden" id="lineName" name="lineName">
<input type="hidden" id="middlesrc" name="middlesrc">
<input type="hidden" id="row" name="row">
<input type="hidden" id="isUpdate" name="isUpdate">
<input type="hidden" id="devtypes" name="devtype">
<input type="hidden" id="username" value="${username}">
<%--Common Modal --%>
<script src="${ctx}/js/plugin/jquery/jquery.min.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap.min.js"></script>
<script src="${ctx}/js/plugin/layui/layer.js"></script>
<script src="${ctx}/js/plugin/json/json2.js"></script>
<script src="${ctx}/js/plugin/jquery/jquery.contextMenu.js"></script>
<script src="${ctx}/js/plugin/jquery/jquery.cleverTabs.js"></script>
<script src="${ctx}/js/plugin/ztree/jquery.ztree.core.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap-datetimepicker.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${ctx}/jspJS/utils/timeControl.js"></script>
<script src="${ctx}/js/plugin/datatables/datatables.jquery.js"></script>
<script src="${ctx}/js/plugin/datatables/datatables.bootstrap.js"></script>
<script src="${ctx}/jspJS/utils/loading.js"></script>
<script src="${ctx}/js/plugin/xss/aes.js"></script>
<script src="${ctx}/jspJS/sm2.js"></script>
<script src="${ctx}/jspJS/sm3.js"></script>
<script src="${ctx}/jspJS/utils/judgeAjaxStatus.js"></script>
<script src="${ctx}/jspJS/confirmIndentity.js"></script>
<script src="${ctx}/js/color.js"></script>
<script type="text/javascript">
    var tltName = '基本定值';
    var devtype = '';
    var isOutIn = '';
    var getProper;
    var dataTable = [];
    var typei = 90;
    var hander = 0;
    var websocket = window.parent.parent.webSocket;
    var lineIndex;
    var devIndex, dataDescrie = 0;
    var obj = [];
    var objData = [];
    var number = 0;
    var json1;
    var i = null, ia = null;
    var isXf = false;
    var jsonProp;
    var isTrue = false;
    var jsonList;
    var descri = "";
    var isFalse = false;
    var indexi;
    var typeConValue = parent.typeConValue;
    var restartLoad = null; //重启loading控制
    var interValue =[];//修改的值
    var restartValue = [];//重启后的值
    var restartNum = 0;
    $(function () {
        lineIndex = parent.linIndex();
        devIndex = parent.deIndex();
        isOutIn = parent.getIsOutIn();
        document.getElementById("insidevalueDescribe").style.display = "none";
        if (typeConValue == 0) {

        } else {
            if (isOutIn == "in") {
                restartNum = 0;
                layer.open({
                    title: '读取内部定值',
                    btn: ['读取内部定值'],
                    btnAlign: 'c',
                    yes: function (index, layero) {
                        i = ityzl_SHOW_LOAD_LAYER();
                        isFalse = true;
                        isXf = false;
                        typei = 90;
                        getDescribeDev(typei);
                        document.getElementById("updateConValues").style.display = "";
                        document.getElementById("updateConValues").disabled = false
                        layer.closeAll();
                    }
                })
            } else {
                layer.open({
                    title: '读取外部定值',
                    btn: ['读取外部定值'],
                    btnAlign: 'c',
                    yes: function (index, layero) {
                        i = ityzl_SHOW_LOAD_LAYER();
                        isFalse = false;
                        isXf = false;
                        typei = 80;
                        getDescribe(typei);
                        document.getElementById("updateConValues").style.display = "";
                        document.getElementById("updateConValues").disabled = false
                    }
                })
            }
        }

        var rows = 0;
        websocket.onmessage = function (evnt) {
            if (evnt.data != "") {
                $('.loading-div').remove()
                if (hander == 1 || hander == 0) {
                    //data数据体后的长度
                    var info = JSON.parse(evnt.data);
                    if (info.resultcode == 10001) {
                        layer.msg("报文头部结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10002) {
                        layer.msg("报文长度结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10003) {
                        layer.msg("JSON字符串解析出错", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10004) {
                        layer.msg("socket处理出现异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10005) {
                        layer.msg("未找到ID为" + lineIndex + "对应的设备", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10006) {
                        layer.msg("传入的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10007) {
                        layer.msg("下发的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10008) {
                        layer.msg("当前有同类型的操作正在执行，请稍后", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10009) {
                        layer.msg(lineIndex + "对应的设备关闭了实时数据功能", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10000) {
                        var infoData = info.data;
                        var infoDataJsom = JSON.parse(infoData.json);
                        if(hander == 0 && restartNum ==1 ){
                            restartValue = infoDataJsom.data
                            if(arrayEqual(interValue,restartValue.toString())){
                                layer.msg("定值修改成功", {
                                    icon: 6,
                                    time: 5000
                                })
                                return false;
                            }else {
                                layer.msg("定值修改失败", {
                                    icon: 5,
                                    time: 5000
                                })
                                return false;
                            }
                        }
                        if (isXf == true) {
                            layer.msg(info, {
                                icon: 6,
                                time: 3000
                            })
                        } else {
                            //解析数据，用于比较
                            dataDescrie = infoDataJsom.data.length;
                            comparisonValueDescribe(typei, infoDataJsom);
                        }
                    } else if (info.resultcode == 10011) {
                        layer.msg("DNS解析失败", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 100) {
                        layer.msg("socket连接失败", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10012) {
                        layer.msg("转码异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10013) {
                        layer.msg("连接超时导致读写异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10014) {
                        layer.msg("该终端无版本号，不可进行定值相关操作!", {
                            icon: 5,
                            time: 3000
                        })
                    }
                } else if (hander == 2) {
                    var info = JSON.parse(evnt.data);
                    if (info.resultcode == 10001) {
                        layer.msg("报文头部结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10002) {
                        layer.msg("报文长度结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10003) {
                        layer.msg("JSON字符串解析出错", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10004) {
                        layer.msg("socket处理出现异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10005) {
                        layer.msg("未找到ID为" + lineIndex + "对应的设备", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10006) {
                        layer.msg("传入的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10007) {
                        layer.msg("下发的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10008) {
                        layer.msg("当前有同类型的操作正在执行，请稍后", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10009) {
                        layer.msg(lineIndex + "对应的设备关闭了实时数据功能", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10000) {
                        //进行校验
                        // layer.msg(info.resultmsg, {
                        //     icon: 6,
                        //     time: 3000
                        // });
                        // getConstanValues();
                    } else if (info.resultcode == 10011) {
                        layer.msg("DNS解析失败", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 100) {
                        layer.msg("socket连接失败", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10012) {
                        layer.msg("转码异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10013) {
                        layer.msg("连接超时导致读写异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10014) {
                        layer.msg("该终端无版本号，不可进行定值相关操作!", {
                            icon: 5,
                            time: 3000
                        })
                    }
                } else if (hander == 3) {
                    //data数据体后的长度
                    var info = JSON.parse(evnt.data);
                    if (info.resultcode == 10001) {
                        layer.msg("报文头部结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10002) {
                        layer.msg("报文长度结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10003) {
                        layer.msg("JSON字符串解析出错", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10004) {
                        layer.msg("socket处理出现异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10005) {
                        layer.msg("未找到ID为" + lineIndex + "对应的设备", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10006) {
                        layer.msg("传入的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10007) {
                        layer.msg("下发的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10008) {
                        layer.msg("当前有同类型的操作正在执行，请稍后", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10009) {
                        layer.msg(lineIndex + "对应的设备关闭了实时数据功能", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10011) {
                        layer.msg("json解析失败", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10000) {
                        layer.msg("定值下发成功！", {
                            icon: 6,
                            time: 3000
                        })
                        var infoData = info.data;
                        var infoDataJsom = JSON.parse(infoData.json);
                        objData = [];
                        objData = infoDataJsom.data;
                        if (obj.toString() == objData.toString()) {
                            hander = 0;
                            //解析数据，用于比较
                            dataDescrie = infoDataJsom.data.length;
                            comparisonValueDescribe(typei, infoDataJsom);
                            //重启装置
                            if (typei == 90) {
                                //发送重启装置指令（判断是否需要重启）
                                //startWebSocketReset(220, lineIndex);
                                var con = layer.confirm("确认重启装置?" + "<lable style='color: red'>(注：内部定值需要重启后生效)</lable>", function () {
                                    let index;
                                    console.log(devIndex)
                                    //发送重启请求
                                    $.ajax({
                                        url: "/pqs9900/version/restartDevConValue",
                                        type: 'POST',
                                        dataType: "json",
                                        data: {
                                            devnumber: devIndex
                                        },
                                        beforeSend: function () {
                                            index = ityzl_SHOW_LOAD_LAYER();
                                        },
                                        success: function (data) {
                                            if (data.code == 200) {
                                            } else {

                                            }
                                            ityzl_CLOSE_LOAD_LAYER(index);
                                            layer.close(con)
                                        }

                                    })
                                })
                                hander = 5;
                            } else {
                                layer.msg("修改定值成功", {
                                    icon: 6,
                                    time: 3000
                                })
                                isFalse = false;
                                isXf = false;
                                typei = 80;
                                getDescribe(typei);
                                document.getElementById("updateConValues").style.display = "";
                                document.getElementById("updateConValues").disabled = false
                            }
                        } else {
                            layer.msg("修改定值失败", {
                                icon: 5,
                                time: 3000
                            })
                        }
                    } else if (info.resultcode == 100) {
                        layer.msg("socket连接失败", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10012) {
                        layer.msg("转码异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10013) {
                        layer.msg("连接超时导致读写异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10014) {
                        layer.msg("该终端无版本号，不可进行定值相关操作!", {
                            icon: 5,
                            time: 3000
                        })
                    }
                } else if (hander == 4) {
                    //data数据体后的长度
                    var info = JSON.parse(evnt.data);
                    if (info.resultcode == 10001) {
                        layer.msg("报文头部结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10002) {
                        layer.msg("报文长度结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10003) {
                        layer.msg("JSON字符串解析出错", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10004) {
                        layer.msg("socket处理出现异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10005) {
                        layer.msg("未找到ID为" + lineIndex + "对应的设备", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10006) {
                        layer.msg("传入的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10007) {
                        layer.msg("下发的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10008) {
                        layer.msg("当前有同类型的操作正在执行，请稍后", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10009) {
                        layer.msg(lineIndex + "对应的设备关闭了实时数据功能", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10000) {
                        layer.msg("修改定值成功！" + "装置重启中......", {
                            icon: 6,
                            time: 3000
                        })
                        hander = 0;
                    } else if (info.resultcode == 10011) {
                        layer.msg("DNS解析失败", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 100) {
                        layer.msg("socket连接失败", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10012) {
                        layer.msg("转码异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10013) {
                        layer.msg("连接超时导致读写异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10014) {
                        layer.msg("该终端无版本号，不可进行定值相关操作!", {
                            icon: 5,
                            time: 3000
                        })
                    }
                } else if (hander == 16) {
                    var info = JSON.parse(evnt.data);
                    if (info.resultcode == 10001) {
                        layer.msg("报文头部结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10002) {
                        layer.msg("报文长度结构有错误", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10003) {
                        layer.msg("JSON字符串解析出错", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10004) {
                        layer.msg("socket处理出现异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10005) {
                        layer.msg("未找到ID为" + lineIndex + "对应的设备", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10006) {
                        layer.msg("传入的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10007) {
                        layer.msg("下发的参数异常", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10008) {
                        layer.msg("当前有同类型的操作正在执行，请稍后", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10009) {
                        layer.msg(lineIndex + "对应的设备关闭了实时数据功能", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10000) {
                        var infoData = info.data;
                        var infoDataJsom = JSON.parse(infoData.json);
                        if (isXf == true) {
                            layer.msg(info, {
                                icon: 6,
                                time: 3000
                            })
                        } else {
                            //解析数据，用于比较
                            dataDescrie = infoDataJsom.data.length;
                            comparisonValueDescribe(typei, infoDataJsom);
                        }
                    } else if (info.resultcode == 10011) {
                        layer.msg("DNS解析失败", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 100) {
                        layer.msg("socket连接失败", {
                            icon: 5,
                            time: 3000
                        });
                    } else if (info.resultcode == 10012) {
                        layer.msg("转码异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10013) {
                        layer.msg("连接超时导致读写异常", {
                            icon: 5,
                            time: 3000
                        })
                    } else if (info.resultcode == 10014) {
                        layer.msg("该终端无版本号，不可进行定值相关操作!", {
                            icon: 5,
                            time: 3000
                        })
                    }
                } else if (hander == 5) {
                    var info = JSON.parse(evnt.data)
                    if (info.type == 181) {
                        //重启命令
                        if (info.resultcode == 10000) {
                            if (restartLoad == null) {
                                restartLoad = layer.open({
                                    type: 1
                                    , title: false //不显示标题栏
                                    , closeBtn: false
                                    , area: '300px;'
                                    , shade: 0.8
                                    , id: 'LAY_Id' //设定一个id，防止重复弹出
                                    , btnAlign: 'c'
                                    , moveType: 1 //拖拽模式，0或者1
                                    , content: '<div  style="padding: 5px 10px 10px 5px"><div class="loading-div">' +
                                        '<i class="fa fa-spinner fa-pulse fa-3x fa-fw "></i>' +
                                        '<span id="reTitle">正在重启装置...</span>' +
                                        '</div><table id="msgInfo"></table>'
                                });
                            }
                        } else if (info.resultcode == 10001) {
                            layer.close(restartLoad);
                            layer.msg("装置重启成功，请稍后....", {
                                icon: 6,
                                time: 3000
                            })
                            window.setTimeout(function () {
                                isFalse = true;
                                isXf = false;
                                typei = 90;
                                restartNum = 1;
                                getDescribeDev(typei);
                                document.getElementById("updateConValues").style.display = "";
                                document.getElementById("updateConValues").disabled = false
                            }, 10000)
                        } else if (info.resultcode == 5555) {
                            //超时处理
                            layer.msg('socket超时,请联系管理员！', {type: 1})
                        } else {
                            $('#msgInfo').append(htmls.replace('{{1}}', info.resultmsg))
                        }


                    }
                }

            }
        }
        var Uarry = $("#qualifiedTab li");//获取所有的li元素
        $("#qualifiedTab li").click(function () {//点击事件
            //测试直接获取值 var v=$(this).text();

            var count = $(this).index();//获取li的下标
            var Tresult = Uarry.eq(count).text();
            tltName = Tresult;
            quarryOutValue(devtype, tltName, isOutIn);
        })
    })

    function getNowFormatDate() {
        var date = new Date();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + '年' + month + '月' + strDate
            + "日" + date.getHours() + '时' + date.getMinutes()
            + '分' + date.getSeconds() + '秒';
        return currentdate;
    }

    function quarryOutValue(devtype, tltName, isOutIn) {
        window.onload = function () {
            setInterval("$('#tlt').text(parent.typetoName()+'->'+tltName+' '+getNowFormatDate())", 1000)
        }
        $.ajax({
            type: "POST",
            url: "/pqs9900/constant/quarryOutValue",
            data: {
                devtype: devtype,
                tltName: tltName,
                isOutIn: isOutIn,
                lineIndex: lineIndex
            },
            beforeSend: function () {
                i = ityzl_SHOW_LOAD_LAYER();
            },
            success: function (data) {
                jsonProp = data.body;
                if (data.code != 500) {
                    outvalue();
                    if (data.body[0].length == 0) {
                        document.getElementsByTagName("li")[0].style.display = "none";
                    }
                    if (data.body[1].length == 0) {
                        document.getElementsByTagName("li")[1].style.display = "none";
                    }
                    if (data.body[2].length == 0) {
                        document.getElementsByTagName("li")[2].style.display = "none";
                    }
                    if (data.body[3].length == 0) {
                        document.getElementsByTagName("li")[3].style.display = "none";
                    }
                    if (tltName == "基本定值") {
                        data = data.body[0];
                    } else if (tltName == "谐波电流") {
                        data = data.body[1]
                    } else if (tltName == "谐波电压") {
                        data = data.body[2];
                    } else {
                        data = data.body[3];
                    }
                    var heightTemp = screen.height;
                    var socy;
                    if (heightTemp === 768) {
                        socy = 440;
                    } else if (heightTemp <= 733) {
                        socy = 440;
                    } else if (heightTemp === 1050) {
                        socy = 480;
                    } else {
                        socy = 400;
                    }
                    if (data == null) {
                        number = 0;
                    } else {
                        number = data.length;
                    }
                    console.log(socy)
                    jsonList = data;
                    dataTable = $("#usertId").DataTable();
                    dataTable.clear().draw();
                    dataTable = $('#usertId').DataTable({
                        order: [],
                        "aaSorting": [[1, "desc"]],
                        columnDefs: [
                            {
                                orderable: false,
                                targets: [0, 1, 2, 3]
                            }
                        ],
                        data: data,
                        columns: [
                            {width: "10%", data: null},
                            {width: "15%", data: "describe"},
                            {
                                width: "10", data: "value",
                                render: function (data, type, full, meta) {
                                    var values, unit;
                                    if (data == null) {
                                        data = full.value;
                                    }
                                    unit = full.unit;
                                    if (unit == null) {

                                        unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                                    }
                                    values =
                                        "<input type='text' disabled id='" + meta.row + "' onblur='geizheng(this.value," +
                                        full.minValue + "," + full.maxValue + "," + meta.row +
                                        ")' style='margin-right:10px;' value='" + data.toFixed(3) +
                                        "'  onkeyup='if(isNaN(value))execCommand(\"undo\")' >" + unit;
                                    return values;
                                }
                            },
                            {
                                width: "15%", data: "minValue",
                                render: function (data, type, full, meta) {
                                    var values;
                                    values = data + '-' + full.maxValue;
                                    return values;
                                }
                            },
                        ],
                        info: false,
                        scrollY: socy,
                        paging: false,
                        destroy: true,
                        searching: true,
                        dom: 'rtip',
                        language: {
                            url: '/pqs9900/json/chine.json',
                            "sEmptyTable": "没有内容"
                        },
                    });
                    dataTable.on('order.dt search.dt',
                        function () {
                            dataTable.column(0, {
                                search: 'applied',
                                order: 'applied'
                            }).nodes().each(function (cell, i) {
                                cell.innerHTML = i + 1;
                            });
                        }).draw();
                } else {
                    outvalueDes();
                    layer.msg("定值获取失败", {icon: 5, time: 3000})
                    dataTable = $("#usertId").DataTable();
                    //dataTable.clear().draw();
                    dataTable = $('#usertId').DataTable({
                        order: [],
                        "aaSorting": [[1, "desc"]],
                        columnDefs: [
                            {
                                orderable: false,
                                targets: [0, 1, 2, 3]
                            }
                        ],
                        data: data,
                        columns: [
                            // {width: "10%", data: null},
                            // {width: "15%", data: "describe"},
                            // {
                            //     width: "10", data: "value",
                            //     render: function (data, type, full, meta) {
                            //         var values, unit;
                            //         if (data == null) {
                            //             data = full.defaultValue;
                            //         }
                            //         unit = full.unit;
                            //         if (unit == null) {
                            //
                            //             unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                            //         }
                            //         values =
                            //             "<input type='text' disabled id='valueOk" + meta.row + "' onblur='geizheng(this.value," +
                            //             full.minValue + "," + full.maxValue + "," + meta.row +
                            //             ")' style='margin-right:10px;' value='" + data.toFixed(3) +
                            //             "'  onkeyup='if(isNaN(value))execCommand(\"undo\")' >" + unit;
                            //         return values;
                            //     }
                            // },
                            // {
                            //     width: "10", data: "value", "visible": false,
                            //     render: function (data, type, full, meta) {
                            //         var values, unit;
                            //         if (data == null) {
                            //             data = full.defaultValue;
                            //         }
                            //         unit = full.unit;
                            //         if (unit == null) {
                            //
                            //             unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                            //         }
                            //         values =
                            //             "<input type='text' id='valueOk" + meta.row + "' onblur='geizheng(this.value," +
                            //             full.minValue + "," + full.maxValue + "," + meta.row +
                            //             ")' style='margin-right:10px;' value='" + data.toFixed(3) +
                            //             "'  onkeyup='if(isNaN(value))execCommand(\"undo\")' >" + unit;
                            //         return values;
                            //     }
                            // },
                            // {
                            //     width: "15%", data: "minValue",
                            //     render: function (data, type, full, meta) {
                            //         var values;
                            //         values = data + '-' + full.maxValue;
                            //         return values;
                            //     }
                            // },
                        ],
                        info: false,
                        scrollY: socy,
                        paging: false,
                        destroy: true,
                        searching: true,
                        dom: 'rtip',
                        language: {
                            url: '/pqs9900/json/chine.json',
                            "sEmptyTable": "没有内容"
                        },
                    });
                    dataTable.on('order.dt search.dt',
                        function () {
                            dataTable.column(0, {
                                search: 'applied',
                                order: 'applied'
                            }).nodes().each(function (cell, i) {
                                cell.innerHTML = i + 1;
                            });
                        }).draw();
                }
                //***********关闭loading
                ityzl_CLOSE_LOAD_LAYER(i);
            }
        });
    }

    function quarryOutValues(devtype, tltName, isOutIn) {
        window.onload = function () {
            setInterval("$('#tlt').text(parent.typetoName()+'->'+tltName+' '+getNowFormatDate())", 1000)
        }
        $.ajax({
            type: "POST",
            url: "/pqs9900/constant/quarryOutValue",
            data: {
                devtype: devtype,
                tltName: tltName,
                isOutIn: isOutIn,
                lineIndex: lineIndex
            },
            success: function (data) {
                jsonProp = data.body;
                if (data.code != 500) {
                    outvalue();
                    if (data.body[0].length == 0) {
                        document.getElementsByTagName("li")[0].style.display = "none";
                    }
                    if (data.body[1].length == 0) {
                        document.getElementsByTagName("li")[1].style.display = "none";
                    }
                    if (data.body[2].length == 0) {
                        document.getElementsByTagName("li")[2].style.display = "none";
                    }
                    if (data.body[3].length == 0) {
                        document.getElementsByTagName("li")[3].style.display = "none";
                    }
                    if (tltName == "基本定值") {
                        data = data.body[0];
                    } else if (tltName == "谐波电流") {
                        data = data.body[1]
                    } else if (tltName == "谐波电压") {
                        data = data.body[2];
                    } else {
                        data = data.body[3];
                    }
                    var heightTemp = screen.height;
                    var socy;
                    if (heightTemp === 768) {
                        socy = 440;
                    } else if (heightTemp <= 733) {
                        socy = 440;
                    } else if (heightTemp === 1050) {
                        socy = 480;
                    } else {
                        socy = 400;
                    }
                    if (data == null) {
                        number = 0;
                    } else {
                        number = data.length;
                    }
                    jsonList = data;
                    dataTable = $("#usertIds").DataTable();
                    dataTable.clear().draw();
                    dataTable = $('#usertIds').DataTable({
                        order: [],
                        "aaSorting": [[1, "desc"]],
                        columnDefs: [
                            {
                                orderable: false,
                                targets: [0, 1, 2, 3]
                            }
                        ],
                        data: data,
                        columns: [
                            {width: "10%", data: null},
                            {width: "15%", data: "describe"},
                            {
                                width: "10", data: "value",
                                render: function (data, type, full, meta) {
                                    var values, unit;
                                    if (data == null) {
                                        data = value;
                                    }
                                    unit = full.unit;
                                    if (unit == null) {

                                        unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                                    }
                                    values =
                                        "<input type='text' disabled id='" + meta.row + "' onblur='geizheng(this.value," +
                                        full.minValue + "," + full.maxValue + "," + meta.row +
                                        ")' style='margin-right:10px;' value='" + data.toFixed(3) +
                                        "'  onkeyup='if(isNaN(value))execCommand(\"undo\")' >" + unit;
                                    return values;
                                }
                            },
                            {
                                width: "10", data: "value",
                                render: function (data, type, full, meta) {
                                    var values, unit;
                                    if (data == null) {
                                        data = full.value;
                                    }
                                    unit = full.unit;
                                    if (unit == null) {

                                        unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                                    }
                                    values =
                                        "<input type='text' id='valueOk" + meta.row + "' onchange='geizheng(this.value," +
                                        full.minValue + "," + full.maxValue + "," + meta.row +
                                        ")' style='margin-right:10px;' value='" + data.toFixed(3) +
                                        "'  onkeyup='if(isNaN(value))execCommand(\"undo\")' >" + unit;
                                    return values;
                                }
                            },
                            {
                                width: "15%", data: "minValue",
                                render: function (data, type, full, meta) {
                                    var values;
                                    values = data + '-' + full.maxValue;
                                    return values;
                                }
                            },
                        ],
                        info: false,
                        scrollY: socy,
                        paging: false,
                        destroy: true,
                        searching: true,
                        dom: 'rtip',
                        language: {
                            url: '/pqs9900/json/chine.json',
                            "sEmptyTable": "没有内容"
                        },
                    });
                    dataTable.on('order.dt search.dt',
                        function () {
                            dataTable.column(0, {
                                search: 'applied',
                                order: 'applied'
                            }).nodes().each(function (cell, i) {
                                cell.innerHTML = i + 1;
                            });
                        }).draw();
                } else {
                    outvalueDes();

                    dataTable = $("#usertIds").DataTable();
                    //dataTable.clear().draw();
                    dataTable = $('#usertIds').DataTable({
                        order: [],
                        "aaSorting": [[1, "desc"]],
                        columnDefs: [
                            {
                                orderable: false,
                                targets: [0, 1, 2, 3]
                            }
                        ],
                        data: data,
                        columns: [
                            // {width: "10%", data: null},
                            // {width: "15%", data: "describe"},
                            // {
                            //     width: "10", data: "value",
                            //     render: function (data, type, full, meta) {
                            //         var values, unit;
                            //         if (data == null) {
                            //             data = full.defaultValue;
                            //         }
                            //         unit = full.unit;
                            //         if (unit == null) {
                            //
                            //             unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                            //         }
                            //         values =
                            //             "<input type='text' disabled id='" + meta.row + "' onblur='geizheng(this.value," +
                            //             full.minValue + "," + full.maxValue + "," + meta.row +
                            //             ")' style='margin-right:10px;' value='" + data.toFixed(3) +
                            //             "'  onkeyup='if(isNaN(value))execCommand(\"undo\")' >" + unit;
                            //         return values;
                            //     }
                            // },
                            // {
                            //     width: "10", data: "value",
                            //     render: function (data, type, full, meta) {
                            //         var values, unit;
                            //         if (data == null) {
                            //             data = full.defaultValue;
                            //         }
                            //         unit = full.unit;
                            //         if (unit == null) {
                            //
                            //             unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                            //         }
                            //         values =
                            //             "<input type='text' id='valueOk" + meta.row + "' onblur='geizheng(this.value," +
                            //             full.minValue + "," + full.maxValue + "," + meta.row +
                            //             ")' style='margin-right:10px;' value='" + data.toFixed(3) +
                            //             "'  onkeyup='if(isNaN(value))execCommand(\"undo\")' >" + unit;
                            //         return values;
                            //     }
                            // },
                            // {
                            //     width: "15%", data: "minValue",
                            //     render: function (data, type, full, meta) {
                            //         var values;
                            //         values = data + '-' + full.maxValue;
                            //         return values;
                            //     }
                            // },
                        ],
                        info: false,
                        scrollY: socy,
                        paging: false,
                        destroy: true,
                        searching: true,
                        dom: 'rtip',
                        language: {
                            url: '/pqs9900/json/chine.json',
                            "sEmptyTable": "没有内容"
                        },
                    });
                    dataTable.on('order.dt search.dt',
                        function () {
                            dataTable.column(0, {
                                search: 'applied',
                                order: 'applied'
                            }).nodes().each(function (cell, i) {
                                cell.innerHTML = i + 1;
                            });
                        }).draw();
                }
                //***********关闭loading
                ityzl_CLOSE_LOAD_LAYER(i);
            }
        })
    }

    function getDe() {
        return descri;
    }

    //默认
    function getConstanValue() {
        document.getElementById('isupdateTable').style.display = "";
        document.getElementById('isupdateTables').style.display = "none";
        if (isOutIn == "in") {
            document.getElementById('qualifiedTab').style.display = "none";
            quarryInValue($("#devtypes").val(), tltName, isOutIn);
        } else {
            quarryOutValue($("#devtypes").val(), tltName, isOutIn);
        }
    }

    //点击修改定值
    function getConstanValues() {
        document.getElementById('isupdateTable').style.display = "none";
        document.getElementById('isupdateTables').style.display = "";
        if (isOutIn == "in") {
            document.getElementById('qualifiedTab').style.display = "none";
            quarryInValues($("#devtypes").val(), tltName, isOutIn);
        } else {
            quarryOutValues($("#devtypes").val(), tltName, isOutIn);
        }
    }

    function quarryInValue(devtype, tltName, isOutIn) {
        window.onload = function () {
            setInterval("$('#tlt').text(parent.typetoName()+'->'+''+' '+getNowFormatDate())", 1000)
        }
        $.ajax({
            type: "POST",
            url: "/pqs9900/constant/quarryOutValue",
            data: {
                devtype: devtype,
                tltName: tltName,
                isOutIn: isOutIn,
                lineIndex: devIndex
            },
            success: function (data) {

                var heightTemp = screen.height;
                var socy;
                if (heightTemp === 768) {
                    socy = 460;
                } else if (heightTemp <= 733) {
                    socy = 460;
                } else if (heightTemp === 1050) {
                    socy = 480;
                } else {
                    socy = 400;
                }
                if (data.body == null) {
                    number = 0;
                } else {
                    number = data.body.length;
                }
                //没有权限的请求
                if (data.code == 300) {
                    location.href = '/pqs9900/auth/unauthorized';
                    //没有登陆的请求
                } else if (data.code == 301) {
                    location.href = '/pqs9900';
                } else if (data.code == 500) {
                    insidevalueDes();
                    dataTable = $("#usertId").DataTable();
                    //dataTable.clear().draw();
                    dataTable = $('#usertId').DataTable({
                        order: [],
                        columnDefs: [
                            {
                                orderable: false,
                                targets: [0, 1, 2, 3]
                            }
                        ],
                        data: data.body,
                        columns: [
                            // {width: "10%", data: null},
                            // {width: "15%", data: "describe"},
                            // {
                            //     width: "10", data: "value",
                            //     render: function (data, type, full, meta) {
                            //         var values, unit;
                            //         if (data == null) {
                            //             data = full.defaultValue;
                            //         }
                            //         unit = full.unit;
                            //         if (unit == null) {
                            //
                            //             unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                            //         }
                            //         if (unit == "分" || unit == "%") {
                            //             data = data;
                            //             values =
                            //                 "<input type='text' disabled " + meta.row +
                            //                 "  style='margin-right:10px;' value='" +
                            //                 data + "'>"
                            //                 + unit;
                            //         } else {
                            //             data = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4);
                            //             values =
                            //                 "<input type='text' disabled" + meta.row +
                            //                 "  style='margin-right:10px;' value='" +
                            //                 data + "'>"
                            //                 + unit;
                            //         }
                            //
                            //         return values;
                            //     }
                            // },
                            // {
                            //     width: "15%", data: "minValue",
                            //     render: function (data, type, full, meta) {
                            //         var values;
                            //         if (full.unit == "分" || full.unit == "%") {
                            //             values = data + '-' + full.maxValue;
                            //         } else {
                            //             values = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4) + '-' + (Array(4).join('0') + ((full.maxValue).toString(16)).toUpperCase()).slice(-4);
                            //         }
                            //
                            //         return values;
                            //     }
                            // },
                        ],
                        info: false,
                        scrollY: socy,
                        paging: false,
                        destroy: true,
                        searching: true,
                        dom: 'rtip',
                        language: {
                            url: '/pqs9900/json/chine.json',
                            "sEmptyTable": "没有内容"
                        },
                    });
                    dataTable.on('order.dt search.dt',
                        function () {
                            dataTable.column(0, {
                                search: 'applied',
                                order: 'applied'
                            }).nodes().each(function (cell, i) {
                                cell.innerHTML = i + 1;
                            });
                        }).draw();
                } else {
                    insidevalue();
                    jsonList = data.body;
                    dataTable = $("#usertId").DataTable();
                    dataTable.clear().draw();
                    dataTable = $('#usertId').DataTable({
                        order: [],
                        "aaSorting": [[1, "desc"]],
                        columnDefs: [
                            {
                                orderable: false,
                                targets: [0, 1, 2, 3]
                            }
                        ],
                        data: data.body,
                        columns: [
                            {width: "10%", data: null},
                            {width: "15%", data: "describe"},
                            {
                                width: "10", data: "value",
                                render: function (data, type, full, meta) {
                                    var values, unit, pvIndex, describe;
                                    if (data == null) {
                                        data = full.value;
                                    }
                                    pvIndex = full.pvIndex;
                                    unit = full.unit;
                                    pvIndex = '"' + pvIndex + '"';
                                    describe = '"' + full.describe + '"';
                                    if (unit == null) {

                                        unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                                    }
                                    var isFt = 0;
                                    $.ajax({
                                        type: "POST",
                                        url: "/pqs9900/protectcw/getIsFT",
                                        dataType: "text",
                                        async: false,
                                        data: {
                                            pvIndex: full.pvIndex
                                        },
                                        success: function (data) {
                                            isFt = data;
                                        }
                                    })
                                    var isUpdate = 0;
                                    if (unit == "分" || unit == "%") {
                                        data = data;
                                        values =
                                            "<input type='text' disabled id='" + meta.row + "' " +
                                            "onkeyup='(this.v=function(){this.value=this.value.replace(/[^0-9]+/,\"\");}).call(this)'" +
                                            "onblur='getfw(this.value,\" +\n" +
                                            "full.minValue + \",\" + full.maxValue + \",\"+meta.row+\")'" +
                                            "  style='margin-right:10px;' value='" +
                                            data + "'>"
                                            + unit;
                                    } else {
                                        data = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4);
                                        values =
                                            "<input type='text'  readonly='readonly' " +
                                            "onclick='select_tab(" + pvIndex + "," + describe + "," + meta.row + "," + isUpdate + ")'" +
                                            "  style='margin-right:10px;' value='" +
                                            data + "' >"
                                            + unit;
                                    }

                                    return values;
                                }
                            },
                            {
                                width: "15%", data: "minValue",
                                render: function (data, type, full, meta) {
                                    var values;
                                    if (full.unit == "分" || full.unit == "%") {
                                        values = data + '-' + full.maxValue;
                                    } else {
                                        values = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4) + '-' + (Array(4).join('0') + ((full.maxValue).toString(16)).toUpperCase()).slice(-4);
                                    }

                                    return values;
                                }
                            },
                        ],
                        info: false,
                        scrollY: socy,
                        paging: false,
                        destroy: true,
                        searching: true,
                        dom: 'rtip',
                        language: {
                            url: '/pqs9900/json/chine.json',
                            "sEmptyTable": "没有内容"
                        },
                    });
                    dataTable.on('order.dt search.dt',
                        function () {
                            dataTable.column(0, {
                                search: 'applied',
                                order: 'applied'
                            }).nodes().each(function (cell, i) {
                                cell.innerHTML = i + 1;
                            });
                        }).draw();
                }
                //***********关闭loading
                ityzl_CLOSE_LOAD_LAYER(i);
            }
        });
    }

    function quarryInValues(devtype, tltName, isOutIn) {
        window.onload = function () {
            setInterval("$('#tlt').text(parent.typetoName()+'->'+''+' '+getNowFormatDate())", 1000)
        }
        $.ajax({
            type: "POST",
            url: "/pqs9900/constant/quarryOutValue",
            data: {
                devtype: devtype,
                tltName: tltName,
                isOutIn: isOutIn,
                lineIndex: devIndex
            },
            success: function (data) {

                var heightTemp = screen.height;
                var socy;
                if (heightTemp === 768) {
                    socy = 460;
                } else if (heightTemp <= 733) {
                    socy = 460;
                } else if (heightTemp === 1050) {
                    socy = 480;
                } else {
                    socy = 400;
                }
                if (data.body == null) {
                    number = 0;
                } else {
                    number = data.body.length;
                }
                //没有权限的请求
                if (data.code == 300) {
                    location.href = '/pqs9900/auth/unauthorized';
                    //没有登陆的请求
                } else if (data.code == 301) {
                    location.href = '/pqs9900';
                } else if (data.code == 500) {
                    insidevalueDes();
                    dataTable = $("#usertIds").DataTable();
                    //dataTable.clear().draw();
                    dataTable = $('#usertIds').DataTable({
                        order: [],
                        columnDefs: [
                            {
                                orderable: false,
                                targets: [0, 1, 2, 3]
                            }
                        ],
                        data: data.body,
                        columns: [
                            // {width: "10%", data: null},
                            // {width: "15%", data: "describe"},
                            // {
                            //     width: "10", data: "value",
                            //     render: function (data, type, full, meta) {
                            //         var values, unit;
                            //         if (data == null) {
                            //             data = full.defaultValue;
                            //         }
                            //         unit = full.unit;
                            //         if (unit == null) {
                            //
                            //             unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                            //         }
                            //         if (unit == "分" || unit == "%") {
                            //             data = data;
                            //             values =
                            //                 "<input type='text' disabled " + meta.row +
                            //                 "  style='margin-right:10px;' value='" +
                            //                 data + "'>"
                            //                 + unit;
                            //         } else {
                            //             data = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4);
                            //             values =
                            //                 "<input type='text' disabled" + meta.row +
                            //                 "  style='margin-right:10px;' value='" +
                            //                 data + "'>"
                            //                 + unit;
                            //         }
                            //
                            //         return values;
                            //     }
                            // },
                            // {
                            //     width: "10", data: "value",
                            //     render: function (data, type, full, meta) {
                            //         var values, unit, pvIndex, describe;
                            //         if (data == null) {
                            //             data = full.defaultValue;
                            //         }
                            //         pvIndex = full.pvIndex;
                            //         unit = full.unit;
                            //         pvIndex = '"' + pvIndex + '"';
                            //         describe = '"' + full.describe + '"';
                            //         if (unit == null) {
                            //
                            //             unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                            //         }
                            //         if (unit == "分" || unit == "%") {
                            //             data = data;
                            //             values =
                            //                 "<input type='text' id='valDz" + meta.row + "' " +
                            //                 "onkeyup='(this.v=function(){this.value=this.value.replace(/[^0-9]+/,\"\");}).call(this)'" +
                            //                 "onblur='getfw(this.value,\" +\n" +
                            //                 "full.minValue + \",\" + full.maxValue + \",\"+meta.row+\")'" +
                            //                 "  style='margin-right:10px;' value='" +
                            //                 data + "'>"
                            //                 + unit;
                            //         } else {
                            //             data = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4);
                            //             values =
                            //                 "<input type='text' id='valDz" + meta.row + "' " +
                            //                 "onclick='select_tab(" + pvIndex + "," + describe + "," + meta.row + ")'" +
                            //                 "  style='margin-right:10px;' value='" +
                            //                 data + "' >"
                            //                 + unit;
                            //         }
                            //
                            //         return values;
                            //     }
                            // },
                            // {
                            //     width: "15%", data: "minValue",
                            //     render: function (data, type, full, meta) {
                            //         var values;
                            //         if (full.unit == "分" || full.unit == "%") {
                            //             values = data + '-' + full.maxValue;
                            //         } else {
                            //             values = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4) + '-' + (Array(4).join('0') + ((full.maxValue).toString(16)).toUpperCase()).slice(-4);
                            //         }
                            //
                            //         return values;
                            //     }
                            // },
                        ],
                        info: false,
                        scrollY: socy,
                        paging: false,
                        destroy: true,
                        searching: true,
                        dom: 'rtip',
                        language: {
                            url: '/pqs9900/json/chine.json',
                            "sEmptyTable": "没有内容"
                        },
                    });
                    dataTable.on('order.dt search.dt',
                        function () {
                            dataTable.column(0, {
                                search: 'applied',
                                order: 'applied'
                            }).nodes().each(function (cell, i) {
                                cell.innerHTML = i + 1;
                            });
                        }).draw();
                } else {
                    insidevalue();
                    jsonList = data.body;
                    dataTable = $("#usertIds").DataTable();
                    dataTable.clear().draw();
                    dataTable = $('#usertIds').DataTable({
                        order: [],
                        "aaSorting": [[1, "desc"]],
                        columnDefs: [
                            {
                                orderable: false,
                                targets: [0, 1, 2, 3]
                            }
                        ],
                        data: data.body,
                        columns: [
                            {width: "10%", data: null},
                            {width: "15%", data: "describe"},
                            {
                                width: "10", data: "value",
                                render: function (data, type, full, meta) {
                                    var values, unit, pvIndex, describe;
                                    if (data == null) {
                                        data = full.value;
                                    }
                                    pvIndex = full.pvIndex;
                                    unit = full.unit;
                                    pvIndex = '"' + pvIndex + '"';
                                    describe = '"' + full.describe + '"';
                                    if (unit == null) {

                                        unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                                    }
                                    var isFt = 0;
                                    $.ajax({
                                        type: "POST",
                                        url: "/pqs9900/protectcw/getIsFT",
                                        dataType: "text",
                                        async: false,
                                        data: {
                                            pvIndex: full.pvIndex
                                        },
                                        success: function (data) {
                                            isFt = data;
                                        }
                                    })
                                    if (unit == "分" || unit == "%") {
                                        data = data;
                                        values =
                                            "<input type='text' disabled id='" + meta.row +
                                            "  style='margin-right:10px;' value='" +
                                            data + "'>"
                                            + unit;
                                    } else {
                                        data = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4);
                                        values =
                                            "<input type='text' disabled readonly id='" + meta.row +
                                            "  style='margin-right:10px;' value='" +
                                            data + "'>"
                                            + unit;
                                    }

                                    return values;
                                }
                            },
                            {
                                width: "10", data: "value",
                                render: function (data, type, full, meta) {
                                    var values, unit, pvIndex, describe;
                                    if (data == null) {
                                        data = full.value;
                                    }
                                    pvIndex = full.pvIndex;
                                    unit = full.unit;
                                    pvIndex = '"' + pvIndex + '"';
                                    describe = '"' + full.describe + '"';
                                    if (unit == null) {

                                        unit = "&nbsp;&nbsp;&nbsp;&nbsp";
                                    }
                                    var isFt = 0;
                                    $.ajax({
                                        type: "POST",
                                        url: "/pqs9900/protectcw/getIsFT",
                                        dataType: "text",
                                        async: false,
                                        data: {
                                            pvIndex: full.pvIndex
                                        },
                                        success: function (data) {
                                            isFt = data;
                                        }
                                    })
                                    var isUpdate = 1;
                                    if (unit == "分" || unit == "%") {
                                        data = data;
                                        values =
                                            "<input type='text' id='valDz" + meta.row + "' " +
                                            "onkeyup='(this.v=function(){this.value=this.value.replace(/[^0-9]+/,\"\");}).call(this)'" +
                                            "onblur='getfw(this.value," + full.minValue + "," + full.maxValue + "," + meta.row + ")'" +
                                            "  style='margin-right:10px;' value='" +
                                            data + "' >"
                                            + unit;
                                    } else if (isFt == 0) {
                                        data = data;
                                        values =
                                            "<input type='text' readonly  id='valDz" + meta.row + "' " +
                                            "onkeyup='(this.v=function(){this.value=this.value.replace(/[^0-9]+/,\"\");}).call(this)'" +
                                            "onblur='getfw(this.value," + full.minValue + "," + full.maxValue + "," + meta.row + ")'" +
                                            "  style='margin-right:10px;' value='" +
                                            data + "' >"
                                            + unit;
                                    } else {
                                        data = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4);
                                        values =
                                            "<input type='text' readonly='readonly' id='valDz" + meta.row + "' " +
                                            "onclick='select_tab(" + pvIndex + "," + describe + "," + meta.row + "," + isUpdate + ")'" +
                                            "  style='margin-right:10px;' value='" +
                                            data + "' >"
                                            + unit;
                                    }

                                    return values;
                                }
                            },
                            {
                                width: "15%", data: "minValue",
                                render: function (data, type, full, meta) {
                                    var values;
                                    if (full.unit == "分" || full.unit == "%") {
                                        values = data + '-' + full.maxValue;
                                    } else {
                                        values = (Array(4).join('0') + (data.toString(16)).toUpperCase()).slice(-4) + '-' + (Array(4).join('0') + ((full.maxValue).toString(16)).toUpperCase()).slice(-4);
                                    }

                                    return values;
                                }
                            },
                        ],
                        info: false,
                        scrollY: socy,
                        paging: false,
                        destroy: true,
                        searching: true,
                        dom: 'rtip',
                        language: {
                            url: '/pqs9900/json/chine.json',
                            "sEmptyTable": "没有内容"
                        },
                    });
                    dataTable.on('order.dt search.dt',
                        function () {
                            dataTable.column(0, {
                                search: 'applied',
                                order: 'applied'
                            }).nodes().each(function (cell, i) {
                                cell.innerHTML = i + 1;
                            });
                        }).draw();
                }
                //***********关闭loading
                ityzl_CLOSE_LOAD_LAYER(i);
            }
        });
    }

    //外部定值
    function outvalue() {
        // document.getElementById("insidevalue").style.display = "none";
        // document.getElementById("outervalue").style.display = "block";
        document.getElementById("insidevalueDescribe").style.display = "none";
        document.getElementById("outervalueDescribe").style.display = "block";
    }

    //内部定值
    function insidevalue() {
        // document.getElementById("insidevalue").style.display = "block";
        // document.getElementById("outervalue").style.display = "none";
        document.getElementById("insidevalueDescribe").style.display = "block";
        document.getElementById("outervalueDescribe").style.display = "none";
    }

    //外部定值描述
    function outvalueDes() {
        // document.getElementById("insidevalue").style.display = "none";
        // document.getElementById("outervalue").style.display = "none";
        document.getElementById("insidevalueDescribe").style.display = "none";
        document.getElementById("outervalueDescribe").style.display = "block";
    }

    //内部定值描述
    function insidevalueDes() {
        // document.getElementById("insidevalue").style.display = "none";
        // document.getElementById("outervalue").style.display = "none";
        document.getElementById("insidevalueDescribe").style.display = "block";
        document.getElementById("outervalueDescribe").style.display = "none";
    }


    function getPro(pvIndex) {
        $.ajax({
            type: "POST",
            url: "/pqs9900/protectcw/getAll",
            dataType: "text",
            async: false,
            data: {
                pvIndex: pvIndex
            },
            success: function (data) {
                getProper = $.parseJSON(data);
            }
        })
    }

    function select_tab(pvIndex, describe, row, isUpdate) {
        descri = describe;
        isTrue = true;
        $("#row").val(row);
        $("#isUpdate").val(isUpdate);
        layer.open({
            type: 2,
            title: describe,
            area: ['25%', '60%'],
            content: '/pqs9900/business/dzglin?pvIndex=' + pvIndex,
            scrollbar: true
        });
    }

    $('#usertIds tbody').on('click', 'tr', function () {
        var data = table.row(this).data();
        alert('You clicked on ' + data[0] + '\'s row');
    });

    function geizheng(value, min, max, row) {
        if (value < min || value > max) {
            $("#valueOk" + row + "").css("background", "#ff6347");
        } else {
            $("#valueOk" + row + "").css("background-color", '');
        }
        $("#valueOk" + row + "")[0].style.border = "1px solid red";
    }

    function getfw(value, min, max, row) {
        if (value < min || value > max) {
            $("#valDz" + row + "").css("background-color", "#ff6347");
        } else {
            $("#valDz" + row + "").css("background-color", '');
        }
        $("#valDz" + row + "")[0].style.border = "1px solid red";
    }

    //将值发送到socket中
    function startWebSocket(type, linendex, hander) {

        //获取端口号
        $.ajax({
            url: '/pqs9900/device/socketon',
            type: 'post',
            //contentType: 'application/json;charset=UTF-8',
            data: {
                typeid: type,
                lineIndex: linendex,
                hander: hander
            },
            beforeSend: function () {
                i = ityzl_SHOW_LOAD_LAYER();
            },
            async:false,
            dataType: 'json',
            success: function (data) {
                layer.msg(data, {
                    time: 3000
                });
                isFalse = false;
                isXf = false;
                typei = 80;
                getValue(typei);
            }
        })
    }

    //将值发送到socket中
    function startWebSocketDev(type, linendex, hander) {
        //获取端口号
        $.ajax({
            url: '/pqs9900/device/socketonDev',
            type: 'post',
            //contentType: 'application/json;charset=UTF-8',
            data: {
                typeid: type,
                lineIndex: linendex,
                hander: hander
            },
            async:false,
            beforeSend: function () {
                i = ityzl_SHOW_LOAD_LAYER();
            },
            dataType: 'json',
            success: function (data) {
                layer.msg(data, {
                    time: 3000
                });
            }
        })
    }

    //获取定值
    function getValue(typei) {
        hander = 0;
        startWebSocket(typei, lineIndex, hander);
    }

    //获取定值描述
    function getDescribeDev(typei) {
        hander = 1;
        startWebSocketDev(typei, lineIndex, hander);
    }

    //获取定值
    function getValueDev(typei) {
        hander = 0;
        startWebSocketDev(typei, lineIndex, hander);
    }

    //获取定值描述
    function getDescribe(typei) {
        hander = 1;
        startWebSocket(typei, lineIndex, hander);
    }

    //定值和定值描述的对比
    function comparisonValueDescribe(typei, json1) {
        /**number表示的是当前数据库中定值或者描述条数
         *dataDescrie表示的是通过（websocket）获取的定值（定值描述）的条数
         * hander用于区分获取的是定值还是定值描述
         **/
        if (hander == 0) {
            updateDatabaseValue(json1);
        } else if (hander == 1) {
            updateDatabase(json1);
        }
    }

    //更新数据库（定值）
    function updateDatabaseValue(json) {
        $.ajax({
            type: "POST",
            timeout: 10000,
            url: "/pqs9900/constant/updateDatabaseValue",
            async: false,
            data: {
                json: JSON.stringify(json)
            },
            success: function (data) {
                // if (data == 1) {
                //     console.log(data)
                //     layer.msg("请求成功", {
                //         icon: 6,
                //         time: 3000
                //     })
                // } else {
                //     layer.msg("定值入库失败！", {
                //         icon: 5,
                //         time: 3000
                //     })
                // }
                // document.getElementById("updateConValues").style.display = "";
                // document.getElementById("updateConValues").disabled = false
                document.getElementById("updateValue").style.display = "none"
                if (typei == 90) {
                    for (var i = 0; i < number; i++) {
                        //$("#valDz" + i + "").attr("disabled", false)
                    }
                } else {
                    for (var i = 0; i < number; i++) {
                        //$("#valueOk" + i + "").attr("disabled", false)
                    }
                }
                getConstanValue();
            }
        })
    }

    //更新数据库(定值描述)
    function updateDatabase(json1) {
        $.ajax({
            type: "POST",
            timeout: 10000,
            url: "/pqs9900/constant/updateDatabase",
            async: true,
            data: {
                json1: JSON.stringify(json1),
                hander: hander,
                type: typei
            },
            success: function (data) {
                if (typei == 90) {
                    isFalse = true;
                    isXf = false;
                    typei = 90;
                    getValueDev(typei);
                } else {
                    isFalse = false;
                    isXf = false;
                    typei = 80;
                    getValue(typei);
                }
            }
        })
    }

    //改变列表的状态
    function chooseState() {
        return isFalse;
    }

    /***
     * type    内外定值的区分 80：外部定值 90：内部定值
     * " Index ":"xxx" //终端/监测点ID
     * " Hander":"xxx" //操作标识  0：定值   1：定值描述
     * number==0,则进行定值描述的获取，否则进行定值的获取
     */
    //内部定值的请求
    $("#insidevalue").click(function () {
        isFalse = true;
        isXf = false;
        typei = 90;
        getValueDev(typei);
        document.getElementById("updateConValues").style.display = "";

    })
    //外部定值的请求
    $("#outervalue").click(function () {
        isFalse = false;
        isXf = false;
        typei = 80;
        getValue(typei);
        document.getElementById("updateConValues").style.display = "";
    })

    //内部定值描述的请求
    $("#insidevalueDescribe").click(function () {
        restartNum = 0
        isFalse = true;
        isXf = false;
        typei = 90;
        getDescribeDev(typei);
        document.getElementById("updateConValues").style.display = "";
        document.getElementById("updateConValues").disabled = false
    })
    //外部定值描述的请求
    $("#outervalueDescribe").click(function () {
        isFalse = false;
        isXf = false;
        typei = 80;
        getDescribe(typei);
        document.getElementById("updateConValues").style.display = "";
        document.getElementById("updateConValues").disabled = false
    })
    //定值修改
    $("#updateConValues").click(function () {
        var resetName = "定值修改";
        var username = $("#username").val();
        // passwordLocalIndentity(username,resetName,function () {
        //     console.log("sss");
        // })
        passwordLocalIndentity(username, resetName, function () {
            document.getElementById('isupdateTable').style.display = "none";
            document.getElementById('isupdateTables').style.display = "";
            getConstanValues();
            document.getElementById('updateConValues').style.display = "none";
            document.getElementById('updateValue').style.display = "";
        })
    })
    //定值下发
    $("#updateValue").click(function () {
        isXf = true;
        var num = 0;
        var resetName = "下发定值";
        var username = $("#username").val();
        passwordIndentity(username, resetName, function () {
            obj = [];
            if (isOutIn == "out") {
                for (var i = 0; i < number; i++) {
                    var rgb = document.getElementById("valueOk" + i + "").style.backgroundColor;
                    //判断当前文本框的定值是否超过定值范围
                    if (rgb != "") {
                        num++;
                    }
                }
                if (num > 0) {
                    layer.msg("有定值超过范围，请查看", {icon: 5})
                } else {
                    //下发定值
                    if (tltName == "基本定值") {
                        for (var j = 0; j < number; j++) {
                            obj.push(parseFloat($("#valueOk" + j + "").val()));
                        }
                        for (var i = 0; i < jsonProp[1].length; i++) {
                            obj.push(jsonProp[1][i].value)
                        }
                        for (var a = 0; a < jsonProp[2].length; a++) {
                            obj.push(jsonProp[2][a].value)
                        }
                        for (var b = 0; b < jsonProp[3].length; b++) {
                            obj.push(jsonProp[3][b].value)
                        }
                    } else if (tltName == "谐波电流") {
                        for (var i = 0; i < jsonProp[0].length; i++) {
                            obj.push(jsonProp[0][i].value)
                        }
                        for (var j = 0; j < number; j++) {
                            obj.push(parseFloat($("#valueOk" + j + "").val()));
                        }
                        for (var a = 0; a < jsonProp[2].length; a++) {
                            obj.push(jsonProp[2][a].value)
                        }
                        for (var b = 0; b < jsonProp[3].length; b++) {
                            obj.push(jsonProp[3][b].value)
                        }
                    } else if (tltName == "谐波电压") {
                        for (var i = 0; i < jsonProp[0].length; i++) {
                            obj.push(jsonProp[0][i].value)
                        }
                        for (var a = 0; a < jsonProp[1].length; a++) {
                            obj.push(jsonProp[1][a].value)
                        }
                        for (var j = 0; j < number; j++) {
                            obj.push(parseFloat($("#valueOk" + j + "").val()));
                        }
                        for (var b = 0; b < jsonProp[3].length; b++) {
                            obj.push(jsonProp[3][b].value)
                        }
                    } else if (tltName == "间谐波定值") {
                        for (var i = 0; i < jsonProp[0].length; i++) {
                            obj.push(jsonProp[0][i].value)
                        }
                        for (var a = 0; a < jsonProp[1].length; a++) {
                            obj.push(jsonProp[1][a].value)
                        }
                        for (var b = 0; b < jsonProp[2].length; b++) {
                            obj.push(jsonProp[2][b].value)
                        }
                        for (var j = 0; j < number; j++) {
                            obj.push(parseFloat($("#valueOk" + j + "").val()));
                        }
                    }
                    hander = 2;
                    var Value = obj.toString();

                    var ajaxTimeoutTest = $.ajax({
                        type: "POST",
                        timeout: 10000,
                        url: "/pqs9900/device/updatesocketon",
                        async: true,
                        data: {
                            typeid: 80,
                            hander: hander,
                            value: Value,
                            lineIndex: lineIndex
                        },
                        success: function (data) {
                            hander = 0;
                            if (typei == 80) {
                                getValue(typei);
                            } else {
                                getValueDev(typei);
                            }
                            //startWebSocket(typei, lineIndex, 0);
                            hander = 3;
                        }
                    })
                }
            } else {
                for (var i = 0; i < number; i++) {
                    var rgb = document.getElementById("valDz" + i + "").style.backgroundColor;
                    //判断当前文本框的定值是否超过定值范围
                    if (rgb != "") {
                        num++;
                    }
                }
                if (num > 0) {
                    layer.msg("有定值超过范围，请查看", {icon: 5})
                } else {
                    for (var j = 0; j < number; j++) {
                        if (j == number - 1 || j == number - 2) {
                            obj.push(parseInt($("#valDz" + j + "").val() * 100));
                        } else {
                            obj.push(parseInt($("#valDz" + j + "").val(), 16));
                        }
                    }
                    hander = 2;
                    interValue = obj.toString();
                    var ajaxTimeoutTest = $.ajax({
                        type: "POST",
                        timeout: 10000,
                        url: "/pqs9900/device/updatesocketonDev",
                        async: true,
                        data: {
                            typeid: 90,
                            hander: hander,
                            interValue: interValue,
                            lineIndex: lineIndex
                        },
                        success: function (data) {
                            hander = 0;
                            if (typei == 80) {
                                getValue(typei);
                            } else {
                                getValueDev(typei);
                            }
                            //startWebSocket(typei, lineIndex, 0);
                            hander = 3;
                        }
                    })
                }
            }
        })
    })

    function arrayEqual(arr1, arr2) {
        if (arr1 === arr2) return true;
        if (arr1.length != arr2.length) return false;
        for (var i = 0; i < arr1.length; ++i) {
            if (arr1[i] !== arr2[i]) return false;
        }
        return true;
    }

</script>
</body>
</html>