Commit da43572f by lcx

Merge branch 'feature/hrp' into release/v20210709功能分支合并

parents 97a18f72 d396c003
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services;
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Api.Controllers
{
[Route("api/[controller]")]
public class ConfigController : Controller
{
private ConfigService _configService;
private AllotService _allotService;
public ConfigController(ConfigService configService, AllotService allotService)
private readonly ConfigService _configService;
private readonly AllotService _allotService;
private readonly DictionaryService _dictionaryService;
public ConfigController(ConfigService configService, AllotService allotService, DictionaryService dictionaryService)
{
_configService = configService;
_allotService = allotService;
_dictionaryService = dictionaryService;
}
#region 弃用
......@@ -673,6 +671,7 @@ public ApiResponse BatchAccountingStructrue([FromRoute] int allotId)
/// 核算单元及组别批量添加
/// </summary>
/// <param name="allotId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("BatchSaveAccounting/{allotId}")]
[HttpPost]
......@@ -725,7 +724,9 @@ public ApiResponse GetHrpDeptHands([FromRoute] int hospitalId, int allotId)
/// <summary>
/// 保存HRP人员科室
/// </summary>
/// <param name=""></param>
/// <param name="hospitalId"></param>
/// <param name="allotId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("savehrpdept/{hospitalId}/allot/{allotId}")]
[HttpPost]
......@@ -738,6 +739,21 @@ public ApiResponse SaveHrpDept(int hospitalId, int allotId, [FromBody] SaveColle
_configService.SaveDepttypeHands(hospitalId, allotId, request);
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 校正HRP人员的科室信息
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("standardhrpdept/{allotId}")]
[HttpPost]
public ApiResponse StandardHrpDept(int allotId)
{
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
_dictionaryService.CorrectionHRPDepartment(allotId);
return new ApiResponse(ResponseType.OK);
}
#endregion
#region 二次分配别名配置
......
......@@ -127,23 +127,28 @@ public class per_employee
public string Remark { get; set; }
/// <summary>
///
/// 0 未通过验证 1 通过验证
/// </summary>
public Nullable<DateTime> CreateTime { get; set; }
public int? IsVerify { get; set; }
/// <summary>
///
/// 验证失败描述
/// </summary>
public Nullable<int> CreateUser { get; set; }
public string VerifyMessage { get; set; }
/// <summary>
/// 0 未通过验证 1 通过验证
/// 是否是hrp人员 0 不是 1 是
/// </summary>
public int? IsVerify { get; set; }
public Nullable<int> IsHrpEmployee { get; set; }
/// <summary>
/// 验证失败描述
///
/// </summary>
public string VerifyMessage { get; set; }
public Nullable<DateTime> CreateTime { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> CreateUser { get; set; }
}
}
......@@ -16,6 +16,7 @@ public class DictionaryService : IAutoInjection
private readonly ILogger<DictionaryService> logger;
private readonly QueryService queryService;
private readonly LogManageService logService;
private readonly PerforCofhrpdepartmentRepository cofhrpdepartmentRepository;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforHospitalconfigRepository hospitalconfigRepository;
private readonly PerforExtypeRepository extypeRepository;
......@@ -27,6 +28,7 @@ public class DictionaryService : IAutoInjection
ILogger<DictionaryService> logger,
QueryService queryService,
LogManageService logService,
PerforCofhrpdepartmentRepository cofhrpdepartmentRepository,
PerforPeremployeeRepository peremployeeRepository,
PerforHospitalconfigRepository hospitalconfigRepository,
PerforExtypeRepository extypeRepository,
......@@ -38,6 +40,7 @@ PerforHisscriptRepository hisscriptRepository
this.logger = logger;
this.queryService = queryService;
this.logService = logService;
this.cofhrpdepartmentRepository = cofhrpdepartmentRepository;
this.peremployeeRepository = peremployeeRepository;
this.hospitalconfigRepository = hospitalconfigRepository;
this.extypeRepository = extypeRepository;
......@@ -94,17 +97,29 @@ private void Employee(per_allot allot, sys_hospitalconfig config, string sql)
var data = queryService.QueryData<per_employee>(config, allot, sql);
if (data == null || !data.Any()) return;
var employees = peremployeeRepository.GetEntities(t => t.AllotId == allot.ID);
if (employees != null && employees.Any())
{
peremployeeRepository.RemoveRange(employees.ToArray());
}
//var employees = peremployeeRepository.GetEntities(t => t.AllotId == allot.ID);
//if (employees != null && employees.Any())
//{
// peremployeeRepository.RemoveRange(employees.ToArray());
//}
data.ToList().ForEach(t =>
{
t.AllotId = allot.ID;
t.HospitalId = allot.HospitalId;
t.IsHrpEmployee = 1;
});
var hrpDepartments = cofhrpdepartmentRepository.GetEntities(t => t.AllotId == allot.ID);
if (hrpDepartments != null && hrpDepartments.Any())
{
data = data.GroupJoin(hrpDepartments, outer => new { department = outer.Department }, inner => new { department = inner.HRPDepartment }, (outer, inner) => new { outer, inner }).Select(t =>
{
t.outer.AccountingUnit = t.inner?.FirstOrDefault()?.AccountingUnit;
return t.outer;
});
}
peremployeeRepository.AddRange(data.ToArray());
}
catch (Exception ex)
......@@ -162,5 +177,34 @@ private string GetSaveValue(params string[] arr)
return value;
return arr.FirstOrDefault(w => !string.IsNullOrEmpty(w));
}
/// <summary>
/// 校正HRP人员的科室信息
/// </summary>
/// <param name="allotId"></param>
public void CorrectionHRPDepartment(int allotId)
{
try
{
var employees = peremployeeRepository.GetEntities(t => t.AllotId == allotId && (t.IsHrpEmployee ?? 0) == 1);
if (employees == null || !employees.Any()) return;
var hrpDepartments = cofhrpdepartmentRepository.GetEntities(t => t.AllotId == allotId);
if (hrpDepartments != null && hrpDepartments.Any())
{
employees = employees.GroupJoin(hrpDepartments, outer => new { department = outer.Department }, inner => new { department = inner.HRPDepartment }, (outer, inner) => new { outer, inner }).Select(t =>
{
t.outer.AccountingUnit = t.inner?.FirstOrDefault()?.AccountingUnit;
return t.outer;
}).ToList();
peremployeeRepository.UpdateRange(employees.ToArray());
}
}
catch (Exception ex)
{
logger.LogError($"修改HRP人员科室时发生异常:{ex}");
}
}
}
}
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