ปรับปรุงรายงานกรอบวงเงิน
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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_limit_frame_groupService : IBaseService2<Guid, eva_limit_frame_groupInputModel, eva_limit_frame_groupViewModel>
|
||||
{
|
||||
new eva_limit_frame_groupViewModel Insert(eva_limit_frame_groupInputModel model, bool is_force_save);
|
||||
new eva_limit_frame_groupViewModel Update(Guid id, eva_limit_frame_groupInputModel model, bool is_force_save);
|
||||
List<eva_limit_frame_groupViewModel> GetListBygroup_guid(Guid? group_guid);
|
||||
List<eva_limit_frame_groupViewModel> GetListBySearch(eva_limit_frame_groupSearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_limit_frame_groupInputModel> model, bool is_force_save);
|
||||
eva_limit_frame_groupWithSelectionViewModel GetWithSelection(Guid id);
|
||||
eva_limit_frame_groupWithSelectionViewModel GetBlankItem();
|
||||
|
||||
void RefreshAutoFieldOfAllData();
|
||||
eva_limit_frame_groupEntity GetEntity(Guid id);
|
||||
DataContext GetContext();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
47
Models/eva_limit_frame_group/eva_limit_frame_groupEntity.cs
Normal file
47
Models/eva_limit_frame_group/eva_limit_frame_groupEntity.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
using System.IO;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_limit_frame_groupEntity : BaseEntity2<Guid>
|
||||
{
|
||||
|
||||
|
||||
[ForeignKey("frame_plan_guid")]
|
||||
public eva_limit_frame_planEntity eva_limit_frame_plan_frame_plan_guid { get; set; }
|
||||
public Guid? frame_plan_guid { get; set; }
|
||||
|
||||
[ForeignKey("group_guid")]
|
||||
public eva_evaluation_groupEntity eva_evaluation_group_group_guid { get; set; }
|
||||
public Guid? group_guid { get; set; }
|
||||
|
||||
public decimal? limit_frame_295 { get; set; }
|
||||
|
||||
public decimal? total_salary { get; set; }
|
||||
|
||||
public decimal? total_salary_limit { get; set; }
|
||||
|
||||
public decimal? total_salary_limit_rounded { get; set; }
|
||||
|
||||
|
||||
public void SetAutoField(DataContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void DoAfterInsertUpdate(DataContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
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_limit_frame_groupInputModel
|
||||
{
|
||||
|
||||
public Guid? id { get; set; }
|
||||
|
||||
public Guid? frame_plan_guid { get; set; }
|
||||
|
||||
public Guid? group_guid { get; set; }
|
||||
|
||||
public decimal? limit_frame_295 { get; set; }
|
||||
|
||||
public decimal? total_salary { get; set; }
|
||||
|
||||
public decimal? total_salary_limit { get; set; }
|
||||
|
||||
public decimal? total_salary_limit_rounded { get; set; }
|
||||
|
||||
public string active_mode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_limit_frame_groupReportRequestModel : eva_limit_frame_groupSearchModel
|
||||
{
|
||||
public string filetype { get; set; }
|
||||
|
||||
public string contentType { get { return MyHelper.GetContentType(filetype); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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_limit_frame_groupSearchModel
|
||||
{
|
||||
|
||||
public Guid id { get; set; }
|
||||
|
||||
public Guid? frame_plan_guid { get; set; }
|
||||
|
||||
public Guid? group_guid { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
301
Models/eva_limit_frame_group/eva_limit_frame_groupService.cs
Normal file
301
Models/eva_limit_frame_group/eva_limit_frame_groupService.cs
Normal file
@@ -0,0 +1,301 @@
|
||||
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_limit_frame_groupService : Ieva_limit_frame_groupService
|
||||
{
|
||||
private IBaseRepository2<eva_limit_frame_groupEntity, Guid> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
|
||||
public eva_limit_frame_groupService(IBaseRepository2<eva_limit_frame_groupEntity, Guid> repository, IMyDatabase mydb, Iexternal_linkageService inext)
|
||||
{
|
||||
_repository = repository;
|
||||
db = mydb;
|
||||
ext = inext;
|
||||
}
|
||||
|
||||
#region Private Functions
|
||||
private eva_limit_frame_groupEntity GetEntity(eva_limit_frame_groupInputModel model)
|
||||
{
|
||||
return Mapper.Map<eva_limit_frame_groupEntity>(model);
|
||||
}
|
||||
private List<eva_limit_frame_groupEntity> GetEntityList(List<eva_limit_frame_groupInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_limit_frame_groupEntity>>(models);
|
||||
}
|
||||
private eva_limit_frame_groupViewModel GetDto(eva_limit_frame_groupEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_limit_frame_groupViewModel>(entity);
|
||||
}
|
||||
private List<eva_limit_frame_groupViewModel> GetDtoList(List<eva_limit_frame_groupEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_limit_frame_groupViewModel>>(entities);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
#region Query Functions
|
||||
|
||||
public eva_limit_frame_groupViewModel Get(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return GetDto(entity);
|
||||
}
|
||||
|
||||
public eva_limit_frame_groupEntity GetEntity(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public DataContext GetContext()
|
||||
{
|
||||
return _repository.Context;
|
||||
}
|
||||
|
||||
public eva_limit_frame_groupWithSelectionViewModel GetWithSelection(Guid id)
|
||||
{
|
||||
var entity = _repository.Get(id);
|
||||
var i = Mapper.Map<eva_limit_frame_groupWithSelectionViewModel>(entity);
|
||||
i.item_group_guid = (from x in _repository.Context.eva_evaluation_group select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
public eva_limit_frame_groupWithSelectionViewModel GetBlankItem()
|
||||
{
|
||||
var i = new eva_limit_frame_groupWithSelectionViewModel();
|
||||
i.item_group_guid = (from x in _repository.Context.eva_evaluation_group select x).ToList();
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public List<eva_limit_frame_groupViewModel> GetListBygroup_guid(Guid? group_guid)
|
||||
{
|
||||
var model = new eva_limit_frame_groupSearchModel();
|
||||
model.group_guid = group_guid;
|
||||
return GetListBySearch(model);
|
||||
}
|
||||
|
||||
public List<eva_limit_frame_groupViewModel> GetListBySearch(eva_limit_frame_groupSearchModel model)
|
||||
{
|
||||
var data = (
|
||||
from m_eva_limit_frame_group in _repository.Context.eva_limit_frame_group
|
||||
|
||||
join fk_eva_limit_frame_plan1 in _repository.Context.eva_limit_frame_plan on m_eva_limit_frame_group.frame_plan_guid equals fk_eva_limit_frame_plan1.id
|
||||
into eva_limit_frame_planResult1
|
||||
from fk_eva_limit_frame_planResult1 in eva_limit_frame_planResult1.DefaultIfEmpty()
|
||||
|
||||
join fk_eva_evaluation_group2 in _repository.Context.eva_evaluation_group on m_eva_limit_frame_group.group_guid equals fk_eva_evaluation_group2.id
|
||||
into eva_evaluation_groupResult2
|
||||
from fk_eva_evaluation_groupResult2 in eva_evaluation_groupResult2.DefaultIfEmpty()
|
||||
|
||||
|
||||
where
|
||||
1 == 1
|
||||
&& (!model.frame_plan_guid.HasValue || m_eva_limit_frame_group.frame_plan_guid == model.frame_plan_guid)
|
||||
&& (!model.group_guid.HasValue || m_eva_limit_frame_group.group_guid == model.group_guid)
|
||||
|
||||
|
||||
orderby m_eva_limit_frame_group.created descending
|
||||
select new eva_limit_frame_groupViewModel()
|
||||
{
|
||||
id = m_eva_limit_frame_group.id,
|
||||
frame_plan_guid = m_eva_limit_frame_group.frame_plan_guid,
|
||||
group_guid = m_eva_limit_frame_group.group_guid,
|
||||
limit_frame_295 = m_eva_limit_frame_group.limit_frame_295,
|
||||
total_salary = m_eva_limit_frame_group.total_salary,
|
||||
total_salary_limit = m_eva_limit_frame_group.total_salary_limit,
|
||||
total_salary_limit_rounded = m_eva_limit_frame_group.total_salary_limit_rounded,
|
||||
|
||||
frame_plan_guid_eva_limit_frame_plan_executed_date = fk_eva_limit_frame_planResult1.executed_date,
|
||||
group_guid_eva_evaluation_group_code = fk_eva_evaluation_groupResult2.code,
|
||||
|
||||
isActive = m_eva_limit_frame_group.isActive,
|
||||
Created = m_eva_limit_frame_group.created,
|
||||
Updated = m_eva_limit_frame_group.updated
|
||||
}
|
||||
).Take(1000).ToList();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Manipulation Functions
|
||||
|
||||
|
||||
|
||||
public eva_limit_frame_groupViewModel Insert(eva_limit_frame_groupInputModel model, bool is_force_save)
|
||||
{
|
||||
var entity = GetEntity(model);
|
||||
entity.id = Guid.NewGuid();
|
||||
|
||||
|
||||
entity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var inserted = _repository.Insert(entity);
|
||||
entity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Get(inserted.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.InsertWithoutCommit(entity);
|
||||
entity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Mapper.Map<eva_limit_frame_groupViewModel>(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public eva_limit_frame_groupViewModel Update(Guid id, eva_limit_frame_groupInputModel model, bool is_force_save)
|
||||
{
|
||||
var existingEntity = _repository.Get(id);
|
||||
if (existingEntity != null)
|
||||
{
|
||||
existingEntity.frame_plan_guid = model.frame_plan_guid;
|
||||
existingEntity.group_guid = model.group_guid;
|
||||
existingEntity.limit_frame_295 = model.limit_frame_295;
|
||||
existingEntity.total_salary = model.total_salary;
|
||||
existingEntity.total_salary_limit = model.total_salary_limit;
|
||||
existingEntity.total_salary_limit_rounded = model.total_salary_limit_rounded;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
|
||||
if (is_force_save)
|
||||
{
|
||||
var updated = _repository.Update(id, existingEntity);
|
||||
existingEntity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Get(updated.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.UpdateWithoutCommit(id, existingEntity);
|
||||
existingEntity.DoAfterInsertUpdate(_repository.Context);
|
||||
return Mapper.Map<eva_limit_frame_groupViewModel>(existingEntity);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_limit_frame_groupInputModel> model, bool is_force_save)
|
||||
{
|
||||
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.frame_plan_guid = i.frame_plan_guid;
|
||||
existingEntity.group_guid = i.group_guid;
|
||||
existingEntity.limit_frame_295 = i.limit_frame_295;
|
||||
existingEntity.total_salary = i.total_salary;
|
||||
existingEntity.total_salary_limit = i.total_salary_limit;
|
||||
existingEntity.total_salary_limit_rounded = i.total_salary_limit_rounded;
|
||||
|
||||
existingEntity.SetAutoField(_repository.Context);
|
||||
_repository.UpdateWithoutCommit(i.id.Value, existingEntity);
|
||||
}
|
||||
}
|
||||
else if (i.active_mode == "1" && !i.id.HasValue) // add
|
||||
{
|
||||
var entity = GetEntity(i);
|
||||
entity.id = Guid.NewGuid();
|
||||
entity.SetAutoField(_repository.Context);
|
||||
_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
|
||||
}
|
||||
}
|
||||
if (is_force_save)
|
||||
{
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
|
||||
return model.Count().ToString();
|
||||
}
|
||||
|
||||
public eva_limit_frame_groupViewModel SetAsActive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public eva_limit_frame_groupViewModel SetAsInactive(Guid id)
|
||||
{
|
||||
var updated = _repository.SetAsInActive(id);
|
||||
|
||||
return Get(updated.id);
|
||||
}
|
||||
public void Delete(Guid id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void RefreshAutoFieldOfAllData()
|
||||
{
|
||||
var all_items = from i in _repository.Context.eva_limit_frame_group
|
||||
select i;
|
||||
foreach (var item in all_items)
|
||||
{
|
||||
item.SetAutoField(_repository.Context);
|
||||
}
|
||||
_repository.Context.SaveChanges();
|
||||
}
|
||||
|
||||
private Dictionary<string,string> GetLookupForLog()
|
||||
{
|
||||
var i = new Dictionary<string, string>();
|
||||
|
||||
|
||||
i.Add("frame_plan_guid", "frame_plan_guid");
|
||||
i.Add("frame_plan_guid_eva_limit_frame_plan_executed_date", "frame_plan_guid");
|
||||
i.Add("group_guid", "กลุ่มการประเมิน");
|
||||
i.Add("group_guid_eva_evaluation_group_code", "กลุ่มการประเมิน");
|
||||
i.Add("limit_frame_295", "กรอบวงเงินที่กันไว้");
|
||||
i.Add("total_salary", "อัตราเงินเดือนรวม");
|
||||
i.Add("total_salary_limit", "วงเงินในการเลื่อนเงินเดือน");
|
||||
i.Add("total_salary_limit_rounded", "วงเงินในการเลื่อนเงินเดือน ที่ใช้จริง");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Match Item
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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_limit_frame_groupViewModel : BaseViewModel2<Guid>
|
||||
{
|
||||
|
||||
public Guid? frame_plan_guid { get; set; }
|
||||
|
||||
public Guid? group_guid { get; set; }
|
||||
|
||||
public decimal? limit_frame_295 { get; set; }
|
||||
|
||||
public decimal? total_salary { get; set; }
|
||||
|
||||
public decimal? total_salary_limit { get; set; }
|
||||
|
||||
public decimal? total_salary_limit_rounded { get; set; }
|
||||
|
||||
public DateTime? frame_plan_guid_eva_limit_frame_plan_executed_date { get; set; }
|
||||
public string group_guid_eva_evaluation_group_code { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class eva_limit_frame_groupWithSelectionViewModel: eva_limit_frame_groupViewModel
|
||||
{
|
||||
public List<eva_evaluation_groupEntity> item_group_guid { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user