分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-01-16 a0f3b5aa29fa51ac9d61b1cf56a5b34624a780cd
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
function query_time(start_time, end_time) {
    this.start_time = start_time;
    this.end_time = end_time;
}
var t = new query_time();
var currentPage_task = 1;//当前页
var recordsCount_task = 17;//每页条数
var totalPages_task = 1;//总页数
 
var currentPage_taskout = 1;//当前页
var recordsCount_taskout = 17;//每页条数
var totalPages_taskout = 1;//总页数
$(function () {
    getQueryTime(t);
 
    var currentPage = 1;//当前页
    var recordsCount = 17;//每页条数
    //获取默认日志数据
    getLogData(t.start_time, t.end_time, "", "", recordsCount, currentPage);
    //获取所有任务
    var totalPages = 10;//总页数
 
    getTaskData("", "", null, null, recordsCount_task, currentPage_task);//查询入库任务
    getTaskOutData("", "", null, null, recordsCount_taskout, currentPage_taskout);//查询出库任务
 
    $("#page").bootstrapPaginator({
        bootstrapMajorVersion: 3, //对应的bootstrap版本
        currentPage: currentPage, //当前页数
        numberOfPages: 10, //每次显示页数
        totalPages: totalPages, //总页数
        shouldShowPage: true,//是否显示该按钮
        useBootstrapTooltip: true,
        //点击事件
        onPageClicked: function (event, originalEvent, type, page) {
            //console.log("点击页数时,触发该函数, type: " + type + " page: " + page);
            var tr_type = $('#TrackType').val();
            var user_data = $('input[name="user_data"]').val();
            getQueryTime(t);
            getLogData(t.start_time, t.end_time, user_data, tr_type, recordsCount, page);
            getTotalPage(t.start_time, t.end_time, user_data, tr_type, recordsCount, page);
        },
        onPageChanged: function (e, oldPage, newPage) {
            //console.log("当页面改变时,触发该函数, old: " + oldPage + " new: " + newPage);
        }
    });
    //入库
    $("#page-task").bootstrapPaginator({
        bootstrapMajorVersion: 3, //对应的bootstrap版本
        currentPage: currentPage_task, //当前页数
        numberOfPages: 10, //每次显示页数
        totalPages: totalPages_task, //总页数
        shouldShowPage: true,//是否显示该按钮
        useBootstrapTooltip: true,
        onPageClicked: function (event, originalEvent, type, page) {
            RefrashTaskInfo(page);
        },
        onPageChanged: function (e, oldPage, newPage) { }
    });
    //出库
    $("#page-taskout").bootstrapPaginator({
        bootstrapMajorVersion: 3, //对应的bootstrap版本
        currentPage: currentPage_task, //当前页数
        numberOfPages: 10, //每次显示页数
        totalPages: totalPages_taskout, //总页数
        shouldShowPage: true,//是否显示该按钮
        useBootstrapTooltip: true,
        onPageClicked: function (event, originalEvent, type, page) {
            RefrashTaskOutInfo(page);
        },
        onPageChanged: function (e, oldPage, newPage) { }
    });
});
 
 
function cacheFunction()
{
    var q0 = "WebDev.WebServer40,VSPEC_WCS";
    $.ajax({
        type: "post",
        url: "../../AJAX/GetAGVInfo.ashx",
        data: { action: "Killprocess", q0: q0 },
        async: false,
        success: function (msg) {}
    });
}
 
function RefrashTaskInfo(page) { //刷新当前入库任务
    var task_bill = $('input[name="task_bill"]').val();
    var task_barcode = $('input[name="task_barcode"]').val();
    var task_type = $('#task_type').val();
    var task_state = $('#task_state').val();
 
    getTaskData(task_bill, task_barcode, task_type, task_state, recordsCount_task, page);
    getTaskTotalPage(task_bill, task_barcode, task_type, task_state, recordsCount_task, page);
}
 
