farmmapsKPI receives minimum necessary input and writes relevant KPI output
This commit is contained in:
@@ -350,9 +350,9 @@ namespace FarmmapsApi.Services
|
||||
return bofekItem;
|
||||
}
|
||||
|
||||
public async Task<List<Item>> GetKpiItemsForCropField(Item cropfieldItem) // dit is dus nieuw om de KPI task te runnen
|
||||
public async Task<List<Item>> GetKpiItemsForCropField(Item cropfieldItem)
|
||||
{
|
||||
var kpiRequest = new TaskRequest { TaskType = KPI_TASK };
|
||||
TaskRequest kpiRequest = new TaskRequest { TaskType = KPI_TASK };
|
||||
kpiRequest.attributes["processAggregateKpi"] = "false";
|
||||
int year = cropfieldItem.DataDate.Value.Year;
|
||||
kpiRequest.attributes["year"] = year.ToString();
|
||||
@@ -372,15 +372,24 @@ namespace FarmmapsApi.Services
|
||||
_logger.LogError($"Something went wrong with task execution: {itemTask.Message}");
|
||||
return null;
|
||||
}
|
||||
await Task.Delay(60000); //wacht hier een minuut tot de KPIs berekend zijn
|
||||
await Task.Delay(6000); // wait 6000 secs for task to be completed
|
||||
|
||||
//PO20230627 Je zou hier ook om de 10 sec eens kunnen kijken of we al zo ver zijn? Iets in trant van while KPI_ITEM is null?
|
||||
//hier nog definieren waar in de hierarchie een KPI item is?
|
||||
var allChildren = await _farmmapsApiService.GetItemChildrenAsync(cropfieldItem.Code);
|
||||
var kpiItems = await _farmmapsApiService.GetItemChildrenAsync(cropfieldItem.Code, KPI_ITEM);
|
||||
//After the task is completed we have 1 kpiContainerItem with a code and with no data
|
||||
//Because the data are in the children of this kpiContainerItem. The container will have a list of children each with an "id" aand data,
|
||||
//The ids' are "a1", "b1", "b2", "c1","d1","d3","d5"
|
||||
//with following meanings:
|
||||
//| A1 | Opbrengst | Yield |
|
||||
//| B1 | Stikstofoverschot | Nitrogen surplus |
|
||||
//| B2 | Fosfaatoverschot | Phosphate surplus |
|
||||
//| C1 | Effectieve Organischestof aanvoer| Effective Organic Matter supply |
|
||||
//| D1 | Gebruik bestrijdingsmiddelen | Use of pesticides|
|
||||
//| D3 | Gewasdiversiteit(randdichtheid) | Crop diversity(edge density) |
|
||||
//| D5 | Percentage rustgewassen | Percentage of rest crops |
|
||||
List <Item> kpiContainerItem = await _farmmapsApiService.GetItemChildrenAsync(cropfieldItem.Code, KPICONTAINER_ITEM);
|
||||
string kpiContainerItemCode = kpiContainerItem[0].Code;
|
||||
List<Item> kpiItems = await _farmmapsApiService.GetItemChildrenAsync(kpiContainerItemCode);
|
||||
|
||||
return kpiItems;
|
||||
|
||||
}
|
||||
|
||||
public async Task<Item> RunAhnTask(Item cropfieldItem) {
|
||||
|
Reference in New Issue
Block a user