审核通过后同步数据到ex_result

parent 0214a744
...@@ -3594,6 +3594,16 @@ ...@@ -3594,6 +3594,16 @@
创建时间 创建时间
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ex_result.IsDelete">
<summary>
1 删除 0 未删除
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result.FromSource">
<summary>
数据来源 0 提取 1 录入
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.Id"> <member name="P:Performance.EntityModels.ex_result_gather.Id">
<summary> <summary>
......
...@@ -129,10 +129,18 @@ public enum Status ...@@ -129,10 +129,18 @@ public enum Status
} }
} }
public enum AuditGatherEnum public class EnumResult
{
public enum AuditGather
{ {
未审核 = 0, 未审核 = 0,
未通过 = 1, 未通过 = 1,
已通过 = 2, 已通过 = 2,
} }
public enum FromSource
{
提取 = 0,
录入 = 1,
}
}
} }
...@@ -76,9 +76,13 @@ public class ex_result ...@@ -76,9 +76,13 @@ public class ex_result
/// </summary> /// </summary>
public Nullable<DateTime> CreateTime { get; set; } public Nullable<DateTime> CreateTime { get; set; }
// /// <summary> /// <summary>
// /// 1 删除 0 未删除 /// 1 删除 0 未删除
// /// </summary> /// </summary>
public int IsDelete { get; set; } public int IsDelete { get; set; }
/// <summary>
/// 数据来源 0 提取 1 录入
/// </summary>
public int FromSource { get; set; }
} }
} }
...@@ -1412,14 +1412,14 @@ public GatherResponse GetGatherTotal(Gather gather) ...@@ -1412,14 +1412,14 @@ public GatherResponse GetGatherTotal(Gather gather)
exp = exp.And(t => t.Category.Contains(gather.SearchQuery) || t.Source.Contains(gather.SearchQuery) || t.Department.Contains(gather.SearchQuery)); exp = exp.And(t => t.Category.Contains(gather.SearchQuery) || t.Source.Contains(gather.SearchQuery) || t.Department.Contains(gather.SearchQuery));
} }
var user = userRepository.GetEntities(); var user = userRepository.GetEntities();
var userLogin= user.FirstOrDefault(t => t.ID == gather.UserId); var userLogin = user.FirstOrDefault(t => t.ID == gather.UserId);
if (userLogin.Login != "admin") if (userLogin.Login != "admin")
{ {
var userSource = perforcollectpermissionRepository.GetEntities(t => t.UserId == gather.UserId) var userSource = perforcollectpermissionRepository.GetEntities(t => t.UserId == gather.UserId)
.Select(s => Regex.Replace(s.SheetName.Replace(" ", "").Replace(".", ""), "[0-9]", "")) .Select(s => Regex.Replace(s.SheetName.Replace(" ", "").Replace(".", ""), "[0-9]", ""))
.Distinct().ToList(); .Distinct().ToList();
exp = exp.And(t => userSource.Contains(t.Source)); exp = exp.And(t => userSource.Contains(t.Source));
var hasDepartment = perdeptdicRepository.GetEntities(p=>p.AccountingUnit.Contains(userLogin.Department)).Select(s=>s.HISDeptName).Distinct().ToList(); var hasDepartment = perdeptdicRepository.GetEntities(p => p.AccountingUnit.Contains(userLogin.Department)).Select(s => s.HISDeptName).Distinct().ToList();
exp = exp.And(t => hasDepartment.Contains(t.Department)); exp = exp.And(t => hasDepartment.Contains(t.Department));
} }
...@@ -1435,9 +1435,9 @@ public GatherResponse GetGatherTotal(Gather gather) ...@@ -1435,9 +1435,9 @@ public GatherResponse GetGatherTotal(Gather gather)
Login = user.FirstOrDefault(t => t.ID == s.Key.Submitter).Login, Login = user.FirstOrDefault(t => t.ID == s.Key.Submitter).Login,
CreateTime = s.Max(t => t.CreateTime).ToString("d"), CreateTime = s.Max(t => t.CreateTime).ToString("d"),
AuditTime = s.Max(t => t.AuditTime)?.ToString("d"), AuditTime = s.Max(t => t.AuditTime)?.ToString("d"),
States = s.Any(w => w.States == (int)AuditGatherEnum.未通过) ? "未通过" States = s.Any(w => w.States == (int)EnumResult.AuditGather.未通过) ? "未通过"
: s.Count() == s.Where(w => w.States == (int)AuditGatherEnum.已通过).Count() ? "已通过" : s.Count() == s.Where(w => w.States == (int)EnumResult.AuditGather.已通过).Count() ? "已通过"
: s.Count() == s.Where(w => w.States == (int)AuditGatherEnum.未审核).Count() ? "未审核" : "未知", : s.Count() == s.Where(w => w.States == (int)EnumResult.AuditGather.未审核).Count() ? "未审核" : "未知",
Remark = s.FirstOrDefault()?.Remark, Remark = s.FirstOrDefault()?.Remark,
}); });
...@@ -1602,7 +1602,7 @@ public ApiResponse SaveGatherHands(int allotId, SaveGatherData saveGather) ...@@ -1602,7 +1602,7 @@ public ApiResponse SaveGatherHands(int allotId, SaveGatherData saveGather)
var ExistsDeptData = departments.FirstOrDefault(w => w.AllotId == allotId var ExistsDeptData = departments.FirstOrDefault(w => w.AllotId == allotId
&& (w.Department != null && w.Department.Contains(newGather[i].Department)) && (w.Department != null && w.Department.Contains(newGather[i].Department))
|| (w.HISDeptName !=null && w.HISDeptName.Contains(newGather[i].Department)) || (w.HISDeptName != null && w.HISDeptName.Contains(newGather[i].Department))
); );
if (ExistsDeptData == null) if (ExistsDeptData == null)
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
...@@ -1616,7 +1616,7 @@ public ApiResponse SaveGatherHands(int allotId, SaveGatherData saveGather) ...@@ -1616,7 +1616,7 @@ public ApiResponse SaveGatherHands(int allotId, SaveGatherData saveGather)
{ "错误原因", $"科室字典中不存在科室[{newGather[i].Department}]" }, { "错误原因", $"科室字典中不存在科室[{newGather[i].Department}]" },
}); });
var ExistNameData = employees.FirstOrDefault(w => w.AllotId == allotId && (w.DoctorName!=null && w.DoctorName == newGather[i].DoctorName)); var ExistNameData = employees.FirstOrDefault(w => w.AllotId == allotId && (w.DoctorName != null && w.DoctorName == newGather[i].DoctorName));
if (ExistNameData == null) if (ExistNameData == null)
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -1629,7 +1629,7 @@ public ApiResponse SaveGatherHands(int allotId, SaveGatherData saveGather) ...@@ -1629,7 +1629,7 @@ public ApiResponse SaveGatherHands(int allotId, SaveGatherData saveGather)
{ "错误原因", $"人员字典中不存在医生姓名[{newGather[i].DoctorName}]" }, { "错误原因", $"人员字典中不存在医生姓名[{newGather[i].DoctorName}]" },
}); });
var ExistNumberData = employees.FirstOrDefault(w => w.AllotId == allotId && (w.PersonnelNumber!= null && w.PersonnelNumber == newGather[i].PersonnelNumber)); var ExistNumberData = employees.FirstOrDefault(w => w.AllotId == allotId && (w.PersonnelNumber != null && w.PersonnelNumber == newGather[i].PersonnelNumber));
if (ExistNumberData == null) if (ExistNumberData == null)
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -1642,7 +1642,7 @@ public ApiResponse SaveGatherHands(int allotId, SaveGatherData saveGather) ...@@ -1642,7 +1642,7 @@ public ApiResponse SaveGatherHands(int allotId, SaveGatherData saveGather)
{ "错误原因", $"人员字典中不存在工号[{newGather[i].PersonnelNumber}]" }, { "错误原因", $"人员字典中不存在工号[{newGather[i].PersonnelNumber}]" },
}); });
if((ExistNumberData == null || ExistNumberData.DoctorName != newGather[i].DoctorName) if ((ExistNumberData == null || ExistNumberData.DoctorName != newGather[i].DoctorName)
|| (ExistNameData == null || ExistNameData.PersonnelNumber != newGather[i].PersonnelNumber)) || (ExistNameData == null || ExistNameData.PersonnelNumber != newGather[i].PersonnelNumber))
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -1763,14 +1763,15 @@ public void SyncDataToResult(int allotId) ...@@ -1763,14 +1763,15 @@ public void SyncDataToResult(int allotId)
var sheets = perforPersheetRepository.GetEntities(t => t.AllotID == allotId && new[] { 3, 4, 7 }.Contains(t.SheetType.Value)); var sheets = perforPersheetRepository.GetEntities(t => t.AllotID == allotId && new[] { 3, 4, 7 }.Contains(t.SheetType.Value));
if (sheets == null || !sheets.Any()) return; if (sheets == null || !sheets.Any()) return;
var data = exresultgatherRepository.GetEntities(w => w.AllotId == allotId); var data = exresultgatherRepository.GetEntities(w => w.AllotId == allotId && w.States == (int)EnumResult.AuditGather.已通过);
if (data == null || !data.Any()) return; if (data == null || !data.Any()) return;
exresultRepository.DeleteFromQuery(w => w.AllotId == allotId && w.FromSource == (int)EnumResult.FromSource.录入);
var syncData = _mapper.Map<List<ex_result>>(data); var syncData = _mapper.Map<List<ex_result>>(data);
syncData.ForEach(x => syncData.ForEach(x =>
{ {
x.Id = 0; x.Id = 0;
x.FromSource = (int)EnumResult.FromSource.录入;
x.Source = sheets.FirstOrDefault(t => t.SheetName.Contains(x.Source))?.SheetName ?? x.Source; x.Source = sheets.FirstOrDefault(t => t.SheetName.Contains(x.Source))?.SheetName ?? x.Source;
}); });
exresultRepository.AddRange(syncData.ToArray()); exresultRepository.AddRange(syncData.ToArray());
...@@ -1811,17 +1812,22 @@ public void AuditGather(List<Gather> gather) ...@@ -1811,17 +1812,22 @@ public void AuditGather(List<Gather> gather)
datas.ForEach(d => datas.ForEach(d =>
{ {
d.AuditTime = DateTime.Now; d.AuditTime = DateTime.Now;
d.States = (int)AuditGatherEnum.已通过; d.States = (int)EnumResult.AuditGather.已通过;
d.Remark = null; d.Remark = null;
}); });
else if (gatherFirst.Status == "失败") else if (gatherFirst.Status == "失败")
datas.ForEach(d => datas.ForEach(d =>
{ {
d.AuditTime = DateTime.Now; d.AuditTime = DateTime.Now;
d.States = (int)AuditGatherEnum.未通过; d.States = (int)EnumResult.AuditGather.未通过;
d.Remark = gatherFirst.Remark; d.Remark = gatherFirst.Remark;
}); });
exresultgatherRepository.UpdateRange(datas.ToArray()); exresultgatherRepository.UpdateRange(datas.ToArray());
if (gatherFirst.Status == "通过")
{
SyncDataToResult(gatherFirst.AllotId);
}
} }
} }
......
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