多科室涉及代码科室优化

parent cf2a7cb6
......@@ -122,7 +122,7 @@ public ApiResponse SelfInfo()
user.Role = _roleService.GetUserRole(user.UserID);
user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
int[] roleArray = UnitTypeUtil.Maps.Keys.ToArray();
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
return new ApiResponse(ResponseType.OK, user);
}
......@@ -149,56 +149,56 @@ public ApiResponse<UserResponse> UpdateSelf([CustomizeValidator(RuleSet = "Self"
[HttpPost]
public ApiResponse<List<UserResponse>> List([FromBody] UserRequest request)
{
var userList = _userService.GetUserList(_claim.GetUserId(),request.Role);
var userList = _userService.GetUserList(_claim.GetUserId(), request.Role);
return new ApiResponse<List<UserResponse>>(ResponseType.OK, "ok", userList);
}
/// <summary>
/// 新增用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("insert")]
[HttpPost]
public ApiResponse<UserResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody] UserRequest request)
{
var userId = _claim.GetUserId();
var user = _userService.Insert(request, userId);
user.Role = request.Role;
return new ApiResponse<UserResponse>(ResponseType.OK, user);
}
/// <summary>
/// 新增用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("delete")]
[HttpPost]
public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody] UserRequest request)
{
return _userService.Delete(request.ID);
}
/// <summary>
/// 删除用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("update")]
[HttpPost]
public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody] UserRequest request)
{
var userId = _claim.GetUserId();
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUserRole(userId);
var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false;
var user = _userService.Update(request, isAgainAdmin);
user.Role = request.Role;
return new ApiResponse<UserResponse>(ResponseType.OK, user);
}
///// <summary>
///// 新增用户
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("insert")]
//[HttpPost]
//public ApiResponse<UserResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody] UserRequest request)
//{
// var userId = _claim.GetUserId();
// var user = _userService.Insert(request, userId);
// user.Role = request.Role;
// return new ApiResponse<UserResponse>(ResponseType.OK, user);
//}
///// <summary>
///// 新增用户
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("delete")]
//[HttpPost]
//public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody] UserRequest request)
//{
// return _userService.Delete(request.ID);
//}
///// <summary>
///// 删除用户
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("update")]
//[HttpPost]
//public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody] UserRequest request)
//{
// var userId = _claim.GetUserId();
// int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
// var roles = _roleService.GetUserRole(userId);
// var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false;
// var user = _userService.Update(request, isAgainAdmin);
// user.Role = request.Role;
// return new ApiResponse<UserResponse>(ResponseType.OK, user);
//}
/// <summary>
/// 修改用户密码
......@@ -311,7 +311,7 @@ public ApiResponse SelfInfos([FromBody] UserRequest request)
user.Role = _roleService.GetUsersRole(user.UserID);
user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
int[] roleArray = UnitTypeUtil.Maps.Keys.ToArray();
if (request.Role <= 0)
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
else
......@@ -345,13 +345,7 @@ public ApiResponse<UserResponse> UpdateUser([CustomizeValidator(RuleSet = "Updat
{
var userId = _claim.GetUserId();
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUsersRole(userId);
//var roleType = roles.Select(c => c.Type).ToArray();
var intersect = roleArray.Intersect(roles.Select(c => (int)c.Type).ToArray());
var isAgainAdmin = roles != null ? intersect.Any() : false;
var user = _userService.UpdateUser(request, isAgainAdmin);
var user = _userService.UpdateUser(request, userId);
user.RoleArr = request.RoleArr;
return new ApiResponse<UserResponse>(ResponseType.OK, user);
}
......@@ -391,12 +385,7 @@ public ApiResponse GetBatchUserStructrue()
[HttpPost]
public ApiResponse BatchSaveUser([CustomizeValidator(RuleSet = "Insert"), FromBody] UserCollectData data)
{
var result = _userService.SaveUserHandsFlat(data);
if (result == "")
return new ApiResponse(ResponseType.OK);
else
return new ApiResponse(ResponseType.Error, result);
return _userService.SaveUserHandsFlat(data);
}
}
}
\ No newline at end of file
......@@ -14,14 +14,14 @@
"ExpirationMinutes": "1200",
//验证码过期
"SmsCodeMinutes": "5",
//护士长二次绩效管理员
"NurseRole": "3",
//科主任二次绩效管理员
"DirectorRole": "4",
//特殊科室二次绩效管理员
"SpecialRole": "9",
//数据收集角色(可查看所有)
"CollectRoles": [ 1, 2, 5, 6, 7, 8 ],
////护士长二次绩效管理员
//"NurseRole": "3",
////科主任二次绩效管理员
//"DirectorRole": "4",
////特殊科室二次绩效管理员
//"SpecialRole": "9",
////数据收集角色(可查看所有)
//"CollectRoles": [ 1, 2, 5, 6, 7, 8 ],
// 抽取结果Excel文件保存地址
"AbsolutePath": "E:\\wwwroot\\testjx.suvalue.com",
// 抽取结果Excel文件保存地址 更替的 网络地址
......
......@@ -49,27 +49,6 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Insert(Performance.DtoModels.UserRequest)">
<summary>
新增用户
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Delete(Performance.DtoModels.UserRequest)">
<summary>
新增用户
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Update(Performance.DtoModels.UserRequest)">
<summary>
删除用户
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Password(Performance.DtoModels.PasswordRequest)">
<summary>
修改用户密码
......@@ -149,29 +128,18 @@
</summary>
<returns></returns>
</member>
<member name="T:Performance.Api.Controllers.AgainAllotController">
<summary>
科室二次分配
</summary>
</member>
<member name="M:Performance.Api.Controllers.AgainAllotController.AllotList">
<summary>
返回当前用户医院下绩效列表
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AgainAllotController.Import(Microsoft.AspNetCore.Http.IFormCollection)">
<member name="M:Performance.Api.Controllers.AccountController.HistoryDepartment(System.Int32)">
<summary>
上传文件
用户过往科室
</summary>
<param name="form"></param>
<param name="userId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AgainAllotController.Detail(Performance.DtoModels.AgainAllotRequest)">
<member name="M:Performance.Api.Controllers.AccountController.DeleteHistoryDepartment(System.Int32)">
<summary>
查看绩效详情
删除用户过往科室
</summary>
<param name="request"></param>
<param name="historyId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AllotController.List(Performance.DtoModels.AllotRequest)">
......
......@@ -34,31 +34,6 @@
短信模板
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.NurseRole">
<summary>
护士长二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.DirectorRole">
<summary>
科主任二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.SpecialRole">
<summary>
特殊科室二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.CollectRoles">
<summary>
数据收集角色(可查看所有)
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.OfficeRole">
<summary>
行政科室二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.Receiver">
<summary>
邮件指定接收人
......@@ -130,39 +105,6 @@
<member name="F:Performance.DtoModels.DbSrouceType.Performance">
<summary> 绩效库 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.数据未上传">
<summary> 数据未上传 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.数据已上传">
<summary> 数据已上传 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.正在校验数据">
<summary> 正在校验数据 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.数据验证通过">
<summary> 数据验证通过 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.数据错误">
<summary> 数据错误 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.正在生成绩效">
<summary> 正在生成绩效 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.绩效下发">
<summary> 绩效下发 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.绩效解析失败">
<summary> 绩效解析失败 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.归档">
<summary> 归档 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.等待">
<summary> 等待 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.绩效结果解析成功">
<summary> 绩效结果解析成功 </summary>
</member>
<member name="F:Performance.DtoModels.AgWorkloadType.PreAccountingReward">
<summary>
核算前奖励
......@@ -735,9 +677,6 @@
是否需要二次分配
</summary>
</member>
<member name="T:Performance.DtoModels.UnitType">
<summary> 核算单元类型 </summary>
</member>
<member name="F:Performance.DtoModels.SheetType.Unidentifiable">
<summary> 无法识别 </summary>
</member>
......
......@@ -8650,6 +8650,41 @@
父级ID
</summary>
</member>
<member name="T:Performance.EntityModels.sys_user_history">
<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>
</member>
<member name="P:Performance.EntityModels.sys_user_history.CreateDate">
<summary>
核算单元变更时间
</summary>
</member>
<member name="T:Performance.EntityModels.sys_user_hospital">
<summary>
......@@ -9045,5 +9080,41 @@
预留金额
</summary>
</member>
<member name="F:AllotStates.数据未上传">
<summary> 数据未上传 </summary>
</member>
<member name="F:AllotStates.数据已上传">
<summary> 数据已上传 </summary>
</member>
<member name="F:AllotStates.正在校验数据">
<summary> 正在校验数据 </summary>
</member>
<member name="F:AllotStates.数据验证通过">
<summary> 数据验证通过 </summary>
</member>
<member name="F:AllotStates.数据错误">
<summary> 数据错误 </summary>
</member>
<member name="F:AllotStates.正在生成绩效">
<summary> 正在生成绩效 </summary>
</member>
<member name="F:AllotStates.绩效下发">
<summary> 绩效下发 </summary>
</member>
<member name="F:AllotStates.绩效解析失败">
<summary> 绩效解析失败 </summary>
</member>
<member name="F:AllotStates.归档">
<summary> 归档 </summary>
</member>
<member name="F:AllotStates.等待">
<summary> 等待 </summary>
</member>
<member name="F:AllotStates.绩效结果解析成功">
<summary> 绩效结果解析成功 </summary>
</member>
<member name="T:UnitType">
<summary> 核算单元类型 </summary>
</member>
</members>
</doc>
......@@ -18,26 +18,26 @@ public class Application
/// 短信模板
/// </summary>
public string SmsTemplate { get; set; }
/// <summary>
/// 护士长二次绩效管理员
/// </summary>
public int NurseRole { get; set; }
/// <summary>
/// 科主任二次绩效管理员
/// </summary>
public int DirectorRole { get; set; }
/// <summary>
/// 特殊科室二次绩效管理员
/// </summary>
public int SpecialRole { get; set; }
/// <summary>
/// 数据收集角色(可查看所有)
/// </summary>
public int[] CollectRoles { get; set; }
/// <summary>
/// 行政科室二次绩效管理员
/// </summary>
public int OfficeRole { get; set; }
///// <summary>
///// 护士长二次绩效管理员
///// </summary>
//public int NurseRole { get; set; }
///// <summary>
///// 科主任二次绩效管理员
///// </summary>
//public int DirectorRole { get; set; }
///// <summary>
///// 特殊科室二次绩效管理员
///// </summary>
//public int SpecialRole { get; set; }
///// <summary>
///// 数据收集角色(可查看所有)
///// </summary>
//public int[] CollectRoles { get; set; }
///// <summary>
///// 行政科室二次绩效管理员
///// </summary>
//public int OfficeRole { get; set; }
/// <summary>
/// 邮件指定接收人
/// </summary>
......
......@@ -45,42 +45,6 @@ public enum DbSrouceType
Performance = 2,
}
public enum AllotStates
{
/// <summary> 数据未上传 </summary>
[Description("数据未上传")]
数据未上传 = 0,
/// <summary> 数据已上传 </summary>
[Description("数据已上传")]
数据已上传 = 1,
/// <summary> 正在校验数据 </summary>
[Description("正在校验数据")]
正在校验数据 = 2,
/// <summary> 数据验证通过 </summary>
[Description("数据验证通过")]
数据验证通过 = 3,
/// <summary> 数据错误 </summary>
[Description("数据错误")]
数据错误 = 4,
/// <summary> 正在生成绩效 </summary>
[Description("正在生成绩效")]
正在生成绩效 = 5,
/// <summary> 绩效下发 </summary>
[Description("绩效下发")]
绩效下发 = 6,
/// <summary> 绩效解析失败 </summary>
[Description("绩效解析失败")]
绩效解析失败 = 7,
/// <summary> 归档 </summary>
[Description("归档")]
归档 = 8,
/// <summary> 等待 </summary>
[Description("等待")]
等待 = 9,
/// <summary> 绩效结果解析成功 </summary>
[Description("数据验证通过")]
绩效结果解析成功 = 10,
}
public enum AgWorkloadType
{
......@@ -119,24 +83,6 @@ public enum DataFormat
日期YYYYMMDD
}
public enum Role
{
绩效管理员 = 1,
医院管理员 = 2,
护士长 = 3,
科主任 = 4,
绩效核算办 = 5,
院领导 = 6,
财务科 = 7,
人事科 = 8,
特殊科室 = 9,
行政科室 = 10,
数据收集 = 11,
护理部审核 = 12,
绩效查询 = 13,
审计 = 14,
}
public class Background
{
public enum JobType
......
......@@ -11,44 +11,6 @@ public enum ExcelVersion
xls
}
/// <summary> 核算单元类型 </summary>
public enum UnitType
{
[Description("医生组")]
医生组 = 1,
[Description("护理组")]
护理组 = 2,
[Description("医技组")]
医技组 = 3,
[Description("专家组")]
专家组 = 4,
//[Description("其他")]
//其他 = 5,
[Description("特殊核算组")]
特殊核算组 = 6,
[Description("其他医生组")]
其他医生组 = 7,
[Description("其他护理组")]
其他护理组 = 8,
[Description("其他医技组")]
其他医技组 = 9,
[Description("行政高层")]
行政高层 = 10,
[Description("行政中层")]
行政中层 = 11,
[Description("行政后勤")]
行政后勤 = 12,
}
public enum SheetType
{
......
using System.ComponentModel;
public enum AllotStates
{
/// <summary> 数据未上传 </summary>
[Description("数据未上传")]
数据未上传 = 0,
/// <summary> 数据已上传 </summary>
[Description("数据已上传")]
数据已上传 = 1,
/// <summary> 正在校验数据 </summary>
[Description("正在校验数据")]
正在校验数据 = 2,
/// <summary> 数据验证通过 </summary>
[Description("数据验证通过")]
数据验证通过 = 3,
/// <summary> 数据错误 </summary>
[Description("数据错误")]
数据错误 = 4,
/// <summary> 正在生成绩效 </summary>
[Description("正在生成绩效")]
正在生成绩效 = 5,
/// <summary> 绩效下发 </summary>
[Description("绩效下发")]
绩效下发 = 6,
/// <summary> 绩效解析失败 </summary>
[Description("绩效解析失败")]
绩效解析失败 = 7,
/// <summary> 归档 </summary>
[Description("归档")]
归档 = 8,
/// <summary> 等待 </summary>
[Description("等待")]
等待 = 9,
/// <summary> 绩效结果解析成功 </summary>
[Description("数据验证通过")]
绩效结果解析成功 = 10,
}
public enum Role
{
绩效管理员 = 1,
医院管理员 = 2,
护士长 = 3,
科主任 = 4,
绩效核算办 = 5,
院领导 = 6,
财务科 = 7,
人事科 = 8,
特殊科室 = 9,
行政科室 = 10,
数据收集 = 11,
护理部审核 = 12,
绩效查询 = 13,
审计 = 14,
}
/// <summary> 核算单元类型 </summary>
public enum UnitType
{
[Description("医生组")]
医生组 = 1,
[Description("护理组")]
护理组 = 2,
[Description("医技组")]
医技组 = 3,
[Description("专家组")]
专家组 = 4,
//[Description("其他")]
//其他 = 5,
[Description("特殊核算组")]
特殊核算组 = 6,
[Description("其他医生组")]
其他医生组 = 7,
[Description("其他护理组")]
其他护理组 = 8,
[Description("其他医技组")]
其他医技组 = 9,
[Description("行政高层")]
行政高层 = 10,
[Description("行政中层")]
行政中层 = 11,
[Description("行政后勤")]
行政后勤 = 12,
}
using Performance.EntityModels;
using System.Collections.Generic;
using System.Linq;
public class UserInfoCenter
{
public sys_user User { get; set; }
public sys_role URole { get; set; }
public List<sys_hospital> Hospitals { get; set; }
public List<int> HospitalIds => Hospitals?.Select(w => w.ID).ToList() ?? new List<int>();
}
using Microsoft.EntityFrameworkCore;
using Performance.EntityModels;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Performance.Repository
{
public partial class PerforUserRepository : PerforRepository<sys_user>
{
/// <summary>
/// 获取用户 医院 角色 过往科室
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public UserInfoCenter GetUser(int userId)
{
var user = context.Set<sys_user>().FirstOrDefault(w => w.IsDelete == 1 && w.ID == userId);
if (user == null)
return null;
var roles = from ur in context.Set<sys_user_role>()
join r in context.Set<sys_role>() on ur.RoleID equals r.ID
where ur.UserID == user.ID
select r;
var hospitals = from uh in context.Set<sys_user_hospital>()
join h in context.Set<sys_hospital>() on uh.HospitalID equals h.ID
where uh.UserID == user.ID
select h;
return new UserInfoCenter
{
User = user,
URole = roles.FirstOrDefault() ?? new sys_role(),
Hospitals = hospitals.ToList() ?? new List<sys_hospital>(),
};
}
/// <summary>
/// 获取指定RoleType的用户
/// </summary>
/// <param name="roleType"></param>
/// <returns></returns>
public List<sys_user> GetUsersByRoleType(params int[] roleType)
{
var users = from u in context.Set<sys_user>()
join ur in context.Set<sys_user_role>() on u.ID equals ur.UserID
join r in context.Set<sys_role>() on ur.RoleID equals r.ID
select new { u, r };
return users.Where(w => roleType.Contains(w.r.Type ?? w.r.ID)).Select(w => w.u).ToList();
}
}
}
......@@ -16,6 +16,7 @@
using System.Data;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
namespace Performance.Services
{
......@@ -30,6 +31,7 @@ public class AllotService : IAutoInjection
private IWebHostEnvironment _evn;
private ILogger<AllotService> _logger;
private readonly IMapper _mapper;
private readonly PerforUserRepository _userRepository;
private PerforPerallotRepository _allotRepository;
private IEmailService emailService;
private readonly IOptions<Application> options;
......@@ -55,6 +57,7 @@ public class AllotService : IAutoInjection
public AllotService(
IMapper mapper,
PerforUserRepository userRepository,
PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService,
ImportDataService importDataService,
......@@ -85,6 +88,7 @@ public class AllotService : IAutoInjection
QueryDataService queryDataService)
{
_mapper = mapper;
_userRepository = userRepository;
_allotRepository = allotRepository;
_againallotRepository = againallotRepository;
_logger = logger;
......@@ -650,26 +654,19 @@ public List<log_dbug> AllotLog(per_allot allot, int type)
/// <returns></returns>
public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int userid)
{
var user = userService.GetUser(userid);
if (user == null)
throw new PerformanceException("用户信息错误");
var role = roleService.GetUserRole(userid)?.FirstOrDefault()?.Type;
if (!role.HasValue)
throw new PerformanceException("用户信息错误");
var userInfo = _userRepository.GetUser(userid);
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
var reserveds = _reportRepository.GetEmployeeReserved(hospitalId, year);
if (reserveds != null && reserveds.Any())
{
if (role.Value == options.Value.NurseRole)
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.护理组, UnitType.其他护理组) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.DirectorRole)
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.医生组, UnitType.其他医生组, UnitType.医技组, UnitType.其他医技组) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.SpecialRole)
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.特殊核算组) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.OfficeRole)
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.行政中层, UnitType.行政后勤) && w.AccountingUnit == user.Department)?.ToList();
Expression<Func<EmployeeReservedDto, bool>> exp = w => w.AccountingUnit == userInfo.User.Department;
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));
reserveds = reserveds.Where(exp.Compile())?.ToList();
}
return reserveds;
......
......@@ -250,7 +250,7 @@ public IEnumerable<collect_permission> GetCollectSheet(int hospitalId, int userI
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
if (userrole == null) return new List<collect_permission>();
if (!options.CollectRoles.Contains(userrole.RoleID))
if (!UnitTypeUtil.CollectRoles.Contains(userrole.RoleID))
{
var types = new[] { (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload, (int)SheetType.SpecialUnit };
var sheetNames = exmoduleRepository.GetEntities(w => w.HospitalId == hospitalId && types.Contains(w.SheetType ?? 0))?.Select(t => t.ModuleName).ToList() ?? new List<string>();
......
......@@ -77,12 +77,12 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro
var account = GetAccounting(allotId, roleType, Department);
Expression<Func<cost_transfer, bool>> exp = t => t.AllotId == allotId;
if (roleType == application.DirectorRole)
if (roleType == (int)Role.科主任)
if (menuType == 1)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.ApplicantUnitType));
else
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.AdoptedUnitType));
else if (roleType == application.NurseRole)
else if (roleType == (int)Role.护士长)
if (menuType == 1)
exp = exp.And(t => t.ApplicantUnitType == UnitType.护理组.ToString());
else
......@@ -149,14 +149,9 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro
public cof_accounting GetAccounting(int allotId, int roleType, string Department = null)
{
Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == allotId && t.AccountingUnit == Department;
if (roleType == application.DirectorRole)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType));
else if (roleType == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
else if (roleType == application.SpecialRole)
exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString());
else if (roleType == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
if (UnitTypeUtil.Maps.ContainsKey(roleType))
exp = exp.And(t => UnitTypeUtil.Maps[roleType].Contains(t.UnitType));
var account = cofaccountingRepository.GetEntity(exp);
......
......@@ -23,6 +23,7 @@ public class CustomExtractService : IAutoInjection
private readonly IOptions<Application> _options;
private readonly UserService _userService;
private readonly RoleService _roleService;
private readonly PerforUserRepository _userRepository;
private readonly PerforPerallotRepository _perallotRepository;
private readonly PerforPerdeptdicRepository _perforPerdeptdicRepository;
private readonly PerforHospitalconfigRepository _perforHospitalconfigRepository;
......@@ -34,6 +35,7 @@ public class CustomExtractService : IAutoInjection
IOptions<Application> options,
UserService userService,
RoleService roleService,
PerforUserRepository userRepository,
PerforPerallotRepository perallotRepository,
PerforPerdeptdicRepository perforPerdeptdicRepository,
PerforHospitalconfigRepository perforHospitalconfigRepository,
......@@ -44,6 +46,7 @@ public class CustomExtractService : IAutoInjection
_options = options;
_userService = userService;
_roleService = roleService;
_userRepository = userRepository;
_perallotRepository = perallotRepository;
_perforPerdeptdicRepository = perforPerdeptdicRepository;
_perforHospitalconfigRepository = perforHospitalconfigRepository;
......@@ -57,8 +60,8 @@ public bool CheckConfigScript(int userId, int allotId)
?? throw new PerformanceException("绩效ID无效");
var scripts = _perforcustscriptRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.IsEnable == 1);
scripts = (IsSecondAdmin(userId, out string[] unitType))
var center = _userRepository.GetUser(userId);
scripts = UnitTypeUtil.Maps.ContainsKey(center?.URole.Type ?? 0)
? scripts?.Where(w => w.IsSecondAllot == 1).ToList()
: scripts?.Where(w => w.IsOnceAllot == 1).ToList();
......@@ -74,9 +77,11 @@ public bool ExtractData(int userId, int allotId, out string resultFilePath)
var filePath = ExtractHelper.GetExtractFile(allot.HospitalId);
resultFilePath = filePath;
var center = _userRepository.GetUser(userId);
var scripts = _perforcustscriptRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.IsEnable == 1);
scripts = (IsSecondAdmin(userId, out string[] unitType))
scripts = UnitTypeUtil.Maps.ContainsKey(center?.URole.Type ?? 0)
? scripts?.Where(w => w.IsSecondAllot == 1).ToList()
: scripts?.Where(w => w.IsOnceAllot == 1).ToList();
......@@ -132,7 +137,12 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
?? throw new PerformanceException("当前医院没有数据库地址配置");
var parameters = GetParameters(allot);
var (isSecondAdmin, department, unitType) = GetUserDepartment(userId);
var center = _userRepository.GetUser(userId);
var isSecondAdmin = UnitTypeUtil.Maps.ContainsKey(center?.URole.Type ?? 0);
var department = isSecondAdmin ? (center?.User.Department ?? "") : string.Empty;
var unitType = UnitTypeUtil.Maps[center?.URole.Type ?? 0];
parameters.Add("@department", $"'{department}'");
if (unitType != null && unitType.Any())
parameters.Add("@unittype", $"{string.Join(", ", unitType.Select(t => $"'{t}'"))}");
......@@ -292,44 +302,5 @@ public IEnumerable<dynamic> QueryData(sys_hospitalconfig config, string execsql,
};
return pairs;
}
/// <summary>
/// 是否是二次分配管理员 是 true 否 false
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
private bool IsSecondAdmin(int userId, out string[] unitType)
{
Dictionary<int, string[]> pairs = new Dictionary<int, string[]>
{
{ _options.Value.NurseRole, new string[] { UnitType.护理组.ToString() } },
{ _options.Value.DirectorRole, new string[] { UnitType.医生组.ToString(), UnitType.医技组.ToString() } },
{ _options.Value.SpecialRole, new string[] { UnitType.特殊核算组.ToString() } },
{ _options.Value.OfficeRole, new string[] { UnitType.行政后勤.ToString() } },
};
var roleId = _roleService.GetRole(userId)?.FirstOrDefault().ID ?? 0;
if (pairs.ContainsKey(roleId))
{
unitType = pairs[roleId];
return true;
}
unitType = new string[] { };
return false;
}
/// <summary>
/// 返回二次分配管理科室 默认 返回 空值
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
private (bool isSecondAdmin, string department, string[] unitType) GetUserDepartment(int userId)
{
var user = _userService.GetUser(userId)
?? throw new PerformanceException("当前用户信息无效");
var isSecondAdmin = IsSecondAdmin(userId, out string[] unitType);
var department = isSecondAdmin ? (user.Department ?? "") : string.Empty;
return (isSecondAdmin, department, unitType);
}
}
}
......@@ -188,12 +188,15 @@ public List<per_employee> GetPerEmployee(int allotId)
/// <returns></returns>
public List<per_employee> GetPersons(int allotId, int userId)
{
var (dept, unittype) = GetDeptByUser(userId);
var userInfo = perforUserRepository.GetUser(userId);
var dept = userInfo?.User.Department ?? "";
var unittype = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
? UnitTypeUtil.Maps[userInfo.URole.Type.Value]
: new string[0];
Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId;
if (!string.IsNullOrEmpty(dept) && unittype.Any())
{
exp = exp.And(t => t.AccountingUnit == dept && unittype.Contains(t.UnitType));
}
var list = peremployeeRepository.GetEntities(exp);
if (list != null && list.Any())
......@@ -209,17 +212,18 @@ public List<per_employee> GetPersons(int allotId, int userId)
/// <returns></returns>
public PageList<per_employee> GetPersons(int allotId, int userId, PersonParamsRequest request)
{
var (dept, unittype) = GetDeptByUser(userId);
var userInfo = perforUserRepository.GetUser(userId);
var dept = userInfo?.User.Department ?? "";
var unittype = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
? UnitTypeUtil.Maps[userInfo.URole.Type.Value]
: new string[0];
Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId;
if (!string.IsNullOrEmpty(dept) && unittype.Any())
{
exp = exp.And(t => t.AccountingUnit == dept && unittype.Contains(t.UnitType));
}
if (request != null && !string.IsNullOrEmpty(request.SearchQuery))
{
exp = exp.And(t => true && (t.AccountingUnit.Contains(request.SearchQuery) || t.PersonnelNumber.Contains(request.SearchQuery) || t.DoctorName.Contains(request.SearchQuery) || t.Department.Contains(request.SearchQuery)));
}
var result = new List<per_employee>();
......@@ -446,31 +450,23 @@ public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId)
return result.OrderBy(w => w.IsVerify).ThenByDescending(t => t.CreateTime).ThenBy(t => t.Department);
}
private (string dept, string[] unittype) GetDeptByUser(int userId)
{
var user = perforUserRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (user == null) throw new PerformanceException("用户信息错误");
//private (string dept, string[] unittype) GetDeptByUser(int userId)
//{
// var user = perforUserRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
// if (user == null) throw new PerformanceException("用户信息错误");
var userrole = perforUserroleRepository.GetEntity(t => t.UserID == user.ID);
var role = perforRoleRepository.GetEntity(t => t.ID == userrole.RoleID);
// var userrole = perforUserroleRepository.GetEntity(t => t.UserID == user.ID);
// var role = perforRoleRepository.GetEntity(t => t.ID == userrole.RoleID);
if (role == null) return ("", new string[] { });
// if (role == null) return ("", new string[] { });
Dictionary<int, string[]> dict = new Dictionary<int, string[]>
{
{ application.DirectorRole, new string[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new string[]{ UnitType.护理组.ToString() } },
{ application.SpecialRole, new string[]{ UnitType.特殊核算组.ToString() } },
{ application.OfficeRole, new string[]{ UnitType.行政后勤.ToString(), "行政工勤" } },
};
if (dict.Keys.Contains(role.Type.Value))
{
return (user.Department, dict[role.Type.Value]);
}
// if (UnitTypeUtil.Maps.ContainsKey(role.Type.Value))
// {
// return (user.Department, UnitTypeUtil.Maps[role.Type.Value]);
// }
return ("", new string[] { });
}
// return ("", new string[] { });
//}
private Deptdic GetDeptdic(per_dept_dic dic)
{
......@@ -636,7 +632,8 @@ public List<TitleValue> DeptDics(int hospitalId, int type)
/// <returns></returns>
public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
{
string[] unitTypes = GetUnitType(userId);
var center = perforUserRepository.GetUser(userId);
string[] unitTypes = UnitTypeUtil.Maps[center?.URole.Type ?? 0];
if (unitTypes == null || !unitTypes.Any()) return new string[] { };
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
......@@ -667,7 +664,8 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
/// <returns></returns>
public object DeptIncomeDetail(WorkDetailRequest request, int userId)
{
string[] unitTypes = GetUnitType(userId);
var center = perforUserRepository.GetUser(userId);
string[] unitTypes = UnitTypeUtil.Maps[center?.URole.Type ?? 0];
if (unitTypes == null || !unitTypes.Any()) return new string[] { };
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
......@@ -694,27 +692,6 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
return new string[] { };
}
private string[] GetUnitType(int userId)
{
Dictionary<int, string[]> dict = new Dictionary<int, string[]>
{
{ application.DirectorRole, new string []{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.医技组.ToString() } },
{ application.NurseRole, new string []{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString() } },
{ application.SpecialRole, new string []{ UnitType.特殊核算组.ToString() } },
{ application.OfficeRole, new string []{ UnitType.行政后勤.ToString() } },
};
var user = perforUserRepository.GetEntity(t => t.ID == userId);
if (user == null)
throw new NotImplementedException("人员ID无效");
var userrole = perforUserroleRepository.GetEntity(t => t.UserID == userId);
var role = perforRoleRepository.GetEntity(t => t.ID == userrole.RoleID);
if (!role.Type.HasValue || !dict.ContainsKey(role.Type.Value))
return new string[] { };
return dict[role.Type.Value];
}
public HandsonTable GetBatchPersonStructrue(int hospitalId)
{
......
......@@ -65,7 +65,8 @@ public List<SelectionOptions> GetReportSelection(int groupId, int userId, int ho
if (selections == null)
return options;
var isMedical = IsMedical(userId);
var userInfo = userRepository.GetUser(userId);
var isMedical = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value));
var dispaly = new int[] { (int)SelectionState.UsableAndNotDispaly, (int)SelectionState.NotUsableAndNotDispaly };
foreach (var item in selections.Where(t => t.State.HasValue && !dispaly.Contains(t.State.Value)))
......@@ -136,8 +137,9 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
var selections = selectionRepository.GetEntities(w => arr2.Contains(w.ID) && w.State.HasValue && dispaly.Contains(w.State.Value))
?? new List<rep_selection>();
var isMedical = IsMedical(userId);
var department = GetUserDepartment(userId);
var userInfo = userRepository.GetUser(userId);
var isMedical = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value));
var department = userInfo?.User.Department ?? "";
List<ReportData> result = new List<ReportData>();
foreach (var report in reports)
......@@ -358,16 +360,6 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection
return content;
}
private bool IsMedical(int userId)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
var roleTypes = new[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
if (role.Type.HasValue && roleTypes.Contains(role.Type.Value))
return true;
else
return false;
}
private string GetUserDepartment(int userId)
{
......
......@@ -739,7 +739,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
var role = _userService.GetUserFirstRole(userId);
//行政科室 只有两种逻辑,或从保存中加载,或加载EXCEL表
if (role?.Type == _application.OfficeRole)
if (role?.Type == (int)Role.行政科室)
{
// 如果已经保存>>走保存加载逻辑
if (employeeSource == (int)EmployeeSource.Initial)
......
......@@ -9,6 +9,25 @@ namespace Performance.Services
public class UnitTypeUtil
{
public static string[] Office = new string[] { "行政后勤", "行政工勤" };
/// <summary>
/// 数据收集角色(可查看所有)
/// </summary>
public static int[] CollectRoles { get; } = new int[] { (int)Role.绩效管理员, (int)Role.医院管理员, (int)Role.绩效核算办, (int)Role.院领导, (int)Role.财务科, (int)Role.人事科 };
/// <summary>
/// 二次分配角色映射表
/// </summary>
public static Dictionary<int, string[]> Maps { get; } = new Dictionary<int, string[]>
{
{ (int)Role.科主任, new string[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ (int)Role.护士长, new string[]{ UnitType.护理组.ToString(), } },
{ (int)Role.特殊科室, new string[]{ UnitType.特殊核算组.ToString(), } },
{ (int)Role.行政科室, new string[]{ UnitType.行政后勤.ToString(), "行政工勤" } },
};
public class RoleUnitMap
{
public Role Role { get; set; }
public string[] UnitType { get; set; }
}
/// <summary>
/// 是否是行政后勤/工勤
......@@ -74,5 +93,6 @@ public static string Recognition(string name, AccountUnitType defaultValue)
return defaultValue.ToString();
}
}
}
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