node-red-trexmes-commands 1.2.3 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-trexmes-commands",
3
- "version": "1.2.3",
3
+ "version": "1.4.0",
4
4
  "description": "A node-red node to execute commands for Trex Mes Systems",
5
5
  "main": "trexcommands.js",
6
6
  "dependencies": {
package/trexcommands.html CHANGED
@@ -416,7 +416,9 @@
416
416
  { value: '14|Start Test Mode', label: 'Start Test Mode', hasValue: false },
417
417
  { value: '15|Finish Test Mode', label: 'Finish Test Mode', hasValue: false },
418
418
  { value: '16|Create Deffect', label: 'Create Deffect', hasValue: false },
419
- { value: '100|Get Open Jobs', label: 'Get Open Jobs', hasValue: false }
419
+ { value: '100|Get Open Jobs', label: 'Get Open Jobs', hasValue: false },
420
+ { value: '101|Get StopCause List', label: 'Get StopCause List', hasValue: false },
421
+ { value: '102|Get PWorkstation List', label: 'Get PWorkstation List', hasValue: false }
420
422
  ],
421
423
  typeField: $('#node-input-modeOptType'),
422
424
  default: 'Load Job Plan'
@@ -467,6 +469,12 @@
467
469
  $("#node-input-label-getOpenJobs-filter").show();
468
470
  $("#node-input-getOpenJobs-filter").show();
469
471
  }
472
+ else if(operationMode.startsWith('101|')) { //Get StopCause List
473
+ data = '{ "WorkstationId": 10 }';
474
+ }
475
+ else if(operationMode.startsWith('102|')) { //Get PWorkstation List
476
+ data = '{}';
477
+ }
470
478
  node.editor.setValue(JSON.stringify(JSON.parse(data),null, 2));
471
479
 
472
480
  });
package/trexcommands.js CHANGED
@@ -34,8 +34,12 @@ module.exports = function (RED) {
34
34
  function checkPayload(payload) {
35
35
  let result = { "isOk" : false, "isGetFunc": false };
36
36
  if(!payload.WorkstationId){
37
- return result;
37
+ if(payload.operationMode != "102" )
38
+ {
39
+ return result;
40
+ }
38
41
  }
42
+
39
43
  result.wsId = payload.WorkstationId;
40
44
 
41
45
  if(payload.operationMode == "1" ) { // Load Job Plan
@@ -116,7 +120,17 @@ module.exports = function (RED) {
116
120
  result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId });
117
121
  result.isOk = true;
118
122
  result.isGetFunc = true;
119
- }
123
+ }
124
+ else if(payload.operationMode == "101" ) { // Get StopCause List
125
+ result.command = JSON.stringify({ "WorkstationId" : payload.WorkstationId });
126
+ result.isOk = true;
127
+ result.isGetFunc = true;
128
+ }
129
+ else if(payload.operationMode == "102" ) { // Get PWorkstation List
130
+ result.command = JSON.stringify({ });
131
+ result.isOk = true;
132
+ result.isGetFunc = true;
133
+ }
120
134
  return result;
121
135
  }
122
136
 
@@ -238,6 +252,49 @@ module.exports = function (RED) {
238
252
  return query;
239
253
  }
240
254
 
