แยกเมนู แบบข้อตกลงการปฏิบัติงานเพื่อประกอบการพิจารณาประเมินผลสัมฤทธิ์ของงาน งด.2/2 ออกมา

This commit is contained in:
Nakorn Rientrakrunchai
2021-02-10 15:54:45 +07:00
parent fe4e051f62
commit 682dc2e5ae
21 changed files with 1639 additions and 194 deletions

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TTSW.EF;
using TTSW.Utils;
using TTSW.Constant;
using TTSW.Common;
using TodoAPI2.Models;
namespace TodoAPI2.Models
{
public interface Ieva_create_evaluation_detail_firstdocService
{
List<eva_create_evaluation_detail_firstdocViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id);
List<eva_create_evaluation_detail_firstdocViewModel> GetListBySearch(eva_create_evaluation_detail_firstdocSearchModel model, int? emp_id);
eva_create_evaluation_detail_firstdocWithSelectionViewModel GetWithSelection(int id);
eva_create_evaluation_detail_firstdocWithSelectionViewModel GetBlankItem();
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using TTSW.EF;
using TTSW.Utils;
using TTSW.Constant;
using TTSW.Common;
namespace TodoAPI2.Models
{
public class eva_create_evaluation_detail_firstdocInputModel
{
public int? id { get; set; }
public string evaluation_round { get; set; }
public string employee_code { get; set; }
public string employee_fullname { get; set; }
public string employee_position { get; set; }
public string employee_position_type { get; set; }
public string employee_position_level { get; set; }
public string employee_org { get; set; }
public string chief_fullname { get; set; }
public string chief_position { get; set; }
public int? create_evaluation_id { get; set; }
public int? org_id { get; set; }
public string search_employee_code { get; set; }
public string search_employee_fullname { get; set; }
public string active_mode { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using TTSW.EF;
using TTSW.Utils;
using TTSW.Constant;
using TTSW.Common;
namespace TodoAPI2.Models
{
public class eva_create_evaluation_detail_firstdocReportRequestModel : eva_create_evaluation_detail_firstdocSearchModel
{
public string filetype { get; set; }
public string contentType { get { return MyHelper.GetContentType(filetype); } }
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using TTSW.EF;
using TTSW.Utils;
using TTSW.Constant;
using TTSW.Common;
namespace TodoAPI2.Models
{
public class eva_create_evaluation_detail_firstdocSearchModel
{
public int id { get; set; }
public int? create_evaluation_id { get; set; }
public int? org_id { get; set; }
public string search_employee_code { get; set; }
public string search_employee_fullname { get; set; }
}
}

View File

@@ -0,0 +1,264 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TTSW.EF;
using TTSW.Utils;
using TTSW.Constant;
using TTSW.Common;
using TodoAPI2.Models;
using System.IO;
using System.Web;
using System.Net;
using TTSW.Configure;
using Microsoft.Extensions.Options;
using System.Data;
namespace TodoAPI2.Models
{
public class eva_create_evaluation_detail_firstdocService : Ieva_create_evaluation_detail_firstdocService
{
private IBaseRepository2<eva_create_evaluation_detailEntity, int> _repository;
private IMyDatabase db;
private Iexternal_linkageService ext;
private Iexternal_employeeService emp;
public eva_create_evaluation_detail_firstdocService(IBaseRepository2<eva_create_evaluation_detailEntity, int> repository, IMyDatabase mydb,
Iexternal_linkageService inext, Iexternal_employeeService inemp)
{
_repository = repository;
db = mydb;
ext = inext;
emp = inemp;
}
#region Private Functions
private eva_create_evaluation_detailEntity GetEntity(eva_create_evaluation_detail_firstdocInputModel model)
{
return Mapper.Map<eva_create_evaluation_detailEntity>(model);
}
private List<eva_create_evaluation_detailEntity> GetEntityList(List<eva_create_evaluation_detail_firstdocInputModel> models)
{
return Mapper.Map<List<eva_create_evaluation_detailEntity>>(models);
}
private eva_create_evaluation_detail_firstdocViewModel GetDto(eva_create_evaluation_detailEntity entity)
{
return Mapper.Map<eva_create_evaluation_detail_firstdocViewModel>(entity);
}
private List<eva_create_evaluation_detail_firstdocViewModel> GetDtoList(List<eva_create_evaluation_detailEntity> entities)
{
return Mapper.Map<List<eva_create_evaluation_detail_firstdocViewModel>>(entities);
}
#endregion
#region Public Functions
#region Query Functions
public string GetWorkTimeText(DateTime? startDate, DateTime? endDate)
{
if (!endDate.HasValue || !startDate.HasValue)
return "";
int monthsApart = 12 * (startDate.Value.Year - endDate.Value.Year) + startDate.Value.Month - endDate.Value.Month;
if (Math.Abs(monthsApart) < 4)
{
return "ปฏิบัติงานไม่ครบ 4 เดือน";
}
return "";
}
public eva_create_evaluation_detail_firstdocViewModel Get(int id)
{
var allemp = emp.GetListByemployee_type(null, null);
var endDate = (from m_eva_create_evaluation_detail_agreement in _repository.Context.eva_create_evaluation_detail
join fk_eva_create_evaluation10 in _repository.Context.eva_create_evaluation on m_eva_create_evaluation_detail_agreement.create_evaluation_id equals fk_eva_create_evaluation10.id
into eva_create_evaluationResult10
from fk_eva_create_evaluationResult10 in eva_create_evaluationResult10.DefaultIfEmpty()
join i in _repository.Context.eva_performance_plan_detail
on fk_eva_create_evaluationResult10.performance_plan_id equals i.performance_plan_id
where m_eva_create_evaluation_detail_agreement.id == id
select i.end_date).Max();
var data = (
from m_eva_create_evaluation_detail_agreement in _repository.Context.eva_create_evaluation_detail
join fk_external_employee in allemp on m_eva_create_evaluation_detail_agreement.employee_id equals fk_external_employee.id
into external_employeeResult
from fk_external_employee in external_employeeResult.DefaultIfEmpty()
join fk_external_chief in allemp on m_eva_create_evaluation_detail_agreement.chief equals fk_external_chief.id
into external_chiefResult
from fk_external_chief in external_chiefResult.DefaultIfEmpty()
join fk_eva_create_evaluation10 in _repository.Context.eva_create_evaluation on m_eva_create_evaluation_detail_agreement.create_evaluation_id equals fk_eva_create_evaluation10.id
into eva_create_evaluationResult10
from fk_eva_create_evaluationResult10 in eva_create_evaluationResult10.DefaultIfEmpty()
where m_eva_create_evaluation_detail_agreement.id == id
orderby m_eva_create_evaluation_detail_agreement.created descending
select new eva_create_evaluation_detail_firstdocWithSelectionViewModel()
{
id = m_eva_create_evaluation_detail_agreement.id,
evaluation_round = fk_eva_create_evaluationResult10.eva_performance_plan.display_text,
employee_code = fk_external_employee.employee_no,
employee_fullname = fk_external_employee.fullname,
employee_position = fk_external_employee.position_name,
employee_position_type = fk_external_employee.position_type_name,
employee_position_level = fk_external_employee.position_level_text,
employee_org = fk_external_employee.department_name,
chief_fullname = fk_external_chief.fullname,
chief_position = fk_external_chief.position_name,
create_evaluation_id = m_eva_create_evaluation_detail_agreement.create_evaluation_id,
org_id = fk_external_employee.department_id,
search_employee_code = fk_external_employee.employee_no,
search_employee_fullname = fk_external_employee.fullname,
status_self = m_eva_create_evaluation_detail_agreement.status_self,
status_chief = m_eva_create_evaluation_detail_agreement.status_chief,
status_supervisor = m_eva_create_evaluation_detail_agreement.status_supervisor,
org_id_external_linkage_external_name = fk_external_employee.department_name,
remark_hrm_work_record = fk_external_employee.remark_hrm_work_record
+ GetWorkTimeText(fk_external_employee.packing_date, endDate),
score1 = fk_eva_create_evaluationResult10.score1,
score2 = fk_eva_create_evaluationResult10.score2,
isActive = m_eva_create_evaluation_detail_agreement.isActive,
Created = m_eva_create_evaluation_detail_agreement.created,
Updated = m_eva_create_evaluation_detail_agreement.updated
}
).ToList();
return data[0];
}
public eva_create_evaluation_detailEntity GetEntity(int id)
{
var entity = _repository.Get(id);
return entity;
}
public DataContext GetContext()
{
return _repository.Context;
}
public eva_create_evaluation_detail_firstdocWithSelectionViewModel GetWithSelection(int id)
{
var entity = Get(id);
var i = Mapper.Map<eva_create_evaluation_detail_firstdocWithSelectionViewModel>(entity);
i.item_org_id = ext.GetDepartmentData();
return i;
}
public eva_create_evaluation_detail_firstdocWithSelectionViewModel GetBlankItem()
{
var i = new eva_create_evaluation_detail_firstdocWithSelectionViewModel();
i.item_org_id = ext.GetDepartmentData();
return i;
}
public List<eva_create_evaluation_detail_firstdocViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id)
{
var model = new eva_create_evaluation_detail_firstdocSearchModel();
model.create_evaluation_id = create_evaluation_id;
return GetListBySearch(model, emp_id);
}
public List<eva_create_evaluation_detail_firstdocViewModel> GetListBySearch(eva_create_evaluation_detail_firstdocSearchModel model, int? emp_id)
{
var allemp = emp.GetListByemployee_type(null, null);
var data = (
from m_eva_create_evaluation_detail_agreement in _repository.Context.eva_create_evaluation_detail
join fk_external_employee in allemp on m_eva_create_evaluation_detail_agreement.employee_id equals fk_external_employee.id
into external_employeeResult
from fk_external_employee in external_employeeResult.DefaultIfEmpty()
join fk_external_chief in allemp on m_eva_create_evaluation_detail_agreement.chief equals fk_external_chief.id
into external_chiefResult
from fk_external_chief in external_chiefResult.DefaultIfEmpty()
join fk_eva_create_evaluation10 in _repository.Context.eva_create_evaluation on m_eva_create_evaluation_detail_agreement.create_evaluation_id equals fk_eva_create_evaluation10.id
into eva_create_evaluationResult10
from fk_eva_create_evaluationResult10 in eva_create_evaluationResult10.DefaultIfEmpty()
join fk_plan in _repository.Context.eva_performance_plan on fk_eva_create_evaluationResult10.performance_plan_id equals fk_plan.id
into planResult
from fk_planResult in planResult.DefaultIfEmpty()
where 1 == 1
&& (m_eva_create_evaluation_detail_agreement.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
&& (fk_external_employee.department_id == model.org_id || !model.org_id.HasValue)
&& (fk_external_employee.employee_no == model.search_employee_code || string.IsNullOrEmpty(model.search_employee_code))
&& (fk_external_employee.fullname.Contains(model.search_employee_fullname) || string.IsNullOrEmpty(model.search_employee_fullname))
&& m_eva_create_evaluation_detail_agreement.employee_id == emp_id
orderby m_eva_create_evaluation_detail_agreement.created descending
select new eva_create_evaluation_detail_firstdocViewModel()
{
id = m_eva_create_evaluation_detail_agreement.id,
evaluation_round = fk_eva_create_evaluationResult10.eva_performance_plan.theTime.ToString(),
employee_code = fk_external_employee.employee_no,
employee_fullname = fk_external_employee.fullname,
employee_position = fk_external_employee.position_name,
employee_position_type = fk_external_employee.employee_type_name,
employee_position_level = fk_external_employee.position_level_text,
employee_org = fk_external_employee.department_name,
chief_fullname = fk_external_chief.fullname,
chief_position = fk_external_chief.position_name,
create_evaluation_id = m_eva_create_evaluation_detail_agreement.create_evaluation_id,
org_id = fk_external_employee.department_id,
search_employee_code = fk_external_employee.employee_no,
search_employee_fullname = fk_external_employee.fullname,
status_self = m_eva_create_evaluation_detail_agreement.status_self,
status_chief = m_eva_create_evaluation_detail_agreement.status_chief,
status_supervisor = m_eva_create_evaluation_detail_agreement.status_supervisor,
org_id_external_linkage_external_name = fk_external_employee.department_name,
status_self_click_date = m_eva_create_evaluation_detail_agreement.status_self_click_date,
status_chief_click_date = m_eva_create_evaluation_detail_agreement.status_chief_click_date,
status_supervisor_click_date = m_eva_create_evaluation_detail_agreement.status_supervisor_click_date,
plan_round_year = checkNull(fk_planResult.theTime) + "/" + checkNull(fk_planResult.fiscal_year),
isActive = m_eva_create_evaluation_detail_agreement.isActive,
Created = m_eva_create_evaluation_detail_agreement.created,
Updated = m_eva_create_evaluation_detail_agreement.updated
}
).ToList();
return data;
}
private string checkNull(object i)
{
if (i != null)
{
return i.ToString();
}
return "";
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using TTSW.EF;
using TTSW.Utils;
using TTSW.Constant;
using TTSW.Common;
namespace TodoAPI2.Models
{
public class eva_create_evaluation_detail_firstdocViewModel : BaseViewModel2<int>
{
public string evaluation_round { get; set; }
public string employee_code { get; set; }
public string employee_fullname { get; set; }
public string employee_position { get; set; }
public string employee_position_type { get; set; }
public string employee_position_level { get; set; }
public string employee_org { get; set; }
public string chief_fullname { get; set; }
public string chief_position { get; set; }
public int? create_evaluation_id { get; set; }
public int? org_id { get; set; }
public string search_employee_code { get; set; }
public string search_employee_fullname { get; set; }
public string org_id_external_linkage_external_name { get; set; }
public string status_self { get; set; }
public string status_chief { get; set; }
public string status_supervisor { get; set; }
public string remark_hrm_work_record { get; set; }
public string plan_round_year { get; set; }
public DateTime? status_self_click_date { get; set; }
public DateTime? status_chief_click_date { get; set; }
public DateTime? status_supervisor_click_date { get; set; }
public decimal? score1 { get; set; }
public decimal? score2 { get; set; }
public string txt_status_self { get { return getStatusText(status_self) + MyHelper.GetDateStringForReport(status_self_click_date); } }
public string txt_status_chief { get { return getStatusText(status_chief) + MyHelper.GetDateStringForReport(status_chief_click_date); } }
public string txt_status_supervisor { get { return getStatusText(status_supervisor) + MyHelper.GetDateStringForReport(status_supervisor_click_date); } }
private string getStatusText(string s)
{
if (!string.IsNullOrEmpty(s))
{
if (s == "Y")
{
return "ส่งแบบประเมินแล้ว <br/>";
}
else if (s == "N")
{
return "ตีกลับ <br/>";
}
}
return " ";
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TodoAPI2.Models
{
public class eva_create_evaluation_detail_firstdocWithSelectionViewModel: eva_create_evaluation_detail_firstdocViewModel
{
public List<external_linkageViewModel> item_org_id { get; set; }
}
}