start & end date & geometry added to operations item and to cropfield characteristics item
This commit is contained in:
parent
fedd363075
commit
1cc36422a4
@ -37,8 +37,11 @@ namespace FarmmapsApi.Services
|
|||||||
return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest);
|
return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Item> CreateOperationItemAsync(string cropRecordingItemCode, string data = "{}")
|
public async Task<Item> CreateOperationItemAsync(string cropRecordingItemCode, int year,
|
||||||
|
string fieldGeomJson, string data = "{}")
|
||||||
{
|
{
|
||||||
|
// not sure if here we also need to specify DataDate, DataEndDate & Geometry. Do it just in case
|
||||||
|
var currentYear = new DateTime(year, 1, 1);
|
||||||
JObject jdata = JObject.Parse(data);
|
JObject jdata = JObject.Parse(data);
|
||||||
string name = string.Format($"CrpRec Operation, {jdata.GetValue("name")}");
|
string name = string.Format($"CrpRec Operation, {jdata.GetValue("name")}");
|
||||||
|
|
||||||
@ -47,21 +50,29 @@ namespace FarmmapsApi.Services
|
|||||||
ParentCode = cropRecordingItemCode,
|
ParentCode = cropRecordingItemCode,
|
||||||
ItemType = CROPOP_ITEMTYPE,
|
ItemType = CROPOP_ITEMTYPE,
|
||||||
Name = name,
|
Name = name,
|
||||||
|
DataDate = currentYear,
|
||||||
|
DataEndDate = currentYear.AddYears(1).AddDays(-1),
|
||||||
Data = jdata,
|
Data = jdata,
|
||||||
|
Geometry = JObject.Parse(fieldGeomJson)
|
||||||
};
|
};
|
||||||
|
|
||||||
return await _farmmapsApiService.CreateItemAsync(operationItemRequest);
|
return await _farmmapsApiService.CreateItemAsync(operationItemRequest);
|
||||||
}
|
}
|
||||||
public async Task<Item> CreateCropfieldCharacteristicItemAsync(string cropfieldItemCode, string data = "{}")
|
public async Task<Item> CreateCropfieldCharacteristicItemAsync(string cropfieldItemCode, int year,
|
||||||
|
string fieldGeomJson, string data = "{}")
|
||||||
{
|
{
|
||||||
|
// not sure if here we also need to specify DataDate, DataEndDate & Geometry. Do it just in case
|
||||||
string name = "Cropfield characteristic";
|
string name = "Cropfield characteristic";
|
||||||
|
var currentYear = new DateTime(year, 1, 1);
|
||||||
ItemRequest cropfieldCharactericsticItemRequest = new ItemRequest()
|
ItemRequest cropfieldCharactericsticItemRequest = new ItemRequest()
|
||||||
{
|
{
|
||||||
ParentCode = cropfieldItemCode,
|
ParentCode = cropfieldItemCode,
|
||||||
ItemType = CROPCHAR_ITEMTYPE,
|
ItemType = CROPCHAR_ITEMTYPE,
|
||||||
Name = name,
|
Name = name,
|
||||||
|
DataDate = currentYear,
|
||||||
|
DataEndDate = currentYear.AddYears(1).AddDays(-1),
|
||||||
Data = JObject.Parse(data),
|
Data = JObject.Parse(data),
|
||||||
|
Geometry = JObject.Parse(fieldGeomJson)
|
||||||
};
|
};
|
||||||
|
|
||||||
return await _farmmapsApiService.CreateItemAsync(cropfieldCharactericsticItemRequest);
|
return await _farmmapsApiService.CreateItemAsync(cropfieldCharactericsticItemRequest);
|
||||||
|
@ -155,7 +155,7 @@ namespace FarmmapsKPI
|
|||||||
if (useCreatedOperations == false || string.IsNullOrEmpty(_settings.OperationItemCode))
|
if (useCreatedOperations == false || string.IsNullOrEmpty(_settings.OperationItemCode))
|
||||||
{
|
{
|
||||||
_logger.LogInformation("CreateOperationItemAsync ...");
|
_logger.LogInformation("CreateOperationItemAsync ...");
|
||||||
crpOperationItem = await _generalService.CreateOperationItemAsync(crprecItem.Code,input.DataOperation.ToString(Formatting.None));
|
crpOperationItem = await _generalService.CreateOperationItemAsync(crprecItem.Code, cropYear, input.GeometryJson.ToString(Formatting.None), input.DataOperation.ToString(Formatting.None));
|
||||||
_settings.OperationItemCode = crpOperationItem.Code;
|
_settings.OperationItemCode = crpOperationItem.Code;
|
||||||
SaveSettings(settingsfile);
|
SaveSettings(settingsfile);
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ namespace FarmmapsKPI
|
|||||||
if (useCreatedCropfieldCharacteristic == false)
|
if (useCreatedCropfieldCharacteristic == false)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("CreateCropfieldCharacteristicItemAsync ...");
|
_logger.LogInformation("CreateCropfieldCharacteristicItemAsync ...");
|
||||||
cropfieldCharacteristicItem = await _generalService.CreateCropfieldCharacteristicItemAsync(cropfieldItem.Code, input.DataCropfieldCharacteristic.ToString(Formatting.None));
|
cropfieldCharacteristicItem = await _generalService.CreateCropfieldCharacteristicItemAsync(cropfieldItem.Code, cropYear, input.GeometryJson.ToString(Formatting.None), input.DataCropfieldCharacteristic.ToString(Formatting.None));
|
||||||
_settings.CropfieldCharacteristicItemCode = cropfieldCharacteristicItem.Code;
|
_settings.CropfieldCharacteristicItemCode = cropfieldCharacteristicItem.Code;
|
||||||
SaveSettings(settingsfile);
|
SaveSettings(settingsfile);
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ namespace FarmmapsKPI
|
|||||||
|
|
||||||
//Now get the KPIs for this cropfield, mounted with operations & cropyield
|
//Now get the KPIs for this cropfield, mounted with operations & cropyield
|
||||||
// Get KPI data for saving it in a file, here the generalsedrvice is called to get the KPI data
|
// Get KPI data for saving it in a file, here the generalsedrvice is called to get the KPI data
|
||||||
_logger.LogInformation($"GetKpiItemsForCropField({cropfieldItem.Code})");
|
_logger.LogInformation($"GetKpiItemsForCropField('{cropfieldItem.Code}')");
|
||||||
var KPIItem = await _generalService.GetKpiItemsForCropField(cropfieldItem);
|
var KPIItem = await _generalService.GetKpiItemsForCropField(cropfieldItem);
|
||||||
|
|
||||||
//Download KPI's into a json output file for this specific cropfield (with unique cropfieldItem.Code)
|
//Download KPI's into a json output file for this specific cropfield (with unique cropfieldItem.Code)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"UseCreatedCropfield": true,
|
"UseCreatedCropfield": false,
|
||||||
"CropfieldItemCode": "",
|
"CropfieldItemCode": "",
|
||||||
"dataCropfield": {
|
"dataCropfield": {
|
||||||
//"area": 4.22,
|
//"area": 4.22,
|
||||||
@ -14,10 +14,10 @@
|
|||||||
"productionPurposeCode": "003"
|
"productionPurposeCode": "003"
|
||||||
//"productionPurposeName": "consumption"
|
//"productionPurposeName": "consumption"
|
||||||
},
|
},
|
||||||
"UseCreatedCropRecording": true,
|
"UseCreatedCropRecording": false,
|
||||||
"CropRecordingItemCode": "",
|
"CropRecordingItemCode": "",
|
||||||
"dataCropRecording": {}, //not yet used
|
"dataCropRecording": {}, //not yet used
|
||||||
"UseCreatedOperation": true,
|
"UseCreatedOperation": false,
|
||||||
"OperationItemCode": "",
|
"OperationItemCode": "",
|
||||||
"dataOperation": {
|
"dataOperation": {
|
||||||
"n": "92",
|
"n": "92",
|
||||||
|
Loading…
Reference in New Issue
Block a user