兼容二次分配开始报表数据

parent 913f7556
...@@ -148,9 +148,8 @@ public ApiResponse GetAttendanceVacationHandsonTable(int allotId) ...@@ -148,9 +148,8 @@ public ApiResponse GetAttendanceVacationHandsonTable(int allotId)
/// 查询考勤记录 /// 查询考勤记录
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("Vacation/{allotId},{hospitalId}")] [HttpGet("Vacation/{allotId}")]
public ApiResponse<List<RecordAttendcance>> GetAttendanceVacation(int allotId) public ApiResponse<List<RecordAttendcance>> GetAttendanceVacation(int allotId)
{ {
return _attendanceService.GetAttendanceVacation(allotId); return _attendanceService.GetAttendanceVacation(allotId);
......
...@@ -191,7 +191,7 @@ public ApiResponse DeleteDeptDic([FromBody] DeptdicResponse request) ...@@ -191,7 +191,7 @@ public ApiResponse DeleteDeptDic([FromBody] DeptdicResponse request)
/// <summary> /// <summary>
/// 系统/标准科室字典 /// 系统/标准科室字典
/// </summary> /// </summary>
/// <param name="hospitalId">医院Id</param> /// <param name="allotId">allotId</param>
/// <param name="type">1系统科室 2标准科室 3核算单元 4行政后勤 5特殊核算组</param> /// <param name="type">1系统科室 2标准科室 3核算单元 4行政后勤 5特殊核算组</param>
/// <returns></returns> /// <returns></returns>
[Route("deptdic/{allotId}/dict/{type}")] [Route("deptdic/{allotId}/dict/{type}")]
......
...@@ -128,20 +128,6 @@ ...@@ -128,20 +128,6 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AccountController.HistoryDepartment(System.Int32)">
<summary>
用户过往科室
</summary>
<param name="userId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.DeleteHistoryDepartment(System.Int32)">
<summary>
删除用户过往科室
</summary>
<param name="historyId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AllotController.List(Performance.DtoModels.AllotRequest)"> <member name="M:Performance.Api.Controllers.AllotController.List(Performance.DtoModels.AllotRequest)">
<summary> <summary>
绩效列表 绩效列表
...@@ -352,7 +338,6 @@ ...@@ -352,7 +338,6 @@
查询考勤记录 查询考勤记录
</summary> </summary>
<param name="allotId"></param> <param name="allotId"></param>
<param name="hospitalId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AttendanceController.AttendanceBatch(System.Int32,System.Int32,Performance.DtoModels.SaveCollectData)"> <member name="M:Performance.Api.Controllers.AttendanceController.AttendanceBatch(System.Int32,System.Int32,Performance.DtoModels.SaveCollectData)">
...@@ -1752,7 +1737,7 @@ ...@@ -1752,7 +1737,7 @@
<summary> <summary>
系统/标准科室字典 系统/标准科室字典
</summary> </summary>
<param name="hospitalId">医院Id</param> <param name="allotId">allotId</param>
<param name="type">1系统科室 2标准科室 3核算单元 4行政后勤 5特殊核算组</param> <param name="type">1系统科室 2标准科室 3核算单元 4行政后勤 5特殊核算组</param>
<returns></returns> <returns></returns>
</member> </member>
......
...@@ -1085,6 +1085,21 @@ ...@@ -1085,6 +1085,21 @@
科室类型 科室类型
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ag_secondallot.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NewUnitType">
<summary>
变更核算组别
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NewAccountingUnit">
<summary>
变更核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.Year"> <member name="P:Performance.EntityModels.ag_secondallot.Year">
<summary> <summary>
...@@ -1095,11 +1110,6 @@ ...@@ -1095,11 +1110,6 @@
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ag_secondallot.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.RealGiveFee"> <member name="P:Performance.EntityModels.ag_secondallot.RealGiveFee">
<summary> <summary>
科室实发金额 科室实发金额
...@@ -8655,39 +8665,14 @@ ...@@ -8655,39 +8665,14 @@
父级ID 父级ID
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.sys_user_history"> <member name="P:Performance.EntityModels.sys_user.UnitType">
<summary> <summary>
用户角色关联表 核算组别
</summary>
</member>
<member name="P:Performance.EntityModels.sys_user_history.UserID">
<summary>
用户ID
</summary>
</member>
<member name="P:Performance.EntityModels.sys_user_history.RoleID">
<summary>
角色ID
</summary>
</member>
<member name="P:Performance.EntityModels.sys_user_history.RoleType">
<summary>
角色类型
</summary>
</member>
<member name="P:Performance.EntityModels.sys_user_history.RoleName">
<summary>
角色名称
</summary>
</member>
<member name="P:Performance.EntityModels.sys_user_history.Department">
<summary>
科室名称
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.sys_user_history.CreateDate"> <member name="P:Performance.EntityModels.sys_user.UnitCode">
<summary> <summary>
核算单元变更时间 核算序号
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.sys_user_hospital"> <member name="T:Performance.EntityModels.sys_user_hospital">
......
...@@ -75,5 +75,13 @@ public class sys_user ...@@ -75,5 +75,13 @@ public class sys_user
/// 父级ID /// 父级ID
/// </summary> /// </summary>
public Nullable<int> ParentID { get; set; } public Nullable<int> ParentID { get; set; }
/// <summary>
/// 核算组别
/// </summary>
public string UnitType { get; set; }
/// <summary>
/// 核算序号
/// </summary>
public string UnitCode { get; set; }
} }
} }
...@@ -34,6 +34,21 @@ public class ag_secondallot ...@@ -34,6 +34,21 @@ public class ag_secondallot
public string UnitType { get; set; } public string UnitType { get; set; }
/// <summary> /// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 变更核算组别
/// </summary>
public string NewUnitType { get; set; }
/// <summary>
/// 变更核算单元
/// </summary>
public string NewAccountingUnit { get; set; }
/// <summary>
/// 年 /// 年
/// </summary> /// </summary>
public Nullable<int> Year { get; set; } public Nullable<int> Year { get; set; }
...@@ -44,11 +59,6 @@ public class ag_secondallot ...@@ -44,11 +59,6 @@ public class ag_secondallot
public Nullable<int> Month { get; set; } public Nullable<int> Month { get; set; }
/// <summary> /// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 科室实发金额 /// 科室实发金额
/// </summary> /// </summary>
public Nullable<decimal> RealGiveFee { get; set; } public Nullable<decimal> RealGiveFee { get; set; }
......
...@@ -66,8 +66,8 @@ public enum UnitType ...@@ -66,8 +66,8 @@ public enum UnitType
[Description("医技组")] [Description("医技组")]
医技组 = 3, 医技组 = 3,
[Description("专家组")] //[Description("专家组")]
专家组 = 4, //专家组 = 4,
//[Description("其他")] //[Description("其他")]
//其他 = 5, //其他 = 5,
......
...@@ -8,4 +8,6 @@ public class UserInfoCenter ...@@ -8,4 +8,6 @@ public class UserInfoCenter
public sys_role URole { get; set; } public sys_role URole { get; set; }
public List<sys_hospital> Hospitals { get; set; } public List<sys_hospital> Hospitals { get; set; }
public List<int> HospitalIds => Hospitals?.Select(w => w.ID).ToList() ?? new List<int>(); public List<int> HospitalIds => Hospitals?.Select(w => w.ID).ToList() ?? new List<int>();
public bool IsSecondAdmin { get; set; }
} }
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace Performance.Infrastructure
{
public static partial class UtilExtensions
{
public static bool NotNullOrEmpty<T>(this IEnumerable<T> enumerable)
{
return enumerable != null && enumerable.Any();
}
}
}
...@@ -6,6 +6,32 @@ namespace Performance.Repository ...@@ -6,6 +6,32 @@ namespace Performance.Repository
{ {
public partial class PerforAgsecondallotRepository : PerforRepository<ag_secondallot> public partial class PerforAgsecondallotRepository : PerforRepository<ag_secondallot>
{ {
public IQueryable<ag_secondallot> GetSeconds(int[] hospitalIds, string[] unitType, string accountingUnit)
{
var secondallots = from ag in context.Set<ag_secondallot>()
join at in context.Set<per_allot>()
on ag.AllotId equals at.ID
where hospitalIds.Contains(at.HospitalId)
select ag;
return secondallots
.Where(w => (unitType.Contains(w.UnitType) && w.Department == accountingUnit) || unitType.Contains(w.NewUnitType) && w.NewAccountingUnit == accountingUnit);
}
public IQueryable<ag_secondallot> Get(int allotId, string[] unitType, string accountingUnit, params int[] status)
{
var secondallots = from ag in context.Set<ag_secondallot>()
where ag.AllotId == allotId
select ag;
secondallots = secondallots
.Where(w => (unitType.Contains(w.UnitType) && w.Department == accountingUnit) || unitType.Contains(w.NewUnitType) && w.NewAccountingUnit == accountingUnit);
if (status.Any())
return secondallots.Where(w => w.Status.HasValue && status.Contains(w.Status.Value));
return secondallots;
}
/// <summary> /// <summary>
/// 删除已提交的历史记录(ag_compute) /// 删除已提交的历史记录(ag_compute)
/// </summary> /// </summary>
......
...@@ -29,11 +29,14 @@ public UserInfoCenter GetUser(int userId) ...@@ -29,11 +29,14 @@ public UserInfoCenter GetUser(int userId)
where uh.UserID == user.ID where uh.UserID == user.ID
select h; select h;
var roleTypes = new int[] { (int)Role.科主任, (int)Role.护士长, (int)Role.特殊科室, (int)Role.行政科室, };
return new UserInfoCenter return new UserInfoCenter
{ {
User = user, User = user,
URole = roles.FirstOrDefault() ?? new sys_role(), URole = roles.FirstOrDefault() ?? new sys_role(),
Hospitals = hospitals.ToList() ?? new List<sys_hospital>(), Hospitals = hospitals.ToList() ?? new List<sys_hospital>(),
IsSecondAdmin = roleTypes.Contains(roles.FirstOrDefault()?.Type ?? 0),
}; };
} }
......
...@@ -276,7 +276,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot ...@@ -276,7 +276,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
var pairs = new[] var pairs = new[]
{ {
new { Name = "医生组临床科室单元核算表", Data = doctorWorkloadData, SheetType = SheetType.ComputeDoctorAccount, new { Name = "医生组临床科室单元核算表", Data = doctorWorkloadData, SheetType = SheetType.ComputeDoctorAccount,
UnitTypes = new List<UnitType> { UnitType.医生组, UnitType.医技组, UnitType.专家组, UnitType.其他医技组,UnitType.其他医生组 } }, UnitTypes = new List<UnitType> { UnitType.医生组, UnitType.医技组, UnitType.其他医技组,UnitType.其他医生组 } },
new { Name = "护理组临床科室单元核算表", Data = nurseWorkloadData, SheetType = SheetType.ComputeNurseAccount, new { Name = "护理组临床科室单元核算表", Data = nurseWorkloadData, SheetType = SheetType.ComputeNurseAccount,
UnitTypes = new List<UnitType> { UnitType.护理组, UnitType.其他护理组 } }, UnitTypes = new List<UnitType> { UnitType.护理组, UnitType.其他护理组 } },
}; };
...@@ -298,7 +298,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot ...@@ -298,7 +298,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
var econDoctor = economicData?.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit); var econDoctor = economicData?.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
var workDoctor = info.Data.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit); var workDoctor = info.Data.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
if (UnitType.专家组 == unitType || UnitType.其他医技组 == unitType || UnitType.其他医生组 == unitType || UnitType.其他护理组 == unitType) if (UnitType.其他医技组 == unitType || UnitType.其他医生组 == unitType || UnitType.其他护理组 == unitType)
{ {
econDoctor = economicData?.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit); econDoctor = economicData?.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit);
workDoctor = info.Data.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit); workDoctor = info.Data.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit);
......
...@@ -696,10 +696,10 @@ public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int useri ...@@ -696,10 +696,10 @@ public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int useri
if (reserveds != null && reserveds.Any()) if (reserveds != null && reserveds.Any())
{ {
var unitTpes = UnitTypeUtil.GetMaps(userInfo?.URole.Type);
Expression<Func<EmployeeReservedDto, bool>> exp = w => w.AccountingUnit == userInfo.User.Department; Expression<Func<EmployeeReservedDto, bool>> exp = w => w.AccountingUnit == userInfo.User.Department;
if (userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value)) if (userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
exp = exp.And(t => UnitTypeUtil.Maps[userInfo.URole.Type.Value].Contains(t.UnitType)); exp = exp.And(t => unitTpes.Contains(t.UnitType));
reserveds = reserveds.Where(exp.Compile())?.ToList(); reserveds = reserveds.Where(exp.Compile())?.ToList();
} }
......
...@@ -309,7 +309,7 @@ public List<DeptResponse> GetNursePerformance(int allotId) ...@@ -309,7 +309,7 @@ public List<DeptResponse> GetNursePerformance(int allotId)
/// <returns></returns> /// <returns></returns>
public List<DeptResponse> GetOtherPerformance(int allotId) public List<DeptResponse> GetOtherPerformance(int allotId)
{ {
return GetGroupPerformance(allotId, new List<int> { (int)UnitType.其他医技组, (int)UnitType.其他医生组, (int)UnitType.其他护理组, (int)UnitType.专家组 }); return GetGroupPerformance(allotId, new List<int> { (int)UnitType.其他医技组, (int)UnitType.其他医生组, (int)UnitType.其他护理组 });
} }
public List<DeptResponse> GetGroupPerformance(int allotId, List<int> group) public List<DeptResponse> GetGroupPerformance(int allotId, List<int> group)
{ {
...@@ -1512,7 +1512,7 @@ private UnitType TypeConversion(int? unitType) ...@@ -1512,7 +1512,7 @@ private UnitType TypeConversion(int? unitType)
{ {
UnitType type = (UnitType)unitType.Value; UnitType type = (UnitType)unitType.Value;
var docUnitTypes = new List<UnitType> { UnitType.专家组, UnitType.其他医生组, UnitType.其他医技组 }; var docUnitTypes = new List<UnitType> { UnitType.其他医生组, UnitType.其他医技组 };
if (docUnitTypes.Contains(type)) if (docUnitTypes.Contains(type))
type = UnitType.医生组; type = UnitType.医生组;
else if (type == UnitType.其他护理组) else if (type == UnitType.其他护理组)
......
...@@ -148,10 +148,11 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro ...@@ -148,10 +148,11 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro
public cof_accounting GetAccounting(int allotId, int roleType, string Department = null) public cof_accounting GetAccounting(int allotId, int roleType, string Department = null)
{ {
var unitTpes = UnitTypeUtil.GetMaps(roleType);
Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == allotId && t.AccountingUnit == Department; Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == allotId && t.AccountingUnit == Department;
if (UnitTypeUtil.Maps.ContainsKey(roleType)) if (UnitTypeUtil.Maps.ContainsKey(roleType))
exp = exp.And(t => UnitTypeUtil.Maps[roleType].Contains(t.UnitType)); exp = exp.And(t => unitTpes.Contains(t.UnitType));
var account = cofaccountingRepository.GetEntity(exp); var account = cofaccountingRepository.GetEntity(exp);
......
...@@ -139,9 +139,9 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri ...@@ -139,9 +139,9 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
var parameters = GetParameters(allot); var parameters = GetParameters(allot);
var center = _userRepository.GetUser(userId); var center = _userRepository.GetUser(userId);
var isSecondAdmin = UnitTypeUtil.Maps.ContainsKey(center?.URole.Type ?? 0); var isSecondAdmin = center.IsSecondAdmin;
var department = isSecondAdmin ? (center?.User.Department ?? "") : string.Empty; var department = isSecondAdmin ? (center?.User.Department ?? "") : string.Empty;
var unitType = UnitTypeUtil.Maps[center?.URole.Type ?? 0]; var unitType = UnitTypeUtil.GetMaps(center?.URole.Type ?? 0);
parameters.Add("@department", $"'{department}'"); parameters.Add("@department", $"'{department}'");
if (unitType != null && unitType.Any()) if (unitType != null && unitType.Any())
......
...@@ -145,7 +145,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null) ...@@ -145,7 +145,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
IEnumerable<cof_workitem> workitems, IEnumerable<CofDrugProp> medicineProps, IEnumerable<CofDrugProp> cmis, IEnumerable<CofDrugProp> inclines, bool isDoctor = false) IEnumerable<cof_workitem> workitems, IEnumerable<CofDrugProp> medicineProps, IEnumerable<CofDrugProp> cmis, IEnumerable<CofDrugProp> inclines, bool isDoctor = false)
{ {
var unittype = isDoctor var unittype = isDoctor
? new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString(), UnitType.专家组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.特殊核算组.ToString() } ? new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.特殊核算组.ToString() }
: new List<string> { UnitType.护理组.ToString(), UnitType.其他护理组.ToString() }; : new List<string> { UnitType.护理组.ToString(), UnitType.其他护理组.ToString() };
if ((medicineProps == null && cmis == null && inclines == null) || workitems == null) if ((medicineProps == null && cmis == null && inclines == null) || workitems == null)
......
...@@ -191,7 +191,7 @@ public List<per_employee> GetPersons(int allotId, int userId) ...@@ -191,7 +191,7 @@ public List<per_employee> GetPersons(int allotId, int userId)
var userInfo = perforUserRepository.GetUser(userId); var userInfo = perforUserRepository.GetUser(userId);
var dept = userInfo?.User.Department ?? ""; var dept = userInfo?.User.Department ?? "";
var unittype = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value)) var unittype = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
? UnitTypeUtil.Maps[userInfo.URole.Type.Value] ? UnitTypeUtil.GetMaps(userInfo.URole.Type.Value)
: new string[0]; : new string[0];
Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId; Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId;
...@@ -215,7 +215,7 @@ public PageList<per_employee> GetPersons(int allotId, int userId, PersonParamsRe ...@@ -215,7 +215,7 @@ public PageList<per_employee> GetPersons(int allotId, int userId, PersonParamsRe
var userInfo = perforUserRepository.GetUser(userId); var userInfo = perforUserRepository.GetUser(userId);
var dept = userInfo?.User.Department ?? ""; var dept = userInfo?.User.Department ?? "";
var unittype = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value)) var unittype = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
? UnitTypeUtil.Maps[userInfo.URole.Type.Value] ? UnitTypeUtil.GetMaps(userInfo.URole.Type.Value)
: new string[0]; : new string[0];
Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId; Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId;
...@@ -647,15 +647,25 @@ public List<TitleValue> DeptDics(int allotId, int type) ...@@ -647,15 +647,25 @@ public List<TitleValue> DeptDics(int allotId, int type)
/// <returns></returns> /// <returns></returns>
public object DeptWorkloadDetail(WorkDetailRequest request, int userId) public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
{ {
var center = perforUserRepository.GetUser(userId); var userInfo = perforUserRepository.GetUser(userId);
string[] unitTypes = UnitTypeUtil.Maps[center?.URole.Type ?? 0]; if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (unitTypes == null || !unitTypes.Any()) return new string[] { }; if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院");
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId); // 查询当前角色下科室的绩效
if (allot == null) UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes);
return null; if (unitTypes == null || !unitTypes.Any()) return Enumerable.Empty<DeptIncomeResponse>();
var data = perallotRepository.QueryWorkloadData(request.AllotId, request.AccountingUnit, unitTypes, allot.HospitalId); var accountingUnit = request.AccountingUnit;
var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin)
{
var secondList = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department);
accountingUnit = secondList.FirstOrDefault()?.Department;
unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType };
}
var data = perallotRepository.QueryWorkloadData(request.AllotId, accountingUnit, unitTypes, hospitalId);
if (data != null && data.Any()) if (data != null && data.Any())
{ {
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category }) return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
...@@ -677,20 +687,32 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId) ...@@ -677,20 +687,32 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
public object DeptIncomeDetail(WorkDetailRequest request, int userId) public IEnumerable<DeptIncomeResponse> DeptIncomeDetail(WorkDetailRequest request, int userId)
{ {
var center = perforUserRepository.GetUser(userId); var userInfo = perforUserRepository.GetUser(userId);
string[] unitTypes = UnitTypeUtil.Maps[center?.URole.Type ?? 0]; if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (unitTypes == null || !unitTypes.Any()) return new string[] { }; if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院");
// 查询当前角色下科室的绩效
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes);
if (unitTypes == null || !unitTypes.Any()) return Enumerable.Empty<DeptIncomeResponse>();
var accountingUnit = request.AccountingUnit;
var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin)
{
var secondList = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department);
accountingUnit = secondList.FirstOrDefault()?.Department;
unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType };
}
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null)
return null;
var sources = new[] { "门诊", "住院" }; var sources = new[] { "门诊", "住院" };
if (!sources.Contains(request.Source)) if (!sources.Contains(request.Source))
throw new PerformanceException($"数据来源错误,只支持:{string.Join(";", sources)}"); throw new PerformanceException($"数据来源错误,只支持:{string.Join(";", sources)}");
var data = perallotRepository.QueryIncomeData(request.AllotId, request.Source, request.AccountingUnit, unitTypes, allot.HospitalId); var data = perallotRepository.QueryIncomeData(request.AllotId, request.Source, accountingUnit, unitTypes, hospitalId);
if (data != null && data.Any()) if (data != null && data.Any())
{ {
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category }) return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
...@@ -704,7 +726,7 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId) ...@@ -704,7 +726,7 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
}).OrderBy(t => t.PersonnelNumber).ThenBy(t => t.Category); }).OrderBy(t => t.PersonnelNumber).ThenBy(t => t.Category);
} }
return new string[] { }; return Enumerable.Empty<DeptIncomeResponse>();
} }
...@@ -715,7 +737,7 @@ public HandsonTable GetBatchPersonStructrue(int allotId) ...@@ -715,7 +737,7 @@ public HandsonTable GetBatchPersonStructrue(int allotId)
var result = new HandsonTable((int)SheetType.Unidentifiable, cols, permissions); var result = new HandsonTable((int)SheetType.Unidentifiable, cols, permissions);
var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == allotId); var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
var ss = deptdics?.Where(t => !new string[] { UnitType.专家组.ToString() }.Contains(t.UnitType)); var ss = deptdics?.Where(t => !new string[] { "专家组" }.Contains(t.UnitType));
if (result.Columns != null && result.Columns.Any()) if (result.Columns != null && result.Columns.Any())
{ {
var columns = new[] { "核算单元", "科室名称", "姓名", "员工工号", "银行卡号" }; var columns = new[] { "核算单元", "科室名称", "姓名", "员工工号", "银行卡号" };
......
...@@ -138,7 +138,7 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId, ...@@ -138,7 +138,7 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
?? new List<rep_selection>(); ?? new List<rep_selection>();
var userInfo = userRepository.GetUser(userId); var userInfo = userRepository.GetUser(userId);
var isMedical = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value)); var isMedical = userInfo.IsSecondAdmin;
var department = userInfo?.User.Department ?? ""; var department = userInfo?.User.Department ?? "";
List<ReportData> result = new List<ReportData>(); List<ReportData> result = new List<ReportData>();
...@@ -359,13 +359,6 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection ...@@ -359,13 +359,6 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection
} }
return content; return content;
} }
private string GetUserDepartment(int userId)
{
var user = userRepository.GetEntity(t => t.ID == userId);
return user.Department;
}
} }
......
...@@ -120,6 +120,22 @@ ComputeService computeService ...@@ -120,6 +120,22 @@ ComputeService computeService
} }
#region 二次绩效列表与数据保存 #region 二次绩效列表与数据保存
//public List<ag_secondallot> GetSeconds(int userId)
//{
// var userInfo = userRepository.GetUser(userId);
// if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
// if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
// if (userInfo?.Hospitals == null) throw new NotImplementedException("当前用户暂未分配医院");
// // 查询当前角色下科室的绩效
// UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitType);
// var secondList = agsecondallotRepository.Get(userInfo.HospitalIds.ToArray(), unitType, userInfo.User.Department);
//}
/// <summary> /// <summary>
/// 获取二次绩效列表 /// 获取二次绩效列表
...@@ -146,13 +162,10 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -146,13 +162,10 @@ public List<SecondListResponse> GetSecondList(int userId)
var secondList = agsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && unitType.Contains(t.UnitType) && t.Department == userInfo.User.Department); var secondList = agsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && unitType.Contains(t.UnitType) && t.Department == userInfo.User.Department);
// 查询过往科室的绩效 // 查询过往科室的绩效
foreach (var item in userInfo.Historys) var histroys = agsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && unitType.Contains(t.NewUnitType) && t.NewAccountingUnit == userInfo.User.Department);
{
UnitTypeUtil.Maps.TryGetValue(item.RoleType ?? 0, out string[] histroyUnitType);
var histroys = agsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && histroyUnitType.Contains(t.UnitType) && t.Department == item.Department);
if (histroys != null && histroys.Any()) if (histroys != null && histroys.Any())
secondList.AddRange(histroys.ToArray()); secondList.AddRange(histroys.ToArray());
}
var list = _mapper.Map<List<SecondListResponse>>(secondList); var list = _mapper.Map<List<SecondListResponse>>(secondList);
// 二次分配只支持单医院 // 二次分配只支持单医院
...@@ -866,10 +879,11 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u ...@@ -866,10 +879,11 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
if (temps != null && temps.Any()) if (temps != null && temps.Any())
{ {
var userCenter = userRepository.GetUser(userId); var userCenter = userRepository.GetUser(userId);
var unitType = UnitTypeUtil.GetMaps(userCenter?.URole.Type ?? 0);
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 (userCenter?.URole != null && userCenter.URole.Type.HasValue) if (userCenter?.URole != null && userCenter.URole.Type.HasValue)
exp = exp.And(t => UnitTypeUtil.Maps[userCenter.URole.Type.Value].Contains(t.UnitType)); exp = exp.And(t => unitType.Contains(t.UnitType));
var useTemp = agusetempRepository.GetEntity(exp); var useTemp = agusetempRepository.GetEntity(exp);
var secondTemps = _mapper.Map<List<SecondTempResponse>>(temps); var secondTemps = _mapper.Map<List<SecondTempResponse>>(temps);
...@@ -1581,10 +1595,10 @@ public bool AuditSubmit(ag_secondallot second, int userId) ...@@ -1581,10 +1595,10 @@ public bool AuditSubmit(ag_secondallot second, int userId)
throw new PerformanceException("二次绩效无效!"); throw new PerformanceException("二次绩效无效!");
var userCenter = userRepository.GetUser(userId); var userCenter = userRepository.GetUser(userId);
var unitType = UnitTypeUtil.GetMaps(userCenter?.URole.Type ?? 0);
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 (userCenter?.URole != null && userCenter.URole.Type.HasValue) if (userCenter?.URole != null && userCenter.URole.Type.HasValue)
exp = exp.And(t => UnitTypeUtil.Maps[userCenter.URole.Type.Value].Contains(t.UnitType)); exp = exp.And(t => unitType.Contains(t.UnitType));
var temp = agusetempRepository.GetEntity(exp); var temp = agusetempRepository.GetEntity(exp);
if (temp == null) if (temp == null)
...@@ -1661,7 +1675,7 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount) ...@@ -1661,7 +1675,7 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount)
} }
} }
} }
logger.LogCritical("程序虽然抛出异常但是还是执行了后续代码"); //logger.LogCritical("程序虽然抛出异常但是还是执行了后续代码");
} }
/// <summary> /// <summary>
...@@ -2418,19 +2432,31 @@ public dynamic Print(int secondId) ...@@ -2418,19 +2432,31 @@ public dynamic Print(int secondId)
public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out int isShowManage) public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out int isShowManage)
{ {
var userCenter = userRepository.GetUser(userId); var userInfo = userRepository.GetUser(userId);
if (userCenter?.User == null) throw new NotImplementedException("当前用户不存在"); if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院");
var deptDatas = new List<DeptDataDetails>(); var deptDatas = new List<DeptDataDetails>();
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
isShowManage = computeService.IsShowManage(allotId); isShowManage = computeService.IsShowManage(allotId);
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
// 未下发或未归档 则不可见 // 未下发或未归档 则不可见
var status = new int[] { (int)AllotStates.绩效下发, (int)AllotStates.归档 }; var status = new int[] { (int)AllotStates.绩效下发, (int)AllotStates.归档 };
if (!status.Contains(allot.States)) return deptDatas; if (!status.Contains(allot.States)) return deptDatas;
// 查询当前角色下科室的绩效
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes);
if (unitTypes == null || !unitTypes.Any()) return deptDatas;
var accountingUnit = userInfo.User.Department;
var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin)
{
var secondList = agsecondallotRepository.Get(allotId, unitTypes, userInfo.User.Department);
accountingUnit = secondList.FirstOrDefault()?.Department;
unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType };
}
Dictionary<int, List<string>> dict = new Dictionary<int, List<string>> Dictionary<int, List<string>> dict = new Dictionary<int, List<string>>
{ {
...@@ -2440,9 +2466,8 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out ...@@ -2440,9 +2466,8 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out
{ (int)Role.特殊科室, new List<string> { AccountUnitType.科主任.ToString() , AccountUnitType.护士长.ToString() } }, { (int)Role.特殊科室, new List<string> { AccountUnitType.科主任.ToString() , AccountUnitType.护士长.ToString() } },
}; };
if (!dict.Keys.Contains(userCenter?.URole.Type ?? 0)) return new List<DeptDataDetails>();
var computes = rescomputeRepository.GetEntities(t => t.AllotID == allotId && t.AccountingUnit == userCenter.User.Department && dict[userCenter.URole.Type.Value].Contains(t.AccountType)); var computes = rescomputeRepository.GetEntities(t => t.AllotID == allotId && t.AccountingUnit == accountingUnit && unitTypes.Contains(t.AccountType));
if (computes == null || !computes.Any()) return new List<DeptDataDetails>(); if (computes == null || !computes.Any()) return new List<DeptDataDetails>();
foreach (var item in computes) foreach (var item in computes)
{ {
......
...@@ -23,11 +23,8 @@ public class UnitTypeUtil ...@@ -23,11 +23,8 @@ public class UnitTypeUtil
{ (int)Role.特殊科室, new string[]{ UnitType.特殊核算组.ToString(), } }, { (int)Role.特殊科室, new string[]{ UnitType.特殊核算组.ToString(), } },
{ (int)Role.行政科室, new string[]{ UnitType.行政后勤.ToString(), "行政工勤" } }, { (int)Role.行政科室, new string[]{ UnitType.行政后勤.ToString(), "行政工勤" } },
}; };
public class RoleUnitMap
{ public static string[] GetMaps(int? key) => (key.HasValue && Maps.ContainsKey(key.Value)) ? Maps[key.Value] : Array.Empty<string>();
public Role Role { get; set; }
public string[] UnitType { get; set; }
}
/// <summary> /// <summary>
/// 是否是行政后勤/工勤 /// 是否是行政后勤/工勤
......
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