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

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 ...@@ -18,36 +18,5 @@ public partial class PerforPerapramountRepository : PerforRepository<per_apr_amo
public PerforPerapramountRepository(PerformanceDbContext context) : base(context) 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 ...@@ -31,9 +31,11 @@ public class EmployeeService : IAutoInjection
private PerforUserroleRepository userroleRepository; private PerforUserroleRepository userroleRepository;
private PerforPeremployeeRepository peremployeeRepository; private PerforPeremployeeRepository peremployeeRepository;
private PerforUserRepository userRepository; private PerforUserRepository userRepository;
private readonly PerforRoleRepository _roleRepository;
private ILogger<EmployeeService> logger; private ILogger<EmployeeService> logger;
public EmployeeService(PerforImemployeeRepository perforImemployeeRepository, public EmployeeService(
PerforImemployeeRepository perforImemployeeRepository,
PerforPersheetRepository perforPersheetRepository, PerforPersheetRepository perforPersheetRepository,
PerforImdataRepository perforImdataRepository, PerforImdataRepository perforImdataRepository,
PerforPerallotRepository perforPerallotRepository, PerforPerallotRepository perforPerallotRepository,
...@@ -45,6 +47,7 @@ public class EmployeeService : IAutoInjection ...@@ -45,6 +47,7 @@ public class EmployeeService : IAutoInjection
PerforUserroleRepository userroleRepository, PerforUserroleRepository userroleRepository,
PerforPeremployeeRepository peremployeeRepository, PerforPeremployeeRepository peremployeeRepository,
PerforUserRepository userRepository, PerforUserRepository userRepository,
PerforRoleRepository roleRepository,
ILogger<EmployeeService> logger) ILogger<EmployeeService> logger)
{ {
this.perforImemployeeRepository = perforImemployeeRepository; this.perforImemployeeRepository = perforImemployeeRepository;
...@@ -59,6 +62,7 @@ public class EmployeeService : IAutoInjection ...@@ -59,6 +62,7 @@ public class EmployeeService : IAutoInjection
this.userroleRepository = userroleRepository; this.userroleRepository = userroleRepository;
this.peremployeeRepository = peremployeeRepository; this.peremployeeRepository = peremployeeRepository;
this.userRepository = userRepository; this.userRepository = userRepository;
_roleRepository = roleRepository;
this.logger = logger; this.logger = logger;
} }
...@@ -416,9 +420,12 @@ public bool InsertApr(per_apr_amount request, int userId) ...@@ -416,9 +420,12 @@ public bool InsertApr(per_apr_amount request, int userId)
if (request == null) if (request == null)
return false; return false;
//var data = perapramountRepository.GetEntity(t => t.PersonnelNumber == request.PersonnelNumber && t.AllotId == request.AllotId); if (string.IsNullOrEmpty(request.PersonnelNumber))
//if (data != null) throw new PerformanceException("文件中存在“工号”为空的数据");
// throw new PerformanceException("人员工号已存在"); if (string.IsNullOrEmpty(request.PerforType) && request.Amount != 0)
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
request.TypeInDepartment = GetTypeInDepartment(userId);
request.Status = 2; request.Status = 2;
request.CreateDate = DateTime.Now; request.CreateDate = DateTime.Now;
request.CreateUser = userId; request.CreateUser = userId;
...@@ -430,6 +437,12 @@ public bool UpdateApr(per_apr_amount request) ...@@ -430,6 +437,12 @@ public bool UpdateApr(per_apr_amount request)
if (request == null) if (request == null)
return false; 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); var data = perapramountRepository.GetEntity(t => t.Id == request.Id);
if (data == null) if (data == null)
throw new PerformanceException("修改数据无效"); throw new PerformanceException("修改数据无效");
...@@ -438,7 +451,6 @@ public bool UpdateApr(per_apr_amount request) ...@@ -438,7 +451,6 @@ public bool UpdateApr(per_apr_amount request)
data.PersonnelNumber = request.PersonnelNumber; data.PersonnelNumber = request.PersonnelNumber;
data.DoctorName = request.DoctorName; data.DoctorName = request.DoctorName;
data.PerforType = request.PerforType; data.PerforType = request.PerforType;
data.TypeInDepartment = request.TypeInDepartment;
//data.AccountingUnit = request.AccountingUnit; //data.AccountingUnit = request.AccountingUnit;
data.Amount = request.Amount; data.Amount = request.Amount;
...@@ -490,6 +502,27 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request) ...@@ -490,6 +502,27 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request)
return true; 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) public void ImpoerAprEmployees(int allotid, string path, int userid)
{ {
var userrole = userroleRepository.GetEntity(t => t.UserID == userid); var userrole = userroleRepository.GetEntity(t => t.UserID == userid);
...@@ -532,7 +565,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -532,7 +565,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
Dictionary<string, int> dict = new Dictionary<string, int> 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()) foreach (var key in dict.Keys.ToList())
...@@ -543,7 +576,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -543,7 +576,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
var entities = new List<per_apr_amount>(); var entities = new List<per_apr_amount>();
var createtime = DateTime.Now; var createtime = DateTime.Now;
var typeIn = GetTypeInDepartment(userid);
for (int rowindex = 1; rowindex < sheet.LastRowNum + 1; rowindex++) for (int rowindex = 1; rowindex < sheet.LastRowNum + 1; rowindex++)
{ {
var row = sheet.GetRow(rowindex); var row = sheet.GetRow(rowindex);
...@@ -556,7 +589,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -556,7 +589,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
DoctorName = dict["姓名"] < 0 ? "" : row.GetCell(dict["姓名"]).GetValue(), DoctorName = dict["姓名"] < 0 ? "" : row.GetCell(dict["姓名"]).GetValue(),
PerforType = 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), 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(), //AccountingUnit = dict["核算单元"] < 0 ? "" : row.GetCell(dict["核算单元"]).GetValue(),
AllotId = allotid, AllotId = allotid,
CreateDate = createtime, CreateDate = createtime,
...@@ -572,8 +605,8 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -572,8 +605,8 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
throw new PerformanceException("文件中存在“工号”为空的数据"); throw new PerformanceException("文件中存在“工号”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.PerforType) && w.Amount != 0)) if (entities.Any(w => string.IsNullOrEmpty(w.PerforType) && w.Amount != 0))
throw new PerformanceException("文件中存在“绩效类型”为空的数据"); throw new PerformanceException("文件中存在“绩效类型”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.TypeInDepartment) && w.Amount != 0)) //if (entities.Any(w => string.IsNullOrEmpty(w.TypeInDepartment) && w.Amount != 0))
throw new PerformanceException("文件中存在“录入科室”为空的数据"); // throw new PerformanceException("文件中存在“录入科室”为空的数据");
//var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotid); //var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotid);
//foreach (var item in entities.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber))) //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