医院其他绩效 录入科室 自动填充

parent 60f260d7
//-----------------------------------------------------------------------
// <copyright file=" per_apr_amount.cs">
// * FileName: per_apr_amount.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// per_apr_amount Repository
/// </summary>
public partial class PerforPerapramountRepository : PerforRepository<per_apr_amount>
{
public List<view_per_apr_amount> GetFullAmount(Func<per_apr_amount, bool> predicate)
{
var employees = this.context.Set<per_employee>().AsEnumerable();
var amounts = this.context.Set<per_apr_amount>().Where(predicate);
var res = amounts.Join(employees,
outer => new { outer.AllotId, outer.PersonnelNumber },
inner => new { AllotId = inner.AllotId ?? 0, inner.PersonnelNumber },
(outer, inner) => new view_per_apr_amount
{
Id = outer.Id,
AllotId = outer.AllotId,
PersonnelNumber = outer.PersonnelNumber,
DoctorName = outer.DoctorName,
PerforType = outer.PerforType,
Amount = outer.Amount,
AccountingUnit = inner.AccountingUnit,
UnitType = inner.UnitType,
TypeInDepartment = outer.TypeInDepartment,
Status = outer.Status,
AuditTime = outer.AuditTime,
AuditUser = outer.AuditUser,
CreateDate = outer.CreateDate,
CreateUser = outer.CreateUser,
Remark = outer.Remark,
IsVerify = outer.IsVerify,
VerifyMessage = outer.VerifyMessage,
});
return res.ToList() ?? new List<view_per_apr_amount>();
}
}
}
......@@ -18,36 +18,5 @@ public partial class PerforPerapramountRepository : PerforRepository<per_apr_amo
public PerforPerapramountRepository(PerformanceDbContext context) : base(context)
{
}
public List<view_per_apr_amount> GetFullAmount(Func<per_apr_amount, bool> predicate)
{
var employees = this.context.Set<per_employee>().AsEnumerable();
var amounts = this.context.Set<per_apr_amount>().Where(predicate);
var res = amounts.Join(employees,
outer => new { outer.AllotId, outer.PersonnelNumber },
inner => new { AllotId = inner.AllotId ?? 0, inner.PersonnelNumber },
(outer, inner) => new view_per_apr_amount
{
Id = outer.Id,
AllotId = outer.AllotId,
PersonnelNumber = outer.PersonnelNumber,
DoctorName = outer.DoctorName,
PerforType = outer.PerforType,
Amount = outer.Amount,
AccountingUnit = inner.AccountingUnit,
UnitType = inner.UnitType,
TypeInDepartment = outer.TypeInDepartment,
Status = outer.Status,
AuditTime = outer.AuditTime,
AuditUser = outer.AuditUser,
CreateDate = outer.CreateDate,
CreateUser = outer.CreateUser,
Remark = outer.Remark,
IsVerify = outer.IsVerify,
VerifyMessage = outer.VerifyMessage,
});
return res.ToList() ?? new List<view_per_apr_amount>();
}
}
}
......@@ -31,9 +31,11 @@ public class EmployeeService : IAutoInjection
private PerforUserroleRepository userroleRepository;
private PerforPeremployeeRepository peremployeeRepository;
private PerforUserRepository userRepository;
private readonly PerforRoleRepository _roleRepository;
private ILogger<EmployeeService> logger;
public EmployeeService(PerforImemployeeRepository perforImemployeeRepository,
public EmployeeService(
PerforImemployeeRepository perforImemployeeRepository,
PerforPersheetRepository perforPersheetRepository,
PerforImdataRepository perforImdataRepository,
PerforPerallotRepository perforPerallotRepository,
......@@ -45,6 +47,7 @@ public class EmployeeService : IAutoInjection
PerforUserroleRepository userroleRepository,
PerforPeremployeeRepository peremployeeRepository,
PerforUserRepository userRepository,
PerforRoleRepository roleRepository,
ILogger<EmployeeService> logger)
{
this.perforImemployeeRepository = perforImemployeeRepository;
......@@ -59,6 +62,7 @@ public class EmployeeService : IAutoInjection
this.userroleRepository = userroleRepository;
this.peremployeeRepository = peremployeeRepository;
this.userRepository = userRepository;
_roleRepository = roleRepository;
this.logger = logger;
}
......@@ -416,9 +420,12 @@ public bool InsertApr(per_apr_amount request, int userId)
if (request == null)
return false;
//var data = perapramountRepository.GetEntity(t => t.PersonnelNumber == request.PersonnelNumber && t.AllotId == request.AllotId);
//if (data != null)
// throw new PerformanceException("人员工号已存在");
if (string.IsNullOrEmpty(request.PersonnelNumber))
throw new PerformanceException("文件中存在“工号”为空的数据");
if (string.IsNullOrEmpty(request.PerforType) && request.Amount != 0)
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
request.TypeInDepartment = GetTypeInDepartment(userId);
request.Status = 2;
request.CreateDate = DateTime.Now;
request.CreateUser = userId;
......@@ -430,6 +437,12 @@ public bool UpdateApr(per_apr_amount request)
if (request == null)
return false;
if (string.IsNullOrEmpty(request.PersonnelNumber))
throw new PerformanceException("文件中存在“工号”为空的数据");
if (string.IsNullOrEmpty(request.PerforType) && request.Amount != 0)
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
var data = perapramountRepository.GetEntity(t => t.Id == request.Id);
if (data == null)
throw new PerformanceException("修改数据无效");
......@@ -438,7 +451,6 @@ public bool UpdateApr(per_apr_amount request)
data.PersonnelNumber = request.PersonnelNumber;
data.DoctorName = request.DoctorName;
data.PerforType = request.PerforType;
data.TypeInDepartment = request.TypeInDepartment;
//data.AccountingUnit = request.AccountingUnit;
data.Amount = request.Amount;
......@@ -490,6 +502,27 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request)
return true;
}
/// <summary>
/// 更加用户ID获取录入科室
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public string GetTypeInDepartment(int userId)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
if (userrole == null) throw new PerformanceException("用户未绑定角色");
string typeIn = "";
// 护士长/科主任/特殊科室/行政科室 录入科室为核算单元
if (new int[] { 3, 4, 9, 10 }.Contains(userrole.RoleID))
typeIn = userRepository.GetEntity(w => w.ID == userId)?.Department ?? "";
// 非 护士长/科主任/特殊科室/行政科室 则为角色名称
else
typeIn = _roleRepository.GetEntity(w => w.ID == userrole.RoleID)?.RoleName ?? "";
return typeIn;
}
public void ImpoerAprEmployees(int allotid, string path, int userid)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userid);
......@@ -532,7 +565,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
Dictionary<string, int> dict = new Dictionary<string, int>
{
{ "录入科室", -1 },{ "核算单元", -1 },{ "人员工号", -1 }, { "姓名", -1 }, { "绩效类型", -1 }, { "金额", -1 },
{ "人员工号", -1 }, { "姓名", -1 }, { "绩效类型", -1 }, { "金额", -1 },
};
foreach (var key in dict.Keys.ToList())
......@@ -543,7 +576,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
var entities = new List<per_apr_amount>();
var createtime = DateTime.Now;
var typeIn = GetTypeInDepartment(userid);
for (int rowindex = 1; rowindex < sheet.LastRowNum + 1; rowindex++)
{
var row = sheet.GetRow(rowindex);
......@@ -556,7 +589,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
DoctorName = dict["姓名"] < 0 ? "" : row.GetCell(dict["姓名"]).GetValue(),
PerforType = dict["绩效类型"] < 0 ? "" : row.GetCell(dict["绩效类型"]).GetValue(),
Amount = dict["金额"] < 0 ? 0 : ConvertHelper.To<decimal>(row.GetCell(dict["金额"]).GetValue(), 0),
TypeInDepartment = dict["录入科室"] < 0 ? "" : row.GetCell(dict["录入科室"]).GetValue(),
TypeInDepartment = typeIn,
//AccountingUnit = dict["核算单元"] < 0 ? "" : row.GetCell(dict["核算单元"]).GetValue(),
AllotId = allotid,
CreateDate = createtime,
......@@ -572,8 +605,8 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
throw new PerformanceException("文件中存在“工号”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.PerforType) && w.Amount != 0))
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.TypeInDepartment) && w.Amount != 0))
throw new PerformanceException("文件中存在“录入科室”为空的数据");
//if (entities.Any(w => string.IsNullOrEmpty(w.TypeInDepartment) && w.Amount != 0))
// throw new PerformanceException("文件中存在“录入科室”为空的数据");
//var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotid);
//foreach (var item in entities.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber)))
......
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