-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderroutine.js
134 lines (114 loc) · 3.74 KB
/
orderroutine.js
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
module.exports = {
generate() {
const ROBOT_TEMPLATE = {
"ActualBin": "GR-YDI1",
"ActQueue": "",
"Lgnum": "1710",
"Rsrc": "LOCAL-ROBOT",
"RsrcType": "RB01",
"RsrcGrp": "RB02",
"ExccodeOverall": ""
}
const WAREHOUSEORDER_TEMPLATE = {
"Lgnum": "1710",
"Who": "",
"Status": "",
"Areawho": "WDF4",
"Lgtyp": "",
"Lgpla": "",
"Queue": "LOCAL-ROBOT",
"Rsrc": "",
"Lsd": "0",
"Topwhoid": "0000000000",
"Refwhoid": "0000000000",
"Flgwho": false,
"Flgto": true
}
const TASKS = [
{
"Lgnum": "1710",
"Tanum": "",
"Flghuto": true,
"Tostat": "",
"Priority": 0,
"Meins": "PC",
"Vsolm": "1",
"Weight": "4.000",
"UnitW": "KG",
"Volum": "3.000",
"UnitV": "L",
"Vltyp": "Y021",
"Vlber": "YS01",
"Vlpla": "GR-YDI1",
"Vlenr": "",
"Nltyp": "Y920",
"Nlber": "YO01",
"Nlpla": "GI-YDO1",
"Nlenr": "",
"Who": ""
}, {
"Lgnum": "1710",
"Tanum": "",
"Flghuto": true,
"Tostat": "",
"Priority": 0,
"Meins": "PC",
"Vsolm": "1",
"Weight": "4.000",
"UnitW": "KG",
"Volum": "3.000",
"UnitV": "L",
"Vltyp": "Y910",
"Vlber": "YI00",
"Vlpla": "GI-YDO1",
"Vlenr": "112345678000000001",
"Nltyp": "Y011",
"Nlber": "YS02",
"Nlpla": "GR-YDI1",
"Nlenr": "112345678000000001",
"Who": ""
}
]
var tools = require('./tools/toolbox.js')
var id = 1
var taskIndex = 0
setTimeout(async () => {
await tools.createEntity("RobotSet", ROBOT_TEMPLATE)
}, 1)
// Create Order + Task
setTimeout(async () => {
let order = WAREHOUSEORDER_TEMPLATE
let task = TASKS[taskIndex]
order.Who = "" + (10000000 + id)
task.Who = order.Who
task.Tanum = "" + (20000000 + id)
taskIndex += 1
await tools.createEntity("WarehouseOrderSet", order)
await tools.createEntity("OpenWarehouseTaskSet", task)
id += 1
}, 100)
// Create Order + Task
var interval = 25000
if (process.env.GEN_INT) {
interval = process.env.GEN_INT
}
setInterval(async () => {
// limit new Orders and Tasks by the total number of open WHTs
let openWhtCount = await tools.makeRequest("http://localhost:8080/odata/SAP/ZEWM_ROBCO_SRV/OpenWarehouseTaskSet/$count", {})
if (openWhtCount.body < 250) {
let order = WAREHOUSEORDER_TEMPLATE
let task = TASKS[taskIndex]
order.Who = "" + (10000000 + id)
task.Who = order.Who
task.Tanum = "" + (20000000 + id)
taskIndex += 1
if (taskIndex == TASKS.length) {
taskIndex = 0
}
await tools.createEntity("WarehouseOrderSet", order)
await tools.createEntity("OpenWarehouseTaskSet", task)
id += 1
}
}, interval)
}
}