大量改动

行政后期修改为行政工勤
核算单元及组别验证优化
HandsonTable返回优化
预留绩效兼容核算单元变更
用户粘贴功能优化
parent 43238061
......@@ -194,7 +194,7 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request)
{
second = _computeService.GetSecondByAccountId(request.AccountID);
}
else if (request.AccountID != 0 && request.UnitType == (int)UnitType.行政)
else if (request.AccountID != 0 && request.UnitType == (int)UnitType.行政)
{
var response = _computeService.DeptOfficeDetail(request.AccountID);
return new ApiResponse(ResponseType.OK, response);
......@@ -205,7 +205,7 @@ public ApiResponse DeptDetail([FromBody] DeptDetailRequest request)
var response = _computeService.SpecialDeptDetail(second);
return new ApiResponse(ResponseType.OK, response);
}
else if (second != null && second.UnitType == UnitType.行政后勤.ToString())
else if (second != null && UnitTypeUtil.IsOffice(second.UnitType))
{
var response = _computeService.DeptOfficeDetail(request.AccountID);
return new ApiResponse(ResponseType.OK, response);
......
......@@ -699,8 +699,8 @@ public ApiResponse BatchAccountingStructrue([FromRoute] int allotId)
[HttpPost]
public ApiResponse BatchCheckAccounting(int allotId)
{
_configService.BatchCheckAccounting(allotId);
return new ApiResponse(ResponseType.OK, "校验通过");
_allotService.AccoungtingVerify(allotId);
return new ApiResponse(ResponseType.OK, "校验完成");
}
/// <summary>
......
......@@ -3353,6 +3353,16 @@
核算单元
</summary>
</member>
<member name="P:Performance.DtoModels.EmployeeReservedDto.NewUnitType">
<summary>
</summary>
</member>
<member name="P:Performance.DtoModels.EmployeeReservedDto.NewAccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="P:Performance.DtoModels.EmployeeReservedDto.EmployeeName">
<summary>
人员姓名
......
......@@ -8870,6 +8870,21 @@
</summary>
</member>
<member name="P:Performance.EntityModels.CofAccountingEntity.UnitType">
<summary>
核算单元类型
</summary>
</member>
<member name="P:Performance.EntityModels.CofAccountingEntity.AccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.CofAccountingEntity.Code">
<summary>
核算单元编码
</summary>
</member>
<member name="P:Performance.EntityModels.Other.view_attendance.UnitType">
<summary>
人员类别
......
......@@ -20,6 +20,28 @@ public HandsonTableBase()
public List<Dictionary<string, object>> Data { get; set; }
public List<HandsonColumn> Columns { get; set; }
public object[] NestedHeadersArray { get; set; }
public void SetRowData(IEnumerable<HandsonRowData> datas)
{
foreach (var dt in datas)
{
var dic = CreateDataRow("编号", dt.Row.ToString());
foreach (var item in dt.CellData)
{
dic[item.Name.ToLower()] = item.Value?.ToString() ?? "";
}
Data.Add(dic);
}
}
protected Dictionary<string, object> CreateDataRow(string key, string value)
{
var temp = new Dictionary<string, object>() { { key, value } };
foreach (var item in ColHeaders)
{
if (!temp.ContainsKey(item))
temp.Add(item.ToLower(), "");
}
return temp;
}
}
public class HandsonTable : HandsonTableBase
......@@ -95,17 +117,6 @@ private void InitColumns(List<collect_permission> permissions)
}
Columns = columns;
}
private Dictionary<string, object> CreateDataRow(string key, string value)
{
var temp = new Dictionary<string, object>() { { key, value } };
foreach (var item in ColHeaders)
{
if (!temp.ContainsKey(item))
temp.Add(item.ToLower(), "");
}
return temp;
}
}
public class HandsonColumn
......
......@@ -27,6 +27,16 @@ public class EmployeeReservedDto
public string AccountingUnit { get; set; }
/// <summary>
///
/// </summary>
public string NewUnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string NewAccountingUnit { get; set; }
/// <summary>
/// 人员姓名
/// </summary>
public string EmployeeName { get; set; }
......
......@@ -89,6 +89,6 @@ public enum UnitType
[Description("行政中层")]
行政中层 = 11,
[Description("行政勤")]
行政 = 12,
[Description("行政勤")]
行政 = 12,
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.EntityModels
{
public class CofAccountingEntity
{
public int HospitalId { get; set; }
/// <summary>
/// 核算单元类型
/// </summary>
public string UnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
/// <summary>
/// 核算单元编码
/// </summary>
public string Code { get; set; }
}
}
using Performance.EntityModels;
using System.Collections.Generic;
using System.Linq;
namespace Performance.Repository
{
public partial class PerforCofaccountingRepository : PerforRepository<cof_accounting>
{
public List<CofAccountingEntity> GetAccounting(params int[] hospitalIds)
{
var cofAccountings = from p in context.Set<per_allot>().Where(w => hospitalIds.Contains(w.HospitalId))
join a in context.Set<cof_accounting>()
on p.ID equals a.AllotId
select new { Allot = p, Accounting = a };
return cofAccountings
.Select(w => new { w.Allot.HospitalId, w.Accounting.AccountingUnit, w.Accounting.UnitType, w.Accounting.Code })
.Distinct()
.Select(w => new CofAccountingEntity
{
HospitalId = w.HospitalId,
Code = w.Code,
UnitType = w.UnitType,
AccountingUnit = w.AccountingUnit,
})
.ToList();
}
}
}
......@@ -28,6 +28,41 @@ public bool UpdateAllotStates(int allotId, int states, string remark, int genera
allot.Generate = generate;
return Update(allot);
}
#region 先取上一个月的绩效Id
/// <summary>
/// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
/// </summary>
/// <param name="allot"></param>
public int GetPrevAllot(int allotId)
{
var allot = context.Set<per_allot>().FirstOrDefault(t => t.ID == allotId);
if (allot == null)
return -1;
return GetPrevAllot(allot);
}
/// <summary>
/// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
/// </summary>
/// <param name="allot"></param>
public int GetPrevAllot(per_allot allot)
{
var list = context.Set<per_allot>().Where(t => t.HospitalId == allot.HospitalId).ToList();
if (list == null || !list.Any(t => t.ID == allot.ID))
return -1;
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
int allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID)
return -1;
return allotId;
}
#endregion
/// <summary>
/// 执行存储过程
......@@ -318,5 +353,25 @@ public IEnumerable<dynamic> QueryEmployee(int allotId)
}
}
}
/// <summary>
/// 验证科室核算单元、工号
/// </summary>
/// <param name="allot"></param>
public void AccoungtingVerify(int allotId)
{
using (var connection = context.Database.GetDbConnection())
{
if (connection.State != ConnectionState.Open) connection.Open();
try
{
connection.Execute("call proc_verify_accoungingunit_unittype(@allotId);", new { allotId }, commandTimeout: 60 * 60);
}
catch (Exception)
{
throw;
}
}
}
}
}
\ No newline at end of file
......@@ -391,6 +391,21 @@ public List<EmployeeReservedDto> GetEmployeeReserved(int hospitalId, int year)
return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = hospitalId, Year = year })?.ToList();
}
/// <summary>
/// 获取医院预留绩效
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="year"></param>
/// <returns></returns>
public List<EmployeeReservedDto> GetEmployeeReserved(int hospitalId, int year, string[] unitTypes, string accountingUnit)
{
string sql = @"
SELECT * FROM view_allot_result_report WHERE HospitalID=@HospitalID AND Year=@Year
AND ((UnitType IN @unitTypes AND AccountingUnit = @accountingUnit) OR (NewUnitType IN @unitTypes AND NewAccountingUnit = @accountingUnit))
";
return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = hospitalId, Year = year, unitTypes, accountingUnit })?.ToList();
}
public List<view_allot_result> GetOwnerPerformance(List<int> hospitalId, string jobNumber)
{
string sql = "SELECT * FROM view_allot_result WHERE States IN (6,8) AND HospitalID IN @HospitalID AND JobNumber=@JobNumber";
......
......@@ -11,7 +11,7 @@ namespace Performance.Repository
/// <summary>
/// cof_accounting Repository
/// </summary>
public class PerforCofaccountingRepository : PerforRepository<cof_accounting>
public partial class PerforCofaccountingRepository : PerforRepository<cof_accounting>
{
public PerforCofaccountingRepository(PerformanceDbContext context) : base(context)
{
......
......@@ -519,7 +519,7 @@ public void GenerateSecondAllot(per_allot allot)
List<ag_secondallot> updSecond = new List<ag_secondallot>();
List<ag_secondallot> delSecond = new List<ag_secondallot>();
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政 };
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政 };
//// 获取医院是否开启后勤二次分配
//var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
//if (hospital?.IsOpenLogisticsSecondAllot != 1)
......@@ -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 xzAccountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是");
var xzAccountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是");
if (xzAccountUnit != null && xzAccountUnit.Count > 0)
(accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
......
......@@ -121,40 +121,6 @@ public class AllotService : IAutoInjection
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 基础功能
/// <summary>
......@@ -486,7 +452,7 @@ public void Generate(per_allot allot)
UpdateAllotStates(allot.ID, (int)AllotStates.绩效结果解析成功, EnumHelper.GetDescription(AllotStates.绩效结果解析成功), generate);
perforCofdirectorRepository.SupplementaryData(allot.ID);
// 验证科室核算单元、工号
AccoungtingVerify(allot.ID);
_allotRepository.AccoungtingVerify(allot.ID);
//补全支出费用类别
configService.SaveDrugtypeDisburse(allot.ID);
//logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true);
......@@ -532,10 +498,7 @@ public void GenerateReport(per_allot allot)
/// <param name="allot"></param>
public void AccoungtingVerify(int allotId)
{
using (IDbConnection connection = new MySqlConnection(_appConnection.Value.PerformanceConnectionString))
{
connection.Execute("call proc_verify_accoungingunit_unittype(@allotId);", new { allotId });
}
_allotRepository.AccoungtingVerify(allotId);
}
/// <summary>
......@@ -692,18 +655,15 @@ public List<EmployeeReservedDto> GetReserved(int hospitalId, int year, int useri
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
var reserveds = _reportRepository.GetEmployeeReserved(hospitalId, year);
if (reserveds != null && reserveds.Any())
if (userInfo.IsSecondAdmin)
{
var unitTpes = UnitTypeUtil.GetMaps(userInfo?.URole.Type);
Expression<Func<EmployeeReservedDto, bool>> exp = w => w.AccountingUnit == userInfo.User.Department;
if (userInfo.URole.Type.HasValue && UnitTypeUtil.Maps.ContainsKey(userInfo.URole.Type.Value))
exp = exp.And(t => unitTpes.Contains(t.UnitType));
reserveds = reserveds.Where(exp.Compile())?.ToList();
return _reportRepository.GetEmployeeReserved(hospitalId, year, unitTpes, userInfo.User.Department);
}
else
{
return _reportRepository.GetEmployeeReserved(hospitalId, year);
}
return reserveds;
}
/// <summary>
/// 查询个人绩效
......
......@@ -116,14 +116,13 @@ public ApiResponse<List<view_attendance>> GetCallIn(int allotId)
}
}
public HandsonTable GetBatchCallInHandsonTable(int allotId)
public HandsonTableBase GetBatchCallInHandsonTable(int allotId)
{
HandsonTable handson = new HandsonTable((int)SheetType.Unidentifiable, Person.Select(c => c.Item2).ToArray(), Person.Select(t => new collect_permission
HandsonTableBase handson = new HandsonTableBase()
{
HeadName = t.Item2,
Visible = 1,
Readnoly = 0
}).ToList());
Columns = Person.Select(t => new HandsonColumn(t.Item2)).ToList(),
ColHeaders = Person.Select(c => c.Item2).ToList(),
};
if (handson.Columns != null && handson.Columns.Any())
{
var cofaccounting = cofaccountingRepository.GetEntities(w => w.UnitType != "" && w.AllotId == allotId);
......@@ -133,7 +132,6 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
if (column.Data == "调入组别")
{
column.Type = "autocomplete";
//column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
column.Source = cofaccounting.Select(w => w.UnitType).Distinct().ToArray();
column.Strict = true;
}
......@@ -141,16 +139,9 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
if (column.Data == "调入核算单元")
{
column.Type = "autocomplete";
//column.Source = EnumHelper.GetItems<AccountUnitType>().Where(w => w.Description != "").Select(w => w.Description).ToArray();
column.Source = cofaccounting.Select(w => w.AccountingUnit).Distinct().ToArray();
column.Strict = true;
}
//if (column.Data == "调入时间")
//{
// column.Type = "date";
// column.DateFormat = "YYYY/MM/DD";
//}
}
}
List<view_attendance> data = new List<view_attendance>();
......@@ -184,7 +175,7 @@ public HandsonTable GetBatchCallInHandsonTable(int allotId)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
handson.SetRowData(rowDatas, rowDatas != null);
handson.SetRowData(rowDatas);
foreach (var item in handson.Data)
{
item.Remove("编号");
......@@ -386,25 +377,19 @@ public ApiResponse DeleteAttendanceType(int id)
#endregion
#region 考勤记录
public HandsonTable GetAttendanceVacationHandsonTable(int allotId)
public HandsonTableBase GetAttendanceVacationHandsonTable(int allotId)
{
HandsonTable handson = new HandsonTable((int)SheetType.Unidentifiable, Vacation.Select(c => c.Item2).ToArray(), Vacation.Select(t => new collect_permission
HandsonTableBase handson = new HandsonTableBase()
{
HeadName = t.Item2,
Visible = 1,
Readnoly = 0
}).ToList());
Columns = Vacation.Select(t => new HandsonColumn(t.Item2)).ToList(),
ColHeaders = Vacation.Select(c => c.Item2).ToList(),
};
if (handson.Columns != null && handson.Columns.Any())
{
var type = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId);
foreach (var column in handson.Columns)
{
column.Type = "text";
//if (column.Data.Contains("时间"))
//{
// column.Type = "date";
// column.DateFormat = "YYYY/MM/DD";
//}
if (column.Data == "考勤类型")
{
column.Type = "autocomplete";
......@@ -444,7 +429,7 @@ public HandsonTable GetAttendanceVacationHandsonTable(int allotId)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
handson.SetRowData(rowDatas, rowDatas != null);
handson.SetRowData(rowDatas);
foreach (var item in handson.Data)
{
item.Remove("编号");
......
......@@ -326,7 +326,7 @@ public List<DeptResponse> GetGroupPerformance(int allotId, List<int> group)
/// <returns></returns>
public List<DeptResponse> GetOfficePerformance(int allotId)
{
var unitType = new List<int> { (int)UnitType.行政 };
var unitType = new List<int> { (int)UnitType.行政 };
var list = perforResaccountRepository.GetEntities(t => unitType.Contains(t.UnitType.Value) && t.AllotID == allotId && t.NeedSecondAllot == "是")
?.OrderBy(t => t.UnitType)
......@@ -565,7 +565,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
#region 需要二次分配的行政科室
// 需要二次分配的行政科室
var needSecond = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是") ?? new List<res_account>();
var needSecond = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是") ?? new List<res_account>();
var needSecondResult = needSecond.Select(t => new DeptResponse
{
UnitName = ((UnitType)t.UnitType).ToString() == "行政后勤" ? "行政工勤" : ((UnitType)t.UnitType).ToString(),
......@@ -712,8 +712,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
enumItems.ForEach(t =>
{
t.Value = UnitTypeUtil.Is(t.Name, UnitType.护理组) ? t.Value + 2 : t.Value;
if (t.Name == UnitType.行政后勤.ToString())
t.Name = "行政工勤";
t.Name = t.Name == "行政后勤" ? UnitType.行政工勤.ToString() : t.Name;
});
result = result.OrderBy(t => enumItems.FirstOrDefault(e => e.Name == t.UnitName)?.Value).ThenBy(t => t.AccountingUnit).ToList();
......@@ -886,7 +885,7 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM
// 预留比例
if (response != null)
{
var types = new string[] { UnitType.行政高层.ToString(), UnitType.行政中层.ToString(), UnitType.行政后勤.ToString(), "行政工勤" };
var types = new string[] { UnitType.行政高层.ToString(), UnitType.行政中层.ToString(), UnitType.行政工勤.ToString(), "行政后勤" };
foreach (var item in response)
{
// 二次分配默认 调节系数100%
......@@ -1512,7 +1511,7 @@ private UnitType TypeConversion(int? unitType)
{
UnitType type = (UnitType)unitType.Value;
var docUnitTypes = new List<UnitType> { UnitType.其他医生组, UnitType.其他医技组 };
var docUnitTypes = new List<UnitType> { UnitType.其他医生组, UnitType.其他医技组 };
if (docUnitTypes.Contains(type))
type = UnitType.医生组;
else if (type == UnitType.其他护理组)
......@@ -1576,8 +1575,8 @@ public DeptDataDetails DeptOfficeDetail(int accountId)
foreach (var sheet in persheet.Where(t => t.SheetType == stype))
{
groupBasis++;
var (sheettype, amount) = CommonDepartmentDetail(basicData, sheet, UnitType.行政);
var items = CommonDetailItems(basicData, headers, sheet, UnitType.行政);
var (sheettype, amount) = CommonDepartmentDetail(basicData, sheet, UnitType.行政);
var items = CommonDetailItems(basicData, headers, sheet, UnitType.行政);
var sheetName = new Regex("[0-9]*").Replace(sheet.SheetName, "", 5).Replace(".", "").Replace(" ", "");
// 只是显示好看而已
......
......@@ -206,7 +206,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
if (atUnitTypeList.Any() && !string.IsNullOrEmpty(atDepartment))
{
var tempDepts = depts.Where(w => atUnitTypeList.Contains(w.UnitType) && w.HISDeptName == atDepartment);
if (isSecondAdmin && unitType.Any(w => w == UnitType.特殊核算组.ToString() || w == UnitType.行政后勤.ToString()))
if (isSecondAdmin && unitType.Any(w => w == UnitType.特殊核算组.ToString() || UnitTypeUtil.Office.Contains(w)))
{
accountUnit = tempDepts.FirstOrDefault()?.AccountingUnit ?? "";
}
......
......@@ -1303,14 +1303,13 @@ public List<GatherDropResponse> GetGatherDrop(int allotId)
}
public HandsonTable GetGatherHands(int AllotId, GatherRequest request)
public HandsonTableBase GetGatherHands(int AllotId, GatherRequest request)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, Gather.Select(t => t.Value).ToArray(), Gather.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1
}).ToList());
Columns = Gather.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = Gather.Select(t => t.Value).ToList(),
};
if (result.Columns != null && result.Columns.Any())
{
......@@ -1346,7 +1345,7 @@ public HandsonTable GetGatherHands(int AllotId, GatherRequest request)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
result.SetRowData(rowDatas);
return result;
}
......
......@@ -331,7 +331,7 @@ private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId
logger.LogInformation($"人均绩效计算");
Dictionary<string, string> basicDict = new Dictionary<string, string>
{
{ "行政工勤人均绩效", UnitType.行政.ToString() },
{ "行政工勤人均绩效", UnitType.行政.ToString() },
{ "临床医生人均绩效", UnitType.医生组.ToString() },
{ "医技医生人均绩效", UnitType.医技组.ToString() },
{ "护士人均绩效", UnitType.护理组.ToString() },
......@@ -634,7 +634,7 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId,
var hos = _hospitalRepository.GetEntity(t => t.ID == hospitalId);
var employees = perforPeremployeeRepository.GetEntities(t => t.AllotId == allotId);
if (employees == null || !employees.Any()) throw new PerformanceException("人员字典中未保存数据");
var alias = _computeService.CustomColumnHeaders(hos, "/result/all_employee");
var dicData = CreateDataRow(hospitalId, request, alias);
var tags = reportperformancepersontagsRepository.GetEntities(t => t.HospitalId == hospitalId);
......@@ -757,13 +757,13 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId,
return new ApiResponse(ResponseType.OK);
}
public HandsonTable GetReportTag(int hospitalId)
public HandsonTableBase GetReportTag(int hospitalId)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, ReportTag.Select(t => t.Value).ToArray(), ReportTag.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1
}).ToList());
Columns = ReportTag.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = ReportTag.Select(t => t.Value).ToList(),
};
var data = reportperformancetagsRepository.GetEntities(t => t.HospitalId == hospitalId)?.OrderBy(t => t.UnitType);
if (data == null) return result;
......@@ -780,7 +780,7 @@ public HandsonTable GetReportTag(int hospitalId)
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
result.SetRowData(rowDatas);
return result;
}
......
......@@ -654,7 +654,7 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
#region 其他模板详情
public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, int employeeSource, out decimal? realAmount)
public HandsonTableBase GetOtherTempData(int userId, int secondId, int isArchive, int employeeSource, out decimal? realAmount)
{
string[] workNumbers = new string[] { };
var details = GetOtherTempDetails(userId, secondId, isArchive, employeeSource);
......@@ -666,12 +666,11 @@ public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, in
OtherTemp.Select(t => t.Value).ToArray() :
new string[] { "可分配绩效", "科室单项奖励", "医院其他绩效", "预留年度考核比例", "年度考核发放金额", "预发绩效工资金额" };
var result = new HandsonTable((int)SheetType.Unidentifiable, OtherTemp.Select(t => t.Value).ToArray(), OtherTemp.Select(t => new collect_permission
HandsonTableBase result = new HandsonTableBase()
{
HeadName = t.Value,
Visible = 1,
Readnoly = readColumns.Contains(t.Value) ? 1 : 0
}).ToList());
Columns = OtherTemp.Select(t => new HandsonColumn(t.Value)).ToList(),
ColHeaders = OtherTemp.Select(t => t.Value).ToList(),
};
if (result.Columns != null && result.Columns.Any())
{
......@@ -707,7 +706,7 @@ public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, in
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
result.SetRowData(rowDatas);
return result;
}
......@@ -825,7 +824,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
var empl = employees?.FirstOrDefault(w => w.PersonnelNumber?.Trim() == item.WorkNumber?.Trim());
item.ReservedRatio = empl?.ReservedRatio ?? 0;
// 如果是行政后勤,则把绩效放在工作量上
if (isTitlePerformance && second.UnitType == UnitType.行政后勤.ToString())
if (isTitlePerformance && UnitTypeUtil.IsOffice(second.UnitType))
{
item.WorkPerformance = distPerformance?.Where(w => w.AccountingUnit == item.Department && w.JobNumber?.Trim() == item.WorkNumber?.Trim())?.Sum(w => w.GiveFee);
if (string.IsNullOrEmpty(item.WorkNumber))
......@@ -835,7 +834,7 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
if (second.UnitType.Replace("其他", "").Replace("医技", "医生")
== (empl?.UnitType ?? "").Replace("其他", "").Replace("医技", "医生"))
{
if (second.UnitType == UnitType.行政后勤.ToString())
if (UnitTypeUtil.IsOffice(second.UnitType))
{
if (string.IsNullOrEmpty(item.WorkNumber))
{
......
......@@ -1518,10 +1518,10 @@ public List<ag_secondallot> AuditList(int allotId)
if (allot == null)
throw new PerformanceException("所选绩效不存在!");
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政 };
var types = new List<int> { (int)UnitType.行政高层, (int)UnitType.行政中层, (int)UnitType.行政 };
var accountUnit = resaccountRepository.GetEntities(t => t.AllotID == allot.ID && !types.Contains(t.UnitType.Value));
// 查询需要进行二次分配的行政后勤科室
var xzAccountUnit = resaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是");
var xzAccountUnit = resaccountRepository.GetEntities(t => t.AllotID == allot.ID && t.UnitType.Value == (int)UnitType.行政 && t.NeedSecondAllot == "是");
if (xzAccountUnit != null && xzAccountUnit.Count > 0)
(accountUnit ?? new List<res_account>()).AddRange(xzAccountUnit);
......@@ -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));
Func<per_employee, decimal?> getDistPerformance = (t) => 0;
if (second.UnitType == UnitType.行政后勤.ToString())
if (UnitTypeUtil.IsOffice(second.UnitType))
getDistPerformance = (t) => second.Department == t.AccountingUnit ? distPerformance
?.Where(w => w.JobNumber?.Trim() == t.PersonnelNumber?.Trim())
?.Sum(w => w.GiveFee) : 0;
......@@ -2457,7 +2457,7 @@ public List<DeptDataDetails> DeptComputeDetailList(int userId, int allotId, out
accountingUnit = secondList.FirstOrDefault()?.Department;
unitTypes = new string[] { secondList.FirstOrDefault()?.UnitType };
}
Dictionary<int, List<string>> dict = new Dictionary<int, List<string>>
{
{ (int)Role.科主任, new List<string>{ AccountUnitType.科主任.ToString()} },
......@@ -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>();
foreach (var item in computes)
{
......
......@@ -19,10 +19,11 @@ public class UnitTypeUtil
public static Dictionary<int, string[]> Maps { get; } = new Dictionary<int, string[]>
{
{ (int)Role.科主任, new string[]{ UnitType.医生组.ToString(), UnitType.其他医生组.ToString(), UnitType.医技组.ToString(), UnitType.其他医技组.ToString() } },
{ (int)Role.护士长, new string[]{ UnitType.护理组.ToString(), } },
{ (int)Role.护士长, new string[]{ UnitType.护理组.ToString(), 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>();
......@@ -33,7 +34,7 @@ public class UnitTypeUtil
/// <returns></returns>
public static bool IsOffice(int? unit)
{
return unit == (int)UnitType.行政;
return unit == (int)UnitType.行政;
}
/// <summary>
......
......@@ -727,16 +727,19 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
try
{
var dicData = CreateDataRow(request, Users);
var allDataList = dicData.Select(item => JsonHelper.Deserialize<UserHandsResponse>(JsonHelper.Serialize(item))).ToList();
var getUsers = _userRepository.GetEntities();
var roles = _roleRepository.GetEntities();
var hospitals = _hospitalRepository.GetEntities();
var accounts = _perforCofaccountingRepository.GetEntities();
var hosnames = allDataList.Select(w => w.HosName).Distinct().Where(w => !string.IsNullOrEmpty(w)).ToList();
var hospitals = _hospitalRepository.GetEntities(w => hosnames.Contains(w.HosName));
var hospitalIds = hospitals.Select(w => w.ID).ToArray();
var accounts = _perforCofaccountingRepository.GetAccounting(hospitalIds) ?? new List<CofAccountingEntity>();
List<sys_user> users = new List<sys_user>();
List<sys_user_role> userRoles = new List<sys_user_role>();
List<sys_user_hospital> userHoss = new List<sys_user_hospital>();
var roleArr = new 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>>();
for (int i = 0; i < allDataList.Count(); i++)
......@@ -759,8 +762,9 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{ "核算单元", 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>
{
......@@ -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>
{
......@@ -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>
{
......@@ -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 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)
{
error.Add(new Dictionary<string, string>
......@@ -827,13 +832,14 @@ public ApiResponse SaveUserHandsFlat(UserCollectData request)
{
if (users.Any(c => c.Login == data?.Login)) continue;
var hospitalId = hospitals.FirstOrDefault(w => w.HosName == (data.HosName?.Trim()))?.ID ?? -1;
var role = (Role)Enum.Parse(typeof(Role), data.RoleName);
var uninTypes = UnitTypeUtil.GetMaps((int)role);
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
{
RealName = data.RealName,
CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")),
CreateDate = DateTime.Now,
CreateUser = request.CreateUser,
Department = data?.Department.Trim() ?? "",
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