report placement, retire
This commit is contained in:
parent
1b04e2dfc3
commit
082f4b2f59
6 changed files with 984 additions and 29 deletions
|
|
@ -33,7 +33,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
private readonly DisciplineDbContext _contextDiscipline;
|
||||
public RetirementController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
|
|
@ -41,7 +41,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
IConfiguration configuration,
|
||||
OrganizationCommonRepository organizationCommonRepository,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
PermissionRepository permission)
|
||||
PermissionRepository permission,
|
||||
DisciplineDbContext contextDiscipline)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
|
|
@ -51,6 +52,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
_permission = permission;
|
||||
_contextDiscipline = contextDiscipline;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -1290,15 +1292,286 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("report1")]
|
||||
public async Task<ActionResult<ResponseObject>> report1(string? nodeId = null, int? node = 0, DateOnly? startDate = null, DateOnly? startEnd = null)
|
||||
public async Task<ActionResult<ResponseObject>> report1(string nodeId = "", int? node = null, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
var data = new
|
||||
{
|
||||
template = "retirement01",
|
||||
reportName = "xlsx-report",
|
||||
data = ""
|
||||
};
|
||||
|
||||
var apiUrl = $"{_configuration["API"]}/org/find/node-all";
|
||||
var data = new object();
|
||||
var data1 = new List<dynamic>();
|
||||
var data2 = new List<dynamic>();
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
|
||||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||
{
|
||||
node,
|
||||
nodeId
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
var orgs = JsonConvert.DeserializeObject<NodeAllRequest>(_result);
|
||||
|
||||
if (orgs == null || orgs.result == null)
|
||||
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
|
||||
|
||||
int no = 1;
|
||||
|
||||
foreach (var org in orgs.result.isRootTrue)
|
||||
{
|
||||
//เกษียณ
|
||||
var retire = _context.RetirementPeriods
|
||||
.Include(x => x.RetirementProfiles.Where(x => x.rootId == org.rootId))
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Type.Trim().ToUpper() == "OFFICER")
|
||||
.FirstOrDefault();
|
||||
|
||||
var rt_count = retire != null ? retire.RetirementProfiles.Count() : 0;
|
||||
|
||||
//ลาออก
|
||||
var retirementResigns = _context.RetirementResigns
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.rootOldId == org.rootId &&
|
||||
x.IsCancel == false && x.Status == "DONE")
|
||||
.ToList();
|
||||
|
||||
var career_count = retirementResigns.Where(x => x.Reason == "CAREER").Count();
|
||||
var move_count = retirementResigns.Where(x => x.Reason == "MOVE").Count();
|
||||
var family_count = retirementResigns.Where(x => x.Reason == "FAMILY").Count();
|
||||
var education_count = retirementResigns.Where(x => x.Reason == "EDUCATION").Count();
|
||||
var other_count = retirementResigns.Where(x => x.Reason == "OTHER").Count();
|
||||
|
||||
//ขอโอน
|
||||
var pt_count = _context.PlacementTransfers
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.rootOldId.Contains(org.rootId) &&
|
||||
x.Status.Trim().ToUpper() == "DONE")
|
||||
.Count();
|
||||
|
||||
//ถึงแก่กรรม
|
||||
var rd_count = _context.RetirementDeceaseds
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ให้ออก
|
||||
var ro_count = _context.RetirementOuts
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.rootOldId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ปลดออก
|
||||
var dl_cm19_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.CommandTypeId == Guid.Parse("ef8db4d7-1472-4c1d-b73f-9114e618a96f") &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ไล่ออก
|
||||
var dl_cm20_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.CommandTypeId == Guid.Parse("d9dee5c3-b75a-4927-9ce2-51e2233cf20b") &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
data1.Add(new
|
||||
{
|
||||
no = no,
|
||||
rootName = org.name,
|
||||
rt_count,
|
||||
career_count,
|
||||
move_count,
|
||||
family_count,
|
||||
education_count,
|
||||
other_count,
|
||||
pt_count,
|
||||
rd_count,
|
||||
ro_count,
|
||||
dl_cm19_count,
|
||||
dl_cm20_count,
|
||||
total = (rt_count + career_count + move_count + family_count + education_count + other_count + pt_count + rd_count + ro_count + dl_cm19_count + dl_cm20_count)
|
||||
});
|
||||
no++;
|
||||
}
|
||||
|
||||
no = 1;
|
||||
foreach (var org in orgs.result.isRootFalse)
|
||||
{
|
||||
//เกษียณ
|
||||
var retire = _context.RetirementPeriods
|
||||
.Include(x => x.RetirementProfiles.Where(x => x.rootId == org.rootId))
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Type.Trim().ToUpper() == "OFFICER")
|
||||
.FirstOrDefault();
|
||||
|
||||
var rt_count = retire != null ? retire.RetirementProfiles.Count() : 0;
|
||||
|
||||
//ลาออก
|
||||
var retirementResigns = _context.RetirementResigns
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.rootOldId == org.rootId &&
|
||||
x.IsCancel == false && x.Status == "DONE")
|
||||
.ToList();
|
||||
|
||||
var career_count = retirementResigns.Where(x => x.Reason == "CAREER").Count();
|
||||
var move_count = retirementResigns.Where(x => x.Reason == "MOVE").Count();
|
||||
var family_count = retirementResigns.Where(x => x.Reason == "FAMILY").Count();
|
||||
var education_count = retirementResigns.Where(x => x.Reason == "EDUCATION").Count();
|
||||
var other_count = retirementResigns.Where(x => x.Reason == "OTHER").Count();
|
||||
|
||||
//ขอโอน
|
||||
var pt_count = _context.PlacementTransfers
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.rootOldId.Contains(org.rootId) &&
|
||||
x.Status.Trim().ToUpper() == "DONE")
|
||||
.Count();
|
||||
|
||||
//ถึงแก่กรรม
|
||||
var rd_count = _context.RetirementDeceaseds
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ให้ออก
|
||||
var ro_count = _context.RetirementOuts
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.rootOldId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ปลดออก
|
||||
var dl_cm19_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.CommandTypeId == Guid.Parse("ef8db4d7-1472-4c1d-b73f-9114e618a96f") &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ไล่ออก
|
||||
var dl_cm20_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.CommandTypeId == Guid.Parse("d9dee5c3-b75a-4927-9ce2-51e2233cf20b") &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
data2.Add(new
|
||||
{
|
||||
no = no,
|
||||
rootName = org.name,
|
||||
rt_count,
|
||||
career_count,
|
||||
move_count,
|
||||
family_count,
|
||||
education_count,
|
||||
other_count,
|
||||
pt_count,
|
||||
rd_count,
|
||||
ro_count,
|
||||
dl_cm19_count,
|
||||
dl_cm20_count,
|
||||
total = (rt_count + career_count + move_count + family_count + education_count + other_count + pt_count + rd_count + ro_count + dl_cm19_count + dl_cm20_count)
|
||||
});
|
||||
no++;
|
||||
}
|
||||
}
|
||||
|
||||
data = new
|
||||
{
|
||||
template = "reportRetirement01All",
|
||||
reportName = "xlsx-report",
|
||||
data = new
|
||||
{
|
||||
date = $"ตั้งแต่วันที่ {startDate.Value.Date.ToThaiShortDate().ToThaiNumber()} ถึง {endDate.Value.Date.ToThaiShortDate().ToThaiNumber()}",
|
||||
dateCurrent = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}",
|
||||
data1,
|
||||
data1Count = new
|
||||
{
|
||||
rt_count = data1.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
|
||||
career_count = data1.Where(x => x.career_count > 0).Sum(x => x.career_count),
|
||||
move_count = data1.Where(x => x.move_count > 0).Sum(x => x.move_count),
|
||||
family_count = data1.Where(x => x.family_count > 0).Sum(x => x.family_count),
|
||||
education_count = data1.Where(x => x.education_count > 0).Sum(x => x.education_count),
|
||||
other_count = data1.Where(x => x.other_count > 0).Sum(x => x.other_count),
|
||||
pt_count = data1.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
|
||||
rd_count = data1.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
|
||||
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
|
||||
dl_cm19_count = data1.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
|
||||
dl_cm20_count = data1.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
|
||||
total = data1.Where(x => x.total > 0).Sum(x => x.total)
|
||||
},
|
||||
data2,
|
||||
data2Count = new
|
||||
{
|
||||
rt_count = data2.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
|
||||
career_count = data2.Where(x => x.career_count > 0).Sum(x => x.career_count),
|
||||
move_count = data2.Where(x => x.move_count > 0).Sum(x => x.move_count),
|
||||
family_count = data2.Where(x => x.family_count > 0).Sum(x => x.family_count),
|
||||
education_count = data2.Where(x => x.education_count > 0).Sum(x => x.education_count),
|
||||
other_count = data2.Where(x => x.other_count > 0).Sum(x => x.other_count),
|
||||
pt_count = data2.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
|
||||
rd_count = data2.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
|
||||
ro_count = data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
|
||||
dl_cm19_count = data2.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
|
||||
dl_cm20_count = data2.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
|
||||
total = data2.Where(x => x.total > 0).Sum(x => x.total)
|
||||
},
|
||||
sum = new
|
||||
{
|
||||
rt_count = data1.Where(x => x.rt_count > 0).Sum(x => x.rt_count) + data2.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
|
||||
career_count = data1.Where(x => x.career_count > 0).Sum(x => x.career_count) + data2.Where(x => x.career_count > 0).Sum(x => x.career_count),
|
||||
move_count = data1.Where(x => x.move_count > 0).Sum(x => x.move_count) + data2.Where(x => x.move_count > 0).Sum(x => x.move_count),
|
||||
family_count = data1.Where(x => x.family_count > 0).Sum(x => x.family_count) + data2.Where(x => x.family_count > 0).Sum(x => x.family_count),
|
||||
education_count = data1.Where(x => x.education_count > 0).Sum(x => x.education_count) + data2.Where(x => x.education_count > 0).Sum(x => x.education_count),
|
||||
other_count = data1.Where(x => x.other_count > 0).Sum(x => x.other_count) + data2.Where(x => x.other_count > 0).Sum(x => x.other_count),
|
||||
pt_count = data1.Where(x => x.pt_count > 0).Sum(x => x.pt_count) + data2.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
|
||||
rd_count = data1.Where(x => x.rd_count > 0).Sum(x => x.rd_count) + data2.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
|
||||
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count) + data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
|
||||
dl_cm19_count = data1.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count) + data2.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
|
||||
dl_cm20_count = data1.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count) + data2.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
|
||||
total = data1.Where(x => x.total > 0).Sum(x => x.total) + data2.Where(x => x.total > 0).Sum(x => x.total)
|
||||
}
|
||||
}
|
||||
};
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
|
|
@ -1311,17 +1584,263 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("report2")]
|
||||
public async Task<ActionResult<ResponseObject>> report2(string? nodeId = null, int? node = 0, DateOnly? startDate = null, DateOnly? startEnd = null)
|
||||
public async Task<ActionResult<ResponseObject>> report2(string nodeId = "", int? node = null, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
|
||||
var data = new
|
||||
var apiUrl = $"{_configuration["API"]}/org/find/node-all";
|
||||
var data = new object();
|
||||
var data1 = new List<dynamic>();
|
||||
var data2 = new List<dynamic>();
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
template = "retirement02",
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
|
||||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||
{
|
||||
node,
|
||||
nodeId
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
var orgs = JsonConvert.DeserializeObject<NodeAllRequest>(_result);
|
||||
|
||||
if (orgs == null || orgs.result == null)
|
||||
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
|
||||
|
||||
int no = 1;
|
||||
|
||||
foreach (var org in orgs.result.isRootTrue)
|
||||
{
|
||||
//เกษียณ
|
||||
var retire = _context.RetirementPeriods
|
||||
.Include(x => x.RetirementProfiles.Where(x => x.rootId == org.rootId))
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Type.Trim().ToUpper() == "OFFICER")
|
||||
.FirstOrDefault();
|
||||
|
||||
var rt_count = retire != null ? retire.RetirementProfiles.Count() : 0;
|
||||
|
||||
//ลาออก
|
||||
var retirementResigns = _context.RetirementResigns
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.rootOldId == org.rootId &&
|
||||
x.IsCancel == false && x.Status == "DONE")
|
||||
.ToList();
|
||||
|
||||
var career_count = retirementResigns.Where(x => x.Reason == "CAREER").Count();
|
||||
var move_count = retirementResigns.Where(x => x.Reason == "MOVE").Count();
|
||||
var family_count = retirementResigns.Where(x => x.Reason == "FAMILY").Count();
|
||||
var education_count = retirementResigns.Where(x => x.Reason == "EDUCATION").Count();
|
||||
var other_count = retirementResigns.Where(x => x.Reason == "OTHER").Count();
|
||||
|
||||
//ถึงแก่กรรม
|
||||
var rd_count = _context.RetirementDeceaseds
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ให้ออก
|
||||
var ro_count = _context.RetirementOuts
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.rootOldId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ปลดออก
|
||||
var dl_cm19_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.CommandTypeId == Guid.Parse("ef8db4d7-1472-4c1d-b73f-9114e618a96f") &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ไล่ออก
|
||||
var dl_cm20_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.CommandTypeId == Guid.Parse("d9dee5c3-b75a-4927-9ce2-51e2233cf20b") &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
data1.Add(new
|
||||
{
|
||||
no = no,
|
||||
rootName = org.name,
|
||||
rt_count,
|
||||
career_count,
|
||||
move_count,
|
||||
family_count,
|
||||
education_count,
|
||||
other_count,
|
||||
rd_count,
|
||||
ro_count,
|
||||
dl_cm19_count,
|
||||
dl_cm20_count,
|
||||
total = (rt_count + career_count + move_count + family_count + education_count + other_count + rd_count + ro_count + dl_cm19_count + dl_cm20_count)
|
||||
});
|
||||
no++;
|
||||
}
|
||||
|
||||
no = 1;
|
||||
foreach (var org in orgs.result.isRootFalse)
|
||||
{
|
||||
//เกษียณ
|
||||
var retire = _context.RetirementPeriods
|
||||
.Include(x => x.RetirementProfiles.Where(x => x.rootId == org.rootId))
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Type.Trim().ToUpper() == "OFFICER")
|
||||
.FirstOrDefault();
|
||||
|
||||
var rt_count = retire != null ? retire.RetirementProfiles.Count() : 0;
|
||||
|
||||
//ลาออก
|
||||
var retirementResigns = _context.RetirementResigns
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.rootOldId == org.rootId &&
|
||||
x.IsCancel == false && x.Status == "DONE")
|
||||
.ToList();
|
||||
|
||||
var career_count = retirementResigns.Where(x => x.Reason == "CAREER").Count();
|
||||
var move_count = retirementResigns.Where(x => x.Reason == "MOVE").Count();
|
||||
var family_count = retirementResigns.Where(x => x.Reason == "FAMILY").Count();
|
||||
var education_count = retirementResigns.Where(x => x.Reason == "EDUCATION").Count();
|
||||
var other_count = retirementResigns.Where(x => x.Reason == "OTHER").Count();
|
||||
|
||||
//ถึงแก่กรรม
|
||||
var rd_count = _context.RetirementDeceaseds
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ให้ออก
|
||||
var ro_count = _context.RetirementOuts
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.rootOldId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ปลดออก
|
||||
var dl_cm19_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.CommandTypeId == Guid.Parse("ef8db4d7-1472-4c1d-b73f-9114e618a96f") &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
//ไล่ออก
|
||||
var dl_cm20_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x =>
|
||||
x.CreatedAt.Date >= startDate &&
|
||||
x.CreatedAt.Date <= endDate &&
|
||||
x.Status.Trim().ToUpper() == "DONE" &&
|
||||
x.profileType.Trim().ToUpper() == "OFFICER" &&
|
||||
x.CommandTypeId == Guid.Parse("d9dee5c3-b75a-4927-9ce2-51e2233cf20b") &&
|
||||
x.rootId.Contains(org.rootId))
|
||||
.Count();
|
||||
|
||||
data2.Add(new
|
||||
{
|
||||
no = no,
|
||||
rootName = org.name,
|
||||
rt_count,
|
||||
career_count,
|
||||
move_count,
|
||||
family_count,
|
||||
education_count,
|
||||
other_count,
|
||||
rd_count,
|
||||
ro_count,
|
||||
dl_cm19_count,
|
||||
dl_cm20_count,
|
||||
total = (rt_count + career_count + move_count + family_count + education_count + other_count + rd_count + ro_count + dl_cm19_count + dl_cm20_count)
|
||||
});
|
||||
no++;
|
||||
}
|
||||
}
|
||||
|
||||
data = new
|
||||
{
|
||||
template = "reportRetirement02All",
|
||||
reportName = "xlsx-report",
|
||||
data = ""
|
||||
|
||||
data = new
|
||||
{
|
||||
date = $"ตั้งแต่วันที่ {startDate.Value.Date.ToThaiShortDate().ToThaiNumber()} ถึง {endDate.Value.Date.ToThaiShortDate().ToThaiNumber()}",
|
||||
dateCurrent = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}",
|
||||
data1,
|
||||
data1Count = new
|
||||
{
|
||||
rt_count = data1.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
|
||||
career_count = data1.Where(x => x.career_count > 0).Sum(x => x.career_count),
|
||||
move_count = data1.Where(x => x.move_count > 0).Sum(x => x.move_count),
|
||||
family_count = data1.Where(x => x.family_count > 0).Sum(x => x.family_count),
|
||||
education_count = data1.Where(x => x.education_count > 0).Sum(x => x.education_count),
|
||||
other_count = data1.Where(x => x.other_count > 0).Sum(x => x.other_count),
|
||||
rd_count = data1.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
|
||||
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
|
||||
dl_cm19_count = data1.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
|
||||
dl_cm20_count = data1.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
|
||||
total = data1.Where(x => x.total > 0).Sum(x => x.total)
|
||||
},
|
||||
data2,
|
||||
data2Count = new
|
||||
{
|
||||
rt_count = data2.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
|
||||
career_count = data2.Where(x => x.career_count > 0).Sum(x => x.career_count),
|
||||
move_count = data2.Where(x => x.move_count > 0).Sum(x => x.move_count),
|
||||
family_count = data2.Where(x => x.family_count > 0).Sum(x => x.family_count),
|
||||
education_count = data2.Where(x => x.education_count > 0).Sum(x => x.education_count),
|
||||
other_count = data2.Where(x => x.other_count > 0).Sum(x => x.other_count),
|
||||
rd_count = data2.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
|
||||
ro_count = data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
|
||||
dl_cm19_count = data2.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
|
||||
dl_cm20_count = data2.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
|
||||
total = data2.Where(x => x.total > 0).Sum(x => x.total)
|
||||
},
|
||||
sum = new
|
||||
{
|
||||
rt_count = data1.Where(x => x.rt_count > 0).Sum(x => x.rt_count) + data2.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
|
||||
career_count = data1.Where(x => x.career_count > 0).Sum(x => x.career_count) + data2.Where(x => x.career_count > 0).Sum(x => x.career_count),
|
||||
move_count = data1.Where(x => x.move_count > 0).Sum(x => x.move_count) + data2.Where(x => x.move_count > 0).Sum(x => x.move_count),
|
||||
family_count = data1.Where(x => x.family_count > 0).Sum(x => x.family_count) + data2.Where(x => x.family_count > 0).Sum(x => x.family_count),
|
||||
education_count = data1.Where(x => x.education_count > 0).Sum(x => x.education_count) + data2.Where(x => x.education_count > 0).Sum(x => x.education_count),
|
||||
other_count = data1.Where(x => x.other_count > 0).Sum(x => x.other_count) + data2.Where(x => x.other_count > 0).Sum(x => x.other_count),
|
||||
rd_count = data1.Where(x => x.rd_count > 0).Sum(x => x.rd_count) + data2.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
|
||||
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count) + data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
|
||||
dl_cm19_count = data1.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count) + data2.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
|
||||
dl_cm20_count = data1.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count) + data2.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
|
||||
total = data1.Where(x => x.total > 0).Sum(x => x.total) + data2.Where(x => x.total > 0).Sum(x => x.total)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue