Commit da43572f by lcx

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

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