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

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);
......
...@@ -152,7 +152,7 @@ public int GetPrevAllot(per_allot allot) ...@@ -152,7 +152,7 @@ public int GetPrevAllot(per_allot allot)
return -1; return -1;
return allotId; return allotId;
} }
#endregion #endregion
#region 基础功能 #region 基础功能
...@@ -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>
/// 获取二次绩效列表 /// 获取二次绩效列表
...@@ -145,14 +161,11 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -145,14 +161,11 @@ public List<SecondListResponse> GetSecondList(int userId)
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitType); UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitType);
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);
{ if (histroys != null && histroys.Any())
UnitTypeUtil.Maps.TryGetValue(item.RoleType ?? 0, out string[] histroyUnitType); secondList.AddRange(histroys.ToArray());
var histroys = agsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && histroyUnitType.Contains(t.UnitType) && t.Department == item.Department);
if (histroys != null && histroys.Any())
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,20 +2432,32 @@ public dynamic Print(int secondId) ...@@ -2418,20 +2432,32 @@ 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>>
{ {
{ (int)Role.科主任, new List<string>{ AccountUnitType.科主任.ToString()} }, { (int)Role.科主任, new List<string>{ AccountUnitType.科主任.ToString()} },
...@@ -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>
/// 是否是行政后勤/工勤 /// 是否是行政后勤/工勤
......
using AutoMapper; using AutoMapper;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Services namespace Performance.Services
{ {
public class UserService : IAutoInjection public class UserService : IAutoInjection
{ {
private Application application;
private PerforUserRepository _userRepository;
private readonly IMapper _mapper; private readonly IMapper _mapper;
private PerforSmsRepository _smsRepository; private readonly PerforUserRepository _userRepository;
private PerforHospitalRepository _hospitalRepository; private readonly PerforSmsRepository _smsRepository;
private readonly PerforUserhistoryRepository _userhistoryRepository; private readonly PerforHospitalRepository _hospitalRepository;
private PerforUserhospitalRepository _userhospitalRepository; private readonly PerforUserhospitalRepository _userhospitalRepository;
private PerforRoleRepository _roleRepository; private readonly PerforRoleRepository _roleRepository;
private PerforUserroleRepository _userroleRepository; private readonly PerforUserroleRepository _userroleRepository;
private PerforImemployeeRepository _employeeRepository; private readonly PerforPerdeptdicRepository _perdeptdicRepository;
private PerforPerallotRepository _perforPerallotRepository; private readonly PerforCofaccountingRepository _perforCofaccountingRepository;
private PerforImaccountbasicRepository _imaccountbasicRepository;
private PerforImspecialunitRepository _imspecialunitRepository;
private PerforResaccountRepository _resaccountRepository;
private PerforPerallotRepository _perallotRepository;
private PerforPerdeptdicRepository _perdeptdicRepository;
private readonly PerforCofaccountingRepository perforCofaccountingRepository;
public UserService( public UserService(
IMapper mapper, IMapper mapper,
IOptions<Application> application,
PerforSmsRepository smsRepository, PerforSmsRepository smsRepository,
PerforUserRepository userRepository, PerforUserRepository userRepository,
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforUserhistoryRepository userhistoryRepository,
PerforUserhospitalRepository userhospitalRepository, PerforUserhospitalRepository userhospitalRepository,
PerforRoleRepository roleRepository, PerforRoleRepository roleRepository,
PerforUserroleRepository userroleRepository, PerforUserroleRepository userroleRepository,
PerforImemployeeRepository employeeRepository,
PerforPerallotRepository perforPerallotRepository,
PerforImaccountbasicRepository imaccountbasicRepository,
PerforImspecialunitRepository imspecialunitRepository,
PerforResaccountRepository resaccountRepository,
PerforPerallotRepository perallotRepository,
PerforPerdeptdicRepository perdeptdicRepository, PerforPerdeptdicRepository perdeptdicRepository,
PerforCofaccountingRepository perforCofaccountingRepository) PerforCofaccountingRepository perforCofaccountingRepository)
{ {
this.application = application.Value;
_userRepository = userRepository; _userRepository = userRepository;
_mapper = mapper; _mapper = mapper;
_smsRepository = smsRepository; _smsRepository = smsRepository;
_hospitalRepository = hospitalRepository; _hospitalRepository = hospitalRepository;
_userhistoryRepository = userhistoryRepository;
_userhospitalRepository = userhospitalRepository; _userhospitalRepository = userhospitalRepository;
_roleRepository = roleRepository; _roleRepository = roleRepository;
_userroleRepository = userroleRepository; _userroleRepository = userroleRepository;
_employeeRepository = employeeRepository;
_perforPerallotRepository = perforPerallotRepository;
_imaccountbasicRepository = imaccountbasicRepository;
_imspecialunitRepository = imspecialunitRepository;
_resaccountRepository = resaccountRepository;
_perallotRepository = perallotRepository;
_perdeptdicRepository = perdeptdicRepository; _perdeptdicRepository = perdeptdicRepository;
this.perforCofaccountingRepository = perforCofaccountingRepository; _perforCofaccountingRepository = perforCofaccountingRepository;
} }
/// <summary> /// <summary>
...@@ -546,11 +517,20 @@ public UserResponse InsertUser(UserRequest request, int userid) ...@@ -546,11 +517,20 @@ public UserResponse InsertUser(UserRequest request, int userid)
if (roleArray.Intersect(request.RoleArr).Any() && string.IsNullOrEmpty(request.Department)) if (roleArray.Intersect(request.RoleArr).Any() && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空"); throw new PerformanceException("二次绩效管理员科室不能为空");
var user = _mapper.Map<sys_user>(request); var user = _mapper.Map<sys_user>(request);
user.CreateDate = DateTime.Now; user.CreateDate = DateTime.Now;
user.CreateUser = userid; user.CreateUser = userid;
user.States = (int)States.Enabled; user.States = (int)States.Enabled;
user.Department = roleArray.Contains(request.RoleArr[0]) ? request.Department : ""; user.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]) ? request.Department : "";
if (UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]))
{
var uninTypes = UnitTypeUtil.GetMaps(request.RoleArr[0]);
var account = _perforCofaccountingRepository.GetEntity(w => w.AccountingUnit == request.Department && uninTypes.Contains(w.UnitType));
user.UnitType = account?.UnitType ?? "";
user.UnitCode = account?.Code ?? "";
}
user.IsDelete = 1; user.IsDelete = 1;
if (!_userRepository.Add(user)) if (!_userRepository.Add(user))
...@@ -566,7 +546,14 @@ public UserResponse InsertUser(UserRequest request, int userid) ...@@ -566,7 +546,14 @@ public UserResponse InsertUser(UserRequest request, int userid)
{ {
user.Login = request.Login + i; user.Login = request.Login + i;
user.ParentID = userID; user.ParentID = userID;
user.Department = roleArray.Contains(request.RoleArr[i]) ? request.Department : ""; user.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[i]) ? request.Department : "";
if (roleArray.Contains(request.RoleArr[i]))
{
var uninTypes = UnitTypeUtil.GetMaps(request.RoleArr[i]);
var account = _perforCofaccountingRepository.GetEntity(w => w.AccountingUnit == request.Department && uninTypes.Contains(w.UnitType));
user.UnitType = account?.UnitType ?? "";
user.UnitCode = account?.Code ?? "";
}
user.ID++; user.ID++;
_userRepository.Add(user); _userRepository.Add(user);
...@@ -601,12 +588,6 @@ public UserResponse UpdateUser(UserRequest request, int userId) ...@@ -601,12 +588,6 @@ public UserResponse UpdateUser(UserRequest request, int userId)
var vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Login == request.Login && t.IsDelete == 1); var vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Login == request.Login && t.IsDelete == 1);
if (null != vlist && vlist.Count() > 0) throw new PerformanceException("登录名重复"); if (null != vlist && vlist.Count() > 0) throw new PerformanceException("登录名重复");
// 只有单角色账号并且是二次分配的科室 才会记录历史科室
if (roleIds.Length == 1 && UnitTypeUtil.Maps.ContainsKey(roleIds[0]))
{
_userRepository.SaveHistoryDepartment(user.ID, request.RoleArr[0], request.Department);
}
user.Login = request.Login; user.Login = request.Login;
user.Mobile = request.Mobile; user.Mobile = request.Mobile;
user.RealName = request.RealName; user.RealName = request.RealName;
...@@ -614,6 +595,14 @@ public UserResponse UpdateUser(UserRequest request, int userId) ...@@ -614,6 +595,14 @@ public UserResponse UpdateUser(UserRequest request, int userId)
user.States = request.States; user.States = request.States;
user.Password = string.IsNullOrEmpty(request.Password) ? user.Password : request.Password; user.Password = string.IsNullOrEmpty(request.Password) ? user.Password : request.Password;
user.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]) ? request.Department : ""; user.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]) ? request.Department : "";
if (UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]))
{
var uninTypes = UnitTypeUtil.GetMaps(request.RoleArr[0]);
var account = _perforCofaccountingRepository.GetEntity(w => w.AccountingUnit == request.Department && uninTypes.Contains(w.UnitType));
user.UnitType = account?.UnitType ?? "";
user.UnitCode = account?.Code ?? "";
}
if (!_userRepository.Update(user)) if (!_userRepository.Update(user))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
...@@ -657,6 +646,14 @@ public UserResponse UpdateUser(UserRequest request, int userId) ...@@ -657,6 +646,14 @@ public UserResponse UpdateUser(UserRequest request, int userId)
diffUser.States = request.States; diffUser.States = request.States;
diffUser.Password = string.IsNullOrEmpty(request.Password) ? user.Password : request.Password; diffUser.Password = string.IsNullOrEmpty(request.Password) ? user.Password : request.Password;
diffUser.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[i]) ? request.Department : ""; diffUser.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[i]) ? request.Department : "";
if (UnitTypeUtil.Maps.ContainsKey(request.RoleArr[i]))
{
var uninTypes = UnitTypeUtil.GetMaps(request.RoleArr[i]);
var account = _perforCofaccountingRepository.GetEntity(w => w.AccountingUnit == request.Department && uninTypes.Contains(w.UnitType));
diffUser.UnitType = account?.UnitType ?? "";
diffUser.UnitCode = account?.Code ?? "";
}
if (!_userRepository.Add(diffUser)) if (!_userRepository.Add(diffUser))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
//添加子用户角色关联关系 //添加子用户角色关联关系
...@@ -733,7 +730,7 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -733,7 +730,7 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
var getUsers = _userRepository.GetEntities(); var getUsers = _userRepository.GetEntities();
var roles = _roleRepository.GetEntities(); var roles = _roleRepository.GetEntities();
var hospitals = _hospitalRepository.GetEntities(); var hospitals = _hospitalRepository.GetEntities();
var accounts = perforCofaccountingRepository.GetEntities(); var accounts = _perforCofaccountingRepository.GetEntities();
List<sys_user> users = new List<sys_user>(); List<sys_user> users = new List<sys_user>();
List<sys_user_role> userRoles = new List<sys_user_role>(); List<sys_user_role> userRoles = new List<sys_user_role>();
...@@ -763,8 +760,7 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -763,8 +760,7 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ "错误原因", "“关键信息缺失”请补全或删除" }, { "错误原因", "“关键信息缺失”请补全或删除" },
}); });
} }
else if (!Enum.IsDefined(typeof(Role), allDataList[i].RoleName))
else if (!hospitals.Any(w => w.HosName == (allDataList[i].HosName?.Trim())))
{ {
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -774,10 +770,10 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -774,10 +770,10 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ "角色", allDataList[i].RoleName ?? "" }, { "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" }, { "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department.ToString() ?? "" }, { "核算单元", allDataList[i].Department.ToString() ?? "" },
{ "错误原因", "“分配医院”错误,请修改或删除" }, { "错误原因", "“角色”错误,请修改或删除" },
}); });
} }
else if (roleArr.Contains(allDataList[i].RoleName?.Trim()) && !accounts.Any(w => w.AccountingUnit == allDataList[i].Department?.Trim())) else if (!hospitals.Any(w => w.HosName == (allDataList[i].HosName?.Trim())))
{ {
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -786,8 +782,8 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -786,8 +782,8 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ "登录名", allDataList[i].RealName ?? "" }, { "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" }, { "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" }, { "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department ?? "" }, { "核算单元", allDataList[i].Department.ToString() ?? "" },
{ "错误原因", "“核算单元”错误,请修改或删除" }, { "错误原因", "“分配医院”错误,请修改或删除" },
}); });
} }
...@@ -804,22 +800,44 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -804,22 +800,44 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ "错误原因", "“登录名”已存在,请修改或删除" }, { "错误原因", "“登录名”已存在,请修改或删除" },
}); });
} }
if (roleArr.Contains(allDataList[i].RoleName?.Trim()))
{
var role = (Role)Enum.Parse(typeof(Role), allDataList[i].RoleName);
var uninTypes = UnitTypeUtil.GetMaps((int)role);
var cts = accounts.FirstOrDefault(w => w.AccountingUnit == allDataList[i].Department?.Trim() && uninTypes.Contains(w.UnitType));
if (cts == null)
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "姓名", allDataList[i].Login ?? "" },
{ "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department ?? "" },
{ "错误原因", "“核算单元”错误,当前角色暂无该核算单元,请修改或删除" },
});
}
}
} }
if (error.Count > 0) if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error); return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
foreach (var data in allDataList) foreach (var data in allDataList)
{ {
if (users.Any(c => c.Login == data?.Login)) continue; if (users.Any(c => c.Login == data?.Login)) continue;
var role = (Role)Enum.Parse(typeof(Role), data.RoleName);
var uninTypes = UnitTypeUtil.GetMaps((int)role);
cof_accounting cts = accounts.FirstOrDefault(w => w.AccountingUnit == allDataList[i].Department?.Trim() && uninTypes.Contains(w.UnitType));
var user = new sys_user var user = new sys_user
{ {
RealName = data.RealName, RealName = data.RealName,
CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")), CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")),
CreateUser = request.CreateUser, CreateUser = request.CreateUser,
Department = data?.Department ?? "", Department = data?.Department.Trim() ?? "",
UnitType = cts?.UnitType ?? "",
UnitCode = cts?.Code ?? "",
IsDelete = 1, IsDelete = 1,
Login = data.Login, Login = data.Login,
Password = data?.Password ?? "123456", Password = data?.Password ?? "123456",
......
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