二次绩效

parent debc4131
......@@ -52,10 +52,11 @@ public ApiResponse<UserIdentity> Login([FromBody]LoginRequest request)
var user = _userService.Login(request);
if (user == null)
return new ApiResponse<UserIdentity>(ResponseType.Fail, "用户不存在");
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole };
user.Hospital = _hospitalService.GetUserHopital(user.UserID);
user.Role = _roleService.GetUserRole(user.UserID);
user.IsHome = (user.Hospital != null && user.Hospital.Count > 1);
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().RoleID) : false;
if (string.IsNullOrEmpty(user.Token))
user.Token = Guid.NewGuid().ToString("N");
......@@ -105,8 +106,8 @@ public ApiResponse<List<UserResponse>> List([FromBody]ApiRequest request)
[HttpPost]
public ApiResponse<UserResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody]UserRequest request)
{
var userid = _claim.At(request.Token).UserID;
var user = _userService.Insert(request, userid);
var userIdentity = _claim.At(request.Token);
var user = _userService.Insert(request, userIdentity.UserID, userIdentity.IsAgainAdmin);
user.Role = request.Role;
return new ApiResponse<UserResponse>(ResponseType.OK, user);
}
......@@ -120,7 +121,8 @@ public ApiResponse<UserResponse> Insert([CustomizeValidator(RuleSet = "Insert"),
[HttpPost]
public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody]UserRequest request)
{
var user = _userService.Update(request);
var userIdentity = _claim.At(request.Token);
var user = _userService.Update(request, userIdentity.IsAgainAdmin);
user.Role = request.Role;
return new ApiResponse<UserResponse>(ResponseType.OK, user);
}
......
......@@ -106,12 +106,31 @@ public ApiResponse Import([FromForm] IFormCollection form)
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 生成绩效
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("generate")]
[HttpPost]
public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
{
var user = claimService.At(request);
var result = againAllotService.Generate(request, user);
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 查看绩效详情
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("detail")]
[HttpPost]
public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
{
var user = claimService.At(request);
var result = againAllotService.Detail(request, user);
return new ApiResponse(ResponseType.OK, new { result.AgainSituation, result.SheetExport });
}
}
......
......@@ -109,6 +109,19 @@ public AutoMapperConfigs()
CreateMap<res_accountdoctor, DoctorResponse>();
CreateMap<res_accountnurse, NurseResponse>();
//二次绩效
CreateMap<ag_header, PerHeader>();
CreateMap<PerHeader, ag_header>();
CreateMap<PerAgainData, ag_data>();
CreateMap<ag_data, PerAgainData>();
CreateMap<PerAgainEmployee, ag_employee>();
CreateMap<ag_employee, PerAgainEmployee>();
CreateMap<PerAgainSituation, ag_againsituation>();
CreateMap<ag_againsituation, PerAgainSituation>();
}
}
}
......@@ -6,115 +6,59 @@ namespace Performance.DtoModels
{
public class PerAgainSituation
{
private decimal? _departmentTotal;
private decimal? _nightShift;
private decimal? _bossPerfor;
private decimal? _award;
private decimal? _allowance;
private decimal? _allotPerfor;
private decimal? _jobPerfor;
private decimal? _workloadPerfor;
private decimal? _alonePerfor;
private decimal? _attendance;
private decimal? _departmentFactorAvg;
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightShift
{
get => _nightShift.HasValue ? Math.Round(_nightShift.Value, 2) : _nightShift;
set => _nightShift = value;
}
public Nullable<decimal> NightShift { get; set; }
/// <summary>
/// 科室总绩效
/// </summary>
public Nullable<decimal> DepartmentTotal
{
get => (_departmentTotal.HasValue ? Math.Round(_departmentTotal.Value, 2) : _departmentTotal);
set => _departmentTotal = value;
}
public Nullable<decimal> DepartmentTotal { get; set; }
/// <summary>
/// 护士长或科主任基础绩效
/// </summary>
public Nullable<decimal> BossPerfor
{
get => _bossPerfor.HasValue ? Math.Round(_bossPerfor.Value, 2) : _bossPerfor;
set => _bossPerfor = value;
}
public Nullable<decimal> BossPerfor { get; set; }
/// <summary>
/// 重点奖励
/// </summary>
public Nullable<decimal> Award
{
get => _award.HasValue ? Math.Round(_award.Value, 2) : _award;
set => _award = value;
}
public Nullable<decimal> Award { get; set; }
/// <summary>
/// 管理津贴
/// </summary>
public Nullable<decimal> Allowance
{
get => _allowance.HasValue ? Math.Round(_allowance.Value, 2) : _allowance;
set => _allowance = value;
}
public Nullable<decimal> Allowance { get; set; }
/// <summary>
/// 业绩分配绩效
/// </summary>
public Nullable<decimal> AllotPerfor
{
get => _allotPerfor.HasValue ? Math.Round(_allotPerfor.Value, 2) : _allotPerfor;
set => _allotPerfor = value;
}
public Nullable<decimal> AllotPerfor { get; set; }
/// <summary>
/// 职称绩效
/// </summary>
public Nullable<decimal> JobPerfor
{
get => _jobPerfor.HasValue ? Math.Round(_jobPerfor.Value, 2) : _jobPerfor;
set => _jobPerfor = value;
}
public Nullable<decimal> JobPerfor { get; set; }
/// <summary>
/// 工作量绩效
/// </summary>
public Nullable<decimal> WorkloadPerfor
{
get => _workloadPerfor.HasValue ? Math.Round(_workloadPerfor.Value, 2) : _workloadPerfor;
set => _workloadPerfor = value;
}
public Nullable<decimal> WorkloadPerfor { get; set; }
/// <summary>
/// 单独核算人员绩效
/// </summary>
public Nullable<decimal> AlonePerfor
{
get => _alonePerfor.HasValue ? Math.Round(_alonePerfor.Value, 2) : _alonePerfor;
set => _alonePerfor = value;
}
public Nullable<decimal> AlonePerfor { get; set; }
/// <summary>
/// 出勤
/// </summary>
public Nullable<decimal> Attendance
{
get => _attendance.HasValue ? Math.Round(_attendance.Value, 2) : _attendance;
set => _attendance = value;
}
public Nullable<decimal> Attendance { get; set; }
/// <summary>
/// 科室系数人均
/// </summary>
public Nullable<decimal> DepartmentFactorAvg
{
get => _departmentFactorAvg.HasValue ? Math.Round(_departmentFactorAvg.Value, 2) : _departmentFactorAvg;
set => _departmentFactorAvg = value;
}
public Nullable<decimal> DepartmentFactorAvg { get; set; }
}
}
......@@ -15,13 +15,16 @@ public class UserIdentity
public string Mail { get; set; }
public string Mobile { get; set; }
public int States { get; set; }
public bool IsHome { get; set; }
/// <summary>
/// 是否是二次绩效管理 是为true 否则为false
/// </summary>
public bool IsAgainAdmin { get; set; }
/// <summary>
/// 用户科室
/// </summary>
public string Department { get; set; }
public List<HospitalResponse> Hospital { get; set; }
public List<RoleResponse> Role { get; set; }
public List<RoleResponse> Role { get; set; }
public UserIdentity()
{
......
......@@ -12,6 +12,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
{
}
/// <summary> 二次分配概览 <summary>
public virtual DbSet<ag_againsituation> ag_againsituation { get; set; }
/// <summary> 二次分配不固定数据 <summary>
public virtual DbSet<ag_data> ag_data { get; set; }
/// <summary> 二次分配人员名单 <summary>
......
//-----------------------------------------------------------------------
// <copyright file=" ag_againsituation.cs">
// * FileName: 二次分配概览.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
/// 二次分配概览
/// </summary>
[Table("ag_againsituation")]
public class ag_againsituation
{
/// <summary>
///
/// </summary>
[Key]
public int ID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AgainAllotID { get; set; }
/// <summary>
/// 夜班费
/// </summary>
public Nullable<decimal> NightShift { get; set; }
/// <summary>
/// 科室总绩效
/// </summary>
public Nullable<decimal> DepartmentTotal { get; set; }
/// <summary>
/// 护士长或科主任基础绩效
/// </summary>
public Nullable<decimal> BossPerfor { get; set; }
/// <summary>
/// 重点奖励
/// </summary>
public Nullable<decimal> Award { get; set; }
/// <summary>
/// 管理津贴
/// </summary>
public Nullable<decimal> Allowance { get; set; }
/// <summary>
/// 业绩分配绩效
/// </summary>
public Nullable<decimal> AllotPerfor { get; set; }
/// <summary>
/// 职称绩效
/// </summary>
public Nullable<decimal> JobPerfor { get; set; }
/// <summary>
/// 工作量绩效
/// </summary>
public Nullable<decimal> WorkloadPerfor { get; set; }
/// <summary>
/// 单独核算人员绩效
/// </summary>
public decimal AlonePerfor { get; set; }
/// <summary>
/// 出勤
/// </summary>
public Nullable<decimal> Attendance { get; set; }
/// <summary>
/// 科室系数人均
/// </summary>
public Nullable<decimal> DepartmentFactorAvg { get; set; }
}
}
......@@ -37,6 +37,11 @@ public class per_againallot
public Nullable<DateTime> CreateDateTime { get; set; }
/// <summary>
/// 上传时间
/// </summary>
public Nullable<DateTime> UploadDateTime { get; set; }
/// <summary>
/// 科室名称
/// </summary>
public string Department { get; set; }
......@@ -47,6 +52,11 @@ public class per_againallot
public string Path { get; set; }
/// <summary>
/// 二次分配状态 0 数据未上传 1 数据已上传 2 正在生成绩效 3 绩效生成成功 4 绩效生成失败
/// </summary>
public Nullable<int> States { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
......
//-----------------------------------------------------------------------
// <copyright file=" ag_againsituation.cs">
// * FileName: ag_againsituation.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// ag_againsituation Repository
/// </summary>
public partial class PerforAgagainsituationRepository : PerforRepository<ag_againsituation>
{
public PerforAgagainsituationRepository(PerformanceDbContext context) : base(context)
{
}
}
}
......@@ -15,6 +15,7 @@ public class AgainAllotService : IAutoInjection
{
private Application application;
private AgainService againService;
private ConfigService configService;
private PerforCofagainRepository perforCofagainRepository;
private PerforPeragainallotRepository perforPeragainallotRepository;
private PerforResaccountdoctorRepository perforResaccountdoctorRepository;
......@@ -22,6 +23,12 @@ public class AgainAllotService : IAutoInjection
private PerforUserRepository perforUserRepository;
private PerforUserhospitalRepository perforUserhospitalRepository;
private PerforPerallotRepository perforPerallotRepository;
private PerforAgagainsituationRepository perforAgagainsituationRepository;
private PerforAgdataRepository perforAgdataRepository;
private PerforAgemployeeRepository perforAgemployeeRepository;
private PerforAgheaderRepository perforAgheaderRepository;
public AgainAllotService(IOptions<Application> options, AgainService againService,
PerforCofagainRepository perforCofagainRepository,
PerforPeragainallotRepository perforPeragainallotRepository,
......@@ -29,7 +36,12 @@ public class AgainAllotService : IAutoInjection
PerforResaccountnurseRepository perforResaccountnurseRepository,
PerforUserRepository perforUserRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perforPerallotRepository)
PerforPerallotRepository perforPerallotRepository,
PerforAgagainsituationRepository perforAgagainsituationRepository,
PerforAgdataRepository perforAgdataRepository,
PerforAgemployeeRepository perforAgemployeeRepository,
PerforAgheaderRepository perforAgheaderRepository,
ConfigService configService)
{
this.application = options.Value;
this.againService = againService;
......@@ -40,18 +52,28 @@ public class AgainAllotService : IAutoInjection
this.perforUserRepository = perforUserRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perforPerallotRepository = perforPerallotRepository;
this.perforAgagainsituationRepository = perforAgagainsituationRepository;
this.perforAgdataRepository = perforAgdataRepository;
this.perforAgemployeeRepository = perforAgemployeeRepository;
this.perforAgheaderRepository = perforAgheaderRepository;
this.configService = configService;
}
/// <summary>
/// 生成二次绩效
/// </summary>
/// <param name="request"></param>
public (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) Generate(AgainAllotRequest request, UserIdentity user)
public bool Generate(AgainAllotRequest request, UserIdentity user)
{
var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
if (againAllot == null || againAllot.ID == 0)
throw new PerformanceException("绩效二次分配不存在");
//清理二次绩效无用数据
configService.ClearAgain(againAllot.ID);
#region 基础信息
//获取基础配置信息
var config = perforCofagainRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
......@@ -66,9 +88,10 @@ public class AgainAllotService : IAutoInjection
var role = user.Role.FirstOrDefault();
if (role != null)
{
basicnumber = application.NurseRole == role.RoleID
? perforResaccountnurseRepository.GetEntity(t => t.AllotID == againAllot.AllotID && t.AccountingUnit == user.Department)?.RealGiveFee
: perforResaccountdoctorRepository.GetEntity(t => t.AllotID == againAllot.AllotID && t.AccountingUnit == user.Department)?.RealGiveFee;
if (application.NurseRole == role.RoleID)
basicnumber = perforResaccountnurseRepository.GetEntity(t => t.AllotID == againAllot.AllotID && t.AccountingUnit == user.Department)?.RealGiveFee;
else if (application.DirectorRole == role.RoleID)
basicnumber = perforResaccountdoctorRepository.GetEntity(t => t.AllotID == againAllot.AllotID && t.AccountingUnit == user.Department)?.RealGiveFee;
}
}
#endregion
......@@ -164,6 +187,42 @@ public class AgainAllotService : IAutoInjection
}
#endregion
#region 保存
var againsituation = Mapper.Map<ag_againsituation>(situation);
againsituation.AllotID = againAllot.AllotID;
againsituation.AgainAllotID = againAllot.ID;
perforAgagainsituationRepository.Add(againsituation);
var employeeList = Mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgemployeeRepository.AddRange(employeeList.ToArray());
var pHeader = Mapper.Map<ag_header>(perAgainExcel.Header);
pHeader.AllotID = againAllot.AllotID;
pHeader.AgainAllotID = againAllot.ID;
var cHeaderList = Mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgheaderRepository.Add(pHeader);
perforAgheaderRepository.AddRange(cHeaderList.ToArray());
var dataList = Mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgdataRepository.AddRange(dataList.ToArray());
#endregion
return true;
//return SheetFormat(perAgainExcel, situation);
}
/// <summary>
/// 绩效详情表格转换
/// </summary>
/// <param name="perAgainExcel"></param>
/// <param name="situation"></param>
/// <returns></returns>
private (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) SheetFormat(PerAgainExcel perAgainExcel, PerAgainSituation situation)
{
#region 表格显示
SheetExportResponse response = new SheetExportResponse("二次绩效分配表");
//返回表格展示数据结构
......@@ -228,6 +287,45 @@ public class AgainAllotService : IAutoInjection
return (response, situation);
}
/// <summary>
/// 查看二次分配详情及概览
/// </summary>
/// <param name="request"></param>
/// <param name="user"></param>
/// <returns></returns>
public (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) Detail(AgainAllotRequest request, UserIdentity user)
{
var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
if (againAllot == null || againAllot.ID == 0)
throw new PerformanceException("绩效二次分配不存在");
var situation = perforAgagainsituationRepository.GetEntity(t => t.AgainAllotID == againAllot.ID);
var againsituation = Mapper.Map<PerAgainSituation>(situation);
var againEmployee = perforAgemployeeRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var employeeList = Mapper.Map<List<PerAgainEmployee>>(againEmployee);
var header = perforAgheaderRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var headerList = Mapper.Map<List<PerHeader>>(header);
var data = perforAgdataRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var dataList = Mapper.Map<List<PerAgainData>>(data);
var pHead = header.FirstOrDefault(t => t.CellValue == "工作量绩效工资");
var head = Mapper.Map<PerHeader>(pHead);
var cHead = Mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资"));
head.Children = cHead;
var perAgainExcel = new PerAgainExcel
{
Header = head,
AgainData = Mapper.Map<List<PerAgainData>>(data),
AgainEmployee = Mapper.Map<List<PerAgainEmployee>>(againEmployee)
};
return SheetFormat(perAgainExcel, againsituation);
}
/// <summary>
/// 二次绩效新增记录
......
......@@ -112,18 +112,17 @@ public List<UserResponse> GetUserList(int userID)
/// 新增用户
/// </summary>
/// <param name="request"></param>
public UserResponse Insert(UserRequest request, int userid)
public UserResponse Insert(UserRequest request, int userid, bool isAgainAdmin)
{
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole };
if (null != _userRepository.GetEntity(t => t.Login == request.Login))
throw new PerformanceException("登录名重复");
if (null != _userRepository.GetEntity(t => t.Mobile == request.Mobile))
throw new PerformanceException("手机号重复");
if (request.Role == 3 && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("请选择科室");
if (roleArray.Contains(request.Role) && request.HosIDArray.Length > 1)
if (isAgainAdmin && request.HosIDArray.Length > 1)
throw new PerformanceException("二次绩效管理员只支持单家医院");
if (roleArray.Contains(request.Role) && string.IsNullOrEmpty(request.Department))
if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
var user = Mapper.Map<sys_user>(request);
......@@ -179,9 +178,8 @@ public bool SetHospital(int userId, int[] hosIDArray)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public UserResponse Update(UserRequest request)
public UserResponse Update(UserRequest request, bool isAgainAdmin)
{
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole };
var user = _userRepository.GetEntity(t => t.ID == request.ID);
if (null == user)
throw new PerformanceException($"用户不存在 UserId:{request.ID}");
......@@ -194,10 +192,10 @@ public UserResponse Update(UserRequest request)
if (null != vlist && vlist.Count() > 0)
throw new PerformanceException("手机号重复");
if (roleArray.Contains(request.Role) && string.IsNullOrEmpty(request.Department))
if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
if (roleArray.Contains(request.Role) && request.HosIDArray.Length > 1)
if (isAgainAdmin && request.HosIDArray.Length > 1)
throw new PerformanceException("二次绩效管理员只支持单家医院");
user.Login = request.Login;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment