Commit 635992b7 by ruyun.zhang@suvalue.com

Merge branch '青白江' into v2020morge

parents e5d1d461 1f8b1f7e
......@@ -80,7 +80,7 @@ public ApiResponse SaveValue(int secondid, [FromBody] List<ag_fixatitem> request
if (repetition.Any())
throw new PerformanceException(string.Join(";", repetition.Select(t => $"行{t.Key.RowNumber}项‘{t.Key.ItemName}’重复录入")));
var result = secondAllotService.SaveValue(request);
var result = secondAllotService.SaveValue(request, secondid);
return new ApiResponse(ResponseType.OK);
}
......
using AutoMapper;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
......@@ -17,6 +18,7 @@ namespace Performance.Services
public class SecondAllotService : IAutoInjection
{
private readonly Application application;
private readonly ILogger<SecondAllotService> _logger;
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforUserRepository perforUserRepository;
private readonly PerforUserhospitalRepository perforUserhospitalRepository;
......@@ -44,6 +46,7 @@ public class SecondAllotService : IAutoInjection
private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>();
public SecondAllotService(IOptions<Application> application,
ILogger<SecondAllotService> logger,
PerforHospitalRepository hospitalRepository,
PerforUserRepository perforUserRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
......@@ -70,6 +73,7 @@ public class SecondAllotService : IAutoInjection
PerforImemployeeclinicRepository imemployeeclinicRepository)
{
this.application = application.Value;
_logger = logger;
this.hospitalRepository = hospitalRepository;
this.perforUserRepository = perforUserRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
......@@ -678,15 +682,14 @@ private void SupplyHeaderByWorkItem(UseTempRequest request, SecondResponse resul
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool SaveValue(List<ag_fixatitem> request)
public bool SaveValue(List<ag_fixatitem> request, int secondId)
{
var secondId = request.First().SecondId;
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == secondId);
if (second == null)
throw new PerformanceException("二次绩效ID不存在");
var fixatitems = perforAgfixatitemRepository.GetEntities(t => t.SecondId == secondId);
var result = DelValue(fixatitems, request);
var result = DelValue(secondId, fixatitems, request);
List<ag_fixatitem> update = new List<ag_fixatitem>(), insert = new List<ag_fixatitem>();
if (fixatitems != null && fixatitems.Any())
{
......@@ -719,23 +722,27 @@ public bool SaveValue(List<ag_fixatitem> request)
/// <summary>
/// 删除未保存的历史数据
/// </summary>
/// <param name="fixatlist">数据库中查询到的值</param>
/// <param name="fixatitems">需要保存的数据</param>
/// <param name="oldFixatItems">数据库中查询到的值</param>
/// <param name="newFixatItems">需要保存的数据</param>
/// <returns></returns>
public bool DelValue(List<ag_fixatitem> fixatlist, List<ag_fixatitem> fixatitems)
public bool DelValue(int secondId, List<ag_fixatitem> oldFixatItems, List<ag_fixatitem> newFixatItems)
{
var result = true;
// 提交数据为空时,删除所有数据
if (fixatitems == null || fixatitems.Count == 0)
if (newFixatItems == null || newFixatItems.Count == 0)
{
if (oldFixatItems != null && oldFixatItems.Any())
{
if (fixatlist != null && fixatlist.Any())
result = perforAgfixatitemRepository.RemoveRange(fixatlist.ToArray());
result = perforAgfixatitemRepository.RemoveRange(oldFixatItems.ToArray());
_logger.LogError($"删除二次分配录入数据:{oldFixatItems.Count()}");
_logger.LogError($"删除二次分配录入数据:{JsonHelper.Serialize(oldFixatItems.Select(w => w.ID))}");
}
return result;
}
if (fixatlist != null && fixatlist.Any())
if (oldFixatItems != null && oldFixatItems.Any())
{
var groupData = fixatlist.GroupBy(t => new { t.RowNumber, t.ItemName }).Select(t => new
var groupData = oldFixatItems.GroupBy(t => new { t.RowNumber, t.ItemName }).Select(t => new
{
t.Key.RowNumber,
t.Key.ItemName,
......@@ -745,16 +752,20 @@ public bool DelValue(List<ag_fixatitem> fixatlist, List<ag_fixatitem> fixatitems
// 删除重复数据
if (groupData.Any(t => t.Count > 1))
{
var delData = fixatlist.Where(t => !groupData.Select(w => w.Id).Contains(t.ID));
int flag = fixatlist.RemoveAll(t => !groupData.Select(w => w.Id).Contains(t.ID));
var delData = oldFixatItems.Where(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID));
int flag = oldFixatItems.RemoveAll(t => t.SecondId == secondId && !groupData.Select(w => w.Id).Contains(t.ID));
_logger.LogError($"删除二次分配录入数据:{delData.Count()}");
result = perforAgfixatitemRepository.RemoveRange(delData.ToArray());
}
// 删除行号不存在的数据
var saveRows = fixatitems.Select(t => t.RowNumber).Distinct();
var delRows = fixatlist.Select(t => t.RowNumber).Distinct().Except(saveRows);
var saveRows = newFixatItems.Where(t => t.SecondId == secondId).Select(t => t.RowNumber).Distinct();
var delRows = oldFixatItems.Where(t => t.SecondId == secondId).Select(t => t.RowNumber).Distinct().Except(saveRows);
if (delRows != null && delRows.Count() > 0)
result = perforAgfixatitemRepository.RemoveRange(fixatlist.Where(t => delRows.Contains(t.RowNumber)).ToArray());
{
result = perforAgfixatitemRepository.RemoveRange(oldFixatItems.Where(t => delRows.Contains(t.RowNumber)).ToArray());
_logger.LogError($"删除二次分配录入数据 删除行号不存在的数据:{oldFixatItems.Count()}");
}
}
return result;
......@@ -909,15 +920,15 @@ public bool UseTemp(UseTempRequest request)
#endregion 获取需要添加的数据 无需操作的数据
//perforAgsecondallotRepository.UpdateRange(update_second_usetemps.ToArray());
if (list != null && list.Count > 0)
{
var delList = fixatList.Except(list);
perforAgfixatitemRepository.RemoveRange(delList.ToArray());
////perforAgsecondallotRepository.UpdateRange(update_second_usetemps.ToArray());
//if (list != null && list.Count > 0)
//{
// var delList = fixatList.Except(list);
// perforAgfixatitemRepository.RemoveRange(delList.Where(w => w.SecondId == request.SecondId).ToArray());
if (addList != null && addList.Count > 0)
perforAgfixatitemRepository.AddRange(addList.ToArray());
}
// if (addList != null && addList.Count > 0)
// perforAgfixatitemRepository.AddRange(addList.ToArray());
//}
}
}
return result;
......@@ -1718,7 +1729,7 @@ public List<SecPrintResponse> Print(int secondId)
JobNumber = fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "人员工号")?.ItemValue,
PersonName = fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "姓名")?.ItemValue,
Department = second.Department,
RealAmount = distperfor + nightworkperfor,
RealAmount = (distperfor ?? 0) + (nightworkperfor ?? 0),
};
sec.WorkPost = fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "职称")?.ItemValue;
sec.TitlePerfor = ConvertHelper.To<decimal?>(fixaitems.FirstOrDefault(t => t.RowNumber == rownumber && t.ItemName == "职称绩效")?.ItemValue);
......
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