Commit 87de3c0a by ruyun.zhang@suvalue.com

Merge branch 'v2020calculate' into fixed/bug

parents 5b4f2155 738cc72f
......@@ -30,7 +30,7 @@ public BudgetController(ClaimService claim, BudgetService budgetService)
/// <returns></returns>
[HttpPost]
[Route("query")]
public ApiResponse<List<BudgetResponse>> Query([FromBody]BudgetRequest request)
public ApiResponse<List<BudgetResponse>> Query([FromBody] BudgetRequest request)
{
if (request.HospitalId == 0 || request.Year == 0)
return new ApiResponse<List<BudgetResponse>>(ResponseType.ParameterError, "参数无效");
......@@ -47,7 +47,7 @@ public ApiResponse<List<BudgetResponse>> Query([FromBody]BudgetRequest request)
/// <returns></returns>
[HttpPost]
[Route("save/{mainYear}")]
public ApiResponse Save(int mainYear, [FromBody]List<BudgetResponse> request)
public ApiResponse Save(int mainYear, [FromBody] List<BudgetResponse> request)
{
var userId = claim.GetUserId();
var result = false;
......@@ -65,7 +65,7 @@ public ApiResponse Save(int mainYear, [FromBody]List<BudgetResponse> request)
/// <returns></returns>
[HttpPost]
[Route("modify")]
public ApiResponse Modify([FromBody]List<BudgetResponse> request)
public ApiResponse Modify([FromBody] List<BudgetResponse> request)
{
//var result = budgetService.ModifyBudgetData(request);
//return result ? new ApiResponse(ResponseType.OK, "修改成功") : new ApiResponse(ResponseType.Fail, "修改失败");
......@@ -79,7 +79,7 @@ public ApiResponse Modify([FromBody]List<BudgetResponse> request)
/// <returns></returns>
[HttpPost]
[Route("result/query")]
public ApiResponse<List<per_budget_result>> Result([FromBody]BudgetRequest request)
public ApiResponse<List<per_budget_result>> Result([FromBody] BudgetRequest request)
{
if (request.HospitalId == 0 || request.Year == 0)
return new ApiResponse<List<per_budget_result>>(ResponseType.ParameterError, "参数无效");
......@@ -95,7 +95,7 @@ public ApiResponse<List<per_budget_result>> Result([FromBody]BudgetRequest reque
/// <returns></returns>
[HttpPost]
[Route("result/ratio")]
public ApiResponse<List<BudgetRatioResponse>> Ratio([FromBody]BudgetRequest request)
public ApiResponse<List<BudgetRatioResponse>> Ratio([FromBody] BudgetRequest request)
{
if (request.HospitalId == 0 || request.Year == 0)
return new ApiResponse<List<BudgetRatioResponse>>(ResponseType.ParameterError, "参数无效");
......@@ -111,7 +111,7 @@ public ApiResponse<List<BudgetRatioResponse>> Ratio([FromBody]BudgetRequest requ
/// <returns></returns>
[HttpPost]
[Route("result/save")]
public ApiResponse ResultSave([FromBody]List<per_budget_result> request)
public ApiResponse ResultSave([FromBody] List<per_budget_result> request)
{
var userId = claim.GetUserId();
var result = budgetService.SaveBudgetRatio(request, userId);
......@@ -143,5 +143,26 @@ public ApiResponse CancelResult(int id)
var result = budgetService.CancelResult(id);
return result ? new ApiResponse(ResponseType.OK, "操作成功") : new ApiResponse(ResponseType.Fail, "操作失败");
}
/// <summary>
/// 统计指定月份绩效信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("result/collect")]
public ApiResponse Collect([FromBody] BudgetCollectRequest request)
{
var result = budgetService.Collect(request.HospitalId, request.Year, request.Month);
return new ApiResponse(ResponseType.OK, new
{
result.Year,
result.Month,
result.MedicalIncome,
result.TheNewPerformance,
result.MedicineProportion,
result.MaterialCosts,
});
}
}
}
\ No newline at end of file
......@@ -331,8 +331,7 @@ public ApiResponse SubmitAudit(SubmitAuditRequest request)
[Route("/api/second/audit/list")]
public ApiResponse<List<ag_secondallot>> AuditList([FromBody] AllotDeptRequest request)
{
var userid = claimService.GetUserId();
var list = secondAllotService.AuditList(userid, request.AllotId);
var list = secondAllotService.AuditList(request.AllotId);
return new ApiResponse<List<ag_secondallot>>(ResponseType.OK, "审核列表", list);
}
......@@ -352,6 +351,32 @@ public ApiResponse AuditResult([FromBody] SecondAuditRequest request)
}
return result ? new ApiResponse(ResponseType.OK, "操作成功") : new ApiResponse(ResponseType.Fail, "操作失败");
}
/// <summary>
/// 护理部二次绩效审核列表
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("/api/second/audit/nursingdept/list")]
public ApiResponse<List<ag_secondallot>> NursingDeptlist([FromBody] AllotDeptRequest request)
{
var list = secondAllotService.NursingDeptlist(request.AllotId);
return new ApiResponse<List<ag_secondallot>>(ResponseType.OK, "审核列表", list);
}
/// <summary>
/// 护理部二次绩效审核结果;驳回、成功
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("/api/second/audit/nursingdept/result")]
public ApiResponse NursingDeptAuditResult([FromBody] SecondAuditRequest request)
{
var userid = claimService.GetUserId();
var result = secondAllotService.NursingDeptAudit(userid, request);
return result ? new ApiResponse(ResponseType.OK, "操作成功") : new ApiResponse(ResponseType.Fail, "操作失败");
}
#endregion
#region 二次绩效其他绩效
......
......@@ -25,6 +25,7 @@ public class TemplateController : Controller
{
private readonly TemplateService templateService;
private readonly DFExtractService extractService;
private readonly ExtractIncomeService extractIncomeService;
private HospitalService hospitalService;
private IHostingEnvironment env;
private ClaimService claim;
......@@ -37,6 +38,7 @@ public class TemplateController : Controller
public TemplateController(TemplateService templateService,
HospitalService hospitalService,
DFExtractService extractService,
ExtractIncomeService extractIncomeService,
IHostingEnvironment env,
ClaimService claim,
IOptions<Application> options,
......@@ -47,6 +49,7 @@ public class TemplateController : Controller
{
this.templateService = templateService;
this.extractService = extractService;
this.extractIncomeService = extractIncomeService;
this.hospitalService = hospitalService;
this.env = env;
this.claim = claim;
......@@ -407,5 +410,24 @@ public ApiResponse Schedule([FromBody] log_dbug request)
var ratio = allotService.AllotLog(allot, 3)?.Max(t => ConvertHelper.TryDecimal(t.Message)) ?? 0;
return new ApiResponse(ResponseType.OK, new { ratio });
}
[Route("extract/income/{allotId}")]
[AllowAnonymous]
[HttpGet]
public IActionResult ExtractIncome(int allotId)
{
string filepath = extractIncomeService.Execture(allotId);
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
{
stream.CopyToAsync(memoryStream).Wait();
}
memoryStream.Seek(0, SeekOrigin.Begin);
string fileExt = Path.GetExtension(filepath);
var provider = new FileExtensionContentTypeProvider();
var memi = provider.Mappings[fileExt];
return File(memoryStream, memi, Path.GetFileName(filepath));
}
}
}
\ No newline at end of file
......@@ -276,6 +276,13 @@
<param name="id"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.BudgetController.Collect(Performance.DtoModels.Request.BudgetCollectRequest)">
<summary>
统计指定月份绩效信息
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.GetCompute(Performance.DtoModels.ComputerRequest)">
<summary>
获取绩效发放列表
......@@ -1161,6 +1168,18 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.NursingDeptlist(Performance.DtoModels.AllotDeptRequest)">
<summary>
护理部二次绩效审核列表
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.NursingDeptAuditResult(Performance.DtoModels.SecondAuditRequest)">
<summary>
护理部二次绩效审核结果;驳回、成功
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.OtherList(Performance.DtoModels.AgOtherRequest)">
<summary>
二次绩效其他绩效详情
......
......@@ -2817,6 +2817,11 @@
是否开启科室CMI占比 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.DtoModels.HospitalResponse.IsOpenNursingDeptAudit">
<summary>
是否开启护理部审核 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.DtoModels.IncomeResponse.SheetNameKeyword">
<summary>
关键字匹配
......
......@@ -857,6 +857,26 @@
备注
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NursingDeptStatus">
<summary>
护理部审核状态 1 未提交 2 等待审核 3 审核通过 4 驳回
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NursingDeptAuditTime">
<summary>
护理部审核时间
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NursingDeptAuditUser">
<summary>
护理部审核人
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.NursingDeptRemark">
<summary>
护理部备注
</summary>
</member>
<member name="T:Performance.EntityModels.ag_temp">
<summary>
二次绩效模板
......@@ -4997,6 +5017,11 @@
是否开启科室CMI占比 1 启用 2 禁用
</summary>
</member>
<member name="P:Performance.EntityModels.sys_hospital.IsOpenNursingDeptAudit">
<summary>
是否开启护理部审核 1 启用 2 禁用
</summary>
</member>
<member name="T:Performance.EntityModels.sys_hospitalconfig">
<summary>
......
......@@ -10,4 +10,8 @@ public class BudgetRequest
public int Year { get; set; }
}
public class BudgetCollectRequest : BudgetRequest
{
public int Month { get; set; }
}
}
......@@ -23,5 +23,9 @@ public class HospitalResponse
/// 是否开启科室CMI占比 1 启用 2 禁用
/// </summary>
public int IsOpenCMIPercent { get; set; }
/// <summary>
/// 是否开启护理部审核 1 启用 2 禁用
/// </summary>
public int IsOpenNursingDeptAudit { get; set; }
}
}
......@@ -85,5 +85,25 @@ public class ag_secondallot
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 护理部审核状态 1 未提交 2 等待审核 3 审核通过 4 驳回
/// </summary>
public Nullable<int> NursingDeptStatus { get; set; }
/// <summary>
/// 护理部审核时间
/// </summary>
public Nullable<DateTime> NursingDeptAuditTime { get; set; }
/// <summary>
/// 护理部审核人
/// </summary>
public Nullable<int> NursingDeptAuditUser { get; set; }
/// <summary>
/// 护理部备注
/// </summary>
public string NursingDeptRemark { get; set; }
}
}
......@@ -90,5 +90,10 @@ public class sys_hospital
/// 是否开启科室CMI占比 1 启用 2 禁用
/// </summary>
public Nullable<int> IsOpenCMIPercent { get; set; }
/// <summary>
/// 是否开启护理部审核 1 启用 2 禁用
/// </summary>
public Nullable<int> IsOpenNursingDeptAudit { get; set; }
}
}
......@@ -35,6 +35,10 @@ public IEnumerable<T> DapperQuery<T>(string sql, object param) where T : class,
{
return context.Database.GetDbConnection().Query<T>(sql, param);
}
public T DapperQueryFirstOrDefault<T>(string sql, object param)
{
return context.Database.GetDbConnection().QueryFirstOrDefault<T>(sql, param);
}
public IEnumerable<T> DapperQuery<T>(string sql, object param, int? commandTimeout = null)
{
......
......@@ -545,6 +545,7 @@ public void GenerateSecondAllot(per_allot allot)
Department = item.Department,
RealGiveFee = item.RealGiveFee,
Status = 1,
NursingDeptStatus = 1,
});
}
else if (Math.Round((second.RealGiveFee ?? 0) - (item.RealGiveFee ?? 0)) >= 0.5m)
......@@ -554,6 +555,8 @@ public void GenerateSecondAllot(per_allot allot)
{
second.Status = 4;
second.Remark = "科室绩效结果发生变更,需要重新提交";
second.NursingDeptStatus = 4;
second.NursingDeptRemark = "科室绩效结果发生变更,需要重新提交";
}
updSecond.Add(second);
}
......
......@@ -329,5 +329,61 @@ public bool GetAdjustAndGrant(per_allot allot, out decimal adjust, out decimal g
grant = result.Grant.Value / 100;
return true;
}
/// <summary>
/// 统计指定月份绩效信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public per_budget_result Collect(int hospitalid, int year, int month)
{
return new per_budget_result
{
Year = year,
Month = month,
MedicalIncome = GetMedicalIncome(hospitalid, year, month),
TheNewPerformance = GetTheNewPerformance(hospitalid, year, month),
MedicineProportion = GetMedicineProportion(hospitalid, year, month),
MaterialCosts = GetMaterialCosts(hospitalid, year, month),
};
}
///绩效总金额
private decimal GetTheNewPerformance(int hospitalid, int year, int month)
{
string sql = @"select ifnull(sum(fee),0) as fee from (
select realgivefee as fee from res_compute t1
join per_allot t2 on t1.allotid=t2.id
where hospitalid=@hospitalid and year=@year and month=@month and accounttype in ('护士长','科主任','行政中层','行政高层')
union all
select AssessLaterPerforTotal as fee from res_account t1
join per_allot t2 on t1.allotid=t2.id
where hospitalid=@hospitalid and year=@year and month=@month
) tab";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
}
///医疗收入
private decimal GetMedicalIncome(int hospitalid, int year, int month)
{
string sql = @"select ifnull(sum(cellvalue),0) as fee from report_original_income t1 where hospitalid=@hospitalid and year=@year and month=@month";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
}
///药品收入
private decimal GetMedicineProportion(int hospitalid, int year, int month)
{
string sql = @"select ifnull(sum(cellvalue),0) as fee
from report_original_income t1
join cof_drugtype t2 on t1.allotid = t2.allotid and t2.chargetype = '药费'
where hospitalid=@hospitalid and year=@year and month=@month";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
}
///材料支出
private decimal GetMaterialCosts(int hospitalid, int year, int month)
{
string sql = @"select ifnull(sum(cellvalue),0) as fee
from report_original_income t1
join cof_drugtype t2 on t1.allotid = t2.allotid and t2.chargetype = '材料费'
where hospitalid=@hospitalid and year=@year and month=@month";
return perbudgetresultRepository.DapperQueryFirstOrDefault<decimal>(sql, new { hospitalid, year, month });
}
}
}
......@@ -474,7 +474,7 @@ private List<ComputeResponse> GetAllotPerformance(int allotId, int isShowManage)
var types2 = new List<string> { AccountUnitType.行政中层.ToString(), AccountUnitType.行政高层.ToString() };
// 一次绩效 获取特定人员绩效结果
var allot = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId && mTypes.Contains(t.AccountType))?.OrderByDescending(t => t.AccountingUnit);
var apramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId);
//var apramounts = perapramountRepository.GetEntities(t => t.AllotId == allotId);
return allot?.Select(t =>
{
......
using Dapper;
using Microsoft.Extensions.Logging;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Services
{
public class ExtractIncomeService : IAutoInjection
{
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforHospitalconfigRepository hospitalconfigRepository;
private readonly PerforExtypeRepository extypeRepository;
private readonly PerforExscriptRepository exscriptRepository;
private readonly ILogger logger;
public ExtractIncomeService(
PerforPerallotRepository perallotRepository,
PerforHospitalconfigRepository hospitalconfigRepository,
PerforExtypeRepository extypeRepository,
PerforExscriptRepository exscriptRepository,
ILogger<ExtractIncomeService> logger
)
{
this.perallotRepository = perallotRepository;
this.hospitalconfigRepository = hospitalconfigRepository;
this.extypeRepository = extypeRepository;
this.exscriptRepository = exscriptRepository;
this.logger = logger;
}
public string Execture(int allotId)
{
try
{
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) throw new PerformanceException("选取的绩效无效!");
var pairs = GetIncomeData(allot);
string filepath = CreateExcel(allot.HospitalId, pairs);
if (string.IsNullOrEmpty(filepath) || !FileHelper.IsExistFile(filepath))
throw new PerformanceException("抽取文件错误");
logger.LogInformation("医生收入文件: " + filepath);
return filepath;
}
catch (Exception ex)
{
logger.LogError(ex.ToString());
throw new PerformanceException("抽取数据过程中发生异常!");
}
}
private Dictionary<string, List<IncomeDataDto>> GetIncomeData(per_allot allot)
{
var configs = hospitalconfigRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (configs == null || !configs.Any()) return null;
var types = extypeRepository.GetEntities(t => t.Source == 100);
if (types == null || !types.Any()) return null;
Dictionary<string, List<IncomeDataDto>> pairs = new Dictionary<string, List<IncomeDataDto>>();
foreach (var item in types)
{
pairs.Add(item.EName, new List<IncomeDataDto>());
var scripts = exscriptRepository.GetEntities(t => t.TypeId == item.Id);
if (scripts == null || !scripts.Any()) continue;
foreach (var script in scripts)
{
var config = configs.FirstOrDefault(t => t.Id == script.ConfigId);
if (config == null) continue;
var data = QueryData(config, allot, script.ExecScript);
if (data != null && data.Any())
pairs[item.EName].AddRange(data);
}
}
return pairs;
}
private IEnumerable<IncomeDataDto> QueryData(sys_hospitalconfig config, per_allot allot, string execsql)
{
var parameters = GetParameters(allot);
using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword))
{
foreach (var item in parameters)
{
execsql = Regex.Replace(execsql, item.Key, item.Value, RegexOptions.IgnoreCase);
}
var result = connection.Query<IncomeDataDto>(execsql, commandTimeout: 20000);
return result;
}
}
private string CreateExcel(int hospitalId, Dictionary<string, List<IncomeDataDto>> dataDict)
{
if (dataDict == null || !dataDict.Any()) throw new PerformanceException("未查询到数据!");
IWorkbook workbook = new XSSFWorkbook();
ICellStyle cellStyle = getCellStyle.Invoke(workbook);
foreach (var dict in dataDict)
{
ISheet sheet = workbook.CreateSheet(dict.Key);
CreateHeader(sheet, cellStyle);
int rowIndex = sheet.LastRowNum + 1;
foreach (var data in dict.Value)
{
IRow row = sheet.CreateRow(rowIndex);
int index = 0;
foreach (var field in memberDict.Values)
{
ICell cell = row.CreateCell(index);
OutToExcelCell(cell, field?.Invoke(data));
cell.CellStyle = cellStyle;
index++;
}
rowIndex++;
}
}
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", $"{hospitalId}", "income");
if (!FileHelper.IsExistDirectory(path))
FileHelper.CreateDirectory(path);
string filepath = Path.Combine(path, $"医生收入{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx");
using (FileStream fs = new FileStream(filepath, FileMode.Create))
{
workbook.Write(fs);
}
if (workbook != null) workbook.Close();
return filepath;
}
private void CreateHeader(ISheet sheet, ICellStyle cellStyle)
{
IRow row = sheet.CreateRow(0);
if (row == null) return;
int index = 0;
foreach (var col in memberDict.Keys)
{
ICell cell = row.CreateCell(index);
cell.SetCellValue(col);
cell.CellStyle = cellStyle;
index++;
}
sheet.CreateFreezePane(0, 1); //首行冻结
}
private Dictionary<string, string> GetParameters(per_allot allot)
{
DateTime beginTime = new DateTime(allot.Year, allot.Month, 1);
Dictionary<string, string> pairs = new Dictionary<string, string>
{
{ "@beginTime", $"'{beginTime.ToString("yyyy-MM-dd")}'" },
{ "@endTime", $"'{beginTime.AddMonths(1).ToString("yyyy-MM-dd")}'"},
};
return pairs;
}
public void OutToExcelCell(ICell cell, object obj)
{
if (obj == null)
{
cell.SetCellValue("");
return;
}
string value = obj.ToString();
try
{
var type = obj.GetType();
switch (type.ToString())
{
case "System.String"://字符串类型
cell.SetCellValue(value);
break;
case "System.DateTime"://日期类型
DateTime dateV;
DateTime.TryParse(value, out dateV);
cell.SetCellValue(dateV.ToString("yyyy/M/d"));
break;
case "System.Boolean"://布尔型
bool boolV = false;
bool.TryParse(value, out boolV);
cell.SetCellValue(boolV);
break;
case "System.Int16"://整型
case "System.Int32":
case "System.Int64":
case "System.Byte":
int intV = 0;
int.TryParse(value, out intV);
cell.SetCellValue(intV);
break;
case "System.Decimal"://浮点型
case "System.Double":
double doubV = 0;
double.TryParse(value, out doubV);
cell.SetCellValue(doubV);
break;
case "System.DBNull"://空值处理
cell.SetCellValue("");
break;
default:
cell.SetCellValue("");
break;
}
}
catch
{
cell.SetCellValue(value);
}
}
private readonly Dictionary<string, Func<IncomeDataDto, object>> memberDict = new Dictionary<string, Func<IncomeDataDto, object>>
{
{ "医生工号", (t) => t.EmpCode }, { "医生姓名", (t) => t.EmpName }, { "开单科室", (t) => t.DeptName }, {"执行科室", (t) => t.ExecDeptName }, {"费用类型", (t) => t.Category }, {"费用", (t) => t.Fee }
};
private readonly Func<IWorkbook, ICellStyle> getCellStyle = (workbook) =>
{
IFont font = workbook.CreateFont();
font.FontHeightInPoints = 12;
font.FontName = "微软雅黑";
ICellStyle cellStyle = workbook.CreateCellStyle();
cellStyle.Alignment = HorizontalAlignment.Center;//设置水平居中
cellStyle.VerticalAlignment = VerticalAlignment.Center;//设置垂直居中
cellStyle.SetFont(font);
return cellStyle;
};
}
public class IncomeDataDto
{
/// <summary>
/// 医生工号
/// </summary>
public string EmpCode { get; set; }
/// <summary>
/// 医生姓名
/// </summary>
public string EmpName { get; set; }
/// <summary>
/// 开单科室
/// </summary>
public string DeptName { get; set; }
/// <summary>
/// 执行科室
/// </summary>
public string ExecDeptName { get; set; }
/// <summary>
/// 费用类型
/// </summary>
public string Category { get; set; }
/// <summary>
/// 费用
/// </summary>
public decimal Fee { get; set; }
}
}
......@@ -17,6 +17,7 @@ namespace Performance.Services
public class SecondAllotService : IAutoInjection
{
private readonly Application application;
private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforUserRepository perforUserRepository;
private readonly PerforUserhospitalRepository perforUserhospitalRepository;
private readonly PerforPerallotRepository perforPerallotRepository;
......@@ -40,6 +41,7 @@ public class SecondAllotService : IAutoInjection
private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>();
public SecondAllotService(IOptions<Application> application,
PerforHospitalRepository hospitalRepository,
PerforUserRepository perforUserRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perforPerallotRepository,
......@@ -62,6 +64,7 @@ public class SecondAllotService : IAutoInjection
PerforRescomputeRepository rescomputeRepository)
{
this.application = application.Value;
this.hospitalRepository = hospitalRepository;
this.perforUserRepository = perforUserRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perforPerallotRepository = perforPerallotRepository;
......@@ -1214,21 +1217,18 @@ public bool DeleteWorkType(WorkloadRequest request)
/// </summary>
/// <param name="userId">用户ID</param>
/// <returns></returns>
public List<ag_secondallot> AuditList(int userId, int allotId)
public List<ag_secondallot> AuditList(int allotId)
{
//var hospital = perforUserhospitalRepository.GetEntities(t => t.UserID == userId);
//var allotList = perforPerallotRepository.GetEntities(t => hospital.Select(h => h.HospitalID).Contains(t.HospitalId));
//if (allotList != null && allotList.Count > 0)
//{
// var allotIds = allotList.Select(t => t.ID);
// return perforAgsecondallotRepository.GetEntities(t => allotIds.Contains(t.AllotId.Value) && t.Status == 2);
//}
//return null;
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null)
throw new PerformanceException("所选绩效不存在!");
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && !new int[] { (int)UnitType.行政高层, (int)UnitType.行政中层 }.Contains(t.UnitType.Value));
return SecondList(allot, accountUnit);
}
private List<ag_secondallot> SecondList(per_allot allot, List<res_account> accountUnit)
{
if (accountUnit == null || !accountUnit.Any()) return new List<ag_secondallot>();
var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month);
......@@ -1238,7 +1238,7 @@ public List<ag_secondallot> AuditList(int userId, int allotId)
if (second != null) return second;
return new ag_secondallot
{
AllotId = allotId,
AllotId = allot.ID,
Year = allot.Year,
Month = allot.Month,
UnitType = ((UnitType)t.UnitType).ToString(),
......@@ -1255,6 +1255,21 @@ public List<ag_secondallot> AuditList(int userId, int allotId)
}
/// <summary>
/// 护理部二次绩效考核列表
/// </summary>
/// <param name="userId">用户ID</param>
/// <returns></returns>
public List<ag_secondallot> NursingDeptlist(int allotId)
{
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null)
throw new PerformanceException("所选绩效不存在!");
var types = new int[] { (int)UnitType.其他护理组, (int)UnitType.护理组 };
var accountUnit = perforResaccountRepository.GetEntities(t => t.AllotID == allotId && types.Contains(t.UnitType.Value));
return SecondList(allot, accountUnit);
}
/// <summary>
/// 提交审核
/// </summary>
/// <param name="userId">用户ID</param>
......@@ -1298,6 +1313,7 @@ public bool AuditSubmit(ag_secondallot second, int userId)
}
second.UseTempId = temp.UseTempId;
second.Status = 2;
second.NursingDeptStatus = 2;
second.SubmitType = temp.UseTempId == 6 ? 2 : 1;
second.SubmitTime = DateTime.Now;
//second.Remark = "已提交审核,等待审核中";
......@@ -1345,6 +1361,16 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
if (result && request.IsPass == 1)
{
// 护理部审核
var allot = perforPerallotRepository.GetEntity(w => w.ID == second.AllotId);
if (allot == null) return true;
var hospital = hospitalRepository.GetEntity(w => w.ID == allot.HospitalId);
if (hospital == null) return true;
if (hospital.IsOpenNursingDeptAudit != 1 || second.NursingDeptStatus != 3)
return true;
var computes = new List<ag_compute>();
if (second.SubmitType == 1)
{
......@@ -1404,6 +1430,35 @@ public bool ConfirmAudit(int userId, SecondAuditRequest request)
#endregion
return result;
}
/// <summary>
/// 护理部审核
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="secondId">二次绩效ID</param>
/// <param name="ispass">1、审核通过 2、驳回</param>
/// <returns></returns>
public bool NursingDeptAudit(int userId, SecondAuditRequest request)
{
var second = perforAgsecondallotRepository.GetEntity(t => t.Id == request.SecondId);
if (second == null)
throw new PerformanceException("二次分配绩效无效");
if (request.IsPass == 1)
{
second.NursingDeptStatus = 3;
second.NursingDeptRemark = $"护理部审核通过;{request.Remark}";
}
else
{
second.UseTempId = null;
second.NursingDeptStatus = 4;
second.NursingDeptRemark = $"护理部驳回;驳回原因:{request.Remark}";
}
second.NursingDeptAuditUser = userId;
second.NursingDeptAuditTime = DateTime.Now;
return perforAgsecondallotRepository.Update(second);
}
#endregion
#region common
......
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