puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
var uid = $("#3dnzNxplgTiHaddR",top.window.document).val();
var companyId = '';
 
var Home = {
    id: "HomeTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1,
    businessType:null,//存储企业信息
};
var language = $("#language").val()
/**
 * 初始化表格的列
 */
Home.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '主键ID', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '最后在线时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.insertTime != '' && row.insertTime != null) {
                    var time = row.insertTime.replace(" ",'<br>');
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.insertTime + '" onfocus="TUser.tooltip()">' + time + '</p>']
                }
                return btn;
            }
        },
        {title: '司机头像', field: 'headImgUrl', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                if (row.headImgUrl == null || row.headImgUrl == '') {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 50px;height:50px;" src="' + Feng.ctxPath + '/static/img/NoPIC.png" /></a>';
                } else {
                    return '<a class = "view"  href="javascript:void(0)"><img style="width: 90px;height:50px;" src="' + row.headImgUrl + '" /></a>';
                }
            },
            events: 'operateEvents'
        },
        {title: '司机姓名', field: 'name', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.name != '' && row.name != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.name + '" onfocus="TUser.tooltip()">' + row.name + '</p>']
                }
                return btn;
            }
        },
        {title: '司机电话', field: 'phone', visible: false, align: 'center', valign: 'middle'},
        {title: '在线设备', field: 'device', visible: true, align: 'center', valign: 'middle'},
        {title: '当前版本', field: 'version', visible: true, align: 'center', valign: 'middle'}
    ];
};
 
 
 
/**
 * 点击添加信息
 */
