123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- var passNumber = [];
- var failNumber = [];
- var failrate = [];
- var stackeverynum = [];
- var failnum = 0;
- var num = 0;
- var n = 0;
- var sectorID = [];
- var namedata = [];
- var lazhang = {};
- var scheduleId = utils_get_param("scheduleId");
- var flowId = utils_get_param("flowId");
- var name1,name2;
- function first_success(obj, sta) {
- let output = first_parse(this, obj);
- let i, j, k, z;
- failnum = 0;
- let x = 0;
- let worksum = [];
- z = 0;
- if (output.list == undefined || output.list.length == 0) {
- send_alert("没有数据");
- }
- output.list.forEach(function(val,it,arr){
- var isExist = false;
- userIDs.forEach(function(vals){
- if(vals == val.userId){
- isExist = true;
- }
- });
- if(!isExist) userIDs.push(val.userId);
- });
- if (output.list.length > 0) {
- sectorID[0] = getSectorId(output.list[0].spotId);
- for (i = 1; i < output.list.length; i++) {
- var thisUid = getSectorId(output.list[i].spotId);
- x = 0;
- for (j = 0; j < sectorID.length; j++) {
- if (sectorID[j] === thisUid) {
- x = 1;
- break;
- }
- }
- if (x === 0) {
- sectorID.push(thisUid);
- }
- }
- j = 0;
- for (k = 0; k < sectorID.length; k++) {
- var uid = sectorID[k];
- z = 0;
- passNumber[k] = 0;
- failNumber[k] = 0;
- stackeverynum[k] = 0;
- for (i = 0; i < output.list.length; i++) {
- if (uid === getSectorId(output.list[i].spotId)) {
- passNumber[k] = output.list[i].passNum + passNumber[j];
- failNumber[k] = output.list[i].failNum + failNumber[j];
- stackeverynum[k] = output.list[i].due + stackeverynum[j];
- z++;
- }
- }
- if (failNumber[k] + passNumber[k] == 0) {
- failrate[k] = 0;
- }
- else {
- failrate[k] = failNumber[k] / (failNumber[k] + passNumber[k]) * 100;
- }
- /*stackeverynum[k]=stackeverynum[k]/z;*/
- ///
- }
- }
- get_data("fcFlow/list?flowId="+ flowId,name_Success);
- for (i = 1; i <= 3; i++) {
- load_flows_history_data(i);
- }
- showChart();
- lazhang.timer = setInterval(request_data_realtime, 1000);
- }
- function name_Success(obj, sta) {
- var factory = first_parse(this, obj);
- var i, j, t;
- console.log(" factory : ");
- console.log(factory);
- name1=factory.list[0].flowPlace;
- name2=factory.list[0].flowName;
- document.getElementById("flow_title").innerHTML = name1+"-"+name2 + " 度彼科技";
- document.title = name1 + " " + name2 + " | 流水线管理 | 度彼科技";
- }
- function request_data_realtime() {
- get_data("fcWorkScheduleLoad/list?scheduleId=" + scheduleId, realtime_success);
- //load_flows_history_realtime_data();
- load_table_red_rank();
- load_table_red_rank1();
- load_table_black_rank();
- load_table_black_rank1();
- }
- function load_flows_history_data(nnm) {
- // 请注意type必须在结尾
- get_data("fcBiFlowDaily/list?scheduleId="+scheduleId+ "&flowId=" + flowId+"&type=" + nnm , history_success);
- }
- function load_flows_history_realtime_data() {
- // 请注意type必须在结尾
- get_data("fcBiFlowDaily/list?flowId=" + flowId +"&type=1", history_success);
- }
- function get_stop_scheudle1() {
- var out = confirm("真的要下班吗?");
- if(out == true){
- get_stop_scheudle();
- }
- else{
- }
- }
- function show_clear_panel(){
- $("#clearModal").modal('show');
- }
- var executed = false;
- var finished = true;
- var directCount = -1;
- function clear_one_data(){
- executed = false;
- directCount = -1;
- finished = true;
- var hand = $("#handInput").val();
- var hd = 0;
- if(hand.length > 0){
- hd = parseInt(hand);
- }
- get_data("endpoint/clearBoard?flowId="+flowId+"&handheldId=" + hd, clearSuccess);
- }
- function clearSuccess(obj, sta){
- console.warn("------- 手持设备清空 ----------");
- console.warn(this);
- send_alert("发送清空请求成功, 正在等待采集端进行处理...");
- finished = false;
- setTimeout(on_timeout_clear, 8000);
- setTimeout(recurseget,300);
- //var output = first_success(this, obj);
- }
- function recurseget(){
- if(finished) return;
- get_data("endpoint/heartbeat?flowId=" + flowId, onheart);
- setTimeout(recurseget,100);
- }
- function onheart(obj,sta){
- var ouy = {};
- if(typeof(obj) === "string"){
- ouy = JSON.parse(obj);
- }else{
- ouy = obj;
- }
- if(typeof(ouy) === "object"){
- if(ouy.ret === "10000"){
- //ok
- if(ouy.model == null || ouy.model === undefined){
- executed = true;
- finished = true;
- }else if(typeof(obj.model) === "object"){
- // 没有拿到,继续
- if(obj.model.list != null && obj.model.list.length > 0){
- var direct = obj.model.list[0];
- if(direct.eventType+"" !== "500"){
- // OK
- executed = true;
- finished = true;
- }else if(direct.arg2+"" !== ""+$("#handInput").val()){
- // OK
- executed = true;
- finished = true;
- }else{
- directCount = direct.counter;
- }
- }
- }
- }
- }
- }
- function on_timeout_clear(){
- finished = true;
- if(executed){
- // 执行成功
- }else{
- if(directCount >= 0){
- get_data("endpoint/ack?counter="+directCount,function(){console.log("撤销操作成功");console.log(this);});
- directCount = -1;
- send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
- }else{
- send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
- }
- }
- }
- function get_stop_scheudle() {
- get_data("fcWorkSchedule/stopSchedule?userId="+userId+"&scheduleId=" + scheduleId, stopSuccess);
- }
- function stopSuccess(obj, sta) {
- send_alert("下班操作成功! <a href='denglu.html'> 点击这里返回控制主页 </a>");
- }
- function add_success(obj, sta) {
- var history1 = first_parse(this, obj);
- var i, j;
- console.log(" history1 : ");
- console.log(history1);
- hispass[t] = 0;
- hisfail[t] = 0;
- hisstack[t] = 0;
- hisrate[t] = 0;
- var lengthnum = history1.length - 1;
- for (i = lengthnum; i < history1.length; i++) {
- hispass[t] = history1[i].passNum + hispass[t];
- hisfail[t] = history1[i].failNum + hisfail[t];
- hisstack[t] = history1[i].avgDue + hisstack[t];
- }
- if (hispass[t] + hisfail[t] == 0) {
- hisrate[t] = 0;
- }
- t++;
- }
- function realtime_success(obj, sta) {
- var output = first_parse(this, obj);
- //在这里排序 spo\
- console.log(" output : ");
- console.log(output);
- var i, j, k, z;
- failnum = 0;
- var x = 0;
- var worksum = [];
- var hhp = 0, hhf = 0, hhs = 0;
- if (output.list.length > 0) {
- sectorID[0] = getSectorId(output.list[0].spotId);
- passNumber[0] = 0;
- failNumber[0] = 0;
- stackeverynum[0] = 0;
- z = 0;
- for (i = 1; i < output.list.length; i++) {
- var thisUid = getSectorId(output.list[i].spotId);
- x = 0;
- for (j = 0; j < sectorID.length; j++) {
- if (sectorID[j] === thisUid) {
- x = 1;
- break;
- }
- }
- if (x === 0) {
- sectorID.push(thisUid);
- }
- }
- j = 0;
- for (k = 0; k < sectorID.length; k++) {
- var uid = sectorID[k];
- z = 0;
- passNumber[k] = 0;
- failNumber[k] = 0;
- stackeverynum[k] = 0;
- for (i = 0; i < output.list.length; i++) {
- if (uid === getSectorId(output.list[i].spotId)) {
- passNumber[k] = output.list[i].passNum + passNumber[k];
- failNumber[k] = output.list[i].failNum + failNumber[k];
- stackeverynum[k] = output.list[i].due + stackeverynum[k];
- z++;
- }
- }
- failrate[k] = get_factor(passNumber[k], failNumber[k]);
- }
- output.list.forEach(function (val, fid, arr) {
- hhp += val.passNum;
- hhf += val.failNum;
- hhs += val.due;
- })
- }
- schedulepass = hhp;
- schedulefail = hhf;
- if (output.list.length > 0) {
- schedulestack = hhs / output.list.length;
- } else {
- schedulestack = 0;
- }
- update_all_history();
- updateChart();
- }
|