InStockFuelReport.cshtml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. @*
  2. For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
  3. *@
  4. @{
  5. ViewData["Title"] = "Auto Tank Gauge System";
  6. Layout = null;
  7. }
  8. <script src="~/js/mqtt.min.js"></script>
  9. <script src="~/js/Chart.bundle.js"></script>
  10. <script src="~/js/jquery-3.4.1.min.js"></script>
  11. <body id="Page_Body" style="height:700px;width:1280px;background-image:url(/images/device/background/background.png);background-repeat:no-repeat">
  12. <div style="display:flex;height:5%;width:50%">
  13. <div style="position:absolute;float:right;left:1081px;height:10%;width:0%;z-index:0;top:0px">
  14. <img id="testimage" src="~/images/device/title/505455.png" style="z-index:2;position:absolute;float:left">
  15. <p style="z-index:4; left:30px;height:7%;position:absolute;float:left;top:-11px"><font size="5" color="white"> 03/31/2020 </font></p>
  16. <canvas></canvas>
  17. </div>
  18. <div style="position:absolute;float:left;height:10%;width:1280px;z-index:0;left:0px;top:0px">
  19. <img id="testimage" src="~/images/device/title/ff1d1c.png" style="z-index:1;position:absolute;float:left;left:0px">
  20. <img id="testimage" src="~/images/device/title/0182d6.png" style="z-index:1;position:absolute;float:left;left:0px">
  21. <img id="testimage" src="~/images/device/title/f8cd1c.png" style="z-index:1;position:absolute;float:left;left:0px">
  22. <p style="z-index: 1; left: 30px; height: 7%; position: absolute; float: left"><font size="6" color="white"> X号油罐 : 高油位警报, </font></p>
  23. <p style="z-index:1; left:550px;height:7%;position:absolute;float:left"><font size="6" color="white"> 活跃预警: </font></p>
  24. <p style="z-index:1; left:850px;height:7%;position:absolute;float:left"><font size="6" color="white"> 活跃报警: </font></p>
  25. <canvas></canvas>
  26. </div>
  27. </div>
  28. <div id="Page_MainBody_Table_FuelDetailList" style="position:absolute;top:100px;height:600px">
  29. <div id="Table_FuelDetailList" style="position:absolute;float:left;height:600px;width:950px" onclick="PageMainBodyClickEvent()">
  30. <table border="0" cellpadding="0" cellspacing="0" width="1280px" style="position:absolute;left:50px;line-height:45px">
  31. <thead style="font-size:24;text-align:left">
  32. <tr>
  33. <th style="width:315px"> 开始/结束时间 </th>
  34. <th style="width:200px"> 加油量(升) </th>
  35. <th style="width:315px"> 温度补偿油量(升) </th>
  36. <th style="width:200px"> 油位(mm) </th>
  37. <th style="width:200px"> 水位(mm) </th>
  38. </tr>
  39. </thead>
  40. <tbody style="font-size:20;text-align:left">
  41. @for (int i = 0; i <= 1; i++)
  42. {
  43. <tr>
  44. <th style="width:300px"> 1号油罐 #92 </th>
  45. </tr>
  46. <tr>
  47. <th style="width:315px"> 开始 20202-04-10 </th>
  48. <th style="width:200px"> </th>
  49. <th style="width:315px"> </th>
  50. <th style="width:200px"> </th>
  51. <th style="width:200px"> </th>
  52. </tr>
  53. <tr>
  54. <th style="width:315px"> 结束 20202-04-10 </th>
  55. <th style="width:200px"> </th>
  56. <th style="width:315px"> </th>
  57. <th style="width:200px"> </th>
  58. <th style="width:200px"> </th>
  59. </tr>
  60. <tr>
  61. <th style="width:315px"> 统计: </th>
  62. <th style="width:200px"> </th>
  63. <th style="width:315px"> </th>
  64. <th> </th>
  65. </tr>
  66. }
  67. </tbody>
  68. </table>
  69. </div>
  70. <div style="display:flex;margin-left:1120px">
  71. <div id="FilterList_HiddenPicture" style="margin-left:70px;margin-top:-40px;visibility:visible">
  72. <a><img src="~/images/device/fairbanks/筛选图标.png" style="" onclick="FilterListPictureClickEvent()"></a>
  73. </div>
  74. <div id="FilterList_ShowTable" style="position:absolute;background-image:url('/images/device/fairbanks/筛选背景.jpg');background-size:contain;height:400px;width:150px;margin-top:-40px;margin-left:-20px;visibility:hidden">
  75. <table style="width:180px;text-align:left">
  76. <caption style="font-size:28;font-weight:bolder;widows:initial;text-align:left"> 筛选查询 </caption>
  77. <tr style="height: 10px">
  78. <th> </th>
  79. </tr>
  80. <tbody>
  81. <tr>
  82. <th style="font-size:24"> 起始时间: </th>
  83. </tr>
  84. <tr>
  85. <th style="font-size:20"> temp </th>
  86. </tr>
  87. <tr>
  88. <th style="font-size:24"> 结束日期: </th>
  89. </tr>
  90. <tr>
  91. <th style="font-size:20"> temp </th>
  92. </tr>
  93. <tr>
  94. <th style="font-size:24"> 油罐选择: </th>
  95. </tr>
  96. <tr>
  97. <th style="font-size:20"> temp </th>
  98. </tr>
  99. <tr style="height:10px">
  100. <th> </th>
  101. </tr>
  102. <tr>
  103. <th> 查询条件: </th>
  104. </tr>
  105. </tbody>
  106. </table>
  107. <div style="position:absolute;margin-top:20px;margin-left:15px">
  108. <div id="FilterList_NewInStockFuel" style="display:flex">
  109. <a href="NewFuelInventory">
  110. <img id="img_NewInStockFuel" src="~/images/device/fairbanks/选框.png" style="z-index:1;position:absolute;float:left;visibility:hidden">
  111. <p style="z-index:1;float:left;position:absolute;width:110px;margin-top:3px;left:25px"><font id="font_NewInStockFuel" size="5" color="white" style="font-weight:bold"> 最新进油 </font></p>
  112. </a>
  113. </div>
  114. <div id="FilterList_InStockFuelReport" style="display:flex;margin-top:50px">
  115. <a href="InStockFuelReport">
  116. <img id="img_InStockFuelReport" src="~/images/device/fairbanks/选框.png" style="z-index:1;position:absolute;float:left;visibility:hidden">
  117. <p style="z-index:1;float:left;position:absolute;width:110px;margin-top:3px;left:25px"><font id="font_InStockFuelReport" size="5" color="white" style="font-weight:bold"> 进油报表 </font></p>
  118. </a>
  119. </div>
  120. <div id="FilterList_NewFuelInventory" style="display:flex;margin-top:50px">
  121. <a href="NewInStockFuel">
  122. <img id="img_NewFuelInventory" src="~/images/device/fairbanks/选框.png" style="z-index:1;position:absolute;float:left;visibility:hidden">
  123. <p style="z-index:1;float:left;position:absolute;width:110px;margin-top:3px;left:25px"><font id="font_NewFuelInventory" size="5" color="white" style="font-weight:bold"> 最新库存 </font></p>
  124. </a>
  125. </div>
  126. <div id="FilterList_FuelInventoryList" style="display:flex;margin-top:50px">
  127. <a href="FuelInventoryList">
  128. <img id="img_FuelInventoryList" src="~/images/device/fairbanks/选框.png" style="z-index:1;position:absolute;float:left;visibility:hidden">
  129. <p style="z-index:1;float:left;position:absolute;width:110px;margin-top:3px;left:25px"><font id="font_FuelInventoryList" size="5" color="white" style="font-weight:bold"> 库存报表 </font></p>
  130. </a>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <div style="position:absolute;top:500px">
  137. <div style="height:40px">
  138. <p style="z-index:1; height:10%;position:absolute;float:left"></p>
  139. </div>
  140. <div style="display:flex;height:5%;width:50%">
  141. <div style="position:absolute;float:left;height:10%;width:1280px;z-index:0;left:50px">
  142. <a href="TankDevicesOverview">
  143. <img id="testimage" src="~/images/device/pages/3fa0df.png" style="z-index:1;position:absolute;float:left;visibility:hidden">
  144. @*<asp:ImageButton ImageUrl="~/image/device/pages/3fa0df.png" href="/_Layout_TankDetail.cshtml" ></asp:ImageButton>*@
  145. <p style="z-index:1; left:25px;height:7%;position:absolute;float:left;top:-11px"><font size="5" color="black" style="font-weight:bold"> 油罐总览 </font></p>
  146. <canvas></canvas>
  147. </a>
  148. </div>
  149. <div style="position:absolute;float:right;left:200px;height:10%;width:1000px;z-index:0">
  150. <a href="TankDeviceDetails">
  151. <img id="testimage" src="~/images/device/pages/3fa0df.png" style="z-index:2;position:absolute;float:left;visibility:hidden" onclick="">
  152. <p style="z-index:4; left:25px;height:7%;position:absolute;float:left;top:-11px"><font size="5" color="black" style="font-weight:bold"> 油罐详情 </font></p>
  153. <canvas></canvas>
  154. </a>
  155. </div>
  156. <div style="position:absolute;float:right;left:350px;height:10%;width:1000px;z-index:0">
  157. <a href="AlarmHistory">
  158. <img id="testimage" src="~/images/device/pages/3fa0df.png" style="z-index:2;position:absolute;float:left;visibility:hidden" onclick="">
  159. <p style="z-index:4; left:25px;height:7%;position:absolute;float:left;top:-11px"><font size="5" color="black" style="font-weight:bold"> 报警查询 </font></p>
  160. <canvas></canvas>
  161. </a>
  162. </div>
  163. <div style="position:absolute;float:right;left:500px;height:10%;width:1000px;z-index:0">
  164. <a href="FuelInventoryList">
  165. <img id="testimage" src="~/images/device/pages/3fa0df.png" style="z-index:2;position:absolute;float:left" onclick="">
  166. <p style="z-index:4; left:25px;height:7%;position:absolute;float:left;top:-11px"><font size="5" color="white" style="font-weight:bold"> 进油库存 </font></p>
  167. <canvas></canvas>
  168. </a>
  169. </div>
  170. @*<div>
  171. <div style="position:absolute;float:right;left:860px;height:10%;width:50px;z-index:0;margin-top:10px">
  172. <img src="~/images/device/pages/1a8eda.png" style="position:absolute;left:0px">
  173. <img src="~/images/device/pages/b1d5eb.png" style="position:absolute;left:0px">
  174. </div>
  175. <div style="position:absolute;float:right;left:940px;height:10%;width:50px;z-index:0;margin-top:10px">
  176. <img src="~/images/device/pages/1a8eda.png" style="position:absolute;left:0px">
  177. <img src="~/images/device/pages/b1d5eb.png" style="position:absolute;left:0px">
  178. </div>
  179. <div style="position:absolute;float:right;left:1020px;height:10%;width:50px;z-index:0;margin-top:10px">
  180. <img src="~/images/device/pages/1a8eda.png" style="position:absolute;left:0px">
  181. <img src="~/images/device/pages/b1d5eb.png" style="position:absolute;left:0px">
  182. </div>
  183. <div style="position:absolute;float:right;left:1100px;height:10%;width:50px;z-index:0;margin-top:10px">
  184. <img src="~/images/device/pages/1a8eda.png" style="position:absolute;left:0px">
  185. <img src="~/images/device/pages/b1d5eb.png" style="position:absolute;left:0px">
  186. </div>
  187. <div style="position:absolute;float:right;left:1180px;height:10%;width:50px;z-index:0;margin-top:10px">
  188. <img src="~/images/device/pages/1a8eda.png" style="position:absolute;left:0px">
  189. <img src="~/images/device/pages/b1d5eb.png" style="position:absolute;left:0px">
  190. </div>
  191. </div>*@
  192. </div>
  193. </div>
  194. </body>
  195. <script>
  196. var FilterList_Pciture = document.getElementById("FilterList_HiddenPicture");
  197. var FilterList_Table = document.getElementById("FilterList_ShowTable");
  198. function FilterList_ShowHide(DivID) {
  199. if (DivID == "PageMainBody" || DivID == "PageBody") {
  200. if (FilterList_Table.style.visibility == "visible") {
  201. FilterList_Pciture.style.visibility = (FilterList_Pciture.style.visibility = "hidden") ? "visible" : "hidden";
  202. FilterList_Table.style.visibility = (FilterList_Table.style.visibility = "visible") ? "hidden" : "visible";
  203. TagDeal_hidden();
  204. }
  205. }
  206. else if (DivID == "FilterListPicture") {
  207. FilterList_Pciture.style.visibility = (FilterList_Pciture.style.visibility = "visible") ? "hidden" : "visible";;
  208. FilterList_Table.style.visibility = (FilterList_Table.style.visibility = "hidden") ? "visible" : "hidden";
  209. TagDeal();
  210. }
  211. }
  212. function PageMainBodyClickEvent() {
  213. FilterList_ShowHide("PageMainBody");
  214. }
  215. function FilterListPictureClickEvent() {
  216. FilterList_ShowHide("FilterListPicture");
  217. }
  218. function TagDeal() {
  219. document.getElementById("font_NewInStockFuel").style.color = "black";
  220. document.getElementById("font_InStockFuelReport").style.color = "white";
  221. document.getElementById("font_NewFuelInventory").style.color = "black";
  222. document.getElementById("font_FuelInventoryList").style.color = "black";
  223. document.getElementById("img_NewInStockFuel").style.visibility = "hidden";
  224. document.getElementById("img_InStockFuelReport").style.visibility = "visible";
  225. document.getElementById("img_NewFuelInventory").style.visibility = "hidden";
  226. document.getElementById("img_FuelInventoryList").style.visibility = "hidden";
  227. }
  228. function TagDeal_hidden() {
  229. document.getElementById("img_InStockFuelReport").style.visibility = "hidden";
  230. }
  231. //$(document).ready(function () {
  232. var hostname = 'localhost', //'192.168.1.2',
  233. port = 8384,
  234. clientId = 'mqttjs_' + (Math.random() * 1000000).toString(),
  235. timeout = 5000,
  236. keepAlive = 100,
  237. cleanSession = false,
  238. mqttVersion = 3,
  239. ssl = false;
  240. var options = {
  241. //mqtt客户端的id,这里面应该还可以加上其他参数,具体看官方文档
  242. clientId: 'mqttjs_' + (Math.random() * 1000000).toString(),
  243. timeout: timeout,
  244. useSSL: false
  245. }
  246. //浏览器采用websocket协议,host主机地址为192.168.0.200,端口为9001,路径为/mqtt
  247. var client = mqtt.connect("ws://localhost:8384/mqtt", options); // you add a ws:// url here
  248. ////建立连接
  249. client.on('connect',
  250. function () {
  251. var a = document.getElementById("testmqqt");
  252. if (a != null) a.innerHTML = "connected";
  253. //订阅主题 presence
  254. client.subscribe('/sys/VeederRoot_ATG_Console_Tcp/VeederRoot_ATG_Console.Handler/thing/service/GetTankDeliveryAsync_reply',
  255. function (err) {
  256. if (!err) {
  257. //client.publish('/sys/VeederRoot_ATG_Console_Tcp/VeederRoot_ATG_Console.Handler/thing/service/GetTankReadingsAsync');
  258. } else {
  259. //打印错误
  260. if (a != null) a.innerHTML = err;
  261. }
  262. });
  263. });
  264. client.publish('/sys/VeederRoot_ATG_Console_Tcp/VeederRoot_ATG_Console.Handler/thing/service/GetTankDeliveryAsync', 'Mqtt Hello');
  265. //如果连接错误,打印错误
  266. client.on('error',
  267. function (err) {
  268. var a = document.getElementById("testmqqt");
  269. if (a != null) a.innerHTML = err;
  270. client.end();
  271. });
  272. //如果client订阅主题成功,那么这里就是当接收到自己订阅主题的处理逻辑
  273. client.on('message',
  274. function (topic, message) {
  275. var a = document.getElementById("testmqqt");
  276. //if (a != null) a.innerHTML = message.toString();
  277. if (topic == "/sys/VeederRoot_ATG_Console_Tcp/VeederRoot_ATG_Console.Handler/thing/service/GetTankDeliveryAsync_reply") {
  278. TableRowADD(JSON.parse(message.toString()));
  279. }
  280. });
  281. //// 用户程序点击事件
  282. //function Onmqtttest() {
  283. // message = "message from browser with websocket"; // 消息内容
  284. // //发布主题presence,消息内容为Hello mqtt,订阅与推送一样自发自收
  285. // client.publish('/sys/VeederRoot_ATG_Console_Tcp/VeederRoot_ATG_Console.Handler/thing/service/GetTankDeliveryAsync', 'Hello mqtt ' + message);
  286. // var a = document.getElementById("testmqqt");
  287. // if (a != null) a.innerHTML = message;
  288. //}
  289. function TableRowADD(datas) {
  290. if (datas == null) {
  291. console.log("response data is null for chart table");
  292. return;
  293. }
  294. var chartTable = document.getElementById("Chart_table");
  295. if (chartTable == null) {
  296. console.log("chart table is not created");
  297. return;
  298. }
  299. var originalTableRows = chartTable.rows.length;
  300. var r = chartTable.insertRow(chartTable.rows.length);
  301. //var c1 = r.insertCell(r.cells.length);
  302. //c1.innerHTML = d.DataCollectorNozzleNumber;
  303. var c1 = r.insertCell(r.cells.length);
  304. c1.innerHTML = new Date().getFullYear() + "-" + (new Date().getMonth() + 1, 2) + "-" + (new Date().getDate(), 2);
  305. var c2 = r.insertCell(r.cells.length);
  306. c2.innerHTML = datas.Volume;
  307. var c3 = r.insertCell(r.cells.length);
  308. c3.innerHTML = datas.TcVolume;
  309. var c4 = r.insertCell(r.cells.length);
  310. c4.innerHTML = datas.Volume//(new Date(d.FuellingEndTime) - new Date(d.FuellingStartTime)) / 1000;
  311. var c5 = r.insertCell(r.cells.length);
  312. c5.innerHTML = datas.WaterVolume;
  313. var c6 = r.insertCell(r.cells.length);
  314. c6.innerHTML = datas.Temperature;
  315. //datas.forEach(function (d) {
  316. // var r = chartTable.insertRow(chartTable.rows.length);
  317. // //var c1 = r.insertCell(r.cells.length);
  318. // //c1.innerHTML = d.DataCollectorNozzleNumber;
  319. // var c1 = r.insertCell(r.cells.length);
  320. // c1.innerHTML = new Date(d.FuellingStartTime).getFullYear() + "-" + Pad(new Date(d.FuellingStartTime).getMonth() + 1, 2) + "-" + Pad(new Date(d.FuellingStartTime).getDate(), 2);
  321. // var c2 = r.insertCell(r.cells.length);
  322. // c2.innerHTML = d.Volume;
  323. // var c3 = r.insertCell(r.cells.length);
  324. // c3.innerHTML = d.TcVolume;
  325. // var c4 = r.insertCell(r.cells.length);
  326. // c4.innerHTML = d.Volume//(new Date(d.FuellingEndTime) - new Date(d.FuellingStartTime)) / 1000;
  327. // var c5 = r.insertCell(r.cells.length);
  328. // c5.innerHTML = d.WaterVolume;
  329. // var c6 = r.insertCell(r.cells.length);
  330. // c6.innerHTML = d.Temperature;
  331. //});
  332. //insert an empty row, otherwise the style of the table will be changed
  333. if (datas.length === 0) {
  334. var r = chartTable.insertRow(chartTable.rows.length);
  335. var c1 = r.insertCell(r.cells.length);
  336. c1.innerHTML = "";
  337. var c2 = r.insertCell(r.cells.length);
  338. c2.innerHTML = "";
  339. var c3 = r.insertCell(r.cells.length);
  340. c3.innerHTML = "";
  341. var c4 = r.insertCell(r.cells.length);
  342. c4.innerHTML = "";
  343. var c5 = r.insertCell(r.cells.length);
  344. c5.innerHTML = "";
  345. var c6 = r.insertCell(r.cells.length);
  346. c6.innerHTML = "";
  347. }
  348. }
  349. //})
  350. function Pad(num, n) {
  351. var len = num.toString().length;
  352. while (len < n) {
  353. num = "0" + num;
  354. len++;
  355. }
  356. return num;
  357. }
  358. function FormatFloat(value, n) {
  359. if (value === null) {
  360. return "00.00";
  361. }
  362. var str = value.toString();
  363. var str_head = Math.round(value).toString();
  364. var str_end = str.substring(str.indexOf('.'), str.indexOf('.') + n + 1);
  365. return str_head + str_end;
  366. }
  367. </script>