Commit 0b65ac16 by 纪旭 韦

每日自动同步代码修改,

人员、科室 删除,修改,新增 时绩效分配(per_allot)的IsModifyConfig修改为1
parent 6c6db09c
......@@ -42,3 +42,5 @@ logs/
/files
performance/Performance.Api/Files/
performance/Performance.Extract.Api/Files/
performance/Performance.Services/ConfigService.cs.rej
performance/Performance.Api/Job/AutoSyncConfigJob.cs.rej
......@@ -31,35 +31,51 @@ public void Execute()
try
{
logger.LogInformation("开始同步配置");
//先查询perallot所有数据
var list = perallotRepository.GetEntities();
if (list == null || !list.Any()) return;
var hospitalIds = list.Select(t => t.HospitalId).Distinct().OrderBy(t => t);
//按照医院循环
foreach (var hospitalId in hospitalIds)
{
var allots = list.Where(w => w.HospitalId == hospitalId)?.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
//按年月进行倒序查询allots
var allots = list.Where(w => w.HospitalId == hospitalId && string.IsNullOrEmpty(w.Path) && w.IsModifyConfig != 1)?.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
if (allots == null || !allots.Any()) continue;
while (allots != null && allots.Any(w => w.IsModifyConfig == 0))
foreach (var item in allots)
{
var prevAllot = allots.FirstOrDefault(t => t.IsModifyConfig == 1);
if (prevAllot == null) continue;
configService.NewCopy(new CopyRequest() { AllotId = item.ID, Type = new[] { "personnels", "workItems", "drugTypeDisburses", "drugTypeFactors", "deptTypes", "agains", "accountings", "department" } });
}
#region 旧代码
var date = ConvertHelper.To<DateTime>($"{prevAllot.Year}-{prevAllot.Month}");
var needSyncData = allots.Where(w => ConvertHelper.To<DateTime>($"{w.Year}-{w.Month}") > date);
if (needSyncData != null && needSyncData.Any())
{
foreach (var item in needSyncData)
configService.NewCopy(new CopyRequest() { AllotId = item.ID, Type = new[] { "personnels", "workItems", "drugTypeDisburses", "drugTypeFactors", "deptTypes", "agains", "accountings", "department" } });
}
////如果allots不为null 并且 数据存在没修改过的,进行循环
//while (allots != null && allots.Any(w => w.IsModifyConfig == 0) && allots.Any(w => w.IsModifyConfig == 1))
//{
// //查询最近一次修改过的allot
// var prevAllot = allots.FirstOrDefault(t => t.IsModifyConfig == 1);
// //if (prevAllot == null) continue;
var noModify = allots.FirstOrDefault(w => ConvertHelper.To<DateTime>($"{w.Year}-{w.Month}") < date && w.IsModifyConfig == 0);
if (noModify != null)
date = ConvertHelper.To<DateTime>($"{noModify.Year}-{noModify.Month}");
// //获取最近一次修改过的月份
// var date = ConvertHelper.To<DateTime>($"{prevAllot.Year}-{prevAllot.Month}");
// //查找需要同步的allot(条件为 最近一次修改过的月份之后的所有allot)
// var needSyncData = allots.Where(w => ConvertHelper.To<DateTime>($"{w.Year}-{w.Month}") > date);
// if (needSyncData != null && needSyncData.Any())
// {
// //开始同步查询到的allot
// foreach (var item in needSyncData)
// configService.NewCopy(new CopyRequest() { AllotId = item.ID, Type = new[] { "personnels", "workItems", "drugTypeDisburses", "drugTypeFactors", "deptTypes", "agains", "accountings", "department" } });
// }
// //同步完之后查询 最近一次修改过的allot 之前的第一条未修改的allot
// var noModify = allots.FirstOrDefault(w => ConvertHelper.To<DateTime>($"{w.Year}-{w.Month}") < date && w.IsModifyConfig == 0);
// if (noModify != null)
// //最近一次修改过的月份 更改为 前的第一条数据的月份
// date = ConvertHelper.To<DateTime>($"{noModify.Year}-{noModify.Month}");
allots = allots.Where(w => ConvertHelper.To<DateTime>($"{w.Year}-{w.Month}") <= date)?.ToList();
}
// //当次循环allots只保留 小于 最近一次修改过的月份
// allots = allots.Where(w => ConvertHelper.To<DateTime>($"{w.Year}-{w.Month}") <= date)?.ToList();
//}
#endregion
}
logger.LogInformation("同步配置结束");
}
......
......@@ -56,7 +56,7 @@ public int GetPrevAllot(per_allot allot)
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
// 先取上一个月的绩效Id,若没有,取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
int allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID)
return -1;
......
......@@ -738,7 +738,6 @@ public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request)
/// <param name="iD"></param>
public void Copy(per_allot allot)
{
var prevAllotId = _perforPerAllotRepository.GetPrevAllot(allot);
NewCopy(new CopyRequest() { AllotId = allot.ID, Type = new[] { "personnels", "workItems", "drugTypeDisburses", "drugTypeFactors", "deptTypes", "agains", "accountings", "department" } });
}
......
......@@ -291,6 +291,9 @@ public ApiResponse CreatePerson(PerEmployeeResponse request)
throw new PerformanceException($"添加失败");
perallotRepository.AccoungtingVerify(entity.AllotId ?? 0);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
return new ApiResponse(ResponseType.OK, "添加成功", entity);
}
......@@ -374,6 +377,8 @@ public ApiResponse UpdatePerson(PerEmployeeResponse request)
//CheckAccountingDept(request.HospitalId.Value, request.AccountingUnit, request.Department);
var res = peremployeeRepository.Update(employee);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
return new ApiResponse(ResponseType.OK, "修改成功");
}
......@@ -395,6 +400,9 @@ public bool DeletePerson(int employeeId)
var employeeBackup = _mapper.Map<per_employee_backup>(employee);
perforPeremployeeBackupRepository.Add(employeeBackup);
var allot = perallotRepository.GetEntity(t => t.ID == oldbackup.AllotId);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
return peremployeeRepository.Remove(employee);
}
......@@ -409,7 +417,9 @@ public bool DeleteAllPerson(int allotId)
?? new List<per_employee>();
dapperService.PerEmployeeBackup(allotId);
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
return peremployeeRepository.RemoveRange(employees.ToArray());
}
......@@ -522,6 +532,9 @@ public per_dept_dic CreateDeptDic(per_dept_dic request)
request.CreateTime = DateTime.Now;
perdeptdicRepository.Add(request);
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
return request;
}
......@@ -605,6 +618,9 @@ public bool UpdateDeptDic(DeptdicResponse request)
}
}
}
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
}
catch (Exception ex)
{
......@@ -629,6 +645,9 @@ public bool DeleteDeptDic(DeptdicResponse request)
if (deptdics == null || !deptdics.Any())
throw new PerformanceException("科室记录不存在!");
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
return perdeptdicRepository.RemoveRange(deptdics.ToArray());
}
......@@ -1020,10 +1039,12 @@ public ApiResponse BathSavePerson(int allotId, int HospitalId, SaveCollectData r
peremployeeRepository.AddRange(employees.ToArray());
}
perallotRepository.AccoungtingVerify(allotId);
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
return new ApiResponse(ResponseType.OK, "");
}
......@@ -1057,6 +1078,9 @@ public void SaveDeptDicHands(int allotId, SaveCollectData request)
perdeptdicRepository.RemoveRange(delDept.ToArray());
if (deptDics != null && deptDics.Any())
perdeptdicRepository.AddRange(deptDics.ToArray());
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
}
private void DeptDicList(int hospitalId, int allotId, List<per_dept_dic> deptDics, DeptdicHands data)
......@@ -1292,6 +1316,8 @@ public bool ReloadPersonnel(int hospitalId, int allotId)
}).ToList();
SaveAllotPersons(data);
allot.IsModifyConfig = 1;
perallotRepository.Update(allot);
return true;
}
......
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