123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 |
- <!DOCTYPE html>
- <html lang="zh">
- <!-- SELECT t_id,t_name,MIN(t_t),MIN(t_rh),MAX(t_t),MAX(t_rh) FROM `Z_DeviceData_KF20220620145301` WHERE `t_time` >= '2022-6-28 02:00:00' AND `t_time` <= '2022-6-28 08:00:00' AND t_id = 1 -->
- <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">
- <title>Document</title>
- <!-- <link rel="stylesheet" href="https://unpkg.com/layui@2.6.8/dist/css/layui.css"> -->
- <script src="/static/js/jquery-3.1.1.min.js"></script>
- <link type="text/css" rel="stylesheet" href="/static/css/layui.css" />
- <link type="text/css" rel="stylesheet" href="/static/css/jedate.css">
- <link type="text/css" rel="stylesheet" href="/static/css/xcConfirm.css">
- <script type="text/javascript" src="/static/js/jedate.js"></script>
- <script src="/static/js/jquery.custom.imitate.editor-v1.0.js"></script>
- <script src="/static/js/jedate.min.js"></script>
- <script src="/static/js/xcConfirm.js" type="text/javascript" charset="utf-8"></script>
- <style>
- .div2 {
- min-height: 20vh;
- /* display: flex; */
- flex-direction: column;
- background-color: lightgray;
- }
- .div2 .content {
- flex: 1 0 auto;
- display: flex;
- }
- .div2 .content article {
- flex: 1 0 auto;
- /* background-color: green; */
- }
- .div2 header,
- .div2 footer {
- /* background-color: bisque; */
- }
- #text1 {
- width: 130%;
- background-color: #282923;
- height: 600px;
- padding-top: 10px;
- padding-right: 10px;
- padding-bottom: 10px;
- color: #f8f8f2;
- font-size: 16px;
- }
- #text2 {
- width: 100%;
- background-color: black;
- height: 600px;
- padding-top: 10px;
- padding-right: 10px;
- padding-bottom: 10px;
- color: #f8f8f2;
- font-size: 16px;
- /* margin-left: 4%; */
- }
- #toto {
- width: 160px;
- height: 50px;
- /* border: black 1px solid; */
- position: absolute;
- display: inline-block;
- float: left;
- font-size: 20px;
- }
- #BUT {
- height: 70px;
- width: 50%;
- /* border: red solid 1px; */
- position: absolute;
- margin-top: -2%;
- margin-left: 96%;
- }
- button {
- width:70px;
- height: 40px;
- background: lightcyan;
- font-size: 20px;
- }
- input {
- width: 70%;
- height: 24px;
- border: 1px #393D49 solid;
- }
- table {
- width: 95%;
- /* border: 1px red solid; */
- /* margin-bottom: 10px; */
- }
- .hide{
- display: none;
- }
- .co{
- color: red;
- }
- </style>
- </head>
- <body style="overflow-x: hidden;">
- <div class="div2">
- <header>
- <table border="0" cellspacing="" cellpadding="" style="height: 120px;">
- <tr>
- <th style="width: 200px;">温度下限<input type="text" id="T_Tlower"></th>
- <th style="width: 200px;">温度上限<input type="text" id="T_Tupper"></th>
- <th style="width: 200px;">湿度下限<input type="text" id="T_RHlower"></th>
- <th style="width: 200px;">湿度上限<input type="text" id="T_RHupper"></th>
- <th style="width: 200px;">GPS:<input type="text" id="T_Site" value="1"></th>
- <th style="width: 200px;">电量:<input type="text" id="T_Dattery" value="0"></th>
- </tr>
- <tr>
- <th style="width: 400px;">sn:<input type="text" id="sn"></th>
- <th style="width: 180px;">名称:<input type="text" id="name" style="width: 70%;"></th>
- <th>ID:<input type="text" id="ID" style="width: 40%;"></th>
- <th style="width: 240px;">开始时间:<input type="text" id="start_date" style="width: 60%;"></th>
- <th style="width: 240px;">结束时间:<input type="text" id="end_date" style="width: 60%;"></th>
- <th>时间间隔:<input type="text" id="date_num" style="width: 40%;"></th>
- <th id="qushi" style="width: 200px;">
- 趋势:
- <select name="" id="Trend" style="background-color: white; width: 80px;">
- <option value="" id="data">原始</option>
- <option value="" id="up">上升</option>
- <option value="" id="down">下降</option>
- <option value="" id="mild">平缓</option>
- <option value="" id="model">模板</option>
- </select>
- </th>
- <th>
- <!-- <a id="puti" style="width: 70px;height: 30px;font-size: 1.2em;background-color: cadetblue;color: white; font-weight: 400;">图表</a> -->
- <button type="button" id="CS" style="width: 70px;height: 30px;font-size: 1.2em;background-color: cadetblue;color: white; font-weight: 400;">语句</button>
- </th>
- <th>
- <!-- <a id="puti" style="width: 70px;height: 30px;font-size: 1.2em;background-color: cadetblue;color: white; font-weight: 400;">图表</a> -->
- <button type="button" id="puti" style="width: 70px;height: 30px;font-size: 1.2em;background-color: cadetblue;color: white; font-weight: 400;">生成</button>
- </th>
- </tr>
- <tr>
- <th id="t_max">最高温度:<input type="text" id="temp_max" style="width:20%;"></th>
- <th id="t_min">最低温度:<input type="text" id="temp_mix" style="width: 40%;"></th>
- <th class="hide" id="gee">温度偏差:<input type="text" id="ge" style="width: 40%;"></th>
- <th id="humi_x">最大湿度:<input type="text" id="humi_max" style="width: 40%;"></th>
- <th id="humi_m">最小湿度:<input type="text" id="humi_mix" style="width: 40%;"></th>
- <th class="hide" id="shi_ge">湿度偏差:<input type="text" id="shi_g" style="width: 40%;"></th>
- <th colspan="12" class="hide" id="mol">温度数据:<input type="text" style="width: 85%;" id="tempData"></th>
- </tr>
- <tr>
- <th colspan="12" class="hide" id="wel">湿度数据:<input type="text" style="width: 85%;" id="humi_Data"></th>
- </tr>
- </table>
- <div id="BUT">
- <button type="button" id="but" class="layui-btn layui-btn-lg">提交</button>
- </div>
- </header>
- <!--<div class="content">
- <!– <aside></aside> –>
- <article>
- <div style="width: 100%;height: 600px;position: relative;">
- <div class="layui-row">
- <div class="layui-col-md10">
- <div style="width: 100%;height: 600px;">
- <textarea type="text" id="text1" class="text"></textarea>
- </div>
- </div>
- <div class="layui-col-md1">
- <div id="toto">
- <textarea type="text" id="text2" class="text"></textarea>
- <!– <span></span> –>
- </div>
- </div>
- </div>
- </div>
- </article>
- </div>-->
- <!-- <footer>footer</footer> -->
- </div>
- <div id="container" style="height: 600px;margin-top: 20px;"></div>
- <div id="container1" style="height: 600px;"></div>
- <!-- <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script> -->
- <script type="text/javascript" src="https://fastly.jsdelivr.net/npm/echarts@5.3.3/dist/echarts.min.js"></script>
- <script>
- jeDate("#start_date", {
- festival: false,
- minDate: "1900-01-01", //最小日期
- maxDate: "2099-12-31", //最大日期
- method: {
- choose: function(params) {
- // console.log(params);
- }
- },
- format: "YYYY-MM-DD hh:mm:ss"
- });
- jeDate("#end_date", {
- festival: false,
- minDate: "1900-01-01", //最小日期
- maxDate: "2099-12-31", //最大日期
- method: {
- choose: function(params) {
- // console.log(params);
- }
- },
- format: "YYYY-MM-DD hh:mm:ss"
- });
- $("#text1,#text2").initTextarea();
- function getData() {
- var data = {
- "sn": $("#sn").val(),
- "name": $("#name").val(),
- "ID": parseInt($("#ID").val()),
- "temp_max": parseFloat($("#temp_max").val()),
- "temp_mix": parseFloat($("#temp_mix").val()),
- "humi_max": parseFloat($("#humi_max").val()),
- "humi_mix": parseFloat($("#humi_mix").val()),
- "start_date": $("#start_date").val(),
- "end_date": $("#end_date").val(),
- "date_num": parseInt($("#date_num").val()),
- "T_Tlower": parseFloat($("#T_Tlower").val()),
- "T_Tupper": parseFloat($("#T_Tupper").val()),
- "T_RHlower": parseFloat($("#T_RHlower").val()),
- "T_RHupper": parseFloat($("#T_RHupper").val()),
- "T_Site": $("#T_Site").val(),
- "T_Dattery": parseInt($("#T_Dattery").val()),
- };
- return data;
- }
- $("#but").click(function() {
- insertData = getInsertData();
- $("#text1").val(insertData);
- var SQL = insertData;
- var sql = SQL.split('\n')
- var str = "";
- var j = 0
- for (var i in sql) {
- if (sql[i] != "") {
- var vd_list = sql[i].split('|')
- console.log("vd_list",vd_list)
- // continue;
- $.ajax({
- type: 'POST',
- url: 'https://cold.baozhida.cn/Device/DeviceData_Add', //发送请求
- // url: 'http://47.111.15.17:6200/Device/DeviceData_Add',//测试
- async: false,
- data: {
- Tokey: "1f9db553",
- T_sn: vd_list[0],
- T_name: vd_list[1],
- T_id: vd_list[2],
- T_t: vd_list[3],
- T_rh: vd_list[4],
- T_time: vd_list[5],
- T_Tlower: vd_list[6],
- T_Tupper: vd_list[7],
- T_RHlower: vd_list[8],
- T_RHupper: vd_list[9],
- T_Site: vd_list[10],
- T_Dattery: vd_list[11],
- },
- success: function(result) {
- if (result.Code == 200) {
- str = str + "OK" + '\n';
- } else {
- str = str + "Err" + '\n';
- }
- }
- });
- }
- str = str;
- }
- $("#text2").val(str);
- })
- $("#Trend").click(function() {
- //获取数据
- sortTempAndDate = get_sortTempAndDate();
- })
- //用来保存不会改变的数据
- var sortTempAndDate = {};
- $("#puti").click(function() {
- // //获取数据
- sortTempAndDate1 = get_sortTempAndDate();
- sortTempAndDate = sortTempAndDate1;
- // console.log(sortTempAndDate);
- echart01(sortTempAndDate1);
- echart02(sortTempAndDate1);
- function echart01(sortTempAndDate) {
- var dom1 = document.getElementById('container1');
- var myChart1 = echarts.init(dom1, 'dark', {
- renderer: 'canvas',
- useDirtyRect: false
- });
- var app1 = {};
- var option1;
- option1 = {
- title: {
- text: '湿度时间趋势图',
- // textVerticalAlign:'center'
- // textAlign:'center'
- textStyle: {
- fontSize: 20,
- },
- left: 'center'
- },
- xAxis: {
- type: 'category',
- data: sortTempAndDate['date'],
- },
- yAxis: {
- type: 'value',
- },
- tooltip: {
- trigger: 'axis', //坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用
- axisPointer: { // 坐标轴指示器,坐标轴触发有效
- type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
- }
- },
- series: [{
- data: sortTempAndDate['sortHumi'],
- type: 'line',
- smooth: true
- }]
- };
- if (option1 && typeof option1 === 'object') {
- myChart1.setOption(option1);
- }
- window.addEventListener('resize', myChart1.resize);
- }
- function echart02(sortTempAndDate) {
- var dom = document.getElementById('container');
- var myChart = echarts.init(dom, 'dark', {
- renderer: 'canvas',
- useDirtyRect: false
- });
- var app = {};
- var option;
- option = {
- title: {
- text: '温度时间趋势图',
- // textVerticalAlign:'center'
- // textAlign:'center'
- textStyle: {
- fontSize: 20,
- },
- left: 'center'
- },
- xAxis: {
- type: 'category',
- data: sortTempAndDate['date'],
- },
- yAxis: {
- type: 'value',
- },
- tooltip: {
- trigger: 'axis', //坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用
- axisPointer: { // 坐标轴指示器,坐标轴触发有效
- type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
- }
- },
- series: [{
- data: sortTempAndDate['sorTtemp'],
- type: 'line',
- smooth: true
- }]
- };
- if (option && typeof option === 'object') {
- myChart.setOption(option);
- }
- window.addEventListener('resize', myChart.resize);
- }
- })
- //获取插入数据
- function getInsertData() {
- var str = "";
- data = getData();
- var sql_top = "sn|name|id|t|h|time|T_Tlower|T_Tupper|T_RHlower|T_RHupper|T_Site|T_Dattery";
- // console.log(sql_top);
- // sortTempAndDate = get_sortTempAndDate();
- for (var i = 0; i < sortTempAndDate['date'].length; i++) {
- // 替换
- // console.log(data)
- str_ = sql_top;
- str_ = str_.replace("sn", data.sn);
- str_ = str_.replace("name", data.name);
- str_ = str_.replace("id", data.ID);
- str_ = str_.replace("t", sortTempAndDate['sorTtemp'][i]);
- str_ = str_.replace("h", sortTempAndDate['sortHumi'][i]);
- str_ = str_.replace("time", sortTempAndDate['date'][i]);
- str_ = str_.replace("T_Tlower",data.T_Tlower);
- str_ = str_.replace("T_Tupper",data.T_Tupper);
- str_ = str_.replace("T_RHlower",data.T_RHlower);
- str_ = str_.replace("T_RHupper",data.T_RHupper);
- str_ = str_.replace("T_Site",data.T_Site);
- str_ = str_.replace("T_Dattery",data.T_Dattery);
- str = str + str_ + "\n"
- }
- return str;
- }
- //温排序温度、湿度以及时间
- function get_sortTempAndDate() {
- var qushi = $("#qushi").find('option:selected').text();
- //排序温度
- var sorTtemp = [];
- //湿度
- var sortHumi = [];
- //时间
- var date = [];
- data = getData();
- var jiange = data.date_num;
- var date_start = convertDateFromString(data.start_date);
- var date_end = convertDateFromString(data.end_date);
- var sortTempAndDate = {};
- while (date_start < date_end) {
- // date_start.setTime(date_start.setSeconds(date_start.getSeconds() + jiange)); //秒
- date_start.setTime(date_start.setMinutes(date_start.getMinutes() + jiange));
- var Dates = date_start.Format("yyyy-MM-dd HH:mm:ss");
- if (date_start >= date_end) {
- date_start = date_end;
- var Dates = date_start.Format("yyyy-MM-dd HH:mm:ss");
- date.push(Dates);
- sorTtemp.push(get_rund(data.temp_max, data.temp_mix));
- sortHumi.push(get_rund(data.humi_max, data.humi_mix));
- break;
- }
- date.push(Dates);
- sorTtemp.push(get_rund(data.temp_max, data.temp_mix));
- sortHumi.push(get_rund(data.humi_max, data.humi_mix));
- }
- if (qushi == '上升') {
- $("#t_max").show();
- $("#t_min").show();
- $("#humi_m").show();
- $("#humi_x").show();
- $("#mol").hide();
- $("#wel").hide();
- $("#gee").hide();
- $("#shi_ge").hide();
- sorTtemp.sort(function(a, b) {
- return a - b
- });
- sortHumi.sort(function(c, d) {
- return c - d
- });
- } else if (qushi == '下降') {
- $("#t_max").show();
- $("#t_min").show();
- $("#humi_m").show();
- $("#humi_x").show();
- $("#mol").hide();
- $("#wel").hide();
- $("#gee").hide();
- $("#shi_ge").hide();
- sorTtemp.sort(function(a, b) {
- return b - a
- });
- sortHumi.sort(function(c, d) {
- return d - c
- });
- } else if (qushi == '原始') {
- $("#t_max").show();
- $("#t_min").show();
- $("#ge").show();
- $("#humi_m").show();
- $("#humi_x").show();
- $("#mol").hide();
- $("#wel").hide();
- $("#gee").hide();
- $("#shi_ge").hide();
- // console.log("sorTtemp:",sorTtemp)
- } else if (qushi == '平缓') {
- //获取温度、湿度数据
- var ge = document.getElementById('ge').value;
- var g = document.getElementById('shi_g').value;
- $("#gee").show();
- $("#shi_ge").show();
- $("#t_max").show();
- $("#t_min").show();
- $("#humi_m").show();
- $("#humi_x").show();
- $("#mol").hide();
- $("#wel").hide();
- // console.log("sorTtemp:",sorTtemp)
- //温度
- for (var l = 1; l < sorTtemp.length; l++) {
- C = get_rund(0, 1)
- if (C >= 0.5) {
- sorTtemp[l] = parseFloat(sorTtemp[l - 1]) - parseFloat(ge);
- } else {
- sorTtemp[l] = parseFloat(sorTtemp[l - 1]) + parseFloat(ge);
- }
- // 限制
- if (data.temp_max < sorTtemp[l]) {
- sorTtemp[l] = data.temp_max
- }
- if (data.temp_mix > sorTtemp[l]) {
- sorTtemp[l] = data.temp_mix
- }
- }
- //湿度
- for (var h = 1; h < sortHumi.length; h++) {
- k = get_rund(0, 1)
- if (k >= 0.5) {
- sortHumi[h] = (parseFloat(sortHumi[h - 1]) - parseFloat(g)).toFixed(1);
- } else {
- sortHumi[h] = (parseFloat(sortHumi[h - 1]) + parseFloat(g)).toFixed(1);
- }
- // 限制
- if (data.humi_max < sortHumi[h]) {
- sortHumi[h] = data.humi_max
- }
- if (data.humi_min > sortHumi[h]) {
- sortHumi[h] = data.humi_min
- }
- }
- // console.log("sorTtemp:",sorTtemp)
- } else if (qushi == '模板') {
- $("#mol").show();
- $("#wel").show();
- $("#gee").hide();
- $("#shi_ge").hide();
- $("#humi_m").hide();
- $("#humi_x").hide();
- $("#t_max").hide();
- $("#t_min").hide();
- tempData = $("#tempData").val();
- humi_Date = $("#humi_Data").val();
- tempDataArr = tempData.split(',');
- humi_Date_Arr = humi_Date.split(',');
- var tempDataList = [];
- var humi_Data_List = [];
- var h = 0;
- for (k = 0; k < date.length; k++) {
- humi_Data_List.push(parseFloat(humi_Date_Arr[h++]).toFixed(1));
- if (h == humi_Date_Arr.length) {
- h = 0;
- }
- }
- sortHumi = humi_Data_List;
- var j = 0;
- for (i = 0; i < date.length; i++) {
- tempDataList.push(parseFloat(tempDataArr[j++]).toFixed(1));
- if (j == tempDataArr.length) {
- j = 0;
- }
- }
- sorTtemp = tempDataList;
- }
- // sortHumiDate["date"] = date;
- sortTempAndDate["sortHumi"] = sortHumi;
- sortTempAndDate["date"] = date;
- sortTempAndDate["sorTtemp"] = sorTtemp;
- return sortTempAndDate;
- }
- //获取随机数
- function get_rund(max, min) {
- return parseFloat((Math.random() * (max - min)) + min).toFixed(1);
- }
- //字符串转换成日期
- function convertDateFromString(dateString) {
- if (dateString) {
- var arr1 = dateString.replace('|');
- var date = new Date(arr1);
- return date;
- }
- }
- //jquery将日期转换成指定格式的字符串
- Date.prototype.Format = function(fmt) {
- var o = {
- "M+": this.getMonth() + 1, //月份
- "d+": this.getDate(), //日
- "H+": this.getHours(), //小时
- "m+": this.getMinutes(), //分
- "s+": this.getSeconds(), //秒
- "q+": Math.floor((this.getMonth() + 3) / 3), //季度
- "S": this.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" +
- o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
- $("#CS").click(function(){
- var txt= "请输入";
- window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.input,{
- onOk:function(v){
- // console.log(v);
- v_list = v.split(" ")
- // console.log(v_list[0]);
- $("#ID").val(v_list[0]);
- $("#name").val(v_list[1]);
- $("#temp_mix").val(v_list[2]);
- $("#humi_mix").val(v_list[3]);
- $("#temp_max").val(v_list[4]);
- $("#humi_max").val(v_list[5]);
- }
- });
- });
- </script>
- </body>
- </html>
|