//获取日志数据
function getLogData(str0, str1, str2, str3, str4, str5) {
    $.ajax({
        type: "post",
        url: "/AJAX/OPCServiceOperation.ashx",
        data: { action: "GetLogInfo", q0: str0, q1: str1, q2: str2, q3: str3, q4: str4, q5: str5 },//q0: "2018-6-15 15:06:19", q1: "2018-6-22 15:06:52", q2: "", q3: "Successed", q4: "17", q5: newPage
        async: false,
        success: function (msg) {
            if (msg.length > 0) {
                $('.LogInfo-Tb tr:gt(0)').empty();
                var json = JSON.parse(msg);
                for (var i = 0; i < json.length; i++) {
                    var dt = eval(json[i].EventDate.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
                    $("<tr><td>" + (i + 1) + "</td><td>" + dt.toLocaleString() + "</td><td>" + json[i].UserData + "</td><td>" + json[i].TrackType + "</td><td>"
                        + json[i].Extension1 + "</td><td>" + json[i].TrackOperator + "</td></tr>").appendTo(".LogInfo-Tb");
                }
            } else {
                $('.LogInfo-Tb tr:gt(0)').empty();
                //swal("无数据!", msg, "error");
            }
        }
    });
}
//获取日志总页数
function getTotalPage(str0, str1, str2, str3, str4, str5) {
    $.ajax({
        type: "post",
        url: "/AJAX/OPCServiceOperation.ashx",
        data: { action: "getTotalPage", q0: str0, q1: str1, q2: str2, q3: str3, q4: str4, q5: str5 },
        async: false,
        success: function (msg) {
            if (msg > 0) {
                $("#page").bootstrapPaginator({ totalPages: Number(msg) });
            }
        }
    });
}
//获取日志查询时间段
function getQueryTime(t) {
    var default_time = $('#my-datepicker').val();
    if ("" != default_time && null != default_time) {
        var times = default_time.trim().split(' - ');
        if (times.length > 0) {
            t.start_time = times[0];
            t.end_time = times[1];
        }
    } else {
        t.start_time = "";
        t.end_time = "";
    }
}
//获取入库任务数据
function getTaskData(bill, barcode, type, state, recordCount, currentPage) {
    $.ajax({
        type: "post",
        url: "/AJAX/OPCServiceOperation.ashx",
        data: { action: "GetTaskInfo", q0: bill, q1: barcode, q2: type, q3: state, q4: recordCount, q5: currentPage },
        async: false,
        success: function (msg) {
            if (msg.length > 0) {
                // TASKNUMBER         
                $('.task-query-tb tr:gt(0)').remove();
                var json = JSON.parse(msg);
                for (var i = 0; i < json.length; i++) {
                    var number = json[i].TASKNUMBER;
                    var dt = eval(json[i].CREATETIME.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
                    $('<tr><td>' + json[i].SEQUENCENUMBER + '</td>' +
                        '<td>'+ json[i].BARCODE + '</td><td>' + json[i].SOURCEADDRESSID + '</td><td>' + json[i].TARGETADDRESSID + '</td><td>' + json[i].DisplayTaskType + '</td><td>'
                        + json[i].DisplayTaskState + '</td><td>' + json[i].DisplayEquipment + '</td><td>'+ json[i].CONTAINERID + '</td><td>' + json[i].ITEMID + '</td><td>'
                        + json[i].QTY + '</td><td>' + dt.toLocaleString() + '</td></tr>').appendTo(".task-query-tb");
                    $('.task-query-tb tr:eq(' + (i + 1) + ')  #delete').attr("disabled", true);
                    if ($('#thisModel').val() == "ExceptionMode")
                    {
                        $('.task-query-tb tr:eq(' + (i + 1) + ')  #delete').attr("disabled", false);
                    }
                    //if (json[i].SEQUENCENUMBER != "主任务")
                    //{
                    //    $('.task-query-tb tr:eq(' + (i + 1) + ') #action').attr("disabled", true);
                    //}
                }
            } else {
                $('.task-query-tb tr:gt(0)').remove();
                //swal("无数据!", msg, "error");
            }
        }
    });
}
// ***************************************************************************************************************************
 
//按序列发送入库任务
function sendEquipmentTask(tasknum) {
    if (null != tasknum && "" != tasknum) {
        swal({
            title: "确定执行命令吗?",
            text: "你将无法恢复到执行前的状态!",
            type: "warning",
            showCancelButton: true,
            confirmbuttoncolor: "#dd6b55",
            confirmbuttontext: "确定执行!",
            confirmButtonText: '执行',
            cancelButtonText: '取消',
            closeonconfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/ajax/SendTaskInfoOperation.ashx",
                data: { action: "sendTask", q0: "", q1: tasknum },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal("成功!", "命令已下发", "success");
                        RefrashTaskInfo(currentPage_task);
                        //if ($('.task-query-tb tr:eq(1) #action').val() != "完成") {
                        //    $('.task-query-tb tr:eq(1) #action').val("完成");
                        //    $('.task-query-tb tr:eq(1) input').removeClass("btn-info");
                        //    $('.task-query-tb tr:eq(1) input').addClass("btn-danger");
                        //}
                        //clearuser();
                    } else {
                        swal("失败!", msg, "error");
                    }
                }
            });
        });
    } else {
        swal("失败!", "未获取到任务号", "error");
    }
}
//获取入库任务总页数
function getTaskTotalPage(bill, barcode, type, state, recordCount, currentPage) {
    $.ajax({
        type: "post",
        url: "/AJAX/OPCServiceOperation.ashx",
        data: { action: "getTaskTotalPage", q0: bill, q1: barcode, q2: type, q3: state, q4: recordCount, q5: currentPage },
        async: false,
        success: function (msg) {
            if (msg > 0) {
                $("#page-task").bootstrapPaginator({ totalPages: Number(msg) });
            }
        }
    });
}
 
