api import เครื่องราช,ใบกำกับ

This commit is contained in:
Kittapath 2023-08-24 19:23:33 +07:00
parent 9c610407f4
commit 69f23fd0cb
21 changed files with 47554 additions and 55 deletions

View file

@ -46,6 +46,60 @@ namespace BMA.EHR.Retirement.Service.Controllers
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
private List<string> GetOcNameFullPath(Guid id, bool showRoot = false)
{
try
{
var ocList = new List<string>();
var oc = (from o in _context.Organizations.Include(x => x.Parent).Include(x => x.OrganizationOrganization).Where(x => x.OrganizationOrganization != null).AsQueryable()
join oc_name in _context.OrganizationOrganizations.AsQueryable() on o.OrganizationOrganization.Id equals oc_name.Id
where o.Parent != null
select new
{
Id = o.Id,
Name = oc_name.Name,
o.IsActive,
o.Parent
}).FirstOrDefault(x => x.Id == id && x.IsActive);
if (oc == null)
return ocList;
ocList.Add(oc.Name);
if (oc.Parent?.Id != null)
{
ocList.AddRange(GetOcNameFullPath(oc.Parent.Id, showRoot));
}
return ocList;
}
catch
{
throw;
}
}
private string FindOCFullPath(Guid id, bool showRoot = false)
{
try
{
var ocList = GetOcNameFullPath(id, showRoot);
var ret = String.Empty;
foreach (var oc in ocList)
{
ret = oc + "/" + ret;
}
ret = ret.Substring(0, ret.Length - 1);
return ret;
}
catch
{
throw;
}
}
/// <summary>
/// list รายการลาออกของ User
@ -446,7 +500,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
Id = p.Id,
ReasonWork = p.ReasonWork == null ? p.ReasonWork : Newtonsoft.Json.JsonConvert.DeserializeObject(p.ReasonWork),
ReasonWorkOther = p.ReasonWorkOther,
TimeThink = p.TimeThink == null ? p.TimeThink : Newtonsoft.Json.JsonConvert.DeserializeObject(p.TimeThink),
TimeThink = p.TimeThink,
ExitFactor = p.ExitFactor == null ? p.ExitFactor : Newtonsoft.Json.JsonConvert.DeserializeObject(p.ExitFactor),
ExitFactorOther = p.ExitFactorOther,
Adjust = p.Adjust == null ? p.Adjust : Newtonsoft.Json.JsonConvert.DeserializeObject(p.Adjust),
@ -484,9 +538,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
Id = p.Id,
Position = p.RetirementResign.Profile.Position == null ? null : p.RetirementResign.Profile.Position.Name,
PositionLevel = p.RetirementResign.Profile.PositionLevel == null ? null : p.RetirementResign.Profile.PositionLevel.Name,
Org = p.RetirementResign.Profile.OcId == null ? null : p.RetirementResign.Profile.OcId,
Fullname = $"{p.RetirementResign.Profile.FirstName} {p.RetirementResign.Profile.LastName}",
Prefix = p.RetirementResign.Profile.Prefix == null ? null : p.RetirementResign.Profile.Prefix.Name,
Avatar = p.RetirementResign.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.RetirementResign.Profile.Avatar.Id,
ReasonWork = p.ReasonWork == null ? p.ReasonWork : Newtonsoft.Json.JsonConvert.DeserializeObject(p.ReasonWork),
ReasonWorkOther = p.ReasonWorkOther,
TimeThink = p.TimeThink == null ? p.TimeThink : Newtonsoft.Json.JsonConvert.DeserializeObject(p.TimeThink),
TimeThink = p.TimeThink,
ExitFactor = p.ExitFactor == null ? p.ExitFactor : Newtonsoft.Json.JsonConvert.DeserializeObject(p.ExitFactor),
ExitFactorOther = p.ExitFactorOther,
Adjust = p.Adjust == null ? p.Adjust : Newtonsoft.Json.JsonConvert.DeserializeObject(p.Adjust),
@ -506,6 +566,34 @@ namespace BMA.EHR.Retirement.Service.Controllers
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.RetirementQuestionNotFound, 404);
var _data = new
{
data.Id,
data.Position,
data.PositionLevel,
Org = data.Org == null ? null : FindOCFullPath(data.Org.Value, true),
data.Fullname,
data.Prefix,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
data.ReasonWork,
data.ReasonWorkOther,
data.TimeThink,
data.ExitFactor,
data.ExitFactorOther,
data.Adjust,
data.AdjustOther,
data.RealReason,
data.NotExitFactor,
data.Havejob,
data.HavejobReason,
data.SuggestFriends,
data.SuggestFriendsReason,
data.FutureWork,
data.FutureWorkReason,
data.Suggestion,
data.LastUpdatedAt,
data.CreatedAt,
};
return Success(data);
}
@ -519,7 +607,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("questionnaire")]
public async Task<ActionResult<ResponseObject>> PostQuestion([FromForm] RetirementQuestionRequest req)
public async Task<ActionResult<ResponseObject>> PostQuestion([FromBody] RetirementQuestionRequest req)
{
var retirementResign = await _context.RetirementResigns.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.RetirementResignId);
@ -531,7 +619,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
RetirementResign = retirementResign,
ReasonWork = Newtonsoft.Json.JsonConvert.SerializeObject(req.ReasonWork),
ReasonWorkOther = req.ReasonWorkOther,
TimeThink = Newtonsoft.Json.JsonConvert.SerializeObject(req.TimeThink),
TimeThink = req.TimeThink,
ExitFactor = Newtonsoft.Json.JsonConvert.SerializeObject(req.ExitFactor),
ExitFactorOther = req.ExitFactorOther,
Adjust = Newtonsoft.Json.JsonConvert.SerializeObject(req.Adjust),
@ -592,7 +680,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("questionnaire/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> PutQuestion([FromForm] RetirementQuestionRequest req, Guid id)
public async Task<ActionResult<ResponseObject>> PutQuestion([FromBody] RetirementQuestionRequest req, Guid id)
{
var uppdated = await _context.RetirementQuestions.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == id);
@ -607,7 +695,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
// uppdated.RetirementResign = retirementResign;
uppdated.ReasonWork = Newtonsoft.Json.JsonConvert.SerializeObject(req.ReasonWork);
uppdated.ReasonWorkOther = req.ReasonWorkOther;
uppdated.TimeThink = Newtonsoft.Json.JsonConvert.SerializeObject(req.TimeThink);
uppdated.TimeThink = req.TimeThink;
uppdated.ExitFactor = Newtonsoft.Json.JsonConvert.SerializeObject(req.ExitFactor);
uppdated.ExitFactorOther = req.ExitFactorOther;
uppdated.Adjust = Newtonsoft.Json.JsonConvert.SerializeObject(req.Adjust);