ปรับโครงสร้างระบบ ให้รองรับ การไปช่วยปฏิบัติงาน
This commit is contained in:
@@ -21,6 +21,8 @@ namespace TodoAPI2.Models
|
||||
[MaxLength(255)]
|
||||
public string thegroup { get; set; }
|
||||
|
||||
public int? main_dept_id { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ namespace TodoAPI2.Models
|
||||
|
||||
public string thegroup { get; set; }
|
||||
|
||||
public int? main_dept_id { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,16 @@ namespace TodoAPI2.Models
|
||||
public class eva_evaluation_groupService : Ieva_evaluation_groupService
|
||||
{
|
||||
private IBaseRepository<eva_evaluation_groupEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_evaluation_groupService(IBaseRepository<eva_evaluation_groupEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
public eva_evaluation_groupService(IBaseRepository<eva_evaluation_groupEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
emp = inemp;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
@@ -47,7 +49,7 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
return Mapper.Map<List<eva_evaluation_groupViewModel>>(entities);
|
||||
}
|
||||
|
||||
|
||||
private List<eva_evaluation_groupEntity> GetListWithoutBase64Fields(IQueryable<eva_evaluation_groupEntity> listQuery)
|
||||
{
|
||||
return listQuery.Select(c => new eva_evaluation_groupEntity()
|
||||
@@ -65,6 +67,21 @@ namespace TodoAPI2.Models
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
private List<external_linkageViewModel> getMainDept()
|
||||
{
|
||||
var a = emp.GetDeptMapping().Where(x => !x.id2.HasValue);
|
||||
var data = new List<external_linkageViewModel>();
|
||||
foreach(var i in a)
|
||||
{
|
||||
var n = new external_linkageViewModel();
|
||||
n.external_id = i.id;
|
||||
n.external_name = i.department_name;
|
||||
n.external_code = i.department_code;
|
||||
data.Add(n);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public eva_evaluation_groupViewModel Get(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
@@ -75,6 +92,7 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_evaluation_groupWithSelectionViewModel>(entity);
|
||||
i.item_main_dept_id = getMainDept();
|
||||
|
||||
|
||||
return i;
|
||||
@@ -82,23 +100,38 @@ namespace TodoAPI2.Models
|
||||
public eva_evaluation_groupWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_evaluation_groupWithSelectionViewModel();
|
||||
i.item_main_dept_id = getMainDept();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_evaluation_groupViewModel> GetListBycode(string code)
|
||||
{
|
||||
var model = new eva_evaluation_groupSearchModel();
|
||||
model.code = code;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_evaluation_groupViewModel> GetListALLeva_evaluation_group()
|
||||
{
|
||||
var data = (
|
||||
from m_eva_evaluation_group in _repository.Context.eva_evaluation_group
|
||||
|
||||
orderby m_eva_evaluation_group.created descending
|
||||
join fk_external_linkage3 in getMainDept() on m_eva_evaluation_group.main_dept_id equals fk_external_linkage3.id
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
orderby m_eva_evaluation_group.code
|
||||
select new eva_evaluation_groupViewModel()
|
||||
{
|
||||
id = m_eva_evaluation_group.id,
|
||||
code = m_eva_evaluation_group.code,
|
||||
thegroup = m_eva_evaluation_group.thegroup,
|
||||
main_dept_id = m_eva_evaluation_group.main_dept_id,
|
||||
percentage = m_eva_evaluation_group.percentage,
|
||||
|
||||
main_dept_id_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
|
||||
isActive = m_eva_evaluation_group.isActive,
|
||||
Created = m_eva_evaluation_group.created,
|
||||
@@ -109,48 +142,30 @@ namespace TodoAPI2.Models
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<eva_evaluation_groupViewModel> GetListBycode(string code)
|
||||
|
||||
public List<eva_evaluation_groupViewModel> GetListBySearch(eva_evaluation_groupSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_evaluation_group in _repository.Context.eva_evaluation_group
|
||||
|
||||
join fk_external_linkage3 in getMainDept() on m_eva_evaluation_group.main_dept_id equals fk_external_linkage3.id
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
where m_eva_evaluation_group.code == code || string.IsNullOrEmpty(code)
|
||||
|
||||
orderby m_eva_evaluation_group.created descending
|
||||
select new eva_evaluation_groupViewModel()
|
||||
{
|
||||
id = m_eva_evaluation_group.id,
|
||||
code = m_eva_evaluation_group.code,
|
||||
thegroup = m_eva_evaluation_group.thegroup,
|
||||
|
||||
|
||||
isActive = m_eva_evaluation_group.isActive,
|
||||
Created = m_eva_evaluation_group.created,
|
||||
Updated = m_eva_evaluation_group.updated
|
||||
}
|
||||
).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<eva_evaluation_groupViewModel> GetListBySearch(eva_evaluation_groupSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_evaluation_group in _repository.Context.eva_evaluation_group
|
||||
|
||||
|
||||
where 1==1
|
||||
where 1 == 1
|
||||
&& (m_eva_evaluation_group.code == model.code || string.IsNullOrEmpty(model.code))
|
||||
|
||||
|
||||
orderby m_eva_evaluation_group.created descending
|
||||
orderby m_eva_evaluation_group.code
|
||||
select new eva_evaluation_groupViewModel()
|
||||
{
|
||||
id = m_eva_evaluation_group.id,
|
||||
code = m_eva_evaluation_group.code,
|
||||
thegroup = m_eva_evaluation_group.thegroup,
|
||||
main_dept_id = m_eva_evaluation_group.main_dept_id,
|
||||
percentage = m_eva_evaluation_group.percentage,
|
||||
|
||||
main_dept_id_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
|
||||
isActive = m_eva_evaluation_group.isActive,
|
||||
Created = m_eva_evaluation_group.created,
|
||||
@@ -172,7 +187,7 @@ namespace TodoAPI2.Models
|
||||
|
||||
|
||||
var inserted = _repository.Insert(entity);
|
||||
|
||||
|
||||
return Get(inserted.id);
|
||||
}
|
||||
|
||||
@@ -183,26 +198,29 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
existingEntity.code = model.code;
|
||||
existingEntity.thegroup = model.thegroup;
|
||||
|
||||
existingEntity.main_dept_id = model.main_dept_id;
|
||||
existingEntity.percentage = model.percentage;
|
||||
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_evaluation_groupInputModel> model)
|
||||
public string UpdateMultiple(List<eva_evaluation_groupInputModel> model)
|
||||
{
|
||||
foreach(var i in model)
|
||||
foreach (var i in model)
|
||||
{
|
||||
if (i.active_mode == "1" && i.id.HasValue) // update
|
||||
{
|
||||
{
|
||||
var existingEntity = _repository.Get(i.id.Value);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.code = i.code;
|
||||
existingEntity.thegroup = i.thegroup;
|
||||
existingEntity.code = i.code;
|
||||
existingEntity.thegroup = i.thegroup;
|
||||
existingEntity.main_dept_id = i.main_dept_id;
|
||||
existingEntity.percentage = i.percentage;
|
||||
|
||||
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
@@ -215,15 +233,15 @@ namespace TodoAPI2.Models
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
}
|
||||
else if (i.active_mode == "0" && i.id.HasValue) // remove
|
||||
{
|
||||
{
|
||||
_repository.DeleteWithoutCommit(i.id.Value);
|
||||
}
|
||||
else if (i.active_mode == "0" && !i.id.HasValue)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
_repository.Context.SaveChanges();
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace TodoAPI2.Models
|
||||
|
||||
public string thegroup { get; set; }
|
||||
|
||||
public int? main_dept_id { get; set; }
|
||||
|
||||
public decimal? percentage { get; set; }
|
||||
|
||||
public string main_dept_id_external_linkage_external_name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,6 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_evaluation_groupWithSelectionViewModel: eva_evaluation_groupViewModel
|
||||
{
|
||||
|
||||
public List<external_linkageViewModel> item_main_dept_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -40,8 +40,10 @@ namespace TodoAPI2.Models
|
||||
|
||||
public int? order_of_data { get; set; }
|
||||
|
||||
public int? help_org_id { get; set; }
|
||||
|
||||
public void SetAutoField(DataContext context)
|
||||
|
||||
public void SetAutoField(DataContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace TodoAPI2.Models
|
||||
|
||||
public int? order_of_data { get; set; }
|
||||
|
||||
public int? help_org_id { get; set; }
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,18 +79,27 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_limit_frame_employeeWithSelectionViewModel>(entity);
|
||||
i.item_frame_group_guid = (from x in _repository.Context.eva_limit_frame_group
|
||||
join j in _repository.Context.eva_evaluation_group
|
||||
on x.group_guid equals j.id
|
||||
where (from q in _repository.Context.eva_limit_frame_group where q.id == entity.frame_group_guid select q.frame_plan_guid).Contains(x.frame_plan_guid)
|
||||
select new external_linkageViewModel { id_guid=x.id,external_name=j.thegroup }).ToList();
|
||||
i.item_employee_id = (from x in emp.GetAllEmployee() select x).ToList();
|
||||
i.item_org_id = (from x in ext.GetDepartmentData() select x).ToList();
|
||||
|
||||
i.item_help_org_id = (from x in ext.GetDepartmentData() select x).ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_limit_frame_employeeWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_limit_frame_employeeWithSelectionViewModel();
|
||||
i.item_frame_group_guid = (from x in _repository.Context.eva_limit_frame_group
|
||||
join j in _repository.Context.eva_evaluation_group
|
||||
on x.group_guid equals j.id
|
||||
select new external_linkageViewModel { id_guid = x.id, external_name = j.thegroup }).ToList();
|
||||
i.item_employee_id = (from x in emp.GetAllEmployee() select x).ToList();
|
||||
i.item_org_id = (from x in ext.GetDepartmentData() select x).ToList();
|
||||
|
||||
i.item_help_org_id = (from x in ext.GetDepartmentData() select x).ToList();
|
||||
|
||||
return i;
|
||||
}
|
||||
@@ -119,6 +128,9 @@ namespace TodoAPI2.Models
|
||||
into external_linkageResult3
|
||||
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
|
||||
|
||||
join fk_external_linkage11 in ext.GetDepartmentData() on m_eva_limit_frame_employee.help_org_id equals fk_external_linkage11.id
|
||||
into external_linkageResult11
|
||||
from fk_external_linkageResult11 in external_linkageResult11.DefaultIfEmpty()
|
||||
|
||||
where
|
||||
1 == 1
|
||||
@@ -140,10 +152,12 @@ namespace TodoAPI2.Models
|
||||
monthly_remuneration = m_eva_limit_frame_employee.monthly_remuneration,
|
||||
cost_of_living = m_eva_limit_frame_employee.cost_of_living,
|
||||
order_of_data = m_eva_limit_frame_employee.order_of_data,
|
||||
help_org_id = m_eva_limit_frame_employee.help_org_id,
|
||||
|
||||
frame_group_guid_eva_limit_frame_group_group_guid = fk_eva_limit_frame_groupResult1.group_guid,
|
||||
employee_id_external_linkage_external_name = fk_external_linkageResult2.fullname,
|
||||
org_id_external_linkage_external_name = fk_external_linkageResult3.external_name,
|
||||
help_org_id_external_linkage_external_name = fk_external_linkageResult11.external_name,
|
||||
|
||||
isActive = m_eva_limit_frame_employee.isActive,
|
||||
Created = m_eva_limit_frame_employee.created,
|
||||
@@ -197,6 +211,7 @@ namespace TodoAPI2.Models
|
||||
existingEntity.monthly_remuneration = model.monthly_remuneration;
|
||||
existingEntity.cost_of_living = model.cost_of_living;
|
||||
existingEntity.order_of_data = model.order_of_data;
|
||||
existingEntity.help_org_id = model.help_org_id;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
|
||||
@@ -236,6 +251,7 @@ namespace TodoAPI2.Models
|
||||
existingEntity.monthly_remuneration = i.monthly_remuneration;
|
||||
existingEntity.cost_of_living = i.cost_of_living;
|
||||
existingEntity.order_of_data = i.order_of_data;
|
||||
existingEntity.help_org_id = i.help_org_id;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
|
||||
@@ -34,9 +34,11 @@ namespace TodoAPI2.Models
|
||||
|
||||
public int? order_of_data { get; set; }
|
||||
|
||||
public int? help_org_id { get; set; }
|
||||
|
||||
public Guid? frame_group_guid_eva_limit_frame_group_group_guid { get; set; }
|
||||
public string employee_id_external_linkage_external_name { get; set; }
|
||||
public string org_id_external_linkage_external_name { get; set; }
|
||||
|
||||
public string help_org_id_external_linkage_external_name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,10 @@ namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_limit_frame_employeeWithSelectionViewModel: eva_limit_frame_employeeViewModel
|
||||
{
|
||||
public List<external_linkageViewModel> item_frame_group_guid { get; set; }
|
||||
public List<external_employeeViewModel> item_employee_id { get; set; }
|
||||
public List<external_linkageViewModel> item_org_id { get; set; }
|
||||
|
||||
public List<external_linkageViewModel> item_help_org_id { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace TodoAPI2.Models
|
||||
&& (!model.group_guid.HasValue || m_eva_limit_frame_group.group_guid == model.group_guid)
|
||||
|
||||
|
||||
orderby m_eva_limit_frame_group.created descending
|
||||
orderby fk_eva_evaluation_groupResult2.code
|
||||
select new eva_limit_frame_groupViewModel()
|
||||
{
|
||||
id = m_eva_limit_frame_group.id,
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace TodoAPI2.Models
|
||||
List<external_employeeViewModel> GetAllEmployee();
|
||||
List<external_menu> GetAllMenu();
|
||||
List<external_menu> GetMenuByUser(int? userid);
|
||||
|
||||
List<external_user> GetAllUser();
|
||||
List<dept_mappingViewModel> GetDeptMapping();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -735,6 +735,53 @@ select id,name from users
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<dept_mappingViewModel> GetDeptMapping()
|
||||
{
|
||||
var sql = string.Format(@"
|
||||
select orgdata.id,orgdata2.id as id2,
|
||||
case when orgdata2.department_name is not null then
|
||||
concat(orgdata2.department_name,' - ',orgdata.department_name)
|
||||
else orgdata.department_name end as full_dep,
|
||||
orgdata.department_name,
|
||||
orgdata.department_code,detail.parent_department_id,
|
||||
case
|
||||
when org_type_depart.department_degree_id = 1 then orgdata.department_code::int*1000
|
||||
when detail.parent_department_id is not null and detail.parent_department_id>0
|
||||
then orgdata2.department_code::int*1000+orgdata.department_code::int
|
||||
else orgdata.department_code::int*100000 end as sort_order,org_type_depart.department_degree_id
|
||||
from public.{0}DepartmentData{0} orgdata
|
||||
left join org_organization_chart_details detail on orgdata.id = detail.department_id
|
||||
left join public.{0}DepartmentData{0} orgdata2 on orgdata2.id = detail.parent_department_id
|
||||
left join public.org_type_departments as org_type_depart on orgdata.department_type_id = org_type_depart.id
|
||||
left join public.org_type_department_colors as org_depart_color
|
||||
on org_type_depart.department_degree_id = org_depart_color.id
|
||||
where orgdata.department_name is not null and orgdata.deleted_at is null
|
||||
order by case
|
||||
when org_type_depart.department_degree_id = 1 then orgdata.department_code::int*1000
|
||||
when detail.parent_department_id is not null and detail.parent_department_id>0
|
||||
then orgdata2.department_code::int*1000+orgdata.department_code::int
|
||||
else orgdata.department_code::int*100000 end
|
||||
", '"'.ToString());
|
||||
var para = db.GetParameterListNpgsql();
|
||||
DataTable dt = db.ExecuteDataTableNpgsql(sql, para);
|
||||
var result = new List<dept_mappingViewModel>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
var i = new dept_mappingViewModel();
|
||||
if(dr["id"] != DBNull.Value) i.id = Convert.ToInt32(dr["id"]);
|
||||
if (dr["id2"] != DBNull.Value) i.id2 = Convert.ToInt32(dr["id2"]);
|
||||
if (dr["full_dep"] != DBNull.Value) i.full_dep= dr["full_dep"].ToString();
|
||||
if (dr["department_name"] != DBNull.Value) i.department_name = dr["department_name"].ToString();
|
||||
if (dr["department_code"] != DBNull.Value) i.department_code = dr["department_code"].ToString();
|
||||
if (dr["parent_department_id"] != DBNull.Value) i.parent_department_id = Convert.ToInt32(dr["parent_department_id"]);
|
||||
if (dr["sort_order"] != DBNull.Value) i.sort_order = Convert.ToInt32(dr["sort_order"]);
|
||||
if (dr["department_degree_id"] != DBNull.Value) i.department_degree_id = Convert.ToInt32(dr["department_degree_id"]);
|
||||
|
||||
result.Add(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class external_menu
|
||||
|
||||
@@ -11,6 +11,18 @@ using TTSW.Common;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class dept_mappingViewModel
|
||||
{
|
||||
public int? id { get; set; }
|
||||
public int? id2 { get; set; }
|
||||
public string full_dep { get; set; }
|
||||
public string department_name { get; set; }
|
||||
public string department_code { get; set; }
|
||||
public int? parent_department_id { get; set; }
|
||||
public int? sort_order { get; set; }
|
||||
public int? department_degree_id { get; set; }
|
||||
}
|
||||
|
||||
public class employee_leaveViewModel
|
||||
{
|
||||
public decimal? sum_day_sick_leave { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user