255
+ function sqlGenerateStopCauseListQuery(record) {
256
+ let query = `DECLARE
257
+ @ACILIS_DURUS NVARCHAR(100),
258
+ @ARKAEKIPMAN_DURUS NVARCHAR(100),
259
+ @ONEKIPMAN_DURUS NVARCHAR(100),
260
+ @PLANYOK_DURUS NVARCHAR(100),
261
+ @NOCONNECTION_DURUS NVARCHAR(100),
262
+ @VARDIYAYOK_DURUS NVARCHAR(100),
263
+ @SHIFTEDSHIFT_DURUS NVARCHAR(100)
264
+
265
+ select @ACILIS_DURUS = PARAMVALUE from UPSYSPARAM where PARAMNAME='PSTOPCAUSEID_ACILISDURUS' and COMPANYID = ${record.companyId}
266
+ select @ARKAEKIPMAN_DURUS = PARAMVALUE from UPSYSPARAM where PARAMNAME='PSTOPCAUSEID_ARKAEKIPMANDURUSU' and COMPANYID = ${record.companyId}
267
+ select @ONEKIPMAN_DURUS = PARAMVALUE from UPSYSPARAM where PARAMNAME='PSTOPCAUSEID_ONEKIPMANDURUSU' and COMPANYID = ${record.companyId}
268
+ select @PLANYOK_DURUS = PARAMVALUE from UPSYSPARAM where PARAMNAME='PSTOPCAUSEID_PLANYOK' and COMPANYID = ${record.companyId}
269
+ select @NOCONNECTION_DURUS = PARAMVALUE from UPSYSPARAM where PARAMNAME='PSTOPCAUSEID_NOCONNECTION' and COMPANYID = ${record.companyId}
270
+ select @VARDIYAYOK_DURUS = PARAMVALUE from UPSYSPARAM where PARAMNAME='PSTOPCAUSEID_VARDIYAYOKDURUSU' and COMPANYID = ${record.companyId}
271
+ select @SHIFTEDSHIFT_DURUS = PARAMVALUE from UPSYSPARAM where PARAMNAME='PSTOPCAUSEID_SHIFTEDSHIFT' and COMPANYID = ${record.companyId}
272
+
273
+ SELECT A.*
274
+ ,B.PSTOPCAUSENO
275
+ ,B.PSTOPCAUSENAME
276
+ ,B.GROUPCODE
277
+ FROM PSTOPCAUSEWS A
278
+ INNER JOIN PSTOPCAUSE B ON A.COMPANYID = B.COMPANYID
279
+ AND A.PSTOPCAUSEID = B.PSTOPCAUSEID
280
+ WHERE A.COMPANYID = ${record.companyId}
281
+ AND B.STATUS = 2
282
+ AND A.PWORKSTATIONID = ${record.wsId}
283
+ AND A.PSTOPCAUSEID NOT IN (@ACILIS_DURUS,@ARKAEKIPMAN_DURUS, @ONEKIPMAN_DURUS,@PLANYOK_DURUS,
284
+ @NOCONNECTION_DURUS,@VARDIYAYOK_DURUS,@SHIFTEDSHIFT_DURUS)`;
285
+
286
+ return query;
287
+
288
+ }
289
+
290
+ function sqlGeneratePWorkstationListQuery(record) {
291
+ let query = `select PWS.PWORKSTATIONID, PWS.PWORKSTATIONNO,
292
+ PWS.PWORKSTATIONNAME from PLINEDET PL inner join PWORKSTATION PWS
293
+ on PL.COMPANYID = PWS.COMPANYID and PL.PWORKSTATIONID = PWS.PWORKSTATIONID
294
+ where PWS.COMPANYID= ${record.companyId} and PWS.STATUS = 2`;
295
+ return query;
296
+ }
297
+
241
298
  function connection(config) {
242
299
  RED.nodes.createNode(this, config);
243
300
  const node = this;
@@ -536,11 +593,19 @@ module.exports = function (RED) {
536
593
 
537
594
  query = sqlGenerateProductionPlanQuery(record);
538
595
  }
596
+ else if(record.cmdId == "101")
597
+ {
598
+ query = sqlGenerateStopCauseListQuery(record);
599
+ }
600
+ else if(record.cmdId == "102")
601
+ {
602
+ query = sqlGeneratePWorkstationListQuery(record);
603
+ }
539
604
  }
540
605
  else {
541
606
  query = sqlNgpCommandQueInsert(record);
542
607
  }
543
- node.log("query: " + query);
608
+ //node.log("query: " + query);
544
609
 
545
610
  trexmesCN.execSql("", query, [], {}, function (err, data, info) {
546
611
  if (err) {