@@ -30,34 +30,24 @@ def zipTimestampsIntoMillis(NodeChildren startDates, NodeChildren startTimes) {
3030// https://api.cloud.factbird.com/v1/docs/#query-lines or a looped process call
3131// against https://api.cloud.factbird.com/v1/docs/#query-linesPaginated (we have
3232// not yet stabilized this latter one as of this writing)
33- def lineIdMapping = [
34- ' 1710 ' : ' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
33+ lineIdMapping = [
34+ ' 1710PACKING ' : ' aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
3535]
3636
3737def Message processData (Message message ) {
38- def productionOrder = new XmlSlurper (). parseText(message. getProperty(" productionOrder" ))
39- def productionOrderSerialNumber = new XmlSlurper (). parseText(message. getProperty(" productionOrderSerialNumber" ))
38+ def processOrder = new XmlSlurper (). parseText(message. getProperty(" processOrder" ))
4039
4140 def messageLog = messageLogFactory. getMessageLog(message);
4241 if (messageLog != null ) {
43- messageLog. addAttachmentAsString(" productionOrder" , message. getProperty(" productionOrder" ), " application/json" );
44- messageLog. addAttachmentAsString(" productionOrderSerialNumber" , message. getProperty(" productionOrderSerialNumber" ), " application/json" );
42+ messageLog. addAttachmentAsString(" processOrder" , message. getProperty(" processOrder" ), " application/json" );
4543 }
4644
4745 def builder = new JsonBuilder ()
4846
4947 def output = []
5048
51- productionOrder.A_ProductionOrder_2Type . each { order ->
52- def serialNumber = productionOrderSerialNumber. children(). find { type ->
53- type.ManufacturingOrder . text() == order.ManufacturingOrder . text()
54- }
55-
56- if (! serialNumber) {
57- return
58- }
59-
60- def released = order. to_ProductionOrderStatus. children(). any { status ->
49+ processOrder.A_ProcessOrder_2Type . each { order ->
50+ def released = order. to_ProcessOrderStatus. children(). any { status ->
6151 status.StatusShortName . text() == " SETC"
6252 // status.StatusShortName.text() == "REL"
6353 }
@@ -66,11 +56,11 @@ def Message processData(Message message) {
6656 return
6757 }
6858
69- def operation = order.to_ProductionOrderOperation.A_ProductionOrderOperation_2Type
70-
71- // Production Orders may propagate from one work center to another - we
59+ def operation = order.to_ProcessOrderOperation.A_ProcessOrderOperation_2Type
60+
61+ // Process Orders may propagate from one work center to another - we
7262 // simply make the assumption it'll remain at the same location.
73- def initiallyAllocatedWorkCenter = order .WorkCenter [0 ]
63+ def initiallyAllocatedWorkCenter = operation .WorkCenter [0 ]
7464
7565 // With that same assumption, all operations are expected to take place
7666 // in order, so for actualStart and actualStop we find the extrema
@@ -86,7 +76,7 @@ def Message processData(Message message) {
8676 output << [
8777 externalLineId : order.Plant . text() + initiallyAllocatedWorkCenter. text(),
8878 batchNumber : order.ManufacturingOrder . text(),
89- itemNumber : serialNumber.Product . text(),
79+ itemNumber : order.Material . text(),
9080 amount : order.TotalQuantity . text(),
9181 plannedStart : formatTimePair(order.MfgOrderPlannedStartDate . text(), order.MfgOrderPlannedStartTime . text()),
9282 actualStart : actualStart,
@@ -97,7 +87,7 @@ def Message processData(Message message) {
9787 def resultXml = new StringWriter ()
9888 def xmlBuilder = new MarkupBuilder (resultXml)
9989
100- xmlBuilder. ' production -orders' {
90+ xmlBuilder. ' process -orders' {
10191 output. each { row ->
10292 ' order' (action : row. actualStop ? ' stop' : (row. actualStart ? ' start' : ' create' )) {
10393 ' line-id' (lineIdMapping[row. externalLineId])
@@ -112,6 +102,6 @@ def Message processData(Message message) {
112102 }
113103
114104 message. setBody(resultXml. toString())
115-
105+
116106 return message;
117107}
0 commit comments