ปรับปรุงให้รองรับ การไปช่วยปฏิบัติงาน
This commit is contained in:
@@ -150,6 +150,16 @@ namespace TodoAPI2.Models
|
||||
entity.id = Guid.NewGuid();
|
||||
entity.limit_frame_005 = (decimal?)0.05;
|
||||
|
||||
var all_all_emp = emp.GetAllEmployee();
|
||||
var mapping_dept = emp.GetDeptMapping();
|
||||
var working_record = from i in emp.GetWorkingRecord() where
|
||||
model.executed_date.HasValue
|
||||
&& i.start_date <= model.executed_date
|
||||
&& i.end_date >= model.executed_date
|
||||
select i;
|
||||
var result_frame_group = new List<eva_limit_frame_groupEntity>();
|
||||
var result_frame_employee = new List<eva_limit_frame_employeeEntity>();
|
||||
|
||||
var all_group = (from i in _repository.Context.eva_evaluation_group
|
||||
select i);
|
||||
foreach (var x in all_group)
|
||||
@@ -172,7 +182,9 @@ namespace TodoAPI2.Models
|
||||
new_frame_group.total_salary = all_emp.Sum(z => z.salary);
|
||||
new_frame_group.total_salary_limit = (new_frame_group.total_salary * new_frame_group.limit_frame_295 / 100);
|
||||
new_frame_group.total_salary_limit_rounded = MyHelper.RoundOff(new_frame_group.total_salary_limit.Value, 10);
|
||||
_repository.Context.Add(new_frame_group);
|
||||
new_frame_group.main_dept_id = x.main_dept_id;
|
||||
//_repository.Context.Add(new_frame_group);
|
||||
result_frame_group.Add(new_frame_group);
|
||||
|
||||
int i = 1;
|
||||
foreach (var y in all_emp)
|
||||
@@ -190,10 +202,60 @@ namespace TodoAPI2.Models
|
||||
new_emp.cost_of_living = y.cost_of_living;
|
||||
new_emp.order_of_data = i;
|
||||
i++;
|
||||
_repository.Context.Add(new_emp);
|
||||
//_repository.Context.Add(new_emp);
|
||||
result_frame_employee.Add(new_emp);
|
||||
}
|
||||
}
|
||||
|
||||
var help_other_org = from i in result_frame_employee
|
||||
where
|
||||
(from j in working_record select j.employee_id).Contains(i.employee_id)
|
||||
select i;
|
||||
foreach(var em in help_other_org)
|
||||
{
|
||||
var w = (from i in working_record where i.employee_id == em.employee_id select i).FirstOrDefault();
|
||||
if(w != null)
|
||||
{
|
||||
int? main_dept = (from i in mapping_dept where i.id == w.place select i.id2.HasValue?i.id2:i.id).FirstOrDefault();
|
||||
var s = (from i in result_frame_group where i.main_dept_id == main_dept select i).FirstOrDefault();
|
||||
|
||||
if(s != null)
|
||||
{
|
||||
em.help_org_id = main_dept;
|
||||
em.frame_group_guid = s.id;
|
||||
em.order_of_data += 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var x in result_frame_group)
|
||||
{
|
||||
x.remark = "";
|
||||
int i = 1;
|
||||
int j = 1;
|
||||
foreach(var y in from z in result_frame_employee where z.frame_group_guid==x.id orderby z.order_of_data select z)
|
||||
{
|
||||
y.order_of_data = i;
|
||||
i++;
|
||||
|
||||
if (y.help_org_id.HasValue)
|
||||
{
|
||||
var theemp = (from q in all_all_emp where q.id == y.employee_id select q).FirstOrDefault();
|
||||
var thedetail = (from r in working_record where r.employee_id == y.employee_id select r).FirstOrDefault();
|
||||
var help_at = (from s in mapping_dept where s.id == thedetail.place select s).FirstOrDefault();
|
||||
if(theemp != null && thedetail != null && help_at != null)
|
||||
{
|
||||
if (x.remark != "") x.remark += "\n";
|
||||
x.remark += $"{j}.ในลำดับที่ {y.order_of_data} {theemp.fullname} ตำแหน่ง{theemp.position_name} {theemp.department_name} \nมาช่วยปฏิบัติงานที่{help_at.department_name} ตั้งแต่วันที่ {MyHelper.GetDateStringForReport(thedetail.start_date)} - {MyHelper.GetDateStringForReport(thedetail.end_date)} \nตาม{thedetail.subject}";
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_repository.Context.AddRange(result_frame_group);
|
||||
_repository.Context.AddRange(result_frame_employee);
|
||||
|
||||
entity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
|
||||
Reference in New Issue
Block a user