Commit 880cb1ef by lcx

抽取写入Excel

parent 0bcf471a
......@@ -161,12 +161,15 @@ public ApiResponse AddItem([FromBody] ItemListRequest request)
[HttpPost]
public ApiResponse Items([FromBody] ModItemRequest request)
{
if (!configService.QueryHosConfigs(request.ModuleId.Value))
if (!configService.QueryHosConfigs(request.ModuleId.Value, out int sheetType))
return new ApiResponse(ResponseType.Fail, "当前医院未配置地址");
if (sheetType == (int)SheetType.Income)
{
logger.LogInformation($"绩效收入模板配置项列表 : 请求地址 {url.HttpPost}/modextract/items");
HttpHelper.HttpPost(url.HttpPost + "/modextract/items", JsonHelper.Serialize(request), true);
logger.LogInformation($"绩效收入模板配置项列表在{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss完成请求")}");
}
var list = configService.QueryItems(request.ModuleId.Value);
return new ApiResponse(ResponseType.OK, list);
}
......@@ -182,7 +185,7 @@ public ApiResponse EditItem([FromBody] ItemListRequest request)
if (request.Items == null || !request.Items.Any())
return new ApiResponse(ResponseType.ParameterError, "请选择需要修改的数据!");
var entity = 0;//= configService.EditItem(request.Items[0]);
var entity = configService.EditItem(request.Items[0]);
return new ApiResponse(ResponseType.OK, "修改成功!", entity);
}
......
......@@ -13,7 +13,7 @@ public class ModModuleRequest
/// <summary> 医院Id </summary>
public Nullable<int> HospitalId { get; set; }
public Nullable<int> ExtractId { get; set; }
public Nullable<int> TypeId { get; set; }
/// <summary>
/// 数据库地址
......
......@@ -98,7 +98,7 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
{
typeIds.AddRange(modules.Select(t => t.TypeId ?? 0));
items = perforExitemRepository.GetEntities(t => t.ModuleId.HasValue
&& modules.Select(m => m.Id).Contains(t.ModuleId.Value));
&& modules.Where(m => m.SheetType != (int)SheetType.Income).Select(m => m.Id).Contains(t.ModuleId.Value));
typeIds.AddRange(items?.Select(t => t.TypeId ?? 0) ?? new List<int>());
}
......@@ -155,14 +155,13 @@ private List<ex_result> ExtractIncome<TEntity>(List<TEntity> entities, List<ex_s
foreach (var module in modules.Where(t => t.TypeId > 0))
{
foreach (var item in scripts.Where(t => t.TypeId == module.TypeId))
{
foreach (var config in configs)
{
var item = scripts.FirstOrDefault(t => t.TypeId == module.TypeId && t.DatabaseType == config.DataBaseType);
if (item == null) continue;
data.AddRange(QueryData(config, allot, item.ExecScript, module.ModuleName));
}
}
}
if (data != null && data.Any())
perforExresultRepository.AddRange(data.ToArray());
......@@ -188,17 +187,17 @@ private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_sc
foreach (var exitem in items.Where(t => t.TypeId > 0))
{
var model = modules.FirstOrDefault(t => t.Id == exitem.ModuleId);
foreach (var item in scripts.Where(t => t.TypeId == exitem.TypeId))
{
var module = modules.FirstOrDefault(t => t.Id == exitem.ModuleId);
foreach (var config in configs)
{
var result = QueryData(config, allot, item.ExecScript, model.ModuleName);
var item = scripts.FirstOrDefault(t => t.TypeId == exitem.TypeId && t.DatabaseType == config.DataBaseType);
if (item == null) continue;
var result = QueryData(config, allot, item.ExecScript, module.ModuleName);
result.ForEach(t => t.Category = exitem.ItemName);
data.AddRange(result);
}
}
}
if (data != null && data.Any())
perforExresultRepository.AddRange(data.ToArray());
......@@ -223,11 +222,12 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s
foreach (var special in specials.Where(t => t.TypeId > 0))
{
foreach (var item in scripts.Where(t => t.TypeId == special.TypeId))
{
foreach (var config in configs)
{
var result = QueryData(config, allot, item.ExecScript, "");
var item = scripts.FirstOrDefault(t => t.TypeId == special.TypeId && t.DatabaseType == config.DataBaseType);
if (item == null) continue;
var result = QueryData(config, allot, item.ExecScript, "4.2 特殊核算单元绩效测算表");
result.ForEach(t =>
{
t.Category = special.Target;
......@@ -236,7 +236,6 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s
data.AddRange(result);
}
}
}
if (data != null && data.Any())
perforExresultRepository.AddRange(data.ToArray());
......@@ -425,6 +424,7 @@ private List<ex_result> QueryData(sys_hospitalconfig config, per_allot allot, st
Source = source,
DatabaseType = config.DataBaseType,
ConfigId = config.Id,
AllotId = allot.ID,
}).ToList();
}
return data;
......@@ -636,7 +636,7 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
var itemList = items.Where(t => t.ModuleId == module.Id).ToList();
logger.LogInformation($"item有{itemList?.Count ?? 0}个.");
if (itemList == null || !itemList.Any()) return;
//if (itemList == null || !itemList.Any()) return;
var extractdata = data.Where(t => t.AllotId == Allot.ID && t.Source == module.ModuleName);
if (extractdata == null || !extractdata.Any())
......@@ -650,7 +650,7 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
Value = t.Fee ?? 0
}).ToList();
logger.LogInformation($"{sheet.SheetName}合计值为: " + allExtract.Sum(t => t.Value));
//logger.LogInformation($"{sheet.SheetName}合计值为: " + allExtract.Sum(t => t.Value));
var category = allExtract.Select(t => t.Category).Distinct().ToList();
WriteIncomeHeaderAndFactor(sheet, sheetRead, category, isNewTemp);
......
......@@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
......@@ -138,7 +139,7 @@ public ex_module AddModule(ModModuleRequest request)
HospitalId = request.HospitalId,
Description = request.Description,
SheetType = request.SheetType,
TypeId = request.ExtractId,
TypeId = request.TypeId,
ReadOnly = 0,
};
if (!exmoduleRepository.Add(entity))
......@@ -161,7 +162,7 @@ public ex_module EditModule(ModModuleRequest request)
entity.ModuleName = request.ModuleName ?? entity.ModuleName;
entity.SheetType = request.SheetType;
entity.Description = request.Description;
entity.TypeId = request.ExtractId;
entity.TypeId = request.TypeId;
entity.ConfigId = request.ConfigId;
if (!exmoduleRepository.Update(entity))
throw new PerformanceException("修改失败!");
......@@ -311,14 +312,15 @@ public void DelSpecial(int specialId)
#endregion
public bool QueryHosConfigs(int moduleId)
public bool QueryHosConfigs(int moduleId, out int sheetType)
{
var module = exmoduleRepository.GetEntity(t => t.Id == moduleId);
if (module == null)
throw new PerformanceException("绩效模板不存在,请重新选择!");
if (module.SheetType != (int)SheetType.Income)
throw new PerformanceException("当前模板不能进行考核项目自动添加");
sheetType = (int)SheetType.Income;
//if (module.SheetType != (int)SheetType.Income)
// throw new PerformanceException("当前模板不能进行考核项目自动添加");
var hospitalConfigs = hospitalconfigRepository.GetEntities(t => t.HospitalId == module.HospitalId);
if (hospitalConfigs != null && hospitalConfigs.Any())
......@@ -438,12 +440,24 @@ public List<sys_hospitalconfig> GetHospitalconfigs(int hospitalId)
public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType)
{
var titlevalue = new List<TitleValue>();
var list = extypeRepository.GetEntities(t => new List<int> { 0, hospitalId }.Contains(t.HospitalId) && executeType.Contains(t.Source));
Expression<Func<ex_type, bool>> exp = t => new List<int> { 0, hospitalId }.Contains(t.HospitalId);
if (executeType.FirstOrDefault() == 1)
exp = exp.And(t => t.Source == (int)SheetType.Income);
else
exp = exp.And(t => t.Source != (int)SheetType.Income);
var list = extypeRepository.GetEntities(exp);
if (list != null && list.Any())
{
var scripts = exscriptRepository.GetEntities(t => list.Select(w => w.Id).Contains(t.TypeId));
//var scripts = exscriptRepository.GetEntities(t => list.Select(w => w.Id).Contains(t.TypeId));
//titlevalue = list.Where(t => scripts.Select(w => w.TypeId).Contains(t.Id)).Select(t => new TitleValue
//{
// Title = string.IsNullOrEmpty(t.Description) ? t.EName : $"{t.EName}({t.Description})",
// Value = t.Id.ToString()
//}).OrderBy(t => t.Title).ToList();
titlevalue = list.Where(t => scripts.Select(w => w.TypeId).Contains(t.Id)).Select(t => new TitleValue
titlevalue = list.Select(t => new TitleValue
{
Title = string.IsNullOrEmpty(t.Description) ? t.EName : $"{t.EName}({t.Description})",
Value = t.Id.ToString()
......
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