Commit 3acd34e0 by lcx

Merge branch '手工录入' of http://192.168.18.110:8880/zry/performance into develop

parents 3dd3d5a8 f4080e41
...@@ -736,6 +736,92 @@ public ApiResponse GetDeptComparison([FromBody] ComparisonPagingRequest request) ...@@ -736,6 +736,92 @@ public ApiResponse GetDeptComparison([FromBody] ComparisonPagingRequest request)
return new ApiResponse(ResponseType.OK, relust); return new ApiResponse(ResponseType.OK, relust);
} }
#region 手工录入
/// <summary>
/// 手工录入 - 下拉列表
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("getgatherdrop/{allotId}")]
[HttpPost]
public ApiResponse GetGatherDrop([FromRoute] int allotId)
{
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
var relust = employeeService.GetGatherDrop(allotId);
return new ApiResponse(ResponseType.OK, relust);
}
/// <summary>
/// 手工录入 - 录入界面
/// </summary>
/// <param name="allotId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("getgatherhands/{allotId}")]
[HttpPost]
public ApiResponse GetGatherHands([FromRoute] int allotId, [FromBody] GatherRequest request)
{
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
var relust = employeeService.GetGatherHands(allotId, request);
return new ApiResponse(ResponseType.OK, relust);
}
/// <summary>
/// 保存手工录入
/// </summary>
/// <param name="allotId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("savegatherhands/{allotId}")]
[HttpPost]
public ApiResponse SaveGatherHands(int allotId, [FromBody] SaveGatherData request)
{
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
if (string.IsNullOrEmpty(request.Source) || string.IsNullOrEmpty(request.Category))
return new ApiResponse(ResponseType.OK);
employeeService.SaveGatherHands(allotId, request);
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 手工录入列表 - 明细
/// </summary>
/// <param name="allotId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("getgather/{allotId}")]
[HttpPost]
public ApiResponse GetGather([FromRoute] int allotId, [FromBody] PersonParamsRequest request)
{
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
var result = employeeService.GetGather(allotId, request);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 手工录入列表 - 汇总
/// </summary>
/// <param name="allotId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("getgathertotal/{allotId}")]
[HttpPost]
public ApiResponse GetGatherTotal([FromRoute] int allotId, [FromBody] PersonParamsRequest request)
{
return new ApiResponse(ResponseType.OK);
}
#endregion
} }
} }
...@@ -1190,6 +1190,37 @@ ...@@ -1190,6 +1190,37 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.EmployeeController.GetGatherDrop(System.Int32)">
<summary>
手工录入 - 下拉列表
</summary>
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.GetGatherHands(System.Int32,Performance.DtoModels.GatherRequest)">
<summary>
手工录入
</summary>
<param name="allotId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.SaveGatherHands(System.Int32,Performance.DtoModels.SaveGatherData)">
<summary>
保存手工录入
</summary>
<param name="allotId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.GetGather(System.Int32,Performance.DtoModels.PersonParamsRequest)">
<summary>
手工录入列表
</summary>
<param name="allotId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ExConfigController.Extract(Performance.DtoModels.ModModuleRequest)"> <member name="M:Performance.Api.Controllers.ExConfigController.Extract(Performance.DtoModels.ModModuleRequest)">
<summary> <summary>
绩效数据抽取模板 绩效数据抽取模板
......
...@@ -157,6 +157,9 @@ ...@@ -157,6 +157,9 @@
<member name="P:Performance.EntityModels.PerformanceDbContext.ex_type"> <member name="P:Performance.EntityModels.PerformanceDbContext.ex_type">
<summary> </summary> <summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.PerformanceDbContext.ex_result_gather">
<summary> </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.his_data"> <member name="P:Performance.EntityModels.PerformanceDbContext.his_data">
<summary> </summary> <summary> </summary>
</member> </member>
...@@ -3571,6 +3574,51 @@ ...@@ -3571,6 +3574,51 @@
1 删除 0 未删除 1 删除 0 未删除
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ex_result_gather.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.AllotId">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.DoctorName">
<summary>
医生姓名
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.PersonnelNumber">
<summary>
人员工号
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.Category">
<summary>
费用类型
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.Fee">
<summary>
费用
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.Source">
<summary>
来源
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.CreateTime">
<summary>
创建时间
</summary>
</member>
<member name="T:Performance.EntityModels.ex_script"> <member name="T:Performance.EntityModels.ex_script">
<summary> <summary>
......
...@@ -250,6 +250,9 @@ public AutoMapperConfigs() ...@@ -250,6 +250,9 @@ public AutoMapperConfigs()
CreateMap<ag_secondallot, IssuedPromptResponse>() CreateMap<ag_secondallot, IssuedPromptResponse>()
.ReverseMap(); .ReverseMap();
CreateMap<ex_result, ex_result_gather>()
.ReverseMap();
} }
} }
} }
...@@ -89,4 +89,18 @@ public class PerSheetHeader ...@@ -89,4 +89,18 @@ public class PerSheetHeader
//("调节系数", (t) => Math.Round(t.Adjust.Value * 100, 2), 1, 1, false, true, true, "Adjust"), //("调节系数", (t) => Math.Round(t.Adjust.Value * 100, 2), 1, 1, false, true, true, "Adjust"),
}; };
} }
public class ColumnHeadsConfig
{
public static List<Heads> GatherHeads { get; } = new List<Heads>
{
new Heads{Column="科室",Name=nameof(ex_result_gather.Department)},
new Heads{Column="医生姓名",Name=nameof(ex_result_gather.DoctorName)},
new Heads{Column="人员工号",Name=nameof(ex_result_gather.PersonnelNumber)},
new Heads{Column="费用类型",Name=nameof(ex_result_gather.Category)},
new Heads{Column="费用",Name=nameof(ex_result_gather.Fee)},
new Heads{Column="来源",Name=nameof(ex_result_gather.Source)}
};
}
} }
using Performance.EntityModels; using Performance.EntityModels;
using System; using Performance.Infrastructure.Models;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels namespace Performance.DtoModels
{ {
......
using Performance.EntityModels;
using Performance.Infrastructure.Models;
using System.Collections.Generic;
namespace Performance.DtoModels
{
public class GatherResponse
{
public List<Heads> Heads { get; set; }
public PageList<ex_result_gather> Datas { get; set; }
public int CurrentPage { get; set; }
public int TotalPages { get; set; }
public int PageSize { get; set; }
public int TotalCount { get; set; }
}
public class GatherDropResponse
{
public string Label { get; set; }
public string Value { get; set; }
public List<GatherDropResponse> Children { get; set; }
}
public class GatherRequest
{
public string Source { get; set; }
public string Category { get; set; }
}
}
...@@ -29,4 +29,12 @@ public class SaveCustomData ...@@ -29,4 +29,12 @@ public class SaveCustomData
public string[] ColHeaders { get; set; } public string[] ColHeaders { get; set; }
public string[][] Data { get; set; } public string[][] Data { get; set; }
} }
public class SaveGatherData
{
public string Source { get; set; }
public string Category { get; set; }
public string[] ColHeaders { get; set; }
public new string[][] Data { get; set; }
}
} }
...@@ -116,6 +116,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -116,6 +116,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <summary> </summary> /// <summary> </summary>
public virtual DbSet<ex_type> ex_type { get; set; } public virtual DbSet<ex_type> ex_type { get; set; }
/// <summary> </summary> /// <summary> </summary>
public virtual DbSet<ex_result_gather> ex_result_gather { get; set; }
/// <summary> </summary>
public virtual DbSet<his_data> his_data { get; set; } public virtual DbSet<his_data> his_data { get; set; }
/// <summary> </summary> /// <summary> </summary>
public virtual DbSet<his_import_account> his_import_account { get; set; } public virtual DbSet<his_import_account> his_import_account { get; set; }
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.EntityModels
{
public class ex_result_gather
{
/// <summary>
///
/// </summary>
public int Id { get; set; }
/// <summary>
///
/// </summary>
public int AllotId { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 医生姓名
/// </summary>
public string DoctorName { get; set; }
/// <summary>
/// 人员工号
/// </summary>
public string PersonnelNumber { get; set; }
/// <summary>
/// 费用类型
/// </summary>
public string Category { get; set; }
/// <summary>
/// 费用
/// </summary>
public decimal Fee { get; set; }
/// <summary>
/// 来源
/// </summary>
public string Source { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 1 未通过 2 通过
/// </summary>
public int States { get; set; }
}
}
...@@ -30,6 +30,13 @@ public new PageList<per_employee> GetEntitiesForPaging(int pageNumber, int pageS ...@@ -30,6 +30,13 @@ public new PageList<per_employee> GetEntitiesForPaging(int pageNumber, int pageS
} }
public PageList<ex_result_gather> GetGatherForPaging(int pageNumber, int pageSize, Expression<Func<ex_result_gather, bool>> exp)
{
IQueryable<ex_result_gather> queryableAuthors = context.Set<ex_result_gather>().Where(exp).OrderBy(w => w.Department).ThenBy(t => t.PersonnelNumber);
return PageList<ex_result_gather>.Create(queryableAuthors, pageNumber, pageSize);
}
//public Comparison GetComparison(ComparisonPagingRequest request) //public Comparison GetComparison(ComparisonPagingRequest request)
//{ //{
// var search = ""; // var search = "";
......
using Performance.EntityModels;
namespace Performance.Repository
{
public partial class PerforExresultgatherRepository : PerforRepository<ex_result_gather>
{
public PerforExresultgatherRepository(PerformanceDbContext context) : base(context)
{
}
}
}
...@@ -35,6 +35,13 @@ public class EmployeeService : IAutoInjection ...@@ -35,6 +35,13 @@ public class EmployeeService : IAutoInjection
private PerforUserRepository userRepository; private PerforUserRepository userRepository;
private readonly PerforRoleRepository _roleRepository; private readonly PerforRoleRepository _roleRepository;
private readonly PerforPerapramounthideRepository _hideRepository; private readonly PerforPerapramounthideRepository _hideRepository;
private readonly PerforExresultgatherRepository exresultgatherRepository;
private readonly PerforImheaderRepository imheaderRepository;
private readonly PerforPerdeptdicRepository perdeptdicRepository;
private readonly PerforExmoduleRepository exmoduleRepository;
private readonly PerforExitemRepository exitemRepository;
private readonly PerforExspecialRepository exspecialRepository;
private readonly PerforExresultRepository exresultRepository;
private ILogger<EmployeeService> logger; private ILogger<EmployeeService> logger;
public EmployeeService( public EmployeeService(
...@@ -53,6 +60,13 @@ public class EmployeeService : IAutoInjection ...@@ -53,6 +60,13 @@ public class EmployeeService : IAutoInjection
PerforUserRepository userRepository, PerforUserRepository userRepository,
PerforRoleRepository roleRepository, PerforRoleRepository roleRepository,
PerforPerapramounthideRepository hideRepository, PerforPerapramounthideRepository hideRepository,
PerforExresultgatherRepository exresultgatherRepository,
PerforImheaderRepository imheaderRepository,
PerforPerdeptdicRepository perdeptdicRepository,
PerforExmoduleRepository exmoduleRepository,
PerforExitemRepository exitemRepository,
PerforExspecialRepository exspecialRepository,
PerforExresultRepository exresultRepository,
ILogger<EmployeeService> logger) ILogger<EmployeeService> logger)
{ {
_mapper = mapper; _mapper = mapper;
...@@ -70,6 +84,13 @@ public class EmployeeService : IAutoInjection ...@@ -70,6 +84,13 @@ public class EmployeeService : IAutoInjection
this.userRepository = userRepository; this.userRepository = userRepository;
_roleRepository = roleRepository; _roleRepository = roleRepository;
_hideRepository = hideRepository; _hideRepository = hideRepository;
this.exresultgatherRepository = exresultgatherRepository;
this.imheaderRepository = imheaderRepository;
this.perdeptdicRepository = perdeptdicRepository;
this.exmoduleRepository = exmoduleRepository;
this.exitemRepository = exitemRepository;
this.exspecialRepository = exspecialRepository;
this.exresultRepository = exresultRepository;
this.logger = logger; this.logger = logger;
} }
...@@ -1124,6 +1145,328 @@ public ComparisonResponse GetComparison(ComparisonPagingRequest request) ...@@ -1124,6 +1145,328 @@ public ComparisonResponse GetComparison(ComparisonPagingRequest request)
return result; return result;
} }
#region 手工数据录入
public List<GatherDropResponse> GetGatherDrop(int allotId)
{
again:
var perSheets = perforPersheetRepository.GetEntities(t => t.AllotID == allotId && new[] { 3, 4, 7 }.Contains(t.SheetType.Value));
if (perSheets == null || !perSheets.Any())
{
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
var list = perallotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (list == null || !list.Any(t => t.ID == allot.ID)) return new List<GatherDropResponse>();
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID) return new List<GatherDropResponse>();
goto again;
}
//var sheets = perSheets.Select(t => new GatherDropResponse() { Label = t.SheetName, Value = t.SheetName });
var imHeaders = imheaderRepository.GetEntities(t => t.AllotID == allotId);
var result = new List<GatherDropResponse>();
var cellValue = new[] { "核算单元(医技组)", "核算单元(医生组)", "核算单元(护理组)", "科室名称" };
foreach (var sheet in perSheets)
{
var drop = new GatherDropResponse();
var header = imHeaders.Where(t => t.SheetID == sheet.ID && !cellValue.Contains(t.CellValue)).Select(t => t.CellValue).Distinct();
drop.Label = sheet.SheetName.Split(' ')[1];
drop.Value = sheet.SheetName.Split(' ')[1];
drop.Children = header.Select(t => new GatherDropResponse() { Label = t, Value = t }).ToList();
result.Add(drop);
}
return result;
}
public HandsonTable GetGatherHands(int AllotId, GatherRequest request)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, Gather.Select(t => t.Value).ToArray(), Gather.Select(t => new collect_permission
{
HeadName = t.Value,
Visible = 1
}).ToList());
if (result.Columns != null && result.Columns.Any())
{
foreach (var column in result.Columns)
{
if (column.Data == "数值")
{
column.Type = "numeric";
column.NumericFormat = new NumericFormat { Pattern = "0,00.00" };
}
else
column.Type = "text";
}
}
var data = exresultgatherRepository.GetEntities(t => t.AllotId == AllotId && t.Source.Contains(request.Source) && t.Category.Contains(request.Category));
if (data == null)
return result;
List<HandsonRowData> rowDatas = new List<HandsonRowData>();
int i = 1;
foreach (var item in data)
{
var json = JsonHelper.Serialize(item);
var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json);
var cells = (from conf in Gather join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper() select new HandsonCellData(conf.Value, fst.Value)).ToList();
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
return result;
}
public void SaveGatherHands(int allotId, SaveGatherData request)
{
var dicData = CreateDataRow(0, allotId, request, Gather);
List<ex_result_gather> depts = new List<ex_result_gather>();
DateTime timeNow = DateTime.Now;
foreach (var item in dicData)
{
var json = JsonHelper.Serialize(item);
var data = JsonHelper.Deserialize<ex_result_gather>(json);
if (!string.IsNullOrEmpty(data.Department) && !string.IsNullOrEmpty(data.Fee.ToString()))
{
data.Source = request.Source;
data.Category = request.Category;
data.AllotId = allotId;
data.CreateTime = timeNow;
depts.Add(data);
}
}
exresultgatherRepository.Execute($@"delete from ex_result_gather where allotid = @allotid and source like '%{request.Source}%' and category = '{request.Category}' ", new { allotId });
exresultgatherRepository.AddRange(depts.ToArray());
}
public GatherResponse GetGather(int allotId, PersonParamsRequest request)
{
var head = ColumnHeadsConfig.GatherHeads;
head.ForEach(t =>
{
t.Name = t.Name.ToLower();
});
Expression<Func<ex_result_gather, bool>> exp = t => t.AllotId == allotId;
if (request != null && !string.IsNullOrEmpty(request.SearchQuery))
exp = exp.And(t => t.Department.Contains(request.SearchQuery) || t.DoctorName.Contains(request.SearchQuery) || t.PersonnelNumber.Contains(request.SearchQuery) || t.Category.Contains(request.SearchQuery) || t.Source.Contains(request.SearchQuery));
var data = peremployeeRepository.GetGatherForPaging(request.PageNumber, request.PageSize, exp);
return new GatherResponse()
{
Heads = head,
Datas = data,
CurrentPage = data.CurrentPage,
TotalCount = data.TotalCount,
PageSize = data.PageSize,
TotalPages = data.TotalPages
};
}
public static Dictionary<string, string> Gather { get; } = new Dictionary<string, string>
{
{nameof(ex_result_gather.Department), "科室"},
{nameof(ex_result_gather.DoctorName), "医生姓名"},
{nameof(ex_result_gather.PersonnelNumber), "人员工号"},
//{nameof(ex_result_gather.Category), "费用类型"},
{nameof(ex_result_gather.Fee), "数值"},
//{nameof(ex_result_gather.Source), "来源"}
};
private List<Dictionary<string, string>> CreateDataRow(int hospitalId, int allotId, SaveGatherData request, Dictionary<string, string> config)
{
List<Dictionary<string, string>> allData = new List<Dictionary<string, string>>();
for (int r = 0; r < request.Data.Length; r++)
{
// 创建固定数据列
Dictionary<string, string> baseData = CreateBaseData(request, config, r);
baseData.Add(nameof(cof_hrp_department.AllotId), hospitalId.ToString());
allData.Add(baseData);
}
return allData;
}
private Dictionary<string, string> CreateBaseData(SaveGatherData request, Dictionary<string, string> config, int rownumber)
{
Dictionary<string, string> result = new Dictionary<string, string>();
for (int c = 0; c < request.ColHeaders.Length; c++)
{
var header = request.ColHeaders[c];
var first = config.FirstOrDefault(w => w.Value == header);
if (!default(KeyValuePair<string, string>).Equals(first)
&& !result.ContainsKey(header)
&& request.Data[rownumber].Length > c)
{
result.Add(first.Key, request.Data[rownumber][c]);
}
}
return result;
}
#endregion
#region 录入校验
public bool CheckGatherData(int allotId)
{
try
{
var allot = perallotRepository.GetEntity(w => w.ID == allotId);
if (allot == null) throw new PerformanceException("绩效记录不存在");
var data = exresultgatherRepository.GetEntities(w => w.AllotId == allotId);
if (data == null || !data.Any()) throw new PerformanceException("录入数据为空");
SetDataStatesAndRemark(data, 2, string.Empty);
var departments = perdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId);
if (departments != null && departments.Any())
{
var notExistsDeptData = data.Where(w => !departments.Select(t => t.Department).Contains(w.Department));
if (notExistsDeptData != null && notExistsDeptData.Any())
SetDataStatesAndRemark(notExistsDeptData, 1, "科室字典中不存在科室[{0}]", t => t.Department);
}
var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotId);
if (employees != null && employees.Any())
{
var notExistNameData = data.Where(w => !employees.Select(t => t.DoctorName).Contains(w.DoctorName) && !string.IsNullOrEmpty(w.DoctorName));
if (notExistNameData != null && notExistNameData.Any())
SetDataStatesAndRemark(notExistNameData, 1, "人员字典中不存在医生名称[{0}]", t => t.DoctorName);
var notExistNumberData = data.Where(w => !employees.Select(t => t.PersonnelNumber).Contains(w.PersonnelNumber) && !string.IsNullOrEmpty(w.PersonnelNumber));
if (notExistNumberData != null && notExistNumberData.Any())
SetDataStatesAndRemark(notExistNumberData, 1, "人员字典中不存在工号[{0}]", t => t.PersonnelNumber);
}
var sheets = perforPersheetRepository.GetEntities(w => w.AllotID == allotId);
if (sheets != null && sheets.Any())
{
var notExistsSourceData = data.Where(w => !sheets.Select(t => t.SheetName).Contains(w.Source));
if (notExistsSourceData != null && notExistsSourceData.Any())
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("校验失败");
}
}
private static void SetDataStatesAndRemark(IEnumerable<ex_result_gather> data, int states, string remark, Func<ex_result_gather, string> func = null)
{
if (new int[] { 1, 2 }.Contains(states)) return;
if (data == null || !data.Any()) return;
foreach (var item in data)
{
if (func != null)
remark = string.Format(remark, func.Invoke(item));
item.States = states;
item.Remark = (!string.IsNullOrEmpty(item.Remark) && item.Remark.Length > 0) ? item.Remark + ", " + remark : remark;
}
}
private void AddCategoryToConfig(List<ex_result_gather> data, int hospitalId)
{
if (data == null || !data.Any(w => w.States == 2)) return;
data = data.Where(w => w.States == 2).ToList();
var modules = exmoduleRepository.GetEntities(w => w.HospitalId == hospitalId && w.SheetType != (int)SheetType.Income);
if (modules == null || !modules.Any()) return;
var items = exitemRepository.GetEntities(w => modules.Select(t => t.Id).Distinct().Contains(w.ModuleId ?? 0));
if (items == null || !items.Any()) return;
try
{
var insertList = new List<ex_item>();
foreach (var module in modules)
{
var categories = data.Where(t => t.Source == module.ModuleName)?.Select(t => t.Category).Distinct();
if (categories == null || !categories.Any()) continue;
var moduleItems = items.Where(w => w.ModuleId == module.Id)?.Select(t => t.ItemName).Distinct();
if (moduleItems == null || !moduleItems.Any()) continue;
var exceptCategories = categories.Except(moduleItems);
if (exceptCategories == null || !exceptCategories.Any()) continue;
insertList.AddRange(exceptCategories.Select(t => new ex_item
{
ModuleId = module.Id,
ItemName = t,
ReadOnly = 0
}));
}
if (insertList != null && insertList.Any())
{
exitemRepository.AddRange(insertList.ToArray());
}
var speacialCategories = data.Where(t => t.Source.Contains("特殊核算单元"))?.Select(t => new { t.Category, t.Department }).Distinct();
if (speacialCategories == null || !speacialCategories.Any()) return;
var specials = exspecialRepository.GetEntities(w => w.HospitalId == hospitalId);
if (specials == null || !specials.Any()) return;
var list = speacialCategories.Where(w => !specials.Select(t => t.Target + t.Department).Contains(w.Category + w.Department));
if (list == null || !list.Any()) return;
exspecialRepository.AddRange(list.Select(t => new ex_special
{
HospitalId = hospitalId,
Department = t.Department,
Target = t.Category
}).ToArray());
}
catch (Exception ex)
{
logger.LogError(ex.Message);
}
}
public void SyncDataToResult(int allotId)
{
var data = exresultgatherRepository.GetEntities(w => w.AllotId == allotId);
if (data == null || !data.Any() || data.Any(w => w.States == 1)) return;
var syncData = _mapper.Map<List<ex_result>>(data);
exresultRepository.AddRange(syncData.ToArray());
}
#endregion
} }
public class ComparisonConfig public class ComparisonConfig
......
...@@ -23,6 +23,7 @@ public class ExtractService : IAutoInjection ...@@ -23,6 +23,7 @@ public class ExtractService : IAutoInjection
private readonly PerSheetService perSheetService; private readonly PerSheetService perSheetService;
private readonly CostTransferDataWrite costTransfer; private readonly CostTransferDataWrite costTransfer;
private readonly DictionaryService dictionaryService; private readonly DictionaryService dictionaryService;
private readonly EmployeeService employeeService;
private readonly CustomDataWrite customDataWrite; private readonly CustomDataWrite customDataWrite;
private readonly PerforPerallotRepository perallotRepository; private readonly PerforPerallotRepository perallotRepository;
private readonly PerforCollectdataRepository collectdataRepository; private readonly PerforCollectdataRepository collectdataRepository;
...@@ -30,6 +31,7 @@ public class ExtractService : IAutoInjection ...@@ -30,6 +31,7 @@ public class ExtractService : IAutoInjection
private readonly PerforPeremployeeRepository peremployeeRepository; private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforPerdeptdicRepository perdeptdicRepository; private readonly PerforPerdeptdicRepository perdeptdicRepository;
private readonly PerforCofdrugtypefactorRepository drugtypefactorRepository; private readonly PerforCofdrugtypefactorRepository drugtypefactorRepository;
private readonly PerforExresultRepository exresultRepository;
public ExtractService( public ExtractService(
ILogger<ExtractService> logger, ILogger<ExtractService> logger,
...@@ -39,13 +41,15 @@ public class ExtractService : IAutoInjection ...@@ -39,13 +41,15 @@ public class ExtractService : IAutoInjection
PerSheetService perSheetService, PerSheetService perSheetService,
CostTransferDataWrite costTransfer, CostTransferDataWrite costTransfer,
DictionaryService dictionaryService, DictionaryService dictionaryService,
EmployeeService employeeService,
CustomDataWrite customDataWrite, CustomDataWrite customDataWrite,
PerforPerallotRepository perallotRepository, PerforPerallotRepository perallotRepository,
PerforCollectdataRepository collectdataRepository, PerforCollectdataRepository collectdataRepository,
PerforExtypeRepository extypeRepository, PerforExtypeRepository extypeRepository,
PerforPeremployeeRepository peremployeeRepository, PerforPeremployeeRepository peremployeeRepository,
PerforPerdeptdicRepository perdeptdicRepository, PerforPerdeptdicRepository perdeptdicRepository,
PerforCofdrugtypefactorRepository drugtypefactorRepository PerforCofdrugtypefactorRepository drugtypefactorRepository,
PerforExresultRepository exresultRepository
) )
{ {
this.logger = logger; this.logger = logger;
...@@ -55,6 +59,7 @@ PerforCofdrugtypefactorRepository drugtypefactorRepository ...@@ -55,6 +59,7 @@ PerforCofdrugtypefactorRepository drugtypefactorRepository
this.perSheetService = perSheetService; this.perSheetService = perSheetService;
this.costTransfer = costTransfer; this.costTransfer = costTransfer;
this.dictionaryService = dictionaryService; this.dictionaryService = dictionaryService;
this.employeeService = employeeService;
this.customDataWrite = customDataWrite; this.customDataWrite = customDataWrite;
this.perallotRepository = perallotRepository; this.perallotRepository = perallotRepository;
this.collectdataRepository = collectdataRepository; this.collectdataRepository = collectdataRepository;
...@@ -62,6 +67,7 @@ PerforCofdrugtypefactorRepository drugtypefactorRepository ...@@ -62,6 +67,7 @@ PerforCofdrugtypefactorRepository drugtypefactorRepository
this.peremployeeRepository = peremployeeRepository; this.peremployeeRepository = peremployeeRepository;
this.perdeptdicRepository = perdeptdicRepository; this.perdeptdicRepository = perdeptdicRepository;
this.drugtypefactorRepository = drugtypefactorRepository; this.drugtypefactorRepository = drugtypefactorRepository;
this.exresultRepository = exresultRepository;
} }
/// <summary> /// <summary>
...@@ -96,7 +102,10 @@ public string Main(int allotId, int hospitalId, string email, string groupName, ...@@ -96,7 +102,10 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
queryService.ClearHistoryData(allot.ID, groupName, isSingle); queryService.ClearHistoryData(allot.ID, groupName, isSingle);
var data = queryService.Handler(hospitalId, allot, groupName, isSingle, ref dict); employeeService.SyncDataToResult(allotId);
var data = exresultRepository.GetEntities(t => t.AllotId == allotId && t.IsDelete == 0);
data.AddRange(queryService.Handler(hospitalId, allot, groupName, isSingle, ref dict));
var standData = StandDataFormat(hospitalId, data); var standData = StandDataFormat(hospitalId, data);
dictionaryService.Handler(hospitalId, allot, groupName, isSingle); dictionaryService.Handler(hospitalId, allot, groupName, isSingle);
......
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