forked from FarmMaps/FarmMapsApiClient
also write totalNapplied to csv file with KPI outputs per cropfield
This commit is contained in:
@@ -44,6 +44,25 @@ namespace FarmmapsApi.Services
|
||||
var currentYear = new DateTime(year, 1, 1);
|
||||
JObject jdata = JObject.Parse(data);
|
||||
string name = string.Format($"CrpRec Operation, {jdata.GetValue("name")}");
|
||||
int code022;
|
||||
string type022;
|
||||
double quantity;
|
||||
double applied_kgNha;
|
||||
double ncontent = 0.0; // for now just any value
|
||||
|
||||
//Is it a fertilizer application?
|
||||
|
||||
//If the operation contains an element "n" then nothing, use that value (kg N/ha administred)
|
||||
//Else: look up the N content for the code022, calculate "n" based on fertilizer amount (data) & content (cl022) and add applied_kgNha to the jdata
|
||||
if (jdata.ContainsKey("n") == false)
|
||||
{
|
||||
quantity = jdata.GetValue("quantity").ToObject<double>();
|
||||
code022 = jdata.GetValue("product").ToObject<int>();
|
||||
//TODO: Now here look up this code022 in the cl022 and get the ncontent from that list.
|
||||
//And check the unit in which the ncontent is expressed, e.g. % or kg/ton and check if it is not null
|
||||
applied_kgNha = quantity * ncontent;
|
||||
jdata.Add("n", applied_kgNha.ToString()); //all Data elements in Farmmaps code ar strings
|
||||
};
|
||||
|
||||
ItemRequest operationItemRequest = new ItemRequest()
|
||||
{
|
||||
|
Reference in New Issue
Block a user