Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2023-09-08 08:45:38 +07:00
commit 0ca54170f4
26 changed files with 16644 additions and 146 deletions

View file

@ -4129,6 +4129,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
.Where(p =>
allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value) &&
p.IsActive == true &&
@ -4180,6 +4181,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
where allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value)
&& p.IsActive == true
&& p.IsLeave == false
@ -4229,6 +4231,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
where p.IsActive == true
&& allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value)
&& p.IsLeave == false
@ -4277,6 +4280,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
where p.IsActive == true
&& allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value)
&& p.IsLeave == false
@ -4326,6 +4330,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
where p.IsActive == true
&& allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value)
&& p.IsLeave == false
@ -4358,6 +4363,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
where p.IsActive == true
&& allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value)
&& p.IsLeave == false
@ -4408,6 +4414,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
where p.IsActive == true
&& allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value)
&& p.IsLeave == false
@ -4457,6 +4464,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
where p.IsActive == true
&& allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value)
&& p.IsLeave == false
@ -4506,6 +4514,7 @@ namespace BMA.EHR.Application.Repositories
.Include(p => p.Insignias)
.ThenInclude(i => i.Insignia)
.Include(p => p.Salaries)
.Include(p => p.PositionLevel)
where p.IsActive == true
&& allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value)
&& p.IsLeave == false
@ -4612,7 +4621,7 @@ namespace BMA.EHR.Application.Repositories
var type3_level11 = await GetInsigniaCandidate_Type3_Level11(periodId, ocId);
var type4_level10 = await GetInsigniaCandidate_Type4_Level10(periodId, ocId);
var type4_level11 = await GetInsigniaCandidate_Type4_Level11(periodId, ocId);
// var type_coin = await GetInsigniaCandidate(periodId, ocId);
var type_coin = await GetInsigniaCandidate(periodId, ocId);
// union result
foreach (var r in type4_level11)
@ -4699,10 +4708,10 @@ namespace BMA.EHR.Application.Repositories
if (old == null)
result_candidate.Add(r);
}
// foreach (var r in type_coin)
// {
// result_candidate.Add(r);
// }
foreach (var r in type_coin)
{
result_candidate.Add(r);
}
return result_candidate.OrderBy(x => x.Seq).ThenBy(x => x.Gender).ThenBy(x => x.ProfileId).ToList();
}
@ -4980,7 +4989,7 @@ namespace BMA.EHR.Application.Repositories
CitizenId = h.Profile.CitizenId,
ProfileId = h.Profile.Id,
ProfileType = h.Profile.ProfileType,
FullName = $"{h.Profile.FirstName} {h.Profile.LastName}",
FullName = $"{h.Profile.Prefix?.Name}{h.Profile.FirstName} {h.Profile.LastName}",
Position = h.Profile.Position.Name,
PosNo = h.Profile.PosNo.Id,
Rank = $"{h.Profile.PositionType.Name}/{h.Profile.PositionLevel.Name}",

View file