Home.openNetCarInfo = function (e) {
    var id = e.getExtData()[0];
    var index = layer.open({
        type: 2,
        title: language==1?'详细数据':(language==2?'detail':'detail'),
        area: ['770px', '500px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/home/openNetCarInfo?id=' + id,
    });
    this.layerIndex = index;
};
 
 
 
Home.onlineDriver = function () {
    var index = layer.open({
        type: 2,
        title: language==1? '在线司机':(language==2?'Online Driver':'Pemandu Online'),
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/home/showDriverOnline',
    });
    this.layerIndex = index;
};
 
 
Home.search = function () {
    var queryData = {};
    queryData['name'] = $("#name").val();
    queryData['phone'] = $("#phone").val();
    Home.table.refresh({query: queryData});
};
Home.resetSearch = function () {
    $("#name").val("");
    $("#phone").val("");
    Home.search();
};
 
 
$(function () {
    var defaultColunms = Home.initColumn();
    var table = new BSTable(Home.id, "/home/queryOnlineDriver", defaultColunms);
    table.setPaginationType("server");
    Home.table = table.init();
 
    var first = $('.breadcrumb').children('li:first').children('a');
    first.css({
        'color': '#AB2626'
    })
    var className = first.attr('class');
    $('.content').hide();
    $('#' + className + 'Div').show();
 
 
    $('.breadcrumb').find('a').on('click', function () {
        $('.breadcrumb').children('li').each(function () {
            $(this).children('a').removeAttr('style');
        })
 
        $(this).css({
            'color': '#AB2626'
        });
        var className = $(this).attr('class');
        $('.content').hide();
        $('#' + className + "Div").show();
        switch (className) {
            case "statistics":
                getData();
                break;
            case "map":
                var companyId = $('#branchOffice1').val();
                if(null != companyId && '' != companyId){
                    Home.webSocketClient(companyId);
                }else{
                    Home.webSocketClient(null);
                }
                break;
            case "order":
                Home.getAllOrder();
                break;
        }
 
    })
 
 
 
    laydate.render({
        elem: '#addDate', //指定元素
        format: 'yyyy-MM-dd',//日期格式
        value: new Date(),//默认值
        zIndex: 99999999,//层叠顺序
        trigger: 'click'
        ,lang:"en",
        done: function(value, date, endDate){
            getData();
            console.log(value); //得到日期生成的值,如:2017-08-18
        }
    });
    laydate.render({
        elem: '#rangeDate', //指定元素
        format: 'yyyy-MM-dd',//日期格式
        range: true
        ,lang:"en",
        value: '',//默认值
        zIndex: 99999999,//层叠顺序
        trigger: 'click',
        done: function(value, date, endDate){
            getData();
            console.log(value); //得到日期生成的值,如:2017-08-18
        }
    });
    getData();
    getCompanyByUid();
    setInterval(function () {
        Home.webSocketClient(null);
    }, 60000);
    setInterval(function () {
        Home.getAllOrder();
    }, 60000);
});
 
 
 
let map;
let markers = [];
 
let map2;
 
let markers2 = [];
 
function initMap() {
    // The location of Uluru
    const uluru = { lat: -6.9174639, lng: 107.6191228 };
    // The map, centered at Uluru
    map = new google.maps.Map(document.getElementById("map"), {
        zoom: 8,
        center: uluru,
    });
 
    // The map, centered at Uluru
    map2 = new google.maps.Map(document.getElementById("map1"), {
        zoom: 8,
        center: uluru,
    });
}
 
 
window.initMap = initMap;
 
 
 
 
function getCompanyByUid() {
    $.ajax({
        url: Feng.ctxPath + "/home/getCompanyInfoByUserId",
        type: 'POST',
        success: function (res) {
            if(language==1){
                var str = '<option value="">----请选择----</option>';
            }else if(language==2){
                var str = '<option value="">----please choose----</option>';
            }else {
                var str = '<option value="">----Silakan pilih----</option>';
            }
 
            for(var i in res){
                str += '<option value="' + res[i].id + '">' + res[i].name + '</option>'
            }
            $('#branchOffice').html(str);
            $('#branchOffice1').html(str);
        }
    });
}
 
 
 
 
 
 
function getData() {
    var branchOffice =$('#branchOffice').val();
    var addDate = $('#addDate').val();
    var date = $('#rangeDate').val();
    var data = new FormData();
    if(null != branchOffice && '' != branchOffice){
        data.append("companyId", branchOffice);
    }
    if(null != addDate && '' != addDate){
        data.append("addDate", addDate);
    }
    if(null != date && date != ''){
        data.append("start", date.split(' - ')[0]);
        data.append("end", date.split(' - ')[1]);
    }
    $.ajax({
        url: Feng.ctxPath + "/home/getSumData",
        type: 'POST',
        contentType: false,
        processData: false,
        data: data,
        success: function (res) {
            var operationStatus = res.operationStatus;
            var operationSum = res.operationSum;
            var operationGrow = res.operationGrow;
            var operationTrend = res.operationTrend;
 
            $('#newPassengerInfo').text(operationStatus.passengerInfo == null ? 0 : operationStatus.passengerInfo);
            $('#newNetcardriver').text(operationStatus.netcardriver == null ? 0 : operationStatus.netcardriver);
            $('#orderDetail1').text(operationStatus.orderDetail1 == null ? 0 : operationStatus.orderDetail1);
            $('#orderDetail2').text(operationStatus.orderDetail2 == null ? 0 : operationStatus.orderDetail2);
            $('#orderDetail3').text(operationStatus.orderDetail3 == null ? 0 : operationStatus.orderDetail3);
            $('#orderDetail4').text(operationStatus.orderDetail4 == null ? 0 : operationStatus.orderDetail4);
            $('#orderDetail5').text(operationStatus.orderDetail5 == null ? 0 : operationStatus.orderDetail5);
 
            $('#passengerInfoSum').text(operationSum.passengerInfoSum == null ? 0 : operationSum.passengerInfoSum);
            $('#netcarDriverSum').text(operationSum.netcarDriverSum == null ? 0 : operationSum.netcarDriverSum);
            $('#netCarSum').text(operationSum.netCarSum == null ? 0 : operationSum.netCarSum);
            $('#orderDetailSum').text(operationSum.orderDetailSum == null ? 0 : operationSum.orderDetailSum);
            $('#paiceSum').text(operationSum.paiceSum == null ? 0 : operationSum.paiceSum);
            $('#paySum').text(operationSum.paySum == null ? 0 : operationSum.paySum);
 
            $('#passengerInfoSum1').text(operationGrow.passengerInfoSum == null ? 0 : operationGrow.passengerInfoSum);
            $('#netcarDriverSum1').text(operationGrow.netcarDriverSum == null ? 0 : operationGrow.netcarDriverSum);
            $('#orderDetail11').text(operationGrow.orderDetail1 == null ? 0 : operationGrow.orderDetail1);
            $('#orderDetail21').text(operationGrow.orderDetail2 == null ? 0 : operationGrow.orderDetail2);
            $('#orderDetail31').text(operationGrow.orderDetail3 == null ? 0 : operationGrow.orderDetail3);
            $('#orderDetail41').text(operationGrow.orderDetail4 == null ? 0 : operationGrow.orderDetail4);
            $('#orderDetail51').text(operationGrow.orderDetail5 == null ? 0 : operationGrow.orderDetail5);
            $('#paySum1').text(operationGrow.paySum == null ? 0 : operationGrow.paySum);
            $('#paiceSum1').text(operationGrow.paiceSum == null ? 0 : operationGrow.paiceSum);
 
            $('#orderDetailSum1').sparkline(operationTrend.orderDetailSum, {
                lineColor:'green',
                width: '100%',
                height: '33px'
            });
            $('#passengerInfoSum2').sparkline(operationTrend.passengerInfoSum, {
                lineColor:'green',
                width: '100%',
                height: '33px'
            });
            $('#orderDetail12').sparkline(operationTrend.orderDetail1, {
                lineColor:'green',
                width: '100%',
                height: '33px'
            });
            $('#orderDetail22').sparkline(operationTrend.orderDetail2, {
                lineColor:'green',
                width: '100%',
                height: '33px'
            });
            $('#orderDetail32').sparkline(operationTrend.orderDetail3, {
                lineColor:'green',
                width: '100%',
                height: '33px'
            });
            $('#orderDetail42').sparkline(operationTrend.orderDetail4, {
                lineColor:'green',
                width: '100%',
                height: '33px'
            });
            $('#orderDetail52').sparkline(operationTrend.orderDetail5, {
                lineColor:'green',
                width: '100%',
                height: '33px'
            });
        }
    });
}
 
 
function clearMarkers() {
    for (let i = 0; i < markers.length; i++) {
        markers[i].setMap(null);
    }
    markers = [];
}
 
function clearMarkers1() {
    for (let i = 0; i < markers2.length; i++) {
        markers2[i].setMap(null);
    }
    markers2 = [];
}
 
 
 
Home.webSocketClient = function (companyId) {
    $.ajax({
        url: Feng.ctxPath + '/home/getDriverPosition',
        type: 'POST',
        data: {
            companyId: companyId
        },
        success: function (res) {
            clearMarkers();
            var data1 = res.driver1;
            var data2 = res.driver2;
            var order = res.order;
            var d = '';
            for(var i in data1){
                var driver = data1[i].driver;
                var driverId = driver.id;
                d += '<li class="list-group-item" id="' + driverId + '">' + driver.name + '-' + driver.phone + '</li>';
                if('' != data1[i].lon){
                    const image = {
                        url: "/icon_car@2x.png",
                        size: new google.maps.Size(50, 50),
                        origin: new google.maps.Point(16, 15),
                        anchor: new google.maps.Point(0, 0),
                    };
                    const shape = {
                        coords: [1, 1, 1, 20, 18, 20, 18, 1],
                        type: "poly",
                    };
 
                    markers.push(
                        new google.maps.Marker({
                            position: { lat: parseFloat(data1[i].lat), lng: parseFloat(data1[i].lon) },
                            map,
                            icon: image,
                            shape: shape,
                            title: driver.name + '-' + driver.phone,
                            zIndex: driverId,
                        })
                    )
                }
            }
 
            for(var i in data2){
                var driver = data2[i].driver;
                var driverId = driver.id;
                d += '<li class="list-group-item" id="' + driverId + '">' + driver.name + '-' + driver.phone + '</li>';
                if('' != data2[i].lon){
                    const image = {
                        url: "/car.png",
                        size: new google.maps.Size(50, 50),
                        origin: new google.maps.Point(0, 0),
                        anchor: new google.maps.Point(0, 50),
                    };
                    const shape = {
                        coords: [1, 1, 1, 20, 18, 20, 18, 1],
                        type: "poly",
                    };
 
                    markers.push(
                        new google.maps.Marker({
                            position: { lat: parseFloat(data2[i].lat), lng: parseFloat(data2[i].lon) },
                            map,
                            icon: image,
                            shape: shape,
                            title: driver.name + '-' + driver.phone,
                            zIndex: driverId,
                        })
                    )
                }
            }
            $('#netcardriver').html(d);
 
            //订单数据
            var zhuanche = order.zhuanche;
            var kuacheng = order.kuacheng;
            var o = '';
            $('#order').html(o);
            if(language==1){
                var zc = '<div class="list-group"><a href="#" class="list-group-item active">摩托车未接订单</a>'
                for(var i in zhuanche){
                    zc += '<a href="#" class="list-group-item"><p class="list-group-item-text">起点:' + zhuanche[i].startAddress + '</p><p class="list-group-item-text">终点:' + zhuanche[i].endAddress + '</p>' +
                        '<p class="list-group-item-text">下单时间:' + new Date(zhuanche[i].travelTime) + '</p>' +
                        '</a>';
                }
                zc += '</div>';
                o += zc;
 
                var kc = '<div class="list-group"><a href="#" class="list-group-item active">同城快送未接订单</a>'
                for(var i in kuacheng){
                    kc += '<a href="#" class="list-group-item"><p class="list-group-item-text">起点:' + kuacheng[i].startAddress + '</p><p class="list-group-item-text">终点:' + kuacheng[i].endAddress + '</p>' +
                        '<p class="list-group-item-text">下单时间:' + new Date(kuacheng[i].travelTime) + '</p><p class="list-group-item-text">物品类型:' + kuacheng[i].cargoName + '</p>' +
                        '<p class="list-group-item-text">数量:' + kuacheng[i].cargoNumber + '</p></a>';
                }
            }else if(language==2){
                var zc = '<div class="list-group"><a href="#" class="list-group-item active">Motorcycle order not received</a>'
                for(var i in zhuanche){
                    zc += '<a href="#" class="list-group-item"><p class="list-group-item-text">origin:' + zhuanche[i].startAddress + '</p><p class="list-group-item-text">destination:' + zhuanche[i].endAddress + '</p>' +
                        '<p class="list-group-item-text">order time:' + new Date(zhuanche[i].travelTime) + '</p>' +
                        '</a>';
                }
                zc += '</div>';
                o += zc;
 
                var kc = '<div class="list-group"><a href="#" class="list-group-item active">City Express delivery missed order</a>'
                for(var i in kuacheng){
                    kc += '<a href="#" class="list-group-item"><p class="list-group-item-text">origin:' + kuacheng[i].startAddress + '</p><p class="list-group-item-text">destination:' + kuacheng[i].endAddress + '</p>' +
                        '<p class="list-group-item-text">order time:' + new Date(kuacheng[i].travelTime) + '</p><p class="list-group-item-text">type:' + kuacheng[i].cargoName + '</p>' +
                        '<p class="list-group-item-text">number:' + kuacheng[i].cargoNumber + '</p></a>';
                }
            }else {
                var zc = '<div class="list-group"><a href="#" class="list-group-item active">Motosikal tidak menerima perintah</a>'
                for(var i in zhuanche){
                    zc += '<a href="#" class="list-group-item"><p class="list-group-item-text">titik awal:' + zhuanche[i].startAddress + '</p><p class="list-group-item-text">Akhir:' + zhuanche[i].endAddress + '</p>' +
                        '<p class="list-group-item-text">Waktu perintah:' + new Date(zhuanche[i].travelTime) + '</p>' +
                        '</a>';
                }
                zc += '</div>';
                o += zc;
 
                var kc = '<div class="list-group"><a href="#" class="list-group-item active">Pengiriman ekspres ke kota tanpa menerima perintah</a>'
                for(var i in kuacheng){
                    kc += '<a href="#" class="list-group-item"><p class="list-group-item-text">titik awal:' + kuacheng[i].startAddress + '</p><p class="list-group-item-text">Akhir:' + kuacheng[i].endAddress + '</p>' +
                        '<p class="list-group-item-text">Waktu perintah:' + new Date(kuacheng[i].travelTime) + '</p><p class="list-group-item-text">Jenis Item:' + kuacheng[i].cargoName + '</p>' +
                        '<p class="list-group-item-text">jumlah:' + kuacheng[i].cargoNumber + '</p></a>';
                }
            }
 
            kc += '</div>';
            o += kc;
 
            $('#order').html(o);
        }
    })
}
 
 
 
Home.getAllOrder = function () {
    var b1 = $("#SupendButton-one").val();
    var b2 = $("#SupendButton-two").val();
    let type =null;
    if(b1!=''){
        type=b1
    }
    if(b2!=''){
        type=b2
    }
    $.ajax({
        url: Feng.ctxPath + '/home/getAllOrder',
        type: 'POST',
        data: {
            companyId: companyId,
            type:type
        },
        success: function (res) {
 
            clearMarkers1()
            for(var i in res){
                markers2.push(
                    new google.maps.Marker({
                        position: { lat: parseFloat(res[i].lat), lng: parseFloat(res[i].lon) },
                        map: map2,
                    })
                )
            }
        }
    });
}
 
 
 
function getData1() {
    var companyId = null;
    var branchOffice1 = $('#branchOffice1').val();
    if('' != branchOffice1  && null != branchOffice1){
        companyId = branchOffice1;
    }
    Home.webSocketClient(companyId);
}