README.md aktualisiert
This commit is contained in:
421
README.md
421
README.md
@@ -1,2 +1,421 @@
|
||||
# CogiscanRest
|
||||
# Cogiscan - Product Release Integration
|
||||
|
||||
**Technische Dokumentation / Technical Documentation**
|
||||
|
||||
**Schnittstelle / Interface:** iTAC MES → Cogiscan Track & Control
|
||||
**Custom Function:** `Cogiscan.cogiscanRelease`
|
||||
**Technologie / Technology:** Rhino JavaScript / Java 8
|
||||
**Stand:** 21.10.2026
|
||||
**Referenz:**
|
||||
|
||||
---
|
||||
|
||||
# Teil 1 - Deutsch
|
||||
|
||||
## 1. Funktionsbeschreibung
|
||||
|
||||
Die Custom Function `Cogiscan.cogiscanRelease` ermöglicht die automatische Anlage und Freigabe von Produkten und Produktgruppen aus dem iTAC MES in der Cogiscan Track & Control Plattform.
|
||||
|
||||
Die Funktion übernimmt die übergebenen Fertigungsauftrags-, Sachnummern-, Mengen-, Panel- und Produktinformationen und führt die erforderlichen REST-API-Aufrufe aus.
|
||||
|
||||
Die Verarbeitung umfasst:
|
||||
|
||||
1. Prüfung, ob die Sachnummer in Cogiscan existiert.
|
||||
2. Automatische Anlage der Sachnummer, falls nicht vorhanden.
|
||||
3. Prüfung, ob der Fertigungsauftrag existiert.
|
||||
4. Automatische Anlage des Fertigungsauftrags einschließlich der konfigurierten Mengeninformation, falls nicht vorhanden.
|
||||
5. Freigabe eines Einzelprodukts oder einer Produktgruppe.
|
||||
6. Protokollierung und Rückgabe des Verarbeitungsergebnisses an iTAC MES.
|
||||
|
||||
## 2. Eingangsparameter
|
||||
|
||||
**IMSAPI-Methode:** `Cogiscan.cogiscanRelease`
|
||||
|
||||
| Index | Parameter | Beschreibung |
|
||||
|---|---|---|
|
||||
| 0 | WorkOrder | Fertigungsauftragsnummer aus iTAC |
|
||||
| 1 | PartNumber | Sachnummer des Produkts |
|
||||
| 2 | Quantity | Auftragsmenge |
|
||||
| 3 | PanelId | Eindeutige Panel-ID |
|
||||
| 4...n | Products | Produkt- bzw. Seriennummern |
|
||||
|
||||
### Beispiel
|
||||
|
||||
```javascript
|
||||
inArgs = [
|
||||
"1003481",
|
||||
"945206-101",
|
||||
"3",
|
||||
"test01",
|
||||
"test01",
|
||||
"test02",
|
||||
"test03"
|
||||
];
|
||||
```
|
||||
|
||||
Die Anzahl der Produkte ist dynamisch. Für jedes Produkt wird automatisch eine fortlaufende `imageId` vergeben, beginnend bei `"1"`.
|
||||
|
||||
Die dargestellte Mengenposition entspricht der besprochenen erweiterten Parameterbelegung.
|
||||
|
||||
## 3. Default-Konfiguration
|
||||
|
||||
Die Funktion besitzt folgende Standardkonfiguration:
|
||||
|
||||
```javascript
|
||||
var defaults = {
|
||||
baseUrl: "http://192.168.21.100/ttc",
|
||||
username: "",
|
||||
password: "",
|
||||
productTypeKey: 3,
|
||||
partNumberKey: null,
|
||||
workOrderKey: null,
|
||||
createWorkOrderIfMissing: true,
|
||||
allowRerelease: true,
|
||||
maxReleaseQty: 0,
|
||||
panelId: null,
|
||||
products: []
|
||||
};
|
||||
```
|
||||
|
||||
### 3.1 Beschreibung der Konfigurationsparameter
|
||||
|
||||
| Parameter | Standardwert | Bedeutung |
|
||||
|---|---|---|
|
||||
| `baseUrl` | `http://192.168.21.100/ttc` | Basisadresse des Cogiscan Track & Control Servers. Alle REST-Endpunkte werden relativ zu dieser Adresse aufgerufen. |
|
||||
| `username` | `""` | Benutzername für die optionale Cogiscan-Authentifizierung. |
|
||||
| `password` | `""` | Passwort für die optionale Cogiscan-Authentifizierung. |
|
||||
| `productTypeKey` | `3` | Interner Cogiscan-Schlüssel des Produkttyps (Artikelgruppe in iTAC), der bei der Neuanlage einer Artikelnummer verwendet wird. |
|
||||
| `partNumberKey` | `null` | Interner Cogiscan-Sachnummernschlüssel. Bei `null` wird die Sachnummer zunächst gesucht und gegebenenfalls angelegt. |
|
||||
| `workOrderKey` | `null` | Interner Cogiscan-Fertigungsauftragsschlüssel. Bei `null` wird der Auftrag zunächst gesucht und gegebenenfalls angelegt. |
|
||||
| `createWorkOrderIfMissing` | `true` | Aktiviert die automatische Neuanlage fehlender Fertigungsaufträge. |
|
||||
| `allowRerelease` | `true` | Erlaubt die erneute Freigabe bereits freigegebener Produkte, soweit die Cogiscan-API dies zulässt. |
|
||||
| `maxReleaseQty` | `0` | Konfigurierter Wert der maximalen Freigabemenge des Fertigungsauftrags. Die Bedeutung von `0` ist abhängig von der Cogiscan-Implementierung. |
|
||||
| `panelId` | `null` | Optionale Kennung einer Produktgruppe bzw. eines Panels. Wird normalerweise aus den Eingangsparametern übernommen. |
|
||||
| `products` | `[]` | Initial leere Produktliste, die dynamisch aus den übergebenen Produkt-IDs aufgebaut wird. |
|
||||
|
||||
### 3.2 Besonderheiten
|
||||
|
||||
**Authentifizierung**
|
||||
|
||||
Wenn `username` und `password` leer sind und kein alternativer Access-Token übergeben wurde, wird die Authentifizierung übersprungen.
|
||||
|
||||
Es erfolgt dann keine Token-Anfrage und es wird kein `Authorization`-Header gesendet.
|
||||
|
||||
Voraussetzung ist, dass der Cogiscan-Server API-Aufrufe ohne Authentifizierung erlaubt.
|
||||
|
||||
**Produkttyp**
|
||||
|
||||
`productTypeKey = 3` bestimmt den bei einer Neuanlage verwendeten Produkttyp. Der Wert muss zu einem gültigen Item Type in der jeweiligen Cogiscan-Installation gehören.
|
||||
|
||||
**Automatische Auftragsanlage**
|
||||
|
||||
Bei `createWorkOrderIfMissing = true` wird ein nicht vorhandener Auftrag automatisch erzeugt.
|
||||
|
||||
Ist die Option auf `false` gesetzt, wird die Verarbeitung bei einem fehlenden Auftrag mit einem Fehler beendet.
|
||||
|
||||
**Erneute Produktfreigabe**
|
||||
|
||||
`allowRerelease = true` erlaubt eine erneute Produktfreigabe gemäß den Regeln der Cogiscan-Plattform.
|
||||
|
||||
Bei `false` wird die erneute Freigabe bereits registrierter Produkte nicht ausdrücklich zugelassen.
|
||||
|
||||
**Freigabemenge**
|
||||
|
||||
`maxReleaseQty = 0` ist der konfigurierte Standardwert.
|
||||
|
||||
Ob `0` als unbegrenzt, als null erlaubte Freigaben oder als spezieller Defaultwert interpretiert wird, muss anhand der Cogiscan-Serverkonfiguration bestätigt werden. `maxReleaseQty` sollte nicht ohne Prüfung mit der Auftrags-Sollmenge gleichgesetzt werden.
|
||||
|
||||
## 4. Verarbeitungsablauf
|
||||
|
||||
### Schritt 1 - Sachnummer suchen
|
||||
|
||||
`GET /api/v1/part-numbers`
|
||||
|
||||
Der Parameter `partNumberName` wird mit UTF-8/Base64 und anschließend URL-Encoding kodiert.
|
||||
|
||||
Existiert die Sachnummer, wird der vorhandene Schlüssel übernommen.
|
||||
|
||||
### Schritt 2 - Sachnummer anlegen
|
||||
|
||||
`POST /api/v1/product-part-numbers`
|
||||
|
||||
Ist die Sachnummer nicht vorhanden, wird sie automatisch erzeugt.
|
||||
|
||||
Für die Neuanlage wird standardmäßig `productTypeKey = 3` verwendet.
|
||||
|
||||
### Schritt 3 - Fertigungsauftrag prüfen
|
||||
|
||||
`GET /api/v1/work-orders`
|
||||
|
||||
Die übergebene Fertigungsauftragsnummer wird vor der Suche kodiert.
|
||||
|
||||
Ein vorhandener Fertigungsauftrag wird wiederverwendet.
|
||||
|
||||
### Schritt 4 - Fertigungsauftrag anlegen
|
||||
|
||||
`POST /api/v1/work-orders`
|
||||
|
||||
Ist der Auftrag nicht vorhanden und `createWorkOrderIfMissing = true`, wird er neu angelegt.
|
||||
|
||||
Der Request enthält mindestens die Auftrags-ID und den ermittelten Sachnummern-Key.
|
||||
|
||||
Das Feld `maxReleaseQty` wird entsprechend der implementierten Mengenlogik ergänzt.
|
||||
|
||||
### Schritt 5 - Produkte freigeben
|
||||
|
||||
**Einzelprodukt:** `POST /api/v1/products`
|
||||
|
||||
**Produktgruppe:** `POST /api/v1/product-groups`
|
||||
|
||||
Die Freigabe verwendet den WorkOrder-Key, PartNumber-Key, `allowRerelease`, die Produkt-IDs und bei Produktgruppen optional die Panel-ID und Image-IDs.
|
||||
|
||||
## 5. Logging
|
||||
|
||||
Die Verarbeitung wird über den iTAC-Logger protokolliert:
|
||||
|
||||
```javascript
|
||||
logHandler.logMessage("[Cogiscan] " + message);
|
||||
```
|
||||
|
||||
Protokolliert werden die Parameterverarbeitung, die API-Aufrufe, die HTTP-Statuscodes, die ermittelten Schlüssel, die Erstellung neuer Stammdaten, die Produktfreigabe sowie auftretende Fehler.
|
||||
|
||||
Passwörter und Tokens werden nicht protokolliert.
|
||||
|
||||
## 6. Rückgabewerte
|
||||
|
||||
Die Funktion gibt ein `Result_customFunctionCommon` an die iTAC IMSAPI zurück.
|
||||
|
||||
**Erfolgreiche Verarbeitung**
|
||||
|
||||
```text
|
||||
return_value = 0
|
||||
errorString = "Done"
|
||||
outArgs[0] = JSON-Ergebnis
|
||||
```
|
||||
|
||||
Das Ergebnis enthält unter anderem die verwendeten Sachnummern- und Auftragsschlüssel, deren Erstellungsstatus sowie das Freigabeergebnis.
|
||||
|
||||
**Fehlerhafte Verarbeitung**
|
||||
|
||||
```text
|
||||
return_value = -99
|
||||
errorString = "FEHLER beim verarbeiten: ..."
|
||||
outArgs = []
|
||||
```
|
||||
|
||||
Die Fehlerbeschreibung enthält zusätzliche Informationen zur Fehlerursache.
|
||||
|
||||
## 7. Technische Voraussetzungen
|
||||
|
||||
Die Funktion läuft innerhalb der iTAC MES Custom Function Engine auf Basis von Rhino JavaScript und Java 8.
|
||||
|
||||
Die HTTP-Kommunikation erfolgt über Java-Netzwerkklassen, die Base64-Kodierung über `java.util.Base64`.
|
||||
|
||||
Es werden keine externen JavaScript-Bibliotheken benötigt.
|
||||
|
||||
---
|
||||
|
||||
# Part 2 - English
|
||||
|
||||
## 1. Function Description
|
||||
|
||||
The custom function `Cogiscan.cogiscanRelease` enables automatic creation and release of products and product groups from iTAC MES into the Cogiscan Track & Control platform.
|
||||
|
||||
The function processes work order, part number, quantity, panel and product information and performs the required REST API operations.
|
||||
|
||||
The processing sequence includes:
|
||||
|
||||
1. Checking whether the part number exists in Cogiscan.
|
||||
2. Automatically creating the part number if it does not exist.
|
||||
3. Checking whether the work order exists.
|
||||
4. Automatically creating the work order with the configured quantity information if required.
|
||||
5. Releasing a single product or product group.
|
||||
6. Logging the processing steps and returning the result to iTAC MES.
|
||||
|
||||
## 2. Input Parameters
|
||||
|
||||
**IMSAPI Method:** `Cogiscan.cogiscanRelease`
|
||||
|
||||
| Index | Parameter | Description |
|
||||
|---|---|---|
|
||||
| 0 | WorkOrder | Production work order number from iTAC |
|
||||
| 1 | PartNumber | Product part number |
|
||||
| 2 | Quantity | Work order quantity |
|
||||
| 3 | PanelId | Unique panel identifier |
|
||||
| 4...n | Products | Product or serial numbers |
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
inArgs = [
|
||||
"1003481",
|
||||
"945206-101",
|
||||
"3",
|
||||
"test01",
|
||||
"test01",
|
||||
"test02",
|
||||
"test03"
|
||||
];
|
||||
```
|
||||
|
||||
The number of products is dynamic. Each product is automatically assigned a sequential `imageId`, starting with `"1"`.
|
||||
|
||||
The quantity position reflects the discussed extended input parameter mapping.
|
||||
|
||||
## 3. Default Configuration
|
||||
|
||||
The function uses the following default configuration:
|
||||
|
||||
```javascript
|
||||
var defaults = {
|
||||
baseUrl: "http://192.168.21.100/ttc",
|
||||
username: "",
|
||||
password: "",
|
||||
productTypeKey: 3,
|
||||
partNumberKey: null,
|
||||
workOrderKey: null,
|
||||
createWorkOrderIfMissing: true,
|
||||
allowRerelease: true,
|
||||
maxReleaseQty: 0,
|
||||
panelId: null,
|
||||
products: []
|
||||
};
|
||||
```
|
||||
|
||||
### 3.1 Configuration Parameters
|
||||
|
||||
| Parameter | Default | Description |
|
||||
|---|---|---|
|
||||
| `baseUrl` | `http://192.168.21.100/ttc` | Base address of the Cogiscan Track & Control server. All REST endpoints are called relative to this URL. |
|
||||
| `username` | `""` | Username used for optional Cogiscan authentication. |
|
||||
| `password` | `""` | Password used for optional Cogiscan authentication. |
|
||||
| `productTypeKey` | `3` | Internal Cogiscan item type key used when creating a product part number. The productTypeKey is in iTAC the Partgroup
|
||||
| `partNumberKey` | `null` | Internal Cogiscan part number key. If `null`, the part number is searched and created if necessary. |
|
||||
| `workOrderKey` | `null` | Internal Cogiscan work order key. If `null`, the work order is searched and created if necessary. |
|
||||
| `createWorkOrderIfMissing` | `true` | Enables automatic creation of missing work orders. |
|
||||
| `allowRerelease` | `true` | Allows previously released products to be released again, subject to Cogiscan API rules. |
|
||||
| `maxReleaseQty` | `0` | Configured maximum release quantity value for the work order. The interpretation of `0` depends on the Cogiscan implementation. |
|
||||
| `panelId` | `null` | Optional panel or product group identifier, normally populated from the input parameters. |
|
||||
| `products` | `[]` | Initially empty product list, dynamically populated with the supplied product identifiers. |
|
||||
|
||||
### 3.2 Configuration Behavior
|
||||
|
||||
**Authentication**
|
||||
|
||||
If both `username` and `password` are empty and no alternative access token is provided, authentication is skipped.
|
||||
|
||||
No authentication token request is performed and no `Authorization` header is added.
|
||||
|
||||
This requires the Cogiscan server to accept unauthenticated API requests.
|
||||
|
||||
**Product Type**
|
||||
|
||||
`productTypeKey = 3` identifies the default item type used when creating new product part numbers.
|
||||
|
||||
The configured key must correspond to a valid Cogiscan item type.
|
||||
|
||||
**Automatic Work Order Creation**
|
||||
|
||||
When `createWorkOrderIfMissing = true`, missing work orders are created automatically.
|
||||
|
||||
When set to `false`, processing stops with an error if the work order does not exist.
|
||||
|
||||
**Product Rerelease**
|
||||
|
||||
`allowRerelease = true` permits previously registered products to be released again according to the Cogiscan platform rules.
|
||||
|
||||
Setting this parameter to `false` does not explicitly authorize rerelease.
|
||||
|
||||
**Release Quantity**
|
||||
|
||||
`maxReleaseQty = 0` is the configured default.
|
||||
|
||||
Whether `0` represents unlimited release quantity, zero permitted releases, or a special default value must be confirmed against the Cogiscan server implementation. The field must not automatically be assumed to represent the planned work order quantity.
|
||||
|
||||
## 4. Processing Sequence
|
||||
|
||||
### Step 1 - Validate Part Number
|
||||
|
||||
`GET /api/v1/part-numbers`
|
||||
|
||||
The `partNumberName` parameter is encoded using UTF-8/Base64 followed by URL encoding.
|
||||
|
||||
If the part number exists, the existing key is reused.
|
||||
|
||||
### Step 2 - Create Part Number
|
||||
|
||||
`POST /api/v1/product-part-numbers`
|
||||
|
||||
If the part number does not exist, it is created automatically.
|
||||
|
||||
The configured default `productTypeKey = 3` is used.
|
||||
|
||||
### Step 3 - Validate Work Order
|
||||
|
||||
`GET /api/v1/work-orders`
|
||||
|
||||
The supplied work order identifier is encoded before being used as a search parameter.
|
||||
|
||||
Existing work orders are reused.
|
||||
|
||||
### Step 4 - Create Work Order
|
||||
|
||||
`POST /api/v1/work-orders`
|
||||
|
||||
If the work order is missing and `createWorkOrderIfMissing = true`, it is created automatically.
|
||||
|
||||
The request includes at least the work order identifier and the resolved part number key.
|
||||
|
||||
The `maxReleaseQty` field is included according to the implemented quantity handling logic.
|
||||
|
||||
### Step 5 - Release Products
|
||||
|
||||
**Single product:** `POST /api/v1/products`
|
||||
|
||||
**Product group:** `POST /api/v1/product-groups`
|
||||
|
||||
The release request uses the work order key, part number key, `allowRerelease`, product identifiers and, for product groups, the optional panel and image identifiers.
|
||||
|
||||
## 5. Logging
|
||||
|
||||
Processing information is written using the iTAC logging interface:
|
||||
|
||||
```javascript
|
||||
logHandler.logMessage("[Cogiscan] " + message);
|
||||
```
|
||||
|
||||
The logs include parameter processing, API operations, HTTP status codes, resolved keys, master data creation, product release results and error conditions.
|
||||
|
||||
Passwords and access tokens are not logged.
|
||||
|
||||
## 6. Return Values
|
||||
|
||||
The function returns a `Result_customFunctionCommon` object to the iTAC IMSAPI.
|
||||
|
||||
**Successful execution**
|
||||
|
||||
```text
|
||||
return_value = 0
|
||||
errorString = "Done"
|
||||
outArgs[0] = JSON result
|
||||
```
|
||||
|
||||
The result includes the resolved part number and work order keys, creation statuses and product release information.
|
||||
|
||||
**Failed execution**
|
||||
|
||||
```text
|
||||
return_value = -99
|
||||
errorString = "FEHLER beim verarbeiten: ..."
|
||||
outArgs = []
|
||||
```
|
||||
|
||||
The error description provides additional details about the failure.
|
||||
|
||||
## 7. Technical Requirements
|
||||
|
||||
The interface executes within the iTAC MES Custom Function Engine using Rhino JavaScript and Java 8.
|
||||
|
||||
HTTP communication uses the Java networking APIs. Base64 encoding is implemented using `java.util.Base64`.
|
||||
|
||||
No external JavaScript libraries are required.
|
||||
|
||||
Reference in New Issue
Block a user