Commit c4ca24e2 by lcx

二次绩效其他模板改为handsontable格式数据

parent 71cb321f
......@@ -402,10 +402,10 @@ public ApiResponse NursingDeptAuditResult([FromBody] SecondAuditRequest request)
public ApiResponse OtherList([FromBody] AgOtherRequest request)
{
//var result = secondAllotService.OtherList(request.SecondId, claimService.GetUserId());
var result = secondAllotDetails.GetOtherTempDetails(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource);
var result = secondAllotDetails.GetOtherTempData(claimService.GetUserId(), request.SecondId, request.IsArchive, request.EmployeeSource, out decimal? realAmount);
var obj = new
{
header = secondAllotService.OtherListHeader(request.SecondId, result?.Sum(t => t.RealAmount)),
header = secondAllotService.OtherListHeader(request.SecondId, realAmount),
body = result,
};
return new ApiResponse(ResponseType.OK, obj);
......@@ -423,6 +423,20 @@ public ApiResponse OtherSave([FromBody] AgOtherRequest request)
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 二次绩效其他绩效保存(new)
/// </summary>
/// <param name="secondId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("api/second/other/save/{secondId}")]
[HttpPost]
public ApiResponse OtherSave(int secondId, [FromBody] SaveCollectData request)
{
secondAllotService.OtherSave(secondId, request);
return new ApiResponse(ResponseType.OK);
}
#endregion 二次绩效其他绩效
/// <summary>
......
......@@ -1237,6 +1237,14 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.OtherSave(System.Int32,Performance.DtoModels.SaveCollectData)">
<summary>
二次绩效其他绩效保存(new)
</summary>
<param name="secondId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.SecondPrint(System.Int32)">
<summary>
二次绩效结果打印
......
......@@ -630,7 +630,62 @@ private void SupplyHeaderByWorkItem(int hospitalId, SecondResponse result, ag_se
#region 其他模板详情
public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int isArchive, int employeeSource)
public HandsonTable GetOtherTempData(int userId, int secondId, int isArchive, int employeeSource, out decimal? realAmount)
{
string[] workNumbers = new string[] { };
var details = GetOtherTempDetails(userId, secondId, isArchive, employeeSource, ref workNumbers);
var secondAllot = agsecondallotRepository.GetEntity(t => t.Id == secondId);
var readColumns = new int[] { 2, 3, }.Contains(secondAllot.Status.Value) ?
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
{
HeadName = t.Value,
Visible = 1,
Readnoly = readColumns.Contains(t.Value) ? 1 : 0
}).ToList());
if (result.Columns != null && result.Columns.Any())
{
foreach (var column in result.Columns)
{
if (column.Data == "工号")
{
column.Type = "autocomplete";
//column.Source = workNumbers;
//column.Strict = true;
}
}
}
realAmount = details?.Sum(t => t.RealAmount);
if (details == null || !details.Any()) return result;
details.ForEach(t =>
{
if (!t.OtherPerformance.HasValue) t.OtherPerformance = 0;
});
List<HandsonRowData> rowDatas = new List<HandsonRowData>();
int i = 1;
foreach (var item in details)
{
var json = JsonHelper.Serialize(item);
var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json);
var cells = (from conf in OtherTemp join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper() select new HandsonCellData(conf.Value, fst.Value)).ToList();
cells.Add(new HandsonCellData(nameof(ag_othersource.Id), item.Id));
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
return result;
}
public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int isArchive, int employeeSource, ref string[] workNumbers)
{
var secondAllot = agsecondallotRepository.GetEntity(t => t.Id == secondId);
if (secondAllot == null) throw new PerformanceException("二次绩效信息无效!");
......@@ -720,6 +775,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
}
}
var originalEmployees = personService.GetPerEmployee(secondAllot.AllotId.Value);
workNumbers = originalEmployees?.Select(t => t.PersonnelNumber).Distinct().ToArray();
SupplementSecondDetail(secondAllot, originalEmployees, result, isSupplementTitlePerformance);
return result;
......@@ -817,6 +873,23 @@ private void SupplementSecondDetail(ag_secondallot second, List<per_employee> em
}
}
public static Dictionary<string, string> OtherTemp { get; } = new Dictionary<string, string>
{
{ nameof (ag_othersource.WorkNumber), "工号" },
{ nameof (ag_othersource.Name), "姓名" },
{ nameof (ag_othersource.Department), "科室" },
{ nameof (ag_othersource.WorkPost), "职称" },
{ nameof (ag_othersource.TitlePerformance), "职称绩效" },
{ nameof (ag_othersource.WorkPerformance), "工作量绩效工资" },
{ nameof (ag_othersource.DeptReward), "科室单项奖励" },
{ nameof (ag_othersource.DistPerformance), "可分配绩效" },
{ nameof (ag_othersource.OtherPerformance), "医院其他绩效" },
{ nameof (ag_othersource.NightWorkPerformance), "夜班工作量绩效" },
{ nameof (ag_othersource.ReservedRatio), "预留比例" },
{ nameof (ag_othersource.ReservedAmount), "预留金额" },
{ nameof (ag_othersource.RealAmount), "实发绩效工资金额" },
};
#endregion 其他模板详情
/// <summary>
......
......@@ -1691,6 +1691,44 @@ public List<ag_othersource> OtherSave(int secondId, List<ag_othersource> request
return perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId);
}
public void OtherSave(int secondId, SaveCollectData collectData)
{
if (collectData.ColHeaders == null || !collectData.ColHeaders.Any()) return;
var parameters = new List<string>();
foreach (var item in collectData.ColHeaders)
{
if (!SecondAllotDetails.OtherTemp.ContainsValue(item)) throw new PerformanceException($"请确认列'{item}'是否正确");
parameters.Add(SecondAllotDetails.OtherTemp.FirstOrDefault(t => t.Value == item).Key);
}
if (parameters == null || !parameters.Any()) return;
List<Dictionary<string, object>> result = new List<Dictionary<string, object>>();
foreach (var item in collectData.Data)
{
var list = item.ToList();
Dictionary<string, object> dict = new Dictionary<string, object>();
parameters.ForEach(t => {
dict.Add(t, list[parameters.IndexOf(t)]);
});
result.Add(dict);
}
var json = JsonHelper.Serialize(result);
var data = JsonHelper.Deserialize<List<ag_othersource>>(json);
data = data.Where(t => !string.IsNullOrEmpty(t.WorkNumber) || !string.IsNullOrEmpty(t.Name))?.ToList();
if (data == null || !data.Any()) return;
var existEntities = perforAgothersourceRepository.GetEntities(t => t.SecondId == secondId);
if (existEntities != null && existEntities.Any())
{
perforAgothersourceRepository.RemoveRange(existEntities.ToArray());
}
data.ForEach(t => t.SecondId = secondId);
perforAgothersourceRepository.AddRange(data.ToArray());
}
#endregion 二次绩效其他来源
#region 打印
......
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