Commit 15e90cb5 by lcx

手工录入数据校验及导出

parent 7d4eccb7
...@@ -789,8 +789,12 @@ public ApiResponse SaveGatherHands([FromRoute] int allotId, [FromBody] SaveGathe ...@@ -789,8 +789,12 @@ public ApiResponse SaveGatherHands([FromRoute] int allotId, [FromBody] SaveGathe
if (string.IsNullOrEmpty(request.Source) || string.IsNullOrEmpty(request.Category)) if (string.IsNullOrEmpty(request.Source) || string.IsNullOrEmpty(request.Category))
return new ApiResponse(ResponseType.Fail); return new ApiResponse(ResponseType.Fail);
if (request.Data == null || !request.Data.Any())
return new ApiResponse(ResponseType.Fail, "用户提交数据为空");
employeeService.CheckGatherData(allotId, request);
employeeService.SaveGatherHands(allotId, request); employeeService.SaveGatherHands(allotId, request);
employeeService.CheckGatherData(allotId); employeeService.AddCategoryToConfig(allotId);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
......
...@@ -3624,11 +3624,6 @@ ...@@ -3624,11 +3624,6 @@
备注 备注
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ex_result_gather.States">
<summary>
1 未通过 2 通过
</summary>
</member>
<member name="T:Performance.EntityModels.ex_script"> <member name="T:Performance.EntityModels.ex_script">
<summary> <summary>
......
...@@ -49,6 +49,6 @@ public class ex_result_gather ...@@ -49,6 +49,6 @@ public class ex_result_gather
/// <summary> /// <summary>
/// 1 未通过 2 通过 /// 1 未通过 2 通过
/// </summary> /// </summary>
public int States { get; set; } // public int States { get; set; }
} }
} }
...@@ -1442,56 +1442,38 @@ public GatherResponse GetGatherTotal(int allotId, PersonParamsRequest request) ...@@ -1442,56 +1442,38 @@ public GatherResponse GetGatherTotal(int allotId, PersonParamsRequest request)
#region 录入校验 #region 录入校验
public bool CheckGatherData(int allotId) public void CheckGatherData(int allotId, SaveGatherData saveGather)
{
try
{ {
var allot = perallotRepository.GetEntity(w => w.ID == allotId); var allot = perallotRepository.GetEntity(w => w.ID == allotId);
if (allot == null) throw new PerformanceException("绩效记录不存在"); if (allot == null) throw new PerformanceException("绩效记录不存在");
var data = exresultgatherRepository.GetEntities(w => w.AllotId == allotId); var data = saveGather.Data;
if (data == null || !data.Any()) throw new PerformanceException("录入数据为空");
SetDataStatesAndRemark(data, 2, string.Empty);
var departments = perdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId); var departments = perdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId);
if (departments != null && departments.Any()) if (departments != null && departments.Any())
{ {
var notExistsDeptData = data.Where(w => !departments.Select(t => t.Department).Contains(w.Department)); var notExistsDeptData = data.Where(w => !departments.Select(t => t.Department).Contains(w[0]));
if (notExistsDeptData != null && notExistsDeptData.Any()) if (notExistsDeptData != null && notExistsDeptData.Any())
SetDataStatesAndRemark(notExistsDeptData, 1, "科室字典中不存在科室[{0}]", t => t.Department); throw new PerformanceException($"科室字典中不存在科室[{string.Join(",", notExistsDeptData.Select(t => t[0]).Distinct())}]");
} }
var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotId); var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotId);
if (employees != null && employees.Any()) if (employees != null && employees.Any())
{ {
var notExistNameData = data.Where(w => !employees.Select(t => t.DoctorName).Contains(w.DoctorName) && !string.IsNullOrEmpty(w.DoctorName)); var notExistNameData = data.Where(w => !employees.Select(t => t.DoctorName).Contains(w[1]) && !string.IsNullOrEmpty(w[1]));
if (notExistNameData != null && notExistNameData.Any()) if (notExistNameData != null && notExistNameData.Any())
SetDataStatesAndRemark(notExistNameData, 1, "人员字典中不存在医生名称[{0}]", t => t.DoctorName); throw new PerformanceException($"人员字典中不存在医生姓名[{string.Join(",", notExistNameData.Select(t => t[1]).Distinct())}]");
var notExistNumberData = data.Where(w => !employees.Select(t => t.PersonnelNumber).Contains(w.PersonnelNumber) && !string.IsNullOrEmpty(w.PersonnelNumber)); var notExistNumberData = data.Where(w => !employees.Select(t => t.PersonnelNumber).Contains(w[2]) && !string.IsNullOrEmpty(w[2]));
if (notExistNumberData != null && notExistNumberData.Any()) if (notExistNumberData != null && notExistNumberData.Any())
SetDataStatesAndRemark(notExistNumberData, 1, "人员字典中不存在工号[{0}]", t => t.PersonnelNumber); throw new PerformanceException($"人员字典中不存在工号[{string.Join(",", notExistNumberData.Select(t => t[2]).Distinct())}]");
} }
var sheets = perforPersheetRepository.GetEntities(w => w.AllotID == allotId); var sheets = perforPersheetRepository.GetEntities(w => w.AllotID == allotId);
if (sheets != null && sheets.Any()) if (sheets != null && sheets.Any())
{ {
var notExistsSourceData = data.Where(w => !sheets.Select(t => t.SheetName).Contains(w.Source)); if (!sheets.Select(t => t.SheetName).Any(t => t.Contains(saveGather.Source)))
if (notExistsSourceData != null && notExistsSourceData.Any()) throw new PerformanceException($"来源错误[{saveGather.Source}]");
SetDataStatesAndRemark(notExistsSourceData, 1, "来源中不存在名称[{0}]", t => t.Source);
}
exresultgatherRepository.UpdateRange(data.ToArray());
AddCategoryToConfig(data, allot.HospitalId);
return data.Any(w => w.States == 1);
}
catch (Exception ex)
{
logger.LogError(ex.Message);
throw new PerformanceException("校验失败");
} }
} }
...@@ -1506,18 +1488,19 @@ private static void SetDataStatesAndRemark(IEnumerable<ex_result_gather> data, i ...@@ -1506,18 +1488,19 @@ private static void SetDataStatesAndRemark(IEnumerable<ex_result_gather> data, i
if (func != null) if (func != null)
remark = string.Format(remark, func.Invoke(item)); remark = string.Format(remark, func.Invoke(item));
item.States = states; //item.States = states;
item.Remark = (!string.IsNullOrEmpty(item.Remark) && item.Remark.Length > 0) ? item.Remark + ", " + remark : remark; item.Remark = (!string.IsNullOrEmpty(item.Remark) && item.Remark.Length > 0) ? item.Remark + ", " + remark : remark;
} }
} }
private void AddCategoryToConfig(List<ex_result_gather> data, int hospitalId) public void AddCategoryToConfig(int allotId)
{ {
if (data == null || !data.Any(w => w.States == 2)) return; var allot = perallotRepository.GetEntity(w => w.ID == allotId);
data = data.Where(w => w.States == 2).ToList(); var data = exresultgatherRepository.GetEntities(w => w.AllotId == allotId);
if (data == null || !data.Any()) return;
var modules = exmoduleRepository.GetEntities(w => w.HospitalId == hospitalId && w.SheetType != (int)SheetType.Income); var modules = exmoduleRepository.GetEntities(w => w.HospitalId == allot.HospitalId && w.SheetType != (int)SheetType.Income);
if (modules == null || !modules.Any()) return; if (modules == null || !modules.Any()) return;
var items = exitemRepository.GetEntities(w => modules.Select(t => t.Id).Distinct().Contains(w.ModuleId ?? 0)); var items = exitemRepository.GetEntities(w => modules.Select(t => t.Id).Distinct().Contains(w.ModuleId ?? 0));
...@@ -1528,16 +1511,16 @@ private void AddCategoryToConfig(List<ex_result_gather> data, int hospitalId) ...@@ -1528,16 +1511,16 @@ private void AddCategoryToConfig(List<ex_result_gather> data, int hospitalId)
var insertList = new List<ex_item>(); var insertList = new List<ex_item>();
foreach (var module in modules) foreach (var module in modules)
{ {
var categories = data.Where(t => t.Source == module.ModuleName)?.Select(t => t.Category).Distinct(); var categories = data.Where(t => module.ModuleName.Contains(t.Source))?.Select(t => t.Category).Distinct();
if (categories == null || !categories.Any()) continue; if (categories == null || !categories.Any()) continue;
var moduleItems = items.Where(w => w.ModuleId == module.Id)?.Select(t => t.ItemName).Distinct(); var moduleItems = items.Where(w => w.ModuleId == module.Id)?.Select(t => t.ItemName).Distinct();
if (moduleItems == null || !moduleItems.Any()) continue; if (moduleItems != null && moduleItems.Any())
categories = categories.Except(moduleItems);
var exceptCategories = categories.Except(moduleItems); if (categories == null || !categories.Any()) continue;
if (exceptCategories == null || !exceptCategories.Any()) continue;
insertList.AddRange(exceptCategories.Select(t => new ex_item insertList.AddRange(categories.Select(t => new ex_item
{ {
ModuleId = module.Id, ModuleId = module.Id,
ItemName = t, ItemName = t,
...@@ -1553,15 +1536,18 @@ private void AddCategoryToConfig(List<ex_result_gather> data, int hospitalId) ...@@ -1553,15 +1536,18 @@ private void AddCategoryToConfig(List<ex_result_gather> data, int hospitalId)
var speacialCategories = data.Where(t => t.Source.Contains("特殊核算单元"))?.Select(t => new { t.Category, t.Department }).Distinct(); var speacialCategories = data.Where(t => t.Source.Contains("特殊核算单元"))?.Select(t => new { t.Category, t.Department }).Distinct();
if (speacialCategories == null || !speacialCategories.Any()) return; if (speacialCategories == null || !speacialCategories.Any()) return;
var specials = exspecialRepository.GetEntities(w => w.HospitalId == hospitalId); var specials = exspecialRepository.GetEntities(w => w.HospitalId == allot.HospitalId);
if (specials == null || !specials.Any()) return; if (specials == null || !specials.Any()) return;
var list = speacialCategories.Where(w => !specials.Select(t => t.Target + t.Department).Contains(w.Category + w.Department)); var list = (specials == null || !specials.Any())
? speacialCategories
: speacialCategories.Where(w => !specials.Select(t => t.Target + t.Department).Contains(w.Category + w.Department));
if (list == null || !list.Any()) return; if (list == null || !list.Any()) return;
exspecialRepository.AddRange(list.Select(t => new ex_special exspecialRepository.AddRange(list.Select(t => new ex_special
{ {
HospitalId = hospitalId, HospitalId = allot.HospitalId,
Department = t.Department, Department = t.Department,
Target = t.Category Target = t.Category
}).ToArray()); }).ToArray());
...@@ -1575,10 +1561,10 @@ private void AddCategoryToConfig(List<ex_result_gather> data, int hospitalId) ...@@ -1575,10 +1561,10 @@ private void AddCategoryToConfig(List<ex_result_gather> data, int hospitalId)
public void SyncDataToResult(int allotId) 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);
if (data == null || !data.Any() || data.Any(w => w.States == 1)) return; if (data == null || !data.Any()) return;
var syncData = _mapper.Map<List<ex_result>>(data); var syncData = _mapper.Map<List<ex_result>>(data);
......
...@@ -197,7 +197,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -197,7 +197,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
{ {
var departments = data.Select(s => s.Department ?? "")/*.Where(w => !string.IsNullOrEmpty(w))*/.Distinct().ToList(); var departments = data.Select(s => s.Department ?? "")/*.Where(w => !string.IsNullOrEmpty(w))*/.Distinct().ToList();
var filed = new Dictionary<string, Func<ExtractTransDto, string>>(); var filed = fieldOut;
if (sheetType == SheetType.Income) if (sheetType == SheetType.Income)
{ {
if (sheet.SheetName.Contains("住院") || sheet.SheetName.Contains("门诊")) if (sheet.SheetName.Contains("住院") || sheet.SheetName.Contains("门诊"))
......
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