新粤机电养护系统增强油猴脚本v0.5
// ==UserScript==
// @name 新粤机电养护系统增强油猴脚本v0.5
// @namespace http://tampermonkey.net/
// @version 2024-02-01
// @description 用于增强优化监管维修及时率等关键指标!
// @author 东御何启峰
// @match https://yz.gdxinyue.net/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=gdxinyue.net
// @grant none
// ==/UserScript==
(function() {
'use strict';
$(document).ready(function(){
var mainPageIframe = document.getElementById("mainPage");
if(mainPageIframe==null){
console.log(mainPageIframe);
var timerId = setTimeout(function () {
load100Fault();
//console.log('2我执行了')//5秒后执行我执行了 只执行一次
}, 2000)
//var timerId2 = setInterval(function() {
//加载并显示待处理故障单
//loadGetCurrentUnfixedFault2();
// console.log('6我执行了')//间隔6秒执行一次 我执行了
//}, 6000)
}
});
function load100Fault(){
var faultlist ;
//获取近100条故障单
$.post("/Usual/Fault/Fault_List.aspx?GetData=1&_search=false&rows=100&page=1&sidx=FAULTID&sord=desc&txtStatus=&txtKey=&txtHOPCOMPANYID=&txtSYSTEM_ID=&txtTimeout=&txtFAULTLEVEL=&txtFAULTKIND=&txtINFOTYPE=&txtGEOGRAPHYINFO_NAME=&txtGEOGRAPHYINFO_ID=&txtFROMCLIENT=&txtREPLACE=&txtYear=&txtMonth=0&txtBeginDate=&txtEndDate=&IsBack=&NewStatus=", { }, function (r) {
faultlist = r.rows;
//console.log(arrJson);
loadGetCurrentUnfixedFault2(faultlist)
}, "json");
// return faultlist;
}
function loadGetCurrentUnfixedFault2(faultlist) {
//$("#tableInspect").parent().children("div").css("display", "");
$.post("D.aspx", { action: "GetCurrentUnfixedFault", txtRoad: $("#txtRoad4").val() }, function (r) {
var table_html = "<table width='100%' border='1' cellspacing='0' cellpadding='0' class='tab_sys2 min_font' id='tableUnfixedFault2'> <thead><tr><th style='width:110px;'>位置信息</th> <th style='width:45px;'>数量</th> <th style='width:130px;'>故障时间</th><th style='width:110px;'>修复时限</th> <th style='width:110px;'>当前状态</th> <th>故障描述</th> </tr> </thead> <tbody></tbody> </table>";
let xDiv = document.querySelector("#xDiv");
xDiv.innerHTML=xDiv.innerHTML+table_html;
//main_layout.after(table_dom);
$("#tableUnfixedFault2 tr:not(:first)").remove();
var arrJson = r.Data;
//var fTotal = [0, 0, 0, 0];
var ccTotal = 0;
for (var i = 0; i < arrJson.length; i++) {
//var arrTime = arrJson[i]["HAPPENTIME"];
var arrTimeR = [];
var leftTime =[];
var statusArray =[];
if (arrJson[i]["HAPPENTIME"] != "") {
var arrTime = arrJson[i]["HAPPENTIME"].split(',');
var arrGuid = arrJson[i]["GUID"].split(',');
for (var j = 0; j < arrTime.length; j++) {
arrTimeR.push("<a style='height:auto;font-weight: normal' href='javascript:;' onclick=\"windowOpen('/Usual/Fault/Fault_View.aspx?GUID=" + arrGuid[j] + "',1200,screen.availHeight-100);return false;\">" + arrTime[j] + "</a>");
var result = faultlist.find(function(fault) {
return fault.GUID1 === arrGuid[j];
});
if(result){
statusArray.push((j+1)+"、"+result["状态"]);
var start = Date.parse(new Date(result["HAPPENTIME"]));
var end = Date.parse(new Date());
var diff = Math.abs(end - start); // 获取两个日期的时间戳差值并取绝对值DOTIMEOUT
var lefthour= 72-Math.ceil(diff / (60 * 60 * 1000)); // 将差值转换为小时数(向上取整)
if(lefthour>0){
if(lefthour>8){
leftTime.push("<span style='color:green'>"+(j+1)+"、"+"剩余"+lefthour+"小时</span>");
}else{
leftTime.push("<span style='color:blue'>"+(j+1)+"、"+lefthour+"小时后超时</span>");
}
}else{
if(result["DOTIMEOUT"]==="0"){
leftTime.push("<span style='color:green'>"+(j+1)+"、"+"备件待料</span>");
}else{
leftTime.push("<span style='color:red'>"+(j+1)+"、"+"超时"+lefthour*-1+"小时</span>");
}
}
console.log(result);
}
}
//console.log(leftTime);
}
var html = $('<tr><td>' + arrJson[i]["LOCATION"] + '</td><td>' + arrJson[i]["NUM"]+ '</td><td>' + arrTimeR.join('<br/>') + '</td><td>' +leftTime.join('<br/>') + '</td><td>' +statusArray.join('<br/>') + '</td><td class="tab_lf">' + arrJson[i]["DES"].htmlEncode() + '</td></tr>');
arrTimeR = null;
if (arrJson[i]["GEOGRAPHYINFO_ID"] == null)
html = '<tr class="tab_title"><td colspan="6">' + arrJson[i]["LOCATION"] + ' </td></tr>';
else
ccTotal += parseInt(arrJson[i]["NUM"]);
$("#tableUnfixedFault2").append(html);
}
if (arrJson.length == 0) {
$("#tableUnfixedFault2").append('<tr class=""><td colspan="6">无</td></tr>');
}
else
$('#tableUnfixedFault2').mergeCell({ cols: [0] });
//$("#spanGetCurrentUnfixedFault").html("(" + ccTotal + ")");
//console.log(main_layout.innerHTML);
}, "json");
}
//alert(document.getElementById("tableGetCurrentUnfixedFault"));
// Your code here...
})();