多科室涉及代码科室优化

parent cf2a7cb6
...@@ -122,7 +122,7 @@ public ApiResponse SelfInfo() ...@@ -122,7 +122,7 @@ public ApiResponse SelfInfo()
user.Role = _roleService.GetUserRole(user.UserID); user.Role = _roleService.GetUserRole(user.UserID);
user.Hospital = _hospitalService.GetUserHopital(user.UserID); user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole }; int[] roleArray = UnitTypeUtil.Maps.Keys.ToArray();
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false; user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
return new ApiResponse(ResponseType.OK, user); return new ApiResponse(ResponseType.OK, user);
} }
...@@ -149,56 +149,56 @@ public ApiResponse<UserResponse> UpdateSelf([CustomizeValidator(RuleSet = "Self" ...@@ -149,56 +149,56 @@ public ApiResponse<UserResponse> UpdateSelf([CustomizeValidator(RuleSet = "Self"
[HttpPost] [HttpPost]
public ApiResponse<List<UserResponse>> List([FromBody] UserRequest request) 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); return new ApiResponse<List<UserResponse>>(ResponseType.OK, "ok", userList);
} }
/// <summary> ///// <summary>
/// 新增用户 ///// 新增用户
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("insert")] //[Route("insert")]
[HttpPost] //[HttpPost]
public ApiResponse<UserResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody] UserRequest request) //public ApiResponse<UserResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody] UserRequest request)
{ //{
var userId = _claim.GetUserId(); // var userId = _claim.GetUserId();
var user = _userService.Insert(request, userId); // var user = _userService.Insert(request, userId);
user.Role = request.Role; // user.Role = request.Role;
return new ApiResponse<UserResponse>(ResponseType.OK, user); // return new ApiResponse<UserResponse>(ResponseType.OK, user);
} //}
/// <summary> ///// <summary>
/// 新增用户 ///// 新增用户
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("delete")] //[Route("delete")]
[HttpPost] //[HttpPost]
public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody] UserRequest request) //public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody] UserRequest request)
{ //{
return _userService.Delete(request.ID); // return _userService.Delete(request.ID);
} //}
/// <summary> ///// <summary>
/// 删除用户 ///// 删除用户
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
[Route("update")] //[Route("update")]
[HttpPost] //[HttpPost]
public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody] UserRequest request) //public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody] UserRequest request)
{ //{
var userId = _claim.GetUserId(); // var userId = _claim.GetUserId();
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole }; // int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUserRole(userId); // var roles = _roleService.GetUserRole(userId);
var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false; // var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false;
var user = _userService.Update(request, isAgainAdmin); // var user = _userService.Update(request, isAgainAdmin);
user.Role = request.Role; // user.Role = request.Role;
return new ApiResponse<UserResponse>(ResponseType.OK, user); // return new ApiResponse<UserResponse>(ResponseType.OK, user);
} //}
/// <summary> /// <summary>
/// 修改用户密码 /// 修改用户密码
...@@ -311,7 +311,7 @@ public ApiResponse SelfInfos([FromBody] UserRequest request) ...@@ -311,7 +311,7 @@ public ApiResponse SelfInfos([FromBody] UserRequest request)
user.Role = _roleService.GetUsersRole(user.UserID); user.Role = _roleService.GetUsersRole(user.UserID);
user.Hospital = _hospitalService.GetUserHopital(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) if (request.Role <= 0)
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false; user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
else else
...@@ -345,13 +345,7 @@ public ApiResponse<UserResponse> UpdateUser([CustomizeValidator(RuleSet = "Updat ...@@ -345,13 +345,7 @@ public ApiResponse<UserResponse> UpdateUser([CustomizeValidator(RuleSet = "Updat
{ {
var userId = _claim.GetUserId(); var userId = _claim.GetUserId();
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole }; var user = _userService.UpdateUser(request, userId);
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);
user.RoleArr = request.RoleArr; user.RoleArr = request.RoleArr;
return new ApiResponse<UserResponse>(ResponseType.OK, user); return new ApiResponse<UserResponse>(ResponseType.OK, user);
} }
...@@ -391,12 +385,7 @@ public ApiResponse GetBatchUserStructrue() ...@@ -391,12 +385,7 @@ public ApiResponse GetBatchUserStructrue()
[HttpPost] [HttpPost]
public ApiResponse BatchSaveUser([CustomizeValidator(RuleSet = "Insert"), FromBody] UserCollectData data) public ApiResponse BatchSaveUser([CustomizeValidator(RuleSet = "Insert"), FromBody] UserCollectData data)
{ {
var result = _userService.SaveUserHandsFlat(data); return _userService.SaveUserHandsFlat(data);
if (result == "")
return new ApiResponse(ResponseType.OK);
else
return new ApiResponse(ResponseType.Error, result);
} }
} }
} }
\ No newline at end of file
using FluentValidation.AspNetCore; //using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Hosting; //using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; //using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; //using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; //using Microsoft.Extensions.Options;
using Performance.DtoModels; //using Performance.DtoModels;
using Performance.DtoModels.AppSettings; //using Performance.DtoModels.AppSettings;
using Performance.Infrastructure; //using Performance.Infrastructure;
using Performance.Services; //using Performance.Services;
using Performance.Services.ExtractExcelService; //using Performance.Services.ExtractExcelService;
using System; //using System;
using System.IO; //using System.IO;
using System.Linq; //using System.Linq;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 //// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Performance.Api.Controllers //namespace Performance.Api.Controllers
{ //{
/// <summary> // /// <summary>
/// 科室二次分配 // /// 科室二次分配
/// </summary> // /// </summary>
[Route("api/[controller]")] // [Route("api/[controller]")]
public class AgainAllotController : Controller // public class AgainAllotController : Controller
{ // {
private AgainAllotService againAllotService; // private AgainAllotService againAllotService;
private RoleService roleService; // private RoleService roleService;
private ComputeService computeService; // private ComputeService computeService;
private ClaimService claimService; // private ClaimService claimService;
private AllotService allotService; // private AllotService allotService;
private IWebHostEnvironment env; // private IWebHostEnvironment env;
private ConfigService configService; // private ConfigService configService;
private Application application; // private Application application;
public AgainAllotController(AgainAllotService againAllotService, // public AgainAllotController(AgainAllotService againAllotService,
RoleService roleService, // RoleService roleService,
ClaimService claimService, // ClaimService claimService,
AllotService allotService, // AllotService allotService,
IWebHostEnvironment env, // IWebHostEnvironment env,
ConfigService configService, // ConfigService configService,
ComputeService computeService, // ComputeService computeService,
IOptions<Application> options) // IOptions<Application> options)
{ // {
this.againAllotService = againAllotService; // this.againAllotService = againAllotService;
this.roleService = roleService; // this.roleService = roleService;
this.claimService = claimService; // this.claimService = claimService;
this.allotService = allotService; // this.allotService = allotService;
this.env = env; // this.env = env;
this.configService = configService; // this.configService = configService;
this.computeService = computeService; // this.computeService = computeService;
this.application = options.Value; // this.application = options.Value;
} // }
/// <summary> // /// <summary>
/// 返回当前用户医院下绩效列表 // /// 返回当前用户医院下绩效列表
/// </summary> // /// </summary>
/// <returns></returns> // /// <returns></returns>
[Route("allotlist")] // [Route("allotlist")]
[HttpPost] // [HttpPost]
public ApiResponse AllotList() // public ApiResponse AllotList()
{ // {
var userId = claimService.GetUserId(); // var userId = claimService.GetUserId();
var list = againAllotService.GetAllotList(userId); // var list = againAllotService.GetAllotList(userId);
return new ApiResponse(ResponseType.OK, list); // return new ApiResponse(ResponseType.OK, list);
} // }
/// <summary> // /// <summary>
/// 上传文件 // /// 上传文件
/// </summary> // /// </summary>
/// <param name="form"></param> // /// <param name="form"></param>
/// <returns></returns> // /// <returns></returns>
[Route("import")] // [Route("import")]
[HttpPost] // [HttpPost]
public ApiResponse Import([FromForm] IFormCollection form) // public ApiResponse Import([FromForm] IFormCollection form)
{ // {
var againid = form.ToDictionary().GetValue("againid", 0); // var againid = form.ToDictionary().GetValue("againid", 0);
if (againid <= 0) // if (againid <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "againid无效"); // return new ApiResponse(ResponseType.Fail, "参数错误", "againid无效");
var file = ((FormFileCollection)form.Files).FirstOrDefault(); // var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null) // if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); // return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName)) // if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件"); // return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
var again = againAllotService.GetAgainallot(againid); // var again = againAllotService.GetAgainallot(againid);
if (again == null) // if (again == null)
return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在"); // return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在");
var allot = allotService.GetAllot(again.AllotID.Value); // var allot = allotService.GetAllot(again.AllotID.Value);
if (allot == null) // if (allot == null)
return new ApiResponse(ResponseType.Fail, "一次绩效记录不存在"); // return new ApiResponse(ResponseType.Fail, "一次绩效记录不存在");
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff"); // var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName); // var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(env.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}"); // var dpath = Path.Combine(env.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath); // FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}"); // var path = Path.Combine(dpath, $"{name}{ext}");
using (var stream = file.OpenReadStream()) // using (var stream = file.OpenReadStream())
{ // {
byte[] bytes = new byte[stream.Length]; // byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length); // stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes)) // if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败"); // return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
allot.Path = path; // allot.Path = path;
allot.Remark = EnumHelper.GetDescription(AllotStates.数据已上传); // allot.Remark = EnumHelper.GetDescription(AllotStates.数据已上传);
if (!againAllotService.Update(allot, againid)) // if (!againAllotService.Update(allot, againid))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败"); // return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
configService.ClearAgain(againid); // configService.ClearAgain(againid);
} // }
return new ApiResponse(ResponseType.OK); // return new ApiResponse(ResponseType.OK);
} // }
///// <summary> // ///// <summary>
///// 查看科室绩效 // ///// 查看科室绩效
///// </summary> // ///// </summary>
///// <param name="request"></param> // ///// <param name="request"></param>
///// <returns></returns> // ///// <returns></returns>
//[Route("departmentdetail")] // //[Route("departmentdetail")]
//[HttpPost] // //[HttpPost]
//public ApiResponse DepartmentDetail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request) // //public ApiResponse DepartmentDetail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
//{ // //{
// var userId = claimService.GetUserId(); // // var userId = claimService.GetUserId();
// var roles = roleService.GetUserRole(userId); // // var roles = roleService.GetUserRole(userId);
// var department = claimService.GetUserClaim(JwtClaimTypes.Department); // // var department = claimService.GetUserClaim(JwtClaimTypes.Department);
// var again = againAllotService.GetAgainallot(request.AgainAllotID); // // var again = againAllotService.GetAgainallot(request.AgainAllotID);
// if (again == null) // // if (again == null)
// return new ApiResponse(ResponseType.Fail, "当前二次绩效ID无效"); // // return new ApiResponse(ResponseType.Fail, "当前二次绩效ID无效");
// if (roles.First().Type == application.DirectorRole) // // if (roles.First().Type == application.DirectorRole)
// { // // {
// var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 1); // // var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 1);
// return new ApiResponse(ResponseType.OK, detail); // // return new ApiResponse(ResponseType.OK, detail);
// } // // }
// else if (roles.First().Type == application.NurseRole) // // else if (roles.First().Type == application.NurseRole)
// { // // {
// var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 2); // // var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 2);
// return new ApiResponse(ResponseType.OK, detail); // // return new ApiResponse(ResponseType.OK, detail);
// } // // }
// return new ApiResponse(ResponseType.Fail, "当前用户角色无法识别"); // // return new ApiResponse(ResponseType.Fail, "当前用户角色无法识别");
//} // //}
///// <summary> // ///// <summary>
///// 生成绩效 // ///// 生成绩效
///// </summary> // ///// </summary>
///// <param name="request"></param> // ///// <param name="request"></param>
///// <returns></returns> // ///// <returns></returns>
//[Route("generate")] // //[Route("generate")]
//[HttpPost] // //[HttpPost]
//public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request) // //public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
//{ // //{
// var userId = claimService.GetUserId(); // // var userId = claimService.GetUserId();
// var department = claimService.GetUserClaim(JwtClaimTypes.Department); // // var department = claimService.GetUserClaim(JwtClaimTypes.Department);
// var result = againAllotService.Generate(request, userId, department); // // var result = againAllotService.Generate(request, userId, department);
// return new ApiResponse(ResponseType.OK); // // return new ApiResponse(ResponseType.OK);
//} // //}
/// <summary> // /// <summary>
/// 查看绩效详情 // /// 查看绩效详情
/// </summary> // /// </summary>
/// <param name="request"></param> // /// <param name="request"></param>
/// <returns></returns> // /// <returns></returns>
[Route("detail")] // [Route("detail")]
[HttpPost] // [HttpPost]
public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody] AgainAllotRequest request) // public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody] AgainAllotRequest request)
{ // {
var result = againAllotService.Detail(request); // var result = againAllotService.Detail(request);
return new ApiResponse(ResponseType.OK, new { result.AgainSituation, result.SheetExport }); // return new ApiResponse(ResponseType.OK, new { result.AgainSituation, result.SheetExport });
} // }
} // }
} //}
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
"ExpirationMinutes": "1200", "ExpirationMinutes": "1200",
//验证码过期 //验证码过期
"SmsCodeMinutes": "5", "SmsCodeMinutes": "5",
//护士长二次绩效管理员 ////护士长二次绩效管理员
"NurseRole": "3", //"NurseRole": "3",
//科主任二次绩效管理员 ////科主任二次绩效管理员
"DirectorRole": "4", //"DirectorRole": "4",
//特殊科室二次绩效管理员 ////特殊科室二次绩效管理员
"SpecialRole": "9", //"SpecialRole": "9",
//数据收集角色(可查看所有) ////数据收集角色(可查看所有)
"CollectRoles": [ 1, 2, 5, 6, 7, 8 ], //"CollectRoles": [ 1, 2, 5, 6, 7, 8 ],
// 抽取结果Excel文件保存地址 // 抽取结果Excel文件保存地址
"AbsolutePath": "E:\\wwwroot\\testjx.suvalue.com", "AbsolutePath": "E:\\wwwroot\\testjx.suvalue.com",
// 抽取结果Excel文件保存地址 更替的 网络地址 // 抽取结果Excel文件保存地址 更替的 网络地址
......
...@@ -49,27 +49,6 @@ ...@@ -49,27 +49,6 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </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)"> <member name="M:Performance.Api.Controllers.AccountController.Password(Performance.DtoModels.PasswordRequest)">
<summary> <summary>
修改用户密码 修改用户密码
...@@ -149,29 +128,18 @@ ...@@ -149,29 +128,18 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:Performance.Api.Controllers.AgainAllotController"> <member name="M:Performance.Api.Controllers.AccountController.HistoryDepartment(System.Int32)">
<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)">
<summary> <summary>
上传文件 用户过往科室
</summary> </summary>
<param name="form"></param> <param name="userId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AgainAllotController.Detail(Performance.DtoModels.AgainAllotRequest)"> <member name="M:Performance.Api.Controllers.AccountController.DeleteHistoryDepartment(System.Int32)">
<summary> <summary>
查看绩效详情 删除用户过往科室
</summary> </summary>
<param name="request"></param> <param name="historyId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AllotController.List(Performance.DtoModels.AllotRequest)"> <member name="M:Performance.Api.Controllers.AllotController.List(Performance.DtoModels.AllotRequest)">
......
...@@ -34,31 +34,6 @@ ...@@ -34,31 +34,6 @@
短信模板 短信模板
</summary> </summary>
</member> </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"> <member name="P:Performance.DtoModels.AppSettings.Application.Receiver">
<summary> <summary>
邮件指定接收人 邮件指定接收人
...@@ -130,39 +105,6 @@ ...@@ -130,39 +105,6 @@
<member name="F:Performance.DtoModels.DbSrouceType.Performance"> <member name="F:Performance.DtoModels.DbSrouceType.Performance">
<summary> 绩效库 </summary> <summary> 绩效库 </summary>
</member> </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"> <member name="F:Performance.DtoModels.AgWorkloadType.PreAccountingReward">
<summary> <summary>
核算前奖励 核算前奖励
...@@ -735,9 +677,6 @@ ...@@ -735,9 +677,6 @@
是否需要二次分配 是否需要二次分配
</summary> </summary>
</member> </member>
<member name="T:Performance.DtoModels.UnitType">
<summary> 核算单元类型 </summary>
</member>
<member name="F:Performance.DtoModels.SheetType.Unidentifiable"> <member name="F:Performance.DtoModels.SheetType.Unidentifiable">
<summary> 无法识别 </summary> <summary> 无法识别 </summary>
</member> </member>
......
...@@ -8650,6 +8650,41 @@ ...@@ -8650,6 +8650,41 @@
父级ID 父级ID
</summary> </summary>
</member> </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"> <member name="T:Performance.EntityModels.sys_user_hospital">
<summary> <summary>
...@@ -9045,5 +9080,41 @@ ...@@ -9045,5 +9080,41 @@
预留金额 预留金额
</summary> </summary>
</member> </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> </members>
</doc> </doc>
...@@ -18,26 +18,26 @@ public class Application ...@@ -18,26 +18,26 @@ public class Application
/// 短信模板 /// 短信模板
/// </summary> /// </summary>
public string SmsTemplate { get; set; } public string SmsTemplate { get; set; }
/// <summary> ///// <summary>
/// 护士长二次绩效管理员 ///// 护士长二次绩效管理员
/// </summary> ///// </summary>
public int NurseRole { get; set; } //public int NurseRole { get; set; }
/// <summary> ///// <summary>
/// 科主任二次绩效管理员 ///// 科主任二次绩效管理员
/// </summary> ///// </summary>
public int DirectorRole { get; set; } //public int DirectorRole { get; set; }
/// <summary> ///// <summary>
/// 特殊科室二次绩效管理员 ///// 特殊科室二次绩效管理员
/// </summary> ///// </summary>
public int SpecialRole { get; set; } //public int SpecialRole { get; set; }
/// <summary> ///// <summary>
/// 数据收集角色(可查看所有) ///// 数据收集角色(可查看所有)
/// </summary> ///// </summary>
public int[] CollectRoles { get; set; } //public int[] CollectRoles { get; set; }
/// <summary> ///// <summary>
/// 行政科室二次绩效管理员 ///// 行政科室二次绩效管理员
/// </summary> ///// </summary>
public int OfficeRole { get; set; } //public int OfficeRole { get; set; }
/// <summary> /// <summary>
/// 邮件指定接收人 /// 邮件指定接收人
/// </summary> /// </summary>
......
...@@ -45,42 +45,6 @@ public enum DbSrouceType ...@@ -45,42 +45,6 @@ public enum DbSrouceType
Performance = 2, 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 public enum AgWorkloadType
{ {
...@@ -119,24 +83,6 @@ public enum DataFormat ...@@ -119,24 +83,6 @@ public enum DataFormat
日期YYYYMMDD 日期YYYYMMDD
} }
public enum Role
{
绩效管理员 = 1,
医院管理员 = 2,
护士长 = 3,
科主任 = 4,
绩效核算办 = 5,
院领导 = 6,
财务科 = 7,
人事科 = 8,
特殊科室 = 9,
行政科室 = 10,
数据收集 = 11,
护理部审核 = 12,
绩效查询 = 13,
审计 = 14,
}
public class Background public class Background
{ {
public enum JobType public enum JobType
......
...@@ -11,44 +11,6 @@ public enum ExcelVersion ...@@ -11,44 +11,6 @@ public enum ExcelVersion
xls 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 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();
}
}
}
using AutoMapper; //using AutoMapper;
using Microsoft.Extensions.Options; //using Microsoft.Extensions.Options;
using Performance.DtoModels; //using Performance.DtoModels;
using Performance.DtoModels.AppSettings; //using Performance.DtoModels.AppSettings;
using Performance.EntityModels; //using Performance.EntityModels;
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.Text;
namespace Performance.Services //namespace Performance.Services
{ //{
public class AgainAllotService : IAutoInjection // public class AgainAllotService : IAutoInjection
{ // {
private Application application; // private Application application;
private readonly IMapper _mapper; // private readonly IMapper _mapper;
private AgainService againService; // private AgainService againService;
private RoleService roleService; // private RoleService roleService;
private ConfigService configService; // private ConfigService configService;
private PerforCofagainRepository perforCofagainRepository; // private PerforCofagainRepository perforCofagainRepository;
private PerforPeragainallotRepository perforPeragainallotRepository; // private PerforPeragainallotRepository perforPeragainallotRepository;
private PerforResaccountRepository perforResaccountRepository; // private PerforResaccountRepository perforResaccountRepository;
//private PerforResaccountnurseRepository perforResaccountnurseRepository; // //private PerforResaccountnurseRepository perforResaccountnurseRepository;
private PerforUserRepository perforUserRepository; // private PerforUserRepository perforUserRepository;
private PerforUserhospitalRepository perforUserhospitalRepository; // private PerforUserhospitalRepository perforUserhospitalRepository;
private PerforPerallotRepository perforPerallotRepository; // private PerforPerallotRepository perforPerallotRepository;
private PerforAgagainsituationRepository perforAgagainsituationRepository; // private PerforAgagainsituationRepository perforAgagainsituationRepository;
private PerforAgdataRepository perforAgdataRepository; // private PerforAgdataRepository perforAgdataRepository;
private PerforAgemployeeRepository perforAgemployeeRepository; // private PerforAgemployeeRepository perforAgemployeeRepository;
private PerforAgheaderRepository perforAgheaderRepository; // private PerforAgheaderRepository perforAgheaderRepository;
public AgainAllotService( // public AgainAllotService(
IOptions<Application> options, // IOptions<Application> options,
IMapper mapper, // IMapper mapper,
AgainService againService, // AgainService againService,
RoleService roleService, // RoleService roleService,
PerforCofagainRepository perforCofagainRepository, // PerforCofagainRepository perforCofagainRepository,
PerforPeragainallotRepository perforPeragainallotRepository, // PerforPeragainallotRepository perforPeragainallotRepository,
PerforResaccountRepository perforResaccountRepository, // PerforResaccountRepository perforResaccountRepository,
//PerforResaccountnurseRepository perforResaccountnurseRepository, // //PerforResaccountnurseRepository perforResaccountnurseRepository,
PerforUserRepository perforUserRepository, // PerforUserRepository perforUserRepository,
PerforUserhospitalRepository perforUserhospitalRepository, // PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perforPerallotRepository, // PerforPerallotRepository perforPerallotRepository,
PerforAgagainsituationRepository perforAgagainsituationRepository, // PerforAgagainsituationRepository perforAgagainsituationRepository,
PerforAgdataRepository perforAgdataRepository, // PerforAgdataRepository perforAgdataRepository,
PerforAgemployeeRepository perforAgemployeeRepository, // PerforAgemployeeRepository perforAgemployeeRepository,
PerforAgheaderRepository perforAgheaderRepository, // PerforAgheaderRepository perforAgheaderRepository,
ConfigService configService) // ConfigService configService)
{ // {
this.application = options.Value; // this.application = options.Value;
_mapper = mapper; // _mapper = mapper;
this.againService = againService; // this.againService = againService;
this.roleService = roleService; // this.roleService = roleService;
this.perforCofagainRepository = perforCofagainRepository; // this.perforCofagainRepository = perforCofagainRepository;
this.perforPeragainallotRepository = perforPeragainallotRepository; // this.perforPeragainallotRepository = perforPeragainallotRepository;
this.perforResaccountRepository = perforResaccountRepository; // this.perforResaccountRepository = perforResaccountRepository;
//this.perforResaccountnurseRepository = perforResaccountnurseRepository; // //this.perforResaccountnurseRepository = perforResaccountnurseRepository;
this.perforUserRepository = perforUserRepository; // this.perforUserRepository = perforUserRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository; // this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perforPerallotRepository = perforPerallotRepository; // this.perforPerallotRepository = perforPerallotRepository;
this.perforAgagainsituationRepository = perforAgagainsituationRepository; // this.perforAgagainsituationRepository = perforAgagainsituationRepository;
this.perforAgdataRepository = perforAgdataRepository; // this.perforAgdataRepository = perforAgdataRepository;
this.perforAgemployeeRepository = perforAgemployeeRepository; // this.perforAgemployeeRepository = perforAgemployeeRepository;
this.perforAgheaderRepository = perforAgheaderRepository; // this.perforAgheaderRepository = perforAgheaderRepository;
this.configService = configService; // this.configService = configService;
} // }
///// <summary> // ///// <summary>
///// 生成二次绩效 // ///// 生成二次绩效
///// </summary> // ///// </summary>
///// <param name="request"></param> // ///// <param name="request"></param>
//public bool Generate(AgainAllotRequest request, int userId, string department) // //public bool Generate(AgainAllotRequest request, int userId, string department)
//{ // //{
// var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID); // // var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
// if (againAllot == null || againAllot.ID == 0) // // if (againAllot == null || againAllot.ID == 0)
// throw new PerformanceException("绩效二次分配不存在"); // // throw new PerformanceException("绩效二次分配不存在");
// var roles = roleService.GetRole(userId); // // var roles = roleService.GetRole(userId);
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; }); // // perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; });
// //清理二次绩效无用数据 // // //清理二次绩效无用数据
// configService.ClearAgain(againAllot.ID); // // configService.ClearAgain(againAllot.ID);
// try // // try
// { // // {
// #region 基础信息 // // #region 基础信息
// //获取基础配置信息 // // //获取基础配置信息
// var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID); // // var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID);
// var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value; // // var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value;
// var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value; // // var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value;
// var days = config.FirstOrDefault(t => t.Type == 3)?.Value; // // var days = config.FirstOrDefault(t => t.Type == 3)?.Value;
// decimal? basicnumber = 0m; // // decimal? basicnumber = 0m;
// //获取科室实发绩效 // // //获取科室实发绩效
// if (roles != null) // // if (roles != null)
// { // // {
// var role = roles.FirstOrDefault(); // // var role = roles.FirstOrDefault();
// if (role != null) // // if (role != null)
// { // // {
// if (application.NurseRole == role.Type) // // if (application.NurseRole == role.Type)
// basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee; // // basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
// else if (application.DirectorRole == role.Type) // // else if (application.DirectorRole == role.Type)
// basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType != (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee; // // basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType != (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
// } // // }
// } // // }
// #endregion // // #endregion
// #region 计算 // // #region 计算
// //读取二次计算excel数据 // // //读取二次计算excel数据
// var perAgainExcel = againService.ReadData(againAllot); // // var perAgainExcel = againService.ReadData(againAllot);
// //护士长或科主任出勤 // // //护士长或科主任出勤
// var bossAttendance = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.JobTitle == "护士长")?.Attendance; // // var bossAttendance = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.JobTitle == "护士长")?.Attendance;
// //计算职称出勤系数、年资出勤系数 // // //计算职称出勤系数、年资出勤系数
// foreach (var item in perAgainExcel.AgainEmployee) // // foreach (var item in perAgainExcel.AgainEmployee)
// { // // {
// item.JobAttendanceFactor = item.JobFactor * item.Attendance / days; // // item.JobAttendanceFactor = item.JobFactor * item.Attendance / days;
// item.YearAttendanceFactor = item.Attendance * item.YearFactor / days; // // item.YearAttendanceFactor = item.Attendance * item.YearFactor / days;
// } // // }
// //计算 科室系数人均 // // //计算 科室系数人均
// var departmentFactorAvg = basicnumber / perAgainExcel.AgainEmployee.Sum(t => t.YearAttendanceFactor); // // var departmentFactorAvg = basicnumber / perAgainExcel.AgainEmployee.Sum(t => t.YearAttendanceFactor);
// //二次分配科室概览 // // //二次分配科室概览
// PerAgainSituation situation = new PerAgainSituation // // PerAgainSituation situation = new PerAgainSituation
// { // // {
// NightShift = perAgainExcel.AgainEmployee.Sum(t => t.NightShift), // // NightShift = perAgainExcel.AgainEmployee.Sum(t => t.NightShift),
// DepartmentTotal = basicnumber, // // DepartmentTotal = basicnumber,
// BossPerfor = departmentFactorAvg * bossAttendance / days, // // BossPerfor = departmentFactorAvg * bossAttendance / days,
// Award = perAgainExcel.AgainEmployee.Sum(t => t.Award), // // Award = perAgainExcel.AgainEmployee.Sum(t => t.Award),
// Allowance = perAgainExcel.AgainEmployee.Sum(t => t.Allowance), // // Allowance = perAgainExcel.AgainEmployee.Sum(t => t.Allowance),
// AlonePerfor = perAgainExcel.AgainEmployee.Sum(t => t.AlonePerfor), // // AlonePerfor = perAgainExcel.AgainEmployee.Sum(t => t.AlonePerfor),
// Attendance = days, // // Attendance = days,
// DepartmentFactorAvg = departmentFactorAvg // // DepartmentFactorAvg = departmentFactorAvg
// }; // // };
// //业绩二次分配科室概览:业绩分配绩效、职称绩效、工作量绩效 // // //业绩二次分配科室概览:业绩分配绩效、职称绩效、工作量绩效
// situation.AllotPerfor = situation.DepartmentTotal - situation.BossPerfor - situation.Award - situation.Allowance - situation.AlonePerfor; // // situation.AllotPerfor = situation.DepartmentTotal - situation.BossPerfor - situation.Award - situation.Allowance - situation.AlonePerfor;
// situation.JobPerfor = situation.AllotPerfor * jobfactor; // // situation.JobPerfor = situation.AllotPerfor * jobfactor;
// situation.WorkloadPerfor = situation.AllotPerfor * workfactor; // // situation.WorkloadPerfor = situation.AllotPerfor * workfactor;
// var rowList = perAgainExcel.AgainData.Select(t => t.RowNumber).Distinct().ToList(); // // var rowList = perAgainExcel.AgainData.Select(t => t.RowNumber).Distinct().ToList();
// //业绩二次分配科室动态数据:工作量得分 // // //业绩二次分配科室动态数据:工作量得分
// foreach (var rowNumber in rowList) // // foreach (var rowNumber in rowList)
// { // // {
// var againEmployee = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.RowNumber == rowNumber); // // var againEmployee = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.RowNumber == rowNumber);
// var atRowList = perAgainExcel.AgainData.Where(t => t.RowNumber == rowNumber); // // var atRowList = perAgainExcel.AgainData.Where(t => t.RowNumber == rowNumber);
// decimal? sumValue = 0m; // // decimal? sumValue = 0m;
// foreach (var atRow in atRowList) // // foreach (var atRow in atRowList)
// sumValue += atRow.IsFactor == 1 ? atRow.IsFactor * atRow.CellValue : atRow.CellValue; // // sumValue += atRow.IsFactor == 1 ? atRow.IsFactor * atRow.CellValue : atRow.CellValue;
// sumValue = sumValue * againEmployee?.YearFactor; // // sumValue = sumValue * againEmployee?.YearFactor;
// var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "工作量得分"); // // var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "工作量得分");
// if (head == null) // // if (head == null)
// { // // {
// perAgainExcel.Header.MergeCell++; // // perAgainExcel.Header.MergeCell++;
// var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow); // // var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
// var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell); // // var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
// head = new PerHeader(pointrow, pointcell, "工作量得分", 1, 1, 1, null, 1); // // head = new PerHeader(pointrow, pointcell, "工作量得分", 1, 1, 1, null, 1);
// perAgainExcel.Header.Children.Add(head); // // perAgainExcel.Header.Children.Add(head);
// } // // }
// perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "工作量得分", sumValue, 1, 2, null, "", "", head.SignID)); // // perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "工作量得分", sumValue, 1, 2, null, "", "", head.SignID));
// } // // }
// //业绩二次分配科室动态数据:绩效工资 // // //业绩二次分配科室动态数据:绩效工资
// foreach (var rowNumber in rowList) // // foreach (var rowNumber in rowList)
// { // // {
// var workvalue = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == rowNumber && t.TypeName == "工作量得分")?.CellValue; // // var workvalue = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == rowNumber && t.TypeName == "工作量得分")?.CellValue;
// var sumvalue = perAgainExcel.AgainData.Where(t => t.TypeName == "工作量得分").Sum(t => t.CellValue); // // var sumvalue = perAgainExcel.AgainData.Where(t => t.TypeName == "工作量得分").Sum(t => t.CellValue);
// var perforValue = workvalue / sumvalue * situation.WorkloadPerfor; // // var perforValue = workvalue / sumvalue * situation.WorkloadPerfor;
// var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "绩效工资"); // // var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "绩效工资");
// if (head == null) // // if (head == null)
// { // // {
// perAgainExcel.Header.MergeCell++; // // perAgainExcel.Header.MergeCell++;
// var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow); // // var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
// var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell); // // var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
// head = new PerHeader(pointrow, pointcell, "绩效工资", 1, 1, 1, null, 1); // // head = new PerHeader(pointrow, pointcell, "绩效工资", 1, 1, 1, null, 1);
// perAgainExcel.Header.Children.Add(head); // // perAgainExcel.Header.Children.Add(head);
// } // // }
// perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "绩效工资", perforValue, 1, 2, null, "", "", head.SignID)); // // perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "绩效工资", perforValue, 1, 2, null, "", "", head.SignID));
// } // // }
// //业绩二次分配科室:应发绩效、实发绩效 // // //业绩二次分配科室:应发绩效、实发绩效
// string[] jobArray = new string[] { "护士长", "科主任" }; // // string[] jobArray = new string[] { "护士长", "科主任" };
// foreach (var employee in perAgainExcel.AgainEmployee) // // foreach (var employee in perAgainExcel.AgainEmployee)
// { // // {
// if (jobArray.Contains(employee.JobTitle)) // // if (jobArray.Contains(employee.JobTitle))
// { // // {
// employee.GiveFee = situation.BossPerfor; // // employee.GiveFee = situation.BossPerfor;
// employee.RealGiveFee = situation.BossPerfor; // // employee.RealGiveFee = situation.BossPerfor;
// } // // }
// else // // else
// { // // {
// employee.JobAttendancePerfor = situation.JobPerfor * employee.JobAttendanceFactor / perAgainExcel.AgainEmployee.Sum(t => t.JobAttendanceFactor); // // employee.JobAttendancePerfor = situation.JobPerfor * employee.JobAttendanceFactor / perAgainExcel.AgainEmployee.Sum(t => t.JobAttendanceFactor);
// var value = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == employee.RowNumber && t.TypeName == "绩效工资")?.CellValue; // // var value = perAgainExcel.AgainData.FirstOrDefault(t => t.RowNumber == employee.RowNumber && t.TypeName == "绩效工资")?.CellValue;
// employee.GiveFee = (employee.JobAttendancePerfor ?? 0) + (value ?? 0) + (employee.Award ?? 0) + (employee.Allowance ?? 0) + (employee.AlonePerfor ?? 0); // // employee.GiveFee = (employee.JobAttendancePerfor ?? 0) + (value ?? 0) + (employee.Award ?? 0) + (employee.Allowance ?? 0) + (employee.AlonePerfor ?? 0);
// employee.RealGiveFee = (employee.GiveFee ?? 0) + (employee.NightShift ?? 0); // // employee.RealGiveFee = (employee.GiveFee ?? 0) + (employee.NightShift ?? 0);
// } // // }
// } // // }
// #endregion // // #endregion
// #region 保存 // // #region 保存
// var againsituation = _mapper.Map<ag_againsituation>(situation); // // var againsituation = _mapper.Map<ag_againsituation>(situation);
// againsituation.AllotID = againAllot.AllotID; // // againsituation.AllotID = againAllot.AllotID;
// againsituation.AgainAllotID = againAllot.ID; // // againsituation.AgainAllotID = againAllot.ID;
// perforAgagainsituationRepository.Add(againsituation); // // perforAgagainsituationRepository.Add(againsituation);
// var employeeList = _mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee); // // var employeeList = _mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
// employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; }); // // employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgemployeeRepository.AddRange(employeeList.ToArray()); // // perforAgemployeeRepository.AddRange(employeeList.ToArray());
// var pHeader = _mapper.Map<ag_header>(perAgainExcel.Header); // // var pHeader = _mapper.Map<ag_header>(perAgainExcel.Header);
// pHeader.AllotID = againAllot.AllotID; // // pHeader.AllotID = againAllot.AllotID;
// pHeader.AgainAllotID = againAllot.ID; // // pHeader.AgainAllotID = againAllot.ID;
// var cHeaderList = _mapper.Map<List<ag_header>>(perAgainExcel.Header.Children); // // var cHeaderList = _mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
// cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; }); // // cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgheaderRepository.Add(pHeader); // // perforAgheaderRepository.Add(pHeader);
// perforAgheaderRepository.AddRange(cHeaderList.ToArray()); // // perforAgheaderRepository.AddRange(cHeaderList.ToArray());
// var dataList = _mapper.Map<List<ag_data>>(perAgainExcel.AgainData); // // var dataList = _mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
// dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; }); // // dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgdataRepository.AddRange(dataList.ToArray()); // // perforAgdataRepository.AddRange(dataList.ToArray());
// #endregion // // #endregion
// } // // }
// catch (Exception ex) // // catch (Exception ex)
// { // // {
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 4; p.Remark = ex.ToString(); }); // // perforPeragainallotRepository.Update(againAllot, p => { p.States = 4; p.Remark = ex.ToString(); });
// } // // }
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 3; }); // // perforPeragainallotRepository.Update(againAllot, p => { p.States = 3; });
// return true; // // return true;
// //return SheetFormat(perAgainExcel, situation); // // //return SheetFormat(perAgainExcel, situation);
//} // //}
/// <summary> // /// <summary>
/// 绩效详情表格转换 // /// 绩效详情表格转换
/// </summary> // /// </summary>
/// <param name="perAgainExcel"></param> // /// <param name="perAgainExcel"></param>
/// <param name="situation"></param> // /// <param name="situation"></param>
/// <returns></returns> // /// <returns></returns>
private (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) SheetFormat(PerAgainExcel perAgainExcel, PerAgainSituation situation) // private (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) SheetFormat(PerAgainExcel perAgainExcel, PerAgainSituation situation)
{ // {
#region 表格显示 // #region 表格显示
SheetExportResponse response = new SheetExportResponse("二次绩效分配表"); // SheetExportResponse response = new SheetExportResponse("二次绩效分配表");
//返回表格展示数据结构 // //返回表格展示数据结构
var row = new Row(0); // var row = new Row(0);
row.Data.Add(new Cell(1, "姓名", 2, 1, false, false)); // row.Data.Add(new Cell(1, "姓名", 2, 1, false, false));
row.Data.Add(new Cell(2, "职务", 2, 1, false, false)); // row.Data.Add(new Cell(2, "职务", 2, 1, false, false));
row.Data.Add(new Cell(3, "职称系数", 2, 1, false, false)); // row.Data.Add(new Cell(3, "职称系数", 2, 1, false, false));
row.Data.Add(new Cell(4, "出勤", 2, 1, false, false)); // row.Data.Add(new Cell(4, "出勤", 2, 1, false, false));
row.Data.Add(new Cell(5, "职称出勤系数", 2, 1, false, false)); // row.Data.Add(new Cell(5, "职称出勤系数", 2, 1, false, false));
row.Data.Add(new Cell(6, "年资", 2, 1, false, false)); // row.Data.Add(new Cell(6, "年资", 2, 1, false, false));
row.Data.Add(new Cell(7, "年资出勤系数", 2, 1, false, false)); // row.Data.Add(new Cell(7, "年资出勤系数", 2, 1, false, false));
row.Data.Add(new Cell(8, "职称出勤绩效", 2, 1, false, false)); // row.Data.Add(new Cell(8, "职称出勤绩效", 2, 1, false, false));
row.Data.Add(new Cell(9, perAgainExcel.Header.CellValue, 1, perAgainExcel.Header.Children.Count, false, false)); // row.Data.Add(new Cell(9, perAgainExcel.Header.CellValue, 1, perAgainExcel.Header.Children.Count, false, false));
row.Data.Add(new Cell(9 + perAgainExcel.Header.Children.Count, "重点奖励", 2, 1, false, false)); // row.Data.Add(new Cell(9 + perAgainExcel.Header.Children.Count, "重点奖励", 2, 1, false, false));
row.Data.Add(new Cell(10 + perAgainExcel.Header.Children.Count, "管理津贴", 2, 1, false, false)); // row.Data.Add(new Cell(10 + perAgainExcel.Header.Children.Count, "管理津贴", 2, 1, false, false));
row.Data.Add(new Cell(11 + perAgainExcel.Header.Children.Count, "单独核算人员绩效", 2, 1, false, false)); // row.Data.Add(new Cell(11 + perAgainExcel.Header.Children.Count, "单独核算人员绩效", 2, 1, false, false));
row.Data.Add(new Cell(12 + perAgainExcel.Header.Children.Count, "应发绩效工资金额", 2, 1, false, false)); // row.Data.Add(new Cell(12 + perAgainExcel.Header.Children.Count, "应发绩效工资金额", 2, 1, false, false));
row.Data.Add(new Cell(13 + perAgainExcel.Header.Children.Count, "夜班费", 2, 1, false, false)); // row.Data.Add(new Cell(13 + perAgainExcel.Header.Children.Count, "夜班费", 2, 1, false, false));
row.Data.Add(new Cell(14 + perAgainExcel.Header.Children.Count, "实发工资合计", 2, 1, false, false)); // row.Data.Add(new Cell(14 + perAgainExcel.Header.Children.Count, "实发工资合计", 2, 1, false, false));
var rowTwo = new Row(1); // var rowTwo = new Row(1);
int startpoint = 9; // int startpoint = 9;
perAgainExcel.Header.Children.ForEach(t => // perAgainExcel.Header.Children.ForEach(t =>
{ // {
rowTwo.Data.Add(new Cell(startpoint, t.CellValue, 1, 1, false, false)); // rowTwo.Data.Add(new Cell(startpoint, t.CellValue, 1, 1, false, false));
startpoint++; // startpoint++;
}); // });
response.Header.Add(row); // response.Header.Add(row);
response.Header.Add(rowTwo); // response.Header.Add(rowTwo);
for (int i = 0; i < perAgainExcel.AgainEmployee.Count(); i++) // for (int i = 0; i < perAgainExcel.AgainEmployee.Count(); i++)
{ // {
var item = perAgainExcel.AgainEmployee.ElementAt(i); // var item = perAgainExcel.AgainEmployee.ElementAt(i);
var rowbody = new Row(i); // var rowbody = new Row(i);
rowbody.Data.Add(new Cell(1, item.Name, 1, 1, false, false)); // rowbody.Data.Add(new Cell(1, item.Name, 1, 1, false, false));
rowbody.Data.Add(new Cell(2, item.JobTitle, 1, 1, false, false)); // rowbody.Data.Add(new Cell(2, item.JobTitle, 1, 1, false, false));
rowbody.Data.Add(new Cell(3, item.JobFactor, 1, 1, false, false)); // rowbody.Data.Add(new Cell(3, item.JobFactor, 1, 1, false, false));
rowbody.Data.Add(new Cell(4, item.Attendance, 1, 1, false, false)); // rowbody.Data.Add(new Cell(4, item.Attendance, 1, 1, false, false));
rowbody.Data.Add(new Cell(5, item.JobAttendanceFactor, 1, 1, false, false)); // rowbody.Data.Add(new Cell(5, item.JobAttendanceFactor, 1, 1, false, false));
rowbody.Data.Add(new Cell(6, item.YearFactor, 1, 1, false, false)); // rowbody.Data.Add(new Cell(6, item.YearFactor, 1, 1, false, false));
rowbody.Data.Add(new Cell(7, item.YearAttendanceFactor, 1, 1, false, false)); // rowbody.Data.Add(new Cell(7, item.YearAttendanceFactor, 1, 1, false, false));
rowbody.Data.Add(new Cell(8, item.JobAttendancePerfor, 1, 1, false, false)); // rowbody.Data.Add(new Cell(8, item.JobAttendancePerfor, 1, 1, false, false));
var againList = perAgainExcel.AgainData.Where(t => t.RowNumber == item.RowNumber); // var againList = perAgainExcel.AgainData.Where(t => t.RowNumber == item.RowNumber);
startpoint = 9; // startpoint = 9;
perAgainExcel.Header.Children.ForEach(t => // perAgainExcel.Header.Children.ForEach(t =>
{ // {
var cellValue = againList.FirstOrDefault(s => t.SignID == s.SignID)?.CellValue; // var cellValue = againList.FirstOrDefault(s => t.SignID == s.SignID)?.CellValue;
rowbody.Data.Add(new Cell(startpoint, cellValue, 1, 1, false, false)); // rowbody.Data.Add(new Cell(startpoint, cellValue, 1, 1, false, false));
startpoint++; // startpoint++;
}); // });
rowbody.Data.Add(new Cell(9 + perAgainExcel.Header.Children.Count, item.Award, 1, 1, false, false)); // rowbody.Data.Add(new Cell(9 + perAgainExcel.Header.Children.Count, item.Award, 1, 1, false, false));
rowbody.Data.Add(new Cell(10 + perAgainExcel.Header.Children.Count, item.Allowance, 1, 1, false, false)); // rowbody.Data.Add(new Cell(10 + perAgainExcel.Header.Children.Count, item.Allowance, 1, 1, false, false));
rowbody.Data.Add(new Cell(11 + perAgainExcel.Header.Children.Count, item.AlonePerfor, 1, 1, false, false)); // rowbody.Data.Add(new Cell(11 + perAgainExcel.Header.Children.Count, item.AlonePerfor, 1, 1, false, false));
rowbody.Data.Add(new Cell(12 + perAgainExcel.Header.Children.Count, item.GiveFee, 1, 1, false, false)); // rowbody.Data.Add(new Cell(12 + perAgainExcel.Header.Children.Count, item.GiveFee, 1, 1, false, false));
rowbody.Data.Add(new Cell(13 + perAgainExcel.Header.Children.Count, item.NightShift, 1, 1, false, false)); // rowbody.Data.Add(new Cell(13 + perAgainExcel.Header.Children.Count, item.NightShift, 1, 1, false, false));
rowbody.Data.Add(new Cell(14 + perAgainExcel.Header.Children.Count, item.RealGiveFee, 1, 1, false, false)); // rowbody.Data.Add(new Cell(14 + perAgainExcel.Header.Children.Count, item.RealGiveFee, 1, 1, false, false));
response.Row.Add(rowbody); // response.Row.Add(rowbody);
} // }
#endregion // #endregion
return (response, situation); // return (response, situation);
} // }
/// <summary> // /// <summary>
/// 查看二次分配详情及概览 // /// 查看二次分配详情及概览
/// </summary> // /// </summary>
/// <param name="request"></param> // /// <param name="request"></param>
/// <param name="user"></param> // /// <param name="user"></param>
/// <returns></returns> // /// <returns></returns>
public (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) Detail(AgainAllotRequest request) // public (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) Detail(AgainAllotRequest request)
{ // {
var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID); // var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
if (againAllot == null || againAllot.ID == 0) // if (againAllot == null || againAllot.ID == 0)
throw new PerformanceException("绩效二次分配不存在"); // throw new PerformanceException("绩效二次分配不存在");
var situation = perforAgagainsituationRepository.GetEntity(t => t.AgainAllotID == againAllot.ID); // var situation = perforAgagainsituationRepository.GetEntity(t => t.AgainAllotID == againAllot.ID);
var againsituation = _mapper.Map<PerAgainSituation>(situation); // var againsituation = _mapper.Map<PerAgainSituation>(situation);
var againEmployee = perforAgemployeeRepository.GetEntities(t => t.AgainAllotID == againAllot.ID); // var againEmployee = perforAgemployeeRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var employeeList = _mapper.Map<List<PerAgainEmployee>>(againEmployee); // //var employeeList = _mapper.Map<List<PerAgainEmployee>>(againEmployee);
var header = perforAgheaderRepository.GetEntities(t => t.AgainAllotID == againAllot.ID); // var header = perforAgheaderRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var headerList = _mapper.Map<List<PerHeader>>(header); // //var headerList = _mapper.Map<List<PerHeader>>(header);
var data = perforAgdataRepository.GetEntities(t => t.AgainAllotID == againAllot.ID); // var data = perforAgdataRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var dataList = _mapper.Map<List<PerAgainData>>(data); // //var dataList = _mapper.Map<List<PerAgainData>>(data);
var pHead = header.FirstOrDefault(t => t.CellValue == "工作量绩效工资"); // var pHead = header.FirstOrDefault(t => t.CellValue == "工作量绩效工资");
var head = _mapper.Map<PerHeader>(pHead); // var head = _mapper.Map<PerHeader>(pHead);
var cHead = _mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资")); // var cHead = _mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资"));
head.Children = cHead; // head.Children = cHead;
var perAgainExcel = new PerAgainExcel // var perAgainExcel = new PerAgainExcel
{ // {
Header = head, // Header = head,
AgainData = _mapper.Map<List<PerAgainData>>(data), // AgainData = _mapper.Map<List<PerAgainData>>(data),
AgainEmployee = _mapper.Map<List<PerAgainEmployee>>(againEmployee) // AgainEmployee = _mapper.Map<List<PerAgainEmployee>>(againEmployee)
}; // };
return SheetFormat(perAgainExcel, againsituation); // return SheetFormat(perAgainExcel, againsituation);
} // }
/// <summary> // /// <summary>
/// 二次绩效新增记录 // /// 二次绩效新增记录
/// </summary> // /// </summary>
/// <param name="allot"></param> // /// <param name="allot"></param>
/// <param name="userid"></param> // /// <param name="userid"></param>
/// <returns></returns> // /// <returns></returns>
public bool Update(per_allot allot, int againid) // public bool Update(per_allot allot, int againid)
{ // {
var again = perforPeragainallotRepository.GetEntity(t => t.ID == againid); // var again = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
again.ID = againid; // again.ID = againid;
again.UploadDateTime = DateTime.Now; // again.UploadDateTime = DateTime.Now;
again.Path = allot.Path; // again.Path = allot.Path;
again.Remark = allot.Remark; // again.Remark = allot.Remark;
again.States = 1; // again.States = 1;
return perforPeragainallotRepository.Update(again); // return perforPeragainallotRepository.Update(again);
} // }
/// <summary> // /// <summary>
/// 根据人物角色获取绩效列表 // /// 根据人物角色获取绩效列表
/// </summary> // /// </summary>
/// <returns></returns> // /// <returns></returns>
public List<AgainAllotResponse> GetAllotList(int userid) // public List<AgainAllotResponse> GetAllotList(int userid)
{ // {
var user = perforUserRepository.GetEntity(t => t.ID == userid); // var user = perforUserRepository.GetEntity(t => t.ID == userid);
if (user == null) // if (user == null)
throw new NotImplementedException("人员ID无效"); // throw new NotImplementedException("人员ID无效");
var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userid); // var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userid);
if (hospital == null) // if (hospital == null)
throw new NotImplementedException("人员未选择医院"); // throw new NotImplementedException("人员未选择医院");
var allot = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.States == 6); // var allot = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.States == 6);
if (allot == null) // if (allot == null)
throw new NotImplementedException("该医院未生成绩效"); // throw new NotImplementedException("该医院未生成绩效");
var allotId = allot.Select(t => t.ID).ToList(); // var allotId = allot.Select(t => t.ID).ToList();
var again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.Department == user.Department); // var again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.Department == user.Department);
var arrId = again == null ? new List<int>() : again.Select(t => t.AllotID.Value).ToList(); // var arrId = again == null ? new List<int>() : again.Select(t => t.AllotID.Value).ToList();
//取得未生成二次绩效的绩效id // //取得未生成二次绩效的绩效id
var exceptId = allotId.Except(arrId).ToList(); // var exceptId = allotId.Except(arrId).ToList();
if (exceptId.Count > 0) // if (exceptId.Count > 0)
{ // {
allot = allot.Where(t => exceptId.Contains(t.ID)).ToList(); // allot = allot.Where(t => exceptId.Contains(t.ID)).ToList();
var model = allot.Select(t => new per_againallot // var model = allot.Select(t => new per_againallot
{ // {
AllotID = t.ID, // AllotID = t.ID,
CreateUser = userid, // CreateUser = userid,
CreateDateTime = DateTime.Now, // CreateDateTime = DateTime.Now,
Department = user.Department, // Department = user.Department,
States = 0 // States = 0
}); // });
//生成二次绩效 // //生成二次绩效
perforPeragainallotRepository.AddRange(model.ToArray()); // perforPeragainallotRepository.AddRange(model.ToArray());
} // }
again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.CreateUser == userid); // again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.CreateUser == userid);
List<AgainAllotResponse> list = _mapper.Map<List<AgainAllotResponse>>(again); // List<AgainAllotResponse> list = _mapper.Map<List<AgainAllotResponse>>(again);
list.ForEach(t => // list.ForEach(t =>
{ // {
var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault(); // var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault();
t.Year = data.Year; // t.Year = data.Year;
t.Month = data.Month; // t.Month = data.Month;
}); // });
return list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList(); // return list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
} // }
/// <summary> // /// <summary>
/// 获取状态不是归档的二次绩效的记录 // /// 获取状态不是归档的二次绩效的记录
/// </summary> // /// </summary>
/// <param name="againid"></param> // /// <param name="againid"></param>
/// <returns></returns> // /// <returns></returns>
public per_againallot GetAgainallot(int againid) // public per_againallot GetAgainallot(int againid)
{ // {
var list = perforPeragainallotRepository.GetEntity(t => t.ID == againid && t.States != 5); // var list = perforPeragainallotRepository.GetEntity(t => t.ID == againid && t.States != 5);
return list; // return list;
} // }
} // }
} //}
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -30,6 +31,7 @@ public class AllotService : IAutoInjection ...@@ -30,6 +31,7 @@ public class AllotService : IAutoInjection
private IWebHostEnvironment _evn; private IWebHostEnvironment _evn;
private ILogger<AllotService> _logger; private ILogger<AllotService> _logger;
private readonly IMapper _mapper; private readonly IMapper _mapper;
private readonly PerforUserRepository _userRepository;
private PerforPerallotRepository _allotRepository; private PerforPerallotRepository _allotRepository;
private IEmailService emailService; private IEmailService emailService;
private readonly IOptions<Application> options; private readonly IOptions<Application> options;
...@@ -55,6 +57,7 @@ public class AllotService : IAutoInjection ...@@ -55,6 +57,7 @@ public class AllotService : IAutoInjection
public AllotService( public AllotService(
IMapper mapper, IMapper mapper,
PerforUserRepository userRepository,
PerforPerallotRepository allotRepository, PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService, BaiscNormService baiscNormService,
ImportDataService importDataService, ImportDataService importDataService,
...@@ -85,6 +88,7 @@ public class AllotService : IAutoInjection ...@@ -85,6 +88,7 @@ public class AllotService : IAutoInjection
QueryDataService queryDataService) QueryDataService queryDataService)
{ {
_mapper = mapper; _mapper = mapper;
_userRepository = userRepository;
_allotRepository = allotRepository; _allotRepository = allotRepository;
_againallotRepository = againallotRepository; _againallotRepository = againallotRepository;
_logger = logger; _logger = logger;
...@@ -650,26 +654,19 @@ public List<log_dbug> AllotLog(per_allot allot, int type) ...@@ -650,26 +654,19 @@ public List<log_dbug> AllotLog(per_allot allot, int type)
/// <returns></returns> /// <returns></returns>
public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int userid) public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int userid)
{ {
var user = userService.GetUser(userid); var userInfo = _userRepository.GetUser(userid);
if (user == null) if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
throw new PerformanceException("用户信息错误"); if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
var role = roleService.GetUserRole(userid)?.FirstOrDefault()?.Type;
if (!role.HasValue)
throw new PerformanceException("用户信息错误");
var reserveds = _reportRepository.GetEmployeeReserved(hospitalId, year); var reserveds = _reportRepository.GetEmployeeReserved(hospitalId, year);
if (reserveds != null && reserveds.Any()) if (reserveds != null && reserveds.Any())
{ {
if (role.Value == options.Value.NurseRole) Expression<Func<EmployeeReservedDto, bool>> exp = w => w.AccountingUnit == userInfo.User.Department;
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.护理组, UnitType.其他护理组) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.DirectorRole) if (userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.医生组, UnitType.其他医生组, UnitType.医技组, UnitType.其他医技组) && w.AccountingUnit == user.Department)?.ToList(); exp = exp.And(t => UnitTypeUtil.Maps[userInfo.URole.Type.Value].Contains(t.UnitType));
else if (role.Value == options.Value.SpecialRole) reserveds = reserveds.Where(exp.Compile())?.ToList();
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();
} }
return reserveds; return reserveds;
......
...@@ -250,7 +250,7 @@ public IEnumerable<collect_permission> GetCollectSheet(int hospitalId, int userI ...@@ -250,7 +250,7 @@ public IEnumerable<collect_permission> GetCollectSheet(int hospitalId, int userI
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
if (userrole == null) return new List<collect_permission>(); 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 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>(); 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 ...@@ -77,12 +77,12 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro
var account = GetAccounting(allotId, roleType, Department); var account = GetAccounting(allotId, roleType, Department);
Expression<Func<cost_transfer, bool>> exp = t => t.AllotId == allotId; Expression<Func<cost_transfer, bool>> exp = t => t.AllotId == allotId;
if (roleType == application.DirectorRole) if (roleType == (int)Role.科主任)
if (menuType == 1) if (menuType == 1)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.ApplicantUnitType)); exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.ApplicantUnitType));
else else
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.AdoptedUnitType)); 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) if (menuType == 1)
exp = exp.And(t => t.ApplicantUnitType == UnitType.护理组.ToString()); exp = exp.And(t => t.ApplicantUnitType == UnitType.护理组.ToString());
else else
...@@ -149,14 +149,9 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro ...@@ -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) public cof_accounting GetAccounting(int allotId, int roleType, string Department = null)
{ {
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 (roleType == application.DirectorRole)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType)); if (UnitTypeUtil.Maps.ContainsKey(roleType))
else if (roleType == application.NurseRole) exp = exp.And(t => UnitTypeUtil.Maps[roleType].Contains(t.UnitType));
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());
var account = cofaccountingRepository.GetEntity(exp); var account = cofaccountingRepository.GetEntity(exp);
......
...@@ -23,6 +23,7 @@ public class CustomExtractService : IAutoInjection ...@@ -23,6 +23,7 @@ public class CustomExtractService : IAutoInjection
private readonly IOptions<Application> _options; private readonly IOptions<Application> _options;
private readonly UserService _userService; private readonly UserService _userService;
private readonly RoleService _roleService; private readonly RoleService _roleService;
private readonly PerforUserRepository _userRepository;
private readonly PerforPerallotRepository _perallotRepository; private readonly PerforPerallotRepository _perallotRepository;
private readonly PerforPerdeptdicRepository _perforPerdeptdicRepository; private readonly PerforPerdeptdicRepository _perforPerdeptdicRepository;
private readonly PerforHospitalconfigRepository _perforHospitalconfigRepository; private readonly PerforHospitalconfigRepository _perforHospitalconfigRepository;
...@@ -34,6 +35,7 @@ public class CustomExtractService : IAutoInjection ...@@ -34,6 +35,7 @@ public class CustomExtractService : IAutoInjection
IOptions<Application> options, IOptions<Application> options,
UserService userService, UserService userService,
RoleService roleService, RoleService roleService,
PerforUserRepository userRepository,
PerforPerallotRepository perallotRepository, PerforPerallotRepository perallotRepository,
PerforPerdeptdicRepository perforPerdeptdicRepository, PerforPerdeptdicRepository perforPerdeptdicRepository,
PerforHospitalconfigRepository perforHospitalconfigRepository, PerforHospitalconfigRepository perforHospitalconfigRepository,
...@@ -44,6 +46,7 @@ public class CustomExtractService : IAutoInjection ...@@ -44,6 +46,7 @@ public class CustomExtractService : IAutoInjection
_options = options; _options = options;
_userService = userService; _userService = userService;
_roleService = roleService; _roleService = roleService;
_userRepository = userRepository;
_perallotRepository = perallotRepository; _perallotRepository = perallotRepository;
_perforPerdeptdicRepository = perforPerdeptdicRepository; _perforPerdeptdicRepository = perforPerdeptdicRepository;
_perforHospitalconfigRepository = perforHospitalconfigRepository; _perforHospitalconfigRepository = perforHospitalconfigRepository;
...@@ -57,8 +60,8 @@ public bool CheckConfigScript(int userId, int allotId) ...@@ -57,8 +60,8 @@ public bool CheckConfigScript(int userId, int allotId)
?? throw new PerformanceException("绩效ID无效"); ?? throw new PerformanceException("绩效ID无效");
var scripts = _perforcustscriptRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.IsEnable == 1); var scripts = _perforcustscriptRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.IsEnable == 1);
var center = _userRepository.GetUser(userId);
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.IsSecondAllot == 1).ToList()
: scripts?.Where(w => w.IsOnceAllot == 1).ToList(); : scripts?.Where(w => w.IsOnceAllot == 1).ToList();
...@@ -74,9 +77,11 @@ public bool ExtractData(int userId, int allotId, out string resultFilePath) ...@@ -74,9 +77,11 @@ public bool ExtractData(int userId, int allotId, out string resultFilePath)
var filePath = ExtractHelper.GetExtractFile(allot.HospitalId); var filePath = ExtractHelper.GetExtractFile(allot.HospitalId);
resultFilePath = filePath; resultFilePath = filePath;
var center = _userRepository.GetUser(userId);
var scripts = _perforcustscriptRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.IsEnable == 1); 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.IsSecondAllot == 1).ToList()
: scripts?.Where(w => w.IsOnceAllot == 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 ...@@ -132,7 +137,12 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
?? throw new PerformanceException("当前医院没有数据库地址配置"); ?? throw new PerformanceException("当前医院没有数据库地址配置");
var parameters = GetParameters(allot); 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}'"); parameters.Add("@department", $"'{department}'");
if (unitType != null && unitType.Any()) if (unitType != null && unitType.Any())
parameters.Add("@unittype", $"{string.Join(", ", unitType.Select(t => $"'{t}'"))}"); parameters.Add("@unittype", $"{string.Join(", ", unitType.Select(t => $"'{t}'"))}");
...@@ -292,44 +302,5 @@ public IEnumerable<dynamic> QueryData(sys_hospitalconfig config, string execsql, ...@@ -292,44 +302,5 @@ public IEnumerable<dynamic> QueryData(sys_hospitalconfig config, string execsql,
}; };
return pairs; 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) ...@@ -188,12 +188,15 @@ public List<per_employee> GetPerEmployee(int allotId)
/// <returns></returns> /// <returns></returns>
public List<per_employee> GetPersons(int allotId, int userId) 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; Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId;
if (!string.IsNullOrEmpty(dept) && unittype.Any()) if (!string.IsNullOrEmpty(dept) && unittype.Any())
{
exp = exp.And(t => t.AccountingUnit == dept && unittype.Contains(t.UnitType)); exp = exp.And(t => t.AccountingUnit == dept && unittype.Contains(t.UnitType));
}
var list = peremployeeRepository.GetEntities(exp); var list = peremployeeRepository.GetEntities(exp);
if (list != null && list.Any()) if (list != null && list.Any())
...@@ -209,17 +212,18 @@ public List<per_employee> GetPersons(int allotId, int userId) ...@@ -209,17 +212,18 @@ public List<per_employee> GetPersons(int allotId, int userId)
/// <returns></returns> /// <returns></returns>
public PageList<per_employee> GetPersons(int allotId, int userId, PersonParamsRequest request) 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; Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId;
if (!string.IsNullOrEmpty(dept) && unittype.Any()) if (!string.IsNullOrEmpty(dept) && unittype.Any())
{
exp = exp.And(t => t.AccountingUnit == dept && unittype.Contains(t.UnitType)); exp = exp.And(t => t.AccountingUnit == dept && unittype.Contains(t.UnitType));
}
if (request != null && !string.IsNullOrEmpty(request.SearchQuery)) 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))); 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>(); var result = new List<per_employee>();
...@@ -446,31 +450,23 @@ public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId) ...@@ -446,31 +450,23 @@ public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId)
return result.OrderBy(w => w.IsVerify).ThenByDescending(t => t.CreateTime).ThenBy(t => t.Department); return result.OrderBy(w => w.IsVerify).ThenByDescending(t => t.CreateTime).ThenBy(t => t.Department);
} }
private (string dept, string[] unittype) GetDeptByUser(int userId) //private (string dept, string[] unittype) GetDeptByUser(int userId)
{ //{
var user = perforUserRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1); // var user = perforUserRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (user == null) throw new PerformanceException("用户信息错误"); // if (user == null) throw new PerformanceException("用户信息错误");
var userrole = perforUserroleRepository.GetEntity(t => t.UserID == user.ID); // var userrole = perforUserroleRepository.GetEntity(t => t.UserID == user.ID);
var role = perforRoleRepository.GetEntity(t => t.ID == userrole.RoleID); // 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[]> // if (UnitTypeUtil.Maps.ContainsKey(role.Type.Value))
{ // {
{ application.DirectorRole, new string[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } }, // return (user.Department, UnitTypeUtil.Maps[role.Type.Value]);
{ 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]);
}
return ("", new string[] { }); // return ("", new string[] { });
} //}
private Deptdic GetDeptdic(per_dept_dic dic) private Deptdic GetDeptdic(per_dept_dic dic)
{ {
...@@ -636,7 +632,8 @@ public List<TitleValue> DeptDics(int hospitalId, int type) ...@@ -636,7 +632,8 @@ public List<TitleValue> DeptDics(int hospitalId, int type)
/// <returns></returns> /// <returns></returns>
public object DeptWorkloadDetail(WorkDetailRequest request, int userId) 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[] { }; if (unitTypes == null || !unitTypes.Any()) return new string[] { };
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
...@@ -667,7 +664,8 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId) ...@@ -667,7 +664,8 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
/// <returns></returns> /// <returns></returns>
public object DeptIncomeDetail(WorkDetailRequest request, int userId) 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[] { }; if (unitTypes == null || !unitTypes.Any()) return new string[] { };
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
...@@ -694,27 +692,6 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId) ...@@ -694,27 +692,6 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
return new string[] { }; 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) public HandsonTable GetBatchPersonStructrue(int hospitalId)
{ {
......
...@@ -65,7 +65,8 @@ public List<SelectionOptions> GetReportSelection(int groupId, int userId, int ho ...@@ -65,7 +65,8 @@ public List<SelectionOptions> GetReportSelection(int groupId, int userId, int ho
if (selections == null) if (selections == null)
return options; 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 }; 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))) 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, ...@@ -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)) var selections = selectionRepository.GetEntities(w => arr2.Contains(w.ID) && w.State.HasValue && dispaly.Contains(w.State.Value))
?? new List<rep_selection>(); ?? new List<rep_selection>();
var isMedical = IsMedical(userId); var userInfo = userRepository.GetUser(userId);
var department = GetUserDepartment(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>(); List<ReportData> result = new List<ReportData>();
foreach (var report in reports) foreach (var report in reports)
...@@ -358,16 +360,6 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection ...@@ -358,16 +360,6 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection
return content; 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) private string GetUserDepartment(int userId)
{ {
......
...@@ -739,7 +739,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is ...@@ -739,7 +739,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
var role = _userService.GetUserFirstRole(userId); var role = _userService.GetUserFirstRole(userId);
//行政科室 只有两种逻辑,或从保存中加载,或加载EXCEL表 //行政科室 只有两种逻辑,或从保存中加载,或加载EXCEL表
if (role?.Type == _application.OfficeRole) if (role?.Type == (int)Role.行政科室)
{ {
// 如果已经保存>>走保存加载逻辑 // 如果已经保存>>走保存加载逻辑
if (employeeSource == (int)EmployeeSource.Initial) if (employeeSource == (int)EmployeeSource.Initial)
......
...@@ -128,32 +128,35 @@ ComputeService computeService ...@@ -128,32 +128,35 @@ ComputeService computeService
/// <returns></returns> /// <returns></returns>
public List<SecondListResponse> GetSecondList(int userId) public List<SecondListResponse> GetSecondList(int userId)
{ {
var user = userRepository.GetEntity(t => t.ID == userId); var userInfo = userRepository.GetUser(userId);
if (user == null) if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
throw new NotImplementedException("人员ID无效");
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
var userhospital = userhospitalRepository.GetEntity(t => t.UserID == userId); if (userInfo?.Hospitals == null) throw new NotImplementedException("当前用户暂未分配医院");
if (userhospital == null)
throw new NotImplementedException("人员未选择医院"); var status = new List<int> { (int)AllotStates.绩效下发, (int)AllotStates.归档, (int)AllotStates.绩效结果解析成功 };
var allotList = perallotRepository.GetEntities(t => t.HospitalId == userhospital.HospitalID && new List<int> { 6, 8, 10 }.Contains(t.States)); var allotList = perallotRepository.GetEntities(t => userInfo.HospitalIds.Contains(t.HospitalId) && status.Contains(t.States));
if (allotList == null || allotList.Count == 0) if (allotList == null || allotList.Count == 0) return new List<SecondListResponse>();
return new List<SecondListResponse>();
var allotListId = allotList.Select(t => t.ID).ToList(); var allotListId = allotList.Select(t => t.ID).ToList();
Expression<Func<ag_secondallot, bool>> exp = t => allotListId.Contains(t.AllotId.Value) && t.Department == user.Department;
if (role.Type == application.DirectorRole) // 查询当前角色下科室的绩效
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType)); UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitType);
else if (role.Type == application.NurseRole) var secondList = agsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && unitType.Contains(t.UnitType) && t.Department == userInfo.User.Department);
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString() || t.UnitType == UnitType.其他护理组.ToString());
else if (role.Type == application.SpecialRole) // 查询过往科室的绩效
exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString()); foreach (var item in userInfo.Historys)
else if (role.Type == application.OfficeRole) {
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString()); 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);
var secondList = agsecondallotRepository.GetEntities(exp); if (histroys != null && histroys.Any())
secondList.AddRange(histroys.ToArray());
}
var list = _mapper.Map<List<SecondListResponse>>(secondList); var list = _mapper.Map<List<SecondListResponse>>(secondList);
var hospital = hospitalRepository.GetEntity(t => t.ID == userhospital.HospitalID); // 二次分配只支持单医院
var hospital = userInfo.Hospitals.First();
list?.ForEach(t => list?.ForEach(t =>
{ {
var allot = allotList.FirstOrDefault(a => a.ID == t.AllotId); var allot = allotList.FirstOrDefault(a => a.ID == t.AllotId);
...@@ -169,17 +172,17 @@ public List<SecondListResponse> GetSecondList(int userId) ...@@ -169,17 +172,17 @@ public List<SecondListResponse> GetSecondList(int userId)
if (secondList != null && secondList.Any()) if (secondList != null && secondList.Any())
{ {
// 暂时在加载列表时补充信息 // 暂时在加载列表时补充信息
var worktypes = agworkloadtypeRepository.GetEntities(t => t.HospitalId == userhospital.HospitalID && t.Department == secondList.First().Department && t.UnitType == secondList.First().UnitType); var worktypes = agworkloadtypeRepository.GetEntities(t => t.HospitalId == hospital.ID && t.Department == secondList.First().Department && t.UnitType == secondList.First().UnitType);
if (worktypes != null && worktypes.Any()) if (worktypes != null && worktypes.Any())
{ {
worktypes.ForEach(t => AddWorkTypeDefaultValues(t)); worktypes.ForEach(t => AddWorkTypeDefaultValues(t));
} }
// 补充默认工作量项 // 补充默认工作量项
CheckDefaultWorkload(userhospital.HospitalID ?? 0, secondList.First().Department, secondList.First().UnitType); CheckDefaultWorkload(hospital.ID, secondList.First().Department, secondList.First().UnitType);
} }
return list; return list.OrderByDescending(w => w.Year).ThenByDescending(w => w.Month).ToList();
} }
#region 二次绩效详情 #region 二次绩效详情
...@@ -862,20 +865,11 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u ...@@ -862,20 +865,11 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
var temps = agtempRepository.GetEntities(t => t.IsEnable == 1); var temps = agtempRepository.GetEntities(t => t.IsEnable == 1);
if (temps != null && temps.Any()) if (temps != null && temps.Any())
{ {
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userCenter = userRepository.GetUser(userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
Dictionary<int, string[]> dic = new Dictionary<int, string[]>
{
{ application.DirectorRole, new[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString()} },
{ application.SpecialRole, new[]{ UnitType.特殊核算组.ToString() }},
{ application.OfficeRole, new[]{ UnitType.行政后勤.ToString() } },
};
Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == hospitalid && t.Department == department; Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == hospitalid && t.Department == department;
if (role.Type.HasValue && dic.ContainsKey(role.Type.Value))
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType)); if (userCenter?.URole != null && userCenter.URole.Type.HasValue)
exp = exp.And(t => UnitTypeUtil.Maps[userCenter.URole.Type.Value].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);
...@@ -1586,20 +1580,11 @@ public bool AuditSubmit(ag_secondallot second, int userId) ...@@ -1586,20 +1580,11 @@ public bool AuditSubmit(ag_secondallot second, int userId)
if (allot == null) if (allot == null)
throw new PerformanceException("二次绩效无效!"); throw new PerformanceException("二次绩效无效!");
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userCenter = userRepository.GetUser(userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
Dictionary<int, string[]> dic = new Dictionary<int, string[]>
{
{ application.DirectorRole, new[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString()} },
{ application.SpecialRole, new[]{ UnitType.特殊核算组.ToString() }},
{ application.OfficeRole, new[]{ UnitType.行政后勤.ToString() } },
};
Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == allot.HospitalId && t.Department == second.Department; Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == allot.HospitalId && t.Department == second.Department;
if (role.Type.HasValue && dic.ContainsKey(role.Type.Value)) if (userCenter?.URole != null && userCenter.URole.Type.HasValue)
exp = exp.And(t => dic[role.Type.Value].Contains(t.UnitType)); exp = exp.And(t => UnitTypeUtil.Maps[userCenter.URole.Type.Value].Contains(t.UnitType));
var temp = agusetempRepository.GetEntity(exp); var temp = agusetempRepository.GetEntity(exp);
if (temp == null) if (temp == null)
...@@ -2433,9 +2418,9 @@ public dynamic Print(int secondId) ...@@ -2433,9 +2418,9 @@ 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 user = userRepository.GetEntity(t => t.ID == userId); var userCenter = userRepository.GetUser(userId);
if (user == null) if (userCenter?.User == null) throw new NotImplementedException("当前用户不存在");
throw new NotImplementedException("人员ID无效");
var deptDatas = new List<DeptDataDetails>(); var deptDatas = new List<DeptDataDetails>();
var allot = perallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
...@@ -2446,19 +2431,18 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out ...@@ -2446,19 +2431,18 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out
if (!status.Contains(allot.States)) return deptDatas; if (!status.Contains(allot.States)) return deptDatas;
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
Dictionary<int, List<string>> dict = new Dictionary<int, List<string>> Dictionary<int, List<string>> dict = new Dictionary<int, List<string>>
{ {
{ application.DirectorRole, new List<string>{ AccountUnitType.科主任.ToString()} }, { (int)Role.科主任, new List<string>{ AccountUnitType.科主任.ToString()} },
{ application.NurseRole, new List<string>{ AccountUnitType.护士长.ToString() } }, { (int)Role.护士长, new List<string>{ AccountUnitType.护士长.ToString() } },
{ application.OfficeRole, new List<string> { AccountUnitType.行政中层.ToString() } }, { (int)Role.行政科室, new List<string> { AccountUnitType.行政中层.ToString() } },
{ application.SpecialRole, new List<string> { AccountUnitType.科主任.ToString() , AccountUnitType.护士长.ToString() } }, { (int)Role.特殊科室, new List<string> { AccountUnitType.科主任.ToString() , AccountUnitType.护士长.ToString() } },
}; };
if (!dict.Keys.Contains(role.Type.Value)) return new List<DeptDataDetails>(); if (!dict.Keys.Contains(userCenter?.URole.Type ?? 0)) return new List<DeptDataDetails>();
var computes = rescomputeRepository.GetEntities(t => t.AllotID == allotId && t.AccountingUnit == user.Department && dict[role.Type.Value].Contains(t.AccountType)); var computes = rescomputeRepository.GetEntities(t => t.AllotID == allotId && t.AccountingUnit == userCenter.User.Department && dict[userCenter.URole.Type.Value].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)
{ {
......
...@@ -9,6 +9,25 @@ namespace Performance.Services ...@@ -9,6 +9,25 @@ namespace Performance.Services
public class UnitTypeUtil public class UnitTypeUtil
{ {
public static string[] Office = new string[] { "行政后勤", "行政工勤" }; 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> /// <summary>
/// 是否是行政后勤/工勤 /// 是否是行政后勤/工勤
...@@ -74,5 +93,6 @@ public static string Recognition(string name, AccountUnitType defaultValue) ...@@ -74,5 +93,6 @@ public static string Recognition(string name, AccountUnitType defaultValue)
return defaultValue.ToString(); return defaultValue.ToString();
} }
} }
} }
...@@ -21,6 +21,7 @@ public class UserService : IAutoInjection ...@@ -21,6 +21,7 @@ public class UserService : IAutoInjection
private readonly IMapper _mapper; private readonly IMapper _mapper;
private PerforSmsRepository _smsRepository; private PerforSmsRepository _smsRepository;
private PerforHospitalRepository _hospitalRepository; private PerforHospitalRepository _hospitalRepository;
private readonly PerforUserhistoryRepository _userhistoryRepository;
private PerforUserhospitalRepository _userhospitalRepository; private PerforUserhospitalRepository _userhospitalRepository;
private PerforRoleRepository _roleRepository; private PerforRoleRepository _roleRepository;
private PerforUserroleRepository _userroleRepository; private PerforUserroleRepository _userroleRepository;
...@@ -39,6 +40,7 @@ public class UserService : IAutoInjection ...@@ -39,6 +40,7 @@ public class UserService : IAutoInjection
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,
...@@ -52,20 +54,21 @@ public class UserService : IAutoInjection ...@@ -52,20 +54,21 @@ public class UserService : IAutoInjection
PerforCofaccountingRepository perforCofaccountingRepository) PerforCofaccountingRepository perforCofaccountingRepository)
{ {
this.application = application.Value; this.application = application.Value;
this._userRepository = userRepository; _userRepository = userRepository;
_mapper = mapper; _mapper = mapper;
this._smsRepository = smsRepository; _smsRepository = smsRepository;
this._hospitalRepository = hospitalRepository; _hospitalRepository = hospitalRepository;
this._userhospitalRepository = userhospitalRepository; _userhistoryRepository = userhistoryRepository;
this._roleRepository = roleRepository; _userhospitalRepository = userhospitalRepository;
this._userroleRepository = userroleRepository; _roleRepository = roleRepository;
this._employeeRepository = employeeRepository; _userroleRepository = userroleRepository;
this._perforPerallotRepository = perforPerallotRepository; _employeeRepository = employeeRepository;
this._imaccountbasicRepository = imaccountbasicRepository; _perforPerallotRepository = perforPerallotRepository;
this._imspecialunitRepository = imspecialunitRepository; _imaccountbasicRepository = imaccountbasicRepository;
this._resaccountRepository = resaccountRepository; _imspecialunitRepository = imspecialunitRepository;
this._perallotRepository = perallotRepository; _resaccountRepository = resaccountRepository;
this._perdeptdicRepository = perdeptdicRepository; _perallotRepository = perallotRepository;
_perdeptdicRepository = perdeptdicRepository;
this.perforCofaccountingRepository = perforCofaccountingRepository; this.perforCofaccountingRepository = perforCofaccountingRepository;
} }
...@@ -148,34 +151,24 @@ public List<int> GetUserHospital(int userId) ...@@ -148,34 +151,24 @@ public List<int> GetUserHospital(int userId)
/// <returns></returns> /// <returns></returns>
public List<UserResponse> GetUserList(int userID, int roleType = 1) public List<UserResponse> GetUserList(int userID, int roleType = 1)
{ {
var userConter = _userRepository.GetUser(userID);
if (userConter?.User == null) throw new PerformanceException("当前用户信息无效");
if (userConter?.URole == null) throw new PerformanceException("当前用户角色无效");
var roleTypes = (roleType == (int)Role.绩效查询)
? EnumHelper.GetItems<Role>().Where(w => w.Value == (int)Role.绩效查询).Select(w => w.Value).ToArray()
: EnumHelper.GetItems<Role>().Where(w => w.Value != (int)Role.绩效查询).Select(w => w.Value).ToArray();
var users = _userRepository.GetUsersByRoleType(roleTypes);
var userRoles = _userroleRepository.GetEntities(); var userRoles = _userroleRepository.GetEntities();
var userHospitals = _userhospitalRepository.GetEntities(); var userHospitals = _userhospitalRepository.GetEntities();
var users = _userRepository.GetEntities();
var hospitals = _hospitalRepository.GetEntities(); var hospitals = _hospitalRepository.GetEntities();
var roles = _roleRepository.GetEntities(); var roles = _roleRepository.GetEntities();
var userrole = userRoles?.FirstOrDefault(t => t.UserID == userID);
if (roleType == 12)
{
var jxQuery = userRoles.Where(t => t.RoleID == roles?.FirstOrDefault(c => c.RoleName == "绩效查询")?.ID).Select(t => t.UserID);
users = users.Where(t => jxQuery.Contains(t.ID)).ToList();
}
else
{
var jxQuery = userRoles.Where(t => roles.Where(c => c.RoleName != "绩效查询").Select(c => c.ID).Contains(t.RoleID)).Select(t => t.UserID);
users = users.Where(t => jxQuery.Contains(t.ID)).ToList();
}
if (userrole == null)
throw new PerformanceException("用户未配置角色");
var role = roles?.FirstOrDefault(t => t.ID == userrole.RoleID);
if (role == null)
throw new PerformanceException("用户角色不存在");
var result = new List<UserResponse>(); var result = new List<UserResponse>();
if (role.IsViewAllUsers == 2) if (userConter?.URole.IsViewAllUsers == 2)
{ {
var userlist = users?.Where(t => t.CreateUser == userID && t.IsDelete == 1 && (t.ParentID == 0 || t.ParentID == null)); var userlist = users?.Where(t => t.CreateUser == userID && t.IsDelete == 1 && (t.ParentID == 0 || t.ParentID == null));
var sonUser = users?.Where(t => t.ParentID != 0 && t.ParentID != null); var sonUser = users?.Where(t => t.ParentID != 0 && t.ParentID != null);
...@@ -247,56 +240,56 @@ public List<UserResponse> GetUserList(int userID, int roleType = 1) ...@@ -247,56 +240,56 @@ public List<UserResponse> GetUserList(int userID, int roleType = 1)
return result; return result;
} }
/// <summary> ///// <summary>
/// 删除 ///// 删除
/// </summary> ///// </summary>
/// <param name="iD"></param> ///// <param name="iD"></param>
/// <returns></returns> ///// <returns></returns>
public ApiResponse Delete(int iD) //public ApiResponse Delete(int iD)
{ //{
var user = _userRepository.GetEntity(t => t.ID == iD && t.IsDelete == 1); // var user = _userRepository.GetEntity(t => t.ID == iD && t.IsDelete == 1);
if (null == user) // if (null == user)
throw new PerformanceException($"用户不存在 UserId:{iD}"); // throw new PerformanceException($"用户不存在 UserId:{iD}");
user.IsDelete = 2; // user.IsDelete = 2;
var result = _userRepository.Remove(user); // var result = _userRepository.Remove(user);
return result ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.Fail); // return result ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.Fail);
} //}
/// <summary>
/// 新增用户
/// </summary>
/// <param name="request"></param>
public UserResponse Insert(UserRequest request, int userid)
{
if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1))
throw new PerformanceException("登录名重复");
//if (null != _userRepository.GetEntity(t => t.Mobile == request.Mobile && t.IsDelete == 1))
// throw new PerformanceException("手机号重复");
//if (request.Role == 3 && string.IsNullOrEmpty(request.Department))
// throw new PerformanceException("请选择科室");
if (request.HosIDArray.Length > 1)
throw new PerformanceException("二次绩效管理员只支持单家医院");
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
if (roleArray.Contains(request.Role) && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
var user = _mapper.Map<sys_user>(request);
user.CreateDate = DateTime.Now;
user.CreateUser = userid;
user.States = (int)States.Enabled;
user.Department = request.Department;
user.IsDelete = 1;
if (!_userRepository.Add(user))
throw new PerformanceException("保存失败");
//添加用户角色关联关系
_userroleRepository.Add(new sys_user_role { UserID = user.ID, RoleID = request.Role });
//添加用户医院
SetHospital(user.ID, request.HosIDArray);
return _mapper.Map<UserResponse>(user); ///// <summary>
} ///// 新增用户
///// </summary>
///// <param name="request"></param>
//public UserResponse Insert(UserRequest request, int userid)
//{
// if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1))
// throw new PerformanceException("登录名重复");
// //if (null != _userRepository.GetEntity(t => t.Mobile == request.Mobile && t.IsDelete == 1))
// // throw new PerformanceException("手机号重复");
// //if (request.Role == 3 && string.IsNullOrEmpty(request.Department))
// // throw new PerformanceException("请选择科室");
// if (request.HosIDArray.Length > 1)
// throw new PerformanceException("二次绩效管理员只支持单家医院");
// int[] roleArray = new int[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
// if (roleArray.Contains(request.Role) && string.IsNullOrEmpty(request.Department))
// throw new PerformanceException("二次绩效管理员科室不能为空");
// var user = _mapper.Map<sys_user>(request);
// user.CreateDate = DateTime.Now;
// user.CreateUser = userid;
// user.States = (int)States.Enabled;
// user.Department = request.Department;
// user.IsDelete = 1;
// if (!_userRepository.Add(user))
// throw new PerformanceException("保存失败");
// //添加用户角色关联关系
// _userroleRepository.Add(new sys_user_role { UserID = user.ID, RoleID = request.Role });
// //添加用户医院
// SetHospital(user.ID, request.HosIDArray);
// return _mapper.Map<UserResponse>(user);
//}
/// <summary> /// <summary>
/// 设置用户医院 /// 设置用户医院
...@@ -330,53 +323,59 @@ public bool SetHospital(int userId, int[] hosIDArray) ...@@ -330,53 +323,59 @@ public bool SetHospital(int userId, int[] hosIDArray)
return rmResult && addResult; return rmResult && addResult;
} }
/// <summary> ///// <summary>
/// 修改用户 ///// 修改用户
/// </summary> ///// </summary>
/// <param name="request"></param> ///// <param name="request"></param>
/// <returns></returns> ///// <returns></returns>
public UserResponse Update(UserRequest request, bool isAgainAdmin) //public UserResponse Update(UserRequest request, bool isAgainAdmin)
{ //{
var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1); // var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1);
if (null == user) // if (null == user)
throw new PerformanceException($"用户不存在 UserId:{request.ID}"); // throw new PerformanceException($"用户不存在 UserId:{request.ID}");
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) // if (null != vlist && vlist.Count() > 0)
throw new PerformanceException("登录名重复"); // throw new PerformanceException("登录名重复");
//vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Mobile == request.Mobile && t.IsDelete == 1); // var userRole = _userroleRepository.GetEntity(t => t.UserID == request.ID);
//if (null != vlist && vlist.Count() > 0)
// throw new PerformanceException("手机号重复");
if (isAgainAdmin && string.IsNullOrEmpty(request.Department)) // //vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Mobile == request.Mobile && t.IsDelete == 1);
throw new PerformanceException("二次绩效管理员科室不能为空"); // //if (null != vlist && vlist.Count() > 0)
// // throw new PerformanceException("手机号重复");
if (isAgainAdmin && request.HosIDArray.Length > 1) // if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员只支持单家医院"); // throw new PerformanceException("二次绩效管理员科室不能为空");
user.Login = request.Login; // if (isAgainAdmin && request.HosIDArray.Length > 1)
user.Mobile = request.Mobile; // throw new PerformanceException("二次绩效管理员只支持单家医院");
user.RealName = request.RealName;
user.Mail = request.Mail;
user.States = request.States;
user.Password = string.IsNullOrEmpty(request.Password) ? user.Password : request.Password;
user.Department = request.Department;
if (!_userRepository.Update(user))
throw new PerformanceException("保存失败");
//删除用户角色关联关系 // SaveHistoryDepartment(user.ID, newRoleId: request.Role, newDepartment: request.Department);
var userRole = _userroleRepository.GetEntity(t => t.UserID == request.ID);
if (null != userRole) // user.Login = request.Login;
_userroleRepository.Remove(userRole); // user.Mobile = request.Mobile;
//添加用户角色关联关系 // user.RealName = request.RealName;
_userroleRepository.Add(new sys_user_role { UserID = request.ID, RoleID = request.Role }); // user.Mail = request.Mail;
//添加用户医院 // user.States = request.States;
SetHospital(user.ID, request.HosIDArray); // user.Password = string.IsNullOrEmpty(request.Password) ? user.Password : request.Password;
// user.Department = request.Department;
// if (!_userRepository.Update(user))
// throw new PerformanceException("保存失败");
// //删除用户角色关联关系
// if (null != userRole)
// _userroleRepository.Remove(userRole);
// //添加用户角色关联关系
// _userroleRepository.Add(new sys_user_role { UserID = request.ID, RoleID = request.Role });
// //添加用户医院
// SetHospital(user.ID, request.HosIDArray);
// return _mapper.Map<UserResponse>(user);
//}
return _mapper.Map<UserResponse>(user);
}
/// <summary> /// <summary>
/// 修改个人信息 /// 修改个人信息
...@@ -584,7 +583,7 @@ public UserResponse InsertUser(UserRequest request, int userid) ...@@ -584,7 +583,7 @@ public UserResponse InsertUser(UserRequest request, int userid)
if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1)) if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1))
throw new PerformanceException("登录名重复"); throw new PerformanceException("登录名重复");
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole }; int[] roleArray = UnitTypeUtil.Maps.Keys.ToArray();
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("二次绩效管理员科室不能为空");
...@@ -625,27 +624,37 @@ public UserResponse InsertUser(UserRequest request, int userid) ...@@ -625,27 +624,37 @@ public UserResponse InsertUser(UserRequest request, int userid)
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin) public UserResponse UpdateUser(UserRequest request, int userId)
{ {
var roleIds = request.RoleArr != null && request.RoleArr.Length > 0 ? request.RoleArr.Distinct().ToArray() : new int[0];
if (roleIds.Length == 0)
throw new PerformanceException("请选择用户角色");
var isAgainAdmin = request.RoleArr.Any(w => UnitTypeUtil.Maps.ContainsKey(w));
if (isAgainAdmin && string.IsNullOrEmpty(request?.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1); var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1);
if (null == user)
throw new PerformanceException($"用户不存在 UserId:{request.ID}"); if (null == user) throw new PerformanceException($"当前用户不存在");
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) if (null != vlist && vlist.Count() > 0) throw new PerformanceException("登录名重复");
throw new PerformanceException("登录名重复");
if (isAgainAdmin && string.IsNullOrEmpty(request.Department)) // 只有单角色账号并且是二次分配的科室 才会记录历史科室
throw new PerformanceException("二次绩效管理员科室不能为空"); if (roleIds.Length == 1 && UnitTypeUtil.Maps.ContainsKey(roleIds[0]))
{
_userRepository.SaveHistoryDepartment(user.ID, request.RoleArr[0], request.Department);
}
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
user.Login = request.Login; user.Login = request.Login;
user.Mobile = request.Mobile; user.Mobile = request.Mobile;
user.RealName = request.RealName; user.RealName = request.RealName;
user.Mail = request.Mail; user.Mail = request.Mail;
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 = roleArray.Contains(request.RoleArr[0]) ? request.Department : ""; user.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]) ? request.Department : "";
if (!_userRepository.Update(user)) if (!_userRepository.Update(user))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
...@@ -653,6 +662,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin) ...@@ -653,6 +662,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
var userRole = _userroleRepository.GetEntity(t => t.UserID == user.ID); var userRole = _userroleRepository.GetEntity(t => t.UserID == user.ID);
if (null != userRole) if (null != userRole)
_userroleRepository.Remove(userRole); _userroleRepository.Remove(userRole);
//添加用户角色关联关系 //添加用户角色关联关系
_userroleRepository.Add(new sys_user_role { UserID = user.ID, RoleID = request.RoleArr[0] }); _userroleRepository.Add(new sys_user_role { UserID = user.ID, RoleID = request.RoleArr[0] });
//添加用户医院 //添加用户医院
...@@ -687,7 +697,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin) ...@@ -687,7 +697,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
diffUser.Mail = request.Mail; diffUser.Mail = request.Mail;
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 = roleArray.Contains(request.RoleArr[i]) ? request.Department : ""; diffUser.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[i]) ? request.Department : "";
if (!_userRepository.Add(diffUser)) if (!_userRepository.Add(diffUser))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
//添加子用户角色关联关系 //添加子用户角色关联关系
...@@ -723,24 +733,24 @@ public ApiResponse DeleteUser(int iD) ...@@ -723,24 +733,24 @@ public ApiResponse DeleteUser(int iD)
#endregion #endregion
public HandsonTable GetUserHandsFlat() public HandsonTableBase GetUserHandsFlat()
{ {
var result = new HandsonTable((int)SheetType.Unidentifiable, Users.Select(t => t.Value).ToArray(), Users.Select(t => new collect_permission HandsonTableBase table = new HandsonTableBase()
{ {
HeadName = t.Value, Columns = Users.Select(t => new HandsonColumn(t.Value)).ToList(),
Visible = 1 ColHeaders = Users.Select(t => t.Value).ToList(),
}).ToList()); };
if (result.Columns != null && result.Columns.Any()) if (table.Columns != null && table.Columns.Any())
{ {
foreach (var column in result.Columns) foreach (var column in table.Columns)
{ {
if (column.Data == "角色") if (Users.Any(w => w.Key == nameof(sys_role.RoleName)) && Users.First(w => w.Key == nameof(sys_role.RoleName)).Value == column.Data)
{ {
column.Type = "autocomplete"; column.Type = "autocomplete";
column.Source = _roleRepository.GetEntities().Select(t => t.RoleName).ToArray(); column.Source = _roleRepository.GetEntities().Select(t => t.RoleName).ToArray();
column.Strict = true; column.Strict = true;
} }
else if (column.Data == "分配医院") if (Users.Any(w => w.Key == nameof(sys_hospital.HosName)) && Users.First(w => w.Key == nameof(sys_hospital.HosName)).Value == column.Data)
{ {
column.Type = "autocomplete"; column.Type = "autocomplete";
column.Source = _hospitalRepository.GetEntities().Select(t => t.HosName).ToArray(); column.Source = _hospitalRepository.GetEntities().Select(t => t.HosName).ToArray();
...@@ -748,7 +758,7 @@ public HandsonTable GetUserHandsFlat() ...@@ -748,7 +758,7 @@ public HandsonTable GetUserHandsFlat()
} }
} }
} }
return result; return table;
} }
/// <summary> /// <summary>
...@@ -756,7 +766,7 @@ public HandsonTable GetUserHandsFlat() ...@@ -756,7 +766,7 @@ public HandsonTable GetUserHandsFlat()
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
public string SaveUserHandsFlat(UserCollectData request) public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ {
try try
{ {
...@@ -769,35 +779,81 @@ public string SaveUserHandsFlat(UserCollectData request) ...@@ -769,35 +779,81 @@ public string SaveUserHandsFlat(UserCollectData request)
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>();
List<sys_user_hospital> userHoss = new List<sys_user_hospital>(); List<sys_user_hospital> userHoss = new List<sys_user_hospital>();
var roleArr = new[] { "护士长", "科主任", "特殊科室", "行政科室" }; var roleArr = new string[] { Role.护士长.ToString(), Role.科主任.ToString(), Role.特殊科室.ToString(), Role.行政科室.ToString() };
var allDataList = dicData.Select(item => JsonHelper.Deserialize<UserHandsResponse>(JsonHelper.Serialize(item))).ToList();
var allDataList = dicData.Select(item => JsonHelper.Deserialize<UserHandsResponse>(JsonHelper.Serialize(item))); List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
var names = allDataList?.Select(w => w?.HosName).Distinct(); for (int i = 0; i < allDataList.Count(); i++)
{
// 姓名、登录名、角色、分配医院
if (string.IsNullOrEmpty(allDataList[i].Login?.Trim())
|| string.IsNullOrEmpty(allDataList[i].RealName?.Trim())
|| string.IsNullOrEmpty(allDataList[i].RoleName?.Trim())
|| string.IsNullOrEmpty(allDataList[i].HosName?.Trim())
|| string.IsNullOrEmpty(allDataList[i].Department?.Trim()))
{
Dictionary<string, List<string>> res = new Dictionary<string, List<string>>(); error.Add(new Dictionary<string, string>
foreach (var item in names)
{ {
if (string.IsNullOrEmpty(item)) return "必填项为空"; { "行号", $"第{i+1}行" },
var HospitalId = hospitals.FirstOrDefault(w => w.HosName == item)?.ID; { "姓名", allDataList[i].Login ?? "" },
{ "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department.ToString() ?? "" },
{ "错误原因", "“关键信息缺失”请补全或删除" },
});
}
if (HospitalId == null) return "未找到分配医院"; else if (!hospitals.Any(w => w.HosName == (allDataList[i].HosName?.Trim())))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "姓名", allDataList[i].Login ?? "" },
{ "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department.ToString() ?? "" },
{ "错误原因", "“分配医院”错误,请修改或删除" },
});
}
else if (roleArr.Contains(allDataList[i].RoleName?.Trim()) && !accounts.Any(w => w.AccountingUnit == allDataList[i].Department?.Trim()))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "姓名", allDataList[i].Login ?? "" },
{ "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department ?? "" },
{ "错误原因", "“核算单元”错误,请修改或删除" },
});
}
var allot = _perallotRepository.GetEntities(t => t.HospitalId == HospitalId); else if (getUsers.Any(c => c.Login == allDataList[i].Login?.Trim()))
var accountingUnits = accounts?.Join(allot, t => t.AllotId, w => w.ID, (t, w) => t.AccountingUnit).Distinct().ToList(); {
res.Add(item, accountingUnits); 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)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
foreach (var data in allDataList) foreach (var data in allDataList)
{ {
if (string.IsNullOrEmpty(data.Login) || string.IsNullOrEmpty(data.RealName)
|| string.IsNullOrEmpty(data.RoleName) || string.IsNullOrEmpty(data.HosName))
return "必填项为空";
if (roleArr.Contains(data.RoleName) && res != null && res[data.HosName] != null && !res[data.HosName].Any(t => t == data.Department))
return "核算单元填写错误";
if (users.Any(c => c.Login == data?.Login) && !string.IsNullOrEmpty(data.Login) if (users.Any(c => c.Login == data?.Login)) continue;
|| getUsers.Any(c => c.Login == data?.Login)) continue;
var user = new sys_user var user = new sys_user
{ {
...@@ -836,7 +892,7 @@ public string SaveUserHandsFlat(UserCollectData request) ...@@ -836,7 +892,7 @@ public string SaveUserHandsFlat(UserCollectData request)
}); });
_userhospitalRepository.AddRange(hosJoin.ToArray()); _userhospitalRepository.AddRange(hosJoin.ToArray());
return ""; return new ApiResponse(ResponseType.OK, "保存成功");
} }
catch (Exception) catch (Exception)
{ {
......
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