function getUser() {
    var user = $('#currentUser').val();
    return user;
}
 
//删除任务
function delThisTask(tasknum,index) {
    if (null != tasknum && "" != tasknum) {
        swal({
            title: "确定删除当前任务吗?",
            text: "你将无法恢复到执行前的状态!",
            type: "warning",
            showCancelButton: true,
            confirmbuttoncolor: "#dd6b55",
            confirmbuttontext: "确定删除!",
            confirmButtonText: '删除',
            cancelButtonText: '取消',
            closeonconfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/ajax/SendTaskInfoOperation.ashx",
                data: { action: "delHandTask", q0: getUser(), q1: tasknum },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal("成功!", "当前任务已删除", "success");
                        if (index == 1) {
                            RefrashTaskInfo(currentPage_task);
                        }
                        if (index == 2)
                        {
                            RefrashTaskOutInfo(currentPage_task);
                        }
                        //clearuser();
                    } else {
                        swal("失败!", msg, "error");
                    }
                }
            });
        });
    } else {
        swal("失败!", "未获取到任务号", "error");
    }
}
// ***************************************************************************************************************************
 
//获取出库任务数据
function getTaskOutData(bill, barcode, type, state, recordCount, currentPage) {
    $.ajax({
        type: "post",
        url: "/AJAX/OPCServiceOperation.ashx",
        data: { action: "GetTaskOutInfo", q0: bill, q1: barcode, q2: type, q3: state, q4: recordCount, q5: currentPage },
        async: false,
        success: function (msg) {
            if (msg.length > 0) {
                // TASKNUMBER         
                $('.taskout-query-tb tr:gt(0)').remove();
                var json = JSON.parse(msg);
                for (var i = 0; i < json.length; i++) {
                    var number = json[i].TASKNUMBER;
                    var dt = eval(json[i].CREATETIME.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
                    $('<tr><td>' + json[i].SEQUENCENUMBER + '</td><td>'
                        + json[i].BARCODE + '</td><td>' + json[i].SOURCEADDRESSID + '</td><td>' + json[i].TARGETADDRESSID + '</td><td>' + json[i].DisplayTaskType + '</td><td>'
                        + json[i].DisplayTaskState + '</td><td>' + json[i].DisplayEquipment + '</td><td>' + json[i].CONTAINERID + '</td><td>' + json[i].ITEMID + '</td><td>'
                        + json[i].QTY + '</td><td>' + dt.toLocaleString() + '</td></tr>').appendTo(".taskout-query-tb");
                    $('.taskout-query-tb tr:eq(' + (i + 1) + ')  #delete').attr("disabled", true);
                    if ($('#thisModel').val() == "ExceptionMode") {
                        $('.taskout-query-tb tr:eq(' + (i + 1) + ')  #delete').attr("disabled", false);
                    }
                    //if (i > 0) {
                    //    $('.taskout-query-tb tr:eq(' + (i + 1) + ') input').attr("disabled", "disabled");
                    //}
                    //if (json[i].SEQUENCENUMBER != "主任务") {
                    //    $('.taskout-query-tb tr:eq(' + (i + 1) + ') #action').attr("disabled", true);
                    //}
                }
            } else {
                $('.taskout-query-tb tr:gt(0)').remove();
                //swal("无数据!", msg, "error");
            }
        }
    });
}
function RefrashTaskOutInfo(page) { //刷新当前出库库任务
    var task_bill = $('input[name="taskout_bill"]').val();
    var task_barcode = $('input[name="taskout_barcode"]').val();
    var task_type = $('#taskout_type').val();
    var task_state = $('#taskout_state').val();
 
    getTaskOutData(task_bill, task_barcode, task_type, task_state, recordsCount_taskout, page);
    getTaskOutTotalPage(task_bill, task_barcode, task_type, task_state, recordsCount_taskout, page);
}
//按序列发送出库任务
function sendEquipmentTaskOut(tasknum) {
    if (null != tasknum && "" != tasknum) {
        swal({
            title: "确定执行命令吗?",
            text: "你将无法恢复到执行前的状态!",
            type: "warning",
            showCancelButton: true,
            confirmbuttoncolor: "#dd6b55",
            confirmbuttontext: "确定执行!",
            confirmButtonText: '执行',
            cancelButtonText: '取消',
            closeonconfirm: false
        },
        function () {
            $.ajax({
                type: "post",
                url: "/ajax/SendTaskInfoOperation.ashx",
                data: { action: "sendTask", q0: "", q1: tasknum },
                async: false,
                success: function (msg) {
                    if ("" == msg) {
                        swal("成功!", "命令已下发", "success");
                        RefrashTaskOutInfo(currentPage_taskout);
                        //if ($('.taskout-query-tb tr:eq(1) input').val() != "完成") {
                        //    $('.taskout-query-tb tr:eq(1) input').val("完成");
                        //    $('.taskout-query-tb tr:eq(1) input').removeClass("btn-info");
                        //    $('.taskout-query-tb tr:eq(1) input').addClass("btn-danger");
                        //}
                        //clearuser();
                    } else {
                        setTimeout(function () { swal("失败", msg, "error"); }, 100);
                        //swal("失败!", msg, "error");
                    }
                }
            });
        });
    } else {
        swal("失败!", "未获取到任务号", "error");
    }
}
 
//获取出库任务总页数
function getTaskOutTotalPage(bill, barcode, type, state, recordCount, currentPage) {
    $.ajax({
        type: "post",
        url: "/AJAX/OPCServiceOperation.ashx",
        data: { action: "getTaskOutTotalPage", q0: bill, q1: barcode, q2: type, q3: state, q4: recordCount, q5: currentPage },
        async: false,
        success: function (msg) {
            if (msg > 0) {
                $("#page-taskout").bootstrapPaginator({ totalPages: Number(msg) });
            }
        }
    });
}