Linear Flow (PlacementService) #224
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m55s

This commit is contained in:
harid 2026-06-18 18:32:06 +07:00
parent 35179d8cfc
commit e926866918
5 changed files with 319 additions and 244 deletions

View file

@ -760,16 +760,6 @@ namespace BMA.EHR.Placement.Service.Controllers
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
var firstRef = req.refIds.FirstOrDefault();
var commandNoText = firstRef != null ? $"{firstRef.commandNo}/{firstRef.commandYear.ToThaiYear()}" : null;
foreach (var profile in data)
{
profile.Status = "DONE";
profile.commandNo = commandNoText;
}
await _context.SaveChangesAsync();
var resultData = (from p in data
join r in req.refIds
on p.Id.ToString() equals r.refId
@ -811,28 +801,42 @@ namespace BMA.EHR.Placement.Service.Controllers
remark = r.remark,
}).ToList();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
using (var client = new HttpClient())
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
// {
// data = resultData,
// });
// //// var _result = await _res.Content.ReadAsStringAsync();
// //// if (_res.IsSuccessStatusCode)
// //// {
// //// foreach (var profile in data)
// //// {
// //// profile.Status = "DONE";
// //// profile.commandNo = resultData.Count > 0 ? $"{resultData[0].commandNo}/{resultData[0].commandYear.ToThaiYear()}" : null;
// //// }
// //// await _context.SaveChangesAsync();
// //// }
// }
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
var firstRef = req.refIds.FirstOrDefault();
var commandNoText = firstRef != null ? $"{firstRef.commandNo}/{firstRef.commandYear.ToThaiYear()}" : null;
data.ForEach(profile =>
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
{
data = resultData,
});
//// var _result = await _res.Content.ReadAsStringAsync();
//// if (_res.IsSuccessStatusCode)
//// {
//// foreach (var profile in data)
//// {
//// profile.Status = "DONE";
//// profile.commandNo = resultData.Count > 0 ? $"{resultData[0].commandNo}/{resultData[0].commandYear.ToThaiYear()}" : null;
//// }
//// await _context.SaveChangesAsync();
//// }
}
return Success();
profile.Status = "DONE";
profile.commandNo = commandNoText;
});
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
}
}