大量改动

行政后期修改为行政工勤
核算单元及组别验证优化
HandsonTable返回优化
预留绩效兼容核算单元变更
用户粘贴功能优化
parent 43238061
...@@ -194,7 +194,7 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request) ...@@ -194,7 +194,7 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request)
{ {
second = _computeService.GetSecondByAccountId(request.AccountID); 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); var response = _computeService.DeptOfficeDetail(request.AccountID);
return new ApiResponse(ResponseType.OK, response); return new ApiResponse(ResponseType.OK, response);
...@@ -205,7 +205,7 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request) ...@@ -205,7 +205,7 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request)
var response = _computeService.SpecialDeptDetail(second); var response = _computeService.SpecialDeptDetail(second);
return new ApiResponse(ResponseType.OK, response); 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); var response = _computeService.DeptOfficeDetail(request.AccountID);
return new ApiResponse(ResponseType.OK, response); return new ApiResponse(ResponseType.OK, response);
......
...@@ -699,8 +699,8 @@ public ApiResponse BatchAccountingStructrue([FromRoute] int allotId) ...@@ -699,8 +699,8 @@ public ApiResponse BatchAccountingStructrue([FromRoute] int allotId)
[HttpPost] [HttpPost]
public ApiResponse BatchCheckAccounting(int allotId) public ApiResponse BatchCheckAccounting(int allotId)
{ {
_configService.BatchCheckAccounting(allotId); _allotService.AccoungtingVerify(allotId);
return new ApiResponse(ResponseType.OK, "校验通过"); return new ApiResponse(ResponseType.OK, "校验完成");
} }
/// <summary> /// <summary>
......
...@@ -3353,6 +3353,16 @@ ...@@ -3353,6 +3353,16 @@
核算单元 核算单元
</summary> </summary>
</member> </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"> <member name="P:Performance.DtoModels.EmployeeReservedDto.EmployeeName">
<summary> <summary>
人员姓名 人员姓名
......
...@@ -8870,6 +8870,21 @@ ...@@ -8870,6 +8870,21 @@
</summary> </summary>
</member> </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"> <member name="P:Performance.EntityModels.Other.view_attendance.UnitType">
<summary> <summary>
人员类别 人员类别
......
...@@ -20,6 +20,28 @@ public HandsonTableBase() ...@@ -20,6 +20,28 @@ public HandsonTableBase()
public List<Dictionary<string, object>> Data { get; set; } public List<Dictionary<string, object>> Data { get; set; }
public List<HandsonColumn> Columns { get; set; } public List<HandsonColumn> Columns { get; set; }
public object[] NestedHeadersArray { 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 public class HandsonTable : HandsonTableBase
...@@ -95,17 +117,6 @@ private void InitColumns(List<collect_permission> permissions) ...@@ -95,17 +117,6 @@ private void InitColumns(List<collect_permission> permissions)
} }
Columns = columns; 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 public class HandsonColumn
......
...@@ -27,6 +27,16 @@ public class EmployeeReservedDto ...@@ -27,6 +27,16 @@ public class EmployeeReservedDto
public string AccountingUnit { get; set; } public string AccountingUnit { get; set; }
/// <summary> /// <summary>
///
/// </summary>
public string NewUnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string NewAccountingUnit { get; set; }
/// <summary>
/// 人员姓名 /// 人员姓名
/// </summary> /// </summary>
public string EmployeeName { get; set; } public string EmployeeName { get; set; }
......
...@@ -89,6 +89,6 @@ public enum UnitType ...@@ -89,6 +89,6 @@ public enum UnitType
[Description("行政中层")] [Description("行政中层")]
行政中层 = 11, 行政中层 = 11,
[Description("行政勤")] [Description("行政勤")]
行政 = 12, 行政 = 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;
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 ...@@ -28,6 +28,41 @@ public bool UpdateAllotStates(int allotId, int states, string remark, int genera
allot.Generate = generate; allot.Generate = generate;
return Update(allot); 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> /// <summary>
/// 执行存储过程 /// 执行存储过程
...@@ -318,5 +353,25 @@ public IEnumerable<dynamic> QueryEmployee(int allotId) ...@@ -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) ...@@ -391,6 +391,21 @@ public List<EmployeeReservedDto> GetEmployeeReserved(int hospitalId, int year)
return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = hospitalId, Year = year })?.ToList(); 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) 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"; string sql = "SELECT * FROM view_allot_result WHERE States IN (6,8) AND HospitalID IN @HospitalID AND JobNumber=@JobNumber";
......
...@@ -11,7 +11,7 @@ namespace Performance.Repository ...@@ -11,7 +11,7 @@ namespace Performance.Repository
/// <summary> /// <summary>
/// cof_accounting Repository /// cof_accounting Repository
/// </summary> /// </summary>
public class PerforCofaccountingRepository : PerforRepository<cof_accounting> public partial class PerforCofaccountingRepository : PerforRepository<cof_accounting>
{ {
public PerforCofaccountingRepository(PerformanceDbContext context) : base(context) public PerforCofaccountingRepository(PerformanceDbContext context) : base(context)
{ {
......
...@@ -519,7 +519,7 @@ public void GenerateSecondAllot(per_allot allot) ...@@ -519,7 +519,7 @@ public void GenerateSecondAllot(per_allot allot)
List<ag_secondallot> updSecond = new List<ag_secondallot>(); List<ag_secondallot> updSecond = new List<ag_secondallot>();
List<ag_secondallot> delSecond = 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); //var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
//if (hospital?.IsOpenLogisticsSecondAllot != 1) //if (hospital?.IsOpenLogisticsSecondAllot != 1)
...@@ -527,7 +527,7 @@ public void GenerateSecondAllot(per_allot allot) ...@@ -527,7 +527,7 @@ public void GenerateSecondAllot(per_allot allot)
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && !types.Contains(t.UnitType.Value)); 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) if (xzAccountUnit != null && xzAccountUnit.Count > 0)
(accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit); (accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
......
...@@ -121,40 +121,6 @@ public class AllotService : IAutoInjection ...@@ -121,40 +121,6 @@ public class AllotService : IAutoInjection
this.queryDataService = queryDataService; this.queryDataService = queryDataService;
} }
#region 先取上一个月的绩效Id
/// <summary>
/// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
/// </summary>
/// <param name="allot"></param>
public int GetPrevAllot(int allotId)
{
var allot = _allotRepository.GetEntity(t => t.ID == allotId);
return GetPrevAllot(allot);
}
/// <summary>
/// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
/// </summary>
/// <param name="allot"></param>
public int GetPrevAllot(per_allot allot)
{
var list = _allotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
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
#region 基础功能 #region 基础功能
/// <summary> /// <summary>
...@@ -486,7 +452,7 @@ public void Generate(per_allot allot) ...@@ -486,7 +452,7 @@ public void Generate(per_allot allot)
UpdateAllotStates(allot.ID, (int)AllotStates.绩效结果解析成功, EnumHelper.GetDescription(AllotStates.绩效结果解析成功), generate); UpdateAllotStates(allot.ID, (int)AllotStates.绩效结果解析成功, EnumHelper.GetDescription(AllotStates.绩效结果解析成功), generate);
perforCofdirectorRepository.SupplementaryData(allot.ID); perforCofdirectorRepository.SupplementaryData(allot.ID);
// 验证科室核算单元、工号 // 验证科室核算单元、工号
AccoungtingVerify(allot.ID); _allotRepository.AccoungtingVerify(allot.ID);
//补全支出费用类别 //补全支出费用类别
configService.SaveDrugtypeDisburse(allot.ID); configService.SaveDrugtypeDisburse(allot.ID);
//logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true); //logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true);
...@@ -532,10 +498,7 @@ public void GenerateReport(per_allot allot) ...@@ -532,10 +498,7 @@ public void GenerateReport(per_allot allot)
/// <param name="allot"></param> /// <param name="allot"></param>
public void AccoungtingVerify(int allotId) public void AccoungtingVerify(int allotId)
{ {
using (IDbConnection connection = new MySqlConnection(_appConnection.Value.PerformanceConnectionString)) _allotRepository.AccoungtingVerify(allotId);
{
connection.Execute("call proc_verify_accoungingunit_unittype(@allotId);", new { allotId });
}
} }
/// <summary> /// <summary>
...@@ -692,18 +655,15 @@ public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int useri ...@@ -692,18 +655,15 @@ public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int useri
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在"); if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色"); if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
var reserveds = _reportRepository.GetEmployeeReserved(hospitalId, year); if (userInfo.IsSecondAdmin)
if (reserveds != null && reserveds.Any())
{ {
var unitTpes = UnitTypeUtil.GetMaps(userInfo?.URole.Type); var unitTpes = UnitTypeUtil.GetMaps(userInfo?.URole.Type);
Expression<Func<EmployeeReservedDto, bool>> exp = w => w.AccountingUnit == userInfo.User.Department; return _reportRepository.GetEmployeeReserved(hospitalId, year, unitTpes, userInfo.User.Department);
if (userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value)) }
exp = exp.And(t => unitTpes.Contains(t.UnitType)); else
reserveds = reserveds.Where(exp.Compile())?.ToList(); {
return _reportRepository.GetEmployeeReserved(hospitalId, year);
} }
return reserveds;
} }
/// <summary> /// <summary>
/// 查询个人绩效 /// 查询个人绩效
......
...@@ -116,14 +116,13 @@ public ApiResponse<List<view_attendance>> GetCallIn(int allotId) ...@@ -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, Columns = Person.Select(t => new HandsonColumn(t.Item2)).ToList(),
Visible = 1, ColHeaders = Person.Select(c => c.Item2).ToList(),
Readnoly = 0 };
}).ToList());
if (handson.Columns != null && handson.Columns.Any()) if (handson.Columns != null && handson.Columns.Any())
{ {
var cofaccounting = cofaccountingRepository.GetEntities(w => w.UnitType != "" && w.AllotId == allotId); var cofaccounting = cofaccountingRepository.GetEntities(w => w.UnitType != "" && w.AllotId == allotId);
...@@ -133,7 +132,6 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId) ...@@ -133,7 +132,6 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
if (column.Data == "调入组别") if (column.Data == "调入组别")
{ {
column.Type = "autocomplete"; column.Type = "autocomplete";
//column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
column.Source = cofaccounting.Select(w => w.UnitType).Distinct().ToArray(); column.Source = cofaccounting.Select(w => w.UnitType).Distinct().ToArray();
column.Strict = true; column.Strict = true;
} }
...@@ -141,16 +139,9 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId) ...@@ -141,16 +139,9 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
if (column.Data == "调入核算单元") if (column.Data == "调入核算单元")
{ {
column.Type = "autocomplete"; 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.Source = cofaccounting.Select(w => w.AccountingUnit).Distinct().ToArray();
column.Strict = true; column.Strict = true;
} }
//if (column.Data == "调入时间")
//{
// column.Type = "date";
// column.DateFormat = "YYYY/MM/DD";
//}
} }
} }
List<view_attendance> data = new List<view_attendance>(); List<view_attendance> data = new List<view_attendance>();
...@@ -184,7 +175,7 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId) ...@@ -184,7 +175,7 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
rowDatas.Add(new HandsonRowData(i, cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
handson.SetRowData(rowDatas, rowDatas != null); handson.SetRowData(rowDatas);
foreach (var item in handson.Data) foreach (var item in handson.Data)
{ {
item.Remove("编号"); item.Remove("编号");
...@@ -386,25 +377,19 @@ public ApiResponse DeleteAttendanceType(int id) ...@@ -386,25 +377,19 @@ public ApiResponse DeleteAttendanceType(int id)
#endregion #endregion
#region 考勤记录 #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, Columns = Vacation.Select(t => new HandsonColumn(t.Item2)).ToList(),
Visible = 1, ColHeaders = Vacation.Select(c => c.Item2).ToList(),
Readnoly = 0 };
}).ToList());
if (handson.Columns != null && handson.Columns.Any()) if (handson.Columns != null && handson.Columns.Any())
{ {
var type = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId); var type = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId);
foreach (var column in handson.Columns) foreach (var column in handson.Columns)
{ {
column.Type = "text"; column.Type = "text";
//if (column.Data.Contains("时间"))
//{
// column.Type = "date";
// column.DateFormat = "YYYY/MM/DD";
//}
if (column.Data == "考勤类型") if (column.Data == "考勤类型")
{ {
column.Type = "autocomplete"; column.Type = "autocomplete";
...@@ -444,7 +429,7 @@ public HandsonTable GetAttendanceVacationHandsonTable(int allotId) ...@@ -444,7 +429,7 @@ public HandsonTable GetAttendanceVacationHandsonTable(int allotId)
rowDatas.Add(new HandsonRowData(i, cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
handson.SetRowData(rowDatas, rowDatas != null); handson.SetRowData(rowDatas);
foreach (var item in handson.Data) foreach (var item in handson.Data)
{ {
item.Remove("编号"); item.Remove("编号");
......
...@@ -326,7 +326,7 @@ public List<DeptResponse> GetGroupPerformance(int allotId, List<int> group) ...@@ -326,7 +326,7 @@ public List<DeptResponse> GetGroupPerformance(int allotId, List<int> group)
/// <returns></returns> /// <returns></returns>
public List<DeptResponse> GetOfficePerformance(int allotId) 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 == "是") var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId && t.NeedSecondAllot == "是")
?.OrderBy(t => t.UnitType) ?.OrderBy(t => t.UnitType)
...@@ -565,7 +565,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId) ...@@ -565,7 +565,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
#region 需要二次分配的行政科室 #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 var needSecondResult = needSecond.Select(t => new DeptResponse
{ {
UnitName = ((UnitType)t.UnitType).ToString() == "行政后勤" ? "行政工勤" : ((UnitType)t.UnitType).ToString(), UnitName = ((UnitType)t.UnitType).ToString() == "行政后勤" ? "行政工勤" : ((UnitType)t.UnitType).ToString(),
...@@ -712,8 +712,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId) ...@@ -712,8 +712,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
enumItems.ForEach(t => enumItems.ForEach(t =>
{ {
t.Value = UnitTypeUtil.Is(t.Name, UnitType.护理组) ? t.Value + 2 : t.Value; t.Value = UnitTypeUtil.Is(t.Name, UnitType.护理组) ? t.Value + 2 : t.Value;
if (t.Name == UnitType.行政后勤.ToString()) t.Name = t.Name == "行政后勤" ? UnitType.行政工勤.ToString() : t.Name;
t.Name = "行政工勤";
}); });
result = result.OrderBy(t => enumItems.FirstOrDefault(e => e.Name == t.UnitName)?.Value).ThenBy(t => t.AccountingUnit).ToList(); 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 ...@@ -886,7 +885,7 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM
// 预留比例 // 预留比例
if (response != null) 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) foreach (var item in response)
{ {
// 二次分配默认 调节系数100% // 二次分配默认 调节系数100%
...@@ -1512,7 +1511,7 @@ private UnitType TypeConversion(int? unitType) ...@@ -1512,7 +1511,7 @@ private UnitType TypeConversion(int? unitType)
{ {
UnitType type = (UnitType)unitType.Value; UnitType type = (UnitType)unitType.Value;
var docUnitTypes = new List<UnitType> { UnitType.其他医生组, UnitType.其他医技组 }; var docUnitTypes = new List<UnitType> { UnitType.其他医生组, UnitType.其他医技组 };
if (docUnitTypes.Contains(type)) if (docUnitTypes.Contains(type))
type = UnitType.医生组; type = UnitType.医生组;
else if (type == UnitType.其他护理组) else if (type == UnitType.其他护理组)
...@@ -1576,8 +1575,8 @@ public DeptDataDetails DeptOfficeDetail(int accountId) ...@@ -1576,8 +1575,8 @@ public DeptDataDetails DeptOfficeDetail(int accountId)
foreach (var sheet in persheet.Where(t => t.SheetType == stype)) foreach (var sheet in persheet.Where(t => t.SheetType == stype))
{ {
groupBasis++; groupBasis++;
var (sheettype, amount) = CommonDepartmentDetail(basicData, sheet, UnitType.行政); var (sheettype, amount) = CommonDepartmentDetail(basicData, sheet, UnitType.行政);
var items = CommonDetailItems(basicData, headers, sheet, UnitType.行政); var items = CommonDetailItems(basicData, headers, sheet, UnitType.行政);
var sheetName = new Regex("[0-9]*").Replace(sheet.SheetName, "", 5).Replace(".", "").Replace(" ", ""); var sheetName = new Regex("[0-9]*").Replace(sheet.SheetName, "", 5).Replace(".", "").Replace(" ", "");
// 只是显示好看而已 // 只是显示好看而已
......
...@@ -19,7 +19,6 @@ public class ConfigService : IAutoInjection ...@@ -19,7 +19,6 @@ public class ConfigService : IAutoInjection
private readonly IMapper _mapper; private readonly IMapper _mapper;
private readonly UserService _userService; private readonly UserService _userService;
private readonly RoleService _roleService; private readonly RoleService _roleService;
private readonly AllotService _allotService;
private readonly CopyService _copyService; private readonly CopyService _copyService;
private readonly PersonService _personService; private readonly PersonService _personService;
private readonly LogManageService _logManageService; private readonly LogManageService _logManageService;
...@@ -46,7 +45,6 @@ public class ConfigService : IAutoInjection ...@@ -46,7 +45,6 @@ public class ConfigService : IAutoInjection
IMapper mapper, IMapper mapper,
UserService userService, UserService userService,
RoleService roleService, RoleService roleService,
AllotService allotService,
CopyService copyService, CopyService copyService,
PersonService personService, PersonService personService,
LogManageService logManageService, LogManageService logManageService,
...@@ -72,7 +70,6 @@ public class ConfigService : IAutoInjection ...@@ -72,7 +70,6 @@ public class ConfigService : IAutoInjection
_mapper = mapper; _mapper = mapper;
_userService = userService; _userService = userService;
_roleService = roleService; _roleService = roleService;
_allotService = allotService;
_copyService = copyService; _copyService = copyService;
_personService = personService; _personService = personService;
_perforReport = perforReport; _perforReport = perforReport;
...@@ -563,8 +560,7 @@ public cof_accounting AccountingInsert(cof_accounting request) ...@@ -563,8 +560,7 @@ public cof_accounting AccountingInsert(cof_accounting request)
public cof_accounting AccountingUpdate(cof_accounting request) public cof_accounting AccountingUpdate(cof_accounting request)
{ {
var entity = _cofaccountingRepository.GetEntity(t => t.Id == request.Id); var entity = _cofaccountingRepository.GetEntity(t => t.Id == request.Id);
if (null == entity) if (null == entity) throw new PerformanceException($"无法找到您要修改的数据!");
throw new PerformanceException($"ID不存在 :{request.Id}");
var existed = _cofaccountingRepository.GetEntity(w => w.Id != request.Id && w.AllotId == request.AllotId && w.Code == request.Code); var existed = _cofaccountingRepository.GetEntity(w => w.Id != request.Id && w.AllotId == request.AllotId && w.Code == request.Code);
if (existed != null) throw new PerformanceException("核算单元编码重复"); if (existed != null) throw new PerformanceException("核算单元编码重复");
...@@ -597,13 +593,13 @@ public bool AccountingDelete(int accountingId) ...@@ -597,13 +593,13 @@ public bool AccountingDelete(int 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, Columns = Accounting.Select(t => new HandsonColumn(t.Value)).ToList(),
Visible = 1 ColHeaders = Accounting.Select(c => c.Value).ToList(),
}).ToList()); };
if (result.Columns != null && result.Columns.Any()) if (result.Columns != null && result.Columns.Any())
{ {
...@@ -612,7 +608,7 @@ public HandsonTable GetBatchAccountingStructrue(int AllotId) ...@@ -612,7 +608,7 @@ public HandsonTable GetBatchAccountingStructrue(int AllotId)
if (column.Data == "核算组别") if (column.Data == "核算组别")
{ {
column.Type = "autocomplete"; 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; column.Strict = true;
} }
if (column.Data == "核算单元编码") if (column.Data == "核算单元编码")
...@@ -631,7 +627,7 @@ public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request) ...@@ -631,7 +627,7 @@ public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request)
if (dicData == null || !dicData.Any()) throw new PerformanceException("未提交数据"); if (dicData == null || !dicData.Any()) throw new PerformanceException("未提交数据");
var getAccounts = _cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? new List<cof_accounting>(); var getAccounts = _cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? new List<cof_accounting>();
var unitType = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray(); var unitType = EnumHelper.GetItems<UnitType>().Select(w => w.Description).ToArray();
var json = JsonHelper.Serialize(dicData); var json = JsonHelper.Serialize(dicData);
var accounts = JsonHelper.Deserialize<List<cof_accounting>>(json) var accounts = JsonHelper.Deserialize<List<cof_accounting>>(json)
...@@ -709,48 +705,10 @@ public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request) ...@@ -709,48 +705,10 @@ public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request)
}); });
_cofaccountingRepository.AddRange(accounts.ToArray()); _cofaccountingRepository.AddRange(accounts.ToArray());
} }
_perforPerAllotRepository.AccoungtingVerify(allotId);
return new ApiResponse(ResponseType.OK); 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> public static Dictionary<string, string> Accounting { get; } = new Dictionary<string, string>
{ {
...@@ -770,7 +728,7 @@ public bool BatchCheckAccounting(int allotId) ...@@ -770,7 +728,7 @@ public bool BatchCheckAccounting(int allotId)
/// <param name="iD"></param> /// <param name="iD"></param>
public void Copy(per_allot allot) public void Copy(per_allot allot)
{ {
var prevAllotId = _allotService.GetPrevAllot(allot); var prevAllotId = _perforPerAllotRepository.GetPrevAllot(allot);
CopyCommand(allot, prevAllotId); CopyCommand(allot, prevAllotId);
} }
...@@ -799,7 +757,7 @@ public void NewCopy(CopyRequest request) ...@@ -799,7 +757,7 @@ public void NewCopy(CopyRequest request)
if (request.Type.Length < 1) return; if (request.Type.Length < 1) return;
var allot = _perallotRepository.GetEntity(t => t.ID == request.AllotId); var allot = _perallotRepository.GetEntity(t => t.ID == request.AllotId);
var prevAllotId = _allotService.GetPrevAllot(allot); var prevAllotId = _perallotRepository.GetPrevAllot(allot);
var pairs = new Dictionary<string, Action<per_allot, int>> var pairs = new Dictionary<string, Action<per_allot, int>>
{ {
...@@ -886,13 +844,13 @@ public List<TitleValue> WorkHeader(int allotId) ...@@ -886,13 +844,13 @@ public List<TitleValue> WorkHeader(int allotId)
#region HRP人员科室 #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, Columns = HrpDept.Select(t => new HandsonColumn(t.Value)).ToList(),
Visible = 1 ColHeaders = HrpDept.Select(c => c.Value).ToList(),
}).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) if (data == null)
...@@ -910,7 +868,7 @@ public HandsonTable GetHrpDeptHands(int HospitalId, int AllotId) ...@@ -910,7 +868,7 @@ public HandsonTable GetHrpDeptHands(int HospitalId, int AllotId)
rowDatas.Add(new HandsonRowData(i, cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
result.SetRowData(rowDatas, rowDatas != null); result.SetRowData(rowDatas);
return result; return result;
} }
...@@ -946,13 +904,13 @@ public void SaveDepttypeHands(int hospitalId, int allotId, SaveCollectData reque ...@@ -946,13 +904,13 @@ public void SaveDepttypeHands(int hospitalId, int allotId, SaveCollectData reque
#region 二次分配别名配置 #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, Columns = Alias.Select(t => new HandsonColumn(t.Value)).ToList(),
Visible = 1 ColHeaders = Alias.Select(c => c.Value).ToList(),
}).ToList()); };
if (result.Columns != null && result.Columns.Any()) if (result.Columns != null && result.Columns.Any())
{ {
...@@ -981,7 +939,7 @@ public HandsonTable GetSecondaryAlias() ...@@ -981,7 +939,7 @@ public HandsonTable GetSecondaryAlias()
rowDatas.Add(new HandsonRowData(i, cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
result.SetRowData(rowDatas, rowDatas != null); result.SetRowData(rowDatas);
return result; return result;
} }
...@@ -1180,9 +1138,13 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request) ...@@ -1180,9 +1138,13 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request)
return sheet; 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()) if (models == null || !models.Any())
...@@ -1341,7 +1303,7 @@ public void SaveDrugtypeFactor(DrugtypeFactorRequest request) ...@@ -1341,7 +1303,7 @@ public void SaveDrugtypeFactor(DrugtypeFactorRequest request)
#region 自定义表 #region 自定义表
public HandsonTable QueryHandsCustom(CustomPagingRequest request) public HandsonTableBase QueryHandsCustom(CustomPagingRequest request)
{ {
var custom = _perforReport.QueryCustomColumn(request.TableName); var custom = _perforReport.QueryCustomColumn(request.TableName);
...@@ -1358,7 +1320,11 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request) ...@@ -1358,7 +1320,11 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
if (dicCustom.GroupBy(x => x.Comment).Where(x => x.Count() > 1).Any()) if (dicCustom.GroupBy(x => x.Comment).Where(x => x.Count() > 1).Any())
throw new PerformanceException("表列头名称重复, 请补全注释或修改重复注释!"); 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 data = JsonHelper.Deserialize<List<Dictionary<string, string>>>(jsonData);
...@@ -1387,7 +1353,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request) ...@@ -1387,7 +1353,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
if (dicCustom.FirstOrDefault(t => t.Comment.Equals(column.Data)).Name.ToLower() == "unittype") if (dicCustom.FirstOrDefault(t => t.Comment.Equals(column.Data)).Name.ToLower() == "unittype")
{ {
column.Type = "autocomplete"; 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; column.Strict = true;
} }
...@@ -1498,13 +1464,8 @@ public ApiResponse QueryCustom(int userId, CustomPagingRequest request) ...@@ -1498,13 +1464,8 @@ public ApiResponse QueryCustom(int userId, CustomPagingRequest request)
if (customGroup.Any()) if (customGroup.Any())
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释"); 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 user = _userService.GetUser(userId);
var roleType = _roleService.GetUserRole(userId)?.FirstOrDefault()?.Type ?? 0; var roleType = _roleService.GetUserRole(userId)?.FirstOrDefault()?.Type ?? 0;
...@@ -1512,9 +1473,9 @@ public ApiResponse QueryCustom(int userId, CustomPagingRequest request) ...@@ -1512,9 +1473,9 @@ public ApiResponse QueryCustom(int userId, CustomPagingRequest request)
{ {
Heads = headList.ToList() Heads = headList.ToList()
}; };
var unitTypes = UnitTypeUtil.GetMaps(roleType);
if (dic.Keys.Contains(roleType)) if (unitTypes.Any())
result.Datas = _perforReport.QueryCustom(request.TableName, request.AllotId, user?.Department ?? "", dic[roleType], request.PageIndex, request.PageSize); result.Datas = _perforReport.QueryCustom(request.TableName, request.AllotId, user?.Department ?? "", unitTypes, request.PageIndex, request.PageSize);
else else
result.Datas = _perforReport.QueryCustom(request, false); result.Datas = _perforReport.QueryCustom(request, false);
......
...@@ -206,7 +206,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri ...@@ -206,7 +206,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
if (atUnitTypeList.Any() && !string.IsNullOrEmpty(atDepartment)) if (atUnitTypeList.Any() && !string.IsNullOrEmpty(atDepartment))
{ {
var tempDepts = depts.Where(w => atUnitTypeList.Contains(w.UnitType) && w.HISDeptName == 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 ?? ""; accountUnit = tempDepts.FirstOrDefault()?.AccountingUnit ?? "";
} }
......
...@@ -1303,14 +1303,13 @@ public List<GatherDropResponse> GetGatherDrop(int allotId) ...@@ -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, Columns = Gather.Select(t => new HandsonColumn(t.Value)).ToList(),
Visible = 1 ColHeaders = Gather.Select(t => t.Value).ToList(),
}).ToList()); };
if (result.Columns != null && result.Columns.Any()) if (result.Columns != null && result.Columns.Any())
{ {
...@@ -1346,7 +1345,7 @@ public HandsonTable GetGatherHands(int AllotId, GatherRequest request) ...@@ -1346,7 +1345,7 @@ public HandsonTable GetGatherHands(int AllotId, GatherRequest request)
rowDatas.Add(new HandsonRowData(i, cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
result.SetRowData(rowDatas, rowDatas != null); result.SetRowData(rowDatas);
return result; return result;
} }
......
...@@ -36,18 +36,6 @@ public class PersonService : IAutoInjection ...@@ -36,18 +36,6 @@ public class PersonService : IAutoInjection
private readonly Application application; private readonly Application application;
private readonly IWebHostEnvironment evn; 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( public PersonService(
IMapper mapper, IMapper mapper,
ILogger<PersonService> logger, ILogger<PersonService> logger,
...@@ -281,11 +269,13 @@ public ApiResponse CreatePerson(PerEmployeeResponse request) ...@@ -281,11 +269,13 @@ public ApiResponse CreatePerson(PerEmployeeResponse request)
int day = DateTime.DaysInMonth(allot.Year, allot.Month); int day = DateTime.DaysInMonth(allot.Year, allot.Month);
entity.Attendance = request.AttendanceDay / day; entity.Attendance = request.AttendanceDay / day;
entity.CreateTime = DateTime.Now; entity.CreateTime = DateTime.Now;
entity.IsVerify = 0; entity.IsVerify = 1;
//CheckAccountingDept(request.HospitalId.Value, request.AccountingUnit, request.Department); //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); return new ApiResponse(ResponseType.OK, "添加成功", entity);
} }
...@@ -433,20 +423,21 @@ public IEnumerable<DeptdicResponse> GetDepartments(int allotId) ...@@ -433,20 +423,21 @@ public IEnumerable<DeptdicResponse> GetDepartments(int allotId)
var allot = perallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null || !depts.Any()) return null; 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 var result = depts.GroupBy(t => new { t.HISDeptName, t.Department }).Select(t => new DeptdicResponse
{ {
AllotId = allotId, AllotId = allotId,
HospitalId = allot.HospitalId, HospitalId = allot.HospitalId,
HISDeptName = t.Key.HISDeptName, HISDeptName = t.Key.HISDeptName,
Department = t.Key.Department, 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 == "门诊")), 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 == "门诊")), 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 == "门诊")), 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 == "住院")), 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 == "住院")), 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 == "住院")), 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())), 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())), 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), CreateTime = t.Max(group => group.CreateTime),
IsVerify = t.Min(w => w.IsVerify) ?? 1, IsVerify = t.Min(w => w.IsVerify) ?? 1,
}); });
...@@ -472,19 +463,6 @@ public IEnumerable<DeptdicResponse> GetDepartments(int allotId) ...@@ -472,19 +463,6 @@ public IEnumerable<DeptdicResponse> GetDepartments(int allotId)
// return ("", new string[] { }); // return ("", new string[] { });
//} //}
private Deptdic GetDeptdic(per_dept_dic dic)
{
if (dic == null) return new Deptdic() { IsVerify = 1 };
return new Deptdic
{
Id = dic.Id,
AccountingUnit = dic.AccountingUnit,
IsVerify = dic.IsVerify ?? 1,
VerifyMessage = dic.VerifyMessage,
};
}
/// <summary> /// <summary>
/// 创建科室核算信息 /// 创建科室核算信息
/// </summary> /// </summary>
...@@ -540,6 +518,17 @@ public bool UpdateDeptDic(DeptdicResponse request) ...@@ -540,6 +518,17 @@ public bool UpdateDeptDic(DeptdicResponse request)
{ {
try 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) foreach (var item in dict)
{ {
var property = typeof(DeptdicResponse).GetProperty(item.Key); var property = typeof(DeptdicResponse).GetProperty(item.Key);
...@@ -627,11 +616,11 @@ public List<TitleValue> DeptDics(int allotId, int type) ...@@ -627,11 +616,11 @@ public List<TitleValue> DeptDics(int allotId, int type)
} }
else if (type == 3) 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) 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) else if (type == 5)
{ {
...@@ -652,17 +641,20 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId) ...@@ -652,17 +641,20 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色"); if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院"); if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院");
// 查询当前角色下科室的绩效 // 查询当前角色下科室的绩效
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes); UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes);
if (unitTypes == null || !unitTypes.Any()) return Enumerable.Empty<DeptIncomeResponse>(); if (unitTypes == null || !unitTypes.Any()) return Enumerable.Empty<DeptIncomeResponse>();
var accountingUnit = request.AccountingUnit; var accountingUnit = request.AccountingUnit;
var hospitalId = userInfo.HospitalIds.First(); var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin) if (userInfo.IsSecondAdmin)
{ {
var secondList = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department); var second = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department)?.FirstOrDefault();
accountingUnit = secondList.FirstOrDefault()?.Department; if (second != null)
unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType }; {
accountingUnit = second.Department ?? request.AccountingUnit;
unitTypes = new string[] { second.UnitType };
}
} }
var data = perallotRepository.QueryWorkloadData(request.AllotId, accountingUnit, unitTypes, hospitalId); var data = perallotRepository.QueryWorkloadData(request.AllotId, accountingUnit, unitTypes, hospitalId);
...@@ -702,9 +694,12 @@ public IEnumerable<DeptIncomeResponse> DeptIncomeDetail(WorkDetailRequest reques ...@@ -702,9 +694,12 @@ public IEnumerable<DeptIncomeResponse> DeptIncomeDetail(WorkDetailRequest reques
var hospitalId = userInfo.HospitalIds.First(); var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin) if (userInfo.IsSecondAdmin)
{ {
var secondList = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department); var second = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department)?.FirstOrDefault();
accountingUnit = secondList.FirstOrDefault()?.Department; if (second != null)
unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType }; {
accountingUnit = second.Department ?? request.AccountingUnit;
unitTypes = new string[] { second.UnitType };
}
} }
...@@ -730,12 +725,14 @@ public IEnumerable<DeptIncomeResponse> DeptIncomeDetail(WorkDetailRequest reques ...@@ -730,12 +725,14 @@ public IEnumerable<DeptIncomeResponse> DeptIncomeDetail(WorkDetailRequest reques
} }
public HandsonTable GetBatchPersonStructrue(int allotId) public HandsonTableBase GetBatchPersonStructrue(int allotId)
{ {
var cols = Person.Select(t => t.Item2).ToArray(); HandsonTableBase result = new HandsonTableBase()
var permissions = Person.Select(t => new collect_permission { HeadName = t.Item2, Visible = 1 }).ToList(); {
Columns = Person.Select(t => new HandsonColumn(t.Item2)).ToList(),
ColHeaders = Person.Select(t => t.Item2).ToList(),
};
var result = new HandsonTable((int)SheetType.Unidentifiable, cols, permissions);
var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == allotId); var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
var ss = deptdics?.Where(t => !new string[] { "专家组" }.Contains(t.UnitType)); var ss = deptdics?.Where(t => !new string[] { "专家组" }.Contains(t.UnitType));
if (result.Columns != null && result.Columns.Any()) if (result.Columns != null && result.Columns.Any())
...@@ -749,7 +746,7 @@ public HandsonTable GetBatchPersonStructrue(int allotId) ...@@ -749,7 +746,7 @@ public HandsonTable GetBatchPersonStructrue(int allotId)
if (column.Data == "核算组别") if (column.Data == "核算组别")
{ {
column.Type = "autocomplete"; 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; column.Strict = true;
} }
else if (new[] { "出勤天数", "预留比例" }.Contains(column.Data)) else if (new[] { "出勤天数", "预留比例" }.Contains(column.Data))
...@@ -762,14 +759,13 @@ public HandsonTable GetBatchPersonStructrue(int allotId) ...@@ -762,14 +759,13 @@ public HandsonTable GetBatchPersonStructrue(int allotId)
return result; return result;
} }
public HandsonTable GetDepartmentHands(int allotId) 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, Columns = DeptDic.Select(t => new HandsonColumn(t.Value)).ToList(),
Visible = 1, ColHeaders = DeptDic.Select(c => c.Value).ToList(),
Readnoly = 0 };
}).ToList());
#region 科室下拉 #region 科室下拉
//if (handson.Columns != null && handson.Columns.Any()) //if (handson.Columns != null && handson.Columns.Any())
//{ //{
...@@ -811,7 +807,7 @@ public HandsonTable GetDepartmentHands(int allotId) ...@@ -811,7 +807,7 @@ public HandsonTable GetDepartmentHands(int allotId)
return handson; 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>(); var dict = new Dictionary<string, string>();
Person.ForEach(t => dict.Add(t.Item1, t.Item2)); Person.ForEach(t => dict.Add(t.Item1, t.Item2));
...@@ -822,16 +818,12 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r ...@@ -822,16 +818,12 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r
var jsons = JsonHelper.Serialize(dicData); var jsons = JsonHelper.Serialize(dicData);
var newEmployees = JsonHelper.Deserialize<List<per_employee>>(jsons); 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>>(); List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
for (int i = 0; i < newEmployees.Count; i++) for (int i = 0; i < newEmployees.Count; i++)
{ {
if (newEmployees[i].PersonnelNumber?.Trim() == "2095")
{
}
if (string.IsNullOrEmpty(newEmployees[i].UnitType?.Trim()) if (string.IsNullOrEmpty(newEmployees[i].UnitType?.Trim())
|| string.IsNullOrEmpty(newEmployees[i].Department?.Trim()) || string.IsNullOrEmpty(newEmployees[i].Department?.Trim())
|| string.IsNullOrEmpty(newEmployees[i].AccountingUnit?.Trim()) || string.IsNullOrEmpty(newEmployees[i].AccountingUnit?.Trim())
...@@ -847,7 +839,18 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r ...@@ -847,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) if (newEmployees.Count(w => w.PersonnelNumber == newEmployees[i].PersonnelNumber) > 1)
{ {
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
...@@ -905,12 +908,13 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r ...@@ -905,12 +908,13 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r
if (oldEmployees != null && oldEmployees.Any(t => t.PersonnelNumber?.Trim() == data.PersonnelNumber?.Trim())) if (oldEmployees != null && oldEmployees.Any(t => t.PersonnelNumber?.Trim() == data.PersonnelNumber?.Trim()))
delPersonsNum.Add(data.PersonnelNumber); delPersonsNum.Add(data.PersonnelNumber);
data.UnitType = data.UnitType.Replace("行政后勤", "行政工勤");
data.HospitalId = HospitalId; data.HospitalId = HospitalId;
data.AllotId = AllotId; data.AllotId = allotId;
data.DoctorName = data.DoctorName?.Trim(); data.DoctorName = data.DoctorName?.Trim();
data.PersonnelNumber = data.PersonnelNumber?.Trim(); data.PersonnelNumber = data.PersonnelNumber?.Trim();
data.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")); data.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd"));
data.IsVerify = 0; data.IsVerify = 1;
employees.Add(data); employees.Add(data);
} }
} }
...@@ -921,6 +925,8 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r ...@@ -921,6 +925,8 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r
if (employees != null && employees.Any()) if (employees != null && employees.Any())
peremployeeRepository.AddRange(employees.ToArray()); peremployeeRepository.AddRange(employees.ToArray());
perallotRepository.AccoungtingVerify(allotId);
return new ApiResponse(ResponseType.OK, ""); return new ApiResponse(ResponseType.OK, "");
} }
......
...@@ -331,7 +331,7 @@ private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId ...@@ -331,7 +331,7 @@ private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId
logger.LogInformation($"人均绩效计算"); logger.LogInformation($"人均绩效计算");
Dictionary<string, string> basicDict = new Dictionary<string, string> Dictionary<string, string> basicDict = new Dictionary<string, string>
{ {
{ "行政工勤人均绩效", UnitType.行政.ToString() }, { "行政工勤人均绩效", UnitType.行政.ToString() },
{ "临床医生人均绩效", UnitType.医生组.ToString() }, { "临床医生人均绩效", UnitType.医生组.ToString() },
{ "医技医生人均绩效", UnitType.医技组.ToString() }, { "医技医生人均绩效", UnitType.医技组.ToString() },
{ "护士人均绩效", UnitType.护理组.ToString() }, { "护士人均绩效", UnitType.护理组.ToString() },
...@@ -634,7 +634,7 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId, ...@@ -634,7 +634,7 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId,
var hos = _hospitalRepository.GetEntity(t => t.ID == hospitalId); var hos = _hospitalRepository.GetEntity(t => t.ID == hospitalId);
var employees = perforPeremployeeRepository.GetEntities(t => t.AllotId == allotId); var employees = perforPeremployeeRepository.GetEntities(t => t.AllotId == allotId);
if (employees == null || !employees.Any()) throw new PerformanceException("人员字典中未保存数据"); if (employees == null || !employees.Any()) throw new PerformanceException("人员字典中未保存数据");
var alias = _computeService.CustomColumnHeaders(hos, "/result/all_employee"); var alias = _computeService.CustomColumnHeaders(hos, "/result/all_employee");
var dicData = CreateDataRow(hospitalId, request, alias); var dicData = CreateDataRow(hospitalId, request, alias);
var tags = reportperformancepersontagsRepository.GetEntities(t => t.HospitalId == hospitalId); var tags = reportperformancepersontagsRepository.GetEntities(t => t.HospitalId == hospitalId);
...@@ -757,13 +757,13 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId, ...@@ -757,13 +757,13 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId,
return new ApiResponse(ResponseType.OK); 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, Columns = ReportTag.Select(t => new HandsonColumn(t.Value)).ToList(),
Visible = 1 ColHeaders = ReportTag.Select(t => t.Value).ToList(),
}).ToList()); };
var data = reportperformancetagsRepository.GetEntities(t => t.HospitalId == hospitalId)?.OrderBy(t => t.UnitType); var data = reportperformancetagsRepository.GetEntities(t => t.HospitalId == hospitalId)?.OrderBy(t => t.UnitType);
if (data == null) return result; if (data == null) return result;
...@@ -780,7 +780,7 @@ public HandsonTable GetReportTag(int hospitalId) ...@@ -780,7 +780,7 @@ public HandsonTable GetReportTag(int hospitalId)
rowDatas.Add(new HandsonRowData(i, cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
result.SetRowData(rowDatas, rowDatas != null); result.SetRowData(rowDatas);
return result; return result;
} }
......
...@@ -654,7 +654,7 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se ...@@ -654,7 +654,7 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
#region 其他模板详情 #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[] { }; string[] workNumbers = new string[] { };
var details = GetOtherTempDetails(userId, secondId, isArchive, employeeSource); var details = GetOtherTempDetails(userId, secondId, isArchive, employeeSource);
...@@ -666,12 +666,11 @@ public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, in ...@@ -666,12 +666,11 @@ public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, in
OtherTemp.Select(t => t.Value).ToArray() : OtherTemp.Select(t => t.Value).ToArray() :
new string[] { "可分配绩效", "科室单项奖励", "医院其他绩效", "预留年度考核比例", "年度考核发放金额", "预发绩效工资金额" }; 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, Columns = OtherTemp.Select(t => new HandsonColumn(t.Value)).ToList(),
Visible = 1, ColHeaders = OtherTemp.Select(t => t.Value).ToList(),
Readnoly = readColumns.Contains(t.Value) ? 1 : 0 };
}).ToList());
if (result.Columns != null && result.Columns.Any()) if (result.Columns != null && result.Columns.Any())
{ {
...@@ -707,7 +706,7 @@ public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, in ...@@ -707,7 +706,7 @@ public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, in
rowDatas.Add(new HandsonRowData(i, cells)); rowDatas.Add(new HandsonRowData(i, cells));
i++; i++;
} }
result.SetRowData(rowDatas, rowDatas != null); result.SetRowData(rowDatas);
return result; return result;
} }
...@@ -825,7 +824,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em ...@@ -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()); var empl = employees?.FirstOrDefault(w => w.PersonnelNumber?.Trim() == item.WorkNumber?.Trim());
item.ReservedRatio = empl?.ReservedRatio ?? 0; 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); item.WorkPerformance = distPerformance?.Where(w => w.AccountingUnit == item.Department && w.JobNumber?.Trim() == item.WorkNumber?.Trim())?.Sum(w => w.GiveFee);
if (string.IsNullOrEmpty(item.WorkNumber)) if (string.IsNullOrEmpty(item.WorkNumber))
...@@ -835,7 +834,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em ...@@ -835,7 +834,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
if (second.UnitType.Replace("其他", "").Replace("医技", "医生") if (second.UnitType.Replace("其他", "").Replace("医技", "医生")
== (empl?.UnitType ?? "").Replace("其他", "").Replace("医技", "医生")) == (empl?.UnitType ?? "").Replace("其他", "").Replace("医技", "医生"))
{ {
if (second.UnitType == UnitType.行政后勤.ToString()) if (UnitTypeUtil.IsOffice(second.UnitType))
{ {
if (string.IsNullOrEmpty(item.WorkNumber)) if (string.IsNullOrEmpty(item.WorkNumber))
{ {
......
...@@ -1518,10 +1518,10 @@ public List<ag_secondallot> AuditList(int allotId) ...@@ -1518,10 +1518,10 @@ public List<ag_secondallot> AuditList(int allotId)
if (allot == null) if (allot == null)
throw new PerformanceException("所选绩效不存在!"); 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 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) if (xzAccountUnit != null && xzAccountUnit.Count > 0)
(accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit); (accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
...@@ -2089,7 +2089,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em ...@@ -2089,7 +2089,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)); var distPerformance = rescomputeRepository.GetEntities(t => t.AllotID == second.AllotId && employees.Select(s => s.PersonnelNumber).Contains(t.JobNumber));
Func<per_employee, decimal?> getDistPerformance = (t) => 0; Func<per_employee, decimal?> getDistPerformance = (t) => 0;
if (second.UnitType == UnitType.行政后勤.ToString()) if (UnitTypeUtil.IsOffice(second.UnitType))
getDistPerformance = (t) => second.Department == t.AccountingUnit ? distPerformance getDistPerformance = (t) => second.Department == t.AccountingUnit ? distPerformance
?.Where(w => w.JobNumber?.Trim() == t.PersonnelNumber?.Trim()) ?.Where(w => w.JobNumber?.Trim() == t.PersonnelNumber?.Trim())
?.Sum(w => w.GiveFee) : 0; ?.Sum(w => w.GiveFee) : 0;
...@@ -2457,7 +2457,7 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out ...@@ -2457,7 +2457,7 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out
accountingUnit = secondList.FirstOrDefault()?.Department; accountingUnit = secondList.FirstOrDefault()?.Department;
unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType }; unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType };
} }
Dictionary<int, List<string>> dict = new Dictionary<int, List<string>> Dictionary<int, List<string>> dict = new Dictionary<int, List<string>>
{ {
{ (int)Role.科主任, new List<string>{ AccountUnitType.科主任.ToString()} }, { (int)Role.科主任, new List<string>{ AccountUnitType.科主任.ToString()} },
...@@ -2467,7 +2467,7 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out ...@@ -2467,7 +2467,7 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out
}; };
var computes = rescomputeRepository.GetEntities(t => t.AllotID == allotId && t.AccountingUnit == accountingUnit && unitTypes.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>(); if (computes == null || !computes.Any()) return new List<DeptDataDetails>();
foreach (var item in computes) foreach (var item in computes)
{ {
......
...@@ -19,10 +19,11 @@ public class UnitTypeUtil ...@@ -19,10 +19,11 @@ public class UnitTypeUtil
public static Dictionary<int, string[]> Maps { get; } = new Dictionary<int, string[]> 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(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ (int)Role.护士长, new string[]{ UnitType.护理组.ToString(), } }, { (int)Role.护士长, new string[]{ UnitType.护理组.ToString(), UnitType.其他护理组.ToString() } },
{ (int)Role.特殊科室, new string[]{ UnitType.特殊核算组.ToString(), } }, { (int)Role.特殊科室, new string[]{ 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>(); public static string[] GetMaps(int? key) => (key.HasValue && Maps.ContainsKey(key.Value)) ? Maps[key.Value] : Array.Empty<string>();
...@@ -33,7 +34,7 @@ public class UnitTypeUtil ...@@ -33,7 +34,7 @@ public class UnitTypeUtil
/// <returns></returns> /// <returns></returns>
public static bool IsOffice(int? unit) public static bool IsOffice(int? unit)
{ {
return unit == (int)UnitType.行政; return unit == (int)UnitType.行政;
} }
/// <summary> /// <summary>
......
...@@ -727,16 +727,19 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -727,16 +727,19 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
try try
{ {
var dicData = CreateDataRow(request, Users); var dicData = CreateDataRow(request, Users);
var allDataList = dicData.Select(item => JsonHelper.Deserialize<UserHandsResponse>(JsonHelper.Serialize(item))).ToList();
var getUsers = _userRepository.GetEntities(); var getUsers = _userRepository.GetEntities();
var roles = _roleRepository.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> users = new List<sys_user>();
List<sys_user_role> userRoles = new List<sys_user_role>(); List<sys_user_role> userRoles = new List<sys_user_role>();
List<sys_user_hospital> userHoss = new List<sys_user_hospital>(); List<sys_user_hospital> userHoss = new List<sys_user_hospital>();
var roleArr = new string[] { Role.护士长.ToString(), Role.科主任.ToString(), Role.特殊科室.ToString(), Role.行政科室.ToString() };
var allDataList = dicData.Select(item => JsonHelper.Deserialize<UserHandsResponse>(JsonHelper.Serialize(item))).ToList();
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>(); List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
for (int i = 0; i < allDataList.Count(); i++) for (int i = 0; i < allDataList.Count(); i++)
...@@ -759,8 +762,9 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -759,8 +762,9 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ "核算单元", allDataList[i].Department.ToString() ?? "" }, { "核算单元", allDataList[i].Department.ToString() ?? "" },
{ "错误原因", "“关键信息缺失”请补全或删除" }, { "错误原因", "“关键信息缺失”请补全或删除" },
}); });
continue;
} }
else if (!Enum.IsDefined(typeof(Role), allDataList[i].RoleName)) if (!Enum.IsDefined(typeof(Role), allDataList[i].RoleName))
{ {
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -773,7 +777,7 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -773,7 +777,7 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ "错误原因", "“角色”错误,请修改或删除" }, { "错误原因", "“角色”错误,请修改或删除" },
}); });
} }
else if (!hospitals.Any(w => w.HosName == (allDataList[i].HosName?.Trim()))) if (!hospitals.Any(w => w.HosName == (allDataList[i].HosName?.Trim())))
{ {
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -787,7 +791,7 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -787,7 +791,7 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
}); });
} }
else if (getUsers.Any(c => c.Login == allDataList[i].Login?.Trim())) if (getUsers.Any(c => c.Login == allDataList[i].Login?.Trim()))
{ {
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -800,11 +804,12 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -800,11 +804,12 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ "错误原因", "“登录名”已存在,请修改或删除" }, { "错误原因", "“登录名”已存在,请修改或删除" },
}); });
} }
if (roleArr.Contains(allDataList[i].RoleName?.Trim())) 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 role = (Role)Enum.Parse(typeof(Role), allDataList[i].RoleName);
var uninTypes = UnitTypeUtil.GetMaps((int)role); var uninTypes = UnitTypeUtil.GetMaps((int)role);
var cts = accounts.FirstOrDefault(w => w.AccountingUnit == allDataList[i].Department?.Trim() && uninTypes.Contains(w.UnitType)); var cts = accounts.FirstOrDefault(w => w.HospitalId == hospitalId && w.AccountingUnit == allDataList[i].Department?.Trim() && uninTypes.Contains(w.UnitType));
if (cts == null) if (cts == null)
{ {
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
...@@ -827,13 +832,14 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request) ...@@ -827,13 +832,14 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ {
if (users.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 role = (Role)Enum.Parse(typeof(Role), data.RoleName);
var uninTypes = UnitTypeUtil.GetMaps((int)role); var uninTypes = UnitTypeUtil.GetMaps((int)role);
cof_accounting cts = accounts.FirstOrDefault(w => w.AccountingUnit == allDataList[i].Department?.Trim() && uninTypes.Contains(w.UnitType)); var cts = accounts.FirstOrDefault(w => w.HospitalId == hospitalId && w.AccountingUnit == data.Department?.Trim() && uninTypes.Contains(w.UnitType));
var user = new sys_user var user = new sys_user
{ {
RealName = data.RealName, RealName = data.RealName,
CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")), CreateDate = DateTime.Now,
CreateUser = request.CreateUser, CreateUser = request.CreateUser,
Department = data?.Department.Trim() ?? "", Department = data?.Department.Trim() ?? "",
UnitType = cts?.UnitType ?? "", UnitType = cts?.UnitType ?? "",
......
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