Commit f13e0af9 by ruyun.zhang@suvalue.com

Merge branch 'feature/核算单元变更' into develop

parents 8e140206 1afa062c
......@@ -122,7 +122,7 @@ public ApiResponse SelfInfo()
user.Role = _roleService.GetUserRole(user.UserID);
user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
int[] roleArray = UnitTypeUtil.Maps.Keys.ToArray();
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
return new ApiResponse(ResponseType.OK, user);
}
......@@ -149,56 +149,56 @@ public ApiResponse<UserResponse> UpdateSelf([CustomizeValidator(RuleSet = "Self"
[HttpPost]
public ApiResponse<List<UserResponse>> List([FromBody] UserRequest request)
{
var userList = _userService.GetUserList(_claim.GetUserId(),request.Role);
var userList = _userService.GetUserList(_claim.GetUserId(), request.Role);
return new ApiResponse<List<UserResponse>>(ResponseType.OK, "ok", userList);
}
/// <summary>
/// 新增用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("insert")]
[HttpPost]
public ApiResponse<UserResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody] UserRequest request)
{
var userId = _claim.GetUserId();
var user = _userService.Insert(request, userId);
user.Role = request.Role;
return new ApiResponse<UserResponse>(ResponseType.OK, user);
}
/// <summary>
/// 新增用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("delete")]
[HttpPost]
public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody] UserRequest request)
{
return _userService.Delete(request.ID);
}
/// <summary>
/// 删除用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("update")]
[HttpPost]
public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody] UserRequest request)
{
var userId = _claim.GetUserId();
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUserRole(userId);
var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false;
var user = _userService.Update(request, isAgainAdmin);
user.Role = request.Role;
return new ApiResponse<UserResponse>(ResponseType.OK, user);
}
///// <summary>
///// 新增用户
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("insert")]
//[HttpPost]
//public ApiResponse<UserResponse> Insert([CustomizeValidator(RuleSet = "Insert"), FromBody] UserRequest request)
//{
// var userId = _claim.GetUserId();
// var user = _userService.Insert(request, userId);
// user.Role = request.Role;
// return new ApiResponse<UserResponse>(ResponseType.OK, user);
//}
///// <summary>
///// 新增用户
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("delete")]
//[HttpPost]
//public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody] UserRequest request)
//{
// return _userService.Delete(request.ID);
//}
///// <summary>
///// 删除用户
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//[Route("update")]
//[HttpPost]
//public ApiResponse<UserResponse> Update([CustomizeValidator(RuleSet = "Update"), FromBody] UserRequest request)
//{
// var userId = _claim.GetUserId();
// int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
// var roles = _roleService.GetUserRole(userId);
// var isAgainAdmin = roles != null ? roleArray.Contains(roles.First().Type ?? 0) : false;
// var user = _userService.Update(request, isAgainAdmin);
// user.Role = request.Role;
// return new ApiResponse<UserResponse>(ResponseType.OK, user);
//}
/// <summary>
/// 修改用户密码
......@@ -230,13 +230,13 @@ public ApiResponse<List<sys_role>> RoleList()
/// <summary>
/// 科室列表
/// </summary>
/// <param name="request"></param>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("department")]
[Route("department/{allotId}")]
[HttpPost]
public ApiResponse<List<TitleValue>> Department([FromBody] SetDepartmentRequest request)
public ApiResponse<List<TitleValue>> Department(int allotId)
{
var department = _userService.Department(request.HospitalID);
var department = _userService.Department(allotId);
return new ApiResponse<List<TitleValue>>(ResponseType.OK, "ok", department);
}
......@@ -311,7 +311,7 @@ public ApiResponse SelfInfos([FromBody] UserRequest request)
user.Role = _roleService.GetUsersRole(user.UserID);
user.Hospital = _hospitalService.GetUserHopital(user.UserID);
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
int[] roleArray = UnitTypeUtil.Maps.Keys.ToArray();
if (request.Role <= 0)
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
else
......@@ -345,13 +345,7 @@ public ApiResponse<UserResponse> UpdateUser([CustomizeValidator(RuleSet = "Updat
{
var userId = _claim.GetUserId();
int[] roleArray = new int[] { _options.NurseRole, _options.DirectorRole, _options.SpecialRole, _options.OfficeRole };
var roles = _roleService.GetUsersRole(userId);
//var roleType = roles.Select(c => c.Type).ToArray();
var intersect = roleArray.Intersect(roles.Select(c => (int)c.Type).ToArray());
var isAgainAdmin = roles != null ? intersect.Any() : false;
var user = _userService.UpdateUser(request, isAgainAdmin);
var user = _userService.UpdateUser(request, userId);
user.RoleArr = request.RoleArr;
return new ApiResponse<UserResponse>(ResponseType.OK, user);
}
......@@ -391,12 +385,7 @@ public ApiResponse GetBatchUserStructrue()
[HttpPost]
public ApiResponse BatchSaveUser([CustomizeValidator(RuleSet = "Insert"), FromBody] UserCollectData data)
{
var result = _userService.SaveUserHandsFlat(data);
if (result == "")
return new ApiResponse(ResponseType.OK);
else
return new ApiResponse(ResponseType.Error, result);
return _userService.SaveUserHandsFlat(data);
}
}
}
\ No newline at end of file
......@@ -103,7 +103,7 @@
// if (!FileHelper.CreateFile(path, bytes))
// return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
// allot.Path = path;
// allot.Remark = EnumHelper.GetDescription(AllotStates.FileUploaded);
// allot.Remark = EnumHelper.GetDescription(AllotStates.数据已上传);
// if (!againAllotService.Update(allot, againid))
// return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
......
......@@ -194,7 +194,7 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request)
{
second = _computeService.GetSecondByAccountId(request.AccountID);
}
else if (request.AccountID != 0 && request.UnitType == (int)UnitType.行政)
else if (request.AccountID != 0 && request.UnitType == (int)UnitType.行政)
{
var response = _computeService.DeptOfficeDetail(request.AccountID);
return new ApiResponse(ResponseType.OK, response);
......@@ -205,7 +205,7 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request)
var response = _computeService.SpecialDeptDetail(second);
return new ApiResponse(ResponseType.OK, response);
}
else if (second != null && second.UnitType == UnitType.行政后勤.ToString())
else if (second != null && UnitTypeUtil.IsOffice(second.UnitType))
{
var response = _computeService.DeptOfficeDetail(request.AccountID);
return new ApiResponse(ResponseType.OK, response);
......
......@@ -626,8 +626,14 @@ public ApiResponse GetAccountingList([FromBody] AccoungingRequest request)
[HttpPost]
public ApiResponse AccountingInsert([FromBody] cof_accounting request)
{
if (request.AllotId == 0 || string.IsNullOrEmpty(request.Code) || string.IsNullOrEmpty(request.UnitType) || string.IsNullOrEmpty(request.AccountingUnit))
return new ApiResponse(ResponseType.ParameterError, "参数不允许为空");
if (request.AllotId == 0)
return new ApiResponse(ResponseType.ParameterError);
if (string.IsNullOrEmpty(request.UnitType) || string.IsNullOrEmpty(request.AccountingUnit))
return new ApiResponse(ResponseType.Fail, "核算单元或组别必须填写");
if (string.IsNullOrEmpty(request.Code))
return new ApiResponse(ResponseType.Fail, "核算单元编码必须填写");
var drugprop = _configService.AccountingInsert(request);
return new ApiResponse(ResponseType.OK, drugprop);
......@@ -642,9 +648,16 @@ public ApiResponse AccountingInsert([FromBody] cof_accounting request)
[HttpPost]
public ApiResponse AccountingUpdate([FromBody] cof_accounting request)
{
if (request.AllotId == 0 || string.IsNullOrEmpty(request.UnitType) || string.IsNullOrEmpty(request.AccountingUnit))
if (request.AllotId == 0)
return new ApiResponse(ResponseType.ParameterError);
if (string.IsNullOrEmpty(request.UnitType) || string.IsNullOrEmpty(request.AccountingUnit))
return new ApiResponse(ResponseType.Fail, "核算单元或组别必须填写");
if (string.IsNullOrEmpty(request.Code))
return new ApiResponse(ResponseType.Fail, "核算单元编码必须填写");
var drugprop = _configService.AccountingUpdate(request);
return new ApiResponse(ResponseType.OK, drugprop);
}
......@@ -686,8 +699,8 @@ public ApiResponse BatchAccountingStructrue([FromRoute] int allotId)
[HttpPost]
public ApiResponse BatchCheckAccounting(int allotId)
{
_configService.BatchCheckAccounting(allotId);
return new ApiResponse(ResponseType.OK, "校验通过");
_allotService.AccoungtingVerify(allotId);
return new ApiResponse(ResponseType.OK, "校验完成");
}
/// <summary>
......@@ -700,11 +713,7 @@ public ApiResponse BatchCheckAccounting(int allotId)
[HttpPost]
public ApiResponse BatchSaveAccounting(int allotId, [FromBody] SaveCollectData request)
{
var result = _configService.BatchSaveAccounting(allotId, request);
if (result)
return new ApiResponse(ResponseType.OK);
else
return new ApiResponse(ResponseType.Error, "请选择正确的核算组别");
return _configService.BatchSaveAccounting(allotId, request);
}
......@@ -859,14 +868,15 @@ public ApiResponse CopyDropDown()
{
var result = new List<CopyDrop>
{
new CopyDrop{Label="核算单元及组别",Value="accountings"},
new CopyDrop{Label="科室字典",Value="department"},
new CopyDrop{Label="人员字典",Value="personnels"},
new CopyDrop{Label="工作量配置",Value="workItems"},
new CopyDrop{Label="收入费用类别",Value="drugTypes"},
//new CopyDrop{Label="收入费用类别",Value="drugTypes"},
new CopyDrop{Label="支出费用类别",Value="drugTypeDisburses"},
new CopyDrop{Label="费用类别系数",Value="drugTypeFactors"},
/* new CopyDrop{Label="科室类型",Value="deptTypes"},*/
//new CopyDrop{Label="科室类型",Value="deptTypes"},
new CopyDrop{Label="二次绩效配置",Value="agains"},
new CopyDrop{Label="核算单元及组别",Value="accountings"},
}; ;
return new ApiResponse(ResponseType.OK, result);
}
......
......@@ -129,13 +129,13 @@ public IActionResult DownloadCurrentCalculationTable([FromRoute] int allotId)
/// <summary>
/// 获取所有科室记录
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("deptdic/list/{hospitalId}")]
[Route("deptdic/list/{allotId}")]
[HttpPost]
public ApiResponse GetDepartments(int hospitalId)
public ApiResponse GetDepartments(int allotId)
{
var list = personService.GetDepartments(hospitalId);
var list = personService.GetDepartments(allotId);
return new ApiResponse(ResponseType.OK, list);
}
......@@ -191,17 +191,17 @@ public ApiResponse DeleteDeptDic([FromBody] DeptdicResponse request)
/// <summary>
/// 系统/标准科室字典
/// </summary>
/// <param name="hospitalId">医院Id</param>
/// <param name="allotId">allotId</param>
/// <param name="type">1系统科室 2标准科室 3核算单元 4行政后勤 5特殊核算组</param>
/// <returns></returns>
[Route("deptdic/{hospitalId}/dict/{type}")]
[Route("deptdic/{allotId}/dict/{type}")]
[HttpPost]
public ApiResponse DeptDics(int hospitalId, int type)
public ApiResponse DeptDics(int allotId, int type)
{
if (!new int[] { 1, 2, 3, 4, 5 }.Contains(type))
return new ApiResponse(ResponseType.ParameterError, "参数错误!");
var result = personService.DeptDics(hospitalId, type);
var result = personService.DeptDics(allotId, type);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -234,10 +234,10 @@ public ApiResponse DeptIncomeDetail([CustomizeValidator(RuleSet = "Select"), Fro
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("person/GetBatchPersonStructrue/{hospitalId}")]
public ApiResponse GetBatchPersonStructrue(int hospitalId)
[Route("person/GetBatchPersonStructrue/{allotId}")]
public ApiResponse GetBatchPersonStructrue(int allotId)
{
var result = personService.GetBatchPersonStructrue(hospitalId);
var result = personService.GetBatchPersonStructrue(allotId);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -257,10 +257,10 @@ public ApiResponse BathSavePerson(int allotId, int hospitalId, SaveCollectData r
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("dept/GetDeptStructrue/{hospitalId}")]
public ApiResponse GetDeptStructrue(int hospitalId)
[Route("dept/GetDeptStructrue/{allotId}")]
public ApiResponse GetDeptStructrue(int allotId)
{
var result = personService.GetDepartmentHands(hospitalId);
var result = personService.GetDepartmentHands(allotId);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -269,10 +269,10 @@ public ApiResponse GetDeptStructrue(int hospitalId)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("dept/SaveDeptHands/{hospitalId}")]
public ApiResponse SaveDeptHands(int hospitalId, SaveCollectData request)
[Route("dept/SaveDeptHands/{allotId}")]
public ApiResponse SaveDeptHands(int allotId, SaveCollectData request)
{
personService.SaveDeptDicHands(hospitalId, request);
personService.SaveDeptDicHands(allotId, request);
return new ApiResponse(ResponseType.OK);
}
......
......@@ -14,14 +14,14 @@
"ExpirationMinutes": "1200",
//验证码过期
"SmsCodeMinutes": "5",
//护士长二次绩效管理员
"NurseRole": "3",
//科主任二次绩效管理员
"DirectorRole": "4",
//特殊科室二次绩效管理员
"SpecialRole": "9",
//数据收集角色(可查看所有)
"CollectRoles": [ 1, 2, 5, 6, 7, 8 ],
////护士长二次绩效管理员
//"NurseRole": "3",
////科主任二次绩效管理员
//"DirectorRole": "4",
////特殊科室二次绩效管理员
//"SpecialRole": "9",
////数据收集角色(可查看所有)
//"CollectRoles": [ 1, 2, 5, 6, 7, 8 ],
// 抽取结果Excel文件保存地址
"AbsolutePath": "E:\\wwwroot\\testjx.suvalue.com",
// 抽取结果Excel文件保存地址 更替的 网络地址
......
......@@ -49,27 +49,6 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Insert(Performance.DtoModels.UserRequest)">
<summary>
新增用户
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Delete(Performance.DtoModels.UserRequest)">
<summary>
新增用户
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Update(Performance.DtoModels.UserRequest)">
<summary>
删除用户
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Password(Performance.DtoModels.PasswordRequest)">
<summary>
修改用户密码
......@@ -83,11 +62,11 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Department(Performance.DtoModels.SetDepartmentRequest)">
<member name="M:Performance.Api.Controllers.AccountController.Department(System.Int32)">
<summary>
科室列表
</summary>
<param name="request"></param>
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.DemoUsers">
......@@ -1730,7 +1709,7 @@
<summary>
获取所有科室记录
</summary>
<param name="hospitalId"></param>
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.PersonController.CreateDeptDic(Performance.EntityModels.per_dept_dic)">
......@@ -1758,7 +1737,7 @@
<summary>
系统/标准科室字典
</summary>
<param name="hospitalId">医院Id</param>
<param name="allotId">allotId</param>
<param name="type">1系统科室 2标准科室 3核算单元 4行政后勤 5特殊核算组</param>
<returns></returns>
</member>
......
......@@ -34,31 +34,6 @@
短信模板
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.NurseRole">
<summary>
护士长二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.DirectorRole">
<summary>
科主任二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.SpecialRole">
<summary>
特殊科室二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.CollectRoles">
<summary>
数据收集角色(可查看所有)
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.OfficeRole">
<summary>
行政科室二次绩效管理员
</summary>
</member>
<member name="P:Performance.DtoModels.AppSettings.Application.Receiver">
<summary>
邮件指定接收人
......@@ -130,39 +105,6 @@
<member name="F:Performance.DtoModels.DbSrouceType.Performance">
<summary> 绩效库 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.数据未上传">
<summary> 数据未上传 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.数据已上传">
<summary> 数据已上传 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.正在校验数据">
<summary> 正在校验数据 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.数据验证通过">
<summary> 数据验证通过 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.数据错误">
<summary> 数据错误 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.正在生成绩效">
<summary> 正在生成绩效 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.绩效下发">
<summary> 绩效下发 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.绩效解析失败">
<summary> 绩效解析失败 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.归档">
<summary> 归档 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.等待">
<summary> 等待 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.绩效结果解析成功">
<summary> 绩效结果解析成功 </summary>
</member>
<member name="F:Performance.DtoModels.AgWorkloadType.PreAccountingReward">
<summary>
核算前奖励
......@@ -735,9 +677,6 @@
是否需要二次分配
</summary>
</member>
<member name="T:Performance.DtoModels.UnitType">
<summary> 核算单元类型 </summary>
</member>
<member name="F:Performance.DtoModels.SheetType.Unidentifiable">
<summary> 无法识别 </summary>
</member>
......@@ -3414,6 +3353,16 @@
核算单元
</summary>
</member>
<member name="P:Performance.DtoModels.EmployeeReservedDto.NewUnitType">
<summary>
</summary>
</member>
<member name="P:Performance.DtoModels.EmployeeReservedDto.NewAccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="P:Performance.DtoModels.EmployeeReservedDto.EmployeeName">
<summary>
人员姓名
......
......@@ -1085,6 +1085,21 @@
科室类型
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NewUnitType">
<summary>
变更核算组别
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NewAccountingUnit">
<summary>
变更核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.Year">
<summary>
......@@ -1095,11 +1110,6 @@
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.RealGiveFee">
<summary>
科室实发金额
......@@ -6620,6 +6630,11 @@
医院Id
</summary>
</member>
<member name="P:Performance.EntityModels.per_dept_dic.AllotId">
<summary>
AllotId
</summary>
</member>
<member name="P:Performance.EntityModels.per_dept_dic.IsVerify">
<summary>
0 未通过验证 1 通过验证
......@@ -8650,6 +8665,16 @@
父级ID
</summary>
</member>
<member name="P:Performance.EntityModels.sys_user.UnitType">
<summary>
核算组别
</summary>
</member>
<member name="P:Performance.EntityModels.sys_user.UnitCode">
<summary>
核算序号
</summary>
</member>
<member name="T:Performance.EntityModels.sys_user_hospital">
<summary>
......@@ -8845,6 +8870,21 @@
</summary>
</member>
<member name="P:Performance.EntityModels.CofAccountingEntity.UnitType">
<summary>
核算单元类型
</summary>
</member>
<member name="P:Performance.EntityModels.CofAccountingEntity.AccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.CofAccountingEntity.Code">
<summary>
核算单元编码
</summary>
</member>
<member name="P:Performance.EntityModels.Other.view_attendance.UnitType">
<summary>
人员类别
......@@ -9045,5 +9085,41 @@
预留金额
</summary>
</member>
<member name="F:AllotStates.数据未上传">
<summary> 数据未上传 </summary>
</member>
<member name="F:AllotStates.数据已上传">
<summary> 数据已上传 </summary>
</member>
<member name="F:AllotStates.正在校验数据">
<summary> 正在校验数据 </summary>
</member>
<member name="F:AllotStates.数据验证通过">
<summary> 数据验证通过 </summary>
</member>
<member name="F:AllotStates.数据错误">
<summary> 数据错误 </summary>
</member>
<member name="F:AllotStates.正在生成绩效">
<summary> 正在生成绩效 </summary>
</member>
<member name="F:AllotStates.绩效下发">
<summary> 绩效下发 </summary>
</member>
<member name="F:AllotStates.绩效解析失败">
<summary> 绩效解析失败 </summary>
</member>
<member name="F:AllotStates.归档">
<summary> 归档 </summary>
</member>
<member name="F:AllotStates.等待">
<summary> 等待 </summary>
</member>
<member name="F:AllotStates.绩效结果解析成功">
<summary> 绩效结果解析成功 </summary>
</member>
<member name="T:UnitType">
<summary> 核算单元类型 </summary>
</member>
</members>
</doc>
......@@ -18,26 +18,26 @@ public class Application
/// 短信模板
/// </summary>
public string SmsTemplate { get; set; }
/// <summary>
/// 护士长二次绩效管理员
/// </summary>
public int NurseRole { get; set; }
/// <summary>
/// 科主任二次绩效管理员
/// </summary>
public int DirectorRole { get; set; }
/// <summary>
/// 特殊科室二次绩效管理员
/// </summary>
public int SpecialRole { get; set; }
/// <summary>
/// 数据收集角色(可查看所有)
/// </summary>
public int[] CollectRoles { get; set; }
/// <summary>
/// 行政科室二次绩效管理员
/// </summary>
public int OfficeRole { get; set; }
///// <summary>
///// 护士长二次绩效管理员
///// </summary>
//public int NurseRole { get; set; }
///// <summary>
///// 科主任二次绩效管理员
///// </summary>
//public int DirectorRole { get; set; }
///// <summary>
///// 特殊科室二次绩效管理员
///// </summary>
//public int SpecialRole { get; set; }
///// <summary>
///// 数据收集角色(可查看所有)
///// </summary>
//public int[] CollectRoles { get; set; }
///// <summary>
///// 行政科室二次绩效管理员
///// </summary>
//public int OfficeRole { get; set; }
/// <summary>
/// 邮件指定接收人
/// </summary>
......
......@@ -45,42 +45,6 @@ public enum DbSrouceType
Performance = 2,
}
public enum AllotStates
{
/// <summary> 数据未上传 </summary>
[Description("数据未上传")]
数据未上传 = 0,
/// <summary> 数据已上传 </summary>
[Description("数据已上传")]
数据已上传 = 1,
/// <summary> 正在校验数据 </summary>
[Description("正在校验数据")]
正在校验数据 = 2,
/// <summary> 数据验证通过 </summary>
[Description("数据验证通过")]
数据验证通过 = 3,
/// <summary> 数据错误 </summary>
[Description("数据错误")]
数据错误 = 4,
/// <summary> 正在生成绩效 </summary>
[Description("正在生成绩效")]
正在生成绩效 = 5,
/// <summary> 绩效下发 </summary>
[Description("绩效下发")]
绩效下发 = 6,
/// <summary> 绩效解析失败 </summary>
[Description("绩效解析失败")]
绩效解析失败 = 7,
/// <summary> 归档 </summary>
[Description("归档")]
归档 = 8,
/// <summary> 等待 </summary>
[Description("等待")]
等待 = 9,
/// <summary> 绩效结果解析成功 </summary>
[Description("数据验证通过")]
绩效结果解析成功 = 10,
}
public enum AgWorkloadType
{
......@@ -119,24 +83,6 @@ public enum DataFormat
日期YYYYMMDD
}
public enum Role
{
绩效管理员 = 1,
医院管理员 = 2,
护士长 = 3,
科主任 = 4,
绩效核算办 = 5,
院领导 = 6,
财务科 = 7,
人事科 = 8,
特殊科室 = 9,
行政科室 = 10,
数据收集 = 11,
护理部审核 = 12,
绩效查询 = 13,
审计 = 14,
}
public class Background
{
public enum JobType
......
......@@ -20,6 +20,28 @@ public HandsonTableBase()
public List<Dictionary<string, object>> Data { get; set; }
public List<HandsonColumn> Columns { get; set; }
public object[] NestedHeadersArray { get; set; }
public void SetRowData(IEnumerable<HandsonRowData> datas)
{
foreach (var dt in datas)
{
var dic = CreateDataRow("编号", dt.Row.ToString());
foreach (var item in dt.CellData)
{
dic[item.Name.ToLower()] = item.Value?.ToString() ?? "";
}
Data.Add(dic);
}
}
protected Dictionary<string, object> CreateDataRow(string key, string value)
{
var temp = new Dictionary<string, object>() { { key, value } };
foreach (var item in ColHeaders)
{
if (!temp.ContainsKey(item))
temp.Add(item.ToLower(), "");
}
return temp;
}
}
public class HandsonTable : HandsonTableBase
......@@ -95,17 +117,6 @@ private void InitColumns(List<collect_permission> permissions)
}
Columns = columns;
}
private Dictionary<string, object> CreateDataRow(string key, string value)
{
var temp = new Dictionary<string, object>() { { key, value } };
foreach (var item in ColHeaders)
{
if (!temp.ContainsKey(item))
temp.Add(item.ToLower(), "");
}
return temp;
}
}
public class HandsonColumn
......
......@@ -11,44 +11,6 @@ public enum ExcelVersion
xls
}
/// <summary> 核算单元类型 </summary>
public enum UnitType
{
[Description("医生组")]
医生组 = 1,
[Description("护理组")]
护理组 = 2,
[Description("医技组")]
医技组 = 3,
[Description("专家组")]
专家组 = 4,
//[Description("其他")]
//其他 = 5,
[Description("特殊核算组")]
特殊核算组 = 6,
[Description("其他医生组")]
其他医生组 = 7,
[Description("其他护理组")]
其他护理组 = 8,
[Description("其他医技组")]
其他医技组 = 9,
[Description("行政高层")]
行政高层 = 10,
[Description("行政中层")]
行政中层 = 11,
[Description("行政后勤")]
行政后勤 = 12,
}
public enum SheetType
{
......
......@@ -6,6 +6,7 @@ namespace Performance.DtoModels
{
public class DeptdicResponse
{
public int AllotId { get; set; }
public int HospitalId { get; set; }
public string HISDeptName { get; set; }
public string Department { get; set; }
......
......@@ -27,6 +27,16 @@ public class EmployeeReservedDto
public string AccountingUnit { get; set; }
/// <summary>
///
/// </summary>
public string NewUnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string NewAccountingUnit { get; set; }
/// <summary>
/// 人员姓名
/// </summary>
public string EmployeeName { get; set; }
......
......@@ -75,5 +75,13 @@ public class sys_user
/// 父级ID
/// </summary>
public Nullable<int> ParentID { get; set; }
/// <summary>
/// 核算组别
/// </summary>
public string UnitType { get; set; }
/// <summary>
/// 核算序号
/// </summary>
public string UnitCode { get; set; }
}
}
......@@ -34,6 +34,21 @@ public class ag_secondallot
public string UnitType { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 变更核算组别
/// </summary>
public string NewUnitType { get; set; }
/// <summary>
/// 变更核算单元
/// </summary>
public string NewAccountingUnit { get; set; }
/// <summary>
/// 年
/// </summary>
public Nullable<int> Year { get; set; }
......@@ -44,11 +59,6 @@ public class ag_secondallot
public Nullable<int> Month { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 科室实发金额
/// </summary>
public Nullable<decimal> RealGiveFee { get; set; }
......
......@@ -50,6 +50,10 @@ public class per_dept_dic
/// 医院Id
/// </summary>
public Nullable<int> HospitalId { get; set; }
/// <summary>
/// AllotId
/// </summary>
public Nullable<int> AllotId { get; set; }
/// <summary>
/// 0 未通过验证 1 通过验证
......
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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.EntityModels
{
public class CofAccountingEntity
{
public int HospitalId { get; set; }
/// <summary>
/// 核算单元类型
/// </summary>
public string UnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 核算单元编码
/// </summary>
public string Code { get; set; }
}
}
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>();
public bool IsSecondAdmin { get; set; }
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace Performance.Infrastructure
{
public static partial class UtilExtensions
{
public static bool NotNullOrEmpty<T>(this IEnumerable<T> enumerable)
{
return enumerable != null && enumerable.Any();
}
}
}
......@@ -7,6 +7,32 @@ namespace Performance.Repository
{
public partial class PerforAgsecondallotRepository : PerforRepository<ag_secondallot>
{
public IQueryable<ag_secondallot> GetSeconds(int[] hospitalIds, string[] unitType, string accountingUnit)
{
var secondallots = from ag in context.Set<ag_secondallot>()
join at in context.Set<per_allot>()
on ag.AllotId equals at.ID
where hospitalIds.Contains(at.HospitalId)
select ag;
return secondallots
.Where(w => (unitType.Contains(w.UnitType) && w.Department == accountingUnit) || unitType.Contains(w.NewUnitType) && w.NewAccountingUnit == accountingUnit);
}
public IQueryable<ag_secondallot> Get(int allotId, string[] unitType, string accountingUnit, params int[] status)
{
var secondallots = from ag in context.Set<ag_secondallot>()
where ag.AllotId == allotId
select ag;
secondallots = secondallots
.Where(w => (unitType.Contains(w.UnitType) && w.Department == accountingUnit) || unitType.Contains(w.NewUnitType) && w.NewAccountingUnit == accountingUnit);
if (status.Any())
return secondallots.Where(w => w.Status.HasValue && status.Contains(w.Status.Value));
return secondallots;
}
/// <summary>
/// 删除已提交的历史记录(ag_compute)
/// </summary>
......
using Performance.EntityModels;
using System.Collections.Generic;
using System.Linq;
namespace Performance.Repository
{
public partial class PerforCofaccountingRepository : PerforRepository<cof_accounting>
{
public List<CofAccountingEntity> GetAccounting(params int[] hospitalIds)
{
var cofAccountings = from p in context.Set<per_allot>().Where(w => hospitalIds.Contains(w.HospitalId))
join a in context.Set<cof_accounting>()
on p.ID equals a.AllotId
select new { Allot = p, Accounting = a };
return cofAccountings
.Select(w => new { w.Allot.HospitalId, w.Accounting.AccountingUnit, w.Accounting.UnitType, w.Accounting.Code })
.Distinct()
.Select(w => new CofAccountingEntity
{
HospitalId = w.HospitalId,
Code = w.Code,
UnitType = w.UnitType,
AccountingUnit = w.AccountingUnit,
})
.ToList();
}
}
}
......@@ -28,6 +28,41 @@ public bool UpdateAllotStates(int allotId, int states, string remark, int genera
allot.Generate = generate;
return Update(allot);
}
#region 先取上一个月的绩效Id
/// <summary>
/// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
/// </summary>
/// <param name="allot"></param>
public int GetPrevAllot(int allotId)
{
var allot = context.Set<per_allot>().FirstOrDefault(t => t.ID == allotId);
if (allot == null)
return -1;
return GetPrevAllot(allot);
}
/// <summary>
/// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
/// </summary>
/// <param name="allot"></param>
public int GetPrevAllot(per_allot allot)
{
var list = context.Set<per_allot>().Where(t => t.HospitalId == allot.HospitalId).ToList();
if (list == null || !list.Any(t => t.ID == allot.ID))
return -1;
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
int allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID)
return -1;
return allotId;
}
#endregion
/// <summary>
/// 执行存储过程
......@@ -318,5 +353,25 @@ public IEnumerable<dynamic> QueryEmployee(int allotId)
}
}
}
/// <summary>
/// 验证科室核算单元、工号
/// </summary>
/// <param name="allot"></param>
public void AccoungtingVerify(int allotId)
{
using (var connection = context.Database.GetDbConnection())
{
if (connection.State != ConnectionState.Open) connection.Open();
try
{
connection.Execute("call proc_verify_accoungingunit_unittype(@allotId);", new { allotId }, commandTimeout: 60 * 60);
}
catch (Exception)
{
throw;
}
}
}
}
}
\ No newline at end of file
......@@ -391,6 +391,21 @@ public List<EmployeeReservedDto> GetEmployeeReserved(int hospitalId, int year)
return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = hospitalId, Year = year })?.ToList();
}
/// <summary>
/// 获取医院预留绩效
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="year"></param>
/// <returns></returns>
public List<EmployeeReservedDto> GetEmployeeReserved(int hospitalId, int year, string[] unitTypes, string accountingUnit)
{
string sql = @"
SELECT * FROM view_allot_result_report WHERE HospitalID=@HospitalID AND Year=@Year
AND ((UnitType IN @unitTypes AND AccountingUnit = @accountingUnit) OR (NewUnitType IN @unitTypes AND NewAccountingUnit = @accountingUnit))
";
return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = hospitalId, Year = year, unitTypes, accountingUnit })?.ToList();
}
public List<view_allot_result> GetOwnerPerformance(List<int> hospitalId, string jobNumber)
{
string sql = "SELECT * FROM view_allot_result WHERE States IN (6,8) AND HospitalID IN @HospitalID AND JobNumber=@JobNumber";
......
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;
var roleTypes = new int[] { (int)Role.科主任, (int)Role.护士长, (int)Role.特殊科室, (int)Role.行政科室, };
return new UserInfoCenter
{
User = user,
URole = roles.FirstOrDefault() ?? new sys_role(),
Hospitals = hospitals.ToList() ?? new List<sys_hospital>(),
IsSecondAdmin = roleTypes.Contains(roles.FirstOrDefault()?.Type ?? 0),
};
}
/// <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();
}
}
}
......@@ -11,7 +11,7 @@ namespace Performance.Repository
/// <summary>
/// cof_accounting Repository
/// </summary>
public class PerforCofaccountingRepository : PerforRepository<cof_accounting>
public partial class PerforCofaccountingRepository : PerforRepository<cof_accounting>
{
public PerforCofaccountingRepository(PerformanceDbContext context) : base(context)
{
......
using AutoMapper;
using Microsoft.Extensions.Options;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Performance.Services
{
public class AgainAllotService : IAutoInjection
{
private Application application;
private readonly IMapper _mapper;
private AgainService againService;
private RoleService roleService;
private ConfigService configService;
private PerforCofagainRepository perforCofagainRepository;
private PerforPeragainallotRepository perforPeragainallotRepository;
private PerforResaccountRepository perforResaccountRepository;
//private PerforResaccountnurseRepository perforResaccountnurseRepository;
private PerforUserRepository perforUserRepository;
private PerforUserhospitalRepository perforUserhospitalRepository;
private PerforPerallotRepository perforPerallotRepository;
private PerforAgagainsituationRepository perforAgagainsituationRepository;
private PerforAgdataRepository perforAgdataRepository;
private PerforAgemployeeRepository perforAgemployeeRepository;
private PerforAgheaderRepository perforAgheaderRepository;
public AgainAllotService(
IOptions<Application> options,
IMapper mapper,
AgainService againService,
RoleService roleService,
PerforCofagainRepository perforCofagainRepository,
PerforPeragainallotRepository perforPeragainallotRepository,
PerforResaccountRepository perforResaccountRepository,
//PerforResaccountnurseRepository perforResaccountnurseRepository,
PerforUserRepository perforUserRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perforPerallotRepository,
PerforAgagainsituationRepository perforAgagainsituationRepository,
PerforAgdataRepository perforAgdataRepository,
PerforAgemployeeRepository perforAgemployeeRepository,
PerforAgheaderRepository perforAgheaderRepository,
ConfigService configService)
{
this.application = options.Value;
_mapper = mapper;
this.againService = againService;
this.roleService = roleService;
this.perforCofagainRepository = perforCofagainRepository;
this.perforPeragainallotRepository = perforPeragainallotRepository;
this.perforResaccountRepository = perforResaccountRepository;
//this.perforResaccountnurseRepository = perforResaccountnurseRepository;
this.perforUserRepository = perforUserRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perforPerallotRepository = perforPerallotRepository;
this.perforAgagainsituationRepository = perforAgagainsituationRepository;
this.perforAgdataRepository = perforAgdataRepository;
this.perforAgemployeeRepository = perforAgemployeeRepository;
this.perforAgheaderRepository = perforAgheaderRepository;
this.configService = configService;
}
///// <summary>
///// 生成二次绩效
///// </summary>
///// <param name="request"></param>
//public bool Generate(AgainAllotRequest request, int userId, string department)
//{
// var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
// if (againAllot == null || againAllot.ID == 0)
// throw new PerformanceException("绩效二次分配不存在");
// var roles = roleService.GetRole(userId);
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; });
// //清理二次绩效无用数据
// configService.ClearAgain(againAllot.ID);
// try
// {
// #region 基础信息
// //获取基础配置信息
// var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID);
// var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value;
// var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value;
// var days = config.FirstOrDefault(t => t.Type == 3)?.Value;
// decimal? basicnumber = 0m;
// //获取科室实发绩效
// if (roles != null)
// {
// var role = roles.FirstOrDefault();
// if (role != null)
// {
// if (application.NurseRole == role.Type)
// basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
// else if (application.DirectorRole == role.Type)
// basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType != (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
// }
// }
// #endregion
// #region 计算
// //读取二次计算excel数据
// var perAgainExcel = againService.ReadData(againAllot);
// //护士长或科主任出勤
// var bossAttendance = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.JobTitle == "护士长")?.Attendance;
// //计算职称出勤系数、年资出勤系数
// foreach (var item in perAgainExcel.AgainEmployee)
// {
// item.JobAttendanceFactor = item.JobFactor * item.Attendance / days;
// item.YearAttendanceFactor = item.Attendance * item.YearFactor / days;
// }
// //计算 科室系数人均
// var departmentFactorAvg = basicnumber / perAgainExcel.AgainEmployee.Sum(t => t.YearAttendanceFactor);
// //二次分配科室概览
// PerAgainSituation situation = new PerAgainSituation
// {
// NightShift = perAgainExcel.AgainEmployee.Sum(t => t.NightShift),
// DepartmentTotal = basicnumber,
// BossPerfor = departmentFactorAvg * bossAttendance / days,
// Award = perAgainExcel.AgainEmployee.Sum(t => t.Award),
// Allowance = perAgainExcel.AgainEmployee.Sum(t => t.Allowance),
// AlonePerfor = perAgainExcel.AgainEmployee.Sum(t => t.AlonePerfor),
// Attendance = days,
// DepartmentFactorAvg = departmentFactorAvg
// };
// //业绩二次分配科室概览:业绩分配绩效、职称绩效、工作量绩效
// situation.AllotPerfor = situation.DepartmentTotal - situation.BossPerfor - situation.Award - situation.Allowance - situation.AlonePerfor;
// situation.JobPerfor = situation.AllotPerfor * jobfactor;
// situation.WorkloadPerfor = situation.AllotPerfor * workfactor;
// var rowList = perAgainExcel.AgainData.Select(t => t.RowNumber).Distinct().ToList();
// //业绩二次分配科室动态数据:工作量得分
// foreach (var rowNumber in rowList)
// {
// var againEmployee = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.RowNumber == rowNumber);
// var atRowList = perAgainExcel.AgainData.Where(t => t.RowNumber == rowNumber);
// decimal? sumValue = 0m;
// foreach (var atRow in atRowList)
// sumValue += atRow.IsFactor == 1 ? atRow.IsFactor * atRow.CellValue : atRow.CellValue;
// sumValue = sumValue * againEmployee?.YearFactor;
// var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "工作量得分");
// if (head == null)
// {
// perAgainExcel.Header.MergeCell++;
// var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
// var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
// head = new PerHeader(pointrow, pointcell, "工作量得分", 1, 1, 1, null, 1);
// perAgainExcel.Header.Children.Add(head);
// }
// perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "工作量得分", sumValue, 1, 2, null, "", "", head.SignID));
// }
// //业绩二次分配科室动态数据:绩效工资
// foreach (var rowNumber in rowList)
// {
// 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 perforValue = workvalue / sumvalue * situation.WorkloadPerfor;
// var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "绩效工资");
// if (head == null)
// {
// perAgainExcel.Header.MergeCell++;
// var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
// var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
// head = new PerHeader(pointrow, pointcell, "绩效工资", 1, 1, 1, null, 1);
// perAgainExcel.Header.Children.Add(head);
// }
// perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "绩效工资", perforValue, 1, 2, null, "", "", head.SignID));
// }
// //业绩二次分配科室:应发绩效、实发绩效
// string[] jobArray = new string[] { "护士长", "科主任" };
// foreach (var employee in perAgainExcel.AgainEmployee)
// {
// if (jobArray.Contains(employee.JobTitle))
// {
// employee.GiveFee = situation.BossPerfor;
// employee.RealGiveFee = situation.BossPerfor;
// }
// else
// {
// 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;
// employee.GiveFee = (employee.JobAttendancePerfor ?? 0) + (value ?? 0) + (employee.Award ?? 0) + (employee.Allowance ?? 0) + (employee.AlonePerfor ?? 0);
// employee.RealGiveFee = (employee.GiveFee ?? 0) + (employee.NightShift ?? 0);
// }
// }
// #endregion
// #region 保存
// var againsituation = _mapper.Map<ag_againsituation>(situation);
// againsituation.AllotID = againAllot.AllotID;
// againsituation.AgainAllotID = againAllot.ID;
// perforAgagainsituationRepository.Add(againsituation);
// var employeeList = _mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
// employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgemployeeRepository.AddRange(employeeList.ToArray());
// var pHeader = _mapper.Map<ag_header>(perAgainExcel.Header);
// pHeader.AllotID = againAllot.AllotID;
// pHeader.AgainAllotID = againAllot.ID;
// var cHeaderList = _mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
// cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgheaderRepository.Add(pHeader);
// perforAgheaderRepository.AddRange(cHeaderList.ToArray());
// var dataList = _mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
// dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// perforAgdataRepository.AddRange(dataList.ToArray());
// #endregion
// }
// catch (Exception ex)
// {
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 4; p.Remark = ex.ToString(); });
// }
// perforPeragainallotRepository.Update(againAllot, p => { p.States = 3; });
// return true;
// //return SheetFormat(perAgainExcel, situation);
//}
/// <summary>
/// 绩效详情表格转换
/// </summary>
/// <param name="perAgainExcel"></param>
/// <param name="situation"></param>
/// <returns></returns>
private (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) SheetFormat(PerAgainExcel perAgainExcel, PerAgainSituation situation)
{
#region 表格显示
SheetExportResponse response = new SheetExportResponse("二次绩效分配表");
//返回表格展示数据结构
var row = new Row(0);
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(3, "职称系数", 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(6, "年资", 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(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(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(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(14 + perAgainExcel.Header.Children.Count, "实发工资合计", 2, 1, false, false));
var rowTwo = new Row(1);
int startpoint = 9;
perAgainExcel.Header.Children.ForEach(t =>
{
rowTwo.Data.Add(new Cell(startpoint, t.CellValue, 1, 1, false, false));
startpoint++;
});
response.Header.Add(row);
response.Header.Add(rowTwo);
for (int i = 0; i < perAgainExcel.AgainEmployee.Count(); i++)
{
var item = perAgainExcel.AgainEmployee.ElementAt(i);
var rowbody = new Row(i);
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(3, item.JobFactor, 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(6, item.YearFactor, 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));
var againList = perAgainExcel.AgainData.Where(t => t.RowNumber == item.RowNumber);
startpoint = 9;
perAgainExcel.Header.Children.ForEach(t =>
{
var cellValue = againList.FirstOrDefault(s => t.SignID == s.SignID)?.CellValue;
rowbody.Data.Add(new Cell(startpoint, cellValue, 1, 1, false, false));
startpoint++;
});
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(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(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));
response.Row.Add(rowbody);
}
#endregion
return (response, situation);
}
/// <summary>
/// 查看二次分配详情及概览
/// </summary>
/// <param name="request"></param>
/// <param name="user"></param>
/// <returns></returns>
public (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) Detail(AgainAllotRequest request)
{
var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
if (againAllot == null || againAllot.ID == 0)
throw new PerformanceException("绩效二次分配不存在");
var situation = perforAgagainsituationRepository.GetEntity(t => t.AgainAllotID == againAllot.ID);
var againsituation = _mapper.Map<PerAgainSituation>(situation);
var againEmployee = perforAgemployeeRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var employeeList = _mapper.Map<List<PerAgainEmployee>>(againEmployee);
var header = perforAgheaderRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var headerList = _mapper.Map<List<PerHeader>>(header);
var data = perforAgdataRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
//var dataList = _mapper.Map<List<PerAgainData>>(data);
var pHead = header.FirstOrDefault(t => t.CellValue == "工作量绩效工资");
var head = _mapper.Map<PerHeader>(pHead);
var cHead = _mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资"));
head.Children = cHead;
var perAgainExcel = new PerAgainExcel
{
Header = head,
AgainData = _mapper.Map<List<PerAgainData>>(data),
AgainEmployee = _mapper.Map<List<PerAgainEmployee>>(againEmployee)
};
return SheetFormat(perAgainExcel, againsituation);
}
/// <summary>
/// 二次绩效新增记录
/// </summary>
/// <param name="allot"></param>
/// <param name="userid"></param>
/// <returns></returns>
public bool Update(per_allot allot, int againid)
{
var again = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
again.ID = againid;
again.UploadDateTime = DateTime.Now;
again.Path = allot.Path;
again.Remark = allot.Remark;
again.States = 1;
return perforPeragainallotRepository.Update(again);
}
/// <summary>
/// 根据人物角色获取绩效列表
/// </summary>
/// <returns></returns>
public List<AgainAllotResponse> GetAllotList(int userid)
{
var user = perforUserRepository.GetEntity(t => t.ID == userid);
if (user == null)
throw new NotImplementedException("人员ID无效");
var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userid);
if (hospital == null)
throw new NotImplementedException("人员未选择医院");
var allot = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.States == 6);
if (allot == null)
throw new NotImplementedException("该医院未生成绩效");
var allotId = allot.Select(t => t.ID).ToList();
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();
//取得未生成二次绩效的绩效id
var exceptId = allotId.Except(arrId).ToList();
if (exceptId.Count > 0)
{
allot = allot.Where(t => exceptId.Contains(t.ID)).ToList();
var model = allot.Select(t => new per_againallot
{
AllotID = t.ID,
CreateUser = userid,
CreateDateTime = DateTime.Now,
Department = user.Department,
States = 0
});
//生成二次绩效
perforPeragainallotRepository.AddRange(model.ToArray());
}
again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.CreateUser == userid);
List<AgainAllotResponse> list = _mapper.Map<List<AgainAllotResponse>>(again);
list.ForEach(t =>
{
var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault();
t.Year = data.Year;
t.Month = data.Month;
});
return list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
}
/// <summary>
/// 获取状态不是归档的二次绩效的记录
/// </summary>
/// <param name="againid"></param>
/// <returns></returns>
public per_againallot GetAgainallot(int againid)
{
var list = perforPeragainallotRepository.GetEntity(t => t.ID == againid && t.States != 5);
return list;
}
}
}
//using AutoMapper;
//using Microsoft.Extensions.Options;
//using Performance.DtoModels;
//using Performance.DtoModels.AppSettings;
//using Performance.EntityModels;
//using Performance.Repository;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//namespace Performance.Services
//{
// public class AgainAllotService : IAutoInjection
// {
// private Application application;
// private readonly IMapper _mapper;
// private AgainService againService;
// private RoleService roleService;
// private ConfigService configService;
// private PerforCofagainRepository perforCofagainRepository;
// private PerforPeragainallotRepository perforPeragainallotRepository;
// private PerforResaccountRepository perforResaccountRepository;
// //private PerforResaccountnurseRepository perforResaccountnurseRepository;
// private PerforUserRepository perforUserRepository;
// private PerforUserhospitalRepository perforUserhospitalRepository;
// private PerforPerallotRepository perforPerallotRepository;
// private PerforAgagainsituationRepository perforAgagainsituationRepository;
// private PerforAgdataRepository perforAgdataRepository;
// private PerforAgemployeeRepository perforAgemployeeRepository;
// private PerforAgheaderRepository perforAgheaderRepository;
// public AgainAllotService(
// IOptions<Application> options,
// IMapper mapper,
// AgainService againService,
// RoleService roleService,
// PerforCofagainRepository perforCofagainRepository,
// PerforPeragainallotRepository perforPeragainallotRepository,
// PerforResaccountRepository perforResaccountRepository,
// //PerforResaccountnurseRepository perforResaccountnurseRepository,
// PerforUserRepository perforUserRepository,
// PerforUserhospitalRepository perforUserhospitalRepository,
// PerforPerallotRepository perforPerallotRepository,
// PerforAgagainsituationRepository perforAgagainsituationRepository,
// PerforAgdataRepository perforAgdataRepository,
// PerforAgemployeeRepository perforAgemployeeRepository,
// PerforAgheaderRepository perforAgheaderRepository,
// ConfigService configService)
// {
// this.application = options.Value;
// _mapper = mapper;
// this.againService = againService;
// this.roleService = roleService;
// this.perforCofagainRepository = perforCofagainRepository;
// this.perforPeragainallotRepository = perforPeragainallotRepository;
// this.perforResaccountRepository = perforResaccountRepository;
// //this.perforResaccountnurseRepository = perforResaccountnurseRepository;
// this.perforUserRepository = perforUserRepository;
// this.perforUserhospitalRepository = perforUserhospitalRepository;
// this.perforPerallotRepository = perforPerallotRepository;
// this.perforAgagainsituationRepository = perforAgagainsituationRepository;
// this.perforAgdataRepository = perforAgdataRepository;
// this.perforAgemployeeRepository = perforAgemployeeRepository;
// this.perforAgheaderRepository = perforAgheaderRepository;
// this.configService = configService;
// }
// ///// <summary>
// ///// 生成二次绩效
// ///// </summary>
// ///// <param name="request"></param>
// //public bool Generate(AgainAllotRequest request, int userId, string department)
// //{
// // var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
// // if (againAllot == null || againAllot.ID == 0)
// // throw new PerformanceException("绩效二次分配不存在");
// // var roles = roleService.GetRole(userId);
// // perforPeragainallotRepository.Update(againAllot, p => { p.States = 2; });
// // //清理二次绩效无用数据
// // configService.ClearAgain(againAllot.ID);
// // try
// // {
// // #region 基础信息
// // //获取基础配置信息
// // var config = perforCofagainRepository.GetEntities(t => t.AllotID == againAllot.AllotID);
// // var jobfactor = config.FirstOrDefault(t => t.Type == 1)?.Value;
// // var workfactor = config.FirstOrDefault(t => t.Type == 2)?.Value;
// // var days = config.FirstOrDefault(t => t.Type == 3)?.Value;
// // decimal? basicnumber = 0m;
// // //获取科室实发绩效
// // if (roles != null)
// // {
// // var role = roles.FirstOrDefault();
// // if (role != null)
// // {
// // if (application.NurseRole == role.Type)
// // basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType == (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
// // else if (application.DirectorRole == role.Type)
// // basicnumber = perforResaccountRepository.GetEntity(t => t.UnitType != (int)UnitType.护理组 && t.AllotID == againAllot.AllotID && t.AccountingUnit == department)?.RealGiveFee;
// // }
// // }
// // #endregion
// // #region 计算
// // //读取二次计算excel数据
// // var perAgainExcel = againService.ReadData(againAllot);
// // //护士长或科主任出勤
// // var bossAttendance = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.JobTitle == "护士长")?.Attendance;
// // //计算职称出勤系数、年资出勤系数
// // foreach (var item in perAgainExcel.AgainEmployee)
// // {
// // item.JobAttendanceFactor = item.JobFactor * item.Attendance / days;
// // item.YearAttendanceFactor = item.Attendance * item.YearFactor / days;
// // }
// // //计算 科室系数人均
// // var departmentFactorAvg = basicnumber / perAgainExcel.AgainEmployee.Sum(t => t.YearAttendanceFactor);
// // //二次分配科室概览
// // PerAgainSituation situation = new PerAgainSituation
// // {
// // NightShift = perAgainExcel.AgainEmployee.Sum(t => t.NightShift),
// // DepartmentTotal = basicnumber,
// // BossPerfor = departmentFactorAvg * bossAttendance / days,
// // Award = perAgainExcel.AgainEmployee.Sum(t => t.Award),
// // Allowance = perAgainExcel.AgainEmployee.Sum(t => t.Allowance),
// // AlonePerfor = perAgainExcel.AgainEmployee.Sum(t => t.AlonePerfor),
// // Attendance = days,
// // DepartmentFactorAvg = departmentFactorAvg
// // };
// // //业绩二次分配科室概览:业绩分配绩效、职称绩效、工作量绩效
// // situation.AllotPerfor = situation.DepartmentTotal - situation.BossPerfor - situation.Award - situation.Allowance - situation.AlonePerfor;
// // situation.JobPerfor = situation.AllotPerfor * jobfactor;
// // situation.WorkloadPerfor = situation.AllotPerfor * workfactor;
// // var rowList = perAgainExcel.AgainData.Select(t => t.RowNumber).Distinct().ToList();
// // //业绩二次分配科室动态数据:工作量得分
// // foreach (var rowNumber in rowList)
// // {
// // var againEmployee = perAgainExcel.AgainEmployee.FirstOrDefault(t => t.RowNumber == rowNumber);
// // var atRowList = perAgainExcel.AgainData.Where(t => t.RowNumber == rowNumber);
// // decimal? sumValue = 0m;
// // foreach (var atRow in atRowList)
// // sumValue += atRow.IsFactor == 1 ? atRow.IsFactor * atRow.CellValue : atRow.CellValue;
// // sumValue = sumValue * againEmployee?.YearFactor;
// // var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "工作量得分");
// // if (head == null)
// // {
// // perAgainExcel.Header.MergeCell++;
// // var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
// // var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
// // head = new PerHeader(pointrow, pointcell, "工作量得分", 1, 1, 1, null, 1);
// // perAgainExcel.Header.Children.Add(head);
// // }
// // perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "工作量得分", sumValue, 1, 2, null, "", "", head.SignID));
// // }
// // //业绩二次分配科室动态数据:绩效工资
// // foreach (var rowNumber in rowList)
// // {
// // 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 perforValue = workvalue / sumvalue * situation.WorkloadPerfor;
// // var head = perAgainExcel.Header.Children.FirstOrDefault(t => t.CellValue == "绩效工资");
// // if (head == null)
// // {
// // perAgainExcel.Header.MergeCell++;
// // var pointrow = perAgainExcel.Header.Children.Max(t => t.PointRow);
// // var pointcell = perAgainExcel.Header.Children.Max(t => t.PointCell);
// // head = new PerHeader(pointrow, pointcell, "绩效工资", 1, 1, 1, null, 1);
// // perAgainExcel.Header.Children.Add(head);
// // }
// // perAgainExcel.AgainData.Add(new PerAgainData(rowNumber.Value, "绩效工资", perforValue, 1, 2, null, "", "", head.SignID));
// // }
// // //业绩二次分配科室:应发绩效、实发绩效
// // string[] jobArray = new string[] { "护士长", "科主任" };
// // foreach (var employee in perAgainExcel.AgainEmployee)
// // {
// // if (jobArray.Contains(employee.JobTitle))
// // {
// // employee.GiveFee = situation.BossPerfor;
// // employee.RealGiveFee = situation.BossPerfor;
// // }
// // else
// // {
// // 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;
// // employee.GiveFee = (employee.JobAttendancePerfor ?? 0) + (value ?? 0) + (employee.Award ?? 0) + (employee.Allowance ?? 0) + (employee.AlonePerfor ?? 0);
// // employee.RealGiveFee = (employee.GiveFee ?? 0) + (employee.NightShift ?? 0);
// // }
// // }
// // #endregion
// // #region 保存
// // var againsituation = _mapper.Map<ag_againsituation>(situation);
// // againsituation.AllotID = againAllot.AllotID;
// // againsituation.AgainAllotID = againAllot.ID;
// // perforAgagainsituationRepository.Add(againsituation);
// // var employeeList = _mapper.Map<List<ag_employee>>(perAgainExcel.AgainEmployee);
// // employeeList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// // perforAgemployeeRepository.AddRange(employeeList.ToArray());
// // var pHeader = _mapper.Map<ag_header>(perAgainExcel.Header);
// // pHeader.AllotID = againAllot.AllotID;
// // pHeader.AgainAllotID = againAllot.ID;
// // var cHeaderList = _mapper.Map<List<ag_header>>(perAgainExcel.Header.Children);
// // cHeaderList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// // perforAgheaderRepository.Add(pHeader);
// // perforAgheaderRepository.AddRange(cHeaderList.ToArray());
// // var dataList = _mapper.Map<List<ag_data>>(perAgainExcel.AgainData);
// // dataList.ForEach(item => { item.AllotID = againAllot.AllotID; item.AgainAllotID = againAllot.ID; });
// // perforAgdataRepository.AddRange(dataList.ToArray());
// // #endregion
// // }
// // catch (Exception ex)
// // {
// // perforPeragainallotRepository.Update(againAllot, p => { p.States = 4; p.Remark = ex.ToString(); });
// // }
// // perforPeragainallotRepository.Update(againAllot, p => { p.States = 3; });
// // return true;
// // //return SheetFormat(perAgainExcel, situation);
// //}
// /// <summary>
// /// 绩效详情表格转换
// /// </summary>
// /// <param name="perAgainExcel"></param>
// /// <param name="situation"></param>
// /// <returns></returns>
// private (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) SheetFormat(PerAgainExcel perAgainExcel, PerAgainSituation situation)
// {
// #region 表格显示
// SheetExportResponse response = new SheetExportResponse("二次绩效分配表");
// //返回表格展示数据结构
// var row = new Row(0);
// 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(3, "职称系数", 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(6, "年资", 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(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(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(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(14 + perAgainExcel.Header.Children.Count, "实发工资合计", 2, 1, false, false));
// var rowTwo = new Row(1);
// int startpoint = 9;
// perAgainExcel.Header.Children.ForEach(t =>
// {
// rowTwo.Data.Add(new Cell(startpoint, t.CellValue, 1, 1, false, false));
// startpoint++;
// });
// response.Header.Add(row);
// response.Header.Add(rowTwo);
// for (int i = 0; i < perAgainExcel.AgainEmployee.Count(); i++)
// {
// var item = perAgainExcel.AgainEmployee.ElementAt(i);
// var rowbody = new Row(i);
// 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(3, item.JobFactor, 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(6, item.YearFactor, 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));
// var againList = perAgainExcel.AgainData.Where(t => t.RowNumber == item.RowNumber);
// startpoint = 9;
// perAgainExcel.Header.Children.ForEach(t =>
// {
// var cellValue = againList.FirstOrDefault(s => t.SignID == s.SignID)?.CellValue;
// rowbody.Data.Add(new Cell(startpoint, cellValue, 1, 1, false, false));
// startpoint++;
// });
// 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(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(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));
// response.Row.Add(rowbody);
// }
// #endregion
// return (response, situation);
// }
// /// <summary>
// /// 查看二次分配详情及概览
// /// </summary>
// /// <param name="request"></param>
// /// <param name="user"></param>
// /// <returns></returns>
// public (SheetExportResponse SheetExport, PerAgainSituation AgainSituation) Detail(AgainAllotRequest request)
// {
// var againAllot = perforPeragainallotRepository.GetEntity(t => t.ID == request.AgainAllotID);
// if (againAllot == null || againAllot.ID == 0)
// throw new PerformanceException("绩效二次分配不存在");
// var situation = perforAgagainsituationRepository.GetEntity(t => t.AgainAllotID == againAllot.ID);
// var againsituation = _mapper.Map<PerAgainSituation>(situation);
// var againEmployee = perforAgemployeeRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
// //var employeeList = _mapper.Map<List<PerAgainEmployee>>(againEmployee);
// var header = perforAgheaderRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
// //var headerList = _mapper.Map<List<PerHeader>>(header);
// var data = perforAgdataRepository.GetEntities(t => t.AgainAllotID == againAllot.ID);
// //var dataList = _mapper.Map<List<PerAgainData>>(data);
// var pHead = header.FirstOrDefault(t => t.CellValue == "工作量绩效工资");
// var head = _mapper.Map<PerHeader>(pHead);
// var cHead = _mapper.Map<List<PerHeader>>(header.Where(t => t.CellValue != "工作量绩效工资"));
// head.Children = cHead;
// var perAgainExcel = new PerAgainExcel
// {
// Header = head,
// AgainData = _mapper.Map<List<PerAgainData>>(data),
// AgainEmployee = _mapper.Map<List<PerAgainEmployee>>(againEmployee)
// };
// return SheetFormat(perAgainExcel, againsituation);
// }
// /// <summary>
// /// 二次绩效新增记录
// /// </summary>
// /// <param name="allot"></param>
// /// <param name="userid"></param>
// /// <returns></returns>
// public bool Update(per_allot allot, int againid)
// {
// var again = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
// again.ID = againid;
// again.UploadDateTime = DateTime.Now;
// again.Path = allot.Path;
// again.Remark = allot.Remark;
// again.States = 1;
// return perforPeragainallotRepository.Update(again);
// }
// /// <summary>
// /// 根据人物角色获取绩效列表
// /// </summary>
// /// <returns></returns>
// public List<AgainAllotResponse> GetAllotList(int userid)
// {
// var user = perforUserRepository.GetEntity(t => t.ID == userid);
// if (user == null)
// throw new NotImplementedException("人员ID无效");
// var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userid);
// if (hospital == null)
// throw new NotImplementedException("人员未选择医院");
// var allot = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.States == 6);
// if (allot == null)
// throw new NotImplementedException("该医院未生成绩效");
// var allotId = allot.Select(t => t.ID).ToList();
// 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();
// //取得未生成二次绩效的绩效id
// var exceptId = allotId.Except(arrId).ToList();
// if (exceptId.Count > 0)
// {
// allot = allot.Where(t => exceptId.Contains(t.ID)).ToList();
// var model = allot.Select(t => new per_againallot
// {
// AllotID = t.ID,
// CreateUser = userid,
// CreateDateTime = DateTime.Now,
// Department = user.Department,
// States = 0
// });
// //生成二次绩效
// perforPeragainallotRepository.AddRange(model.ToArray());
// }
// again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.CreateUser == userid);
// List<AgainAllotResponse> list = _mapper.Map<List<AgainAllotResponse>>(again);
// list.ForEach(t =>
// {
// var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault();
// t.Year = data.Year;
// t.Month = data.Month;
// });
// return list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
// }
// /// <summary>
// /// 获取状态不是归档的二次绩效的记录
// /// </summary>
// /// <param name="againid"></param>
// /// <returns></returns>
// public per_againallot GetAgainallot(int againid)
// {
// var list = perforPeragainallotRepository.GetEntity(t => t.ID == againid && t.States != 5);
// return list;
// }
// }
//}
......@@ -276,7 +276,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
var pairs = new[]
{
new { Name = "医生组临床科室单元核算表", Data = doctorWorkloadData, SheetType = SheetType.ComputeDoctorAccount,
UnitTypes = new List<UnitType> { UnitType.医生组, UnitType.医技组, UnitType.专家组, UnitType.其他医技组,UnitType.其他医生组 } },
UnitTypes = new List<UnitType> { UnitType.医生组, UnitType.医技组, UnitType.其他医技组,UnitType.其他医生组 } },
new { Name = "护理组临床科室单元核算表", Data = nurseWorkloadData, SheetType = SheetType.ComputeNurseAccount,
UnitTypes = new List<UnitType> { UnitType.护理组, UnitType.其他护理组 } },
};
......@@ -298,7 +298,7 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
var econDoctor = economicData?.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
var workDoctor = info.Data.FirstOrDefault(t => t.UnitType == unitType.ToString() && t.AccountingUnit == dept.AccountingUnit);
if (UnitType.专家组 == unitType || UnitType.其他医技组 == unitType || UnitType.其他医生组 == unitType || UnitType.其他护理组 == unitType)
if (UnitType.其他医技组 == unitType || UnitType.其他医生组 == unitType || UnitType.其他护理组 == unitType)
{
econDoctor = economicData?.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit);
workDoctor = info.Data.FirstOrDefault(t => t.AccountingUnit == dept.AccountingUnit);
......
......@@ -521,7 +521,7 @@ public void GenerateSecondAllot(per_allot allot)
List<ag_secondallot> updSecond = new List<ag_secondallot>();
List<ag_secondallot> delSecond = new List<ag_secondallot>();
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政 };
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政 };
//// 获取医院是否开启后勤二次分配
//var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
//if (hospital?.IsOpenLogisticsSecondAllot != 1)
......@@ -529,7 +529,7 @@ public void GenerateSecondAllot(per_allot allot)
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && !types.Contains(t.UnitType.Value));
// 查询需要进行二次分配的行政后勤科室
var xzAccountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是");
var xzAccountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是");
if (xzAccountUnit != null && xzAccountUnit.Count > 0)
(accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
......
......@@ -16,6 +16,7 @@
using System.Data;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
namespace Performance.Services
{
......@@ -30,6 +31,7 @@ public class AllotService : IAutoInjection
private IWebHostEnvironment _evn;
private ILogger<AllotService> _logger;
private readonly IMapper _mapper;
private readonly PerforUserRepository _userRepository;
private PerforPerallotRepository _allotRepository;
private IEmailService emailService;
private readonly IOptions<Application> options;
......@@ -55,6 +57,7 @@ public class AllotService : IAutoInjection
public AllotService(
IMapper mapper,
PerforUserRepository userRepository,
PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService,
ImportDataService importDataService,
......@@ -85,6 +88,7 @@ public class AllotService : IAutoInjection
QueryDataService queryDataService)
{
_mapper = mapper;
_userRepository = userRepository;
_allotRepository = allotRepository;
_againallotRepository = againallotRepository;
_logger = logger;
......@@ -448,7 +452,7 @@ public void Generate(per_allot allot)
UpdateAllotStates(allot.ID, (int)AllotStates.绩效结果解析成功, EnumHelper.GetDescription(AllotStates.绩效结果解析成功), generate);
perforCofdirectorRepository.SupplementaryData(allot.ID);
// 验证科室核算单元、工号
AccoungtingVerify(allot.ID);
_allotRepository.AccoungtingVerify(allot.ID);
//补全支出费用类别
configService.SaveDrugtypeDisburse(allot.ID);
//logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true);
......@@ -494,10 +498,7 @@ public void GenerateReport(per_allot allot)
/// <param name="allot"></param>
public void AccoungtingVerify(int allotId)
{
using (IDbConnection connection = new MySqlConnection(_appConnection.Value.PerformanceConnectionString))
{
connection.Execute("call proc_verify_accoungingunit_unittype(@allotId);", new { allotId });
}
_allotRepository.AccoungtingVerify(allotId);
}
/// <summary>
......@@ -650,29 +651,19 @@ public List<log_dbug> AllotLog(per_allot allot, int type)
/// <returns></returns>
public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int userid)
{
var user = userService.GetUser(userid);
if (user == null)
throw new PerformanceException("用户信息错误");
var userInfo = _userRepository.GetUser(userid);
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
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);
if (reserveds != null && reserveds.Any())
if (userInfo.IsSecondAdmin)
{
if (role.Value == options.Value.NurseRole)
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.护理组, UnitType.其他护理组) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.DirectorRole)
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.医生组, UnitType.其他医生组, UnitType.医技组, UnitType.其他医技组) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.SpecialRole)
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.特殊核算组) && w.AccountingUnit == user.Department)?.ToList();
else if (role.Value == options.Value.OfficeRole)
reserveds = reserveds.Where(w => UnitTypeUtil.Is(w.UnitType, UnitType.行政中层, UnitType.行政后勤) && w.AccountingUnit == user.Department)?.ToList();
var unitTpes = UnitTypeUtil.GetMaps(userInfo?.URole.Type);
return _reportRepository.GetEmployeeReserved(hospitalId, year, unitTpes, userInfo.User.Department);
}
else
{
return _reportRepository.GetEmployeeReserved(hospitalId, year);
}
return reserveds;
}
/// <summary>
/// 查询个人绩效
......
......@@ -116,14 +116,13 @@ public ApiResponse<List<view_attendance>> GetCallIn(int allotId)
}
}
public HandsonTable GetBatchCallInHandsonTable(int allotId)
public HandsonTableBase GetBatchCallInHandsonTable(int allotId)
{
HandsonTable handson = new HandsonTable((int)SheetType.Unidentifiable, Person.Select(c => c.Item2).ToArray(), Person.Select(t => new collect_permission
HandsonTableBase handson = new HandsonTableBase()
{
HeadName = t.Item2,
Visible = 1,
Readnoly = 0
}).ToList());
Columns = Person.Select(t => new HandsonColumn(t.Item2)).ToList(),
ColHeaders = Person.Select(c => c.Item2).ToList(),
};
if (handson.Columns != null && handson.Columns.Any())
{
var cofaccounting = cofaccountingRepository.GetEntities(w => w.UnitType != "" && w.AllotId == allotId);
......@@ -133,7 +132,6 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
if (column.Data == "调入组别")
{
column.Type = "autocomplete";
//column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
column.Source = cofaccounting.Select(w => w.UnitType).Distinct().ToArray();
column.Strict = true;
}
......@@ -141,16 +139,9 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
if (column.Data == "调入核算单元")
{
column.Type = "autocomplete";
//column.Source = EnumHelper.GetItems<AccountUnitType>().Where(w => w.Description != "").Select(w => w.Description).ToArray();
column.Source = cofaccounting.Select(w => w.AccountingUnit).Distinct().ToArray();
column.Strict = true;
}
//if (column.Data == "调入时间")
//{
// column.Type = "date";
// column.DateFormat = "YYYY/MM/DD";
//}
}
}
List<view_attendance> data = new List<view_attendance>();
......@@ -184,7 +175,7 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
handson.SetRowData(rowDatas, rowDatas != null);
handson.SetRowData(rowDatas);
foreach (var item in handson.Data)
{
item.Remove("编号");
......@@ -386,25 +377,19 @@ public ApiResponse DeleteAttendanceType(int id)
#endregion
#region 考勤记录
public HandsonTable GetAttendanceVacationHandsonTable(int allotId)
public HandsonTableBase GetAttendanceVacationHandsonTable(int allotId)
{
HandsonTable handson = new HandsonTable((int)SheetType.Unidentifiable, Vacation.Select(c => c.Item2).ToArray(), Vacation.Select(t => new collect_permission
HandsonTableBase handson = new HandsonTableBase()
{
HeadName = t.Item2,
Visible = 1,
Readnoly = 0
}).ToList());
Columns = Vacation.Select(t => new HandsonColumn(t.Item2)).ToList(),
ColHeaders = Vacation.Select(c => c.Item2).ToList(),
};
if (handson.Columns != null && handson.Columns.Any())
{
var type = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId);
foreach (var column in handson.Columns)
{
column.Type = "text";
//if (column.Data.Contains("时间"))
//{
// column.Type = "date";
// column.DateFormat = "YYYY/MM/DD";
//}
if (column.Data == "考勤类型")
{
column.Type = "autocomplete";
......@@ -444,7 +429,7 @@ public HandsonTable GetAttendanceVacationHandsonTable(int allotId)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
handson.SetRowData(rowDatas, rowDatas != null);
handson.SetRowData(rowDatas);
foreach (var item in handson.Data)
{
item.Remove("编号");
......
......@@ -250,7 +250,7 @@ public IEnumerable<collect_permission> GetCollectSheet(int hospitalId, int userI
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
if (userrole == null) return new List<collect_permission>();
if (!options.CollectRoles.Contains(userrole.RoleID))
if (!UnitTypeUtil.CollectRoles.Contains(userrole.RoleID))
{
var types = new[] { (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload, (int)SheetType.SpecialUnit };
var sheetNames = exmoduleRepository.GetEntities(w => w.HospitalId == hospitalId && types.Contains(w.SheetType ?? 0))?.Select(t => t.ModuleName).ToList() ?? new List<string>();
......@@ -560,7 +560,7 @@ private List<HandsonRowData> GetAccountExtra(per_allot allot, int sheetType, str
var unitTypes = new string[] { UnitType.医生组.ToString(), UnitType.医技组.ToString(), UnitType.护理组.ToString(), UnitType.特殊核算组.ToString() };
var departments = perforPerdeptdicRepository.GetEntities(t => t.HospitalId == allot.HospitalId && unitTypes.Contains(t.UnitType) && !string.IsNullOrEmpty(t.Department) && t.Department.Replace("无", "").Replace("/", "").Trim() != "");
var departments = perforPerdeptdicRepository.GetEntities(t => t.AllotId == allot.ID && unitTypes.Contains(t.UnitType) && !string.IsNullOrEmpty(t.Department) && t.Department.Replace("无", "").Replace("/", "").Trim() != "");
if (departments == null || !departments.Any()) return handsonRows;
var data = departments.GroupBy(t => t.Department).Select(t => new
......
......@@ -309,7 +309,7 @@ public List<DeptResponse> GetNursePerformance(int allotId)
/// <returns></returns>
public List<DeptResponse> GetOtherPerformance(int allotId)
{
return GetGroupPerformance(allotId, new List<int> { (int)UnitType.其他医技组, (int)UnitType.其他医生组, (int)UnitType.其他护理组, (int)UnitType.专家组 });
return GetGroupPerformance(allotId, new List<int> { (int)UnitType.其他医技组, (int)UnitType.其他医生组, (int)UnitType.其他护理组 });
}
public List<DeptResponse> GetGroupPerformance(int allotId, List<int> group)
{
......@@ -326,7 +326,7 @@ public List<DeptResponse> GetGroupPerformance(int allotId, List<int> group)
/// <returns></returns>
public List<DeptResponse> GetOfficePerformance(int allotId)
{
var unitType = new List<int> { (int)UnitType.行政 };
var unitType = new List<int> { (int)UnitType.行政 };
var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId && t.NeedSecondAllot == "是")
?.OrderBy(t => t.UnitType)
......@@ -565,7 +565,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
#region 需要二次分配的行政科室
// 需要二次分配的行政科室
var needSecond = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是") ?? new List<res_account>();
var needSecond = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是") ?? new List<res_account>();
var needSecondResult = needSecond.Select(t => new DeptResponse
{
UnitName = ((UnitType)t.UnitType).ToString() == "行政后勤" ? "行政工勤" : ((UnitType)t.UnitType).ToString(),
......@@ -712,8 +712,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
enumItems.ForEach(t =>
{
t.Value = UnitTypeUtil.Is(t.Name, UnitType.护理组) ? t.Value + 2 : t.Value;
if (t.Name == UnitType.行政后勤.ToString())
t.Name = "行政工勤";
t.Name = t.Name == "行政后勤" ? UnitType.行政工勤.ToString() : t.Name;
});
result = result.OrderBy(t => enumItems.FirstOrDefault(e => e.Name == t.UnitName)?.Value).ThenBy(t => t.AccountingUnit).ToList();
......@@ -886,7 +885,7 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM
// 预留比例
if (response != null)
{
var types = new string[] { UnitType.行政高层.ToString(), UnitType.行政中层.ToString(), UnitType.行政后勤.ToString(), "行政工勤" };
var types = new string[] { UnitType.行政高层.ToString(), UnitType.行政中层.ToString(), UnitType.行政工勤.ToString(), "行政后勤" };
foreach (var item in response)
{
// 二次分配默认 调节系数100%
......@@ -1512,7 +1511,7 @@ private UnitType TypeConversion(int? unitType)
{
UnitType type = (UnitType)unitType.Value;
var docUnitTypes = new List<UnitType> { UnitType.专家组, UnitType.其他医生组, UnitType.其他医技组 };
var docUnitTypes = new List<UnitType> { UnitType.其他医生组, UnitType.其他医技组 };
if (docUnitTypes.Contains(type))
type = UnitType.医生组;
else if (type == UnitType.其他护理组)
......@@ -1576,8 +1575,8 @@ public DeptDataDetails DeptOfficeDetail(int accountId)
foreach (var sheet in persheet.Where(t => t.SheetType == stype))
{
groupBasis++;
var (sheettype, amount) = CommonDepartmentDetail(basicData, sheet, UnitType.行政);
var items = CommonDetailItems(basicData, headers, sheet, UnitType.行政);
var (sheettype, amount) = CommonDepartmentDetail(basicData, sheet, UnitType.行政);
var items = CommonDetailItems(basicData, headers, sheet, UnitType.行政);
var sheetName = new Regex("[0-9]*").Replace(sheet.SheetName, "", 5).Replace(".", "").Replace(" ", "");
// 只是显示好看而已
......
using AutoMapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.EntityModels.Other;
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Repository.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Performance.Repository.Repository;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using Performance.EntityModels.Other;
namespace Performance.Services
{
public class ConfigService : IAutoInjection
{
private readonly IMapper _mapper;
#region
private readonly IMapper _mapper;
private readonly UserService _userService;
private readonly RoleService _roleService;
private readonly CopyService _copyService;
private readonly PersonService _personService;
private readonly LogManageService _logManageService;
private readonly ExConfigService _exConfigService;
private readonly PerforReportRepository _perforReport;
private readonly PerforImdataRepository _imdataRepository;
private readonly PerforPerallotRepository _perallotRepository;
private readonly PerforCofdirectorRepository _directorRepository;
//private readonly PerforCofdrugpropRepository _drugpropRepository;
private readonly PerforCofworkitemRepository _workitemRepository;
private readonly PerforCofagainRepository _againRepository;
private readonly PerforCofdrugtypeRepository _drugtypeRepository;
private readonly PerforPerallotRepository perforPerAllotRepository;
private readonly PerforHospitalRepository perforHospitalRepository;
private readonly PerforPersheetRepository perforPersheetRepository;
private readonly PerforImheaderRepository perforImheaderRepository;
private readonly PerforImdataRepository imdataRepository;
private readonly PerforCofdepttypeRepository perforCofdepttypeRepository;
private readonly PerforPerapramountRepository perapramountRepository;
//private readonly PerforCofcmiRepository perforCofcmiRepository;
private readonly PerforCofHrpDeptRepository perforCofHrpDeptRepository;
private readonly PerforCofaliasRepository perforCofaliasRepository;
private readonly PerforCofaccountingRepository cofaccountingRepository;
private readonly PerforCofdrugtypeDisburseRepository drugtypeDisburseRepository;
private readonly PersonService personService;
private readonly LogManageService logManageService;
private readonly ExConfigService exConfigService;
private readonly ILogger<ConfigService> logger;
private readonly PerforExmoduleRepository perforExmoduleRepository;
private readonly PerforCofdrugtypefactorRepository cofdrugtypefactorRepository;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforReportRepository perforReport;
private readonly PerforPerallotRepository _perforPerAllotRepository;
private readonly PerforPersheetRepository _perforPersheetRepository;
private readonly PerforImheaderRepository _perforImheaderRepository;
private readonly PerforCofdepttypeRepository _perforCofdepttypeRepository;
private readonly PerforCofHrpDeptRepository _perforCofHrpDeptRepository;
private readonly PerforCofaliasRepository _perforCofaliasRepository;
private readonly PerforCofaccountingRepository _cofaccountingRepository;
private readonly PerforCofdrugtypeDisburseRepository _drugtypeDisburseRepository;
private readonly PerforExmoduleRepository _perforExmoduleRepository;
private readonly PerforCofdrugtypefactorRepository _cofdrugtypefactorRepository;
public ConfigService(
IMapper mapper,
UserService userService,
RoleService roleService,
CopyService copyService,
PersonService personService,
LogManageService logManageService,
ExConfigService exConfigService,
PerforReportRepository perforReport,
PerforImdataRepository imdataRepository,
PerforPerallotRepository perallotRepository,
PerforCofdirectorRepository cofdirectorRepository,
//PerforCofdrugpropRepository cofdrugpropRepository,
PerforCofagainRepository againRepository,
PerforExmoduleRepository perforExmoduleRepository,
PerforCofdrugtypeRepository drugtypeRepository,
PerforPerallotRepository perforPerAllotRepository,
PerforHospitalRepository perforHospitalRepository,
PerforCofworkitemRepository workitemRepository,
PerforPersheetRepository perforPersheetRepository,
PerforImheaderRepository perforImheaderRepository,
PerforImdataRepository imdataRepository,
PerforCofdepttypeRepository perforCofdepttypeRepository,
PerforPerapramountRepository perapramountRepository,
//PerforCofcmiRepository perforCofcmiRepository,
PerforCofHrpDeptRepository perforCofHrpDeptRepository,
PerforCofaliasRepository perforCofaliasRepository,
PerforCofaccountingRepository cofaccountingRepository,
PerforCofdrugtypeDisburseRepository drugtypeDisburseRepository,
PersonService personService,
LogManageService logManageService,
ILogger<ConfigService> logger,
ExConfigService exConfigService,
PerforExmoduleRepository perforExmoduleRepository,
PerforCofdrugtypefactorRepository cofdrugtypefactorRepository,
PerforPerallotRepository perallotRepository,
PerforReportRepository perforReport)
PerforCofdrugtypefactorRepository cofdrugtypefactorRepository)
{
_mapper = mapper;
_userService = userService;
_roleService = roleService;
this._directorRepository = cofdirectorRepository;
//this._drugpropRepository = cofdrugpropRepository;
this._workitemRepository = workitemRepository;
this._againRepository = againRepository;
this._drugtypeRepository = drugtypeRepository;
this.perforPerAllotRepository = perforPerAllotRepository;
this.perforHospitalRepository = perforHospitalRepository;
this.perforPersheetRepository = perforPersheetRepository;
this.perforImheaderRepository = perforImheaderRepository;
this.imdataRepository = imdataRepository;
this.perforCofdepttypeRepository = perforCofdepttypeRepository;
this.perapramountRepository = perapramountRepository;
//this.perforCofcmiRepository = perforCofcmiRepository;
this.perforCofHrpDeptRepository = perforCofHrpDeptRepository;
this.perforCofaliasRepository = perforCofaliasRepository;
this.cofaccountingRepository = cofaccountingRepository;
this.drugtypeDisburseRepository = drugtypeDisburseRepository;
this.personService = personService;
this.logManageService = logManageService;
this.exConfigService = exConfigService;
this.logger = logger;
this.perforExmoduleRepository = perforExmoduleRepository;
this.cofdrugtypefactorRepository = cofdrugtypefactorRepository;
this.perallotRepository = perallotRepository;
this.perforReport = perforReport;
_copyService = copyService;
_personService = personService;
_perforReport = perforReport;
_logManageService = logManageService;
_exConfigService = exConfigService;
_imdataRepository = imdataRepository;
_againRepository = againRepository;
_drugtypeRepository = drugtypeRepository;
_perallotRepository = perallotRepository;
_directorRepository = cofdirectorRepository;
_workitemRepository = workitemRepository;
_perforPerAllotRepository = perforPerAllotRepository;
_perforPersheetRepository = perforPersheetRepository;
_perforImheaderRepository = perforImheaderRepository;
_perforCofdepttypeRepository = perforCofdepttypeRepository;
_perforCofHrpDeptRepository = perforCofHrpDeptRepository;
_perforCofaliasRepository = perforCofaliasRepository;
_cofaccountingRepository = cofaccountingRepository;
_drugtypeDisburseRepository = drugtypeDisburseRepository;
_perforExmoduleRepository = perforExmoduleRepository;
_cofdrugtypefactorRepository = cofdrugtypefactorRepository;
}
#endregion
#region 弃用
//#region cof_director 规模/效率绩效配置
///// <summary>
///// 获取cof_director列表
///// </summary>
///// <returns></returns>
//public List<DirectorResponse> GetDireList(int allotId)
//{
// var list = _directorRepository.GetEntities(t => t.AllotID == allotId);
// return _mapper.Map<List<DirectorResponse>>(list);
//}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DirectorResponse DireInsert(DirectorRequest request)
//{
// var director = _mapper.Map<cof_director>(request);
// if (!_directorRepository.Add(director))
// throw new PerformanceException("保存失败");
// return _mapper.Map<DirectorResponse>(director);
//}
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DirectorResponse DireUpdate(DirectorRequest request)
//{
// var director = _directorRepository.GetEntity(t => t.ID == request.ID);
// if (null == director)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// director.TypeName = request.TypeName;
// director.JobTitle = request.JobTitle;
// director.Value = request.Value;
// if (!_directorRepository.Update(director))
// throw new PerformanceException("保存失败");
// return _mapper.Map<DirectorResponse>(director);
//}
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool DireDelete(DirectorRequest request)
//{
// var director = _directorRepository.GetEntity(t => t.ID == request.ID);
// if (null == director)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// return _directorRepository.Remove(director);
//}
//#endregion
//#region cof_income ICU有效收入配置
///// <summary>
///// 获取cof_income列表
///// </summary>
///// <returns></returns>
//public List<IncomeResponse> GetIncomeList(int allotId)
//{
// var list = _incomeRepository.GetEntities(T => T.AllotID == allotId);
// return _mapper.Map<List<IncomeResponse>>(list);
//}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public IncomeResponse IncomeInsert(IncomeRequest request)
//{
// var income = _mapper.Map<cof_income>(request);
// if (!_incomeRepository.Add(income))
// throw new PerformanceException("保存失败");
// return _mapper.Map<IncomeResponse>(income);
//}
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public IncomeResponse IncomeUpdate(IncomeRequest request)
//{
// var income = _incomeRepository.GetEntity(t => t.ID == request.ID);
// if (null == income)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// income.SheetNameKeyword = request.SheetNameKeyword;
// income.UnitName = request.UnitName;
// income.Value = request.Value;
// if (!_incomeRepository.Update(income))
// throw new PerformanceException("保存失败");
// return _mapper.Map<IncomeResponse>(income);
//}
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool IncomeDelete(IncomeRequest request)
//{
// var income = _incomeRepository.GetEntity(t => t.ID == request.ID);
// if (null == income)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// return _incomeRepository.Remove(income);
//}
//#endregion
//#region cof_workyear 年资系数配置
///// <summary>
///// 获取cof_drugprop列表
///// </summary>
///// <returns></returns>
//public List<WorkyearResponse> GetWorkList(int allotId)
//{
// var list = _workyearRepository.GetEntities(t => t.AllotID == allotId);
// return _mapper.Map<List<WorkyearResponse>>(list);
//}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public WorkyearResponse WorkInsert(WorkyearRequest request)
//{
// var workyear = _mapper.Map<cof_workyear>(request);
// if (!_workyearRepository.Add(workyear))
// throw new PerformanceException("保存失败");
// return _mapper.Map<WorkyearResponse>(workyear);
//}
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public WorkyearResponse WorkUpdate(WorkyearRequest request)
//{
// var workyear = _workyearRepository.GetEntity(t => t.ID == request.ID);
// if (null == workyear)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// workyear.MaxRange = request.MaxRange;
// workyear.MinRange = request.MinRange;
// workyear.Value = request.Value;
// if (!_workyearRepository.Update(workyear))
// throw new PerformanceException("保存失败");
// return _mapper.Map<WorkyearResponse>(workyear);
//}
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool WorkDelete(WorkyearRequest request)
//{
// var workyear = _workyearRepository.GetEntity(t => t.ID == request.ID);
// if (null == workyear)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// return _workyearRepository.Remove(workyear);
//}
//#endregion
#endregion
#region cof_drugprop 药占比系数配置
///// <summary>
///// 获取cof_drugprop列表
///// </summary>
///// <returns></returns>
//public List<DrugpropResponse> GetDrugList(int allotId)
//{
// var list = _drugpropRepository.GetEntities(t => t.AllotID == allotId);
// return _mapper.Map<List<DrugpropResponse>>(list);
//}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DrugpropResponse DrugInsert(DrugpropRequest request)
//{
// var drugprop = _mapper.Map<cof_drugprop>(request);
// if (!_drugpropRepository.Add(drugprop))
// throw new PerformanceException("保存失败");
// return _mapper.Map<DrugpropResponse>(drugprop);
//}
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DrugpropResponse DrugUpdate(DrugpropRequest request)
//{
// var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
// if (null == drugprop)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// drugprop.MaxRange = request.MaxRange;
// drugprop.MinRange = request.MinRange;
// drugprop.Value = request.Value;
// if (!_drugpropRepository.Update(drugprop))
// throw new PerformanceException("保存失败");
// return _mapper.Map<DrugpropResponse>(drugprop);
//}
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool DrugDelete(DrugpropRequest request)
//{
// var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
// if (null == drugprop)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// return _drugpropRepository.Remove(drugprop);
//}
#endregion
#region cof_drugtype 药占比类别配置
/// <summary>
......@@ -400,12 +143,6 @@ public cof_drugtype DrugtypeUpdate(DrugpropRequest request)
if (!_drugtypeRepository.Update(entity))
throw new PerformanceException("保存失败");
//var factors = cofdrugtypefactorRepository.GetEntities(t => t.HospitalId == entity.HospitalId && t.AllotID == entity.AllotID && t.Charge == entity.Charge);
//if (factors != null && factors.Any())
//{
// factors.ForEach(t => t.Charge = request.Charge);
// cofdrugtypefactorRepository.UpdateRange(factors.ToArray());
//}
return entity;
}
......@@ -433,7 +170,7 @@ public bool DrugtypeDelete(DrugpropRequest request)
/// <returns></returns>
public List<cof_drugtype_disburse> GetDrugtypeDisburseList(int HospitalId, int allotId)
{
var list = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId && t.HospitalId == HospitalId);
var list = _drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId && t.HospitalId == HospitalId);
return list;
}
......@@ -451,7 +188,7 @@ public cof_drugtype_disburse DrugtypeDisburseInsert(DrugpropRequest request)
Charge = request.Charge,
ChargeType = request.ChargeType
};
if (!drugtypeDisburseRepository.Add(entity))
if (!_drugtypeDisburseRepository.Add(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -463,14 +200,14 @@ public cof_drugtype_disburse DrugtypeDisburseInsert(DrugpropRequest request)
/// <returns></returns>
public cof_drugtype_disburse DrugtypeDisburseUpdate(DrugpropRequest request)
{
var entity = drugtypeDisburseRepository.GetEntity(t => t.ID == request.ID);
var entity = _drugtypeDisburseRepository.GetEntity(t => t.ID == request.ID);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.ID}");
entity.Charge = request.Charge;
entity.ChargeType = request.ChargeType;
if (!drugtypeDisburseRepository.Update(entity))
if (!_drugtypeDisburseRepository.Update(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -482,22 +219,22 @@ public cof_drugtype_disburse DrugtypeDisburseUpdate(DrugpropRequest request)
/// <returns></returns>
public bool DrugtypeDisburseDelete(DrugpropRequest request)
{
var entity = drugtypeDisburseRepository.GetEntity(t => t.ID == request.ID);
var entity = _drugtypeDisburseRepository.GetEntity(t => t.ID == request.ID);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.ID}");
return drugtypeDisburseRepository.Remove(entity);
return _drugtypeDisburseRepository.Remove(entity);
}
public void SaveDrugtypeDisburse(int allotId)
{
var Disburse = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId);
var Disburse = _drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId);
if (Disburse == null || !Disburse.Any()) return;
var perSheet = perforPersheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Expend);
var perSheet = _perforPersheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Expend);
if (perSheet == null || !perSheet.Any()) return;
var TypeNames = imdataRepository.GetEntities(t => perSheet.Select(c => c.ID).Contains(t.SheetID.Value)).Select(t => t.TypeName).Distinct().ToList();
var TypeNames = _imdataRepository.GetEntities(t => perSheet.Select(c => c.ID).Contains(t.SheetID.Value)).Select(t => t.TypeName).Distinct().ToList();
if (TypeNames == null || !TypeNames.Any()) return;
var except = Disburse.Select(t => t.Charge).Distinct().Intersect(TypeNames);
......@@ -511,7 +248,7 @@ public void SaveDrugtypeDisburse(int allotId)
}
var drugDis = TypeNames?.Select(t => new cof_drugtype_disburse { HospitalId = Disburse.FirstOrDefault().HospitalId, AllotID = allotId, Charge = t, ChargeType = "" });
drugtypeDisburseRepository.AddRange(drugDis.ToArray());
_drugtypeDisburseRepository.AddRange(drugDis.ToArray());
}
#endregion
......@@ -587,7 +324,7 @@ public bool WorkItemkDelete(WorkItemRequest request)
/// <returns></returns>
public List<cof_depttype> GetDepttypeList(int allotId)
{
var list = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId);
var list = _perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId);
return list;
}
......@@ -604,7 +341,7 @@ public cof_depttype DepttypeInsert(DrugpropRequest request)
Charge = request.Charge,
ChargeType = request.ChargeType
};
if (!perforCofdepttypeRepository.Add(entity))
if (!_perforCofdepttypeRepository.Add(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -616,14 +353,14 @@ public cof_depttype DepttypeInsert(DrugpropRequest request)
/// <returns></returns>
public cof_depttype DepttypeUpdate(DrugpropRequest request)
{
var entity = perforCofdepttypeRepository.GetEntity(t => t.ID == request.ID);
var entity = _perforCofdepttypeRepository.GetEntity(t => t.ID == request.ID);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.ID}");
entity.Charge = request.Charge;
entity.ChargeType = request.ChargeType;
if (!perforCofdepttypeRepository.Update(entity))
if (!_perforCofdepttypeRepository.Update(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -635,11 +372,11 @@ public cof_depttype DepttypeUpdate(DrugpropRequest request)
/// <returns></returns>
public bool DepttypeDelete(DrugpropRequest request)
{
var entity = perforCofdepttypeRepository.GetEntity(t => t.ID == request.ID);
var entity = _perforCofdepttypeRepository.GetEntity(t => t.ID == request.ID);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.ID}");
return perforCofdepttypeRepository.Remove(entity);
return _perforCofdepttypeRepository.Remove(entity);
}
#endregion
......@@ -777,7 +514,7 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == request.AllotId;
if (request.AllotId == 0)
{
var allots = perforPerAllotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
var allots = _perforPerAllotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
if (allots == null || !allots.Any())
throw new PerformanceException("请先配置科室信息");
exp = t => allots.Select(a => a.ID).Contains(t.AllotId);
......@@ -786,7 +523,7 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
if (request.Type == (int)AccountTypeEnum.AccountingUnit && !string.IsNullOrEmpty(request.UnitType))
exp = exp.And(t => t.UnitType.Replace("行政后勤", "行政工勤") == request.UnitType.Replace("行政后勤", "行政工勤"));
return cofaccountingRepository.GetEntities(exp)?.OrderBy(t => t.IsVerify).ThenBy(t => ConvertHelper.To<int>(t.Code)).ToList() ?? new List<cof_accounting>();
return _cofaccountingRepository.GetEntities(exp)?.OrderBy(t => t.IsVerify).ThenBy(t => ConvertHelper.To<int>(t.Code)).ToList() ?? new List<cof_accounting>();
}
/// <summary>
......@@ -796,10 +533,10 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
/// <returns></returns>
public cof_accounting AccountingInsert(cof_accounting request)
{
var existed = cofaccountingRepository.GetEntity(w => w.Code == request.Code);
var existed = _cofaccountingRepository.GetEntity(w => w.AllotId == request.AllotId && w.Code == request.Code);
if (existed != null) throw new PerformanceException("核算单元编码重复");
existed = cofaccountingRepository.GetEntity(w => w.AllotId == request.AllotId && w.UnitType == request.UnitType && w.AccountingUnit == request.AccountingUnit);
existed = _cofaccountingRepository.GetEntity(w => w.AllotId == request.AllotId && w.UnitType == request.UnitType && w.AccountingUnit == request.AccountingUnit);
if (existed != null) throw new PerformanceException("核算单元、核算组别已存在");
var entity = new cof_accounting
......@@ -807,9 +544,10 @@ public cof_accounting AccountingInsert(cof_accounting request)
AllotId = request.AllotId,
Code = request.Code,
UnitType = request.UnitType,
AccountingUnit = request.AccountingUnit
AccountingUnit = request.AccountingUnit,
IsVerify = 1,
};
if (!cofaccountingRepository.Add(entity))
if (!_cofaccountingRepository.Add(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -821,16 +559,22 @@ public cof_accounting AccountingInsert(cof_accounting request)
/// <returns></returns>
public cof_accounting AccountingUpdate(cof_accounting request)
{
var entity = cofaccountingRepository.GetEntity(t => t.Id == request.Id);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.Id}");
var entity = _cofaccountingRepository.GetEntity(t => t.Id == request.Id);
if (null == entity) throw new PerformanceException($"无法找到您要修改的数据!");
var existed = _cofaccountingRepository.GetEntity(w => w.Id != request.Id && w.AllotId == request.AllotId && w.Code == request.Code);
if (existed != null) throw new PerformanceException("核算单元编码重复");
existed = _cofaccountingRepository.GetEntity(w => w.Id != request.Id && w.AllotId == request.AllotId && w.UnitType == request.UnitType && w.AccountingUnit == request.AccountingUnit);
if (existed != null) throw new PerformanceException("核算单元、核算组别已存在");
entity.AllotId = request.AllotId;
entity.Code = request.Code;
entity.UnitType = request.UnitType;
entity.AccountingUnit = request.AccountingUnit;
entity.IsVerify = 1;
if (!cofaccountingRepository.Update(entity))
if (!_cofaccountingRepository.Update(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -842,20 +586,20 @@ public cof_accounting AccountingUpdate(cof_accounting request)
/// <returns></returns>
public bool AccountingDelete(int accountingId)
{
var entity = cofaccountingRepository.GetEntity(t => t.Id == accountingId);
var entity = _cofaccountingRepository.GetEntity(t => t.Id == accountingId);
if (null == entity)
throw new PerformanceException($"ID不存在 :{accountingId}");
return cofaccountingRepository.Remove(entity);
return _cofaccountingRepository.Remove(entity);
}
public HandsonTable GetBatchAccountingStructrue(int AllotId)
public HandsonTableBase GetBatchAccountingStructrue(int AllotId)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, Accounting.Select(t => t.Value).ToArray(), Accounting.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1
}).ToList());
Columns = Accounting.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = Accounting.Select(c => c.Value).ToList(),
};
if (result.Columns != null && result.Columns.Any())
{
......@@ -864,7 +608,7 @@ public HandsonTable GetBatchAccountingStructrue(int AllotId)
if (column.Data == "核算组别")
{
column.Type = "autocomplete";
column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description).ToArray();
column.Strict = true;
}
if (column.Data == "核算单元编码")
......@@ -877,28 +621,69 @@ public HandsonTable GetBatchAccountingStructrue(int AllotId)
return result;
}
public bool BatchSaveAccounting(int allotId, SaveCollectData request)
public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request)
{
var dicData = CreateDataRow(0, allotId, request, Accounting);
if (dicData == null || !dicData.Any()) throw new PerformanceException("未提交数据");
var getAccounts = cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? new List<cof_accounting>();
var unitType = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
var getAccounts = _cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? new List<cof_accounting>();
var unitType = EnumHelper.GetItems<UnitType>().Select(w => w.Description).ToArray();
var json = JsonHelper.Serialize(dicData);
var accounts = JsonHelper.Deserialize<List<cof_accounting>>(json);
if (accounts.Any(w => string.IsNullOrEmpty(w.Code))) throw new PerformanceException("核算单元编码有空值");
if (accounts.GroupBy(t => t.Code).Any(w => w.Count() > 1)) throw new PerformanceException("核算单元编码有重复值");
if (accounts.Any(w => string.IsNullOrEmpty(w.AccountingUnit))) throw new PerformanceException("核算单元有空值");
var accounts = JsonHelper.Deserialize<List<cof_accounting>>(json)
.Where(w => !string.IsNullOrEmpty(w.Code) || !string.IsNullOrEmpty(w.UnitType) || !string.IsNullOrEmpty(w.AccountingUnit))
.ToList();
if (accounts.Any(w => string.IsNullOrEmpty(w.UnitType))) throw new PerformanceException("核算单元类型有空值");
var grouped = accounts.GroupBy(t => new { t.AccountingUnit, t.UnitType });
if (grouped.Any(w => w.Count() > 1)) throw new PerformanceException("核算单元、核算单元类型有重复值");
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
for (int i = 0; i < accounts.Count(); i++)
{
if (string.IsNullOrEmpty(accounts[i].Code) || string.IsNullOrEmpty(accounts[i].UnitType) || string.IsNullOrEmpty(accounts[i].AccountingUnit))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "核算单元编码", accounts[i].Code ?? "" },
{ "核算组别", accounts[i].UnitType ?? "" },
{ "核算单元", accounts[i].AccountingUnit ?? "" },
{ "错误原因", "“关键信息缺失”请补全或删除" },
});
}
else if (accounts.Count(w => w.Code == accounts[i].Code) > 1)
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "核算单元编码", accounts[i].Code ?? "" },
{ "核算组别", accounts[i].UnitType ?? "" },
{ "核算单元", accounts[i].AccountingUnit ?? "" },
{ "错误原因", "“核算单元编码”重复值,请修改或删除" },
});
}
else if (accounts.Count(w => w.AccountingUnit == accounts[i].AccountingUnit && w.UnitType == accounts[i].UnitType) > 1)
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "核算单元编码", accounts[i].Code ?? "" },
{ "核算组别", accounts[i].UnitType ?? "" },
{ "核算单元", accounts[i].AccountingUnit ?? "" },
{ "错误原因", "“核算组别/核算单元”重复,请修改或删除" },
});
}
else if (getAccounts.Any(w => w.Code != accounts[i].Code && w.AccountingUnit == accounts[i].AccountingUnit && w.UnitType == accounts[i].UnitType))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "核算单元编码", accounts[i].Code ?? "" },
{ "核算组别", accounts[i].UnitType ?? "" },
{ "核算单元", accounts[i].AccountingUnit ?? "" },
{ "错误原因", "“核算组别/核算单元”重复但“核算单元编码”不同,请修改或删除" },
});
}
}
if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
var delAccounts = new List<cof_accounting>();
......@@ -909,7 +694,7 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
delAccounts.Add(account);
}
if (delAccounts != null && delAccounts.Any())
cofaccountingRepository.RemoveRange(delAccounts.ToArray());
_cofaccountingRepository.RemoveRange(delAccounts.ToArray());
if (accounts != null && accounts.Any())
{
......@@ -918,51 +703,12 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
account.AllotId = allotId;
account.IsVerify = 1;
});
cofaccountingRepository.AddRange(accounts.ToArray());
_cofaccountingRepository.AddRange(accounts.ToArray());
}
return true;
_perforPerAllotRepository.AccoungtingVerify(allotId);
return new ApiResponse(ResponseType.OK);
}
public bool BatchCheckAccounting(int allotId)
{
var accounts = cofaccountingRepository.GetEntities(t => t.AllotId == allotId);
if (accounts == null || !accounts.Any()) return true;
accounts.ForEach(t =>
{
t.IsVerify = 1;
t.VerifyMessage = string.Empty;
});
if (accounts.GroupBy(t => t.Code).Any(w => w.Count() > 1))
{
var items = accounts.GroupBy(t => t.Code).Where(w => w.Count() > 1).SelectMany(w => w.Select(t => t.Id));
foreach (var item in accounts.Where(w => items.Contains(w.Id)))
{
item.IsVerify = 0;
item.VerifyMessage = "核算单元编码重复";
}
}
var grouped = accounts.GroupBy(t => new { t.AccountingUnit, t.UnitType });
if (grouped.Any(w => w.Count() > 1))
{
var items = grouped.Where(w => w.Count() > 1).SelectMany(w => w.Select(t => t.Id));
foreach (var item in accounts.Where(w => items.Contains(w.Id)))
{
var extend = string.IsNullOrEmpty(item.VerifyMessage) ? "" : ";";
item.IsVerify = 0;
item.VerifyMessage += $"{extend}核算单元、核算单元类型重复";
}
}
return cofaccountingRepository.UpdateRange(accounts.ToArray());
}
public static Dictionary<string, string> Accounting { get; } = new Dictionary<string, string>
{
......@@ -982,202 +728,22 @@ public bool BatchCheckAccounting(int allotId)
/// <param name="iD"></param>
public void Copy(per_allot allot)
{
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (list == null || !list.Any(t => t.ID == allot.ID)) return;
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
int allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID) allotId = -1;
CopyCommand(allot, allotId);
var prevAllotId = _perforPerAllotRepository.GetPrevAllot(allot);
CopyCommand(allot, prevAllotId);
}
public void CopyCommand(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
#region 弃用
//var hospital = perforHospitalRepository.GetEntity(t => t.ID == allot.HospitalId);
//logger.LogInformation($"apramount{allotId} {allot.ID}");
//CopyAprData(allotId, allot.ID);
//CopyCMIData(allotId, allot.ID);
//var orgDirector = _directorRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgDirector == null || orgDirector.Count == 0)
//{
// var director = _directorRepository.GetEntities(t => t.AllotID == allotId) ?? _directorRepository.GetEntities(t => t.AllotID == -1);
// var newDirectors = director.Select(t => new cof_director { AllotID = allot.ID, JobTitle = t.JobTitle, TypeName = t.TypeName, Value = t.Value });
// if (hospital != null && hospital?.IsOpenDirector == 2)
// newDirectors = director.Select(t => new cof_director { AllotID = allot.ID, JobTitle = t.JobTitle, TypeName = t.TypeName, Value = 1 });
// _directorRepository.AddRange(newDirectors.ToArray());
//}
//var orgIncome = _incomeRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgIncome == null || orgIncome.Count == 0)
//{
// var income = _incomeRepository.GetEntities(t => t.AllotID == allotId) ?? _incomeRepository.GetEntities(t => t.AllotID == -1);
// var newIncomes = income.Select(t => new cof_income { AllotID = allot.ID, SheetNameKeyword = t.SheetNameKeyword, UnitName = t.UnitName, Value = t.Value });
// if (hospital != null && hospital?.IsOpenIncome == 2)
// newIncomes = income.Select(t => new cof_income { AllotID = allot.ID, SheetNameKeyword = t.SheetNameKeyword, UnitName = t.UnitName, Value = 1 });
// _incomeRepository.AddRange(newIncomes.ToArray());
//}
//var orgWorkyear = _workyearRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgWorkyear == null || orgWorkyear.Count == 0)
//{
// var workyear = _workyearRepository.GetEntities(t => t.AllotID == allotId) ?? _workyearRepository.GetEntities(t => t.AllotID == -1);
// var newWorkyears = workyear.Select(t => new cof_workyear { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
// if (hospital != null && hospital?.IsOpenWorkYear == 2)
// newWorkyears = new List<cof_workyear> { new cof_workyear { AllotID = allot.ID, MaxRange = 1000, MinRange = 0, Value = 1 } };
// _workyearRepository.AddRange(newWorkyears.ToArray());
//}
//logger.LogInformation($"orgDurgprop");
//var orgDurgprop = _drugpropRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgDurgprop == null || orgDurgprop.Count == 0)
//{
// var durgprop = _drugpropRepository.GetEntities(t => t.AllotID == allotId) ?? _drugpropRepository.GetEntities(t => t.AllotID == -1);
// var newDurgprops = durgprop?.Select(t => new cof_drugprop { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
// //if (hospital != null && hospital?.IsOpenDrugprop == 2)
// // newDurgprops = new List<cof_drugprop> { new cof_drugprop { AllotID = allot.ID, MaxRange = 1000, MinRange = 0, Value = 1 } };
// if (durgprop != null && durgprop.Any())
// _drugpropRepository.AddRange(newDurgprops.ToArray());
//}
#endregion
var flag = delHistotyData;
personService.CreateAllotPersons(allot.HospitalId, allot.ID, prevAllotId);
logger.LogInformation($"copy workItems");
var workItems = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && workItems != null && workItems.Any())
flag = _workitemRepository.RemoveRange(workItems.ToArray());
if (flag || workItems == null || !workItems.Any())
{
workItems = _workitemRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItems != null && workItems.Any())
{
var newWorkItems = workItems.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItems.ToArray());
}
}
_personService.CreateAllotPersons(allot.HospitalId, allot.ID, prevAllotId);
_copyService.Copy_WorkItems(allot, prevAllotId, delHistotyData);
_copyService.Copy_DrugTypes(allot, prevAllotId, delHistotyData);
_copyService.Copy_DrugTypeDisburses(allot, prevAllotId, delHistotyData);
_copyService.Copy_DrugTypeFactors(allot, prevAllotId, delHistotyData);
_copyService.Copy_DeptTypes(allot, prevAllotId, delHistotyData);
_copyService.Copy_Agains(allot, prevAllotId, delHistotyData);
_copyService.Copy_Accountings(allot, prevAllotId, delHistotyData);
_copyService.Copy_DeptDic(allot, prevAllotId, delHistotyData);
logger.LogInformation($"copy drugTypes");
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypes != null && drugTypes.Any())
flag = _drugtypeRepository.RemoveRange(drugTypes.ToArray());
if (flag || drugTypes == null || !drugTypes.Any())
{
drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
if (drugTypes != null && drugTypes.Any())
{
var newDrugTypes = drugTypes.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newDrugTypes.ToArray());
}
}
logger.LogInformation($"copy drugTypeDisburses");
var drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypeDisburses != null && drugTypeDisburses.Any())
flag = drugtypeDisburseRepository.RemoveRange(drugTypeDisburses.ToArray());
if (flag || drugTypeDisburses == null || !drugTypeDisburses.Any())
{
drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId)
?? drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeDisburses != null && drugTypeDisburses.Any())
{
var newDrugTypeDisburses = drugTypeDisburses.Select(t => new cof_drugtype_disburse { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
drugtypeDisburseRepository.AddRange(newDrugTypeDisburses.ToArray());
}
}
logger.LogInformation($"copy drugTypeFactors");
var drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypeFactors != null && drugTypeFactors.Any())
flag = cofdrugtypefactorRepository.RemoveRange(drugTypeFactors.ToArray());
if (flag || drugTypeFactors == null || !drugTypeFactors.Any())
{
drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId)
?? cofdrugtypefactorRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeFactors != null && drugTypeFactors.Any())
{
var newDrugtypeFactors = drugTypeFactors.Select(t => new cof_drugtype_factor
{
HospitalId = allot.HospitalId,
AllotID = allot.ID,
ExModuleId = t.ExModuleId,
Charge = t.Charge,
YSZ = t.YSZ,
HLZ = t.HLZ,
YJZ = t.YJZ
});
cofdrugtypefactorRepository.AddRange(newDrugtypeFactors.ToArray());
}
}
logger.LogInformation($"copy deptTypes");
var deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && deptTypes != null && deptTypes.Any())
flag = perforCofdepttypeRepository.RemoveRange(deptTypes.ToArray());
if (flag || deptTypes == null || !deptTypes.Any())
{
deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == prevAllotId) ?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
if (deptTypes != null && deptTypes.Any())
{
var newDeptTypes = deptTypes.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
perforCofdepttypeRepository.AddRange(newDeptTypes.ToArray());
}
}
logger.LogInformation($"copy agains");
var agains = _againRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && agains != null && agains.Any())
flag = _againRepository.RemoveRange(agains.ToArray());
if (flag || agains == null || !agains.Any())
{
agains = _againRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _againRepository.GetEntities(t => t.AllotID == -1);
if (agains != null && agains.Any())
{
var days = DateTime.DaysInMonth(allot.Year, allot.Month);
var newAgains = agains.Select(t => new cof_again
{
AllotID = allot.ID,
Type = t.Type,
Department = t.Department,
TypeName = t.TypeName,
Value = t.TypeName == "满勤天数" ? days : t.Value
});
_againRepository.AddRange(newAgains.ToArray());
}
}
logger.LogInformation($"copy accountings");
var accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allot.ID);
if (delHistotyData && accountings != null && accountings.Any())
flag = cofaccountingRepository.RemoveRange(accountings.ToArray());
if (flag || accountings == null || !accountings.Any())
{
accountings = cofaccountingRepository.GetEntities(t => t.AllotId == prevAllotId) ?? cofaccountingRepository.GetEntities(t => t.AllotId == -1);
if (accountings != null && accountings.Any())
{
var newAccountings = accountings.Select(t => new cof_accounting
{
AllotId = allot.ID,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
Code = t.Code,
IsVerify = t.IsVerify,
VerifyMessage = t.VerifyMessage
});
cofaccountingRepository.AddRange(newAccountings.ToArray());
}
}
}
//todo:新copy
......@@ -1188,154 +754,28 @@ public void CopyCommand(per_allot allot, int prevAllotId, bool delHistotyData =
/// <param name="type"></param>
public void NewCopy(CopyRequest request)
{
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (list == null || !list.Any(t => t.ID == allot.ID)) return;
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
if (request.Type.Length < 1) return;
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
var allot = _perallotRepository.GetEntity(t => t.ID == request.AllotId);
var prevAllotId = _perallotRepository.GetPrevAllot(allot);
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
int allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID) request.AllotId = -1;
if (request.Type.Length < 1)
return;
var pairs = new Dictionary<string, Action<per_allot, int>>
{
{ "personnels", (allot, prevAllotId) => _personService.CreateAllotPersons(allot.HospitalId, allot.ID, prevAllotId) },
{ "workItems", (allot, prevAllotId) => _copyService.Copy_WorkItems(allot, prevAllotId, delHistotyData:true) },
{ "drugTypes", (allot, prevAllotId) =>_copyService.Copy_DrugTypes(allot, prevAllotId, delHistotyData:true) },
{ "drugTypeDisburses", (allot, prevAllotId) =>_copyService.Copy_DrugTypeDisburses(allot, prevAllotId, delHistotyData:true) },
{ "drugTypeFactors", (allot, prevAllotId) =>_copyService.Copy_DrugTypeFactors(allot, prevAllotId, delHistotyData:true) },
{ "deptTypes", (allot, prevAllotId) =>_copyService.Copy_DeptTypes(allot, prevAllotId, delHistotyData:true) },
{ "agains", (allot, prevAllotId) =>_copyService.Copy_Agains(allot, prevAllotId, delHistotyData:true) },
{ "accountings", (allot, prevAllotId) =>_copyService.Copy_Accountings(allot, prevAllotId, delHistotyData:true) },
{ "department", (allot, prevAllotId) =>_copyService.Copy_DeptDic(allot, prevAllotId, delHistotyData:true) },
};
foreach (var item in request.Type)
{
switch (item)
{
case "personnels":
personService.CreateAllotPersons(allot.HospitalId, allot.ID, allotId);
break;
case "workItems":
logger.LogInformation($"copy workItems");
var workItems = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
//先判断是否为空,不为空删除再执行下面的代码
if (workItems != null)
{
_workitemRepository.RemoveRange(workItems.ToArray());
}
workItems = _workitemRepository.GetEntities(t => t.AllotID == allotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItems != null && workItems.Any())
{
var newWorkItems = workItems.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItems.ToArray());
}
break;
case "drugTypes":
logger.LogInformation($"copy drugTypes");
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (drugTypes != null)
{
_drugtypeRepository.RemoveRange(drugTypes.ToArray());
}
var Types = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allotId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
if (drugTypes != null && drugTypes.Any())
{
var newDrugTypes = drugTypes.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newDrugTypes.ToArray());
}
break;
case "drugTypeDisburses":
logger.LogInformation($"copy drugTypeDisburses");
var drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (drugTypeDisburses != null)
{
drugtypeDisburseRepository.RemoveRange(drugTypeDisburses.ToArray());
}
drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId) ?? drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeDisburses != null && drugTypeDisburses.Any())
{
var newDrugTypeDisburses = drugTypeDisburses.Select(t => new cof_drugtype_disburse { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
drugtypeDisburseRepository.AddRange(newDrugTypeDisburses.ToArray());
}
break;
case "drugTypeFactors":
logger.LogInformation($"copy drugTypeFactors");
var drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allot.ID);
if (drugTypeFactors != null)
{
cofdrugtypefactorRepository.RemoveRange(drugTypeFactors.ToArray());
}
drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allotId) ?? cofdrugtypefactorRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeFactors != null && drugTypeFactors.Any())
{
var newDrugtypeFactors = drugTypeFactors.Select(t => new cof_drugtype_factor
{
HospitalId = allot.HospitalId,
AllotID = allot.ID,
ExModuleId = t.ExModuleId,
Charge = t.Charge,
YSZ = t.YSZ,
HLZ = t.HLZ,
YJZ = t.YJZ
});
cofdrugtypefactorRepository.AddRange(newDrugtypeFactors.ToArray());
}
break;
case "deptTypes":
logger.LogInformation($"copy deptTypes");
var deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (deptTypes != null)
{
perforCofdepttypeRepository.RemoveRange(deptTypes.ToArray());
}
deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId) ?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
if (deptTypes != null && deptTypes.Any())
{
var newDeptTypes = deptTypes.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
perforCofdepttypeRepository.AddRange(newDeptTypes.ToArray());
}
break;
case "agains":
logger.LogInformation($"copy agains");
var agains = _againRepository.GetEntities(t => t.AllotID == allot.ID);
if (agains != null)
{
_againRepository.RemoveRange(agains.ToArray());
}
agains = _againRepository.GetEntities(t => t.AllotID == allotId) ?? _againRepository.GetEntities(t => t.AllotID == -1);
if (agains != null && agains.Any())
{
var days = DateTime.DaysInMonth(allot.Year, allot.Month);
var newAgains = agains.Select(t => new cof_again { AllotID = allot.ID, Type = t.Type, Department = t.Department, TypeName = t.TypeName, Value = t.TypeName == "满勤天数" ? days : t.Value });
_againRepository.AddRange(newAgains.ToArray());
}
break;
case "accountings":
logger.LogInformation($"copy accountings");
var accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allot.ID);
if (accountings != null)
{
cofaccountingRepository.RemoveRange(accountings.ToArray());
}
accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? cofaccountingRepository.GetEntities(t => t.AllotId == -1);
if (accountings != null && accountings.Any())
{
var newAccountings = accountings.Select(t => new cof_accounting
{
AllotId = allot.ID,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
Code = t.Code,
IsVerify = t.IsVerify,
VerifyMessage = t.VerifyMessage
});
cofaccountingRepository.AddRange(newAccountings.ToArray());
}
break;
default:
break;
}
pairs[item].Invoke(allot, prevAllotId);
}
//personService.CreateAllotPersons(allot.HospitalId, allot.ID, allotId);
}
#endregion
......@@ -1349,7 +789,7 @@ public void NewCopy(CopyRequest request)
public void Clear(int allotId)
{
_directorRepository.DeleteData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据!", 1, allotId, "ReceiveMessage", true);
_logManageService.WriteMsg("清理无效数据", $"清理无效数据!", 1, allotId, "ReceiveMessage", true);
}
/// <summary>
......@@ -1368,7 +808,7 @@ public void ClearAllotData(int allotId)
public void ClearResData(int allotId)
{
var count = _directorRepository.DeleteResData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true);
_logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true);
}
/// <summary>
......@@ -1378,7 +818,7 @@ public void ClearResData(int allotId)
public void ClearAgain(int againId)
{
var count = _directorRepository.DelAgain(againId);
logManageService.WriteMsg("清理无效数据", $"清除二次绩效中无效数据,受影响行数:{count}", 1, againId, "ReceiveMessage", true);
_logManageService.WriteMsg("清理无效数据", $"清除二次绩效中无效数据,受影响行数:{count}", 1, againId, "ReceiveMessage", true);
}
#endregion
......@@ -1389,10 +829,10 @@ public void ClearAgain(int againId)
/// <returns></returns>
public List<TitleValue> WorkHeader(int allotId)
{
var sheets = perforPersheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetName.Contains("工作量"));
var sheets = _perforPersheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetName.Contains("工作量"));
if (sheets == null)
return new List<TitleValue>();
var header = perforImheaderRepository.GetEntities(t => sheets.Select(s => s.ID).Contains(t.SheetID.Value) && !t.CellValue.Contains("核算单元") && t.CellValue != "科室名称")?.ToList();
var header = _perforImheaderRepository.GetEntities(t => sheets.Select(s => s.ID).Contains(t.SheetID.Value) && !t.CellValue.Contains("核算单元") && t.CellValue != "科室名称")?.ToList();
if (header != null && header.Count > 0)
{
var list = header.Select(t => t.CellValue).Where(t => !string.IsNullOrEmpty(t)).Distinct();
......@@ -1401,50 +841,18 @@ public List<TitleValue> WorkHeader(int allotId)
return null;
}
///// <summary>
///// 人员绩效额外金额
///// </summary>
//private void CopyAprData(int prevAllotId, int allotId)
//{
// if (prevAllotId == 0) return;
// var list = perapramountRepository.GetEntities(t => new List<int> { prevAllotId, allotId }.Contains(t.AllotId));
// if (list == null || !list.Any(t => t.AllotId == prevAllotId)) return;
// if (list.Any(t => t.AllotId == allotId))
// {
// var prevData = list.Where(t => t.AllotId == prevAllotId);
// var existData = list.Where(t => t.AllotId == allotId);
// if (existData != null && existData.Any())
// list = prevData.Where(t => !existData.Select(w => w.PersonnelNumber).Contains(t.PersonnelNumber)).ToList();
// }
// if (list.Any())
// {
// var data = list.Select(t => new per_apr_amount
// {
// Status = 2,
// AllotId = allotId,
// PersonnelNumber = t.PersonnelNumber,
// DoctorName = t.DoctorName,
// PerforType = t.PerforType,
// Amount = t.Amount,
// CreateDate = DateTime.Now
// });
// perapramountRepository.AddRange(data.ToArray());
// }
//}
#region HRP人员科室
public HandsonTable GetHrpDeptHands(int HospitalId, int AllotId)
public HandsonTableBase GetHrpDeptHands(int HospitalId, int AllotId)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, HrpDept.Select(t => t.Value).ToArray(), HrpDept.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1
}).ToList());
Columns = HrpDept.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = HrpDept.Select(c => c.Value).ToList(),
};
var data = perforCofHrpDeptRepository.GetEntities(t => t.HospitalId == HospitalId && t.AllotId == AllotId);
var data = _perforCofHrpDeptRepository.GetEntities(t => t.HospitalId == HospitalId && t.AllotId == AllotId);
if (data == null)
return result;
......@@ -1460,7 +868,7 @@ public HandsonTable GetHrpDeptHands(int HospitalId, int AllotId)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
result.SetRowData(rowDatas);
return result;
}
......@@ -1481,9 +889,9 @@ public void SaveDepttypeHands(int hospitalId, int allotId, SaveCollectData reque
}
}
perforCofHrpDeptRepository.Execute("delete from cof_hrp_department where HospitalId=@hospitalId and allotid = @allotid"
_perforCofHrpDeptRepository.Execute("delete from cof_hrp_department where HospitalId=@hospitalId and allotid = @allotid"
, new { hospitalId, allotId });
perforCofHrpDeptRepository.AddRange(depts.ToArray());
_perforCofHrpDeptRepository.AddRange(depts.ToArray());
}
public static Dictionary<string, string> HrpDept { get; } = new Dictionary<string, string>
......@@ -1496,13 +904,13 @@ public void SaveDepttypeHands(int hospitalId, int allotId, SaveCollectData reque
#region 二次分配别名配置
public HandsonTable GetSecondaryAlias()
public HandsonTableBase GetSecondaryAlias()
{
var result = new HandsonTable((int)SheetType.Unidentifiable, Alias.Select(t => t.Value).ToArray(), Alias.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1
}).ToList());
Columns = Alias.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = Alias.Select(c => c.Value).ToList(),
};
if (result.Columns != null && result.Columns.Any())
{
......@@ -1516,7 +924,7 @@ public HandsonTable GetSecondaryAlias()
}
}
}
var data = perforCofaliasRepository.GetEntities()?.OrderBy(t => t.Route);
var data = _perforCofaliasRepository.GetEntities()?.OrderBy(t => t.Route);
if (data == null) return result;
List<HandsonRowData> rowDatas = new List<HandsonRowData>();
......@@ -1531,7 +939,7 @@ public HandsonTable GetSecondaryAlias()
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
result.SetRowData(rowDatas);
return result;
}
......@@ -1557,8 +965,8 @@ public void SaveSecondaryAlias(SaveCollectData request)
}
}
perforCofaliasRepository.Execute("delete from cof_alias", null);
perforCofaliasRepository.AddRange(aliases.ToArray());
_perforCofaliasRepository.Execute("delete from cof_alias", null);
_perforCofaliasRepository.AddRange(aliases.ToArray());
}
public static Dictionary<string, string> Alias { get; } = new Dictionary<string, string>
......@@ -1607,36 +1015,6 @@ public void SaveSecondaryAlias(SaveCollectData request)
}
///// <summary>
///// CMI值
///// </summary>
///// <param name="prevAllotId"></param>
///// <param name="allotId"></param>
//private void CopyCMIData(int prevAllotId, int allotId)
//{
// if (prevAllotId == 0) return;
// var list = perforCofcmiRepository.GetEntities(t => new List<int> { prevAllotId, allotId }.Contains(t.AllotId));
// if (list == null || !list.Any(t => t.AllotId == prevAllotId)) return;
// if (list.Any(t => t.AllotId == allotId))
// {
// var prevData = list.Where(t => t.AllotId == prevAllotId);
// var existData = list.Where(t => t.AllotId == allotId);
// if (existData != null && existData.Any())
// list = prevData.Where(t => !existData.Select(w => w.UnitType + w.AccountingUnit).Contains(t.UnitType + t.AccountingUnit)).ToList();
// }
// if (list.Any())
// {
// var data = list.Select(t => new cof_cmi
// {
// AllotId = allotId,
// UnitType = t.UnitType,
// AccountingUnit = t.AccountingUnit,
// Value = t.Value,
// });
// perforCofcmiRepository.AddRange(data.ToArray());
// }
//}
#region 费用类型系数
......@@ -1646,12 +1024,12 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request)
#region header
var models = perforExmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
var models = _perforExmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
if (models == null || !models.Any())
{
exConfigService.DefaultModules(request.HospitalId);
_exConfigService.DefaultModules(request.HospitalId);
models = perforExmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
models = _perforExmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
if (models == null || !models.Any()) return sheet;
}
......@@ -1760,16 +1138,20 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request)
return sheet;
}
public HandsonTable GetDrugtypeFactorConfig(int hospitalId, int allotId)
public HandsonTableBase GetDrugtypeFactorConfig(int hospitalId, int allotId)
{
HandsonTable table = new HandsonTable((int)SheetType.Unidentifiable, new string[] { }, new List<collect_permission>());
HandsonTableBase table = new HandsonTableBase()
{
Columns = new List<HandsonColumn>(),
ColHeaders = new List<string>(),
};
var models = perforExmoduleRepository.GetEntities(t => t.HospitalId == hospitalId && t.SheetType == (int)SheetType.Income);
var models = _perforExmoduleRepository.GetEntities(t => t.HospitalId == hospitalId && t.SheetType == (int)SheetType.Income);
if (models == null || !models.Any())
{
//exConfigService.DefaultModules(hospitalId);
models = perforExmoduleRepository.GetEntities(t => t.HospitalId == hospitalId && t.SheetType == (int)SheetType.Income);
models = _perforExmoduleRepository.GetEntities(t => t.HospitalId == hospitalId && t.SheetType == (int)SheetType.Income);
if (models == null || !models.Any()) return table;
}
......@@ -1896,13 +1278,13 @@ public void SaveDrugtypeFactor(DrugtypeFactorRequest request)
}
}
var savedData = cofdrugtypefactorRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.AllotID == request.AllotId);
var savedData = _cofdrugtypefactorRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.AllotID == request.AllotId);
if (savedData != null && savedData.Any())
{
cofdrugtypefactorRepository.RemoveRange(savedData.ToArray());
_cofdrugtypefactorRepository.RemoveRange(savedData.ToArray());
}
if (factors != null && factors.Any())
cofdrugtypefactorRepository.AddRange(factors.ToArray());
_cofdrugtypefactorRepository.AddRange(factors.ToArray());
if (isHasChargeData)
{
......@@ -1921,11 +1303,11 @@ public void SaveDrugtypeFactor(DrugtypeFactorRequest request)
#region 自定义表
public HandsonTable QueryHandsCustom(CustomPagingRequest request)
public HandsonTableBase QueryHandsCustom(CustomPagingRequest request)
{
var custom = perforReport.QueryCustomColumn(request.TableName);
var custom = _perforReport.QueryCustomColumn(request.TableName);
var isExist = perforReport.QueryIsAllotId(request.TableName, "AllotId", "AccountingUnit", "UnitType");
var isExist = _perforReport.QueryIsAllotId(request.TableName, "AllotId", "AccountingUnit", "UnitType");
if (custom == null || isExist == false)
return null;
......@@ -1938,9 +1320,13 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
if (dicCustom.GroupBy(x => x.Comment).Where(x => x.Count() > 1).Any())
throw new PerformanceException("表列头名称重复, 请补全注释或修改重复注释!");
var result = new HandsonTable((int)SheetType.Unidentifiable, new string[] { }, new List<collect_permission>());
HandsonTableBase result = new HandsonTableBase()
{
Columns = new List<HandsonColumn>(),
ColHeaders = new List<string>(),
};
var jsonData = JsonHelper.Serialize(perforReport.QueryCustom(request, true).DataList);
var jsonData = JsonHelper.Serialize(_perforReport.QueryCustom(request, true).DataList);
var data = JsonHelper.Deserialize<List<Dictionary<string, string>>>(jsonData);
var headDic = new List<Dictionary<string, object>>();
......@@ -1958,7 +1344,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
var Columns = dicCustom.Select(t => new HandsonColumn(t.Comment, false, DataFormat.普通格式)).ToList();
//表类型
var columnType = perforReport.QueryType(request.TableName);
var columnType = _perforReport.QueryType(request.TableName);
if (Columns != null && Columns.Any())
{
......@@ -1967,7 +1353,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
if (dicCustom.FirstOrDefault(t => t.Comment.Equals(column.Data)).Name.ToLower() == "unittype")
{
column.Type = "autocomplete";
column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description).ToArray();
column.Strict = true;
}
......@@ -2002,9 +1388,9 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
public ApiResponse SaveCustomTable(SaveCustomData request)
{
if (!request.Data.Any())
perforReport.CreatCustom(request.AllotId, request.TableName, null);
_perforReport.CreatCustom(request.AllotId, request.TableName, null);
var custom = perforReport.QueryCustomColumn(request.TableName);
var custom = _perforReport.QueryCustomColumn(request.TableName);
if (custom.Count > 50)
return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据!");
......@@ -2019,7 +1405,7 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
var dicData = CreateCustomRow(request.AllotId, request, dicCustom);
//字段类型
var typeColumn = perforReport.QueryType(request.TableName);
var typeColumn = _perforReport.QueryType(request.TableName);
var datas = new List<dynamic>();
foreach (var item in dicData)
......@@ -2054,7 +1440,7 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
datas.Add(item);
}
if (datas.Any())
perforReport.CreatCustom(request.AllotId, request.TableName, datas);
_perforReport.CreatCustom(request.AllotId, request.TableName, datas);
return new ApiResponse(ResponseType.OK);
......@@ -2062,8 +1448,8 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
public ApiResponse QueryCustom(int userId, CustomPagingRequest request)
{
var heads = perforReport.QueryCustomColumn(request.TableName);
var isExist = perforReport.QueryIsAllotId(request.TableName, "AllotId", "AccountingUnit", "UnitType");
var heads = _perforReport.QueryCustomColumn(request.TableName);
var isExist = _perforReport.QueryIsAllotId(request.TableName, "AllotId", "AccountingUnit", "UnitType");
if (isExist == false || heads == null)
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
if (heads.Count > 50)
......@@ -2078,13 +1464,8 @@ public ApiResponse QueryCustom(int userId, CustomPagingRequest request)
if (customGroup.Any())
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
Dictionary<int, string[]> dic = new Dictionary<int, string[]>
{
{ (int)Role.科主任, new[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ (int)Role.护士长, new[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString()} },
{ (int)Role.特殊科室, new[]{ UnitType.特殊核算组.ToString() }},
{ (int)Role.行政科室, new[]{ UnitType.行政后勤.ToString() } },
};
var user = _userService.GetUser(userId);
var roleType = _roleService.GetUserRole(userId)?.FirstOrDefault()?.Type ?? 0;
......@@ -2092,11 +1473,11 @@ public ApiResponse QueryCustom(int userId, CustomPagingRequest request)
{
Heads = headList.ToList()
};
if (dic.Keys.Contains(roleType))
result.Datas = perforReport.QueryCustom(request.TableName, request.AllotId, user?.Department ?? "", dic[roleType], request.PageIndex, request.PageSize);
var unitTypes = UnitTypeUtil.GetMaps(roleType);
if (unitTypes.Any())
result.Datas = _perforReport.QueryCustom(request.TableName, request.AllotId, user?.Department ?? "", unitTypes, request.PageIndex, request.PageSize);
else
result.Datas = perforReport.QueryCustom(request, false);
result.Datas = _perforReport.QueryCustom(request, false);
return new ApiResponse(ResponseType.OK, result);
}
......
using Microsoft.Extensions.Logging;
using Performance.EntityModels;
using Performance.Repository;
using Performance.Repository.Repository;
using System;
using System.Linq;
namespace Performance.Services
{
public class CopyService : IAutoInjection
{
private readonly ILogger<ConfigService> _logger;
private readonly PerforPerdeptdicRepository _perdeptdicRepository;
private readonly PerforCofworkitemRepository _workitemRepository;
private readonly PerforCofagainRepository _againRepository;
private readonly PerforCofdrugtypeRepository _drugtypeRepository;
private readonly PerforCofdepttypeRepository _perforCofdepttypeRepository;
private readonly PerforCofaccountingRepository _cofaccountingRepository;
private readonly PerforCofdrugtypeDisburseRepository _drugtypeDisburseRepository;
private readonly PerforCofdrugtypefactorRepository _cofdrugtypefactorRepository;
public CopyService(
ILogger<ConfigService> logger,
PerforPerdeptdicRepository perdeptdicRepository,
PerforCofagainRepository againRepository,
PerforCofdrugtypeRepository drugtypeRepository,
PerforCofworkitemRepository workitemRepository,
PerforCofdepttypeRepository perforCofdepttypeRepository,
PerforCofaccountingRepository cofaccountingRepository,
PerforCofdrugtypeDisburseRepository drugtypeDisburseRepository,
PerforCofdrugtypefactorRepository cofdrugtypefactorRepository)
{
_logger = logger;
_perdeptdicRepository = perdeptdicRepository;
_workitemRepository = workitemRepository;
_againRepository = againRepository;
_drugtypeRepository = drugtypeRepository;
_perforCofdepttypeRepository = perforCofdepttypeRepository;
_cofaccountingRepository = cofaccountingRepository;
_drugtypeDisburseRepository = drugtypeDisburseRepository;
_cofdrugtypefactorRepository = cofdrugtypefactorRepository;
}
public void Copy_WorkItems(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy workItems");
var workItems = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && workItems != null && workItems.Any())
flag = _workitemRepository.RemoveRange(workItems.ToArray());
if (flag || workItems == null || !workItems.Any())
{
workItems = _workitemRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItems != null && workItems.Any())
{
var newWorkItems = workItems.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItems.ToArray());
}
}
}
public void Copy_DrugTypes(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy drugTypes");
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypes != null && drugTypes.Any())
flag = _drugtypeRepository.RemoveRange(drugTypes.ToArray());
if (flag || drugTypes == null || !drugTypes.Any())
{
drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
if (drugTypes != null && drugTypes.Any())
{
var newDrugTypes = drugTypes.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newDrugTypes.ToArray());
}
}
}
public void Copy_DrugTypeDisburses(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy drugTypeDisburses");
var drugTypeDisburses = _drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypeDisburses != null && drugTypeDisburses.Any())
flag = _drugtypeDisburseRepository.RemoveRange(drugTypeDisburses.ToArray());
if (flag || drugTypeDisburses == null || !drugTypeDisburses.Any())
{
drugTypeDisburses = _drugtypeDisburseRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId)
?? _drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeDisburses != null && drugTypeDisburses.Any())
{
var newDrugTypeDisburses = drugTypeDisburses.Select(t => new cof_drugtype_disburse { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeDisburseRepository.AddRange(newDrugTypeDisburses.ToArray());
}
}
}
public void Copy_DrugTypeFactors(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy drugTypeFactors");
var drugTypeFactors = _cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypeFactors != null && drugTypeFactors.Any())
flag = _cofdrugtypefactorRepository.RemoveRange(drugTypeFactors.ToArray());
if (flag || drugTypeFactors == null || !drugTypeFactors.Any())
{
drugTypeFactors = _cofdrugtypefactorRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId)
?? _cofdrugtypefactorRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeFactors != null && drugTypeFactors.Any())
{
var newDrugtypeFactors = drugTypeFactors.Select(t => new cof_drugtype_factor
{
HospitalId = allot.HospitalId,
AllotID = allot.ID,
ExModuleId = t.ExModuleId,
Charge = t.Charge,
YSZ = t.YSZ,
HLZ = t.HLZ,
YJZ = t.YJZ
});
_cofdrugtypefactorRepository.AddRange(newDrugtypeFactors.ToArray());
}
}
}
public void Copy_DeptTypes(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy deptTypes");
var deptTypes = _perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && deptTypes != null && deptTypes.Any())
flag = _perforCofdepttypeRepository.RemoveRange(deptTypes.ToArray());
if (flag || deptTypes == null || !deptTypes.Any())
{
deptTypes = _perforCofdepttypeRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
if (deptTypes != null && deptTypes.Any())
{
var newDeptTypes = deptTypes.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_perforCofdepttypeRepository.AddRange(newDeptTypes.ToArray());
}
}
}
public void Copy_Agains(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy agains");
var agains = _againRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && agains != null && agains.Any())
flag = _againRepository.RemoveRange(agains.ToArray());
if (flag || agains == null || !agains.Any())
{
agains = _againRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _againRepository.GetEntities(t => t.AllotID == -1);
if (agains != null && agains.Any())
{
var days = DateTime.DaysInMonth(allot.Year, allot.Month);
var newAgains = agains.Select(t => new cof_again
{
AllotID = allot.ID,
Type = t.Type,
Department = t.Department,
TypeName = t.TypeName,
Value = t.TypeName == "满勤天数" ? days : t.Value
});
_againRepository.AddRange(newAgains.ToArray());
}
}
}
public void Copy_Accountings(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy accountings");
var accountings = _cofaccountingRepository.GetEntities(t => t.AllotId == allot.ID);
if (delHistotyData && accountings != null && accountings.Any())
flag = _cofaccountingRepository.RemoveRange(accountings.ToArray());
if (flag || accountings == null || !accountings.Any())
{
accountings = _cofaccountingRepository.GetEntities(t => t.AllotId == prevAllotId) ?? _cofaccountingRepository.GetEntities(t => t.AllotId == -1);
if (accountings != null && accountings.Any())
{
var newAccountings = accountings.Select(t => new cof_accounting
{
AllotId = allot.ID,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
Code = t.Code,
IsVerify = t.IsVerify,
VerifyMessage = t.VerifyMessage
});
_cofaccountingRepository.AddRange(newAccountings.ToArray());
}
}
}
public void Copy_DeptDic(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy per_dept_dic");
var deptDic = _perdeptdicRepository.GetEntities(t => t.AllotId == allot.ID);
if (delHistotyData && deptDic != null && deptDic.Any())
flag = _perdeptdicRepository.RemoveRange(deptDic.ToArray());
if (flag || deptDic == null || !deptDic.Any())
{
deptDic = _perdeptdicRepository.GetEntities(t => t.AllotId == prevAllotId) ?? _perdeptdicRepository.GetEntities(t => t.AllotId == -1);
if (deptDic != null && deptDic.Any())
{
var newDeptDic = deptDic.Select(t => new per_dept_dic
{
AllotId = allot.ID,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
CreateTime = t.CreateTime,
CreateUser = t.CreateUser,
Department = t.Department,
HISDeptName = t.HISDeptName,
HospitalId = t.HospitalId,
Source = t.Source,
IsVerify = t.IsVerify,
VerifyMessage = t.VerifyMessage
});
_perdeptdicRepository.AddRange(newDeptDic.ToArray());
}
}
}
}
}
......@@ -77,12 +77,12 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro
var account = GetAccounting(allotId, roleType, Department);
Expression<Func<cost_transfer, bool>> exp = t => t.AllotId == allotId;
if (roleType == application.DirectorRole)
if (roleType == (int)Role.科主任)
if (menuType == 1)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.ApplicantUnitType));
else
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.AdoptedUnitType));
else if (roleType == application.NurseRole)
else if (roleType == (int)Role.护士长)
if (menuType == 1)
exp = exp.And(t => t.ApplicantUnitType == UnitType.护理组.ToString());
else
......@@ -148,15 +148,11 @@ public List<CostTransferResponse> GetAuditList(int allotId, int menuType, int ro
public cof_accounting GetAccounting(int allotId, int roleType, string Department = null)
{
var unitTpes = UnitTypeUtil.GetMaps(roleType);
Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == allotId && t.AccountingUnit == Department;
if (roleType == application.DirectorRole)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType));
else if (roleType == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
else if (roleType == application.SpecialRole)
exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString());
else if (roleType == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
if (UnitTypeUtil.Maps.ContainsKey(roleType))
exp = exp.And(t => unitTpes.Contains(t.UnitType));
var account = cofaccountingRepository.GetEntity(exp);
......
......@@ -23,6 +23,7 @@ public class CustomExtractService : IAutoInjection
private readonly IOptions<Application> _options;
private readonly UserService _userService;
private readonly RoleService _roleService;
private readonly PerforUserRepository _userRepository;
private readonly PerforPerallotRepository _perallotRepository;
private readonly PerforPerdeptdicRepository _perforPerdeptdicRepository;
private readonly PerforHospitalconfigRepository _perforHospitalconfigRepository;
......@@ -34,6 +35,7 @@ public class CustomExtractService : IAutoInjection
IOptions<Application> options,
UserService userService,
RoleService roleService,
PerforUserRepository userRepository,
PerforPerallotRepository perallotRepository,
PerforPerdeptdicRepository perforPerdeptdicRepository,
PerforHospitalconfigRepository perforHospitalconfigRepository,
......@@ -44,6 +46,7 @@ public class CustomExtractService : IAutoInjection
_options = options;
_userService = userService;
_roleService = roleService;
_userRepository = userRepository;
_perallotRepository = perallotRepository;
_perforPerdeptdicRepository = perforPerdeptdicRepository;
_perforHospitalconfigRepository = perforHospitalconfigRepository;
......@@ -57,8 +60,8 @@ public bool CheckConfigScript(int userId, int allotId)
?? throw new PerformanceException("绩效ID无效");
var scripts = _perforcustscriptRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.IsEnable == 1);
scripts = (IsSecondAdmin(userId, out string[] unitType))
var center = _userRepository.GetUser(userId);
scripts = UnitTypeUtil.Maps.ContainsKey(center?.URole.Type ?? 0)
? scripts?.Where(w => w.IsSecondAllot == 1).ToList()
: scripts?.Where(w => w.IsOnceAllot == 1).ToList();
......@@ -74,9 +77,11 @@ public bool ExtractData(int userId, int allotId, out string resultFilePath)
var filePath = ExtractHelper.GetExtractFile(allot.HospitalId);
resultFilePath = filePath;
var center = _userRepository.GetUser(userId);
var scripts = _perforcustscriptRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.IsEnable == 1);
scripts = (IsSecondAdmin(userId, out string[] unitType))
scripts = UnitTypeUtil.Maps.ContainsKey(center?.URole.Type ?? 0)
? scripts?.Where(w => w.IsSecondAllot == 1).ToList()
: scripts?.Where(w => w.IsOnceAllot == 1).ToList();
......@@ -85,7 +90,7 @@ public bool ExtractData(int userId, int allotId, out string resultFilePath)
result = false;
return result;
}
var depts = _perforPerdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId);
var depts = _perforPerdeptdicRepository.GetEntities(w => w.AllotId == allot.ID);
IWorkbook workbook = null;
try
......@@ -132,7 +137,12 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
?? throw new PerformanceException("当前医院没有数据库地址配置");
var parameters = GetParameters(allot);
var (isSecondAdmin, department, unitType) = GetUserDepartment(userId);
var center = _userRepository.GetUser(userId);
var isSecondAdmin = center.IsSecondAdmin;
var department = isSecondAdmin ? (center?.User.Department ?? "") : string.Empty;
var unitType = UnitTypeUtil.GetMaps(center?.URole.Type ?? 0);
parameters.Add("@department", $"'{department}'");
if (unitType != null && unitType.Any())
parameters.Add("@unittype", $"{string.Join(", ", unitType.Select(t => $"'{t}'"))}");
......@@ -196,7 +206,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
if (atUnitTypeList.Any() && !string.IsNullOrEmpty(atDepartment))
{
var tempDepts = depts.Where(w => atUnitTypeList.Contains(w.UnitType) && w.HISDeptName == atDepartment);
if (isSecondAdmin && unitType.Any(w => w == UnitType.特殊核算组.ToString() || w == UnitType.行政后勤.ToString()))
if (isSecondAdmin && unitType.Any(w => w == UnitType.特殊核算组.ToString() || UnitTypeUtil.Office.Contains(w)))
{
accountUnit = tempDepts.FirstOrDefault()?.AccountingUnit ?? "";
}
......@@ -292,44 +302,5 @@ public IEnumerable<dynamic> QueryData(sys_hospitalconfig config, string execsql,
};
return pairs;
}
/// <summary>
/// 是否是二次分配管理员 是 true 否 false
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
private bool IsSecondAdmin(int userId, out string[] unitType)
{
Dictionary<int, string[]> pairs = new Dictionary<int, string[]>
{
{ _options.Value.NurseRole, new string[] { UnitType.护理组.ToString() } },
{ _options.Value.DirectorRole, new string[] { UnitType.医生组.ToString(), UnitType.医技组.ToString() } },
{ _options.Value.SpecialRole, new string[] { UnitType.特殊核算组.ToString() } },
{ _options.Value.OfficeRole, new string[] { UnitType.行政后勤.ToString() } },
};
var roleId = _roleService.GetRole(userId)?.FirstOrDefault().ID ?? 0;
if (pairs.ContainsKey(roleId))
{
unitType = pairs[roleId];
return true;
}
unitType = new string[] { };
return false;
}
/// <summary>
/// 返回二次分配管理科室 默认 返回 空值
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
private (bool isSecondAdmin, string department, string[] unitType) GetUserDepartment(int userId)
{
var user = _userService.GetUser(userId)
?? throw new PerformanceException("当前用户信息无效");
var isSecondAdmin = IsSecondAdmin(userId, out string[] unitType);
var department = isSecondAdmin ? (user.Department ?? "") : string.Empty;
return (isSecondAdmin, department, unitType);
}
}
}
......@@ -1303,14 +1303,13 @@ public List<GatherDropResponse> GetGatherDrop(int allotId)
}
public HandsonTable GetGatherHands(int AllotId, GatherRequest request)
public HandsonTableBase GetGatherHands(int AllotId, GatherRequest request)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, Gather.Select(t => t.Value).ToArray(), Gather.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1
}).ToList());
Columns = Gather.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = Gather.Select(t => t.Value).ToList(),
};
if (result.Columns != null && result.Columns.Any())
{
......@@ -1346,7 +1345,7 @@ public HandsonTable GetGatherHands(int AllotId, GatherRequest request)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
result.SetRowData(rowDatas);
return result;
}
......@@ -1546,7 +1545,7 @@ public void CheckGatherData(int allotId, SaveGatherData saveGather)
var data = saveGather.Data;
var departments = perdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId);
var departments = perdeptdicRepository.GetEntities(w => w.AllotId == allot.ID);
if (departments == null || !departments.Any()) throw new PerformanceException("未配置科室字典");
var notExistsDeptData = data.Where(w => !departments.Select(t => t.HISDeptName).Contains(w[0]));
......
......@@ -741,7 +741,7 @@ public string Judge(int allotId, int hospitalId, int useTemplate, ref bool isSin
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
var drugTypes = cofdrugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
var deptDic = perdeptdicRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
var deptDic = perdeptdicRepository.GetEntities(t => t.AllotId == allot.ID);
var moduleSheet = exmoduleRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.SheetType == (int)SheetType.Income);
if (moduleSheet == null || !moduleSheet.Any()) return null;
......@@ -786,6 +786,7 @@ public string Judge(int allotId, int hospitalId, int useTemplate, ref bool isSin
UnitType = defauleUnittype,
Source = source,
HospitalId = allot.HospitalId,
AllotId = allot.ID,
IsVerify = 0,
VerifyMessage = "抽取前科室校验后补增科室",
CreateUser = 1
......
......@@ -291,7 +291,7 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, int allotId, List<
var types = extypeRepository.GetEntities(w => w.HospitalId == hospitalId) ?? new List<ex_type>();
var dict = personService.GetDepartments(hospitalId)?.ToList();
var dict = personService.GetDepartments(allotId)?.ToList();
if (dict == null || !dict.Any())
{
return results.GroupBy(t => new { t.Department, t.Category, t.Source }).Select(t => new ExtractTransDto
......
......@@ -52,7 +52,7 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, ExcelStyle style,
if (departments == null || !departments.Any()) return;
var standardDict = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId && departments.Contains(t.Department)) ?? new List<per_dept_dic>();
var standardDict = perdeptdicRepository.GetEntities(t => t.AllotId == allotId && departments.Contains(t.Department)) ?? new List<per_dept_dic>();
WriteSheetDataNonexistent(sheet, cellStyle, point, columns, departments, standardDict, costTransfers, costTransferItems);
}
......
......@@ -145,7 +145,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
IEnumerable<cof_workitem> workitems, IEnumerable<CofDrugProp> medicineProps, IEnumerable<CofDrugProp> cmis, IEnumerable<CofDrugProp> inclines, bool isDoctor = false)
{
var unittype = isDoctor
? new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString(), UnitType.专家组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.特殊核算组.ToString() }
? new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.特殊核算组.ToString() }
: new List<string> { UnitType.护理组.ToString(), UnitType.其他护理组.ToString() };
if ((medicineProps == null && cmis == null && inclines == null) || workitems == null)
......
......@@ -36,18 +36,6 @@ public class PersonService : IAutoInjection
private readonly Application application;
private readonly IWebHostEnvironment evn;
private readonly Dictionary<string, (string, string)> dict = new Dictionary<string, (string, string)>
{
{ nameof(DeptdicResponse.OutDoctorAccounting), (UnitType.医生组.ToString(), "门诊") },
{ nameof(DeptdicResponse.OutNurseAccounting), (UnitType.护理组.ToString(), "门诊") },
{ nameof(DeptdicResponse.OutTechnicAccounting), (UnitType.医技组.ToString(), "门诊") },
{ nameof(DeptdicResponse.InpatDoctorAccounting), (UnitType.医生组.ToString(), "住院") },
{ nameof(DeptdicResponse.InpatNurseAccounting), (UnitType.护理组.ToString(), "住院") },
{ nameof(DeptdicResponse.InpatTechnicAccounting), (UnitType.医技组.ToString(), "住院") },
{ nameof(DeptdicResponse.LogisticsAccounting), (UnitType.行政后勤.ToString(), null) },
{ nameof(DeptdicResponse.SpecialAccounting), (UnitType.特殊核算组.ToString(), null) },
};
public PersonService(
IMapper mapper,
ILogger<PersonService> logger,
......@@ -188,12 +176,15 @@ public List<per_employee> GetPerEmployee(int allotId)
/// <returns></returns>
public List<per_employee> GetPersons(int allotId, int userId)
{
var (dept, unittype) = GetDeptByUser(userId);
var userInfo = perforUserRepository.GetUser(userId);
var dept = userInfo?.User.Department ?? "";
var unittype = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
? UnitTypeUtil.GetMaps(userInfo.URole.Type.Value)
: new string[0];
Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId;
if (!string.IsNullOrEmpty(dept) && unittype.Any())
{
exp = exp.And(t => t.AccountingUnit == dept && unittype.Contains(t.UnitType));
}
var list = peremployeeRepository.GetEntities(exp);
if (list != null && list.Any())
......@@ -209,17 +200,18 @@ public List<per_employee> GetPersons(int allotId, int userId)
/// <returns></returns>
public PageList<per_employee> GetPersons(int allotId, int userId, PersonParamsRequest request)
{
var (dept, unittype) = GetDeptByUser(userId);
var userInfo = perforUserRepository.GetUser(userId);
var dept = userInfo?.User.Department ?? "";
var unittype = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
? UnitTypeUtil.GetMaps(userInfo.URole.Type.Value)
: new string[0];
Expression<Func<per_employee, bool>> exp = t => t.AllotId == allotId;
if (!string.IsNullOrEmpty(dept) && unittype.Any())
{
exp = exp.And(t => t.AccountingUnit == dept && unittype.Contains(t.UnitType));
}
if (request != null && !string.IsNullOrEmpty(request.SearchQuery))
{
exp = exp.And(t => true && (t.AccountingUnit.Contains(request.SearchQuery) || t.PersonnelNumber.Contains(request.SearchQuery) || t.DoctorName.Contains(request.SearchQuery) || t.Department.Contains(request.SearchQuery)));
}
var result = new List<per_employee>();
......@@ -277,11 +269,13 @@ public ApiResponse CreatePerson(PerEmployeeResponse request)
int day = DateTime.DaysInMonth(allot.Year, allot.Month);
entity.Attendance = request.AttendanceDay / day;
entity.CreateTime = DateTime.Now;
entity.IsVerify = 0;
entity.IsVerify = 1;
//CheckAccountingDept(request.HospitalId.Value, request.AccountingUnit, request.Department);
peremployeeRepository.Add(entity);
if (!peremployeeRepository.Add(entity))
throw new PerformanceException($"添加失败");
perallotRepository.AccoungtingVerify(entity.AllotId ?? 0);
return new ApiResponse(ResponseType.OK, "添加成功", entity);
}
......@@ -394,51 +388,56 @@ public bool DeleteAllPerson(int allotId)
return peremployeeRepository.RemoveRange(employees.ToArray());
}
/// <summary>
/// 检查核算单元是否已存在
/// </summary>
/// <param name="hosapitalId">医院Id</param>
/// <param name="accountingUnit">核算单元</param>
/// <param name="department">科室</param>
private void CheckAccountingDept(int hosapitalId, string accountingUnit, string department)
{
var accountDept = perdeptdicRepository.GetEntity(t => t.HospitalId == hosapitalId && t.AccountingUnit == accountingUnit && t.Department == department);
if (accountDept == null)
{
var entity = new per_dept_dic
{
AccountingUnit = accountingUnit,
Department = department,
HospitalId = hosapitalId,
Source = "人事科增加人员记录时补充"
};
perdeptdicRepository.Add(entity);
}
}
///// <summary>
///// 检查核算单元是否已存在
///// </summary>
///// <param name="hosapitalId">医院Id</param>
///// <param name="accountingUnit">核算单元</param>
///// <param name="department">科室</param>
//private void CheckAccountingDept(int hosapitalId, string accountingUnit, string department)
//{
// var accountDept = perdeptdicRepository.GetEntity(t => t.HospitalId == hosapitalId && t.AccountingUnit == accountingUnit && t.Department == department);
// if (accountDept == null)
// {
// var entity = new per_dept_dic
// {
// AccountingUnit = accountingUnit,
// Department = department,
// HospitalId = hosapitalId,
// Source = "人事科增加人员记录时补充"
// };
// perdeptdicRepository.Add(entity);
// }
//}
/// <summary>
/// 获取给医院所有的
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="allotId"></param>
/// <returns></returns>
public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId)
public IEnumerable<DeptdicResponse> GetDepartments(int allotId)
{
var depts = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var depts = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
if (depts == null || !depts.Any()) return null;
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null || !depts.Any()) return null;
Func<per_dept_dic, Deptdic> getDeptdic = (dic) => new Deptdic { Id = dic?.Id ?? 0, IsVerify = dic?.IsVerify ?? 1, AccountingUnit = dic?.AccountingUnit, VerifyMessage = dic?.VerifyMessage, };
var result = depts.GroupBy(t => new { t.HISDeptName, t.Department }).Select(t => new DeptdicResponse
{
HospitalId = hospitalId,
AllotId = allotId,
HospitalId = allot.HospitalId,
HISDeptName = t.Key.HISDeptName,
Department = t.Key.Department,
OutDoctorAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医生组.ToString() && group.Source == "门诊")),
OutNurseAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.护理组.ToString() && group.Source == "门诊")),
OutTechnicAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医技组.ToString() && group.Source == "门诊")),
InpatDoctorAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医生组.ToString() && group.Source == "住院")),
InpatNurseAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.护理组.ToString() && group.Source == "住院")),
InpatTechnicAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医技组.ToString() && group.Source == "住院")),
LogisticsAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.行政后勤.ToString())),
SpecialAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.特殊核算组.ToString())),
OutDoctorAccounting = getDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医生组.ToString() && group.Source == "门诊")),
OutNurseAccounting = getDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.护理组.ToString() && group.Source == "门诊")),
OutTechnicAccounting = getDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医技组.ToString() && group.Source == "门诊")),
InpatDoctorAccounting = getDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医生组.ToString() && group.Source == "住院")),
InpatNurseAccounting = getDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.护理组.ToString() && group.Source == "住院")),
InpatTechnicAccounting = getDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医技组.ToString() && group.Source == "住院")),
LogisticsAccounting = getDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && UnitTypeUtil.Office.Contains(group.UnitType))),
SpecialAccounting = getDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.特殊核算组.ToString())),
CreateTime = t.Max(group => group.CreateTime),
IsVerify = t.Min(w => w.IsVerify) ?? 1,
});
......@@ -446,44 +445,23 @@ public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId)
return result.OrderBy(w => w.IsVerify).ThenByDescending(t => t.CreateTime).ThenBy(t => t.Department);
}
private (string dept, string[] unittype) GetDeptByUser(int userId)
{
var user = perforUserRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (user == null) throw new PerformanceException("用户信息错误");
var userrole = perforUserroleRepository.GetEntity(t => t.UserID == user.ID);
var role = perforRoleRepository.GetEntity(t => t.ID == userrole.RoleID);
//private (string dept, string[] unittype) GetDeptByUser(int userId)
//{
// var user = perforUserRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
// if (user == null) throw new PerformanceException("用户信息错误");
if (role == null) return ("", new string[] { });
Dictionary<int, string[]> dict = new Dictionary<int, string[]>
{
{ application.DirectorRole, new string[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ application.NurseRole, new string[]{ UnitType.护理组.ToString() } },
{ application.SpecialRole, new string[]{ UnitType.特殊核算组.ToString() } },
{ application.OfficeRole, new string[]{ UnitType.行政后勤.ToString(), "行政工勤" } },
};
if (dict.Keys.Contains(role.Type.Value))
{
return (user.Department, dict[role.Type.Value]);
}
// var userrole = perforUserroleRepository.GetEntity(t => t.UserID == user.ID);
// var role = perforRoleRepository.GetEntity(t => t.ID == userrole.RoleID);
return ("", new string[] { });
}
// if (role == null) return ("", new string[] { });
private Deptdic GetDeptdic(per_dept_dic dic)
{
if (dic == null) return new Deptdic() { IsVerify = 1 };
// if (UnitTypeUtil.Maps.ContainsKey(role.Type.Value))
// {
// return (user.Department, UnitTypeUtil.Maps[role.Type.Value]);
// }
return new Deptdic
{
Id = dic.Id,
AccountingUnit = dic.AccountingUnit,
IsVerify = dic.IsVerify ?? 1,
VerifyMessage = dic.VerifyMessage,
};
}
// return ("", new string[] { });
//}
/// <summary>
/// 创建科室核算信息
......@@ -492,8 +470,13 @@ private Deptdic GetDeptdic(per_dept_dic dic)
/// <returns></returns>
public per_dept_dic CreateDeptDic(per_dept_dic request)
{
var deptdic = perdeptdicRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.AccountingUnit == request.AccountingUnit
&& t.Department == request.Department && t.HISDeptName == request.HISDeptName && t.Source == request.Source && t.UnitType == request.UnitType);
var deptdic = perdeptdicRepository.GetEntity(t =>
t.AllotId == request.AllotId
&& t.AccountingUnit == request.AccountingUnit
&& t.Department == request.Department
&& t.HISDeptName == request.HISDeptName
&& t.Source == request.Source
&& t.UnitType == request.UnitType);
if (deptdic != null)
throw new PerformanceException($"{request.Department}数据重复!");
......@@ -504,22 +487,27 @@ public per_dept_dic CreateDeptDic(per_dept_dic request)
return request;
}
/// <summary>
/// 更新科室核算信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool UpdateDeptDic(per_dept_dic request)
{
var deptdic = perdeptdicRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.AccountingUnit == request.AccountingUnit
&& t.Department == request.Department && t.Source == request.Source && t.UnitType == request.UnitType);
if (deptdic != null && deptdic.Id != request.Id)
throw new PerformanceException($"{request.Department}数据重复!");
_mapper.Map(request, deptdic, typeof(per_dept_dic), typeof(per_dept_dic));
return perdeptdicRepository.Add(deptdic);
}
///// <summary>
///// 更新科室核算信息
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool UpdateDeptDic(per_dept_dic request)
//{
// var deptdic = perdeptdicRepository.GetEntity(t =>
// t.HospitalId == request.HospitalId
// && t.AllotId == request.AllotId
// && t.AccountingUnit == request.AccountingUnit
// && t.Department == request.Department
// && t.Source == request.Source
// && t.UnitType == request.UnitType);
// if (deptdic != null && deptdic.Id != request.Id)
// throw new PerformanceException($"{request.Department}数据重复!");
// _mapper.Map(request, deptdic, typeof(per_dept_dic), typeof(per_dept_dic));
// return perdeptdicRepository.Add(deptdic);
//}
/// <summary>
/// 更新科室核算信息
......@@ -530,6 +518,17 @@ public bool UpdateDeptDic(DeptdicResponse request)
{
try
{
Dictionary<string, (string, string)> dict = new Dictionary<string, (string, string)>
{
{ nameof(DeptdicResponse.OutDoctorAccounting), (UnitType.医生组.ToString(), "门诊") },
{ nameof(DeptdicResponse.OutNurseAccounting), (UnitType.护理组.ToString(), "门诊") },
{ nameof(DeptdicResponse.OutTechnicAccounting), (UnitType.医技组.ToString(), "门诊") },
{ nameof(DeptdicResponse.InpatDoctorAccounting), (UnitType.医生组.ToString(), "住院") },
{ nameof(DeptdicResponse.InpatNurseAccounting), (UnitType.护理组.ToString(), "住院") },
{ nameof(DeptdicResponse.InpatTechnicAccounting), (UnitType.医技组.ToString(), "住院") },
{ nameof(DeptdicResponse.LogisticsAccounting), (UnitType.行政工勤.ToString(), null) },
{ nameof(DeptdicResponse.SpecialAccounting), (UnitType.特殊核算组.ToString(), null) },
};
foreach (var item in dict)
{
var property = typeof(DeptdicResponse).GetProperty(item.Key);
......@@ -555,6 +554,7 @@ public bool UpdateDeptDic(DeptdicResponse request)
{
var entity = new per_dept_dic
{
AllotId = request.AllotId,
HospitalId = request.HospitalId,
HISDeptName = request.HISDeptName,
Department = request.Department,
......@@ -587,7 +587,7 @@ public bool DeleteDeptDic(DeptdicResponse request)
if (request == null)
throw new PerformanceException("科室记录不存在!");
var deptdics = perdeptdicRepository.GetEntities(t => t.HISDeptName == request.HISDeptName && t.Department == request.Department && t.HospitalId == request.HospitalId);
var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == request.AllotId && t.HISDeptName == request.HISDeptName && t.Department == request.Department);
if (deptdics == null || !deptdics.Any())
throw new PerformanceException("科室记录不存在!");
......@@ -597,12 +597,12 @@ public bool DeleteDeptDic(DeptdicResponse request)
/// <summary>
/// 系统/标准科室字典
/// </summary>
/// <param name="hospitalId">医院Id</param>
/// <param name="allotId">allotId</param>
/// <param name="type">1系统科室 2标准科室 3核算单元</param>
/// <returns></returns>
public List<TitleValue> DeptDics(int hospitalId, int type)
public List<TitleValue> DeptDics(int allotId, int type)
{
var deptdics = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
if (deptdics == null || !deptdics.Any()) return new List<TitleValue>();
var result = new List<string>();
......@@ -616,11 +616,11 @@ public List<TitleValue> DeptDics(int hospitalId, int type)
}
else if (type == 3)
{
result = deptdics.Where(t => !new string[] { UnitType.行政后勤.ToString(), UnitType.特殊核算组.ToString() }.Contains(t.UnitType)).Select(t => t.AccountingUnit).Distinct().ToList();
result = deptdics.Where(t => UnitTypeUtil.Office.Contains(t.UnitType) || UnitType.特殊核算组.ToString() == t.UnitType).Select(t => t.AccountingUnit).Distinct().ToList();
}
else if (type == 4)
{
result = deptdics.Where(t => t.UnitType == UnitType.行政后勤.ToString()).Select(t => t.AccountingUnit).Distinct().ToList();
result = deptdics.Where(t => UnitTypeUtil.Office.Contains(t.UnitType)).Select(t => t.AccountingUnit).Distinct().ToList();
}
else if (type == 5)
{
......@@ -636,14 +636,28 @@ public List<TitleValue> DeptDics(int hospitalId, int type)
/// <returns></returns>
public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
{
string[] unitTypes = GetUnitType(userId);
if (unitTypes == null || !unitTypes.Any()) return new string[] { };
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null)
return null;
var userInfo = perforUserRepository.GetUser(userId);
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院");
// 查询当前角色下科室的绩效
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes);
if (unitTypes == null || !unitTypes.Any()) return Enumerable.Empty<DeptIncomeResponse>();
var accountingUnit = request.AccountingUnit;
var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin)
{
var second = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department)?.FirstOrDefault();
if (second != null)
{
accountingUnit = second.Department ?? request.AccountingUnit;
unitTypes = new string[] { second.UnitType };
}
}
var data = perallotRepository.QueryWorkloadData(request.AllotId, request.AccountingUnit, unitTypes, allot.HospitalId);
var data = perallotRepository.QueryWorkloadData(request.AllotId, accountingUnit, unitTypes, hospitalId);
if (data != null && data.Any())
{
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
......@@ -665,19 +679,35 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public object DeptIncomeDetail(WorkDetailRequest request, int userId)
public IEnumerable<DeptIncomeResponse> DeptIncomeDetail(WorkDetailRequest request, int userId)
{
string[] unitTypes = GetUnitType(userId);
if (unitTypes == null || !unitTypes.Any()) return new string[] { };
var userInfo = perforUserRepository.GetUser(userId);
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院");
// 查询当前角色下科室的绩效
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes);
if (unitTypes == null || !unitTypes.Any()) return Enumerable.Empty<DeptIncomeResponse>();
var accountingUnit = request.AccountingUnit;
var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin)
{
var second = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department)?.FirstOrDefault();
if (second != null)
{
accountingUnit = second.Department ?? request.AccountingUnit;
unitTypes = new string[] { second.UnitType };
}
}
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null)
return null;
var sources = new[] { "门诊", "住院" };
if (!sources.Contains(request.Source))
throw new PerformanceException($"数据来源错误,只支持:{string.Join(";", sources)}");
var data = perallotRepository.QueryIncomeData(request.AllotId, request.Source, request.AccountingUnit, unitTypes, allot.HospitalId);
var data = perallotRepository.QueryIncomeData(request.AllotId, request.Source, accountingUnit, unitTypes, hospitalId);
if (data != null && data.Any())
{
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
......@@ -691,39 +721,20 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
}).OrderBy(t => t.PersonnelNumber).ThenBy(t => t.Category);
}
return new string[] { };
return Enumerable.Empty<DeptIncomeResponse>();
}
private string[] GetUnitType(int userId)
public HandsonTableBase GetBatchPersonStructrue(int allotId)
{
Dictionary<int, string[]> dict = new Dictionary<int, string[]>
HandsonTableBase result = new HandsonTableBase()
{
{ 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() } },
Columns = Person.Select(t => new HandsonColumn(t.Item2)).ToList(),
ColHeaders = Person.Select(t => t.Item2).ToList(),
};
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)
{
var cols = Person.Select(t => t.Item2).ToArray();
var permissions = Person.Select(t => new collect_permission { HeadName = t.Item2, Visible = 1 }).ToList();
var result = new HandsonTable((int)SheetType.Unidentifiable, cols, permissions);
var deptdics = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var ss = deptdics?.Where(t => !new string[] { UnitType.专家组.ToString() }.Contains(t.UnitType));
var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
var ss = deptdics?.Where(t => !new string[] { "专家组" }.Contains(t.UnitType));
if (result.Columns != null && result.Columns.Any())
{
var columns = new[] { "核算单元", "科室名称", "姓名", "员工工号", "银行卡号" };
......@@ -735,7 +746,7 @@ public HandsonTable GetBatchPersonStructrue(int hospitalId)
if (column.Data == "核算组别")
{
column.Type = "autocomplete";
column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description).ToArray();
column.Strict = true;
}
else if (new[] { "出勤天数", "预留比例" }.Contains(column.Data))
......@@ -748,14 +759,13 @@ public HandsonTable GetBatchPersonStructrue(int hospitalId)
return result;
}
public HandsonTable GetDepartmentHands(int hospitalId)
public HandsonTableBase GetDepartmentHands(int allotId)
{
HandsonTable handson = new HandsonTable((int)SheetType.Unidentifiable, DeptDic.Select(c => c.Value).ToArray(), DeptDic.Select(t => new collect_permission
HandsonTableBase handson = new HandsonTableBase
{
HeadName = t.Value,
Visible = 1,
Readnoly = 0
}).ToList());
Columns = DeptDic.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = DeptDic.Select(c => c.Value).ToList(),
};
#region 科室下拉
//if (handson.Columns != null && handson.Columns.Any())
//{
......@@ -797,7 +807,7 @@ public HandsonTable GetDepartmentHands(int hospitalId)
return handson;
}
public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData request)
public ApiResponse BathSavePerson(int allotId, int HospitalId, SaveCollectData request)
{
var dict = new Dictionary<string, string>();
Person.ForEach(t => dict.Add(t.Item1, t.Item2));
......@@ -808,16 +818,12 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r
var jsons = JsonHelper.Serialize(dicData);
var newEmployees = JsonHelper.Deserialize<List<per_employee>>(jsons);
var oldEmployees = peremployeeRepository.GetEntities(t => t.HospitalId == HospitalId && t.AllotId == AllotId);
var oldEmployees = peremployeeRepository.GetEntities(t => t.HospitalId == HospitalId && t.AllotId == allotId);
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
for (int i = 0; i < newEmployees.Count; i++)
{
if (newEmployees[i].PersonnelNumber?.Trim() == "2095")
{
}
if (string.IsNullOrEmpty(newEmployees[i].UnitType?.Trim())
|| string.IsNullOrEmpty(newEmployees[i].Department?.Trim())
|| string.IsNullOrEmpty(newEmployees[i].AccountingUnit?.Trim())
......@@ -833,7 +839,18 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r
{ "错误原因", "“关键信息缺失”请补全或删除" },
});
}
newEmployees[i].UnitType = newEmployees[i].UnitType?.Replace("行政后勤", "行政工勤");
if (!Enum.IsDefined(typeof(UnitType), newEmployees[i].UnitType?.Trim()))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "人员工号", newEmployees[i].PersonnelNumber??"" },
{ "姓名", newEmployees[i].DoctorName??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "“核算组别”错误,请修改或删除" },
});
}
if (newEmployees.Count(w => w.PersonnelNumber == newEmployees[i].PersonnelNumber) > 1)
{
error.Add(new Dictionary<string, string>
......@@ -891,12 +908,13 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r
if (oldEmployees != null && oldEmployees.Any(t => t.PersonnelNumber?.Trim() == data.PersonnelNumber?.Trim()))
delPersonsNum.Add(data.PersonnelNumber);
data.UnitType = data.UnitType.Replace("行政后勤", "行政工勤");
data.HospitalId = HospitalId;
data.AllotId = AllotId;
data.AllotId = allotId;
data.DoctorName = data.DoctorName?.Trim();
data.PersonnelNumber = data.PersonnelNumber?.Trim();
data.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd"));
data.IsVerify = 0;
data.IsVerify = 1;
employees.Add(data);
}
}
......@@ -907,13 +925,18 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r
if (employees != null && employees.Any())
peremployeeRepository.AddRange(employees.ToArray());
perallotRepository.AccoungtingVerify(allotId);
return new ApiResponse(ResponseType.OK, "");
}
public void SaveDeptDicHands(int HospitalId, SaveCollectData request)
public void SaveDeptDicHands(int allotId, SaveCollectData request)
{
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) throw new PerformanceException("绩效记录不存在");
var dicData = CreateDataRow(request, DeptDic);
var deptDic = perdeptdicRepository.GetEntities(t => t.HospitalId == HospitalId);
var deptDic = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
var depts = deptDic?.Select(w => new { w.Department, w.HISDeptName }).Distinct();
List<per_dept_dic> deptDics = new List<per_dept_dic>();
var delDepartment = new List<string>();
......@@ -928,7 +951,7 @@ public void SaveDeptDicHands(int HospitalId, SaveCollectData request)
if (!string.IsNullOrEmpty(data.HISDeptName?.Trim()) && !any)
{
DeptDicList(HospitalId, deptDics, data);
DeptDicList(allot.HospitalId, allotId, deptDics, data);
}
}
......@@ -939,97 +962,48 @@ public void SaveDeptDicHands(int HospitalId, SaveCollectData request)
perdeptdicRepository.AddRange(deptDics.ToArray());
}
private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHands data)
private void DeptDicList(int hospitalId, int allotId, List<per_dept_dic> deptDics, DeptdicHands data)
{
var nowTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
#region 住院
if (!string.IsNullOrEmpty(data.InpatDoctorAccounting) || !string.IsNullOrEmpty(data.InpatNurseAccounting) || !string.IsNullOrEmpty(data.InpatTechnicAccounting))
Func<string, string, string, per_dept_dic> getDeptDic = (source, unittype, accountingUnit) =>
{
if (!string.IsNullOrEmpty(data.InpatDoctorAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatDoctorAccounting?.Trim();
deptDic.UnitType = "医生组";
deptDics.Add(deptDic);
}
if (!string.IsNullOrEmpty(data.InpatNurseAccounting))
return new per_dept_dic()
{
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatNurseAccounting?.Trim();
deptDic.UnitType = "护理组";
deptDics.Add(deptDic);
}
if (!string.IsNullOrEmpty(data.InpatTechnicAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatTechnicAccounting?.Trim();
deptDic.UnitType = "医技组";
deptDics.Add(deptDic);
}
}
Source = source,
HospitalId = hospitalId,
AllotId = allotId,
Department = data.Department?.Trim(),
HISDeptName = data.HISDeptName?.Trim(),
CreateTime = nowTime,
AccountingUnit = accountingUnit,
UnitType = unittype,
};
};
#endregion
if (!string.IsNullOrEmpty(data.InpatDoctorAccounting))
deptDics.Add(getDeptDic("住院", "医生组", data.InpatDoctorAccounting?.Trim()));
#region 门诊
if (!string.IsNullOrEmpty(data.InpatNurseAccounting))
deptDics.Add(getDeptDic("住院", "护理组", data.InpatNurseAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.OutDoctorAccounting) || !string.IsNullOrEmpty(data.OutNurseAccounting) || !string.IsNullOrEmpty(data.OutTechnicAccounting))
{
if (!string.IsNullOrEmpty(data.InpatTechnicAccounting))
deptDics.Add(getDeptDic("住院", "医技组", data.InpatTechnicAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.OutDoctorAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutDoctorAccounting?.Trim();
deptDic.UnitType = "医生组";
deptDics.Add(deptDic);
}
if (!string.IsNullOrEmpty(data.OutNurseAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutNurseAccounting?.Trim();
deptDic.UnitType = "护理组";
deptDics.Add(deptDic);
}
if (!string.IsNullOrEmpty(data.OutTechnicAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutTechnicAccounting?.Trim();
deptDic.UnitType = "医技组";
deptDics.Add(deptDic);
}
}
if (!string.IsNullOrEmpty(data.OutDoctorAccounting))
deptDics.Add(getDeptDic("门诊", "医生组", data.OutDoctorAccounting?.Trim()));
#endregion
if (!string.IsNullOrEmpty(data.OutNurseAccounting))
deptDics.Add(getDeptDic("门诊", "护理组", data.OutNurseAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.OutTechnicAccounting))
deptDics.Add(getDeptDic("门诊", "医技组", data.OutTechnicAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.LogisticsAccounting))
{
per_dept_dic deptDic = new per_dept_dic()
{
HospitalId = HospitalId,
Department = data.Department?.Trim(),
HISDeptName = data.HISDeptName?.Trim(),
CreateTime = nowTime,
AccountingUnit = data.LogisticsAccounting?.Trim(),
UnitType = "行政后勤"
};
deptDics.Add(deptDic);
}
deptDics.Add(getDeptDic("", "行政后勤", data.LogisticsAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.SpecialAccounting))
{
per_dept_dic deptDic = new per_dept_dic()
{
HospitalId = HospitalId,
Department = data.Department?.Trim(),
HISDeptName = data.HISDeptName?.Trim(),
CreateTime = nowTime,
AccountingUnit = data.LogisticsAccounting?.Trim(),
UnitType = "特殊核算组"
};
deptDics.Add(deptDic);
}
deptDics.Add(getDeptDic("", "特殊核算组", data.LogisticsAccounting?.Trim()));
}
private List<Dictionary<string, string>> CreateDataRow(SaveCollectData request, Dictionary<string, string> config)
......
......@@ -65,7 +65,8 @@ public List<SelectionOptions> GetReportSelection(int groupId, int userId, int ho
if (selections == null)
return options;
var isMedical = IsMedical(userId);
var userInfo = userRepository.GetUser(userId);
var isMedical = (userInfo != null && userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value));
var dispaly = new int[] { (int)SelectionState.UsableAndNotDispaly, (int)SelectionState.NotUsableAndNotDispaly };
foreach (var item in selections.Where(t => t.State.HasValue && !dispaly.Contains(t.State.Value)))
......@@ -136,8 +137,9 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
var selections = selectionRepository.GetEntities(w => arr2.Contains(w.ID) && w.State.HasValue && dispaly.Contains(w.State.Value))
?? new List<rep_selection>();
var isMedical = IsMedical(userId);
var department = GetUserDepartment(userId);
var userInfo = userRepository.GetUser(userId);
var isMedical = userInfo.IsSecondAdmin;
var department = userInfo?.User.Department ?? "";
List<ReportData> result = new List<ReportData>();
foreach (var report in reports)
......@@ -357,23 +359,6 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection
}
return content;
}
private bool IsMedical(int userId)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
var roleTypes = new[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
if (role.Type.HasValue && roleTypes.Contains(role.Type.Value))
return true;
else
return false;
}
private string GetUserDepartment(int userId)
{
var user = userRepository.GetEntity(t => t.ID == userId);
return user.Department;
}
}
......
......@@ -331,7 +331,7 @@ private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId
logger.LogInformation($"人均绩效计算");
Dictionary<string, string> basicDict = new Dictionary<string, string>
{
{ "行政工勤人均绩效", UnitType.行政.ToString() },
{ "行政工勤人均绩效", UnitType.行政.ToString() },
{ "临床医生人均绩效", UnitType.医生组.ToString() },
{ "医技医生人均绩效", UnitType.医技组.ToString() },
{ "护士人均绩效", UnitType.护理组.ToString() },
......@@ -634,7 +634,7 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId,
var hos = _hospitalRepository.GetEntity(t => t.ID == hospitalId);
var employees = perforPeremployeeRepository.GetEntities(t => t.AllotId == allotId);
if (employees == null || !employees.Any()) throw new PerformanceException("人员字典中未保存数据");
var alias = _computeService.CustomColumnHeaders(hos, "/result/all_employee");
var dicData = CreateDataRow(hospitalId, request, alias);
var tags = reportperformancepersontagsRepository.GetEntities(t => t.HospitalId == hospitalId);
......@@ -757,13 +757,13 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId,
return new ApiResponse(ResponseType.OK);
}
public HandsonTable GetReportTag(int hospitalId)
public HandsonTableBase GetReportTag(int hospitalId)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, ReportTag.Select(t => t.Value).ToArray(), ReportTag.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1
}).ToList());
Columns = ReportTag.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = ReportTag.Select(t => t.Value).ToList(),
};
var data = reportperformancetagsRepository.GetEntities(t => t.HospitalId == hospitalId)?.OrderBy(t => t.UnitType);
if (data == null) return result;
......@@ -780,7 +780,7 @@ public HandsonTable GetReportTag(int hospitalId)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
result.SetRowData(rowDatas);
return result;
}
......
......@@ -654,7 +654,7 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
#region 其他模板详情
public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, int employeeSource, out decimal? realAmount)
public HandsonTableBase GetOtherTempData(int userId, int secondId, int isArchive, int employeeSource, out decimal? realAmount)
{
string[] workNumbers = new string[] { };
var details = GetOtherTempDetails(userId, secondId, isArchive, employeeSource);
......@@ -666,12 +666,11 @@ public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, in
OtherTemp.Select(t => t.Value).ToArray() :
new string[] { "可分配绩效", "科室单项奖励", "医院其他绩效", "预留年度考核比例", "年度考核发放金额", "预发绩效工资金额" };
var result = new HandsonTable((int)SheetType.Unidentifiable, OtherTemp.Select(t => t.Value).ToArray(), OtherTemp.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1,
Readnoly = readColumns.Contains(t.Value) ? 1 : 0
}).ToList());
Columns = OtherTemp.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = OtherTemp.Select(t => t.Value).ToList(),
};
if (result.Columns != null && result.Columns.Any())
{
......@@ -707,7 +706,7 @@ public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, in
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
result.SetRowData(rowDatas);
return result;
}
......@@ -739,7 +738,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
var role = _userService.GetUserFirstRole(userId);
//行政科室 只有两种逻辑,或从保存中加载,或加载EXCEL表
if (role?.Type == _application.OfficeRole)
if (role?.Type == (int)Role.行政科室)
{
// 如果已经保存>>走保存加载逻辑
if (employeeSource == (int)EmployeeSource.Initial)
......@@ -825,7 +824,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
var empl = employees?.FirstOrDefault(w => w.PersonnelNumber?.Trim() == item.WorkNumber?.Trim());
item.ReservedRatio = empl?.ReservedRatio ?? 0;
// 如果是行政后勤,则把绩效放在工作量上
if (isTitlePerformance && second.UnitType == UnitType.行政后勤.ToString())
if (isTitlePerformance && UnitTypeUtil.IsOffice(second.UnitType))
{
item.WorkPerformance = distPerformance?.Where(w => w.AccountingUnit == item.Department && w.JobNumber?.Trim() == item.WorkNumber?.Trim())?.Sum(w => w.GiveFee);
if (string.IsNullOrEmpty(item.WorkNumber))
......@@ -835,7 +834,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
if (second.UnitType.Replace("其他", "").Replace("医技", "医生")
== (empl?.UnitType ?? "").Replace("其他", "").Replace("医技", "医生"))
{
if (second.UnitType == UnitType.行政后勤.ToString())
if (UnitTypeUtil.IsOffice(second.UnitType))
{
if (string.IsNullOrEmpty(item.WorkNumber))
{
......
......@@ -120,6 +120,22 @@ ComputeService computeService
}
#region 二次绩效列表与数据保存
//public List<ag_secondallot> GetSeconds(int userId)
//{
// var userInfo = userRepository.GetUser(userId);
// if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
// if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
// if (userInfo?.Hospitals == null) throw new NotImplementedException("当前用户暂未分配医院");
// // 查询当前角色下科室的绩效
// UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitType);
// var secondList = agsecondallotRepository.Get(userInfo.HospitalIds.ToArray(), unitType, userInfo.User.Department);
//}
/// <summary>
/// 获取二次绩效列表
......@@ -128,32 +144,32 @@ ComputeService computeService
/// <returns></returns>
public List<SecondListResponse> GetSecondList(int userId)
{
var user = userRepository.GetEntity(t => t.ID == userId);
if (user == null)
throw new NotImplementedException("人员ID无效");
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
var userhospital = userhospitalRepository.GetEntity(t => t.UserID == userId);
if (userhospital == null)
throw new NotImplementedException("人员未选择医院");
var allotList = perallotRepository.GetEntities(t => t.HospitalId == userhospital.HospitalID && new List<int> { 6, 8, 10 }.Contains(t.States));
if (allotList == null || allotList.Count == 0)
return new List<SecondListResponse>();
var userInfo = userRepository.GetUser(userId);
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (userInfo?.Hospitals == null) throw new NotImplementedException("当前用户暂未分配医院");
var status = new List<int> { (int)AllotStates.绩效下发, (int)AllotStates.归档, (int)AllotStates.绩效结果解析成功 };
var allotList = perallotRepository.GetEntities(t => userInfo.HospitalIds.Contains(t.HospitalId) && status.Contains(t.States));
if (allotList == null || allotList.Count == 0) return new List<SecondListResponse>();
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));
else if (role.Type == application.NurseRole)
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());
else if (role.Type == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var secondList = agsecondallotRepository.GetEntities(exp);
// 查询当前角色下科室的绩效
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitType);
var secondList = agsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && unitType.Contains(t.UnitType) && t.Department == userInfo.User.Department);
// 查询过往科室的绩效
var histroys = agsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && unitType.Contains(t.NewUnitType) && t.NewAccountingUnit == userInfo.User.Department);
if (histroys != null && histroys.Any())
secondList.AddRange(histroys.ToArray());
var list = _mapper.Map<List<SecondListResponse>>(secondList);
var hospital = hospitalRepository.GetEntity(t => t.ID == userhospital.HospitalID);
// 二次分配只支持单医院
var hospital = userInfo.Hospitals.First();
list?.ForEach(t =>
{
var allot = allotList.FirstOrDefault(a => a.ID == t.AllotId);
......@@ -169,17 +185,17 @@ public List<SecondListResponse> GetSecondList(int userId)
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())
{
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 二次绩效详情
......@@ -862,20 +878,12 @@ public List<SecondTempResponse> GetTemp(int hospitalid, string department, int u
var temps = agtempRepository.GetEntities(t => t.IsEnable == 1);
if (temps != null && temps.Any())
{
var userrole = userroleRepository.GetEntity(t => t.UserID == 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() } },
};
var userCenter = userRepository.GetUser(userId);
var unitType = UnitTypeUtil.GetMaps(userCenter?.URole.Type ?? 0);
Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == hospitalid && t.Department == department;
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 => unitType.Contains(t.UnitType));
var useTemp = agusetempRepository.GetEntity(exp);
var secondTemps = _mapper.Map<List<SecondTempResponse>>(temps);
......@@ -1510,10 +1518,10 @@ public List<ag_secondallot> AuditList(int allotId)
if (allot == null)
throw new PerformanceException("所选绩效不存在!");
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政 };
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政 };
var accountUnit = resaccountRepository.GetEntities(t => t.AllotID == allot.ID && !types.Contains(t.UnitType.Value));
// 查询需要进行二次分配的行政后勤科室
var xzAccountUnit = resaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是");
var xzAccountUnit = resaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是");
if (xzAccountUnit != null && xzAccountUnit.Count > 0)
(accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
......@@ -1586,20 +1594,11 @@ public bool AuditSubmit(ag_secondallot second, int userId)
if (allot == null)
throw new PerformanceException("二次绩效无效!");
var userrole = userroleRepository.GetEntity(t => t.UserID == 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() } },
};
var userCenter = userRepository.GetUser(userId);
var unitType = UnitTypeUtil.GetMaps(userCenter?.URole.Type ?? 0);
Expression<Func<ag_usetemp, bool>> exp = t => t.HospitalId == allot.HospitalId && t.Department == second.Department;
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 => unitType.Contains(t.UnitType));
var temp = agusetempRepository.GetEntity(exp);
if (temp == null)
......@@ -2081,7 +2080,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
var distPerformance = rescomputeRepository.GetEntities(t => t.AllotID == second.AllotId && employees.Select(s => s.PersonnelNumber).Contains(t.JobNumber));
Func<per_employee, decimal?> getDistPerformance = (t) => 0;
if (second.UnitType == UnitType.行政后勤.ToString())
if (UnitTypeUtil.IsOffice(second.UnitType))
getDistPerformance = (t) => second.Department == t.AccountingUnit ? distPerformance
?.Where(w => w.JobNumber?.Trim() == t.PersonnelNumber?.Trim())
?.Sum(w => w.GiveFee) : 0;
......@@ -2424,32 +2423,42 @@ public dynamic Print(int secondId)
public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out int isShowManage)
{
var user = userRepository.GetEntity(t => t.ID == userId);
if (user == null)
throw new NotImplementedException("人员ID无效");
var userInfo = userRepository.GetUser(userId);
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院");
var deptDatas = new List<DeptDataDetails>();
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
isShowManage = computeService.IsShowManage(allotId);
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
// 未下发或未归档 则不可见
var status = new int[] { (int)AllotStates.绩效下发, (int)AllotStates.归档 };
if (!status.Contains(allot.States)) return deptDatas;
// 查询当前角色下科室的绩效
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes);
if (unitTypes == null || !unitTypes.Any()) return deptDatas;
var accountingUnit = userInfo.User.Department;
var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin)
{
var secondList = agsecondallotRepository.Get(allotId, unitTypes, userInfo.User.Department);
accountingUnit = secondList.FirstOrDefault()?.Department;
unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType };
}
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>>
{
{ application.DirectorRole, new List<string>{ AccountUnitType.科主任.ToString()} },
{ application.NurseRole, new List<string>{ AccountUnitType.护士长.ToString() } },
{ application.OfficeRole, new List<string> { AccountUnitType.行政中层.ToString() } },
{ application.SpecialRole, new List<string> { AccountUnitType.科主任.ToString() , AccountUnitType.护士长.ToString() } },
{ (int)Role.科主任, new List<string>{ AccountUnitType.科主任.ToString()} },
{ (int)Role.护士长, new List<string>{ AccountUnitType.护士长.ToString() } },
{ (int)Role.行政科室, new List<string> { AccountUnitType.行政中层.ToString() } },
{ (int)Role.特殊科室, new List<string> { AccountUnitType.科主任.ToString() , AccountUnitType.护士长.ToString() } },
};
if (!dict.Keys.Contains(role.Type.Value)) 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 == accountingUnit && unitTypes.Contains(t.UnitType));
if (computes == null || !computes.Any()) return new List<DeptDataDetails>();
foreach (var item in computes)
{
......
......@@ -9,6 +9,23 @@ namespace Performance.Services
public class UnitTypeUtil
{
public static string[] Office = new string[] { "行政后勤", "行政工勤" };
/// <summary>
/// 数据收集角色(可查看所有)
/// </summary>
public static int[] CollectRoles { get; } = new int[] { (int)Role.绩效管理员, (int)Role.医院管理员, (int)Role.绩效核算办, (int)Role.院领导, (int)Role.财务科, (int)Role.人事科 };
/// <summary>
/// 二次分配角色映射表
/// </summary>
public static Dictionary<int, string[]> Maps { get; } = new Dictionary<int, string[]>
{
{ (int)Role.科主任, new string[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ (int)Role.护士长, new string[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString() } },
{ (int)Role.特殊科室, new string[]{ UnitType.特殊核算组.ToString(), } },
{ (int)Role.行政科室, new string[]{ UnitType.行政工勤.ToString(), "行政后勤" } },
};
public static Role[] SecondAdmin { get; } = new Role[] { Role.科主任, Role.护士长, Role.特殊科室, Role.行政科室 };
public static string[] GetMaps(int? key) => (key.HasValue && Maps.ContainsKey(key.Value)) ? Maps[key.Value] : Array.Empty<string>();
/// <summary>
/// 是否是行政后勤/工勤
......@@ -17,7 +34,7 @@ public class UnitTypeUtil
/// <returns></returns>
public static bool IsOffice(int? unit)
{
return unit == (int)UnitType.行政;
return unit == (int)UnitType.行政;
}
/// <summary>
......@@ -74,5 +91,6 @@ public static string Recognition(string name, AccountUnitType defaultValue)
return defaultValue.ToString();
}
}
}
using AutoMapper;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Services
{
public class UserService : IAutoInjection
{
private Application application;
private PerforUserRepository _userRepository;
private readonly IMapper _mapper;
private PerforSmsRepository _smsRepository;
private PerforHospitalRepository _hospitalRepository;
private PerforUserhospitalRepository _userhospitalRepository;
private PerforRoleRepository _roleRepository;
private PerforUserroleRepository _userroleRepository;
private PerforImemployeeRepository _employeeRepository;
private PerforPerallotRepository _perforPerallotRepository;
private PerforImaccountbasicRepository _imaccountbasicRepository;
private PerforImspecialunitRepository _imspecialunitRepository;
private PerforResaccountRepository _resaccountRepository;
private PerforPerallotRepository _perallotRepository;
private PerforPerdeptdicRepository _perdeptdicRepository;
private readonly PerforCofaccountingRepository perforCofaccountingRepository;
private readonly PerforUserRepository _userRepository;
private readonly PerforSmsRepository _smsRepository;
private readonly PerforHospitalRepository _hospitalRepository;
private readonly PerforUserhospitalRepository _userhospitalRepository;
private readonly PerforRoleRepository _roleRepository;
private readonly PerforUserroleRepository _userroleRepository;
private readonly PerforPerdeptdicRepository _perdeptdicRepository;
private readonly PerforCofaccountingRepository _perforCofaccountingRepository;
public UserService(
IMapper mapper,
IOptions<Application> application,
PerforSmsRepository smsRepository,
PerforUserRepository userRepository,
PerforHospitalRepository hospitalRepository,
PerforUserhospitalRepository userhospitalRepository,
PerforRoleRepository roleRepository,
PerforUserroleRepository userroleRepository,
PerforImemployeeRepository employeeRepository,
PerforPerallotRepository perforPerallotRepository,
PerforImaccountbasicRepository imaccountbasicRepository,
PerforImspecialunitRepository imspecialunitRepository,
PerforResaccountRepository resaccountRepository,
PerforPerallotRepository perallotRepository,
PerforPerdeptdicRepository perdeptdicRepository,
PerforCofaccountingRepository perforCofaccountingRepository)
{
this.application = application.Value;
this._userRepository = userRepository;
_userRepository = userRepository;
_mapper = mapper;
this._smsRepository = smsRepository;
this._hospitalRepository = hospitalRepository;
this._userhospitalRepository = userhospitalRepository;
this._roleRepository = roleRepository;
this._userroleRepository = userroleRepository;
this._employeeRepository = employeeRepository;
this._perforPerallotRepository = perforPerallotRepository;
this._imaccountbasicRepository = imaccountbasicRepository;
this._imspecialunitRepository = imspecialunitRepository;
this._resaccountRepository = resaccountRepository;
this._perallotRepository = perallotRepository;
this._perdeptdicRepository = perdeptdicRepository;
this.perforCofaccountingRepository = perforCofaccountingRepository;
_smsRepository = smsRepository;
_hospitalRepository = hospitalRepository;
_userhospitalRepository = userhospitalRepository;
_roleRepository = roleRepository;
_userroleRepository = userroleRepository;
_perdeptdicRepository = perdeptdicRepository;
_perforCofaccountingRepository = perforCofaccountingRepository;
}
/// <summary>
......@@ -148,34 +122,24 @@ public List<int> GetUserHospital(int userId)
/// <returns></returns>
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 userHospitals = _userhospitalRepository.GetEntities();
var users = _userRepository.GetEntities();
var hospitals = _hospitalRepository.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>();
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 sonUser = users?.Where(t => t.ParentID != 0 && t.ParentID != null);
......@@ -247,56 +211,56 @@ public List<UserResponse> GetUserList(int userID, int roleType = 1)
return result;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="iD"></param>
/// <returns></returns>
public ApiResponse Delete(int iD)
{
var user = _userRepository.GetEntity(t => t.ID == iD && t.IsDelete == 1);
if (null == user)
throw new PerformanceException($"用户不存在 UserId:{iD}");
user.IsDelete = 2;
var result = _userRepository.Remove(user);
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="iD"></param>
///// <returns></returns>
//public ApiResponse Delete(int iD)
//{
// var user = _userRepository.GetEntity(t => t.ID == iD && t.IsDelete == 1);
// if (null == user)
// throw new PerformanceException($"用户不存在 UserId:{iD}");
// user.IsDelete = 2;
// var result = _userRepository.Remove(user);
// 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>
/// 设置用户医院
......@@ -330,53 +294,59 @@ public bool SetHospital(int userId, int[] hosIDArray)
return rmResult && addResult;
}
/// <summary>
/// 修改用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public UserResponse Update(UserRequest request, bool isAgainAdmin)
{
var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1);
if (null == user)
throw new PerformanceException($"用户不存在 UserId:{request.ID}");
///// <summary>
///// 修改用户
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public UserResponse Update(UserRequest request, bool isAgainAdmin)
//{
// var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1);
// if (null == user)
// throw new PerformanceException($"用户不存在 UserId:{request.ID}");
var vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Login == request.Login && t.IsDelete == 1);
if (null != vlist && vlist.Count() > 0)
throw new PerformanceException("登录名重复");
// var vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Login == request.Login && t.IsDelete == 1);
// if (null != vlist && vlist.Count() > 0)
// throw new PerformanceException("登录名重复");
//vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Mobile == request.Mobile && t.IsDelete == 1);
//if (null != vlist && vlist.Count() > 0)
// throw new PerformanceException("手机号重复");
// var userRole = _userroleRepository.GetEntity(t => t.UserID == request.ID);
if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
// //vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Mobile == request.Mobile && t.IsDelete == 1);
// //if (null != vlist && vlist.Count() > 0)
// // throw new PerformanceException("手机号重复");
if (isAgainAdmin && request.HosIDArray.Length > 1)
throw new PerformanceException("二次绩效管理员只支持单家医院");
// if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
// throw new PerformanceException("二次绩效管理员科室不能为空");
user.Login = request.Login;
user.Mobile = request.Mobile;
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 (isAgainAdmin && request.HosIDArray.Length > 1)
// throw new PerformanceException("二次绩效管理员只支持单家医院");
if (!_userRepository.Update(user))
throw new PerformanceException("保存失败");
//删除用户角色关联关系
var userRole = _userroleRepository.GetEntity(t => t.UserID == request.ID);
if (null != userRole)
_userroleRepository.Remove(userRole);
//添加用户角色关联关系
_userroleRepository.Add(new sys_user_role { UserID = request.ID, RoleID = request.Role });
//添加用户医院
SetHospital(user.ID, request.HosIDArray);
// SaveHistoryDepartment(user.ID, newRoleId: request.Role, newDepartment: request.Department);
// user.Login = request.Login;
// user.Mobile = request.Mobile;
// 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("保存失败");
// //删除用户角色关联关系
// 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>
/// 修改个人信息
......@@ -453,53 +423,12 @@ public List<sys_role> RoleList(int userId)
/// 科室列表
/// </summary>
/// <returns></returns>
public List<TitleValue> Department(int hospitalId)
public List<TitleValue> Department(int allotId)
{
//var allotList = _perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId);
//var result = new List<string>();
//if (allotList != null)
//{
// var idList = allotList.Select(s => s.ID).ToList();
// //var department = _employeeRepository.GetEntities(t => t.Department != "" && idList.Contains(t.AllotID.Value)).Select(t => t.Department);
// //if (department != null && department.Count() > 0)
// // result.AddRange(department);
// var department = _imaccountbasicRepository.GetEntities(t => !string.IsNullOrEmpty(t.DoctorAccountingUnit) && idList.Contains(t.AllotID.Value))?.Select(t => t.DoctorAccountingUnit);
// if (department != null && department.Count() > 0)
// result.AddRange(department);
// // 特殊科室
// department = _imspecialunitRepository.GetEntities(t => !string.IsNullOrEmpty(t.AccountingUnit) && idList.Contains(t.AllotID.Value))?.Select(t => t.AccountingUnit);
// if (department != null && department.Count() > 0)
// result.AddRange(department);
// if (result != null && result.Any())
// {
// result = result.Distinct().OrderBy(t => t).ToList();
// }
//}
var list = _perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var list = _perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
if (list == null || !list.Any()) return new List<TitleValue>();
var result = list.Select(t => t.AccountingUnit).Distinct().OrderBy(t => t).ToList();
//// 补充行政科室
//var states = new int[] { (int)AllotStates.Archive, (int)AllotStates.GenerateAccomplish };
//var allots = _perallotRepository.GetEntities(w => w.HospitalId == hospitalId && states.Contains(w.States));
//if (allots != null && allots.Any())
//{
// var allot = allots.OrderByDescending(w => w.Year).ThenByDescending(w => w.Month).FirstOrDefault();
// if (allot != null)
// {
// var types = new int[] { (int)UnitType.行政中层, (int)UnitType.行政后勤 };
// var accounts = _resaccountRepository.GetEntities(w => w.AllotID == allot.ID && w.UnitType.HasValue && types.Contains(w.UnitType.Value));
// if (accounts != null && accounts.Any())
// {
// result.AddRange(accounts.Select(w => w.AccountingUnit));
// }
// }
//}
return result?.Select(t => new TitleValue { Title = t, Value = t }).ToList();
}
......@@ -584,15 +513,24 @@ public UserResponse InsertUser(UserRequest request, int userid)
if (null != _userRepository.GetEntity(t => t.Login == request.Login && t.IsDelete == 1))
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))
throw new PerformanceException("二次绩效管理员科室不能为空");
var user = _mapper.Map<sys_user>(request);
user.CreateDate = DateTime.Now;
user.CreateUser = userid;
user.States = (int)States.Enabled;
user.Department = roleArray.Contains(request.RoleArr[0]) ? request.Department : "";
user.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]) ? request.Department : "";
if (UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]))
{
var uninTypes = UnitTypeUtil.GetMaps(request.RoleArr[0]);
var account = _perforCofaccountingRepository.GetEntity(w => w.AccountingUnit == request.Department && uninTypes.Contains(w.UnitType));
user.UnitType = account?.UnitType ?? "";
user.UnitCode = account?.Code ?? "";
}
user.IsDelete = 1;
if (!_userRepository.Add(user))
......@@ -608,7 +546,14 @@ public UserResponse InsertUser(UserRequest request, int userid)
{
user.Login = request.Login + i;
user.ParentID = userID;
user.Department = roleArray.Contains(request.RoleArr[i]) ? request.Department : "";
user.Department = UnitTypeUtil.Maps.ContainsKey(request.RoleArr[i]) ? request.Department : "";
if (roleArray.Contains(request.RoleArr[i]))
{
var uninTypes = UnitTypeUtil.GetMaps(request.RoleArr[i]);
var account = _perforCofaccountingRepository.GetEntity(w => w.AccountingUnit == request.Department && uninTypes.Contains(w.UnitType));
user.UnitType = account?.UnitType ?? "";
user.UnitCode = account?.Code ?? "";
}
user.ID++;
_userRepository.Add(user);
......@@ -625,27 +570,39 @@ public UserResponse InsertUser(UserRequest request, int userid)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
public UserResponse UpdateUser(UserRequest request, int userId)
{
var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1);
if (null == user)
throw new PerformanceException($"用户不存在 UserId:{request.ID}");
var roleIds = request.RoleArr != null && request.RoleArr.Length > 0 ? request.RoleArr.Distinct().ToArray() : new int[0];
if (roleIds.Length == 0)
throw new PerformanceException("请选择用户角色");
var vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Login == request.Login && t.IsDelete == 1);
if (null != vlist && vlist.Count() > 0)
throw new PerformanceException("登录名重复");
var isAgainAdmin = request.RoleArr.Any(w => UnitTypeUtil.Maps.ContainsKey(w));
if (isAgainAdmin && string.IsNullOrEmpty(request.Department))
if (isAgainAdmin && string.IsNullOrEmpty(request?.Department))
throw new PerformanceException("二次绩效管理员科室不能为空");
int[] roleArray = new int[] { application.NurseRole, application.DirectorRole, application.SpecialRole, application.OfficeRole };
var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1);
if (null == user) throw new PerformanceException($"当前用户不存在");
var vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Login == request.Login && t.IsDelete == 1);
if (null != vlist && vlist.Count() > 0) throw new PerformanceException("登录名重复");
user.Login = request.Login;
user.Mobile = request.Mobile;
user.RealName = request.RealName;
user.Mail = request.Mail;
user.States = request.States;
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 (UnitTypeUtil.Maps.ContainsKey(request.RoleArr[0]))
{
var uninTypes = UnitTypeUtil.GetMaps(request.RoleArr[0]);
var account = _perforCofaccountingRepository.GetEntity(w => w.AccountingUnit == request.Department && uninTypes.Contains(w.UnitType));
user.UnitType = account?.UnitType ?? "";
user.UnitCode = account?.Code ?? "";
}
if (!_userRepository.Update(user))
throw new PerformanceException("保存失败");
......@@ -653,6 +610,7 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
var userRole = _userroleRepository.GetEntity(t => t.UserID == user.ID);
if (null != userRole)
_userroleRepository.Remove(userRole);
//添加用户角色关联关系
_userroleRepository.Add(new sys_user_role { UserID = user.ID, RoleID = request.RoleArr[0] });
//添加用户医院
......@@ -687,7 +645,15 @@ public UserResponse UpdateUser(UserRequest request, bool isAgainAdmin)
diffUser.Mail = request.Mail;
diffUser.States = request.States;
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 (UnitTypeUtil.Maps.ContainsKey(request.RoleArr[i]))
{
var uninTypes = UnitTypeUtil.GetMaps(request.RoleArr[i]);
var account = _perforCofaccountingRepository.GetEntity(w => w.AccountingUnit == request.Department && uninTypes.Contains(w.UnitType));
diffUser.UnitType = account?.UnitType ?? "";
diffUser.UnitCode = account?.Code ?? "";
}
if (!_userRepository.Add(diffUser))
throw new PerformanceException("保存失败");
//添加子用户角色关联关系
......@@ -723,24 +689,24 @@ public ApiResponse DeleteUser(int iD)
#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,
Visible = 1
}).ToList());
if (result.Columns != null && result.Columns.Any())
Columns = Users.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = Users.Select(t => t.Value).ToList(),
};
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.Source = _roleRepository.GetEntities().Select(t => t.RoleName).ToArray();
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.Source = _hospitalRepository.GetEntities().Select(t => t.HosName).ToArray();
......@@ -748,7 +714,7 @@ public HandsonTable GetUserHandsFlat()
}
}
}
return result;
return table;
}
/// <summary>
......@@ -756,55 +722,128 @@ public HandsonTable GetUserHandsFlat()
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public string SaveUserHandsFlat(UserCollectData request)
public ApiResponse SaveUserHandsFlat(UserCollectData request)
{
try
{
var dicData = CreateDataRow(request, Users);
var allDataList = dicData.Select(item => JsonHelper.Deserialize<UserHandsResponse>(JsonHelper.Serialize(item))).ToList();
var getUsers = _userRepository.GetEntities();
var roles = _roleRepository.GetEntities();
var hospitals = _hospitalRepository.GetEntities();
var accounts = perforCofaccountingRepository.GetEntities();
var hosnames = allDataList.Select(w => w.HosName).Distinct().Where(w => !string.IsNullOrEmpty(w)).ToList();
var hospitals = _hospitalRepository.GetEntities(w => hosnames.Contains(w.HosName));
var hospitalIds = hospitals.Select(w => w.ID).ToArray();
var accounts = _perforCofaccountingRepository.GetAccounting(hospitalIds) ?? new List<CofAccountingEntity>();
List<sys_user> users = new List<sys_user>();
List<sys_user_role> userRoles = new List<sys_user_role>();
List<sys_user_hospital> userHoss = new List<sys_user_hospital>();
var roleArr = new[] { "护士长", "科主任", "特殊科室", "行政科室" };
var allDataList = dicData.Select(item => JsonHelper.Deserialize<UserHandsResponse>(JsonHelper.Serialize(item)));
var names = allDataList?.Select(w => w?.HosName).Distinct();
Dictionary<string, List<string>> res = new Dictionary<string, List<string>>();
foreach (var item in names)
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
for (int i = 0; i < allDataList.Count(); i++)
{
if (string.IsNullOrEmpty(item)) return "必填项为空";
var HospitalId = hospitals.FirstOrDefault(w => w.HosName == item)?.ID;
// 姓名、登录名、角色、分配医院
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()))
{
if (HospitalId == null) return "未找到分配医院";
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "姓名", allDataList[i].Login ?? "" },
{ "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department.ToString() ?? "" },
{ "错误原因", "“关键信息缺失”请补全或删除" },
});
continue;
}
if (!Enum.IsDefined(typeof(Role), allDataList[i].RoleName))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "姓名", allDataList[i].Login ?? "" },
{ "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department.ToString() ?? "" },
{ "错误原因", "“角色”错误,请修改或删除" },
});
}
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() ?? "" },
{ "错误原因", "“分配医院”错误,请修改或删除" },
});
}
var allot = _perallotRepository.GetEntities(t => t.HospitalId == HospitalId);
var accountingUnits = accounts?.Join(allot, t => t.AllotId, w => w.ID, (t, w) => t.AccountingUnit).Distinct().ToList();
res.Add(item, accountingUnits);
if (getUsers.Any(c => c.Login == allDataList[i].Login?.Trim()))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "姓名", allDataList[i].Login ?? "" },
{ "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department ?? "" },
{ "错误原因", "“登录名”已存在,请修改或删除" },
});
}
if (UnitTypeUtil.SecondAdmin.Any(r => r.ToString() == allDataList[i].RoleName?.Trim()))
{
var hospitalId = hospitals.FirstOrDefault(w => w.HosName == (allDataList[i].HosName?.Trim()))?.ID ?? -1;
var role = (Role)Enum.Parse(typeof(Role), allDataList[i].RoleName);
var uninTypes = UnitTypeUtil.GetMaps((int)role);
var cts = accounts.FirstOrDefault(w => w.HospitalId == hospitalId && w.AccountingUnit == allDataList[i].Department?.Trim() && uninTypes.Contains(w.UnitType));
if (cts == null)
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "姓名", allDataList[i].Login ?? "" },
{ "登录名", allDataList[i].RealName ?? "" },
{ "角色", allDataList[i].RoleName ?? "" },
{ "分配医院", allDataList[i].HosName ?? "" },
{ "核算单元", allDataList[i].Department ?? "" },
{ "错误原因", "“核算单元”错误,当前角色暂无该核算单元,请修改或删除" },
});
}
}
}
if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
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)
|| getUsers.Any(c => c.Login == data?.Login)) continue;
if (users.Any(c => c.Login == data?.Login)) continue;
var hospitalId = hospitals.FirstOrDefault(w => w.HosName == (data.HosName?.Trim()))?.ID ?? -1;
var role = (Role)Enum.Parse(typeof(Role), data.RoleName);
var uninTypes = UnitTypeUtil.GetMaps((int)role);
var cts = accounts.FirstOrDefault(w => w.HospitalId == hospitalId && w.AccountingUnit == data.Department?.Trim() && uninTypes.Contains(w.UnitType));
var user = new sys_user
{
RealName = data.RealName,
CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")),
CreateDate = DateTime.Now,
CreateUser = request.CreateUser,
Department = data?.Department ?? "",
Department = data?.Department.Trim() ?? "",
UnitType = cts?.UnitType ?? "",
UnitCode = cts?.Code ?? "",
IsDelete = 1,
Login = data.Login,
Password = data?.Password ?? "123456",
......@@ -816,9 +855,9 @@ public string SaveUserHandsFlat(UserCollectData request)
}
_userRepository.AddRange(users.ToArray());
var joinData = users.Join(allDataList,
outer => new { outer.Login, outer.RealName, Department = outer.Department ?? "" },
inner => new { inner.Login, inner.RealName, Department = inner.Department ?? "" },
var joinData = users.Join(allDataList,
outer => new { outer.Login, outer.RealName, Department = outer.Department ?? "" },
inner => new { inner.Login, inner.RealName, Department = inner.Department ?? "" },
(outer, inner) => new { outer, inner });
......@@ -836,7 +875,7 @@ public string SaveUserHandsFlat(UserCollectData request)
});
_userhospitalRepository.AddRange(hosJoin.ToArray());
return "";
return new ApiResponse(ResponseType.OK, "保存成功");
}
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