node-red-trexmes-commands 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/locales/en-US/trexcommands.json +12 -1
- package/src/trexcommands.html +98 -11
- package/src/trexcommands.js +196 -51
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ The following operations can be performed with this node by communicating with t
|
|
|
22
22
|
- Finish Test Mode
|
|
23
23
|
- Create Deffect
|
|
24
24
|
|
|
25
|
-
For configuration, first MS SQL server connection setting must be made. In addition, the
|
|
25
|
+
For configuration, first MS SQL server connection setting must be made. In addition, the company identification id and the identification id of the personnel who will perform the transaction should be defined as default in the connection features, specific to the trex system.
|
|
26
26
|
|
|
27
27
|
Then, the relevant operation is selected from the "Operation Type" combo contained in the node.
|
|
28
28
|
The Json sample data requested as input is displayed on the node for each operation.
|
package/package.json
CHANGED
|
@@ -13,7 +13,17 @@
|
|
|
13
13
|
"editor": "Expected Input Format",
|
|
14
14
|
"error_handling": "Error Handling",
|
|
15
15
|
"error_handling_send_in_msg": "Send in msg.error",
|
|
16
|
-
"error_handling_throw": "Throw error"
|
|
16
|
+
"error_handling_throw": "Throw error",
|
|
17
|
+
"isShowingOnlyJobsToCome": "Only Jobs to Come",
|
|
18
|
+
"isShowingOnlyPassedJobs": "Only Passed Jobs",
|
|
19
|
+
"isShowingSameStationGroupJobs": "Same Station Group Jobs",
|
|
20
|
+
"isShowingSameWorkCenterJobs": "Same Workcenter Jobs",
|
|
21
|
+
"isProducedQuantityConditionDisabled":"Remove Check Produced Quantity",
|
|
22
|
+
"isLineProduction": "Line Production",
|
|
23
|
+
"isFinishingPlanWhenCompleted": "Finishing Plan When Completed",
|
|
24
|
+
"isCheckingPreviousOperationWorkingControl": "Check Prev Opr Working",
|
|
25
|
+
"isCheckingPreviousOperationProductionControl": "Check Prev Opr Product",
|
|
26
|
+
"getOpenJobs-filter": "Open Jobs Filter Options"
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
"connection": {
|
|
@@ -28,6 +38,7 @@
|
|
|
28
38
|
"domain": "Domain",
|
|
29
39
|
"database": "Database",
|
|
30
40
|
"companyId": "Company Id",
|
|
41
|
+
"cperiodId": "Period Id",
|
|
31
42
|
"userId": "User Id",
|
|
32
43
|
"tds": {
|
|
33
44
|
"title": "TDS Version",
|
package/src/trexcommands.html
CHANGED
|
@@ -85,7 +85,11 @@
|
|
|
85
85
|
<div class="form-row trexmes-cmd-form-row">
|
|
86
86
|
<label for="node-config-input-companyId"><i class="fa fa-building"></i> <span data-i18n="trexMes-CMD.connection.label.companyId"></label>
|
|
87
87
|
<input type="text" id="node-config-input-companyId">
|
|
88
|
-
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="form-row trexmes-cmd-form-row">
|
|
90
|
+
<label for="node-config-input-cperiodId"><i class="fa fa-building"></i> <span data-i18n="trexMes-CMD.connection.label.cperiodId"></label>
|
|
91
|
+
<input type="text" id="node-config-input-cperiodId">
|
|
92
|
+
</div>
|
|
89
93
|
<div class="form-row trexmes-cmd-form-row">
|
|
90
94
|
<label for="node-config-input-userId"><i class="fa fa-user-md"></i> <span data-i18n="trexMes-CMD.connection.label.userId"></label>
|
|
91
95
|
<input type="text" id="node-config-input-userId">
|
|
@@ -180,6 +184,10 @@
|
|
|
180
184
|
value: 0,
|
|
181
185
|
required: true
|
|
182
186
|
},
|
|
187
|
+
cperiodId: {
|
|
188
|
+
value: 0,
|
|
189
|
+
required: true
|
|
190
|
+
},
|
|
183
191
|
userId: {
|
|
184
192
|
value: 0,
|
|
185
193
|
required: true
|
|
@@ -253,19 +261,54 @@
|
|
|
253
261
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="trexMes-CMD.node.label.name"></span></label>
|
|
254
262
|
<input type="text" id="node-input-name" data-i18n="[placeholder]trexMes-CMD.node.label.name">
|
|
255
263
|
</div>
|
|
256
|
-
|
|
257
|
-
|
|
264
|
+
|
|
258
265
|
<div class="form-row trexmes-cmd-form-row">
|
|
259
|
-
<label for="node-input-
|
|
266
|
+
<label for="node-input-modeOpt"><i class="fa fa-list-ul"></i> <span data-i18n="trexMes-CMD.node.label.query_mode"></span></label>
|
|
260
267
|
<input type="hidden" id="node-input-modeOptType">
|
|
261
268
|
<input type="text" id="node-input-modeOpt" style="width: 70%" data-i18n="[placeholder]trexMes-CMD.node.label.query_mode">
|
|
262
269
|
</div>
|
|
263
|
-
|
|
270
|
+
|
|
271
|
+
<label for="node-input-getOpenJobs-filter" id="node-input-label-getOpenJobs-filter" style="display:none"><i class="fa fa-filter"></i><span data-i18n="trexMes-CMD.node.label.getOpenJobs-filter"></span></label>
|
|
272
|
+
<div class="form-row trexmes-cmd-form-row" id="node-input-getOpenJobs-filter" style="display:none">
|
|
273
|
+
|
|
274
|
+
<label for="node-input-isShowingOnlyJobsToCome" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isShowingOnlyJobsToCome"></span></label>
|
|
275
|
+
<input type="checkbox" id="node-input-isShowingOnlyJobsToCome" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isShowingOnlyJobsToCome">
|
|
276
|
+
<br>
|
|
277
|
+
<label for="node-input-isShowingOnlyPassedJobs" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isShowingOnlyPassedJobs"></span></label>
|
|
278
|
+
<input type="checkbox" id="node-input-isShowingOnlyPassedJobs" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isShowingOnlyPassedJobs">
|
|
279
|
+
<br>
|
|
280
|
+
<label for="node-input-isShowingSameStationGroupJobs" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isShowingSameStationGroupJobs"></span></label>
|
|
281
|
+
<input type="checkbox" id="node-input-isShowingSameStationGroupJobs" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isShowingSameStationGroupJobs">
|
|
282
|
+
<br>
|
|
283
|
+
<label for="node-input-isShowingSameWorkCenterJobs" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isShowingSameWorkCenterJobs"></span></label>
|
|
284
|
+
<input type="checkbox" id="node-input-isShowingSameWorkCenterJobs" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isShowingSameWorkCenterJobs">
|
|
285
|
+
<br>
|
|
286
|
+
<label for="node-input-isProducedQuantityConditionDisabled" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isProducedQuantityConditionDisabled"></span></label>
|
|
287
|
+
<input type="checkbox" id="node-input-isProducedQuantityConditionDisabled" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isProducedQuantityConditionDisabled">
|
|
288
|
+
<br>
|
|
289
|
+
<label for="node-input-isLineProduction" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isLineProduction"></span></label>
|
|
290
|
+
<input type="checkbox" id="node-input-isLineProduction" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isLineProduction">
|
|
291
|
+
<br>
|
|
292
|
+
<label for="node-input-isFinishingPlanWhenCompleted" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isFinishingPlanWhenCompleted"></span></label>
|
|
293
|
+
<input type="checkbox" id="node-input-isFinishingPlanWhenCompleted" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isFinishingPlanWhenCompleted">
|
|
294
|
+
<br>
|
|
295
|
+
<label for="node-input-isCheckingPreviousOperationProductionControl" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isCheckingPreviousOperationProductionControl"></span></label>
|
|
296
|
+
<input type="checkbox" id="node-input-isCheckingPreviousOperationProductionControl" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isCheckingPreviousOperationProductionControl">
|
|
297
|
+
<br>
|
|
298
|
+
<label for="node-input-isCheckingPreviousOperationWorkingControl" style="width: 70%"><span data-i18n="trexMes-CMD.node.label.isCheckingPreviousOperationWorkingControl"></span></label>
|
|
299
|
+
<input type="checkbox" id="node-input-isCheckingPreviousOperationWorkingControl" style="width: 30%" data-i18n="[placeholder]trexMes-CMD.node.label.isCheckingPreviousOperationWorkingControl">
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
</div>
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
264
307
|
<div class="form-row trexmes-cmd-form-row node-text-editor-row" style="min-height: 60px; margin-top: -6px;">
|
|
265
308
|
<label for="node-json-param-editor" style="width: 100% !important;"><i class="fa fa-tag"></i> <span data-i18n="trexMes-CMD.node.label.editor"></span></label>
|
|
266
309
|
<div style="height: 60px;" class="node-text-editor" id="node-json-param-editor" ></div>
|
|
267
310
|
</div>
|
|
268
|
-
|
|
311
|
+
|
|
269
312
|
<div class="form-row trexmes-cmd-form-row">
|
|
270
313
|
<label for="node-input-throwErrors"><i class="fa fa-exclamation"></i> <span data-i18n="trexMes-CMD.node.label.error_handling"></label>
|
|
271
314
|
<select id="node-input-throwErrors" style="width: 70%">
|
|
@@ -299,6 +342,36 @@
|
|
|
299
342
|
},
|
|
300
343
|
modeOptType: {
|
|
301
344
|
value: '1|Load Job Plan'
|
|
345
|
+
},
|
|
346
|
+
isShowingOnlyJobsToCome: {
|
|
347
|
+
value: false
|
|
348
|
+
},
|
|
349
|
+
isShowingOnlyPassedJobs: {
|
|
350
|
+
value: false
|
|
351
|
+
},
|
|
352
|
+
isShowingSameStationGroupJobs: {
|
|
353
|
+
value: false
|
|
354
|
+
},
|
|
355
|
+
isShowingSameStationGroupJobs: {
|
|
356
|
+
value: false
|
|
357
|
+
},
|
|
358
|
+
isShowingSameWorkCenterJobs: {
|
|
359
|
+
value: false
|
|
360
|
+
},
|
|
361
|
+
isProducedQuantityConditionDisabled: {
|
|
362
|
+
value: false
|
|
363
|
+
},
|
|
364
|
+
isLineProduction: {
|
|
365
|
+
value: false
|
|
366
|
+
},
|
|
367
|
+
isFinishingPlanWhenCompleted: {
|
|
368
|
+
value: false
|
|
369
|
+
},
|
|
370
|
+
isCheckingPreviousOperationProductionControl: {
|
|
371
|
+
value: false
|
|
372
|
+
},
|
|
373
|
+
isCheckingPreviousOperationWorkingControl: {
|
|
374
|
+
value: false
|
|
302
375
|
}
|
|
303
376
|
},
|
|
304
377
|
inputs: 1,
|
|
@@ -342,7 +415,8 @@
|
|
|
342
415
|
{ value: '13|Shifted Shift', label: 'Shifted Shift', hasValue: false },
|
|
343
416
|
{ value: '14|Start Test Mode', label: 'Start Test Mode', hasValue: false },
|
|
344
417
|
{ value: '15|Finish Test Mode', label: 'Finish Test Mode', hasValue: false },
|
|
345
|
-
{ value: '16|Create Deffect', label: 'Create Deffect', hasValue: false }
|
|
418
|
+
{ value: '16|Create Deffect', label: 'Create Deffect', hasValue: false },
|
|
419
|
+
{ value: '100|Get Open Jobs', label: 'Get Open Jobs', hasValue: false }
|
|
346
420
|
],
|
|
347
421
|
typeField: $('#node-input-modeOptType'),
|
|
348
422
|
default: 'Load Job Plan'
|
|
@@ -351,7 +425,9 @@
|
|
|
351
425
|
//show expected data sample
|
|
352
426
|
modeField.on('change', function() {
|
|
353
427
|
const operationMode = $(this).typedInput('type');
|
|
354
|
-
|
|
428
|
+
$("#node-input-label-getOpenJobs-filter").hide();
|
|
429
|
+
$("#node-input-getOpenJobs-filter").hide();
|
|
430
|
+
|
|
355
431
|
let data = '{}';
|
|
356
432
|
if(operationMode.startsWith('1|')) { // Load Job Plan
|
|
357
433
|
data = '{ "WorkstationId": 10 , "PlanId": 123 }';
|
|
@@ -386,15 +462,26 @@
|
|
|
386
462
|
else if(operationMode.startsWith('16|')) { //Create Deffect
|
|
387
463
|
data = '{ "WorkstationId": 10, "DefectId": 11,"StockId": 12, "Quantity": 15.5 }';
|
|
388
464
|
}
|
|
465
|
+
else if(operationMode.startsWith('100|')) { //Get Open Jobs
|
|
466
|
+
data = '{ "WorkstationId": 10 }';
|
|
467
|
+
$("#node-input-label-getOpenJobs-filter").show();
|
|
468
|
+
$("#node-input-getOpenJobs-filter").show();
|
|
469
|
+
}
|
|
389
470
|
node.editor.setValue(JSON.stringify(JSON.parse(data),null, 2));
|
|
390
471
|
|
|
391
472
|
});
|
|
392
473
|
|
|
393
|
-
|
|
394
|
-
$('#node-input-returnType')[0].selectedIndex = this.returnType ? this.returnType : 0;
|
|
474
|
+
|
|
395
475
|
$('#node-input-throwErrors')[0].selectedIndex = this.throwErrors ? this.throwErrors : 0;
|
|
396
476
|
|
|
397
|
-
|
|
477
|
+
if(this.modeOptType.startsWith("100|")) {
|
|
478
|
+
$("#node-input-label-getOpenJobs-filter").show();
|
|
479
|
+
$("#node-input-getOpenJobs-filter").show();
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
$("#node-input-label-getOpenJobs-filter").hide();
|
|
483
|
+
$("#node-input-getOpenJobs-filter").hide();
|
|
484
|
+
}
|
|
398
485
|
},
|
|
399
486
|
oneditsave: function () {
|
|
400
487
|
const node = this;
|
package/src/trexcommands.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = function (RED) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function checkPayload(payload) {
|
|
35
|
-
let result = { "isOk" : false };
|
|
35
|
+
let result = { "isOk" : false, "isGetFunc": false };
|
|
36
36
|
if(!payload.WorkstationId){
|
|
37
37
|
return result;
|
|
38
38
|
}
|
|
@@ -111,7 +111,12 @@ module.exports = function (RED) {
|
|
|
111
111
|
}
|
|
112
112
|
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId, "DefectId": payload.DefectId, "StockId": payload.StockId, "Quantity": payload.Quantity, "ReferenceQuantityType": 0 });
|
|
113
113
|
result.isOk = true;
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
|
+
else if(payload.operationMode == "100" ) { // Get Open Jobs
|
|
116
|
+
result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId });
|
|
117
|
+
result.isOk = true;
|
|
118
|
+
result.isGetFunc = true;
|
|
119
|
+
}
|
|
115
120
|
return result;
|
|
116
121
|
}
|
|
117
122
|
|
|
@@ -139,6 +144,100 @@ module.exports = function (RED) {
|
|
|
139
144
|
return sql;
|
|
140
145
|
}
|
|
141
146
|
|
|
147
|
+
function sqlGenerateProductionPlanQuery(record) {
|
|
148
|
+
|
|
149
|
+
let SqlPorderNo = `(SELECT B.RECEIPTNO FROM PJOBORDERPROT B (NOLOCK) WHERE COMPANYID = ${record.companyId}
|
|
150
|
+
AND B.CPERIODID = ${record.cperiodId}
|
|
151
|
+
AND B.RECEIPTID = (SELECT TOP 1 B.PJOBORDERID FROM PPRODUCTPLANITEM B (NOLOCK) WHERE B.COMPANYID = ${record.companyId} AND B.PID = A.PID)) AS PORDERNO `;
|
|
152
|
+
let SqlSipBilgi = " '' AS SIPBILGI";
|
|
153
|
+
let SqlUreSipBilgi = `ISNULL((SELECT PORDERSNO FROM PORDERS (NOLOCK) WHERE COMPANYID = A.COMPANYID AND CPERIODID = ${record.cperiodId} AND PORDERSID = (SELECT PORDERSID FROM PJOBORDERPROT WHERE COMPANYID = A.COMPANYID AND CPERIODID = ${record.cperiodId}
|
|
154
|
+
AND RECEIPTID = A.PJOBORDERID)),'') AS URESIPBILGI `;
|
|
155
|
+
let SqlUretilen = " A.PQUANTITY";
|
|
156
|
+
let SqlPidWhere = ` AND A.PID IN (SELECT A.PID FROM PPRODUCTPLANWS A, PPRODUCTPLANITEM B, STOCK C (NOLOCK)
|
|
157
|
+
WHERE A.COMPANYID = B.COMPANYID
|
|
158
|
+
AND A.PID = B.PID
|
|
159
|
+
AND A.PIDSTATUS = 2
|
|
160
|
+
AND B.COMPANYID = C.COMPANYID
|
|
161
|
+
AND B.STOCKID = C.STOCKID)`;
|
|
162
|
+
let SqlPWorkStation = "";
|
|
163
|
+
let SqlIsYuklemeSirasi = "ROW_NUMBER() OVER(ORDER BY A.SORTID ASC) AS SEQUENCENO, ";
|
|
164
|
+
//Planlı Bakımlar Gösterilmesin
|
|
165
|
+
SqlPidWhere += " AND ISNULL(A.PTASKSID,0) != 99";
|
|
166
|
+
|
|
167
|
+
if (record.isShowingOnlyJobsToCome) {
|
|
168
|
+
SqlPidWhere += " AND A.STARTDATE >= GETDATE()";
|
|
169
|
+
}
|
|
170
|
+
if (record.isShowingOnlyPassedJobs) {
|
|
171
|
+
SqlPidWhere += " AND A.STARTDATE <= GETDATE()";
|
|
172
|
+
}
|
|
173
|
+
SqlPidWhere += " AND A.PIDSTATUS <> 3";
|
|
174
|
+
|
|
175
|
+
if (record.isShowingSameStationGroupJobs) {
|
|
176
|
+
SqlPWorkStation = `SELECT A.PWORKSTATIONID FROM PWORKSTATION A (NOLOCK)
|
|
177
|
+
WHERE A.COMPANYID = ${record.companyId}
|
|
178
|
+
AND A.GROUPCODE = (SELECT GROUPCODE FROM PWORKSTATION WHERE COMPANYID = ${record.companyId} AND PWORKSTATIONID = ${record.wsId} )`;
|
|
179
|
+
}
|
|
180
|
+
else if (record.isShowingSameWorkCenterJobs) {
|
|
181
|
+
SqlPWorkStation = `SELECT A.PWORKSTATIONID FROM PWORKSTATION A (NOLOCK)
|
|
182
|
+
WHERE A.COMPANYID = ${record.companyId}
|
|
183
|
+
AND A.PWORKCENTERID = (SELECT B.PWORKCENTERID FROM PWORKSTATION B WHERE B.COMPANYID = ${record.companyId} AND B.PWORKSTATIONID IN ( @SqlPWorkStation ))`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
let query = `DECLARE
|
|
188
|
+
@SqlPWorkStation VARCHAR(100)
|
|
189
|
+
SELECT @SqlPWorkStation = PLINETOP.PWORKSTATIONID
|
|
190
|
+
FROM PLINETOP WITH (NOLOCK)
|
|
191
|
+
LEFT OUTER JOIN PLINEDET WITH (NOLOCK) ON PLINETOP.COMPANYID = PLINEDET.COMPANYID AND PLINEDET.PLINEID = PLINETOP.PLINEID
|
|
192
|
+
WHERE PLINEDET.COMPANYID = ${record.companyId} AND PLINEDET.PWORKSTATIONID = ${record.wsId}
|
|
193
|
+
ORDER BY PLINETOP.PLINENO `;
|
|
194
|
+
|
|
195
|
+
query = query + ` SELECT ${SqlIsYuklemeSirasi} A.PWORKSTATIONID, PW.PWORKSTATIONNO, A.SORTID, A.PID, A.DESCRIPTION, A.WORKSTARTDATE, A.PSTOPCAUSEID, A.SETUPDURATION, A.EMPDURATION,
|
|
196
|
+
A.SPEED, A.PJOBORDERID, PJB.PROORDERSNO, PJB.TRANSCODE, A.PEQUIPMENTID, PE.PEQUIPMENTNO, A.DURATION, A.FPLANSTARTDATE, A.REQWORKEMPCOUNT, A.ITEMNO, A.PLANSHIFT, A.PLANWEEK, A.PLANDAY, A.PRIORITY,
|
|
197
|
+
A.STOCKID, A.CAPACITY, A.CYCLEUNIT, A.PPROTREEID, A.PPROTREEITEMID, A.PRODUCTNUMBER, A.PRODUCTNUMBER1, A.NOTES, DATEPART(WEEK, A.STARTDATE) HAFTA, PJB.PJOBORDERGROUPNO, PJB.PJOBORDERGROUPORDERNO, PJB.RECEIPTNO,
|
|
198
|
+
(SELECT TOP 1 B.STOCKNO FROM VE_PPRODUCTPLANITEM B (NOLOCK) WHERE A.COMPANYID = B.COMPANYID AND A.PID = B.PID) STOCKNO,
|
|
199
|
+
(SELECT TOP 1 B.STOCKNAME FROM VE_PPRODUCTPLANITEM B (NOLOCK) WHERE A.COMPANYID = B.COMPANYID AND A.PID = B.PID) STOCKNAME,
|
|
200
|
+
A.CYCLEPERIOD, A.CYCLEOFCOE, A.CYCLEOFPULSE, A.STARTDATE, A.GROUPCODE, A.SPECCODE1, A.SPECCODE2,
|
|
201
|
+
A.QUANTITY ORJQTY, A.QUANTITY2 ORJQTY2, A.QUANTITY3 ORJQTY3, A.PQUANTITY, A.PQUANTITY2, A.PQUANTITY3,
|
|
202
|
+
A.QUANTITY - ${SqlUretilen} QUANTITY, A.QUANTITY2 - ${SqlUretilen}2 QUANTITY2, A.QUANTITY3 - ${SqlUretilen}3 QUANTITY3,
|
|
203
|
+
${SqlPorderNo}, A.PPROCESSID, P.PPROCESSNO, P.PPROCESSNAME, ${SqlUreSipBilgi}, ${SqlSipBilgi} FROM PPRODUCTPLANWS A (NOLOCK)
|
|
204
|
+
LEFT JOIN PPROCESS P ON A.COMPANYID = P.COMPANYID AND A.PPROCESSID = P.PPROCESSID
|
|
205
|
+
LEFT JOIN PEQUIPMENT PE ON A.COMPANYID = PE.COMPANYID AND A.PEQUIPMENTID = PE.PEQUIPMENTID
|
|
206
|
+
LEFT JOIN PWORKSTATION PW ON A.COMPANYID = PW.COMPANYID AND A.PWORKSTATIONID = PW.PWORKSTATIONID
|
|
207
|
+
LEFT JOIN PJOBORDERPROT PJB ON A.COMPANYID = PJB.COMPANYID AND A.PJOBORDERID = PJB.RECEIPTID
|
|
208
|
+
WHERE A.COMPANYID = ${record.companyId}
|
|
209
|
+
${SqlPidWhere} AND ISNULL(A.PPARENTID, 0) > 0`;
|
|
210
|
+
|
|
211
|
+
if(SqlPWorkStation.length === 0) {
|
|
212
|
+
SqlPWorkStation = "@SqlPWorkStation";
|
|
213
|
+
}
|
|
214
|
+
if (!record.IsProducedQuantityConditionDisabled) {
|
|
215
|
+
query += ` AND A.QUANTITY - ${SqlUretilen} > 0 \n`;
|
|
216
|
+
}
|
|
217
|
+
if (record.isLineProductionEnabled && record.isFinishingPlanWhenCompleted) {
|
|
218
|
+
query += ` AND (A.QUANTITY - (SELECT ISNULL(SUM(QUANTITY),0) PQTY FROM PRECEIPTOT WITH (NOLOCK) WHERE COMPANYID = A.COMPANYID AND PID = A.PID AND PWORKSTATIONID = ${record.wsId} )) > 0 ` ;
|
|
219
|
+
}
|
|
220
|
+
query += ` AND A.PWORKSTATIONID IN (${SqlPWorkStation} )\n`;
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
if (record.isCheckingPreviousOperationWorkingControl && record.isCheckingPreviousOperationProductionControl) {
|
|
224
|
+
query += ` AND (CASE WHEN PJB.PPARENTID != 0 THEN (SELECT SUM(ISNULL(QUANTITY,0)) FROM PRECEIPTOT NOLOCK WHERE COMPANYID = PJB.COMPANYID AND PJOBORDERID = PJB.PPARENTID) ELSE 1 END > 0
|
|
225
|
+
OR EXISTS(SELECT 1 FROM PWSSTATUS S WITH(NOLOCK) INNER JOIN PPRODUCTPLANITEM P WITH(NOLOCK) ON P.COMPANYID = S.COMPANYID AND P.PID = S.PJOBID
|
|
226
|
+
WHERE S.COMPANYID = A.COMPANYID AND P.PJOBORDERID = PJB.PPARENTID)) \n`;
|
|
227
|
+
}
|
|
228
|
+
else if (record.isCheckingPreviousOperationProductionControl) {
|
|
229
|
+
query += ` AND (CASE WHEN PJB.PPARENTID != 0 THEN (SELECT SUM(ISNULL(QUANTITY,0)) FROM PRECEIPTOT NOLOCK WHERE COMPANYID = PJB.COMPANYID AND PJOBORDERID = PJB.PPARENTID) ELSE 1 END > 0 )`;
|
|
230
|
+
}
|
|
231
|
+
else if (record.isCheckingPreviousOperationWorkingControl) {
|
|
232
|
+
query += ` AND EXISTS (SELECT 1 FROM PWSSTATUS S WITH (NOLOCK) INNER JOIN PPRODUCTPLANITEM P WITH (NOLOCK) ON P.COMPANYID=S.COMPANYID AND P.PID = S.PJOBID
|
|
233
|
+
WHERE S.COMPANYID = A.COMPANYID AND P.PJOBORDERID = PJB.PPARENTID) ` ;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
query += " ORDER BY A.STARTDATE, ISNULL(A.SORTID,A.PID)";
|
|
237
|
+
|
|
238
|
+
return query;
|
|
239
|
+
}
|
|
240
|
+
|
|
142
241
|
function connection(config) {
|
|
143
242
|
RED.nodes.createNode(this, config);
|
|
144
243
|
const node = this;
|
|
@@ -164,6 +263,7 @@ module.exports = function (RED) {
|
|
|
164
263
|
server: config.server,
|
|
165
264
|
database: config.database,
|
|
166
265
|
companyId: config.companyId,
|
|
266
|
+
cperiodId: config.cperiodId,
|
|
167
267
|
userId: config.userId,
|
|
168
268
|
options: {
|
|
169
269
|
port: config.port ? safeParseInt(config.port, 1433) : undefined,
|
|
@@ -307,6 +407,15 @@ module.exports = function (RED) {
|
|
|
307
407
|
node.throwErrors = !(!config.throwErrors || config.throwErrors === '0');
|
|
308
408
|
|
|
309
409
|
node.modeOptType = config.modeOptType || '1';
|
|
410
|
+
node.isShowingOnlyJobsToCome = config.isShowingOnlyJobsToCome;
|
|
411
|
+
node.isShowingOnlyPassedJobs = config.isShowingOnlyPassedJobs;
|
|
412
|
+
node.isShowingSameStationGroupJobs = config.isShowingSameStationGroupJobs;
|
|
413
|
+
node.isShowingSameWorkCenterJobs = config.isShowingSameWorkCenterJobs;
|
|
414
|
+
node.isProducedQuantityConditionDisabled = config.isProducedQuantityConditionDisabled;
|
|
415
|
+
node.isLineProduction = config.isLineProduction;
|
|
416
|
+
node.isFinishingPlanWhenCompleted = config.isFinishingPlanWhenCompleted;
|
|
417
|
+
node.isCheckingPreviousOperationWorkingControl = config.isCheckingPreviousOperationWorkingControl;
|
|
418
|
+
node.isCheckingPreviousOperationProductionControl = config.isCheckingPreviousOperationProductionControl;
|
|
310
419
|
|
|
311
420
|
const setResult = function (msg, field, value, returnType = 0) {
|
|
312
421
|
const set = (obj, path, val) => {
|
|
@@ -406,72 +515,108 @@ module.exports = function (RED) {
|
|
|
406
515
|
|
|
407
516
|
let record = {};
|
|
408
517
|
record.companyId = trexmesCN.config.companyId;
|
|
518
|
+
record.cperiodId = trexmesCN.config.cperiodId;
|
|
409
519
|
record.userId = trexmesCN.config.userId;
|
|
410
520
|
record.cmdId = msg.operationMode;
|
|
411
521
|
record.command = resultCmd.command;
|
|
412
522
|
record.wsId = resultCmd.wsId;
|
|
413
523
|
|
|
414
|
-
|
|
415
|
-
|
|
524
|
+
if(resultCmd.isGetFunc) {
|
|
525
|
+
if(record.cmdId == "100")
|
|
526
|
+
{
|
|
527
|
+
record.isShowingOnlyJobsToCome = node.isShowingOnlyJobsToCome;
|
|
528
|
+
record.isShowingOnlyPassedJobs = node.isShowingOnlyPassedJobs;
|
|
529
|
+
record.isShowingSameStationGroupJobs = node.isShowingSameStationGroupJobs;
|
|
530
|
+
record.isShowingSameWorkCenterJobs = node.isShowingSameWorkCenterJobs;
|
|
531
|
+
record.isProducedQuantityConditionDisabled = node.isProducedQuantityConditionDisabled;
|
|
532
|
+
record.isLineProduction = node.isLineProduction;
|
|
533
|
+
record.isFinishingPlanWhenCompleted = node.isFinishingPlanWhenCompleted;
|
|
534
|
+
record.isCheckingPreviousOperationWorkingControl = node.isCheckingPreviousOperationWorkingControl;
|
|
535
|
+
record.isCheckingPreviousOperationProductionControl = node.isCheckingPreviousOperationProductionControl;
|
|
536
|
+
|
|
537
|
+
query = sqlGenerateProductionPlanQuery(record);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
query = sqlNgpCommandQueInsert(record);
|
|
542
|
+
}
|
|
543
|
+
node.log("query: " + query);
|
|
416
544
|
|
|
417
545
|
trexmesCN.execSql("", query, [], {}, function (err, data, info) {
|
|
418
546
|
if (err) {
|
|
419
547
|
node.processError(err, msg);
|
|
420
548
|
} else {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
549
|
+
if (!resultCmd.isGetFunc) {
|
|
550
|
+
node.status({
|
|
551
|
+
fill: 'yellow',
|
|
552
|
+
shape: 'dot',
|
|
553
|
+
text: 'Sended, aprove waiting.. '
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
node.status({
|
|
558
|
+
fill: 'green',
|
|
559
|
+
shape: 'dot',
|
|
560
|
+
text: 'done.'
|
|
561
|
+
});
|
|
562
|
+
}
|
|
426
563
|
setResult(msg, node.outField, data, node.returnType);
|
|
427
564
|
//node.send(msg);
|
|
428
565
|
//node.send(msg.payload.length);
|
|
429
566
|
let commandId = 0;
|
|
430
567
|
if(msg.payload.length>0) {
|
|
431
|
-
|
|
568
|
+
if(msg.payload[0].maxID) {
|
|
569
|
+
commandId = msg.payload[0].maxID;
|
|
570
|
+
}
|
|
432
571
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
node.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
572
|
+
|
|
573
|
+
if (!resultCmd.isGetFunc) {
|
|
574
|
+
//Process onay bekleniyor
|
|
575
|
+
setTimeout(function () {
|
|
576
|
+
query = "select Q.COMMANDID,Q.ISPROCESSED,P.ISSUCCESS,P.MESSAGE from NGPCOMMANDQUEUE Q join NGPCOMMANDRESPONSE P on Q.COMMANDID = P.COMMANDID where P.COMMANDID=" + commandId;
|
|
577
|
+
//node.log(query);
|
|
578
|
+
trexmesCN.execSql("", query, [], {}, function (err, data, info) {
|
|
579
|
+
if (err) {
|
|
580
|
+
node.processError(err, msg);
|
|
581
|
+
} else {
|
|
582
|
+
setResult(msg, node.outField, data, node.returnType);
|
|
583
|
+
let isProcessed = 0;
|
|
584
|
+
let isSuccess = 0;
|
|
585
|
+
let message = "";
|
|
586
|
+
if (msg.payload.length > 0) {
|
|
587
|
+
isProcessed = msg.payload[0].ISPROCESSED;
|
|
588
|
+
isSuccess = msg.payload[0].ISSUCCESS;
|
|
589
|
+
message = msg.payload[0].MESSAGE;
|
|
590
|
+
}
|
|
591
|
+
node.send(msg);
|
|
592
|
+
if (isProcessed == 1 && isSuccess == 1) {
|
|
593
|
+
node.status({
|
|
594
|
+
fill: 'green',
|
|
595
|
+
shape: 'dot',
|
|
596
|
+
text: 'done'
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
else if (isProcessed == 1 && isSuccess == 0) {
|
|
600
|
+
node.status({
|
|
601
|
+
fill: 'yellow',
|
|
602
|
+
shape: 'dot',
|
|
603
|
+
text: 'done with error: ' + message
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
node.status({
|
|
608
|
+
fill: 'blue',
|
|
609
|
+
shape: 'dot',
|
|
610
|
+
text: 'command not processed in 2 sec.'
|
|
611
|
+
});
|
|
612
|
+
}
|
|
471
613
|
}
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
}
|
|
614
|
+
});
|
|
615
|
+
}, 2000);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
node.send(msg);
|
|
619
|
+
}
|
|
475
620
|
}
|
|
476
621
|
});
|
|
477
622
|
} catch (err) {
|