Some fixes.

This commit is contained in:
Mark van der Wal 2020-04-10 13:12:15 +02:00
parent 08d9f94f2b
commit c0fe0c0a14
2 changed files with 7 additions and 6 deletions

View File

@ -75,7 +75,7 @@ namespace FarmmapsNbs
}
var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDriveRoot.Code,
$"VRA NBS cropfield {input.OutputFileName}", DateTime.Now.Year, input.GeometryJson.ToString(Formatting.None));
$"VRA NBS cropfield {input.OutputFileName}", plantingDate.Year, input.GeometryJson.ToString(Formatting.None));
var dataPath = Path.Combine("Data", input.IsariaZipFile);
var isariaShapeItem =
@ -97,7 +97,7 @@ namespace FarmmapsNbs
_logger.LogInformation($"Calculating targetN with targetYield: {input.TargetYield}");
var targetNItem = await _nitrogenService.CreateTargetNItem(cropfieldItem);
var targetNData = await _nitrogenService.CalculateTargetN(cropfieldItem, targetNItem, plantingDate,
measurementDate, input.PotatoPurposeType, "irmi", input.TargetYield);
measurementDate, input.PotatoPurposeType, input.TargetYield);
if (targetNData == null)
{

View File

@ -39,19 +39,20 @@ namespace FarmmapsNbs
/// Calculates TargetN, makes the assumption the cropfield and user.input(targetn) item have the same parent
/// </summary>
/// <param name="cropfieldItem">The cropfield to base the calculations on</param>
/// <param name="targetYield">The target yield input for the TargetN calculation</param>
/// <param name="targetNItem">The targetN item to save calculations in</param>
/// <param name="plantingDate">The date the crop is planted</param>
/// <param name="measurementDate">The date the measurements are taken</param>
/// <param name="purposeType">The crop purpose</param>
/// <param name="targetYield">The target yield input for the TargetN calculation</param>
/// <returns>The TargetN</returns>
public async Task<TargetNData> CalculateTargetN(Item cropfieldItem, Item targetNItem, DateTime plantingDate,
DateTime measurementDate, string inputType, string purposeType, int targetYield)
DateTime measurementDate, string purposeType, int targetYield)
{
var nbsTargetNRequest = new TaskRequest {TaskType = VRANBS_TASK};
nbsTargetNRequest.attributes["operation"] = "targetn";
nbsTargetNRequest.attributes["inputCode"] = targetNItem.Code;
nbsTargetNRequest.attributes["plantingDate"] = plantingDate.ToString();
nbsTargetNRequest.attributes["measurementDate"] = measurementDate.ToString();
nbsTargetNRequest.attributes["inputType"] = inputType;
nbsTargetNRequest.attributes["purposeType"] = purposeType.ToLower();
nbsTargetNRequest.attributes["targetYield"] = targetYield.ToString();
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, nbsTargetNRequest);