行政后勤二次分配

parent 1a969928
...@@ -110,7 +110,7 @@ public ApiResponse SelfInfo() ...@@ -110,7 +110,7 @@ public ApiResponse SelfInfo()
user.Role = _roleService.GetUserRole(user.UserID); user.Role = _roleService.GetUserRole(user.UserID);
user.Hospital = _hospitalService.GetUserHopital(user.UserID); user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole }; int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false; user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
return new ApiResponse(ResponseType.OK, user); return new ApiResponse(ResponseType.OK, user);
} }
...@@ -179,7 +179,7 @@ public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"), ...@@ -179,7 +179,7 @@ public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"),
{ {
var userId = _claim.GetUserId(); var userId = _claim.GetUserId();
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole }; int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUserRole(userId); var roles = _roleService.GetUserRole(userId);
var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false; var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false;
......
...@@ -116,49 +116,49 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -116,49 +116,49 @@ public ApiResponse Import([FromForm] IFormCollection form)
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
/// <summary> ///// <summary>
/// 查看科室绩效 ///// 查看科室绩效
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("departmentdetail")] //[Route("departmentdetail")]
[HttpPost] //[HttpPost]
public ApiResponse DepartmentDetail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request) //public ApiResponse DepartmentDetail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
{ //{
var userId = claimService.GetUserId(); // var userId = claimService.GetUserId();
var roles = roleService.GetUserRole(userId); // var roles = roleService.GetUserRole(userId);
var department = claimService.GetUserClaim(JwtClaimTypes.Department); // var department = claimService.GetUserClaim(JwtClaimTypes.Department);
var again = againAllotService.GetAgainallot(request.AgainAllotID); // var again = againAllotService.GetAgainallot(request.AgainAllotID);
if (again == null) // if (again == null)
return new ApiResponse(ResponseType.Fail, "当前二次绩效ID无效"); // return new ApiResponse(ResponseType.Fail, "当前二次绩效ID无效");
if (roles.First().Type == application.DirectorRole) // if (roles.First().Type == application.DirectorRole)
{ // {
var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 1); // var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 1);
return new ApiResponse(ResponseType.OK, detail); // return new ApiResponse(ResponseType.OK, detail);
} // }
else if (roles.First().Type == application.NurseRole) // else if (roles.First().Type == application.NurseRole)
{ // {
var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 2); // var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 2);
return new ApiResponse(ResponseType.OK, detail); // return new ApiResponse(ResponseType.OK, detail);
} // }
return new ApiResponse(ResponseType.Fail, "当前用户角色无法识别"); // return new ApiResponse(ResponseType.Fail, "当前用户角色无法识别");
} //}
/// <summary> ///// <summary>
/// 生成绩效 ///// 生成绩效
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("generate")] //[Route("generate")]
[HttpPost] //[HttpPost]
public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request) //public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
{ //{
var userId = claimService.GetUserId(); // var userId = claimService.GetUserId();
var department = claimService.GetUserClaim(JwtClaimTypes.Department); // var department = claimService.GetUserClaim(JwtClaimTypes.Department);
var result = againAllotService.Generate(request, userId, department); // var result = againAllotService.Generate(request, userId, department);
return new ApiResponse(ResponseType.OK); // return new ApiResponse(ResponseType.OK);
} //}
/// <summary> /// <summary>
/// 查看绩效详情 /// 查看绩效详情
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
"DirectorRole": "4", "DirectorRole": "4",
//特殊科室二次绩效管理员 //特殊科室二次绩效管理员
"SpecialRole": "9", "SpecialRole": "9",
//行政科室二次绩效管理员
"OfficeRole": "10",
//邮件指定接收人 //邮件指定接收人
"Receiver": [ "chengxiang.li@suvalue.com", "486035085@qq.com" ], "Receiver": [ "chengxiang.li@suvalue.com", "486035085@qq.com" ],
// 抽取结果Excel文件保存地址 // 抽取结果Excel文件保存地址
......
...@@ -115,20 +115,6 @@ ...@@ -115,20 +115,6 @@
<param name="form"></param> <param name="form"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AgainAllotController.DepartmentDetail(Performance.DtoModels.AgainAllotRequest)">
<summary>
查看科室绩效
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AgainAllotController.Generate(Performance.DtoModels.AgainAllotRequest)">
<summary>
生成绩效
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AgainAllotController.Detail(Performance.DtoModels.AgainAllotRequest)"> <member name="M:Performance.Api.Controllers.AgainAllotController.Detail(Performance.DtoModels.AgainAllotRequest)">
<summary> <summary>
查看绩效详情 查看绩效详情
......
...@@ -49,6 +49,11 @@ ...@@ -49,6 +49,11 @@
特殊科室二次绩效管理员 特殊科室二次绩效管理员
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.AppSettings.Application.OfficeRole">
<summary>
行政科室二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.Receiver"> <member name="P:Performance.DtoModels.AppSettings.Application.Receiver">
<summary> <summary>
邮件指定接收人 邮件指定接收人
......
...@@ -31,6 +31,10 @@ public class Application ...@@ -31,6 +31,10 @@ public class Application
/// </summary> /// </summary>
public int SpecialRole { get; set; } public int SpecialRole { get; set; }
/// <summary> /// <summary>
/// 行政科室二次绩效管理员
/// </summary>
public int OfficeRole { get; set; }
/// <summary>
/// 邮件指定接收人 /// 邮件指定接收人
/// </summary> /// </summary>
public string[] Receiver { get; set; } public string[] Receiver { get; set; }
......
...@@ -37,8 +37,8 @@ public enum UnitType ...@@ -37,8 +37,8 @@ public enum UnitType
行政高层 = 10, 行政高层 = 10,
[Description("行政中层")] [Description("行政中层")]
行政中层 = 11, 行政中层 = 11,
[Description("行政勤")] [Description("行政勤")]
行政 = 12, 行政 = 12,
} }
public enum SheetType public enum SheetType
......
...@@ -64,170 +64,170 @@ public class AgainAllotService : IAutoInjection ...@@ -64,170 +64,170 @@ public class AgainAllotService : IAutoInjection
this.configService = configService; this.configService = configService;
} }
/// <summary> ///// <summary>
/// 生成二次绩效 ///// 生成二次绩效
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
public bool Generate(AgainAllotRequest request, int userId, string department) //public bool Generate(AgainAllotRequest request, int userId, string department)
{ //{
var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID); // var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
if (againAllot == null || againAllot.ID == 0) // if (againAllot == null || againAllot.ID == 0)
throw new PerformanceException("绩效二次分配不存在"); // throw new PerformanceException("绩效二次分配不存在");
var roles = roleService.GetRole(userId); // var roles = roleService.GetRole(userId);
perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; }); // perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; });
//清理二次绩效无用数据 // //清理二次绩效无用数据
configService.ClearAgain(againAllot.ID); // configService.ClearAgain(againAllot.ID);
try // try
{ // {
#region 基础信息 // #region 基础信息
//获取基础配置信息 // //获取基础配置信息
var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID); // var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID);
var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value; // var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value;
var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value; // var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value;
var days = config.FirstOrDefault(t => t.Type == 3)?.Value; // var days = config.FirstOrDefault(t => t.Type == 3)?.Value;
decimal? basicnumber = 0m; // decimal? basicnumber = 0m;
//获取科室实发绩效 // //获取科室实发绩效
if (roles != null) // if (roles != null)
{ // {
var role = roles.FirstOrDefault(); // var role = roles.FirstOrDefault();
if (role != null) // if (role != null)
{ // {
if (application.NurseRole == role.Type) // if (application.NurseRole == role.Type)
basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee; // basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
else if (application.DirectorRole == role.Type) // else if (application.DirectorRole == role.Type)
basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType != (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee; // basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType != (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
} // }
} // }
#endregion // #endregion
#region 计算 // #region 计算
//读取二次计算excel数据 // //读取二次计算excel数据
var perAgainExcel = againService.ReadData(againAllot); // var perAgainExcel = againService.ReadData(againAllot);
//护士长或科主任出勤 // //护士长或科主任出勤
var bossAttendance = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.JobTitle == "护士长")?.Attendance; // var bossAttendance = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.JobTitle == "护士长")?.Attendance;
//计算职称出勤系数、年资出勤系数 // //计算职称出勤系数、年资出勤系数
foreach (var item in perAgainExcel.AgainEmployee) // foreach (var item in perAgainExcel.AgainEmployee)
{ // {
item.JobAttendanceFactor = item.JobFactor * item.Attendance / days; // item.JobAttendanceFactor = item.JobFactor * item.Attendance / days;
item.YearAttendanceFactor = item.Attendance * item.YearFactor / days; // item.YearAttendanceFactor = item.Attendance * item.YearFactor / days;
} // }
//计算 科室系数人均 // //计算 科室系数人均
var departmentFactorAvg = basicnumber / perAgainExcel.AgainEmployee.Sum(t => t.YearAttendanceFactor); // var departmentFactorAvg = basicnumber / perAgainExcel.AgainEmployee.Sum(t => t.YearAttendanceFactor);
//二次分配科室概览 // //二次分配科室概览
PerAgainSituation situation = new PerAgainSituation // PerAgainSituation situation = new PerAgainSituation
{ // {
NightShift = perAgainExcel.AgainEmployee.Sum(t => t.NightShift), // NightShift = perAgainExcel.AgainEmployee.Sum(t => t.NightShift),
DepartmentTotal = basicnumber, // DepartmentTotal = basicnumber,
BossPerfor = departmentFactorAvg * bossAttendance / days, // BossPerfor = departmentFactorAvg * bossAttendance / days,
Award = perAgainExcel.AgainEmployee.Sum(t => t.Award), // Award = perAgainExcel.AgainEmployee.Sum(t => t.Award),
Allowance = perAgainExcel.AgainEmployee.Sum(t => t.Allowance), // Allowance = perAgainExcel.AgainEmployee.Sum(t => t.Allowance),
AlonePerfor = perAgainExcel.AgainEmployee.Sum(t => t.AlonePerfor), // AlonePerfor = perAgainExcel.AgainEmployee.Sum(t => t.AlonePerfor),
Attendance = days, // Attendance = days,
DepartmentFactorAvg = departmentFactorAvg // DepartmentFactorAvg = departmentFactorAvg
}; // };
//业绩二次分配科室概览:业绩分配绩效、职称绩效、工作量绩效 // //业绩二次分配科室概览:业绩分配绩效、职称绩效、工作量绩效
situation.AllotPerfor = situation.DepartmentTotal - situation.BossPerfor - situation.Award - situation.Allowance - situation.AlonePerfor; // situation.AllotPerfor = situation.DepartmentTotal - situation.BossPerfor - situation.Award - situation.Allowance - situation.AlonePerfor;
situation.JobPerfor = situation.AllotPerfor * jobfactor; // situation.JobPerfor = situation.AllotPerfor * jobfactor;
situation.WorkloadPerfor = situation.AllotPerfor * workfactor; // situation.WorkloadPerfor = situation.AllotPerfor * workfactor;
var rowList = perAgainExcel.AgainData.Select(t => t.RowNumber).Distinct().ToList(); // var rowList = perAgainExcel.AgainData.Select(t => t.RowNumber).Distinct().ToList();
//业绩二次分配科室动态数据:工作量得分 // //业绩二次分配科室动态数据:工作量得分
foreach (var rowNumber in rowList) // foreach (var rowNumber in rowList)
{ // {
var againEmployee = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.RowNumber == rowNumber); // var againEmployee = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.RowNumber == rowNumber);
var atRowList = perAgainExcel.AgainData.Where(t => t.RowNumber == rowNumber); // var atRowList = perAgainExcel.AgainData.Where(t => t.RowNumber == rowNumber);
decimal? sumValue = 0m; // decimal? sumValue = 0m;
foreach (var atRow in atRowList) // foreach (var atRow in atRowList)
sumValue += atRow.IsFactor == 1 ? atRow.IsFactor * atRow.CellValue : atRow.CellValue; // sumValue += atRow.IsFactor == 1 ? atRow.IsFactor * atRow.CellValue : atRow.CellValue;
sumValue = sumValue * againEmployee?.YearFactor; // sumValue = sumValue * againEmployee?.YearFactor;
var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "工作量得分"); // var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "工作量得分");
if (head == null) // if (head == null)
{ // {
perAgainExcel.Header.MergeCell++; // perAgainExcel.Header.MergeCell++;
var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow); // var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell); // var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
head = new PerHeader(pointrow, pointcell, "工作量得分", 1, 1, 1, null, 1); // head = new PerHeader(pointrow, pointcell, "工作量得分", 1, 1, 1, null, 1);
perAgainExcel.Header.Children.Add(head); // perAgainExcel.Header.Children.Add(head);
} // }
perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "工作量得分", sumValue, 1, 2, null, "", "", head.SignID)); // perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "工作量得分", sumValue, 1, 2, null, "", "", head.SignID));
} // }
//业绩二次分配科室动态数据:绩效工资 // //业绩二次分配科室动态数据:绩效工资
foreach (var rowNumber in rowList) // foreach (var rowNumber in rowList)
{ // {
var workvalue = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == rowNumber && t.TypeName == "工作量得分")?.CellValue; // var workvalue = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == rowNumber && t.TypeName == "工作量得分")?.CellValue;
var sumvalue = perAgainExcel.AgainData.Where(t => t.TypeName == "工作量得分").Sum(t => t.CellValue); // var sumvalue = perAgainExcel.AgainData.Where(t => t.TypeName == "工作量得分").Sum(t => t.CellValue);
var perforValue = workvalue / sumvalue * situation.WorkloadPerfor; // var perforValue = workvalue / sumvalue * situation.WorkloadPerfor;
var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "绩效工资"); // var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "绩效工资");
if (head == null) // if (head == null)
{ // {
perAgainExcel.Header.MergeCell++; // perAgainExcel.Header.MergeCell++;
var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow); // var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell); // var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
head = new PerHeader(pointrow, pointcell, "绩效工资", 1, 1, 1, null, 1); // head = new PerHeader(pointrow, pointcell, "绩效工资", 1, 1, 1, null, 1);
perAgainExcel.Header.Children.Add(head); // perAgainExcel.Header.Children.Add(head);
} // }
perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "绩效工资", perforValue, 1, 2, null, "", "", head.SignID)); // perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "绩效工资", perforValue, 1, 2, null, "", "", head.SignID));
} // }
//业绩二次分配科室:应发绩效、实发绩效 // //业绩二次分配科室:应发绩效、实发绩效
string[] jobArray = new string[] { "护士长", "科主任" }; // string[] jobArray = new string[] { "护士长", "科主任" };
foreach (var employee in perAgainExcel.AgainEmployee) // foreach (var employee in perAgainExcel.AgainEmployee)
{ // {
if (jobArray.Contains(employee.JobTitle)) // if (jobArray.Contains(employee.JobTitle))
{ // {
employee.GiveFee = situation.BossPerfor; // employee.GiveFee = situation.BossPerfor;
employee.RealGiveFee = situation.BossPerfor; // employee.RealGiveFee = situation.BossPerfor;
} // }
else // else
{ // {
employee.JobAttendancePerfor = situation.JobPerfor * employee.JobAttendanceFactor / perAgainExcel.AgainEmployee.Sum(t => t.JobAttendanceFactor); // employee.JobAttendancePerfor = situation.JobPerfor * employee.JobAttendanceFactor / perAgainExcel.AgainEmployee.Sum(t => t.JobAttendanceFactor);
var value = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == employee.RowNumber && t.TypeName == "绩效工资")?.CellValue; // var value = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == employee.RowNumber && t.TypeName == "绩效工资")?.CellValue;
employee.GiveFee = (employee.JobAttendancePerfor ?? 0) + (value ?? 0) + (employee.Award ?? 0) + (employee.Allowance ?? 0) + (employee.AlonePerfor ?? 0); // employee.GiveFee = (employee.JobAttendancePerfor ?? 0) + (value ?? 0) + (employee.Award ?? 0) + (employee.Allowance ?? 0) + (employee.AlonePerfor ?? 0);
employee.RealGiveFee = (employee.GiveFee ?? 0) + (employee.NightShift ?? 0); // employee.RealGiveFee = (employee.GiveFee ?? 0) + (employee.NightShift ?? 0);
} // }
} // }
#endregion // #endregion
#region 保存 // #region 保存
var againsituation = Mapper.Map<ag_againsituation>(situation); // var againsituation = Mapper.Map<ag_againsituation>(situation);
againsituation.AllotID = againAllot.AllotID; // againsituation.AllotID = againAllot.AllotID;
againsituation.AgainAllotID = againAllot.ID; // againsituation.AgainAllotID = againAllot.ID;
perforAgagainsituationRepository.Add(againsituation); // perforAgagainsituationRepository.Add(againsituation);
var employeeList = Mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee); // var employeeList = Mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; }); // employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgemployeeRepository.AddRange(employeeList.ToArray()); // perforAgemployeeRepository.AddRange(employeeList.ToArray());
var pHeader = Mapper.Map<ag_header>(perAgainExcel.Header); // var pHeader = Mapper.Map<ag_header>(perAgainExcel.Header);
pHeader.AllotID = againAllot.AllotID; // pHeader.AllotID = againAllot.AllotID;
pHeader.AgainAllotID = againAllot.ID; // pHeader.AgainAllotID = againAllot.ID;
var cHeaderList = Mapper.Map<List<ag_header>>(perAgainExcel.Header.Children); // var cHeaderList = Mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; }); // cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgheaderRepository.Add(pHeader); // perforAgheaderRepository.Add(pHeader);
perforAgheaderRepository.AddRange(cHeaderList.ToArray()); // perforAgheaderRepository.AddRange(cHeaderList.ToArray());
var dataList = Mapper.Map<List<ag_data>>(perAgainExcel.AgainData); // var dataList = Mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; }); // dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
perforAgdataRepository.AddRange(dataList.ToArray()); // perforAgdataRepository.AddRange(dataList.ToArray());
#endregion // #endregion
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
perforPeragainallotRepository.Update(againAllot, p => { p.States = 4; p.Remark = ex.ToString(); }); // perforPeragainallotRepository.Update(againAllot, p => { p.States = 4; p.Remark = ex.ToString(); });
} // }
perforPeragainallotRepository.Update(againAllot, p => { p.States = 3; }); // perforPeragainallotRepository.Update(againAllot, p => { p.States = 3; });
return true; // return true;
//return SheetFormat(perAgainExcel, situation); // //return SheetFormat(perAgainExcel, situation);
} //}
/// <summary> /// <summary>
/// 绩效详情表格转换 /// 绩效详情表格转换
......
...@@ -535,7 +535,7 @@ public List<res_reserved> GetReserved(int hospitalId, int year, int userid) ...@@ -535,7 +535,7 @@ public List<res_reserved> GetReserved(int hospitalId, int year, int userid)
if (!role.HasValue) if (!role.HasValue)
throw new PerformanceException("用户信息错误"); throw new PerformanceException("用户信息错误");
var roleTypes = new[] { options.Value.NurseRole, options.Value.DirectorRole, options.Value.SpecialRole }; var roleTypes = new[] { options.Value.NurseRole, options.Value.DirectorRole, options.Value.SpecialRole, options.Value.OfficeRole };
var reserveds = perforresreservedRepository.GetEntities(w => w.HospitalId == hospitalId && w.Year == year); var reserveds = perforresreservedRepository.GetEntities(w => w.HospitalId == hospitalId && w.Year == year);
...@@ -547,6 +547,8 @@ public List<res_reserved> GetReserved(int hospitalId, int year, int userid) ...@@ -547,6 +547,8 @@ public List<res_reserved> GetReserved(int hospitalId, int year, int userid)
reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && (w.UnitType.Contains(UnitType.医生组.ToString()) || w.UnitType.Contains(UnitType.医技组.ToString())) && w.AccountingUnit == user.Department)?.ToList(); reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && (w.UnitType.Contains(UnitType.医生组.ToString()) || w.UnitType.Contains(UnitType.医技组.ToString())) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.SpecialRole) else if (role.Value == options.Value.SpecialRole)
reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && w.UnitType.Contains(UnitType.特殊核算组.ToString()) && w.AccountingUnit == user.Department)?.ToList(); reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && w.UnitType.Contains(UnitType.特殊核算组.ToString()) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.OfficeRole)
reserveds = reserveds.Where(w => !string.IsNullOrEmpty(w.UnitType) && (w.UnitType.Contains(UnitType.行政中层.ToString()) || w.UnitType.Contains(UnitType.行政后勤.ToString())) && w.AccountingUnit == user.Department)?.ToList();
} }
return reserveds; return reserveds;
......
...@@ -272,7 +272,7 @@ public List<DeptResponse> GetOtherPerformance(int allotId) ...@@ -272,7 +272,7 @@ public List<DeptResponse> GetOtherPerformance(int allotId)
/// <returns></returns> /// <returns></returns>
public List<DeptResponse> GetOfficePerformance(int allotId) public List<DeptResponse> GetOfficePerformance(int allotId)
{ {
var unitType = new List<int> { (int)UnitType.行政 }; var unitType = new List<int> { (int)UnitType.行政 };
var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId) var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId)
?.OrderBy(t => t.UnitType) ?.OrderBy(t => t.UnitType)
......
...@@ -302,9 +302,10 @@ public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId) ...@@ -302,9 +302,10 @@ public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId)
Dictionary<int, string[]> dict = new Dictionary<int, string[]> Dictionary<int, string[]> dict = new Dictionary<int, string[]>
{ {
{ application.DirectorRole, new string[]{ UnitType.医生组.ToString(), UnitType.医技组.ToString() } }, { application.DirectorRole, new string[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new string[]{ UnitType.护理组.ToString() } }, { application.NurseRole, new string[]{ UnitType.护理组.ToString() } },
{ application.SpecialRole, new string[]{ UnitType.特殊核算组.ToString() } }, { application.SpecialRole, new string[]{ UnitType.特殊核算组.ToString() } },
{ application.OfficeRole, new string[]{ UnitType.行政中层.ToString(), UnitType.行政后勤.ToString()} },
}; };
if (dict.Keys.Contains(role.Type.Value)) if (dict.Keys.Contains(role.Type.Value))
......
...@@ -358,7 +358,8 @@ private bool IsMedical(int userId) ...@@ -358,7 +358,8 @@ private bool IsMedical(int userId)
{ {
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID); var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
if (role.Type == application.DirectorRole || role.Type == application.NurseRole) var roleTypes = new[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
if (role.Type.HasValue && roleTypes.Contains(role.Type.Value))
return true; return true;
else else
return false; return false;
......
...@@ -113,6 +113,8 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -113,6 +113,8 @@ public List<SecondListResponse> GetSecondList(int userId)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString()); exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
else if (role.Type == application.SpecialRole) else if (role.Type == application.SpecialRole)
exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString()); exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString());
else if (role.Type == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var secondList = perforAgsecondallotRepository.GetEntities(exp); var secondList = perforAgsecondallotRepository.GetEntities(exp);
//各科室绩效分配结果 //各科室绩效分配结果
...@@ -137,6 +139,8 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -137,6 +139,8 @@ public List<SecondListResponse> GetSecondList(int userId)
account = accountList?.FirstOrDefault(t => t.AllotID == item && t.UnitType == (int)UnitType.护理组); account = accountList?.FirstOrDefault(t => t.AllotID == item && t.UnitType == (int)UnitType.护理组);
else if (role.Type == application.SpecialRole) else if (role.Type == application.SpecialRole)
special = specialList?.FirstOrDefault(t => t.AllotID == item); special = specialList?.FirstOrDefault(t => t.AllotID == item);
else if (role.Type == application.OfficeRole)
account = accountList?.FirstOrDefault(t => t.AllotID == item && t.UnitType == (int)UnitType.行政后勤);
if (account == null && special == null) continue; if (account == null && special == null) continue;
...@@ -798,11 +802,18 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u ...@@ -798,11 +802,18 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
{ {
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID); var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
Dictionary<int, string[]> dic = new Dictionary<int, string[]>
{
{ application.DirectorRole, new[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString()} },
{ application.SpecialRole, new[]{ UnitType.特殊核算组.ToString() }},
{ application.OfficeRole, new[]{ UnitType.行政后勤.ToString() } },
};
Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == hospitalid && t.Department == department; Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == hospitalid && t.Department == department;
if (role.Type == application.DirectorRole) if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType)); exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
else if (role.Type == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
var useTemp = perforAgusetempRepository.GetEntity(exp); var useTemp = perforAgusetempRepository.GetEntity(exp);
var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps); var secondTemps = Mapper.Map<List<SecondTempResponse>>(temps);
...@@ -1130,6 +1141,10 @@ public bool DeleteWorkType(WorkloadRequest request) ...@@ -1130,6 +1141,10 @@ public bool DeleteWorkType(WorkloadRequest request)
return (UnitType.医生组.ToString(), user.Department); return (UnitType.医生组.ToString(), user.Department);
else if (role.Type == application.NurseRole) else if (role.Type == application.NurseRole)
return (UnitType.护理组.ToString(), user.Department); return (UnitType.护理组.ToString(), user.Department);
if (role.Type == application.SpecialRole)
return (UnitType.特殊核算组.ToString(), user.Department);
if (role.Type == application.OfficeRole)
return (UnitType.行政后勤.ToString(), user.Department);
else else
return ("", user.Department); return ("", user.Department);
} }
...@@ -1174,11 +1189,17 @@ public bool AuditSubmit(ag_secondallot second, int userId) ...@@ -1174,11 +1189,17 @@ public bool AuditSubmit(ag_secondallot second, int userId)
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID); var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
Dictionary<int, string[]> dic = new Dictionary<int, string[]>
{
{ application.DirectorRole, new[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString()} },
{ application.SpecialRole, new[]{ UnitType.特殊核算组.ToString() }},
{ application.OfficeRole, new[]{ UnitType.行政后勤.ToString() } },
};
Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == allot.HospitalId && t.Department == second.Department; Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == allot.HospitalId && t.Department == second.Department;
if (role.Type == application.DirectorRole) if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType)); exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType));
else if (role.Type == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
var temp = perforAgusetempRepository.GetEntity(exp); var temp = perforAgusetempRepository.GetEntity(exp);
if (temp == null) if (temp == null)
...@@ -1538,6 +1559,7 @@ public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId) ...@@ -1538,6 +1559,7 @@ public List<SecondPerforResponse> DeptComputeDetail(int userId, int allotId)
{ {
{ application.DirectorRole, AccountUnitType.科主任.ToString() }, { application.DirectorRole, AccountUnitType.科主任.ToString() },
{ application.NurseRole, AccountUnitType.护士长.ToString() }, { application.NurseRole, AccountUnitType.护士长.ToString() },
{ application.OfficeRole, AccountUnitType.行政中层.ToString() },
}; };
if (!dict.Keys.Contains(role.Type.Value)) return new List<SecondPerforResponse>(); if (!dict.Keys.Contains(role.Type.Value)) return new List<SecondPerforResponse>();
......
...@@ -27,6 +27,8 @@ public class UserService : IAutoInjection ...@@ -27,6 +27,8 @@ public class UserService : IAutoInjection
private PerforPerallotRepository _perforPerallotRepository; private PerforPerallotRepository _perforPerallotRepository;
private PerforImaccountbasicRepository _imaccountbasicRepository; private PerforImaccountbasicRepository _imaccountbasicRepository;
private PerforImspecialunitRepository _imspecialunitRepository; private PerforImspecialunitRepository _imspecialunitRepository;
private PerforResaccountRepository _resaccountRepository;
private PerforPerallotRepository _perallotRepository;
private PerforPerdeptdicRepository _perdeptdicRepository; private PerforPerdeptdicRepository _perdeptdicRepository;
public UserService(IOptions<Application> application, public UserService(IOptions<Application> application,
PerforSmsRepository smsRepository, PerforSmsRepository smsRepository,
...@@ -39,6 +41,8 @@ public class UserService : IAutoInjection ...@@ -39,6 +41,8 @@ public class UserService : IAutoInjection
PerforPerallotRepository perforPerallotRepository, PerforPerallotRepository perforPerallotRepository,
PerforImaccountbasicRepository imaccountbasicRepository, PerforImaccountbasicRepository imaccountbasicRepository,
PerforImspecialunitRepository imspecialunitRepository, PerforImspecialunitRepository imspecialunitRepository,
PerforResaccountRepository resaccountRepository,
PerforPerallotRepository perallotRepository,
PerforPerdeptdicRepository perdeptdicRepository) PerforPerdeptdicRepository perdeptdicRepository)
{ {
this.application = application.Value; this.application = application.Value;
...@@ -52,6 +56,8 @@ public class UserService : IAutoInjection ...@@ -52,6 +56,8 @@ public class UserService : IAutoInjection
this._perforPerallotRepository = perforPerallotRepository; this._perforPerallotRepository = perforPerallotRepository;
this._imaccountbasicRepository = imaccountbasicRepository; this._imaccountbasicRepository = imaccountbasicRepository;
this._imspecialunitRepository = imspecialunitRepository; this._imspecialunitRepository = imspecialunitRepository;
this._resaccountRepository = resaccountRepository;
this._perallotRepository = perallotRepository;
this._perdeptdicRepository = perdeptdicRepository; this._perdeptdicRepository = perdeptdicRepository;
} }
...@@ -148,16 +154,15 @@ public ApiResponse Delete(int iD) ...@@ -148,16 +154,15 @@ public ApiResponse Delete(int iD)
/// <param name="request"></param> /// <param name="request"></param>
public UserResponse Insert(UserRequest request, int userid) public UserResponse Insert(UserRequest request, int userid)
{ {
var isAgainAdmin = new int[] { application.DirectorRole, application.NurseRole }.Contains(request.Role);
if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1)) if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1))
throw new PerformanceException("登录名重复"); throw new PerformanceException("登录名重复");
//if (null != _userRepository.GetEntity(t => t.Mobile == request.Mobile && t.IsDelete == 1)) //if (null != _userRepository.GetEntity(t => t.Mobile == request.Mobile && t.IsDelete == 1))
// throw new PerformanceException("手机号重复"); // throw new PerformanceException("手机号重复");
if (request.Role == 3 && string.IsNullOrEmpty(request.Department)) if (request.Role == 3 && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("请选择科室"); throw new PerformanceException("请选择科室");
if (isAgainAdmin && request.HosIDArray.Length > 1) if (request.HosIDArray.Length > 1)
throw new PerformanceException("二次绩效管理员只支持单家医院"); throw new PerformanceException("二次绩效管理员只支持单家医院");
if (isAgainAdmin && string.IsNullOrEmpty(request.Department)) if (string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空"); throw new PerformanceException("二次绩效管理员科室不能为空");
var user = Mapper.Map<sys_user>(request); var user = Mapper.Map<sys_user>(request);
...@@ -326,7 +331,7 @@ public List<sys_role> RoleList(int userId) ...@@ -326,7 +331,7 @@ public List<sys_role> RoleList(int userId)
List<sys_role> result = new List<sys_role>() { role }; List<sys_role> result = new List<sys_role>() { role };
GetChildrenRole(roles, role.ID, result); GetChildrenRole(roles, role.ID, result);
return result?.Distinct().ToList(); return result?.OrderBy(w => w.Sort)?.Distinct().ToList();
} }
/// <summary> /// <summary>
...@@ -362,7 +367,24 @@ public List<TitleValue> Department(int hospitalId) ...@@ -362,7 +367,24 @@ public List<TitleValue> Department(int hospitalId)
var list = _perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId); var list = _perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
if (list == null || !list.Any()) return new List<TitleValue>(); if (list == null || !list.Any()) return new List<TitleValue>();
var result = list.Select(t => t.AccountingUnit).Distinct().OrderBy(t => t); var result = list.Select(t => t.AccountingUnit).Distinct().OrderBy(t => t).ToList();
// 补充行政科室
var states = new int[] { (int)AllotStates.Archive, (int)AllotStates.GenerateAccomplish };
var allots = _perallotRepository.GetEntities(w => w.HospitalId == hospitalId && states.Contains(w.States));
if (allots != null && allots.Any())
{
var allot = allots.OrderByDescending(w => w.Year).ThenByDescending(w => w.Month).FirstOrDefault();
if (allot != null)
{
var types = new int[] { (int)UnitType.行政中层, (int)UnitType.行政后勤 };
var accounts = _resaccountRepository.GetEntities(w => w.AllotID == allot.ID && w.UnitType.HasValue && types.Contains(w.UnitType.Value));
if (accounts != null && accounts.Any())
{
result.AddRange(accounts.Select(w => w.AccountingUnit));
}
}
}
return result?.Select(t => new TitleValue { Title = t, Value = t }).ToList(); return result?.Select(t => new TitleValue { Title = t, Value = t }).ToList();
} }
......
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