{
  "$schema": "https://datapackage.org/profiles/2.0/tableschema.json",
  "title": "日ごとのルート",
  "description": "ある日、ある地区の作業の計画です。車両ごとのルート（回る依頼の順番と、着く時刻と出る時刻）と、入らなかった依頼を持ちます。ルート最適化（VRP）のソフトウェアの結果（routes と unassigned）をそのまま残せます。計画を実際に走った記録は、Smart Data Models の FleetVehicleOperation で表せます。planStatus、statusLabel のどれか 1 つは必須です。",
  "x-type": "RoutePlan",
  "x-typeIri": "https://datamodels.jp/ns/fieldservice/RoutePlan",
  "x-version": "1.0.0",
  "x-schema": "https://datamodels.jp/schema/fieldservice/RoutePlan/v1.0.0.json",
  "x-context": "https://datamodels.jp/context/fieldservice/v1.jsonld",
  "x-translations": {
    "en": {
      "title": "Route plan",
      "description": "The plan of the work of one day in one area: a route per vehicle (the requests in order, with arrival and departure times) and the requests that did not fit. It keeps the result of route optimisation (VRP) software (routes and unassigned) as it is. What was actually driven can be recorded with Smart Data Models FleetVehicleOperation. At least one of planStatus, statusLabel is needed."
    }
  },
  "fields": [
    {
      "name": "id",
      "title": "エンティティの ID",
      "description": "エンティティの ID（URI。例：urn:ngsi-ld:RoutePlan:001）",
      "type": "string",
      "constraints": {
        "required": true,
        "unique": true
      },
      "x-translations": {
        "en": {
          "title": "Entity id",
          "description": "Entity id: a URI, for example urn:ngsi-ld:RoutePlan:001"
        }
      }
    },
    {
      "name": "provider",
      "title": "作業を引き受ける組織",
      "description": "作業を引き受ける組織（自治体、委託先など）",
      "type": "string",
      "format": "uri",
      "x-iri": "https://schema.org/provider",
      "x-translations": {
        "en": {
          "title": "The organisation that does the work",
          "description": "The organisation that does the work (a municipality, a contractor)"
        }
      }
    },
    {
      "name": "localGovernmentCode",
      "title": "計画する自治体の全国地方公共団体コード",
      "description": "計画する自治体の全国地方公共団体コード（6 桁）",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/common/localGovernmentCode",
      "constraints": {
        "pattern": "\\d{6}"
      },
      "x-translations": {
        "en": {
          "title": "Local government code",
          "description": "Local government code (6 digits) of the municipality the plan is for"
        }
      }
    },
    {
      "name": "area",
      "title": "計画の単位となる地区",
      "description": "計画の単位となる地区。提供者が決めた名前です。",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/fieldservice/area",
      "constraints": {
        "minLength": 1
      },
      "x-translations": {
        "en": {
          "description": "The planning area, as the provider names it"
        }
      }
    },
    {
      "name": "planDate",
      "title": "計画した日",
      "description": "計画した日（作業する日）",
      "type": "date",
      "x-iri": "https://datamodels.jp/ns/fieldservice/planDate",
      "constraints": {
        "required": true
      },
      "x-translations": {
        "en": {
          "title": "The day the plan is for",
          "description": "The day the plan is for"
        }
      }
    },
    {
      "name": "planStatus",
      "title": "状態",
      "description": "状態：draft（案）、confirmed（確定）、in-progress（実行中）、completed（完了）、cancelled（取消）。合う値がなければ省き、statusLabel を書きます。",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/fieldservice/planStatus",
      "constraints": {
        "enum": [
          "draft",
          "confirmed",
          "in-progress",
          "completed",
          "cancelled"
        ]
      },
      "x-translations": {
        "en": {
          "title": "State",
          "description": "State: draft, confirmed, in-progress, completed, cancelled. When no value fits, leave it out and write statusLabel"
        }
      }
    },
    {
      "name": "statusLabel",
      "title": "元のシステムの状態名をそのまま",
      "description": "元のシステムの状態名をそのまま。状態の値が合わないときは必須です。",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/task/statusLabel",
      "constraints": {
        "minLength": 1
      },
      "x-translations": {
        "en": {
          "description": "The source system's own status name, unchanged. Required when the status is left out"
        }
      }
    },
    {
      "name": "planner",
      "title": "計画に使ったソフトウェアとその版",
      "description": "計画に使ったソフトウェアとその版（例：VROOM 1.14）",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/fieldservice/planner",
      "constraints": {
        "minLength": 1
      },
      "x-translations": {
        "en": {
          "description": "The software that made the plan, with its version (for example VROOM 1.14)"
        }
      }
    },
    {
      "name": "computedAt",
      "title": "計画を計算した日時",
      "description": "計画を計算した日時",
      "type": "datetime",
      "x-iri": "https://datamodels.jp/ns/fieldservice/computedAt",
      "x-translations": {
        "en": {
          "title": "When the plan was computed",
          "description": "When the plan was computed"
        }
      }
    },
    {
      "name": "vehicles",
      "title": "計画に使った車両",
      "description": "計画に使った車両（ServiceVehicle）。key-values の形では、1 台でも配列です。複数の値は ; で区切ります。",
      "type": "list",
      "itemType": "string",
      "delimiter": ";",
      "x-iri": "https://datamodels.jp/ns/fieldservice/vehicles",
      "constraints": {
        "minLength": 1
      },
      "x-translations": {
        "en": {
          "title": "The vehicles of the plan",
          "description": "The vehicles of the plan: ServiceVehicles. Always an array in the key-values form, even with one. Several values separated by ;."
        }
      }
    },
    {
      "name": "serviceRequests",
      "title": "計画した依頼",
      "description": "計画した依頼（ServiceRequest）。入らなかったものも含みます。key-values の形では、1 件でも配列です。複数の値は ; で区切ります。",
      "type": "list",
      "itemType": "string",
      "delimiter": ";",
      "x-iri": "https://datamodels.jp/ns/fieldservice/serviceRequests",
      "constraints": {
        "minLength": 1
      },
      "x-translations": {
        "en": {
          "description": "The requests planned, those left unassigned included: ServiceRequests. Always an array in the key-values form, even with one. Several values separated by ;."
        }
      }
    },
    {
      "name": "routes",
      "title": "車両ごとのルート",
      "description": "車両ごとのルート。車両、班、出発と帰着の時刻、距離（メートル）、時間、積んだ量と、止まる所（start、job、break、end）の順番です。job には依頼（request）、位置、着く時刻と出る時刻を書きます。位置は依頼の location と同じです。",
      "type": "array",
      "x-iri": "https://datamodels.jp/ns/fieldservice/routes",
      "constraints": {
        "required": true,
        "jsonSchema": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "vehicle",
              "stops"
            ],
            "properties": {
              "vehicle": {
                "type": "string",
                "format": "uri"
              },
              "crew": {
                "type": "string",
                "format": "uri"
              },
              "start": {
                "type": "string",
                "format": "date-time"
              },
              "end": {
                "type": "string",
                "format": "date-time"
              },
              "distance": {
                "type": "number",
                "minimum": 0
              },
              "duration": {
                "type": "string",
                "pattern": "^P(?!$)(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?$"
              },
              "load": {
                "type": "array",
                "items": {
                  "type": "number",
                  "minimum": 0
                },
                "minItems": 1
              },
              "stops": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "kind"
                  ],
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "start",
                        "job",
                        "break",
                        "end"
                      ]
                    },
                    "request": {
                      "type": "string",
                      "format": "uri"
                    },
                    "position": {
                      "type": "array",
                      "minItems": 2,
                      "maxItems": 2,
                      "items": {
                        "type": "number"
                      }
                    },
                    "arrival": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "departure": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "load": {
                      "type": "array",
                      "items": {
                        "type": "number",
                        "minimum": 0
                      },
                      "minItems": 1
                    }
                  }
                }
              }
            }
          },
          "description": "One route per vehicle: the vehicle, crew, start and end time, distance (metres), duration, load, and its stops in order (start, job, break, end); a job stop names its request, with its position and arrival and departure times. The positions repeat the requests' locations"
        }
      },
      "x-translations": {
        "en": {
          "title": "One route per vehicle",
          "description": "One route per vehicle: the vehicle, crew, start and end time, distance (metres), duration, load, and its stops in order (start, job, break, end); a job stop names its request, with its position and arrival and departure times. The positions repeat the requests' locations"
        }
      }
    },
    {
      "name": "unassigned",
      "title": "入らなかった依頼",
      "description": "入らなかった依頼（ServiceRequest の ID）。全部入ったときは空の配列です。複数の値は ; で区切ります。",
      "type": "list",
      "itemType": "string",
      "delimiter": ";",
      "x-iri": "https://datamodels.jp/ns/fieldservice/unassigned",
      "x-translations": {
        "en": {
          "title": "The requests that did not fit",
          "description": "The requests that did not fit (ServiceRequest ids); an empty array when all did. Several values separated by ;."
        }
      }
    },
    {
      "name": "totalDistance",
      "title": "すべてのルートの距離の合計",
      "description": "すべてのルートの距離の合計（メートル）",
      "type": "number",
      "x-iri": "https://datamodels.jp/ns/fieldservice/totalDistance",
      "constraints": {
        "minimum": 0
      },
      "x-translations": {
        "en": {
          "description": "The distance of all routes together, in metres"
        }
      }
    },
    {
      "name": "totalDuration",
      "title": "すべてのルートの時間の合計",
      "description": "すべてのルートの時間の合計（ISO 8601 の期間）",
      "type": "string",
      "x-pattern": "^P(?!$)(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?$",
      "x-iri": "https://datamodels.jp/ns/fieldservice/totalDuration",
      "x-translations": {
        "en": {
          "description": "The time of all routes together, as an ISO 8601 duration"
        }
      }
    },
    {
      "name": "source",
      "title": "データの出典",
      "description": "データの出典（URL など）",
      "type": "string",
      "x-iri": "https://smart-data-models.github.io/data-models/terms.jsonld#/definitions/source",
      "constraints": {
        "minLength": 1
      },
      "x-translations": {
        "en": {
          "title": "Where the data comes from",
          "description": "Where the data comes from (a URL, for example)"
        }
      }
    }
  ],
  "primaryKey": [
    "id"
  ],
  "missingValues": [
    ""
  ]
}
