Commit 8e140206 by ruyun.zhang@suvalue.com

Merge branch 'release/v22.2.10-Beta-ninghai' into develop

parents 477996d8 8a346089
using FluentValidation.AspNetCore; //using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Hosting; //using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; //using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; //using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; //using Microsoft.Extensions.Options;
using Performance.DtoModels; //using Performance.DtoModels;
using Performance.DtoModels.AppSettings; //using Performance.DtoModels.AppSettings;
using Performance.Infrastructure; //using Performance.Infrastructure;
using Performance.Services; //using Performance.Services;
using Performance.Services.ExtractExcelService; //using Performance.Services.ExtractExcelService;
using System; //using System;
using System.IO; //using System.IO;
using System.Linq; //using System.Linq;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 //// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Performance.Api.Controllers //namespace Performance.Api.Controllers
{ //{
/// <summary> // /// <summary>
/// 科室二次分配 // /// 科室二次分配
/// </summary> // /// </summary>
[Route("api/[controller]")] // [Route("api/[controller]")]
public class AgainAllotController : Controller // public class AgainAllotController : Controller
{ // {
private AgainAllotService againAllotService; // private AgainAllotService againAllotService;
private RoleService roleService; // private RoleService roleService;
private ComputeService computeService; // private ComputeService computeService;
private ClaimService claimService; // private ClaimService claimService;
private AllotService allotService; // private AllotService allotService;
private IWebHostEnvironment env; // private IWebHostEnvironment env;
private ConfigService configService; // private ConfigService configService;
private Application application; // private Application application;
public AgainAllotController(AgainAllotService againAllotService, // public AgainAllotController(AgainAllotService againAllotService,
RoleService roleService, // RoleService roleService,
ClaimService claimService, // ClaimService claimService,
AllotService allotService, // AllotService allotService,
IWebHostEnvironment env, // IWebHostEnvironment env,
ConfigService configService, // ConfigService configService,
ComputeService computeService, // ComputeService computeService,
IOptions<Application> options) // IOptions<Application> options)
{ // {
this.againAllotService = againAllotService; // this.againAllotService = againAllotService;
this.roleService = roleService; // this.roleService = roleService;
this.claimService = claimService; // this.claimService = claimService;
this.allotService = allotService; // this.allotService = allotService;
this.env = env; // this.env = env;
this.configService = configService; // this.configService = configService;
this.computeService = computeService; // this.computeService = computeService;
this.application = options.Value; // this.application = options.Value;
} // }
/// <summary> // /// <summary>
/// 返回当前用户医院下绩效列表 // /// 返回当前用户医院下绩效列表
/// </summary> // /// </summary>
/// <returns></returns> // /// <returns></returns>
[Route("allotlist")] // [Route("allotlist")]
[HttpPost] // [HttpPost]
public ApiResponse AllotList() // public ApiResponse AllotList()
{ // {
var userId = claimService.GetUserId(); // var userId = claimService.GetUserId();
var list = againAllotService.GetAllotList(userId); // var list = againAllotService.GetAllotList(userId);
return new ApiResponse(ResponseType.OK, list); // return new ApiResponse(ResponseType.OK, list);
} // }
/// <summary> // /// <summary>
/// 上传文件 // /// 上传文件
/// </summary> // /// </summary>
/// <param name="form"></param> // /// <param name="form"></param>
/// <returns></returns> // /// <returns></returns>
[Route("import")] // [Route("import")]
[HttpPost] // [HttpPost]
public ApiResponse Import([FromForm] IFormCollection form) // public ApiResponse Import([FromForm] IFormCollection form)
{ // {
var againid = form.ToDictionary().GetValue("againid", 0); // var againid = form.ToDictionary().GetValue("againid", 0);
if (againid <= 0) // if (againid <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "againid无效"); // return new ApiResponse(ResponseType.Fail, "参数错误", "againid无效");
var file = ((FormFileCollection)form.Files).FirstOrDefault(); // var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null) // if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); // return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName)) // if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件"); // return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
var again = againAllotService.GetAgainallot(againid); // var again = againAllotService.GetAgainallot(againid);
if (again == null) // if (again == null)
return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在"); // return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在");
var allot = allotService.GetAllot(again.AllotID.Value); // var allot = allotService.GetAllot(again.AllotID.Value);
if (allot == null) // if (allot == null)
return new ApiResponse(ResponseType.Fail, "一次绩效记录不存在"); // return new ApiResponse(ResponseType.Fail, "一次绩效记录不存在");
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff"); // var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName); // var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(env.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}"); // var dpath = Path.Combine(env.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath); // FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}"); // var path = Path.Combine(dpath, $"{name}{ext}");
using (var stream = file.OpenReadStream()) // using (var stream = file.OpenReadStream())
{ // {
byte[] bytes = new byte[stream.Length]; // byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length); // stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes)) // if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败"); // return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
allot.Path = path; // allot.Path = path;
allot.Remark = EnumHelper.GetDescription(AllotStates.数据已上传); // allot.Remark = EnumHelper.GetDescription(AllotStates.FileUploaded);
if (!againAllotService.Update(allot, againid)) // if (!againAllotService.Update(allot, againid))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败"); // return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
configService.ClearAgain(againid); // configService.ClearAgain(againid);
} // }
return new ApiResponse(ResponseType.OK); // return new ApiResponse(ResponseType.OK);
} // }
///// <summary> // ///// <summary>
///// 查看科室绩效 // ///// 查看科室绩效
///// </summary> // ///// </summary>
///// <param name="request"></param> // ///// <param name="request"></param>
///// <returns></returns> // ///// <returns></returns>
//[Route("departmentdetail")] // //[Route("departmentdetail")]
//[HttpPost] // //[HttpPost]
//public ApiResponse DepartmentDetail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request) // //public ApiResponse DepartmentDetail([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
//{ // //{
// var userId = claimService.GetUserId(); // // var userId = claimService.GetUserId();
// var roles = roleService.GetUserRole(userId); // // var roles = roleService.GetUserRole(userId);
// var department = claimService.GetUserClaim(JwtClaimTypes.Department); // // var department = claimService.GetUserClaim(JwtClaimTypes.Department);
// var again = againAllotService.GetAgainallot(request.AgainAllotID); // // var again = againAllotService.GetAgainallot(request.AgainAllotID);
// if (again == null) // // if (again == null)
// return new ApiResponse(ResponseType.Fail, "当前二次绩效ID无效"); // // return new ApiResponse(ResponseType.Fail, "当前二次绩效ID无效");
// if (roles.First().Type == application.DirectorRole) // // if (roles.First().Type == application.DirectorRole)
// { // // {
// var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 1); // // var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 1);
// return new ApiResponse(ResponseType.OK, detail); // // return new ApiResponse(ResponseType.OK, detail);
// } // // }
// else if (roles.First().Type == application.NurseRole) // // else if (roles.First().Type == application.NurseRole)
// { // // {
// var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 2); // // var detail = computeService.GetDepartmentDetail(again.AllotID.Value, department, 2);
// return new ApiResponse(ResponseType.OK, detail); // // return new ApiResponse(ResponseType.OK, detail);
// } // // }
// return new ApiResponse(ResponseType.Fail, "当前用户角色无法识别"); // // return new ApiResponse(ResponseType.Fail, "当前用户角色无法识别");
//} // //}
///// <summary> // ///// <summary>
///// 生成绩效 // ///// 生成绩效
///// </summary> // ///// </summary>
///// <param name="request"></param> // ///// <param name="request"></param>
///// <returns></returns> // ///// <returns></returns>
//[Route("generate")] // //[Route("generate")]
//[HttpPost] // //[HttpPost]
//public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request) // //public ApiResponse Generate([CustomizeValidator(RuleSet = "Generate"), FromBody]AgainAllotRequest request)
//{ // //{
// var userId = claimService.GetUserId(); // // var userId = claimService.GetUserId();
// var department = claimService.GetUserClaim(JwtClaimTypes.Department); // // var department = claimService.GetUserClaim(JwtClaimTypes.Department);
// var result = againAllotService.Generate(request, userId, department); // // var result = againAllotService.Generate(request, userId, department);
// return new ApiResponse(ResponseType.OK); // // return new ApiResponse(ResponseType.OK);
//} // //}
/// <summary> // /// <summary>
/// 查看绩效详情 // /// 查看绩效详情
/// </summary> // /// </summary>
/// <param name="request"></param> // /// <param name="request"></param>
/// <returns></returns> // /// <returns></returns>
[Route("detail")] // [Route("detail")]
[HttpPost] // [HttpPost]
public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody] AgainAllotRequest request) // public ApiResponse Detail([CustomizeValidator(RuleSet = "Generate"), FromBody] AgainAllotRequest request)
{ // {
var result = againAllotService.Detail(request); // var result = againAllotService.Detail(request);
return new ApiResponse(ResponseType.OK, new { result.AgainSituation, result.SheetExport }); // return new ApiResponse(ResponseType.OK, new { result.AgainSituation, result.SheetExport });
} // }
} // }
} //}
...@@ -767,6 +767,9 @@ public ApiResponse RedistributionSave([FromBody] SecondComputeDto request) ...@@ -767,6 +767,9 @@ public ApiResponse RedistributionSave([FromBody] SecondComputeDto request)
var second = secondAllotService.GetSecondAllot(request.SecondId); var second = secondAllotService.GetSecondAllot(request.SecondId);
if (second == null) throw new PerformanceException("参数SecondId无效!"); if (second == null) throw new PerformanceException("参数SecondId无效!");
if (second.Status == (int)SecondAllot.Status.等待审核 || second.Status == (int)SecondAllot.Status.审核通过)
throw new PerformanceException("保存失败,当前二次分配已提交!");
var allot = _allotService.GetAllot(second.AllotId.Value); var allot = _allotService.GetAllot(second.AllotId.Value);
if (allot == null) if (allot == null)
throw new PerformanceException("绩效记录不存在!"); throw new PerformanceException("绩效记录不存在!");
......
...@@ -149,31 +149,6 @@ ...@@ -149,31 +149,6 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:Performance.Api.Controllers.AgainAllotController">
<summary>
科室二次分配
</summary>
</member>
<member name="M:Performance.Api.Controllers.AgainAllotController.AllotList">
<summary>
返回当前用户医院下绩效列表
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AgainAllotController.Import(Microsoft.AspNetCore.Http.IFormCollection)">
<summary>
上传文件
</summary>
<param name="form"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AgainAllotController.Detail(Performance.DtoModels.AgainAllotRequest)">
<summary>
查看绩效详情
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AllotController.List(Performance.DtoModels.AllotRequest)"> <member name="M:Performance.Api.Controllers.AllotController.List(Performance.DtoModels.AllotRequest)">
<summary> <summary>
绩效列表 绩效列表
......
...@@ -156,6 +156,7 @@ public enum Status ...@@ -156,6 +156,7 @@ public enum Status
超时 = 99, 超时 = 99,
} }
} }
public class Attendance public class Attendance
{ {
public enum Type public enum Type
...@@ -169,6 +170,16 @@ public enum Deduction ...@@ -169,6 +170,16 @@ public enum Deduction
核减 = 1, 核减 = 1,
不核减 = 2, 不核减 = 2,
} }
}
public class SecondAllot
{
public enum Status
{
未提交 = 1,
等待审核 = 2,
审核通过 = 3,
驳回 = 4,
}
} }
} }
using Performance.EntityModels; using Performance.EntityModels;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -42,5 +43,11 @@ public List<view_second_compute_collect> GetComputeBySecond(int secondId) ...@@ -42,5 +43,11 @@ public List<view_second_compute_collect> GetComputeBySecond(int secondId)
return new List<view_second_compute_collect>(); return new List<view_second_compute_collect>();
} }
public int Submit(int secondId, int tempId, decimal realGiveFee, int submitType, string remark = "")
{
string sql = "UPDATE ag_secondallot SET UseTempId = @tempId,NursingDeptStatus = @status, Status = @status, SubmitType = @submitType,SubmitTime = @date, Remark = @remark WHERE Id = @secondId AND RealGiveFee = @fee";
return Execute(sql, new { secondId, tempId, status = 2, date = DateTime.Now, fee = realGiveFee, submitType, remark });
}
} }
} }
...@@ -306,7 +306,9 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot ...@@ -306,7 +306,9 @@ public List<PerSheet> Compute(PerExcel excel, List<PerSheet> perSheet, per_allot
if (UnitType.医技组 == unitType && workDoctor == null) if (UnitType.医技组 == unitType && workDoctor == null)
workDoctor = info.Data.FirstOrDefault(t => t.UnitType == UnitType.医生组.ToString() && t.AccountingUnit == dept.AccountingUnit); workDoctor = info.Data.FirstOrDefault(t => t.UnitType == UnitType.医生组.ToString() && t.AccountingUnit == dept.AccountingUnit);
// 夜班绩效 从医院奖罚的明细项中获取 // 夜班绩效 从医院奖罚的明细项中获取
var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0; // 2022-03-16 wufeifei
string[] nightShiftTexts = new string[] { "夜班绩效", "夜班工作量", "夜班工作量奖励" };
var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && nightShiftTexts.Contains(w.TypeName?.Trim()))?.CellValue ?? 0;
dept.NightShiftWorkPerforFee = nightShift; dept.NightShiftWorkPerforFee = nightShift;
//dept.MedicineFactor = workDoctor?.MedicineFactor; //dept.MedicineFactor = workDoctor?.MedicineFactor;
...@@ -388,7 +390,9 @@ public void ComputeOffice(per_allot allot, PerExcel excel) ...@@ -388,7 +390,9 @@ public void ComputeOffice(per_allot allot, PerExcel excel)
if (UnitTypeUtil.IsOffice(resAccount?.UnitType) && dept.NeedSecondAllot == "是") if (UnitTypeUtil.IsOffice(resAccount?.UnitType) && dept.NeedSecondAllot == "是")
{ {
// 夜班绩效 从医院奖罚的明细项中获取 // 夜班绩效 从医院奖罚的明细项中获取
var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == resAccount?.UnitType && w.AccountingUnit == dept.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0; // 2022-03-16 wufeifei
string[] nightShiftTexts = new string[] { "夜班绩效", "夜班工作量", "夜班工作量奖励" };
var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && nightShiftTexts.Contains(w.TypeName?.Trim()))?.CellValue ?? 0;
dept.NightShiftWorkPerforFee = nightShift; dept.NightShiftWorkPerforFee = nightShift;
dept.ScoringAverage = resAccount?.ScoringAverage == null ? 0 : resAccount.ScoringAverage; dept.ScoringAverage = resAccount?.ScoringAverage == null ? 0 : resAccount.ScoringAverage;
......
...@@ -167,7 +167,9 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -167,7 +167,9 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
//var scoreAverage = accountScoreAverages?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept?.AccountingUnit)?.TotelValue; //var scoreAverage = accountScoreAverages?.FirstOrDefault(w => w.UnitType == UnitType.特殊核算组.ToString() && w.AccountingUnit == dept?.AccountingUnit)?.TotelValue;
// 夜班绩效 从医院奖罚的明细项中获取 // 夜班绩效 从医院奖罚的明细项中获取
var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == dept?.UnitType && w.AccountingUnit == dept?.AccountingUnit && w.TypeName?.Trim() == "夜班绩效")?.CellValue ?? 0; // 2022-03-16 wufeifei
string[] nightShiftTexts = new string[] { "夜班绩效", "夜班工作量", "夜班工作量奖励" };
var nightShift = adjustLaterOtherFee?.FirstOrDefault(w => w.UnitType == dept.UnitType && w.AccountingUnit == dept.AccountingUnit && nightShiftTexts.Contains(w.TypeName?.Trim()))?.CellValue ?? 0;
decimal? headcount = null; decimal? headcount = null;
if (typeList.Any(o => o.Description == item.QuantitativeIndicators)) if (typeList.Any(o => o.Description == item.QuantitativeIndicators))
......
...@@ -1549,7 +1549,7 @@ public void CheckGatherData(int allotId, SaveGatherData saveGather) ...@@ -1549,7 +1549,7 @@ public void CheckGatherData(int allotId, SaveGatherData saveGather)
var departments = perdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId); var departments = perdeptdicRepository.GetEntities(w => w.HospitalId == allot.HospitalId);
if (departments == null || !departments.Any()) throw new PerformanceException("未配置科室字典"); if (departments == null || !departments.Any()) throw new PerformanceException("未配置科室字典");
var notExistsDeptData = data.Where(w => !departments.Select(t => t.Department).Contains(w[0])); var notExistsDeptData = data.Where(w => !departments.Select(t => t.HISDeptName).Contains(w[0]));
if (notExistsDeptData != null && notExistsDeptData.Any()) if (notExistsDeptData != null && notExistsDeptData.Any())
throw new PerformanceException($"科室字典中不存在科室[{string.Join(",", notExistsDeptData.Select(t => t[0]).Distinct())}]"); throw new PerformanceException($"科室字典中不存在科室[{string.Join(",", notExistsDeptData.Select(t => t[0]).Distinct())}]");
......
...@@ -91,13 +91,16 @@ public void Handler(int hospitalId, per_allot allot, string groupName, bool isSi ...@@ -91,13 +91,16 @@ public void Handler(int hospitalId, per_allot allot, string groupName, bool isSi
} }
} }
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"开始提取HIS数据", isSingle: isSingle);
var hisScrips = hisscriptRepository.GetEntities(t => t.HospitalId == hospitalId); var hisScrips = hisscriptRepository.GetEntities(t => t.HospitalId == hospitalId);
if (hisScrips == null || !hisScrips.Any()) return; if (hisScrips == null || !hisScrips.Any()) return;
foreach (var item in hisScrips) foreach (var item in hisScrips)
{ {
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"提取{item.SourceType} - {item.Category}数据", isSingle: isSingle); HisData(allot, configs.FirstOrDefault(t => t.Id == item.ConfigId), item, groupName, isSingle);
HisData(allot, configs.FirstOrDefault(t => t.Id == item.ConfigId), item, isSingle);
} }
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"提取HIS数据完成", isSingle: isSingle);
} }
catch (Exception) catch (Exception)
{ {
...@@ -227,10 +230,12 @@ private void JudgeDataEqual(List<string> columns, List<per_employee> emps, List< ...@@ -227,10 +230,12 @@ private void JudgeDataEqual(List<string> columns, List<per_employee> emps, List<
} }
} }
private void HisData(per_allot allot, sys_hospitalconfig config, his_script script, bool isSingle) private void HisData(per_allot allot, sys_hospitalconfig config, his_script script, string groupName, bool isSingle)
{ {
try try
{ {
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"提取“{script.SourceType} - {script.Category}”数据", isSingle: isSingle);
if (config == null || string.IsNullOrEmpty(script.ExecScript)) return; if (config == null || string.IsNullOrEmpty(script.ExecScript)) return;
var data = queryService.QueryData<HisData>(config, script.ExecScript, allot, isSingle); var data = queryService.QueryData<HisData>(config, script.ExecScript, allot, isSingle);
...@@ -259,10 +264,12 @@ private void HisData(per_allot allot, sys_hospitalconfig config, his_script scri ...@@ -259,10 +264,12 @@ private void HisData(per_allot allot, sys_hospitalconfig config, his_script scri
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
}); });
hisdataRepository.AddRange(insertData.ToArray()); hisdataRepository.AddRange(insertData.ToArray());
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"提取“{script.SourceType} - {script.Category}”完成", isSingle: isSingle);
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError("获取his_data时发生异常:" + ex.ToString()); logger.LogError("获取his_data时发生异常:" + ex.ToString());
logService.ReturnTheLog(allot.ID, allot.ID.ToString(), 2, "SQL错误", $"获取HIS数据“{script.SourceType} - {script.Category}”时发生异常", 3, isSingle);
} }
} }
......
...@@ -225,6 +225,12 @@ public static string NoBlank(this string @string) ...@@ -225,6 +225,12 @@ public static string NoBlank(this string @string)
return @string.Replace("\n", "").Replace("\r", "").Replace(" ", "").Trim(); return @string.Replace("\n", "").Replace("\r", "").Replace(" ", "").Trim();
} }
public static string GetNo(this string @string)
{
var match = Regex.Match(@string, "^(1.[1-9].[1-9])|(^[1-9]+.[1-9]+)");
return match.Value;
}
public static IWorkbook GetWorkbook(string filePath) public static IWorkbook GetWorkbook(string filePath)
{ {
IWorkbook workbook = null; IWorkbook workbook = null;
......
...@@ -54,38 +54,38 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo ...@@ -54,38 +54,38 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo
try try
{ {
var sheetNames = workbook.GetAllNames().Select(w => w.SheetName);
foreach (var module in modulesList.Where(t => t.SheetType == (int)SheetType.Income)?.OrderBy(t => t.ModuleName)) foreach (var module in modulesList.Where(t => t.SheetType == (int)SheetType.Income)?.OrderBy(t => t.ModuleName))
{ {
var sheet = workbook.GetSheet(module.ModuleName) ?? workbook.GetSheet(module.ModuleName.NoBlank()); var no = module.ModuleName.GetNo();
var name = sheetNames.FirstOrDefault(name => name.StartsWith(no)) ?? module.ModuleName;
var sheet = workbook.GetSheet(name) ?? workbook.GetSheet(module.ModuleName);
if (sheet == null) if (sheet == null)
{ {
string[] keyArray = new string[] { "开单", "就诊", "执行" }; string[] keyArray = new string[] { "开单", "就诊", "执行" };
if (keyArray.Any(key => module.ModuleName.Contains(key))) if (keyArray.Any(key => name.Contains(key)))
{ {
var item = pairs.Where(t => t.Key.ToString().NoBlank().StartsWith("1.")).OrderByDescending(t => t.Key).First(); var item = pairs.Where(t => t.Key.ToString().NoBlank().StartsWith("1.")).OrderByDescending(t => t.Key).First();
var copysheet = workbook.GetSheet(item.Key); var copysheet = workbook.GetSheet(item.Key);
if (copysheet == null) continue; if (copysheet == null) continue;
try var newSheet = copysheet.CopySheet(name, true);
{ workbook.SetSheetOrder(newSheet.SheetName, workbook.NumberOfSheets - 1);
var newSheet = copysheet.CopySheet(module.ModuleName, true);
workbook.SetSheetOrder(newSheet.SheetName, workbook.NumberOfSheets - 1);
}
catch (Exception)
{
}
} }
} }
} }
foreach (var module in modulesList.Where(t => new int[] { (int)SheetType.OtherWorkload, (int)SheetType.Assess }.Contains(t.SheetType.Value))?.OrderBy(t => t.ModuleName)) foreach (var module in modulesList.Where(t => new int[] { (int)SheetType.OtherWorkload, (int)SheetType.Assess }.Contains(t.SheetType.Value))?.OrderBy(t => t.ModuleName))
{ {
var sheet = workbook.GetSheet(module.ModuleName) ?? workbook.GetSheet(module.ModuleName.NoBlank()); var no = module.ModuleName.GetNo();
var name = sheetNames.FirstOrDefault(name => name.StartsWith(no)) ?? module.ModuleName;
var sheet = workbook.GetSheet(name) ?? workbook.GetSheet(module.ModuleName);
if (sheet == null) if (sheet == null)
{ {
var item = pairs.Where(t => t.Key.ToString().NoBlank().StartsWith("3.")).OrderByDescending(t => t.Key).First(); var item = pairs.Where(t => t.Key.ToString().NoBlank().StartsWith("3.")).OrderByDescending(t => t.Key).First();
var copysheet = workbook.GetSheet(item.Key); var copysheet = workbook.GetSheet(item.Key);
if (copysheet == null) continue; if (copysheet == null) continue;
var newSheet = copysheet.CopySheet(module.ModuleName, true); var newSheet = copysheet.CopySheet(name, true);
workbook.SetSheetOrder(newSheet.SheetName, workbook.NumberOfSheets - 1); workbook.SetSheetOrder(newSheet.SheetName, workbook.NumberOfSheets - 1);
var point = PerSheetDataFactory.GetDataRead(SheetType.Workload)?.Point; var point = PerSheetDataFactory.GetDataRead(SheetType.Workload)?.Point;
......
...@@ -157,12 +157,15 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -157,12 +157,15 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
if (row == null) continue; if (row == null) continue;
string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes(); string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes();
if (string.IsNullOrEmpty(department)) continue;
if (rowIndex >= dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1; var deptData = data.Where(t => t.Department.NoBlank() == department);
if (deptData == null || !deptData.Any(t => t.Value.HasValue && t.Value != 0)) continue;
#region 写入数据 #region 写入数据
if (sheetType == SheetType.Income && !string.IsNullOrEmpty(department)) if (sheetType == SheetType.Income)
{ {
if (!incomes.Any(t => t.Department == department)) if (!incomes.Any(t => t.Department == department))
incomes.Add(GetIncomeRowMessage(row, dataFirstCellNum, department, rowIndex)); incomes.Add(GetIncomeRowMessage(row, dataFirstCellNum, department, rowIndex));
...@@ -175,24 +178,13 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -175,24 +178,13 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
var cell = row.GetOrCreate(cellIndex); var cell = row.GetOrCreate(cellIndex);
if (string.IsNullOrEmpty(column)) continue; if (string.IsNullOrEmpty(column)) continue;
var value = deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value;
decimal? value = 0m;
if (!string.IsNullOrEmpty(department))
{
var deptData = data.Where(t => t.Department.NoBlank() == department);
if (deptData != null && deptData.Any(t => t.Value.HasValue && t.Value != 0))
value = deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value;
}
//数据为空,且单元格值不为空,不写入数据(保留原始值) //数据为空,且单元格值不为空,不写入数据(保留原始值)
// 22.3.29 ry 只要是提取的列头全部覆盖数据 if (value.HasValue && value != 0)
//if (value.HasValue && value != 0) cell.SetCellValue<decimal>(value);
if (headers != null && headers.Contains(column)) if (headers != null && headers.Contains(column))
{
cell.SetCellValue<decimal>(value ?? 0);
cell.CellStyle = cellStyle; cell.CellStyle = cellStyle;
}
} }
#endregion #endregion
...@@ -235,7 +227,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -235,7 +227,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
var row = sheet.GetOrCreate(dataFirstRowNum); var row = sheet.GetOrCreate(dataFirstRowNum);
for (int cellIndex = point.HeaderFirstCellNum.Value; cellIndex < columnHeader.LastCellNum; cellIndex++) for (int cellIndex = point.HeaderFirstCellNum.Value; cellIndex < columnHeader.LastCellNum; cellIndex++)
{ {
var column = columnHeader.GetCell(cellIndex).GetDecodeEscapes()?.Replace("(", "(").Replace(")", ")"); ; var column = columnHeader.GetCell(cellIndex).GetDecodeEscapes()?.Replace("(", "(").Replace(")", ")");
var cell = row.CreateCell(cellIndex); var cell = row.CreateCell(cellIndex);
if (filed.ContainsKey(column)) if (filed.ContainsKey(column))
...@@ -278,14 +270,14 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -278,14 +270,14 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
{ {
{ 1, item.Department }, { 1, item.Department },
{ 2, (sheet.SheetName.Contains("门诊") { 2, (sheet.SheetName.Contains("门诊")
? deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.OutNurseAccounting))?.OutNurseAccounting ? deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.OutNurseAccounting))?.OutNurseAccounting
: deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.InpatNurseAccounting))?.InpatNurseAccounting) ?? item.NurseAccount }, : deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.InpatNurseAccounting))?.InpatNurseAccounting) ?? item.NurseAccount },
{ 3, (sheet.SheetName.Contains("门诊") { 3, (sheet.SheetName.Contains("门诊")
? deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.OutDoctorAccounting))?.OutDoctorAccounting ? deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.OutDoctorAccounting))?.OutDoctorAccounting
: deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.InpatDoctorAccounting))?.InpatDoctorAccounting) ?? item.DoctorAccount }, : deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.InpatDoctorAccounting))?.InpatDoctorAccounting) ?? item.DoctorAccount },
{ 4, (sheet.SheetName.Contains("门诊") { 4, (sheet.SheetName.Contains("门诊")
? deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.OutTechnicAccounting))?.OutTechnicAccounting ? deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.OutTechnicAccounting))?.OutTechnicAccounting
: deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.InpatTechnicAccounting))?.InpatTechnicAccounting) ?? item.TechnicAccounting }, : deptData.FirstOrDefault(t => !string.IsNullOrEmpty(t.InpatTechnicAccounting))?.InpatTechnicAccounting) ?? item.TechnicAccounting },
}; };
foreach (var content in deptContents) foreach (var content in deptContents)
...@@ -301,16 +293,9 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -301,16 +293,9 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
{ {
var column = columnHeader.GetOrCreate(cellIndex).GetDecodeEscapes(); var column = columnHeader.GetOrCreate(cellIndex).GetDecodeEscapes();
var cell = row.GetOrCreate(cellIndex); var cell = row.GetOrCreate(cellIndex);
var value = deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value;
var value = (deptData != null && deptData.Any()) if (value.HasValue && value != 0)
? deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value cell.SetCellValue<decimal>(value);
: 0;
//if (cell.CellType != CellType.Formula)
//{
// cell.SetCellValue<decimal>(value);
// cell.CellStyle = cellStyle;
//}
cell.SetCellValue<decimal>(value);
cell.CellStyle = cellStyle; cell.CellStyle = cellStyle;
} }
......
...@@ -99,7 +99,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName, ...@@ -99,7 +99,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
var dict = new Dictionary<ExDataDict, object>(); var dict = new Dictionary<ExDataDict, object>();
logService.ReturnTheLog(allotId, groupName, 3, "", 5, 1, isSingle); logService.ReturnTheLog(allotId, groupName, 3, "", 5, 1, isSingle);
queryService.ClearConnectionPools(); queryService.ClearConnectionPools();
queryService.ClearHistoryData(allot.ID, groupName, isSingle); queryService.ClearHistoryData(allot.ID, groupName, isSingle);
...@@ -107,7 +107,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName, ...@@ -107,7 +107,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
var data = exresultRepository.GetEntities(t => t.AllotId == allotId); var data = exresultRepository.GetEntities(t => t.AllotId == allotId);
data.AddRange(queryService.Handler(hospitalId, allot, groupName, isSingle, ref dict)); 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); dictionaryService.Handler(hospitalId, allot, groupName, isSingle);
...@@ -233,10 +233,10 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD ...@@ -233,10 +233,10 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD
var customer = factory.GetWriteData(sheetType, logger); var customer = factory.GetWriteData(sheetType, logger);
if (customer != null) if (customer != null)
{ {
var collects = collectData?.Where(t => t.SheetName.NoBlank() == sheetName).ToList(); var collects = collectData?.Where(t => t.SheetName.StartsWith(sheetName.GetNo())).ToList();
customer.WriteCollectData(sheet, point, sheetType, style, collects, exdict); customer.WriteCollectData(sheet, point, sheetType, style, collects, exdict);
var exdata = extractDto.Where(t => t.SheetName.NoBlank() == sheetName)?.ToList(); var exdata = extractDto.Where(t => t.SheetName.StartsWith(sheetName.GetNo()))?.ToList();
if (exdata != null) if (exdata != null)
{ {
logger.LogInformation($"{sheetName}: 总金额 - {exdata.Sum(s => s.Value ?? 0)}; 科室 - {string.Join(",", exdata.Select(s => s.Department).Distinct())}"); logger.LogInformation($"{sheetName}: 总金额 - {exdata.Sum(s => s.Value ?? 0)}; 科室 - {string.Join(",", exdata.Select(s => s.Department).Distinct())}");
...@@ -275,10 +275,11 @@ private object GetDataBySheetType(int hospitalId, SheetType sheetType, List<Extr ...@@ -275,10 +275,11 @@ private object GetDataBySheetType(int hospitalId, SheetType sheetType, List<Extr
/// <summary> /// <summary>
/// 标准数据格式, 匹配科室字典 /// 标准数据格式, 匹配科室字典
/// </summary> /// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param> /// <param name="hospitalId"></param>
/// <param name="results"></param> /// <param name="results"></param>
/// <returns></returns> /// <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>(); if (results == null || !results.Any()) return new List<ExtractTransDto>();
...@@ -305,47 +306,50 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> re ...@@ -305,47 +306,50 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> re
dict.ForEach(t => dict.ForEach(t =>
{ {
t.Department = WriteDataHelper.HasValue(t.HISDeptName, t.Department); t.HISDeptName = WriteDataHelper.HasValue(t.HISDeptName, t.Department);
}); });
var data = results.GroupJoin(dict, outer => new { Department = outer.Department }, inner => new { Department = inner.HISDeptName }, (outer, inner) => new { outer, inner }) var data = new List<ExtractTransDto>();
.Select(t => foreach (var item in results)
{
var firstDic = dict.FirstOrDefault(w => w.HISDeptName == item.Department) ?? dict.FirstOrDefault(w => w.Department == item.Department);
var dept = !string.IsNullOrEmpty(firstDic?.Department) ? firstDic?.Department : item.Department;
var d = new ExtractTransDto
{ {
var dept = !string.IsNullOrEmpty(t.inner.FirstOrDefault()?.Department) ? t.inner.FirstOrDefault()?.Department : t.outer.Department; SheetName = item.Source,
return new ExtractTransDto Department = dept,
{ Category = item.Category,
SheetName = t.outer.Source, DoctorName = item.DoctorName,
Department = dept, PersonnelNumber = item.PersonnelNumber,
Category = t.outer.Category, Value = item.Fee ?? 0,
DoctorName = t.outer.DoctorName, OutDoctorAccounting = firstDic?.OutDoctorAccounting?.AccountingUnit,
PersonnelNumber = t.outer.PersonnelNumber, OutNurseAccounting = firstDic?.OutNurseAccounting?.AccountingUnit,
Value = t.outer.Fee ?? 0, OutTechnicAccounting = firstDic?.OutTechnicAccounting?.AccountingUnit,
OutDoctorAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.OutDoctorAccounting?.AccountingUnit, InpatDoctorAccounting = firstDic?.InpatDoctorAccounting?.AccountingUnit,
OutNurseAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.OutNurseAccounting?.AccountingUnit, InpatNurseAccounting = firstDic?.InpatNurseAccounting?.AccountingUnit,
OutTechnicAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.OutTechnicAccounting?.AccountingUnit, InpatTechnicAccounting = firstDic?.InpatTechnicAccounting?.AccountingUnit,
InpatDoctorAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.InpatDoctorAccounting?.AccountingUnit, SpecialAccounting = firstDic?.SpecialAccounting?.AccountingUnit ?? dept,
InpatNurseAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.InpatNurseAccounting?.AccountingUnit, EName = types.FirstOrDefault(w => w.Id == item.TypeId)?.EName,
InpatTechnicAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.InpatTechnicAccounting?.AccountingUnit, };
SpecialAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.SpecialAccounting?.AccountingUnit ?? dept, data.Add(d);
EName = types.FirstOrDefault(w => w.Id == t.outer.TypeId)?.EName, }
};
});
var groupdata = data.GroupBy(t => new { t.Department, t.Category, t.SheetName }).Select(t => new ExtractTransDto var groupdata = data.GroupBy(t => new { t.Department, t.Category, t.SheetName })
{ .Select(t => new ExtractTransDto
SheetName = t.Key.SheetName, {
Department = t.Key.Department, SheetName = t.Key.SheetName,
Category = t.Key.Category, Department = t.Key.Department,
Value = t.Sum(group => group.Value) == 0 ? null : t.Sum(group => group.Value), Category = t.Key.Category,
OutDoctorAccounting = t.FirstOrDefault()?.OutDoctorAccounting, Value = t.Sum(group => group.Value) == 0 ? null : t.Sum(group => group.Value),
OutNurseAccounting = t.FirstOrDefault()?.OutNurseAccounting, OutDoctorAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.OutDoctorAccounting))?.OutDoctorAccounting,
OutTechnicAccounting = t.FirstOrDefault()?.OutTechnicAccounting, OutNurseAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.OutNurseAccounting))?.OutNurseAccounting,
InpatDoctorAccounting = t.FirstOrDefault()?.InpatDoctorAccounting, OutTechnicAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.OutTechnicAccounting))?.OutTechnicAccounting,
InpatNurseAccounting = t.FirstOrDefault()?.InpatNurseAccounting, InpatDoctorAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.InpatDoctorAccounting))?.InpatDoctorAccounting,
InpatTechnicAccounting = t.FirstOrDefault()?.InpatTechnicAccounting, InpatNurseAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.InpatNurseAccounting))?.InpatNurseAccounting,
SpecialAccounting = t.FirstOrDefault()?.SpecialAccounting, InpatTechnicAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.InpatTechnicAccounting))?.InpatTechnicAccounting,
EName = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.EName))?.EName SpecialAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.SpecialAccounting))?.SpecialAccounting,
}); EName = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.EName))?.EName
});
return groupdata.ToList(); return groupdata.ToList();
} }
......
...@@ -438,7 +438,7 @@ public IEnumerable<T> QueryData<T>(sys_hospitalconfig config, string execsql, pe ...@@ -438,7 +438,7 @@ public IEnumerable<T> QueryData<T>(sys_hospitalconfig config, string execsql, pe
if (connection == null) return Enumerable.Empty<T>(); if (connection == null) return Enumerable.Empty<T>();
if (connection.State == ConnectionState.Closed) if (connection.State != ConnectionState.Open)
connection.Open(); connection.Open();
} }
catch catch
...@@ -446,11 +446,19 @@ public IEnumerable<T> QueryData<T>(sys_hospitalconfig config, string execsql, pe ...@@ -446,11 +446,19 @@ public IEnumerable<T> QueryData<T>(sys_hospitalconfig config, string execsql, pe
logService.ReturnTheLog(allot.ID, allot.ID.ToString(), 2, "数据库连接", $"数据库“{config.DbName}”连接失败", 3, isSingle); logService.ReturnTheLog(allot.ID, allot.ID.ToString(), 2, "数据库连接", $"数据库“{config.DbName}”连接失败", 3, isSingle);
} }
logger.LogInformation($"提取绩效数据SQL脚本{execsql}"); try
var result = connection.Query<T>(execsql, commandTimeout: 20000); {
logger.LogInformation($"提取绩效数据执行脚本获取数据{result?.Count() ?? 0}条记录"); logger.LogInformation($"提取绩效数据SQL脚本{execsql}");
var result = connection.Query<T>(execsql, commandTimeout: 60 * 60 * 5);
logger.LogInformation($"提取绩效数据执行脚本获取数据{result?.Count() ?? 0}条记录");
return result;
}
catch (Exception ex)
{
logService.ReturnTheLog(allot.ID, allot.ID.ToString(), 2, "SQL执行错误", ex.Message, 3, isSingle);
throw;
}
return result;
} }
/// <summary> /// <summary>
......
...@@ -39,7 +39,8 @@ public void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType sheetT ...@@ -39,7 +39,8 @@ public void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType sheetT
public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetType, ExcelStyle style, object data, Dictionary<ExDataDict, object> exdict = null) public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetType, ExcelStyle style, object data, Dictionary<ExDataDict, object> exdict = null)
{ {
var modules = exdict[ExDataDict.ExModule] as List<ex_module>; var modules = exdict[ExDataDict.ExModule] as List<ex_module>;
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType && t.ModuleName.NoBlank() == sheet.SheetName.NoBlank()); var no = sheet.SheetName.GetNo();
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType && t.ModuleName.StartsWith(no));
if (module == null) return; if (module == null) return;
if (data is List<ExtractTransDto> extractDto && extractDto.Any()) if (data is List<ExtractTransDto> extractDto && extractDto.Any())
......
...@@ -39,6 +39,7 @@ public class RedistributionService : IAutoInjection ...@@ -39,6 +39,7 @@ public class RedistributionService : IAutoInjection
private readonly PerforAgworkloadRepository _agworkloadRepository; private readonly PerforAgworkloadRepository _agworkloadRepository;
private readonly PerforAgworkloadsourceRepository _agworkloadsourceRepository; private readonly PerforAgworkloadsourceRepository _agworkloadsourceRepository;
private readonly PerforAgworkloadtypeRepository _agworkloadtypeRepository; private readonly PerforAgworkloadtypeRepository _agworkloadtypeRepository;
private readonly PerforImemployeeclinicRepository _imemployeeclinicRepository;
private readonly PerforImemployeelogisticsRepository _imemployeelogisticsRepository; private readonly PerforImemployeelogisticsRepository _imemployeelogisticsRepository;
public RedistributionService( public RedistributionService(
...@@ -59,6 +60,7 @@ public class RedistributionService : IAutoInjection ...@@ -59,6 +60,7 @@ public class RedistributionService : IAutoInjection
PerforAgworkloadRepository agworkloadRepository, PerforAgworkloadRepository agworkloadRepository,
PerforAgworkloadsourceRepository agworkloadsourceRepository, PerforAgworkloadsourceRepository agworkloadsourceRepository,
PerforAgworkloadtypeRepository agworkloadtypeRepository, PerforAgworkloadtypeRepository agworkloadtypeRepository,
PerforImemployeeclinicRepository imemployeeclinicRepository,
PerforImemployeelogisticsRepository imemployeelogisticsRepository) PerforImemployeelogisticsRepository imemployeelogisticsRepository)
{ {
_logger = logger; _logger = logger;
...@@ -78,6 +80,7 @@ public class RedistributionService : IAutoInjection ...@@ -78,6 +80,7 @@ public class RedistributionService : IAutoInjection
_agworkloadRepository = agworkloadRepository; _agworkloadRepository = agworkloadRepository;
_agworkloadsourceRepository = agworkloadsourceRepository; _agworkloadsourceRepository = agworkloadsourceRepository;
_agworkloadtypeRepository = agworkloadtypeRepository; _agworkloadtypeRepository = agworkloadtypeRepository;
_imemployeeclinicRepository = imemployeeclinicRepository;
_imemployeelogisticsRepository = imemployeelogisticsRepository; _imemployeelogisticsRepository = imemployeelogisticsRepository;
} }
#endregion #endregion
...@@ -433,6 +436,7 @@ public void RowsExpand(per_allot allot, List<SecondColumnDictionary> dic, List<D ...@@ -433,6 +436,7 @@ public void RowsExpand(per_allot allot, List<SecondColumnDictionary> dic, List<D
head.AddOrUpdate(nameof(second.UnitType), second.UnitType); head.AddOrUpdate(nameof(second.UnitType), second.UnitType);
head.AddOrUpdate(nameof(ComputeMode), computeMode); head.AddOrUpdate(nameof(ComputeMode), computeMode);
head.AddOrUpdate("ComputeModeDescription", EnumHelper.GetDescription(computeMode)); head.AddOrUpdate("ComputeModeDescription", EnumHelper.GetDescription(computeMode));
var allotStates = new int[] { (int)AllotStates.绩效下发, (int)AllotStates.归档 }; var allotStates = new int[] { (int)AllotStates.绩效下发, (int)AllotStates.归档 };
head.AddOrUpdate(nameof(ag_headsource.SecondId), second.Id); head.AddOrUpdate(nameof(ag_headsource.SecondId), second.Id);
head.AddOrUpdate(nameof(ag_headsource.PaymentOfTheMonth), $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}月"); head.AddOrUpdate(nameof(ag_headsource.PaymentOfTheMonth), $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}月");
...@@ -446,7 +450,10 @@ public void RowsExpand(per_allot allot, List<SecondColumnDictionary> dic, List<D ...@@ -446,7 +450,10 @@ public void RowsExpand(per_allot allot, List<SecondColumnDictionary> dic, List<D
var refAvg = 0m; var refAvg = 0m;
if (Enum.TryParse(typeof(UnitType), second.UnitType, true, out object unittype)) if (Enum.TryParse(typeof(UnitType), second.UnitType, true, out object unittype))
{ {
var rescompute = _resaccountRepository.GetEntity(w => w.AccountingUnit == second.Department && w.UnitType == (int)((UnitType)unittype)); // 优先取 业务中层实际人均绩效 否则 取 科室人均
var empolyee = _imemployeeclinicRepository.GetEntity(w => w.AllotID == allot.ID && w.AccountingUnit == second.Department && w.UnitType == second.UnitType);
var rescompute = _resaccountRepository.GetEntity(w => w.AllotID == allot.ID && w.AccountingUnit == second.Department && w.UnitType == (int)((UnitType)unittype));
var avg = (empolyee != null && empolyee.FitPeopleValue.HasValue) ? empolyee.FitPeopleValue : rescompute?.Avg ?? 0;
refAvg = rescompute?.Avg ?? 0; refAvg = rescompute?.Avg ?? 0;
} }
head.AddOrUpdate("RefAvg", Math.Round(refAvg, 0, MidpointRounding.AwayFromZero)); head.AddOrUpdate("RefAvg", Math.Round(refAvg, 0, MidpointRounding.AwayFromZero));
......
...@@ -1621,14 +1621,11 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount) ...@@ -1621,14 +1621,11 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount)
if (!VerifySubmissioAmount(total, second.RealGiveFee)) if (!VerifySubmissioAmount(total, second.RealGiveFee))
throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee},提交金额:{total}"); throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee},提交金额:{total}");
logger.LogCritical("程序虽然抛出异常但是还是执行了后续代码"); var submitType = temp.UseTempId == 6 ? 2 : 1;
second.UseTempId = temp.UseTempId; var res = agsecondallotRepository.Submit(second.Id, temp.UseTempId ?? 0, total, submitType);
second.Status = 2; if (res == 0)
second.NursingDeptStatus = 2; throw new PerformanceException($"提交失败,当前绩效分配可能发生改变!");
second.SubmitType = temp.UseTempId == 6 ? 2 : 1; return true;
second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中";
return agsecondallotRepository.Update(second);
} }
else if (new int[] { 7, 8 }.Contains(temp.UseTempId.Value)) else if (new int[] { 7, 8 }.Contains(temp.UseTempId.Value))
{ {
...@@ -1641,14 +1638,11 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount) ...@@ -1641,14 +1638,11 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount)
if (!VerifySubmissioAmount(total, second.RealGiveFee)) if (!VerifySubmissioAmount(total, second.RealGiveFee))
throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee},提交金额:{total}"); throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee},提交金额:{total}");
logger.LogCritical("程序虽然抛出异常但是还是执行了后续代码"); var submitType = temp.UseTempId == 6 ? 2 : 1;
second.UseTempId = temp.UseTempId; var res = agsecondallotRepository.Submit(second.Id, temp.UseTempId ?? 0, total, submitType);
second.Status = 2; if (res == 0)
second.NursingDeptStatus = 2; throw new PerformanceException($"提交失败,当前绩效分配可能发生改变请刷新后重试!");
second.SubmitType = temp.UseTempId == 6 ? 2 : 1; return true;
second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中";
return agsecondallotRepository.Update(second);
} }
else /*if (new int[] { 9, 10 }.Contains(temp.UseTempId.Value))*/ else /*if (new int[] { 9, 10 }.Contains(temp.UseTempId.Value))*/
{ {
...@@ -1657,25 +1651,23 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount) ...@@ -1657,25 +1651,23 @@ bool VerifySubmissioAmount(decimal? leftAmount, decimal? rightAmount)
throw new PerformanceException("提交时未检测到数据!"); throw new PerformanceException("提交时未检测到数据!");
else else
{ {
var nightShiftWorkPerforFee = data?.Sum(w => w.NightWorkPerformance ?? 0); var nightShiftWorkPerforFee = data.Sum(w => w.NightWorkPerformance ?? 0);
var total = data?.Sum(t => (t.DistPerformance ?? 0) + (t.NightWorkPerformance ?? 0)); var total = data.Sum(t => (t.DistPerformance ?? 0) + (t.NightWorkPerformance ?? 0));
if (!VerifySubmissioAmount(nightShiftWorkPerforFee, second.NightShiftWorkPerforFee)) if (!VerifySubmissioAmount(nightShiftWorkPerforFee, second.NightShiftWorkPerforFee))
throw new PerformanceException($"夜班绩效金额不一致!夜班绩效金额:{second.NightShiftWorkPerforFee ?? 0:0.####},提交金额:{nightShiftWorkPerforFee:0.####}"); throw new PerformanceException($"夜班绩效金额不一致!夜班绩效金额:{second.NightShiftWorkPerforFee ?? 0:0.####},提交金额:{nightShiftWorkPerforFee:0.####}");
else if (!VerifySubmissioAmount(total, second.RealGiveFee)) else if (!VerifySubmissioAmount(total, second.RealGiveFee))
throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee:0.####},提交金额:{total:0.####}"); throw new PerformanceException($"总金额与考核后金额不一致!可分配金额:{second.RealGiveFee:0.####},提交金额:{total:0.####}");
else else
{ {
// 这段逻辑是为了监测 验证失败后继续修改状态而特意加入的 var submitType = temp.UseTempId == 6 ? 2 : 1;
second.UseTempId = temp.UseTempId; var res = agsecondallotRepository.Submit(second.Id, temp.UseTempId ?? 0, total, submitType);
second.Status = 2; if (res == 0)
second.NursingDeptStatus = 2; throw new PerformanceException($"提交失败,当前绩效分配可能发生改变,请刷新后重试!");
second.SubmitType = temp.UseTempId == 6 ? 2 : 1; return true;
second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中";
return agsecondallotRepository.Update(second);
} }
} }
} }
//logger.LogCritical("程序虽然抛出异常但是还是执行了后续代码");
} }
/// <summary> /// <summary>
......
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