Skip to main content

Work Orders

The work orders are another type of information the user can register into the platform. A work order links labours (previously created) with extra information that could be useful for the user.

The user must specify in the work order the labours which will be done, the date of the work order, notes or additional information, and especific recommendations about enviromental conditions to be taken into account at the time the work order is being performed.

Recommendations

The recommendations are specific items which are realted to the work order and indicates enviromental conditions. The available recomendations depends on the labours selected for the work order. See below.

APIs

GET

List of the work order for the specified yeargroup.

GET /api/work_orders

Must specify the yeargroup into the query string:

  • yeargroup : integer, yeargroup whose work orders will be listed

Response example:

{
"data": [
{
"recomendations": [
{
"type": {
"id": 1,
"name": "Temperature"
},
"value": "25 grades"
}
],
"uuid": "6ecb29ba-004b-1d1e-95ea-0dbd40e43f58",
"yeargroup": 2022,
"notes": "Notes or comments",
"labours": [
{
"yeargroup": 2022,
"idLabourType": 2,
"fieldName": "Field name",
"uuid": "7a5ee236-8527-11ec-834d-7b82f1b6b166",
"farmName": "Farm name"
},
{
"yeargroup": 2022,
"idLabourType": 1,
"fieldName": "Another field name",
"uuid": "900c80ac-8527-11ec-834d-0f130893a0a2",
"farmName": "Farm name"
}
],
"date": "2022-02-03T00:00:00+00:00",
"name": "Work order name"
},
{...}
]
}

GET

Solo se pueden utilizar las reocomendaciones que acepten los id de las labores. Recommendations list that can be used depending on the type of labour selected. Only the recommendations which accepts the labour id can be used to create the work order. For instance, the "Temperatura" recommendation could only be used if a labour of the type "1" is selected. See type_id on labours API.

GET /api/work_orders/recomendations/types

Response:

[
{
"labourTypeIds": [1],
"id": 1,
"name": "Temperatura"
},
{
"labourTypeIds": [2,3],
"id": 2,
"name": "Velocidad de avance"
},
{
"labourTypeIds": [1],
"id": 3,
"name": "Dirección del viento"
},
{
"labourTypeIds": [1],
"id": 4,
"name": "Velocidad del viento"
},
{
"labourTypeIds": [1,2,3],
"id": 5,
"name": "Humedad"
},
{
"labourTypeIds": [3],
"id": 6,
"name": "Profundidad"
}
]

POST

Creates a new work order.

Content-Type: application/json
POST /api/work_orders

The body must recieve the following parameters:

  • uuid: String, UUID of the work order Required
  • labours: Array, Labours UUIDs Array Required
  • recomendations: Array, Array of Objects that contains the following
    • type_id: String, Recommendation ID
    • value: String, Recommendation value
  • date: date, Work order date, in the format of YYYY-MM-DD Required
  • notes: String, Notes or comments
  • name: String, Work order name
  • yeargroup: date Required

Body example:

{
"uuid": "89ccE57E-BDb3-13De-964d-7FA4FcB2db2A",
"labours": [
"900c80ac-8527-11ec-834d-0f130893a0a2"
],
"recomendations": [
{
"type_id": "1",
"value": "25 grades"
}
],
"date": "2022-02-03",
"notes": "Notes or comments",
"name": "Work order name",
"yeargroup": "2022"
}

If success returns an object with de uuid.

Response example:

{
"data": {
"uuid": "89cce57e-bdb3-13de-964d-7fa4fcb2db2a"
}
}

PUT

Modifies a work order.

Content-Type: application/json
PUT /api/work_orders/${uuid}
  • uuid: String, Work order of the UUID

The body and response are the same as the POST method.

Whether some optional parameter is not sent it will be replaced for a null value

DELETE

Deletes a worke order.

DELETE /api/work_orders/${uuid}
  • uuid: String, Work order UUID

GET (Descargar)

Downloads a work order in pdf or excel format.

GET /api/work_orders/${uuid}/download
  • uuid: String, Work order UUID

The type of file is sent into the query string, into the parameter type, and the value could be pdf or excel.

Complete URL example:

  • /api/work_orders/${uuid}/download?type=pdf