科室字典修改为按月单独存储

parent 9c91da6a
......@@ -230,13 +230,13 @@ public ApiResponse<List<sys_role>> RoleList()
/// <summary>
/// 科室列表
/// </summary>
/// <param name="request"></param>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("department")]
[Route("department/{allotId}")]
[HttpPost]
public ApiResponse<List<TitleValue>> Department([FromBody] SetDepartmentRequest request)
public ApiResponse<List<TitleValue>> Department(int allotId)
{
var department = _userService.Department(request.HospitalID);
var department = _userService.Department(allotId);
return new ApiResponse<List<TitleValue>>(ResponseType.OK, "ok", department);
}
......
......@@ -868,14 +868,15 @@ public ApiResponse CopyDropDown()
{
var result = new List<CopyDrop>
{
new CopyDrop{Label="核算单元及组别",Value="accountings"},
new CopyDrop{Label="科室字典",Value="department"},
new CopyDrop{Label="人员字典",Value="personnels"},
new CopyDrop{Label="工作量配置",Value="workItems"},
new CopyDrop{Label="收入费用类别",Value="drugTypes"},
//new CopyDrop{Label="收入费用类别",Value="drugTypes"},
new CopyDrop{Label="支出费用类别",Value="drugTypeDisburses"},
new CopyDrop{Label="费用类别系数",Value="drugTypeFactors"},
/* new CopyDrop{Label="科室类型",Value="deptTypes"},*/
//new CopyDrop{Label="科室类型",Value="deptTypes"},
new CopyDrop{Label="二次绩效配置",Value="agains"},
new CopyDrop{Label="核算单元及组别",Value="accountings"},
}; ;
return new ApiResponse(ResponseType.OK, result);
}
......
......@@ -129,13 +129,13 @@ public IActionResult DownloadCurrentCalculationTable([FromRoute] int allotId)
/// <summary>
/// 获取所有科室记录
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("deptdic/list/{hospitalId}")]
[Route("deptdic/list/{allotId}")]
[HttpPost]
public ApiResponse GetDepartments(int hospitalId)
public ApiResponse GetDepartments(int allotId)
{
var list = personService.GetDepartments(hospitalId);
var list = personService.GetDepartments(allotId);
return new ApiResponse(ResponseType.OK, list);
}
......@@ -194,14 +194,14 @@ public ApiResponse DeleteDeptDic([FromBody] DeptdicResponse request)
/// <param name="hospitalId">医院Id</param>
/// <param name="type">1系统科室 2标准科室 3核算单元 4行政后勤 5特殊核算组</param>
/// <returns></returns>
[Route("deptdic/{hospitalId}/dict/{type}")]
[Route("deptdic/{allotId}/dict/{type}")]
[HttpPost]
public ApiResponse DeptDics(int hospitalId, int type)
public ApiResponse DeptDics(int allotId, int type)
{
if (!new int[] { 1, 2, 3, 4, 5 }.Contains(type))
return new ApiResponse(ResponseType.ParameterError, "参数错误!");
var result = personService.DeptDics(hospitalId, type);
var result = personService.DeptDics(allotId, type);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -234,10 +234,10 @@ public ApiResponse DeptIncomeDetail([CustomizeValidator(RuleSet = "Select"), Fro
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("person/GetBatchPersonStructrue/{hospitalId}")]
public ApiResponse GetBatchPersonStructrue(int hospitalId)
[Route("person/GetBatchPersonStructrue/{allotId}")]
public ApiResponse GetBatchPersonStructrue(int allotId)
{
var result = personService.GetBatchPersonStructrue(hospitalId);
var result = personService.GetBatchPersonStructrue(allotId);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -257,10 +257,10 @@ public ApiResponse BathSavePerson(int allotId, int hospitalId, SaveCollectData r
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("dept/GetDeptStructrue/{hospitalId}")]
public ApiResponse GetDeptStructrue(int hospitalId)
[Route("dept/GetDeptStructrue/{allotId}")]
public ApiResponse GetDeptStructrue(int allotId)
{
var result = personService.GetDepartmentHands(hospitalId);
var result = personService.GetDepartmentHands(allotId);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -269,10 +269,10 @@ public ApiResponse GetDeptStructrue(int hospitalId)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("dept/SaveDeptHands/{hospitalId}")]
public ApiResponse SaveDeptHands(int hospitalId, SaveCollectData request)
[Route("dept/SaveDeptHands/{allotId}")]
public ApiResponse SaveDeptHands(int allotId, SaveCollectData request)
{
personService.SaveDeptDicHands(hospitalId, request);
personService.SaveDeptDicHands(allotId, request);
return new ApiResponse(ResponseType.OK);
}
......
......@@ -62,11 +62,11 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.Department(Performance.DtoModels.SetDepartmentRequest)">
<member name="M:Performance.Api.Controllers.AccountController.Department(System.Int32)">
<summary>
科室列表
</summary>
<param name="request"></param>
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AccountController.DemoUsers">
......@@ -1724,7 +1724,7 @@
<summary>
获取所有科室记录
</summary>
<param name="hospitalId"></param>
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.PersonController.CreateDeptDic(Performance.EntityModels.per_dept_dic)">
......
......@@ -6620,6 +6620,11 @@
医院Id
</summary>
</member>
<member name="P:Performance.EntityModels.per_dept_dic.AllotId">
<summary>
AllotId
</summary>
</member>
<member name="P:Performance.EntityModels.per_dept_dic.IsVerify">
<summary>
0 未通过验证 1 通过验证
......
......@@ -6,6 +6,7 @@ namespace Performance.DtoModels
{
public class DeptdicResponse
{
public int AllotId { get; set; }
public int HospitalId { get; set; }
public string HISDeptName { get; set; }
public string Department { get; set; }
......
......@@ -50,6 +50,10 @@ public class per_dept_dic
/// 医院Id
/// </summary>
public Nullable<int> HospitalId { get; set; }
/// <summary>
/// AllotId
/// </summary>
public Nullable<int> AllotId { get; set; }
/// <summary>
/// 0 未通过验证 1 通过验证
......
......@@ -121,6 +121,40 @@ public class AllotService : IAutoInjection
this.queryDataService = queryDataService;
}
#region 先取上一个月的绩效Id
/// <summary>
/// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
/// </summary>
/// <param name="allot"></param>
public int GetPrevAllot(int allotId)
{
var allot = _allotRepository.GetEntity(t => t.ID == allotId);
return GetPrevAllot(allot);
}
/// <summary>
/// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
/// </summary>
/// <param name="allot"></param>
public int GetPrevAllot(per_allot allot)
{
var list = _allotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (list == null || !list.Any(t => t.ID == allot.ID))
return -1;
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的数据
int allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID)
return -1;
return allotId;
}
#endregion
#region 基础功能
/// <summary>
......
......@@ -560,7 +560,7 @@ private List<HandsonRowData> GetAccountExtra(per_allot allot, int sheetType, str
var unitTypes = new string[] { UnitType.医生组.ToString(), UnitType.医技组.ToString(), UnitType.护理组.ToString(), UnitType.特殊核算组.ToString() };
var departments = perforPerdeptdicRepository.GetEntities(t => t.HospitalId == allot.HospitalId && unitTypes.Contains(t.UnitType) && !string.IsNullOrEmpty(t.Department) && t.Department.Replace("无", "").Replace("/", "").Trim() != "");
var departments = perforPerdeptdicRepository.GetEntities(t => t.AllotId == allot.ID && unitTypes.Contains(t.UnitType) && !string.IsNullOrEmpty(t.Department) && t.Department.Replace("无", "").Replace("/", "").Trim() != "");
if (departments == null || !departments.Any()) return handsonRows;
var data = departments.GroupBy(t => t.Department).Select(t => new
......
using AutoMapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.EntityModels.Other;
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Repository.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Performance.Repository.Repository;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using Performance.EntityModels.Other;
namespace Performance.Services
{
public class ConfigService : IAutoInjection
{
private readonly IMapper _mapper;
#region
private readonly IMapper _mapper;
private readonly UserService _userService;
private readonly RoleService _roleService;
private readonly AllotService _allotService;
private readonly CopyService _copyService;
private readonly PersonService _personService;
private readonly LogManageService _logManageService;
private readonly ExConfigService _exConfigService;
private readonly PerforReportRepository _perforReport;
private readonly PerforImdataRepository _imdataRepository;
private readonly PerforPerallotRepository _perallotRepository;
private readonly PerforCofdirectorRepository _directorRepository;
//private readonly PerforCofdrugpropRepository _drugpropRepository;
private readonly PerforCofworkitemRepository _workitemRepository;
private readonly PerforCofagainRepository _againRepository;
private readonly PerforCofdrugtypeRepository _drugtypeRepository;
private readonly PerforPerallotRepository perforPerAllotRepository;
private readonly PerforHospitalRepository perforHospitalRepository;
private readonly PerforPersheetRepository perforPersheetRepository;
private readonly PerforImheaderRepository perforImheaderRepository;
private readonly PerforImdataRepository imdataRepository;
private readonly PerforCofdepttypeRepository perforCofdepttypeRepository;
private readonly PerforPerapramountRepository perapramountRepository;
//private readonly PerforCofcmiRepository perforCofcmiRepository;
private readonly PerforCofHrpDeptRepository perforCofHrpDeptRepository;
private readonly PerforCofaliasRepository perforCofaliasRepository;
private readonly PerforCofaccountingRepository cofaccountingRepository;
private readonly PerforCofdrugtypeDisburseRepository drugtypeDisburseRepository;
private readonly PersonService personService;
private readonly LogManageService logManageService;
private readonly ExConfigService exConfigService;
private readonly ILogger<ConfigService> logger;
private readonly PerforExmoduleRepository perforExmoduleRepository;
private readonly PerforCofdrugtypefactorRepository cofdrugtypefactorRepository;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforReportRepository perforReport;
private readonly PerforPerallotRepository _perforPerAllotRepository;
private readonly PerforPersheetRepository _perforPersheetRepository;
private readonly PerforImheaderRepository _perforImheaderRepository;
private readonly PerforCofdepttypeRepository _perforCofdepttypeRepository;
private readonly PerforCofHrpDeptRepository _perforCofHrpDeptRepository;
private readonly PerforCofaliasRepository _perforCofaliasRepository;
private readonly PerforCofaccountingRepository _cofaccountingRepository;
private readonly PerforCofdrugtypeDisburseRepository _drugtypeDisburseRepository;
private readonly PerforExmoduleRepository _perforExmoduleRepository;
private readonly PerforCofdrugtypefactorRepository _cofdrugtypefactorRepository;
public ConfigService(
IMapper mapper,
UserService userService,
RoleService roleService,
AllotService allotService,
CopyService copyService,
PersonService personService,
LogManageService logManageService,
ExConfigService exConfigService,
PerforReportRepository perforReport,
PerforImdataRepository imdataRepository,
PerforPerallotRepository perallotRepository,
PerforCofdirectorRepository cofdirectorRepository,
//PerforCofdrugpropRepository cofdrugpropRepository,
PerforCofagainRepository againRepository,
PerforExmoduleRepository perforExmoduleRepository,
PerforCofdrugtypeRepository drugtypeRepository,
PerforPerallotRepository perforPerAllotRepository,
PerforHospitalRepository perforHospitalRepository,
PerforCofworkitemRepository workitemRepository,
PerforPersheetRepository perforPersheetRepository,
PerforImheaderRepository perforImheaderRepository,
PerforImdataRepository imdataRepository,
PerforCofdepttypeRepository perforCofdepttypeRepository,
PerforPerapramountRepository perapramountRepository,
//PerforCofcmiRepository perforCofcmiRepository,
PerforCofHrpDeptRepository perforCofHrpDeptRepository,
PerforCofaliasRepository perforCofaliasRepository,
PerforCofaccountingRepository cofaccountingRepository,
PerforCofdrugtypeDisburseRepository drugtypeDisburseRepository,
PersonService personService,
LogManageService logManageService,
ILogger<ConfigService> logger,
ExConfigService exConfigService,
PerforExmoduleRepository perforExmoduleRepository,
PerforCofdrugtypefactorRepository cofdrugtypefactorRepository,
PerforPerallotRepository perallotRepository,
PerforReportRepository perforReport)
PerforCofdrugtypefactorRepository cofdrugtypefactorRepository)
{
_mapper = mapper;
_userService = userService;
_roleService = roleService;
this._directorRepository = cofdirectorRepository;
//this._drugpropRepository = cofdrugpropRepository;
this._workitemRepository = workitemRepository;
this._againRepository = againRepository;
this._drugtypeRepository = drugtypeRepository;
this.perforPerAllotRepository = perforPerAllotRepository;
this.perforHospitalRepository = perforHospitalRepository;
this.perforPersheetRepository = perforPersheetRepository;
this.perforImheaderRepository = perforImheaderRepository;
this.imdataRepository = imdataRepository;
this.perforCofdepttypeRepository = perforCofdepttypeRepository;
this.perapramountRepository = perapramountRepository;
//this.perforCofcmiRepository = perforCofcmiRepository;
this.perforCofHrpDeptRepository = perforCofHrpDeptRepository;
this.perforCofaliasRepository = perforCofaliasRepository;
this.cofaccountingRepository = cofaccountingRepository;
this.drugtypeDisburseRepository = drugtypeDisburseRepository;
this.personService = personService;
this.logManageService = logManageService;
this.exConfigService = exConfigService;
this.logger = logger;
this.perforExmoduleRepository = perforExmoduleRepository;
this.cofdrugtypefactorRepository = cofdrugtypefactorRepository;
this.perallotRepository = perallotRepository;
this.perforReport = perforReport;
_allotService = allotService;
_copyService = copyService;
_personService = personService;
_perforReport = perforReport;
_logManageService = logManageService;
_exConfigService = exConfigService;
_imdataRepository = imdataRepository;
_againRepository = againRepository;
_drugtypeRepository = drugtypeRepository;
_perallotRepository = perallotRepository;
_directorRepository = cofdirectorRepository;
_workitemRepository = workitemRepository;
_perforPerAllotRepository = perforPerAllotRepository;
_perforPersheetRepository = perforPersheetRepository;
_perforImheaderRepository = perforImheaderRepository;
_perforCofdepttypeRepository = perforCofdepttypeRepository;
_perforCofHrpDeptRepository = perforCofHrpDeptRepository;
_perforCofaliasRepository = perforCofaliasRepository;
_cofaccountingRepository = cofaccountingRepository;
_drugtypeDisburseRepository = drugtypeDisburseRepository;
_perforExmoduleRepository = perforExmoduleRepository;
_cofdrugtypefactorRepository = cofdrugtypefactorRepository;
}
#endregion
#region 弃用
//#region cof_director 规模/效率绩效配置
///// <summary>
///// 获取cof_director列表
///// </summary>
///// <returns></returns>
//public List<DirectorResponse> GetDireList(int allotId)
//{
// var list = _directorRepository.GetEntities(t => t.AllotID == allotId);
// return _mapper.Map<List<DirectorResponse>>(list);
//}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DirectorResponse DireInsert(DirectorRequest request)
//{
// var director = _mapper.Map<cof_director>(request);
// if (!_directorRepository.Add(director))
// throw new PerformanceException("保存失败");
// return _mapper.Map<DirectorResponse>(director);
//}
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DirectorResponse DireUpdate(DirectorRequest request)
//{
// var director = _directorRepository.GetEntity(t => t.ID == request.ID);
// if (null == director)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// director.TypeName = request.TypeName;
// director.JobTitle = request.JobTitle;
// director.Value = request.Value;
// if (!_directorRepository.Update(director))
// throw new PerformanceException("保存失败");
// return _mapper.Map<DirectorResponse>(director);
//}
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool DireDelete(DirectorRequest request)
//{
// var director = _directorRepository.GetEntity(t => t.ID == request.ID);
// if (null == director)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// return _directorRepository.Remove(director);
//}
//#endregion
//#region cof_income ICU有效收入配置
///// <summary>
///// 获取cof_income列表
///// </summary>
///// <returns></returns>
//public List<IncomeResponse> GetIncomeList(int allotId)
//{
// var list = _incomeRepository.GetEntities(T => T.AllotID == allotId);
// return _mapper.Map<List<IncomeResponse>>(list);
//}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public IncomeResponse IncomeInsert(IncomeRequest request)
//{
// var income = _mapper.Map<cof_income>(request);
// if (!_incomeRepository.Add(income))
// throw new PerformanceException("保存失败");
// return _mapper.Map<IncomeResponse>(income);
//}
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public IncomeResponse IncomeUpdate(IncomeRequest request)
//{
// var income = _incomeRepository.GetEntity(t => t.ID == request.ID);
// if (null == income)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// income.SheetNameKeyword = request.SheetNameKeyword;
// income.UnitName = request.UnitName;
// income.Value = request.Value;
// if (!_incomeRepository.Update(income))
// throw new PerformanceException("保存失败");
// return _mapper.Map<IncomeResponse>(income);
//}
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool IncomeDelete(IncomeRequest request)
//{
// var income = _incomeRepository.GetEntity(t => t.ID == request.ID);
// if (null == income)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// return _incomeRepository.Remove(income);
//}
//#endregion
//#region cof_workyear 年资系数配置
///// <summary>
///// 获取cof_drugprop列表
///// </summary>
///// <returns></returns>
//public List<WorkyearResponse> GetWorkList(int allotId)
//{
// var list = _workyearRepository.GetEntities(t => t.AllotID == allotId);
// return _mapper.Map<List<WorkyearResponse>>(list);
//}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public WorkyearResponse WorkInsert(WorkyearRequest request)
//{
// var workyear = _mapper.Map<cof_workyear>(request);
// if (!_workyearRepository.Add(workyear))
// throw new PerformanceException("保存失败");
// return _mapper.Map<WorkyearResponse>(workyear);
//}
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public WorkyearResponse WorkUpdate(WorkyearRequest request)
//{
// var workyear = _workyearRepository.GetEntity(t => t.ID == request.ID);
// if (null == workyear)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// workyear.MaxRange = request.MaxRange;
// workyear.MinRange = request.MinRange;
// workyear.Value = request.Value;
// if (!_workyearRepository.Update(workyear))
// throw new PerformanceException("保存失败");
// return _mapper.Map<WorkyearResponse>(workyear);
//}
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool WorkDelete(WorkyearRequest request)
//{
// var workyear = _workyearRepository.GetEntity(t => t.ID == request.ID);
// if (null == workyear)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// return _workyearRepository.Remove(workyear);
//}
//#endregion
#endregion
#region cof_drugprop 药占比系数配置
///// <summary>
///// 获取cof_drugprop列表
///// </summary>
///// <returns></returns>
//public List<DrugpropResponse> GetDrugList(int allotId)
//{
// var list = _drugpropRepository.GetEntities(t => t.AllotID == allotId);
// return _mapper.Map<List<DrugpropResponse>>(list);
//}
///// <summary>
///// 添加数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DrugpropResponse DrugInsert(DrugpropRequest request)
//{
// var drugprop = _mapper.Map<cof_drugprop>(request);
// if (!_drugpropRepository.Add(drugprop))
// throw new PerformanceException("保存失败");
// return _mapper.Map<DrugpropResponse>(drugprop);
//}
///// <summary>
///// 更新数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public DrugpropResponse DrugUpdate(DrugpropRequest request)
//{
// var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
// if (null == drugprop)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// drugprop.MaxRange = request.MaxRange;
// drugprop.MinRange = request.MinRange;
// drugprop.Value = request.Value;
// if (!_drugpropRepository.Update(drugprop))
// throw new PerformanceException("保存失败");
// return _mapper.Map<DrugpropResponse>(drugprop);
//}
///// <summary>
///// 删除数据
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool DrugDelete(DrugpropRequest request)
//{
// var drugprop = _drugpropRepository.GetEntity(t => t.ID == request.ID);
// if (null == drugprop)
// throw new PerformanceException($"ID不存在 :{request.ID}");
// return _drugpropRepository.Remove(drugprop);
//}
#endregion
#region cof_drugtype 药占比类别配置
/// <summary>
......@@ -400,12 +146,6 @@ public cof_drugtype DrugtypeUpdate(DrugpropRequest request)
if (!_drugtypeRepository.Update(entity))
throw new PerformanceException("保存失败");
//var factors = cofdrugtypefactorRepository.GetEntities(t => t.HospitalId == entity.HospitalId && t.AllotID == entity.AllotID && t.Charge == entity.Charge);
//if (factors != null && factors.Any())
//{
// factors.ForEach(t => t.Charge = request.Charge);
// cofdrugtypefactorRepository.UpdateRange(factors.ToArray());
//}
return entity;
}
......@@ -433,7 +173,7 @@ public bool DrugtypeDelete(DrugpropRequest request)
/// <returns></returns>
public List<cof_drugtype_disburse> GetDrugtypeDisburseList(int HospitalId, int allotId)
{
var list = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId && t.HospitalId == HospitalId);
var list = _drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId && t.HospitalId == HospitalId);
return list;
}
......@@ -451,7 +191,7 @@ public cof_drugtype_disburse DrugtypeDisburseInsert(DrugpropRequest request)
Charge = request.Charge,
ChargeType = request.ChargeType
};
if (!drugtypeDisburseRepository.Add(entity))
if (!_drugtypeDisburseRepository.Add(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -463,14 +203,14 @@ public cof_drugtype_disburse DrugtypeDisburseInsert(DrugpropRequest request)
/// <returns></returns>
public cof_drugtype_disburse DrugtypeDisburseUpdate(DrugpropRequest request)
{
var entity = drugtypeDisburseRepository.GetEntity(t => t.ID == request.ID);
var entity = _drugtypeDisburseRepository.GetEntity(t => t.ID == request.ID);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.ID}");
entity.Charge = request.Charge;
entity.ChargeType = request.ChargeType;
if (!drugtypeDisburseRepository.Update(entity))
if (!_drugtypeDisburseRepository.Update(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -482,22 +222,22 @@ public cof_drugtype_disburse DrugtypeDisburseUpdate(DrugpropRequest request)
/// <returns></returns>
public bool DrugtypeDisburseDelete(DrugpropRequest request)
{
var entity = drugtypeDisburseRepository.GetEntity(t => t.ID == request.ID);
var entity = _drugtypeDisburseRepository.GetEntity(t => t.ID == request.ID);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.ID}");
return drugtypeDisburseRepository.Remove(entity);
return _drugtypeDisburseRepository.Remove(entity);
}
public void SaveDrugtypeDisburse(int allotId)
{
var Disburse = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId);
var Disburse = _drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId);
if (Disburse == null || !Disburse.Any()) return;
var perSheet = perforPersheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Expend);
var perSheet = _perforPersheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Expend);
if (perSheet == null || !perSheet.Any()) return;
var TypeNames = imdataRepository.GetEntities(t => perSheet.Select(c => c.ID).Contains(t.SheetID.Value)).Select(t => t.TypeName).Distinct().ToList();
var TypeNames = _imdataRepository.GetEntities(t => perSheet.Select(c => c.ID).Contains(t.SheetID.Value)).Select(t => t.TypeName).Distinct().ToList();
if (TypeNames == null || !TypeNames.Any()) return;
var except = Disburse.Select(t => t.Charge).Distinct().Intersect(TypeNames);
......@@ -511,7 +251,7 @@ public void SaveDrugtypeDisburse(int allotId)
}
var drugDis = TypeNames?.Select(t => new cof_drugtype_disburse { HospitalId = Disburse.FirstOrDefault().HospitalId, AllotID = allotId, Charge = t, ChargeType = "" });
drugtypeDisburseRepository.AddRange(drugDis.ToArray());
_drugtypeDisburseRepository.AddRange(drugDis.ToArray());
}
#endregion
......@@ -587,7 +327,7 @@ public bool WorkItemkDelete(WorkItemRequest request)
/// <returns></returns>
public List<cof_depttype> GetDepttypeList(int allotId)
{
var list = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId);
var list = _perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId);
return list;
}
......@@ -604,7 +344,7 @@ public cof_depttype DepttypeInsert(DrugpropRequest request)
Charge = request.Charge,
ChargeType = request.ChargeType
};
if (!perforCofdepttypeRepository.Add(entity))
if (!_perforCofdepttypeRepository.Add(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -616,14 +356,14 @@ public cof_depttype DepttypeInsert(DrugpropRequest request)
/// <returns></returns>
public cof_depttype DepttypeUpdate(DrugpropRequest request)
{
var entity = perforCofdepttypeRepository.GetEntity(t => t.ID == request.ID);
var entity = _perforCofdepttypeRepository.GetEntity(t => t.ID == request.ID);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.ID}");
entity.Charge = request.Charge;
entity.ChargeType = request.ChargeType;
if (!perforCofdepttypeRepository.Update(entity))
if (!_perforCofdepttypeRepository.Update(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -635,11 +375,11 @@ public cof_depttype DepttypeUpdate(DrugpropRequest request)
/// <returns></returns>
public bool DepttypeDelete(DrugpropRequest request)
{
var entity = perforCofdepttypeRepository.GetEntity(t => t.ID == request.ID);
var entity = _perforCofdepttypeRepository.GetEntity(t => t.ID == request.ID);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.ID}");
return perforCofdepttypeRepository.Remove(entity);
return _perforCofdepttypeRepository.Remove(entity);
}
#endregion
......@@ -777,7 +517,7 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == request.AllotId;
if (request.AllotId == 0)
{
var allots = perforPerAllotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
var allots = _perforPerAllotRepository.GetEntities(t => t.HospitalId == request.HospitalId);
if (allots == null || !allots.Any())
throw new PerformanceException("请先配置科室信息");
exp = t => allots.Select(a => a.ID).Contains(t.AllotId);
......@@ -786,7 +526,7 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
if (request.Type == (int)AccountTypeEnum.AccountingUnit && !string.IsNullOrEmpty(request.UnitType))
exp = exp.And(t => t.UnitType.Replace("行政后勤", "行政工勤") == request.UnitType.Replace("行政后勤", "行政工勤"));
return cofaccountingRepository.GetEntities(exp)?.OrderBy(t => t.IsVerify).ThenBy(t => ConvertHelper.To<int>(t.Code)).ToList() ?? new List<cof_accounting>();
return _cofaccountingRepository.GetEntities(exp)?.OrderBy(t => t.IsVerify).ThenBy(t => ConvertHelper.To<int>(t.Code)).ToList() ?? new List<cof_accounting>();
}
/// <summary>
......@@ -796,10 +536,10 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
/// <returns></returns>
public cof_accounting AccountingInsert(cof_accounting request)
{
var existed = cofaccountingRepository.GetEntity(w => w.AllotId == request.AllotId && w.Code == request.Code);
var existed = _cofaccountingRepository.GetEntity(w => w.AllotId == request.AllotId && w.Code == request.Code);
if (existed != null) throw new PerformanceException("核算单元编码重复");
existed = cofaccountingRepository.GetEntity(w => w.AllotId == request.AllotId && w.UnitType == request.UnitType && w.AccountingUnit == request.AccountingUnit);
existed = _cofaccountingRepository.GetEntity(w => w.AllotId == request.AllotId && w.UnitType == request.UnitType && w.AccountingUnit == request.AccountingUnit);
if (existed != null) throw new PerformanceException("核算单元、核算组别已存在");
var entity = new cof_accounting
......@@ -810,7 +550,7 @@ public cof_accounting AccountingInsert(cof_accounting request)
AccountingUnit = request.AccountingUnit,
IsVerify = 1,
};
if (!cofaccountingRepository.Add(entity))
if (!_cofaccountingRepository.Add(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -822,14 +562,14 @@ public cof_accounting AccountingInsert(cof_accounting request)
/// <returns></returns>
public cof_accounting AccountingUpdate(cof_accounting request)
{
var entity = cofaccountingRepository.GetEntity(t => t.Id == request.Id);
var entity = _cofaccountingRepository.GetEntity(t => t.Id == request.Id);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.Id}");
var existed = cofaccountingRepository.GetEntity(w => w.Id != request.Id && w.AllotId == request.AllotId && w.Code == request.Code);
var existed = _cofaccountingRepository.GetEntity(w => w.Id != request.Id && w.AllotId == request.AllotId && w.Code == request.Code);
if (existed != null) throw new PerformanceException("核算单元编码重复");
existed = cofaccountingRepository.GetEntity(w => w.Id != request.Id && w.AllotId == request.AllotId && w.UnitType == request.UnitType && w.AccountingUnit == request.AccountingUnit);
existed = _cofaccountingRepository.GetEntity(w => w.Id != request.Id && w.AllotId == request.AllotId && w.UnitType == request.UnitType && w.AccountingUnit == request.AccountingUnit);
if (existed != null) throw new PerformanceException("核算单元、核算组别已存在");
entity.AllotId = request.AllotId;
......@@ -838,7 +578,7 @@ public cof_accounting AccountingUpdate(cof_accounting request)
entity.AccountingUnit = request.AccountingUnit;
entity.IsVerify = 1;
if (!cofaccountingRepository.Update(entity))
if (!_cofaccountingRepository.Update(entity))
throw new PerformanceException("保存失败");
return entity;
}
......@@ -850,11 +590,11 @@ public cof_accounting AccountingUpdate(cof_accounting request)
/// <returns></returns>
public bool AccountingDelete(int accountingId)
{
var entity = cofaccountingRepository.GetEntity(t => t.Id == accountingId);
var entity = _cofaccountingRepository.GetEntity(t => t.Id == accountingId);
if (null == entity)
throw new PerformanceException($"ID不存在 :{accountingId}");
return cofaccountingRepository.Remove(entity);
return _cofaccountingRepository.Remove(entity);
}
public HandsonTable GetBatchAccountingStructrue(int AllotId)
......@@ -890,7 +630,7 @@ public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request)
var dicData = CreateDataRow(0, allotId, request, Accounting);
if (dicData == null || !dicData.Any()) throw new PerformanceException("未提交数据");
var getAccounts = cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? new List<cof_accounting>();
var getAccounts = _cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? new List<cof_accounting>();
var unitType = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
var json = JsonHelper.Serialize(dicData);
......@@ -958,7 +698,7 @@ public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request)
delAccounts.Add(account);
}
if (delAccounts != null && delAccounts.Any())
cofaccountingRepository.RemoveRange(delAccounts.ToArray());
_cofaccountingRepository.RemoveRange(delAccounts.ToArray());
if (accounts != null && accounts.Any())
{
......@@ -967,14 +707,14 @@ public ApiResponse BatchSaveAccounting(int allotId, SaveCollectData request)
account.AllotId = allotId;
account.IsVerify = 1;
});
cofaccountingRepository.AddRange(accounts.ToArray());
_cofaccountingRepository.AddRange(accounts.ToArray());
}
return new ApiResponse(ResponseType.OK);
}
public bool BatchCheckAccounting(int allotId)
{
var accounts = cofaccountingRepository.GetEntities(t => t.AllotId == allotId);
var accounts = _cofaccountingRepository.GetEntities(t => t.AllotId == allotId);
if (accounts == null || !accounts.Any()) return true;
......@@ -1009,7 +749,7 @@ public bool BatchCheckAccounting(int allotId)
}
}
return cofaccountingRepository.UpdateRange(accounts.ToArray());
return _cofaccountingRepository.UpdateRange(accounts.ToArray());
}
public static Dictionary<string, string> Accounting { get; } = new Dictionary<string, string>
......@@ -1030,202 +770,22 @@ public bool BatchCheckAccounting(int allotId)
/// <param name="iD"></param>
public void Copy(per_allot allot)
{
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (list == null || !list.Any(t => t.ID == allot.ID)) return;
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的数据
int allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID) allotId = -1;
CopyCommand(allot, allotId);
var prevAllotId = _allotService.GetPrevAllot(allot);
CopyCommand(allot, prevAllotId);
}
public void CopyCommand(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
#region 弃用
//var hospital = perforHospitalRepository.GetEntity(t => t.ID == allot.HospitalId);
_personService.CreateAllotPersons(allot.HospitalId, allot.ID, prevAllotId);
_copyService.Copy_WorkItems(allot, prevAllotId, delHistotyData);
_copyService.Copy_DrugTypes(allot, prevAllotId, delHistotyData);
_copyService.Copy_DrugTypeDisburses(allot, prevAllotId, delHistotyData);
_copyService.Copy_DrugTypeFactors(allot, prevAllotId, delHistotyData);
_copyService.Copy_DeptTypes(allot, prevAllotId, delHistotyData);
_copyService.Copy_Agains(allot, prevAllotId, delHistotyData);
_copyService.Copy_Accountings(allot, prevAllotId, delHistotyData);
_copyService.Copy_DeptDic(allot, prevAllotId, delHistotyData);
//logger.LogInformation($"apramount{allotId} {allot.ID}");
//CopyAprData(allotId, allot.ID);
//CopyCMIData(allotId, allot.ID);
//var orgDirector = _directorRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgDirector == null || orgDirector.Count == 0)
//{
// var director = _directorRepository.GetEntities(t => t.AllotID == allotId) ?? _directorRepository.GetEntities(t => t.AllotID == -1);
// var newDirectors = director.Select(t => new cof_director { AllotID = allot.ID, JobTitle = t.JobTitle, TypeName = t.TypeName, Value = t.Value });
// if (hospital != null && hospital?.IsOpenDirector == 2)
// newDirectors = director.Select(t => new cof_director { AllotID = allot.ID, JobTitle = t.JobTitle, TypeName = t.TypeName, Value = 1 });
// _directorRepository.AddRange(newDirectors.ToArray());
//}
//var orgIncome = _incomeRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgIncome == null || orgIncome.Count == 0)
//{
// var income = _incomeRepository.GetEntities(t => t.AllotID == allotId) ?? _incomeRepository.GetEntities(t => t.AllotID == -1);
// var newIncomes = income.Select(t => new cof_income { AllotID = allot.ID, SheetNameKeyword = t.SheetNameKeyword, UnitName = t.UnitName, Value = t.Value });
// if (hospital != null && hospital?.IsOpenIncome == 2)
// newIncomes = income.Select(t => new cof_income { AllotID = allot.ID, SheetNameKeyword = t.SheetNameKeyword, UnitName = t.UnitName, Value = 1 });
// _incomeRepository.AddRange(newIncomes.ToArray());
//}
//var orgWorkyear = _workyearRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgWorkyear == null || orgWorkyear.Count == 0)
//{
// var workyear = _workyearRepository.GetEntities(t => t.AllotID == allotId) ?? _workyearRepository.GetEntities(t => t.AllotID == -1);
// var newWorkyears = workyear.Select(t => new cof_workyear { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
// if (hospital != null && hospital?.IsOpenWorkYear == 2)
// newWorkyears = new List<cof_workyear> { new cof_workyear { AllotID = allot.ID, MaxRange = 1000, MinRange = 0, Value = 1 } };
// _workyearRepository.AddRange(newWorkyears.ToArray());
//}
//logger.LogInformation($"orgDurgprop");
//var orgDurgprop = _drugpropRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgDurgprop == null || orgDurgprop.Count == 0)
//{
// var durgprop = _drugpropRepository.GetEntities(t => t.AllotID == allotId) ?? _drugpropRepository.GetEntities(t => t.AllotID == -1);
// var newDurgprops = durgprop?.Select(t => new cof_drugprop { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
// //if (hospital != null && hospital?.IsOpenDrugprop == 2)
// // newDurgprops = new List<cof_drugprop> { new cof_drugprop { AllotID = allot.ID, MaxRange = 1000, MinRange = 0, Value = 1 } };
// if (durgprop != null && durgprop.Any())
// _drugpropRepository.AddRange(newDurgprops.ToArray());
//}
#endregion
var flag = delHistotyData;
personService.CreateAllotPersons(allot.HospitalId, allot.ID, prevAllotId);
logger.LogInformation($"copy workItems");
var workItems = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && workItems != null && workItems.Any())
flag = _workitemRepository.RemoveRange(workItems.ToArray());
if (flag || workItems == null || !workItems.Any())
{
workItems = _workitemRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItems != null && workItems.Any())
{
var newWorkItems = workItems.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItems.ToArray());
}
}
logger.LogInformation($"copy drugTypes");
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypes != null && drugTypes.Any())
flag = _drugtypeRepository.RemoveRange(drugTypes.ToArray());
if (flag || drugTypes == null || !drugTypes.Any())
{
drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
if (drugTypes != null && drugTypes.Any())
{
var newDrugTypes = drugTypes.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newDrugTypes.ToArray());
}
}
logger.LogInformation($"copy drugTypeDisburses");
var drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypeDisburses != null && drugTypeDisburses.Any())
flag = drugtypeDisburseRepository.RemoveRange(drugTypeDisburses.ToArray());
if (flag || drugTypeDisburses == null || !drugTypeDisburses.Any())
{
drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId)
?? drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeDisburses != null && drugTypeDisburses.Any())
{
var newDrugTypeDisburses = drugTypeDisburses.Select(t => new cof_drugtype_disburse { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
drugtypeDisburseRepository.AddRange(newDrugTypeDisburses.ToArray());
}
}
logger.LogInformation($"copy drugTypeFactors");
var drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypeFactors != null && drugTypeFactors.Any())
flag = cofdrugtypefactorRepository.RemoveRange(drugTypeFactors.ToArray());
if (flag || drugTypeFactors == null || !drugTypeFactors.Any())
{
drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId)
?? cofdrugtypefactorRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeFactors != null && drugTypeFactors.Any())
{
var newDrugtypeFactors = drugTypeFactors.Select(t => new cof_drugtype_factor
{
HospitalId = allot.HospitalId,
AllotID = allot.ID,
ExModuleId = t.ExModuleId,
Charge = t.Charge,
YSZ = t.YSZ,
HLZ = t.HLZ,
YJZ = t.YJZ
});
cofdrugtypefactorRepository.AddRange(newDrugtypeFactors.ToArray());
}
}
logger.LogInformation($"copy deptTypes");
var deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && deptTypes != null && deptTypes.Any())
flag = perforCofdepttypeRepository.RemoveRange(deptTypes.ToArray());
if (flag || deptTypes == null || !deptTypes.Any())
{
deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == prevAllotId) ?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
if (deptTypes != null && deptTypes.Any())
{
var newDeptTypes = deptTypes.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
perforCofdepttypeRepository.AddRange(newDeptTypes.ToArray());
}
}
logger.LogInformation($"copy agains");
var agains = _againRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && agains != null && agains.Any())
flag = _againRepository.RemoveRange(agains.ToArray());
if (flag || agains == null || !agains.Any())
{
agains = _againRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _againRepository.GetEntities(t => t.AllotID == -1);
if (agains != null && agains.Any())
{
var days = DateTime.DaysInMonth(allot.Year, allot.Month);
var newAgains = agains.Select(t => new cof_again
{
AllotID = allot.ID,
Type = t.Type,
Department = t.Department,
TypeName = t.TypeName,
Value = t.TypeName == "满勤天数" ? days : t.Value
});
_againRepository.AddRange(newAgains.ToArray());
}
}
logger.LogInformation($"copy accountings");
var accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allot.ID);
if (delHistotyData && accountings != null && accountings.Any())
flag = cofaccountingRepository.RemoveRange(accountings.ToArray());
if (flag || accountings == null || !accountings.Any())
{
accountings = cofaccountingRepository.GetEntities(t => t.AllotId == prevAllotId) ?? cofaccountingRepository.GetEntities(t => t.AllotId == -1);
if (accountings != null && accountings.Any())
{
var newAccountings = accountings.Select(t => new cof_accounting
{
AllotId = allot.ID,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
Code = t.Code,
IsVerify = t.IsVerify,
VerifyMessage = t.VerifyMessage
});
cofaccountingRepository.AddRange(newAccountings.ToArray());
}
}
}
//todo:新copy
......@@ -1236,154 +796,28 @@ public void CopyCommand(per_allot allot, int prevAllotId, bool delHistotyData =
/// <param name="type"></param>
public void NewCopy(CopyRequest request)
{
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (list == null || !list.Any(t => t.ID == allot.ID)) return;
if (request.Type.Length < 1) return;
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
var allot = _perallotRepository.GetEntity(t => t.ID == request.AllotId);
var prevAllotId = _allotService.GetPrevAllot(allot);
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
int allotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (allotId == allot.ID) request.AllotId = -1;
if (request.Type.Length < 1)
return;
foreach (var item in request.Type)
{
switch (item)
{
case "personnels":
personService.CreateAllotPersons(allot.HospitalId, allot.ID, allotId);
break;
case "workItems":
logger.LogInformation($"copy workItems");
var workItems = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
//先判断是否为空,不为空删除再执行下面的代码
if (workItems != null)
{
_workitemRepository.RemoveRange(workItems.ToArray());
}
workItems = _workitemRepository.GetEntities(t => t.AllotID == allotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItems != null && workItems.Any())
var pairs = new Dictionary<string, Action<per_allot, int>>
{
var newWorkItems = workItems.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItems.ToArray());
}
break;
case "drugTypes":
logger.LogInformation($"copy drugTypes");
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (drugTypes != null)
{
_drugtypeRepository.RemoveRange(drugTypes.ToArray());
}
{ "personnels", (allot, prevAllotId) => _personService.CreateAllotPersons(allot.HospitalId, allot.ID, prevAllotId) },
{ "workItems", (allot, prevAllotId) => _copyService.Copy_WorkItems(allot, prevAllotId, delHistotyData:true) },
{ "drugTypes", (allot, prevAllotId) =>_copyService.Copy_DrugTypes(allot, prevAllotId, delHistotyData:true) },
{ "drugTypeDisburses", (allot, prevAllotId) =>_copyService.Copy_DrugTypeDisburses(allot, prevAllotId, delHistotyData:true) },
{ "drugTypeFactors", (allot, prevAllotId) =>_copyService.Copy_DrugTypeFactors(allot, prevAllotId, delHistotyData:true) },
{ "deptTypes", (allot, prevAllotId) =>_copyService.Copy_DeptTypes(allot, prevAllotId, delHistotyData:true) },
{ "agains", (allot, prevAllotId) =>_copyService.Copy_Agains(allot, prevAllotId, delHistotyData:true) },
{ "accountings", (allot, prevAllotId) =>_copyService.Copy_Accountings(allot, prevAllotId, delHistotyData:true) },
{ "department", (allot, prevAllotId) =>_copyService.Copy_DeptDic(allot, prevAllotId, delHistotyData:true) },
};
var Types = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allotId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
if (drugTypes != null && drugTypes.Any())
{
var newDrugTypes = drugTypes.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newDrugTypes.ToArray());
}
break;
case "drugTypeDisburses":
logger.LogInformation($"copy drugTypeDisburses");
var drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (drugTypeDisburses != null)
{
drugtypeDisburseRepository.RemoveRange(drugTypeDisburses.ToArray());
}
drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId) ?? drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeDisburses != null && drugTypeDisburses.Any())
{
var newDrugTypeDisburses = drugTypeDisburses.Select(t => new cof_drugtype_disburse { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
drugtypeDisburseRepository.AddRange(newDrugTypeDisburses.ToArray());
}
break;
case "drugTypeFactors":
logger.LogInformation($"copy drugTypeFactors");
var drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allot.ID);
if (drugTypeFactors != null)
{
cofdrugtypefactorRepository.RemoveRange(drugTypeFactors.ToArray());
}
drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allotId) ?? cofdrugtypefactorRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeFactors != null && drugTypeFactors.Any())
{
var newDrugtypeFactors = drugTypeFactors.Select(t => new cof_drugtype_factor
{
HospitalId = allot.HospitalId,
AllotID = allot.ID,
ExModuleId = t.ExModuleId,
Charge = t.Charge,
YSZ = t.YSZ,
HLZ = t.HLZ,
YJZ = t.YJZ
});
cofdrugtypefactorRepository.AddRange(newDrugtypeFactors.ToArray());
}
break;
case "deptTypes":
logger.LogInformation($"copy deptTypes");
var deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (deptTypes != null)
{
perforCofdepttypeRepository.RemoveRange(deptTypes.ToArray());
}
deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId) ?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
if (deptTypes != null && deptTypes.Any())
{
var newDeptTypes = deptTypes.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
perforCofdepttypeRepository.AddRange(newDeptTypes.ToArray());
}
break;
case "agains":
logger.LogInformation($"copy agains");
var agains = _againRepository.GetEntities(t => t.AllotID == allot.ID);
if (agains != null)
{
_againRepository.RemoveRange(agains.ToArray());
}
agains = _againRepository.GetEntities(t => t.AllotID == allotId) ?? _againRepository.GetEntities(t => t.AllotID == -1);
if (agains != null && agains.Any())
{
var days = DateTime.DaysInMonth(allot.Year, allot.Month);
var newAgains = agains.Select(t => new cof_again { AllotID = allot.ID, Type = t.Type, Department = t.Department, TypeName = t.TypeName, Value = t.TypeName == "满勤天数" ? days : t.Value });
_againRepository.AddRange(newAgains.ToArray());
}
break;
case "accountings":
logger.LogInformation($"copy accountings");
var accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allot.ID);
if (accountings != null)
{
cofaccountingRepository.RemoveRange(accountings.ToArray());
}
accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? cofaccountingRepository.GetEntities(t => t.AllotId == -1);
if (accountings != null && accountings.Any())
{
var newAccountings = accountings.Select(t => new cof_accounting
foreach (var item in request.Type)
{
AllotId = allot.ID,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
Code = t.Code,
IsVerify = t.IsVerify,
VerifyMessage = t.VerifyMessage
});
cofaccountingRepository.AddRange(newAccountings.ToArray());
pairs[item].Invoke(allot, prevAllotId);
}
break;
default:
break;
}
}
//personService.CreateAllotPersons(allot.HospitalId, allot.ID, allotId);
}
#endregion
......@@ -1397,7 +831,7 @@ public void NewCopy(CopyRequest request)
public void Clear(int allotId)
{
_directorRepository.DeleteData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据!", 1, allotId, "ReceiveMessage", true);
_logManageService.WriteMsg("清理无效数据", $"清理无效数据!", 1, allotId, "ReceiveMessage", true);
}
/// <summary>
......@@ -1416,7 +850,7 @@ public void ClearAllotData(int allotId)
public void ClearResData(int allotId)
{
var count = _directorRepository.DeleteResData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true);
_logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true);
}
/// <summary>
......@@ -1426,7 +860,7 @@ public void ClearResData(int allotId)
public void ClearAgain(int againId)
{
var count = _directorRepository.DelAgain(againId);
logManageService.WriteMsg("清理无效数据", $"清除二次绩效中无效数据,受影响行数:{count}", 1, againId, "ReceiveMessage", true);
_logManageService.WriteMsg("清理无效数据", $"清除二次绩效中无效数据,受影响行数:{count}", 1, againId, "ReceiveMessage", true);
}
#endregion
......@@ -1437,10 +871,10 @@ public void ClearAgain(int againId)
/// <returns></returns>
public List<TitleValue> WorkHeader(int allotId)
{
var sheets = perforPersheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetName.Contains("工作量"));
var sheets = _perforPersheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetName.Contains("工作量"));
if (sheets == null)
return new List<TitleValue>();
var header = perforImheaderRepository.GetEntities(t => sheets.Select(s => s.ID).Contains(t.SheetID.Value) && !t.CellValue.Contains("核算单元") && t.CellValue != "科室名称")?.ToList();
var header = _perforImheaderRepository.GetEntities(t => sheets.Select(s => s.ID).Contains(t.SheetID.Value) && !t.CellValue.Contains("核算单元") && t.CellValue != "科室名称")?.ToList();
if (header != null && header.Count > 0)
{
var list = header.Select(t => t.CellValue).Where(t => !string.IsNullOrEmpty(t)).Distinct();
......@@ -1449,38 +883,6 @@ public List<TitleValue> WorkHeader(int allotId)
return null;
}
///// <summary>
///// 人员绩效额外金额
///// </summary>
//private void CopyAprData(int prevAllotId, int allotId)
//{
// if (prevAllotId == 0) return;
// var list = perapramountRepository.GetEntities(t => new List<int> { prevAllotId, allotId }.Contains(t.AllotId));
// if (list == null || !list.Any(t => t.AllotId == prevAllotId)) return;
// if (list.Any(t => t.AllotId == allotId))
// {
// var prevData = list.Where(t => t.AllotId == prevAllotId);
// var existData = list.Where(t => t.AllotId == allotId);
// if (existData != null && existData.Any())
// list = prevData.Where(t => !existData.Select(w => w.PersonnelNumber).Contains(t.PersonnelNumber)).ToList();
// }
// if (list.Any())
// {
// var data = list.Select(t => new per_apr_amount
// {
// Status = 2,
// AllotId = allotId,
// PersonnelNumber = t.PersonnelNumber,
// DoctorName = t.DoctorName,
// PerforType = t.PerforType,
// Amount = t.Amount,
// CreateDate = DateTime.Now
// });
// perapramountRepository.AddRange(data.ToArray());
// }
//}
#region HRP人员科室
......@@ -1492,7 +894,7 @@ public HandsonTable GetHrpDeptHands(int HospitalId, int AllotId)
Visible = 1
}).ToList());
var data = perforCofHrpDeptRepository.GetEntities(t => t.HospitalId == HospitalId && t.AllotId == AllotId);
var data = _perforCofHrpDeptRepository.GetEntities(t => t.HospitalId == HospitalId && t.AllotId == AllotId);
if (data == null)
return result;
......@@ -1529,9 +931,9 @@ public void SaveDepttypeHands(int hospitalId, int allotId, SaveCollectData reque
}
}
perforCofHrpDeptRepository.Execute("delete from cof_hrp_department where HospitalId=@hospitalId and allotid = @allotid"
_perforCofHrpDeptRepository.Execute("delete from cof_hrp_department where HospitalId=@hospitalId and allotid = @allotid"
, new { hospitalId, allotId });
perforCofHrpDeptRepository.AddRange(depts.ToArray());
_perforCofHrpDeptRepository.AddRange(depts.ToArray());
}
public static Dictionary<string, string> HrpDept { get; } = new Dictionary<string, string>
......@@ -1564,7 +966,7 @@ public HandsonTable GetSecondaryAlias()
}
}
}
var data = perforCofaliasRepository.GetEntities()?.OrderBy(t => t.Route);
var data = _perforCofaliasRepository.GetEntities()?.OrderBy(t => t.Route);
if (data == null) return result;
List<HandsonRowData> rowDatas = new List<HandsonRowData>();
......@@ -1605,8 +1007,8 @@ public void SaveSecondaryAlias(SaveCollectData request)
}
}
perforCofaliasRepository.Execute("delete from cof_alias", null);
perforCofaliasRepository.AddRange(aliases.ToArray());
_perforCofaliasRepository.Execute("delete from cof_alias", null);
_perforCofaliasRepository.AddRange(aliases.ToArray());
}
public static Dictionary<string, string> Alias { get; } = new Dictionary<string, string>
......@@ -1655,36 +1057,6 @@ public void SaveSecondaryAlias(SaveCollectData request)
}
///// <summary>
///// CMI值
///// </summary>
///// <param name="prevAllotId"></param>
///// <param name="allotId"></param>
//private void CopyCMIData(int prevAllotId, int allotId)
//{
// if (prevAllotId == 0) return;
// var list = perforCofcmiRepository.GetEntities(t => new List<int> { prevAllotId, allotId }.Contains(t.AllotId));
// if (list == null || !list.Any(t => t.AllotId == prevAllotId)) return;
// if (list.Any(t => t.AllotId == allotId))
// {
// var prevData = list.Where(t => t.AllotId == prevAllotId);
// var existData = list.Where(t => t.AllotId == allotId);
// if (existData != null && existData.Any())
// list = prevData.Where(t => !existData.Select(w => w.UnitType + w.AccountingUnit).Contains(t.UnitType + t.AccountingUnit)).ToList();
// }
// if (list.Any())
// {
// var data = list.Select(t => new cof_cmi
// {
// AllotId = allotId,
// UnitType = t.UnitType,
// AccountingUnit = t.AccountingUnit,
// Value = t.Value,
// });
// perforCofcmiRepository.AddRange(data.ToArray());
// }
//}
#region 费用类型系数
......@@ -1694,12 +1066,12 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request)
#region header
var models = perforExmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
var models = _perforExmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
if (models == null || !models.Any())
{
exConfigService.DefaultModules(request.HospitalId);
_exConfigService.DefaultModules(request.HospitalId);
models = perforExmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
models = _perforExmoduleRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.SheetType == (int)SheetType.Income);
if (models == null || !models.Any()) return sheet;
}
......@@ -1812,12 +1184,12 @@ public HandsonTable GetDrugtypeFactorConfig(int hospitalId, int allotId)
{
HandsonTable table = new HandsonTable((int)SheetType.Unidentifiable, new string[] { }, new List<collect_permission>());
var models = perforExmoduleRepository.GetEntities(t => t.HospitalId == hospitalId && t.SheetType == (int)SheetType.Income);
var models = _perforExmoduleRepository.GetEntities(t => t.HospitalId == hospitalId && t.SheetType == (int)SheetType.Income);
if (models == null || !models.Any())
{
//exConfigService.DefaultModules(hospitalId);
models = perforExmoduleRepository.GetEntities(t => t.HospitalId == hospitalId && t.SheetType == (int)SheetType.Income);
models = _perforExmoduleRepository.GetEntities(t => t.HospitalId == hospitalId && t.SheetType == (int)SheetType.Income);
if (models == null || !models.Any()) return table;
}
......@@ -1944,13 +1316,13 @@ public void SaveDrugtypeFactor(DrugtypeFactorRequest request)
}
}
var savedData = cofdrugtypefactorRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.AllotID == request.AllotId);
var savedData = _cofdrugtypefactorRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.AllotID == request.AllotId);
if (savedData != null && savedData.Any())
{
cofdrugtypefactorRepository.RemoveRange(savedData.ToArray());
_cofdrugtypefactorRepository.RemoveRange(savedData.ToArray());
}
if (factors != null && factors.Any())
cofdrugtypefactorRepository.AddRange(factors.ToArray());
_cofdrugtypefactorRepository.AddRange(factors.ToArray());
if (isHasChargeData)
{
......@@ -1971,9 +1343,9 @@ public void SaveDrugtypeFactor(DrugtypeFactorRequest request)
public HandsonTable QueryHandsCustom(CustomPagingRequest request)
{
var custom = perforReport.QueryCustomColumn(request.TableName);
var custom = _perforReport.QueryCustomColumn(request.TableName);
var isExist = perforReport.QueryIsAllotId(request.TableName, "AllotId", "AccountingUnit", "UnitType");
var isExist = _perforReport.QueryIsAllotId(request.TableName, "AllotId", "AccountingUnit", "UnitType");
if (custom == null || isExist == false)
return null;
......@@ -1988,7 +1360,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
var result = new HandsonTable((int)SheetType.Unidentifiable, new string[] { }, new List<collect_permission>());
var jsonData = JsonHelper.Serialize(perforReport.QueryCustom(request, true).DataList);
var jsonData = JsonHelper.Serialize(_perforReport.QueryCustom(request, true).DataList);
var data = JsonHelper.Deserialize<List<Dictionary<string, string>>>(jsonData);
var headDic = new List<Dictionary<string, object>>();
......@@ -2006,7 +1378,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
var Columns = dicCustom.Select(t => new HandsonColumn(t.Comment, false, DataFormat.普通格式)).ToList();
//表类型
var columnType = perforReport.QueryType(request.TableName);
var columnType = _perforReport.QueryType(request.TableName);
if (Columns != null && Columns.Any())
{
......@@ -2050,9 +1422,9 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
public ApiResponse SaveCustomTable(SaveCustomData request)
{
if (!request.Data.Any())
perforReport.CreatCustom(request.AllotId, request.TableName, null);
_perforReport.CreatCustom(request.AllotId, request.TableName, null);
var custom = perforReport.QueryCustomColumn(request.TableName);
var custom = _perforReport.QueryCustomColumn(request.TableName);
if (custom.Count > 50)
return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据!");
......@@ -2067,7 +1439,7 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
var dicData = CreateCustomRow(request.AllotId, request, dicCustom);
//字段类型
var typeColumn = perforReport.QueryType(request.TableName);
var typeColumn = _perforReport.QueryType(request.TableName);
var datas = new List<dynamic>();
foreach (var item in dicData)
......@@ -2102,7 +1474,7 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
datas.Add(item);
}
if (datas.Any())
perforReport.CreatCustom(request.AllotId, request.TableName, datas);
_perforReport.CreatCustom(request.AllotId, request.TableName, datas);
return new ApiResponse(ResponseType.OK);
......@@ -2110,8 +1482,8 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
public ApiResponse QueryCustom(int userId, CustomPagingRequest request)
{
var heads = perforReport.QueryCustomColumn(request.TableName);
var isExist = perforReport.QueryIsAllotId(request.TableName, "AllotId", "AccountingUnit", "UnitType");
var heads = _perforReport.QueryCustomColumn(request.TableName);
var isExist = _perforReport.QueryIsAllotId(request.TableName, "AllotId", "AccountingUnit", "UnitType");
if (isExist == false || heads == null)
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
if (heads.Count > 50)
......@@ -2142,9 +1514,9 @@ public ApiResponse QueryCustom(int userId, CustomPagingRequest request)
};
if (dic.Keys.Contains(roleType))
result.Datas = perforReport.QueryCustom(request.TableName, request.AllotId, user?.Department ?? "", dic[roleType], request.PageIndex, request.PageSize);
result.Datas = _perforReport.QueryCustom(request.TableName, request.AllotId, user?.Department ?? "", dic[roleType], request.PageIndex, request.PageSize);
else
result.Datas = perforReport.QueryCustom(request, false);
result.Datas = _perforReport.QueryCustom(request, false);
return new ApiResponse(ResponseType.OK, result);
}
......
using Microsoft.Extensions.Logging;
using Performance.EntityModels;
using Performance.Repository;
using Performance.Repository.Repository;
using System;
using System.Linq;
namespace Performance.Services
{
public class CopyService : IAutoInjection
{
private readonly ILogger<ConfigService> _logger;
private readonly PerforPerdeptdicRepository _perdeptdicRepository;
private readonly PerforCofworkitemRepository _workitemRepository;
private readonly PerforCofagainRepository _againRepository;
private readonly PerforCofdrugtypeRepository _drugtypeRepository;
private readonly PerforCofdepttypeRepository _perforCofdepttypeRepository;
private readonly PerforCofaccountingRepository _cofaccountingRepository;
private readonly PerforCofdrugtypeDisburseRepository _drugtypeDisburseRepository;
private readonly PerforCofdrugtypefactorRepository _cofdrugtypefactorRepository;
public CopyService(
ILogger<ConfigService> logger,
PerforPerdeptdicRepository perdeptdicRepository,
PerforCofagainRepository againRepository,
PerforCofdrugtypeRepository drugtypeRepository,
PerforCofworkitemRepository workitemRepository,
PerforCofdepttypeRepository perforCofdepttypeRepository,
PerforCofaccountingRepository cofaccountingRepository,
PerforCofdrugtypeDisburseRepository drugtypeDisburseRepository,
PerforCofdrugtypefactorRepository cofdrugtypefactorRepository)
{
_logger = logger;
_perdeptdicRepository = perdeptdicRepository;
_workitemRepository = workitemRepository;
_againRepository = againRepository;
_drugtypeRepository = drugtypeRepository;
_perforCofdepttypeRepository = perforCofdepttypeRepository;
_cofaccountingRepository = cofaccountingRepository;
_drugtypeDisburseRepository = drugtypeDisburseRepository;
_cofdrugtypefactorRepository = cofdrugtypefactorRepository;
}
public void Copy_WorkItems(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy workItems");
var workItems = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && workItems != null && workItems.Any())
flag = _workitemRepository.RemoveRange(workItems.ToArray());
if (flag || workItems == null || !workItems.Any())
{
workItems = _workitemRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItems != null && workItems.Any())
{
var newWorkItems = workItems.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItems.ToArray());
}
}
}
public void Copy_DrugTypes(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy drugTypes");
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypes != null && drugTypes.Any())
flag = _drugtypeRepository.RemoveRange(drugTypes.ToArray());
if (flag || drugTypes == null || !drugTypes.Any())
{
drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
if (drugTypes != null && drugTypes.Any())
{
var newDrugTypes = drugTypes.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newDrugTypes.ToArray());
}
}
}
public void Copy_DrugTypeDisburses(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy drugTypeDisburses");
var drugTypeDisburses = _drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypeDisburses != null && drugTypeDisburses.Any())
flag = _drugtypeDisburseRepository.RemoveRange(drugTypeDisburses.ToArray());
if (flag || drugTypeDisburses == null || !drugTypeDisburses.Any())
{
drugTypeDisburses = _drugtypeDisburseRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId)
?? _drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeDisburses != null && drugTypeDisburses.Any())
{
var newDrugTypeDisburses = drugTypeDisburses.Select(t => new cof_drugtype_disburse { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeDisburseRepository.AddRange(newDrugTypeDisburses.ToArray());
}
}
}
public void Copy_DrugTypeFactors(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy drugTypeFactors");
var drugTypeFactors = _cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (delHistotyData && drugTypeFactors != null && drugTypeFactors.Any())
flag = _cofdrugtypefactorRepository.RemoveRange(drugTypeFactors.ToArray());
if (flag || drugTypeFactors == null || !drugTypeFactors.Any())
{
drugTypeFactors = _cofdrugtypefactorRepository.GetEntities(t => t.AllotID == prevAllotId && t.HospitalId == allot.HospitalId)
?? _cofdrugtypefactorRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeFactors != null && drugTypeFactors.Any())
{
var newDrugtypeFactors = drugTypeFactors.Select(t => new cof_drugtype_factor
{
HospitalId = allot.HospitalId,
AllotID = allot.ID,
ExModuleId = t.ExModuleId,
Charge = t.Charge,
YSZ = t.YSZ,
HLZ = t.HLZ,
YJZ = t.YJZ
});
_cofdrugtypefactorRepository.AddRange(newDrugtypeFactors.ToArray());
}
}
}
public void Copy_DeptTypes(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy deptTypes");
var deptTypes = _perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && deptTypes != null && deptTypes.Any())
flag = _perforCofdepttypeRepository.RemoveRange(deptTypes.ToArray());
if (flag || deptTypes == null || !deptTypes.Any())
{
deptTypes = _perforCofdepttypeRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
if (deptTypes != null && deptTypes.Any())
{
var newDeptTypes = deptTypes.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_perforCofdepttypeRepository.AddRange(newDeptTypes.ToArray());
}
}
}
public void Copy_Agains(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy agains");
var agains = _againRepository.GetEntities(t => t.AllotID == allot.ID);
if (delHistotyData && agains != null && agains.Any())
flag = _againRepository.RemoveRange(agains.ToArray());
if (flag || agains == null || !agains.Any())
{
agains = _againRepository.GetEntities(t => t.AllotID == prevAllotId) ?? _againRepository.GetEntities(t => t.AllotID == -1);
if (agains != null && agains.Any())
{
var days = DateTime.DaysInMonth(allot.Year, allot.Month);
var newAgains = agains.Select(t => new cof_again
{
AllotID = allot.ID,
Type = t.Type,
Department = t.Department,
TypeName = t.TypeName,
Value = t.TypeName == "满勤天数" ? days : t.Value
});
_againRepository.AddRange(newAgains.ToArray());
}
}
}
public void Copy_Accountings(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy accountings");
var accountings = _cofaccountingRepository.GetEntities(t => t.AllotId == allot.ID);
if (delHistotyData && accountings != null && accountings.Any())
flag = _cofaccountingRepository.RemoveRange(accountings.ToArray());
if (flag || accountings == null || !accountings.Any())
{
accountings = _cofaccountingRepository.GetEntities(t => t.AllotId == prevAllotId) ?? _cofaccountingRepository.GetEntities(t => t.AllotId == -1);
if (accountings != null && accountings.Any())
{
var newAccountings = accountings.Select(t => new cof_accounting
{
AllotId = allot.ID,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
Code = t.Code,
IsVerify = t.IsVerify,
VerifyMessage = t.VerifyMessage
});
_cofaccountingRepository.AddRange(newAccountings.ToArray());
}
}
}
public void Copy_DeptDic(per_allot allot, int prevAllotId, bool delHistotyData = false)
{
var flag = delHistotyData;
_logger.LogInformation($"copy per_dept_dic");
var deptDic = _perdeptdicRepository.GetEntities(t => t.AllotId == allot.ID);
if (delHistotyData && deptDic != null && deptDic.Any())
flag = _perdeptdicRepository.RemoveRange(deptDic.ToArray());
if (flag || deptDic == null || !deptDic.Any())
{
deptDic = _perdeptdicRepository.GetEntities(t => t.AllotId == prevAllotId) ?? _perdeptdicRepository.GetEntities(t => t.AllotId == -1);
if (deptDic != null && deptDic.Any())
{
var newDeptDic = deptDic.Select(t => new per_dept_dic
{
AllotId = allot.ID,
UnitType = t.UnitType,
AccountingUnit = t.AccountingUnit,
CreateTime = t.CreateTime,
CreateUser = t.CreateUser,
Department = t.Department,
HISDeptName = t.HISDeptName,
HospitalId = t.HospitalId,
Source = t.Source,
IsVerify = t.IsVerify,
VerifyMessage = t.VerifyMessage
});
_perdeptdicRepository.AddRange(newDeptDic.ToArray());
}
}
}
}
}
......@@ -90,7 +90,7 @@ public bool ExtractData(int userId, int allotId, out string resultFilePath)
result = false;
return result;
}
var depts = _perforPerdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId);
var depts = _perforPerdeptdicRepository.GetEntities(w => w.AllotId == allot.ID);
IWorkbook workbook = null;
try
......
......@@ -1546,7 +1546,7 @@ public void CheckGatherData(int allotId, SaveGatherData saveGather)
var data = saveGather.Data;
var departments = perdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId);
var departments = perdeptdicRepository.GetEntities(w => w.AllotId == allot.ID);
if (departments == null || !departments.Any()) throw new PerformanceException("未配置科室字典");
var notExistsDeptData = data.Where(w => !departments.Select(t => t.Department).Contains(w[0]));
......
......@@ -741,7 +741,7 @@ public string Judge(int allotId, int hospitalId, int useTemplate, ref bool isSin
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
var drugTypes = cofdrugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
var deptDic = perdeptdicRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
var deptDic = perdeptdicRepository.GetEntities(t => t.AllotId == allot.ID);
var moduleSheet = exmoduleRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.SheetType == (int)SheetType.Income);
if (moduleSheet == null || !moduleSheet.Any()) return null;
......@@ -786,6 +786,7 @@ public string Judge(int allotId, int hospitalId, int useTemplate, ref bool isSin
UnitType = defauleUnittype,
Source = source,
HospitalId = allot.HospitalId,
AllotId = allot.ID,
IsVerify = 0,
VerifyMessage = "抽取前科室校验后补增科室",
CreateUser = 1
......
......@@ -107,7 +107,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
var data = exresultRepository.GetEntities(t => t.AllotId == allotId);
data.AddRange(queryService.Handler(hospitalId, allot, groupName, isSingle, ref dict));
var standData = StandDataFormat(hospitalId, data);
var standData = StandDataFormat(hospitalId, allotId, data);
dictionaryService.Handler(hospitalId, allot, groupName, isSingle);
......@@ -275,10 +275,11 @@ private object GetDataBySheetType(int hospitalId, SheetType sheetType, List<Extr
/// <summary>
/// 标准数据格式, 匹配科室字典
/// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="results"></param>
/// <returns></returns>
private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> results)
private List<ExtractTransDto> StandDataFormat(int hospitalId, int allotId, List<ex_result> results)
{
if (results == null || !results.Any()) return new List<ExtractTransDto>();
......@@ -290,7 +291,7 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> re
var types = extypeRepository.GetEntities(w => w.HospitalId == hospitalId) ?? new List<ex_type>();
var dict = personService.GetDepartments(hospitalId)?.ToList();
var dict = personService.GetDepartments(allotId)?.ToList();
if (dict == null || !dict.Any())
{
return results.GroupBy(t => new { t.Department, t.Category, t.Source }).Select(t => new ExtractTransDto
......
......@@ -52,7 +52,7 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, ExcelStyle style,
if (departments == null || !departments.Any()) return;
var standardDict = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId && departments.Contains(t.Department)) ?? new List<per_dept_dic>();
var standardDict = perdeptdicRepository.GetEntities(t => t.AllotId == allotId && departments.Contains(t.Department)) ?? new List<per_dept_dic>();
WriteSheetDataNonexistent(sheet, cellStyle, point, columns, departments, standardDict, costTransfers, costTransferItems);
}
......
......@@ -398,41 +398,45 @@ public bool DeleteAllPerson(int allotId)
return peremployeeRepository.RemoveRange(employees.ToArray());
}
/// <summary>
/// 检查核算单元是否已存在
/// </summary>
/// <param name="hosapitalId">医院Id</param>
/// <param name="accountingUnit">核算单元</param>
/// <param name="department">科室</param>
private void CheckAccountingDept(int hosapitalId, string accountingUnit, string department)
{
var accountDept = perdeptdicRepository.GetEntity(t => t.HospitalId == hosapitalId && t.AccountingUnit == accountingUnit && t.Department == department);
if (accountDept == null)
{
var entity = new per_dept_dic
{
AccountingUnit = accountingUnit,
Department = department,
HospitalId = hosapitalId,
Source = "人事科增加人员记录时补充"
};
perdeptdicRepository.Add(entity);
}
}
///// <summary>
///// 检查核算单元是否已存在
///// </summary>
///// <param name="hosapitalId">医院Id</param>
///// <param name="accountingUnit">核算单元</param>
///// <param name="department">科室</param>
//private void CheckAccountingDept(int hosapitalId, string accountingUnit, string department)
//{
// var accountDept = perdeptdicRepository.GetEntity(t => t.HospitalId == hosapitalId && t.AccountingUnit == accountingUnit && t.Department == department);
// if (accountDept == null)
// {
// var entity = new per_dept_dic
// {
// AccountingUnit = accountingUnit,
// Department = department,
// HospitalId = hosapitalId,
// Source = "人事科增加人员记录时补充"
// };
// perdeptdicRepository.Add(entity);
// }
//}
/// <summary>
/// 获取给医院所有的
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="allotId"></param>
/// <returns></returns>
public IEnumerable<DeptdicResponse> GetDepartments(int hospitalId)
public IEnumerable<DeptdicResponse> GetDepartments(int allotId)
{
var depts = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var depts = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
if (depts == null || !depts.Any()) return null;
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null || !depts.Any()) return null;
var result = depts.GroupBy(t => new { t.HISDeptName, t.Department }).Select(t => new DeptdicResponse
{
HospitalId = hospitalId,
AllotId = allotId,
HospitalId = allot.HospitalId,
HISDeptName = t.Key.HISDeptName,
Department = t.Key.Department,
OutDoctorAccounting = GetDeptdic(t.FirstOrDefault(group => group.Department == t.Key.Department && group.HISDeptName == t.Key.HISDeptName && group.UnitType == UnitType.医生组.ToString() && group.Source == "门诊")),
......@@ -488,8 +492,13 @@ private Deptdic GetDeptdic(per_dept_dic dic)
/// <returns></returns>
public per_dept_dic CreateDeptDic(per_dept_dic request)
{
var deptdic = perdeptdicRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.AccountingUnit == request.AccountingUnit
&& t.Department == request.Department && t.HISDeptName == request.HISDeptName && t.Source == request.Source && t.UnitType == request.UnitType);
var deptdic = perdeptdicRepository.GetEntity(t =>
t.AllotId == request.AllotId
&& t.AccountingUnit == request.AccountingUnit
&& t.Department == request.Department
&& t.HISDeptName == request.HISDeptName
&& t.Source == request.Source
&& t.UnitType == request.UnitType);
if (deptdic != null)
throw new PerformanceException($"{request.Department}数据重复!");
......@@ -500,22 +509,27 @@ public per_dept_dic CreateDeptDic(per_dept_dic request)
return request;
}
/// <summary>
/// 更新科室核算信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool UpdateDeptDic(per_dept_dic request)
{
var deptdic = perdeptdicRepository.GetEntity(t => t.HospitalId == request.HospitalId && t.AccountingUnit == request.AccountingUnit
&& t.Department == request.Department && t.Source == request.Source && t.UnitType == request.UnitType);
if (deptdic != null && deptdic.Id != request.Id)
throw new PerformanceException($"{request.Department}数据重复!");
_mapper.Map(request, deptdic, typeof(per_dept_dic), typeof(per_dept_dic));
return perdeptdicRepository.Add(deptdic);
}
///// <summary>
///// 更新科室核算信息
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public bool UpdateDeptDic(per_dept_dic request)
//{
// var deptdic = perdeptdicRepository.GetEntity(t =>
// t.HospitalId == request.HospitalId
// && t.AllotId == request.AllotId
// && t.AccountingUnit == request.AccountingUnit
// && t.Department == request.Department
// && t.Source == request.Source
// && t.UnitType == request.UnitType);
// if (deptdic != null && deptdic.Id != request.Id)
// throw new PerformanceException($"{request.Department}数据重复!");
// _mapper.Map(request, deptdic, typeof(per_dept_dic), typeof(per_dept_dic));
// return perdeptdicRepository.Add(deptdic);
//}
/// <summary>
/// 更新科室核算信息
......@@ -551,6 +565,7 @@ public bool UpdateDeptDic(DeptdicResponse request)
{
var entity = new per_dept_dic
{
AllotId = request.AllotId,
HospitalId = request.HospitalId,
HISDeptName = request.HISDeptName,
Department = request.Department,
......@@ -583,7 +598,7 @@ public bool DeleteDeptDic(DeptdicResponse request)
if (request == null)
throw new PerformanceException("科室记录不存在!");
var deptdics = perdeptdicRepository.GetEntities(t => t.HISDeptName == request.HISDeptName && t.Department == request.Department && t.HospitalId == request.HospitalId);
var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == request.AllotId && t.HISDeptName == request.HISDeptName && t.Department == request.Department);
if (deptdics == null || !deptdics.Any())
throw new PerformanceException("科室记录不存在!");
......@@ -593,12 +608,12 @@ public bool DeleteDeptDic(DeptdicResponse request)
/// <summary>
/// 系统/标准科室字典
/// </summary>
/// <param name="hospitalId">医院Id</param>
/// <param name="allotId">allotId</param>
/// <param name="type">1系统科室 2标准科室 3核算单元</param>
/// <returns></returns>
public List<TitleValue> DeptDics(int hospitalId, int type)
public List<TitleValue> DeptDics(int allotId, int type)
{
var deptdics = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
if (deptdics == null || !deptdics.Any()) return new List<TitleValue>();
var result = new List<string>();
......@@ -693,13 +708,13 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
}
public HandsonTable GetBatchPersonStructrue(int hospitalId)
public HandsonTable GetBatchPersonStructrue(int allotId)
{
var cols = Person.Select(t => t.Item2).ToArray();
var permissions = Person.Select(t => new collect_permission { HeadName = t.Item2, Visible = 1 }).ToList();
var result = new HandsonTable((int)SheetType.Unidentifiable, cols, permissions);
var deptdics = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var deptdics = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
var ss = deptdics?.Where(t => !new string[] { UnitType.专家组.ToString() }.Contains(t.UnitType));
if (result.Columns != null && result.Columns.Any())
{
......@@ -725,7 +740,7 @@ public HandsonTable GetBatchPersonStructrue(int hospitalId)
return result;
}
public HandsonTable GetDepartmentHands(int hospitalId)
public HandsonTable GetDepartmentHands(int allotId)
{
HandsonTable handson = new HandsonTable((int)SheetType.Unidentifiable, DeptDic.Select(c => c.Value).ToArray(), DeptDic.Select(t => new collect_permission
{
......@@ -887,10 +902,13 @@ public ApiResponse BathSavePerson(int AllotId, int HospitalId, SaveCollectData r
return new ApiResponse(ResponseType.OK, "");
}
public void SaveDeptDicHands(int HospitalId, SaveCollectData request)
public void SaveDeptDicHands(int allotId, SaveCollectData request)
{
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) throw new PerformanceException("绩效记录不存在");
var dicData = CreateDataRow(request, DeptDic);
var deptDic = perdeptdicRepository.GetEntities(t => t.HospitalId == HospitalId);
var deptDic = perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
var depts = deptDic?.Select(w => new { w.Department, w.HISDeptName }).Distinct();
List<per_dept_dic> deptDics = new List<per_dept_dic>();
var delDepartment = new List<string>();
......@@ -905,7 +923,7 @@ public void SaveDeptDicHands(int HospitalId, SaveCollectData request)
if (!string.IsNullOrEmpty(data.HISDeptName?.Trim()) && !any)
{
DeptDicList(HospitalId, deptDics, data);
DeptDicList(allot.HospitalId, allotId, deptDics, data);
}
}
......@@ -916,97 +934,48 @@ public void SaveDeptDicHands(int HospitalId, SaveCollectData request)
perdeptdicRepository.AddRange(deptDics.ToArray());
}
private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHands data)
private void DeptDicList(int hospitalId, int allotId, List<per_dept_dic> deptDics, DeptdicHands data)
{
var nowTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
#region 住院
if (!string.IsNullOrEmpty(data.InpatDoctorAccounting) || !string.IsNullOrEmpty(data.InpatNurseAccounting) || !string.IsNullOrEmpty(data.InpatTechnicAccounting))
{
if (!string.IsNullOrEmpty(data.InpatDoctorAccounting))
Func<string, string, string, per_dept_dic> getDeptDic = (source, unittype, accountingUnit) =>
{
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatDoctorAccounting?.Trim();
deptDic.UnitType = "医生组";
deptDics.Add(deptDic);
}
if (!string.IsNullOrEmpty(data.InpatNurseAccounting))
return new per_dept_dic()
{
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatNurseAccounting?.Trim();
deptDic.UnitType = "护理组";
deptDics.Add(deptDic);
}
if (!string.IsNullOrEmpty(data.InpatTechnicAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatTechnicAccounting?.Trim();
deptDic.UnitType = "医技组";
deptDics.Add(deptDic);
}
}
Source = source,
HospitalId = hospitalId,
AllotId = allotId,
Department = data.Department?.Trim(),
HISDeptName = data.HISDeptName?.Trim(),
CreateTime = nowTime,
AccountingUnit = accountingUnit,
UnitType = unittype,
};
};
#endregion
if (!string.IsNullOrEmpty(data.InpatDoctorAccounting))
deptDics.Add(getDeptDic("住院", "医生组", data.InpatDoctorAccounting?.Trim()));
#region 门诊
if (!string.IsNullOrEmpty(data.InpatNurseAccounting))
deptDics.Add(getDeptDic("住院", "护理组", data.InpatNurseAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.OutDoctorAccounting) || !string.IsNullOrEmpty(data.OutNurseAccounting) || !string.IsNullOrEmpty(data.OutTechnicAccounting))
{
if (!string.IsNullOrEmpty(data.InpatTechnicAccounting))
deptDics.Add(getDeptDic("住院", "医技组", data.InpatTechnicAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.OutDoctorAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutDoctorAccounting?.Trim();
deptDic.UnitType = "医生组";
deptDics.Add(deptDic);
}
if (!string.IsNullOrEmpty(data.OutNurseAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutNurseAccounting?.Trim();
deptDic.UnitType = "护理组";
deptDics.Add(deptDic);
}
if (!string.IsNullOrEmpty(data.OutTechnicAccounting))
{
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutTechnicAccounting?.Trim();
deptDic.UnitType = "医技组";
deptDics.Add(deptDic);
}
}
deptDics.Add(getDeptDic("门诊", "医生组", data.OutDoctorAccounting?.Trim()));
#endregion
if (!string.IsNullOrEmpty(data.OutNurseAccounting))
deptDics.Add(getDeptDic("门诊", "护理组", data.OutNurseAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.OutTechnicAccounting))
deptDics.Add(getDeptDic("门诊", "医技组", data.OutTechnicAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.LogisticsAccounting))
{
per_dept_dic deptDic = new per_dept_dic()
{
HospitalId = HospitalId,
Department = data.Department?.Trim(),
HISDeptName = data.HISDeptName?.Trim(),
CreateTime = nowTime,
AccountingUnit = data.LogisticsAccounting?.Trim(),
UnitType = "行政后勤"
};
deptDics.Add(deptDic);
}
deptDics.Add(getDeptDic("", "行政后勤", data.LogisticsAccounting?.Trim()));
if (!string.IsNullOrEmpty(data.SpecialAccounting))
{
per_dept_dic deptDic = new per_dept_dic()
{
HospitalId = HospitalId,
Department = data.Department?.Trim(),
HISDeptName = data.HISDeptName?.Trim(),
CreateTime = nowTime,
AccountingUnit = data.LogisticsAccounting?.Trim(),
UnitType = "特殊核算组"
};
deptDics.Add(deptDic);
}
deptDics.Add(getDeptDic("", "特殊核算组", data.LogisticsAccounting?.Trim()));
}
private List<Dictionary<string, string>> CreateDataRow(SaveCollectData request, Dictionary<string, string> config)
......
......@@ -452,53 +452,12 @@ public List<sys_role> RoleList(int userId)
/// 科室列表
/// </summary>
/// <returns></returns>
public List<TitleValue> Department(int hospitalId)
public List<TitleValue> Department(int allotId)
{
//var allotList = _perforPerallotRepository.GetEntities(t => t.HospitalId == hospitalId);
//var result = new List<string>();
//if (allotList != null)
//{
// var idList = allotList.Select(s => s.ID).ToList();
// //var department = _employeeRepository.GetEntities(t => t.Department != "" && idList.Contains(t.AllotID.Value)).Select(t => t.Department);
// //if (department != null && department.Count() > 0)
// // result.AddRange(department);
// var department = _imaccountbasicRepository.GetEntities(t => !string.IsNullOrEmpty(t.DoctorAccountingUnit) && idList.Contains(t.AllotID.Value))?.Select(t => t.DoctorAccountingUnit);
// if (department != null && department.Count() > 0)
// result.AddRange(department);
// // 特殊科室
// department = _imspecialunitRepository.GetEntities(t => !string.IsNullOrEmpty(t.AccountingUnit) && idList.Contains(t.AllotID.Value))?.Select(t => t.AccountingUnit);
// if (department != null && department.Count() > 0)
// result.AddRange(department);
// if (result != null && result.Any())
// {
// result = result.Distinct().OrderBy(t => t).ToList();
// }
//}
var list = _perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var list = _perdeptdicRepository.GetEntities(t => t.AllotId == allotId);
if (list == null || !list.Any()) return new List<TitleValue>();
var result = list.Select(t => t.AccountingUnit).Distinct().OrderBy(t => t).ToList();
//// 补充行政科室
//var states = new int[] { (int)AllotStates.Archive, (int)AllotStates.GenerateAccomplish };
//var allots = _perallotRepository.GetEntities(w => w.HospitalId == hospitalId && states.Contains(w.States));
//if (allots != null && allots.Any())
//{
// var allot = allots.OrderByDescending(w => w.Year).ThenByDescending(w => w.Month).FirstOrDefault();
// if (allot != null)
// {
// var types = new int[] { (int)UnitType.行政中层, (int)UnitType.行政后勤 };
// var accounts = _resaccountRepository.GetEntities(w => w.AllotID == allot.ID && w.UnitType.HasValue && types.Contains(w.UnitType.Value));
// if (accounts != null && accounts.Any())
// {
// result.AddRange(accounts.Select(w => w.AccountingUnit));
// }
// }
//}
return result?.Select(t => new TitleValue { Title = t, Value = t }).ToList();
}
......
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