@ -54,6 +54,70 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
}
}
public async Task PushNotificationAsync(Guid ReceiverUserId, string Subject, string Body, bool IsSendNotification = true, bool IsSendInbox = false, bool IsSendMail = false)
{
try
{
var profile = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.Id == ReceiverUserId);
if (profile == null)
throw new Exception(GlobalMessages.DataNotFound);
if (IsSendNotification == true)
{
_dbContext.Set<Notification>().Add(new Notification
{
Body = Body,
ReceiverUserId = ReceiverUserId,
Type = "",
Payload = "",
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
if (IsSendInbox == true)
{
_dbContext.Set<Inbox>().Add(new Inbox
{
Subject = Subject,
Body = Body,
ReceiverUserId = ReceiverUserId,
Payload = "",
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
if (IsSendMail == true)
{
// _context.Notifications.Add(new Notification
// {
// Body = req.Body,
// ReceiverUserId = req.ReceiverUserId,
// Type = "",
// Payload = "",
// CreatedUserId = FullName ?? "",
// CreatedFullName = UserId ?? "System Administrator",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// });
}
await _dbContext.SaveChangesAsync();
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -37,15 +37,61 @@ namespace BMA.EHR.Application.Repositories.Reports
#endregion
#region " Methods "
// public async Task<dynamic> GetOcInsigniaPeriod(Guid id)
// private string GetPositionByYear(string profileID, int year)
// {
// var period = await _dbContext.Set<InsigniaPeriod>()
// .FirstOrDefaultAsync(x => x.Id == id);
// if (period == null)
// throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
// period.
// var OCName = r.OcId == null ? "-" : _organizationCommonRepository.GetOrganizationNameFullPath(r.OcId.Value, false, false);
// return OCName;
// using (var ctx = new ApplicationDbContext())
// {
// var ret = (from x in ctx.ProfileSalaryPositions.AsQueryable()
// where x.IdNavigation.ProfileId == profileID &&
// x.IdNavigation.SalaryDateAnnounce.Value.Year == year
// orderby x.IdNavigation.Order descending
// select x)
// .Include(x => x.Position)
// .FirstOrDefault();
// if (ret != null)
// return ret.Position.Name;
// else
// return "ไม่ระบุ";
// }
// }
// private string GetPositionLevelByYear(string profileID, int year)
// {
// using (var ctx = new ApplicationDbContext())
// {
// var ret = (from x in ctx.ProfileSalaryPositionLevels.AsQueryable()
// where x.IdNavigation.ProfileId == profileID &&
// x.IdNavigation.SalaryDateAnnounce.Value.Year == year
// orderby x.IdNavigation.Order descending
// select x)
// .Include(x => x.PositionLevel)
// .FirstOrDefault();
// if (ret != null)
// return ret.PositionLevel.Name;
// else
// return "ไม่ระบุ";
// }
// }
// private string GetPositionTypeByYear(string profileID, int year)
// {
// using (var ctx = new ApplicationDbContext())
// {
// var ret = (from x in ctx.ProfileSalaryPositionTypes.AsQueryable()
// where x.IdNavigation.ProfileId == profileID &&
// x.IdNavigation.SalaryDateAnnounce.Value.Year == year
// orderby x.IdNavigation.Order descending
// select x)
// .Include(x => x.PositionType)
// .FirstOrDefault();
// if (ret != null)
// return ret.PositionType.Name;
// else
// return "ไม่ระบุ";
// }
// }
public async Task<dynamic> GetYearInsigniaPeriod(Guid id)
@ -149,6 +195,7 @@ namespace BMA.EHR.Application.Repositories.Reports
G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0),
G5Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
G5Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
Remark = "",
}).ToList();
return insignia;
@ -191,6 +238,7 @@ namespace BMA.EHR.Application.Repositories.Reports
G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0),
G5Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
G5Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
Remark = "",
}).ToList();
return new
@ -205,6 +253,7 @@ namespace BMA.EHR.Application.Repositories.Reports
G4Female = insignia.Sum(x => x.G4Female),
G5Male = insignia.Sum(x => x.G5Male),
G5Female = insignia.Sum(x => x.G5Female),
Remark = "",
};
}
@ -254,6 +303,7 @@ namespace BMA.EHR.Application.Repositories.Reports
G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0),
G9Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
Remark = "",
}).ToList();
return insignia;
@ -303,6 +353,7 @@ namespace BMA.EHR.Application.Repositories.Reports
G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0),
G9Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
Remark = "",
}).ToList();
return new
@ -325,6 +376,7 @@ namespace BMA.EHR.Application.Repositories.Reports
G8Female = insignia.Sum(x => x.G8Female),
G9Male = insignia.Sum(x => x.G9Male),
G9Female = insignia.Sum(x => x.G9Female),
Remark = "",
};
}
@ -430,6 +482,7 @@ namespace BMA.EHR.Application.Repositories.Reports
InsigniaInitial = r.RequestInsignia.ShortName,
InsigniaName = r.RequestInsignia.Name,
ProfileId = r.Profile.Id,
CitizenId = r.Profile.CitizenId,
FullName = $"{r.Profile.Prefix?.Name}{r.Profile.FirstName} {r.Profile.LastName}",
ShowProfileId = r.Profile.Id,
Type = r.Profile.PositionType == null ? "-" : r.Profile.PositionType.Name,
@ -444,8 +497,9 @@ namespace BMA.EHR.Application.Repositories.Reports
Remark = "",
Position = r.Profile.Position?.Name +
(r.Profile.PositionType == null ? null : " ประเภท" + r.Profile.PositionType?.Name) +
(r.Profile.PositionLevel == null ? null : " ระดับ" + r.Profile.PositionLevel?.Name) +
CRLF,
(r.Profile.PositionLevel == null ? null : " สังกัด" + r.Profile.PositionLevel?.Name) +
(r.Request.Organization == null ? null : " ระดับ" + CRLF + _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false))
,
OCName = _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false)
})
.Distinct()
@ -473,6 +527,7 @@ namespace BMA.EHR.Application.Repositories.Reports
InsigniaInitial = r.RequestInsignia.ShortName,
InsigniaName = r.RequestInsignia.Name,
ProfileId = r.Profile.Id,
CitizenId = r.Profile.CitizenId,
FullName = $"",
ShowProfileId = Guid.Parse("00000000-0000-0000-0000-000000000000"),
Type = "",
@ -487,6 +542,9 @@ namespace BMA.EHR.Application.Repositories.Reports
InsigniaRequest = "",
Remark = "",
Position = "",
// Position = GetPositionByYear(r.Profile.Id, r.Request.Period.Year) + " ประเภท" +
// GetPositionTypeByYear(r.Profile.Id, r.Request.Period.Year) + " ระดับ" +
// GetPositionLevelByYear(r.Profile.Id, r.Request.Period.Year),
OCName = _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false)
})
.Distinct()
@ -528,6 +586,7 @@ namespace BMA.EHR.Application.Repositories.Reports
G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0),
G2Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
G2Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
Remark = "",
}).ToList();
return insignia;
@ -563,6 +622,7 @@ namespace BMA.EHR.Application.Repositories.Reports
G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0),
G2Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
G2Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
Remark = "",
}).ToList();
return new
@ -570,7 +630,8 @@ namespace BMA.EHR.Application.Repositories.Reports
G1Male = insignia.Sum(x => x.G1Male),
G1Female = insignia.Sum(x => x.G1Female),
G2Male = insignia.Sum(x => x.G2Male),
G2Female = insignia.Sum(x => x.G2Female)
G2Female = insignia.Sum(x => x.G2Female),
Remark = "",
};
}