Commit d46c8d42 by 钟博

划拨显示,申请,审核样式修正、驳回修改

parent 10edced7
......@@ -59,8 +59,11 @@ public ApiResponse Common(int hospitalId, int allotId)
var userid = claim.GetUserId();
var user = userService.GetUser(userid);
var role = roleService.GetARole(user.UserID);
var result = costTransferService.Common(allotId, hospitalId,role.Type.Value, user.Department);
var result = costTransferService.Common(allotId, hospitalId);
result.deparment = user.Department ?? "";
return new ApiResponse(ResponseType.OK, result);
}
......@@ -109,5 +112,21 @@ public ApiResponse Audit([FromBody] CostTransferUpdateRequest request)
costTransferService.CostTransferAudit(request, false);
return new ApiResponse(ResponseType.OK);
}
/// <summary>
/// 驳回修改
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("updateapplicat")]
[HttpPost]
public ApiResponse UpdateApplicat([FromBody] CostTransferUpdateRequest request)
{
if (request.AllotId <= 0)
return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
costTransferService.UpdateApplicat(request);
return new ApiResponse(ResponseType.OK);
}
}
}
......@@ -723,6 +723,13 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.CostTransferController.UpdateApplicat(Performance.DtoModels.CostTransferUpdateRequest)">
<summary>
驳回修改
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.GetEmployeeList(Performance.DtoModels.EmployeeRequest)">
<summary>
获取人员列表
......
......@@ -2953,6 +2953,36 @@
银行卡号
</summary>
</member>
<member name="P:Performance.DtoModels.CostTransferResponse.AllotId">
<summary>
</summary>
</member>
<member name="P:Performance.DtoModels.CostTransferResponse.ApplicantUnitType">
<summary>
申请者核算单元类型
</summary>
</member>
<member name="P:Performance.DtoModels.CostTransferResponse.ApplicantDepartment">
<summary>
申请者科室
</summary>
</member>
<member name="P:Performance.DtoModels.CostTransferResponse.AdoptedUnitType">
<summary>
审核者核算单元类型
</summary>
</member>
<member name="P:Performance.DtoModels.CostTransferResponse.AdoptedDepartment">
<summary>
审核者科室
</summary>
</member>
<member name="P:Performance.DtoModels.CostTransferResponse.Status">
<summary>
0 未审核 1 部分审核 2 全部审核 3 未含有划拨明细
</summary>
</member>
<member name="P:Performance.DtoModels.DeptDataDetails`1.Pandect">
<summary> 概览</summary>
</member>
......
......@@ -235,6 +235,12 @@ public AutoMapperConfigs()
CreateMap<HistoryData, report_original_surgery>()
.ForMember(dest => dest.PersonTime, opt => opt.MapFrom(src => src.ResultData))
.ReverseMap();
CreateMap<cost_transfer, CostTransferResponse>(
).ForMember(back=>back.Items,n=>n.Ignore());
CreateMap<cost_transfer, cost_transfer>(
).ForMember(back => back.Id, n => n.Ignore());
}
public void xx()
......
......@@ -8,39 +8,62 @@ namespace Performance.DtoModels
public class CostTransferResponse
{
public int Id { get; set; }
public string AdoptedDepartment { get; set; }
public string AdoptedUnitType { get; set; }
public string ApplicantDepartment { get; set; }
public string ApplicantUnitType { get; set; }
public string Source { get; set; }
public string Category { get; set; }
/// <summary>
///
/// </summary>
public int AllotId { get; set; }
public Nullable<decimal> Amount { get; set; }
/// <summary>
/// 申请者核算单元类型
/// </summary>
public string ApplicantUnitType { get; set; }
public Nullable<decimal> Ratio { get; set; }
/// <summary>
/// 申请者科室
/// </summary>
public string ApplicantDepartment { get; set; }
public Nullable<decimal> CalculationAmount { get; set; }
/// <summary>
/// 审核者核算单元类型
/// </summary>
public string AdoptedUnitType { get; set; }
public string Remark { get; set; }
/// <summary>
/// 审核者科室
/// </summary>
public string AdoptedDepartment { get; set; }
/// <summary>
/// 0 未审核 1 部分审核 2 全部审核
/// </summary>
public int Status { get; set; }
public int AdminStatus { get; set; }
//public List<TransferItemResponse> costTransferItem { get; set; }
public List<Option> Items { get; set; }
}
public class CommonResponse
{
public string deparment { get; set; }
public string unitType { get; set; }
public IEnumerable<TitleValue> drugType { get; set; }
public List<TitleValue> account { get; set; }
public IEnumerable<TitleValue> sheets { get; set; }
public List<Common> Data { get; set; }
}
//public List<cof_accounting> accounting { get; set; }
public class Common
{
public string Source { get; set; }
public string Category { get; set; }
public decimal Ratio { get; set; }
}
public IEnumerable<TitleValue> dept { get; set; }
public class Option : cost_transfer_item
{
public string[] options { get; set; }
}
}
......@@ -46,8 +46,10 @@ public class cost_transfer
public string AdoptedDepartment { get; set; }
/// <summary>
/// 0 未审核 1 部分审核 2 全部审核 3 未含有划拨明细
/// 0 未审核 1 部分审核 2 全部审核
/// </summary>
public int Status { get; set; }
public int AdminStatus { get; set; }
}
}
using Microsoft.EntityFrameworkCore.Internal;
using AutoMapper;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
......@@ -11,6 +12,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
namespace Performance.Services
{
......@@ -25,6 +27,7 @@ public class CostTransferService : IAutoInjection
private readonly PerforCofaccountingRepository cofaccountingRepository;
private readonly PerforPerdeptdicRepository perdeptdicRepository;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforImdataRepository imdataRepository;
public CostTransferService(
ILogger<CostTransferService> logger,
......@@ -35,7 +38,8 @@ public class CostTransferService : IAutoInjection
PerforPersheetRepository persheetRepository,
PerforCofaccountingRepository cofaccountingRepository,
PerforPerdeptdicRepository perdeptdicRepository,
PerforPerallotRepository perallotRepository
PerforPerallotRepository perallotRepository,
PerforImdataRepository imdataRepository
)
{
this.logger = logger;
......@@ -47,6 +51,7 @@ PerforPerallotRepository perallotRepository
this.cofaccountingRepository = cofaccountingRepository;
this.perdeptdicRepository = perdeptdicRepository;
this.perallotRepository = perallotRepository;
this.imdataRepository = imdataRepository;
}
/// <summary>
......@@ -58,29 +63,19 @@ PerforPerallotRepository perallotRepository
public List<CostTransferResponse> GetAuditList(int allotId, int roleType, string Department)
{
var roleTypes = new[] { 1, 2, 5 }.Contains(roleType);
Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == allotId && t.AccountingUnit == Department;
if (roleType == application.DirectorRole)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType));
else if (roleType == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
else if (roleType == application.SpecialRole)
exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString());
else if (roleType == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var account = cofaccountingRepository.GetEntity(exp);
var account = GetAccounting(allotId, roleType, Department);
Expression<Func<cost_transfer, bool>> expCost = t => t.AllotId == allotId ;
Expression<Func<cost_transfer, bool>> exp = t => t.AllotId == allotId;
if (roleType == application.DirectorRole)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType));
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.AdoptedUnitType));
else if (roleType == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
exp = exp.And(t => t.AdoptedUnitType == UnitType.护理组.ToString());
else if (roleType == application.SpecialRole)
exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString());
exp = exp.And(t => t.AdoptedUnitType == UnitType.特殊核算组.ToString());
else if (roleType == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
exp = exp.And(t => t.AdoptedUnitType == UnitType.行政后勤.ToString());
var costTransfers = costtransferRepository.GetEntities(expCost);
var costTransfers = costtransferRepository.GetEntities(exp);
if (!roleTypes)
costTransfers = costTransfers?.FindAll(t => t.AdoptedDepartment == Department);
......@@ -93,19 +88,16 @@ public List<CostTransferResponse> GetAuditList(int allotId, int roleType, string
var costItem = costtransferitemRepository.GetEntities(t => costsId.Contains(t.TransferId));
//如果是绩效办显示已经被科室同意的数据
if (roleTypes)
costItem = costItem?.FindAll(t => t.Status == 1);
//if (roleTypes)
// costItem = costItem?.FindAll(t => t.Status == 1);
foreach (var item in costTransfers)
{
var cost = costItem.Where(t=>t.TransferId==item.Id)?.Select(t => new CostTransferResponse
var result = new CostTransferResponse();
result = Mapper.Map<CostTransferResponse>(item);
result.Items = costItem.Where(t => t.TransferId == item.Id)?.Select(t => new Option
{
Id=t.Id,
AdoptedDepartment = roleTypes ? item.AdoptedDepartment : account?.AccountingUnit,
AdoptedUnitType = roleTypes ? item.AdoptedUnitType : account?.UnitType,
ApplicantDepartment = item.ApplicantDepartment,
ApplicantUnitType = item.ApplicantUnitType,
Id = t.Id,
Source = t.Source,
Category = t.Category,
Amount = t.Amount,
......@@ -113,50 +105,112 @@ public List<CostTransferResponse> GetAuditList(int allotId, int roleType, string
CalculationAmount = t.CalculationAmount,
Status = t.Status,
AdminStatus = t.AdminStatus,
Remark = t.Remark
}).ToList();
response.AddRange(cost);
Remark = t.Remark,
options = new string[] { }
}).OrderBy(t => t.Status).ThenBy(t => t.AdminStatus).ToList();
response.Add(result);
}
return response;
return response.OrderBy(t => t.Status).ToList();
}
public cof_accounting GetAccounting(int allotId, int roleType, string Department = null)
{
Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == allotId && t.AccountingUnit == Department;
if (roleType == application.DirectorRole)
exp = exp.And(t => new List<string> { UnitType.医生组.ToString(), UnitType.医技组.ToString() }.Contains(t.UnitType));
else if (roleType == application.NurseRole)
exp = exp.And(t => t.UnitType == UnitType.护理组.ToString());
else if (roleType == application.SpecialRole)
exp = exp.And(t => t.UnitType == UnitType.特殊核算组.ToString());
else if (roleType == application.OfficeRole)
exp = exp.And(t => t.UnitType == UnitType.行政后勤.ToString());
var account = cofaccountingRepository.GetEntity(exp);
return account;
}
/// <summary>
/// 申请页面下拉选项
/// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <returns></returns>
public CommonResponse Common(int allotId, int hospitalId)
public CommonResponse Common(int allotId, int hospitalId, int roleType, string deparment)
{
var common = new CommonResponse();
var sheetList = new TitleValue[]
{
new TitleValue{ Title = "1.0.1 额外收入", Value = "1.0.1 额外收入" },
new TitleValue{ Title = "1.1.1 门诊开单收入", Value = "1.1.1 门诊开单收入" },
new TitleValue{ Title = "1.1.2 门诊执行收入", Value = "1.1.2 门诊执行收入" },
new TitleValue{ Title = "1.2.1 住院开单收入", Value = "1.2.1 住院开单收入" },
new TitleValue{ Title = "1.2.2 住院执行收入", Value = "1.2.2 住院执行收入" },
new TitleValue{ Title = "2.1 成本支出统计表", Value = "2.1 成本支出统计表" },
new TitleValue{ Title = "3.1 医生组工作量绩效测算表", Value = "3.1 医生组工作量绩效测算表" },
new TitleValue{ Title = "3.2 护理组工作量绩效测算表", Value = "3.2 护理组工作量绩效测算表" },
common.account = cofaccountingRepository.GetEntities(t => t.AllotId == allotId)
?.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).ToDistinct().ToList();
var sheets = persheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Income);
if (sheets == null || !sheets.Any())
{
var data = new List<Common>()
{
new Common{ Source = "门诊开单收入"},
new Common{ Source = "门诊执行收入"},
new Common{ Source = "住院开单收入"},
new Common{ Source = "住院执行收入"},
};
common.Data = data;
return common;
}
var unitType = GetAccounting(allotId, roleType, deparment)?.UnitType;
var unitValue = EnumHelper.GetItems<UnitType>().Find(t => t.Name == unitType).Value;
var sheetId = sheets.Select(t => t.ID);
var imData = imdataRepository.GetEntities(t => t.AllotID == allotId && sheetId.Contains(t.SheetID.Value) && t.UnitType == unitValue);
if (imData == null || !imData.Any()) return common;
var datas = from im in imData group im by new { im.SheetID, im.TypeName, im.FactorValue } into i select new { i.Key, i };
var commons = datas.Select(t => new Common
{
Source = Regex.Replace(sheets.Find(w => w.ID == t.Key.SheetID).SheetName, @"\d.", ""),
Category = t.Key.TypeName,
Ratio = t.Key.FactorValue.Value
}).ToList();
common.Data = commons;
common.unitType = unitType;
#region
/*
var drugType = cofdrugtypeRepository.GetEntities(t => t.HospitalId == hospitalId && t.AllotID == allotId)
?.Select(t => new TitleValue { Title = t.Charge, Value = t.Charge }).ToDistinct();
var sheet = persheetRepository.GetEntities(t => t.AllotID == allotId)
?.Select(t => new TitleValue { Title = t.SheetName, Value = t.SheetName }).ToDistinct();
var sheet = persheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Income)
?.Select(t => new TitleValue
{
Title = Regex.Replace(t.SheetName, @"\d.", "")
,
Value = Regex.Replace(t.SheetName, @"\d.", "")
}).ToDistinct();
//var account = cofaccountingRepository.GetEntities(t => t.AllotId == allotId);
var dept = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId)
?.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).ToDistinct();
*/
#endregion
if (unitType == null)
{
var prevAllot = PrevAllot(hospitalId, allotId);
common.unitType = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
to:
if (common.unitType == null)
{
var prevAllotId = prevAllot.ID--;
if (prevAllotId <= 0) return common;
common.unitType = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
goto to;
}
}
common.drugType = drugType;
common.sheets = sheet ?? sheetList.ToList();
//common.accounting = account ?? new List<cof_accounting>();
common.dept = dept;
return common;
}
......@@ -180,11 +234,15 @@ public bool Applicat(CostTransferRequest request)
if (request.Items == null || !request.Items.Any())
throw new PerformanceException("参数错误,申请条目为空");
if(request.Adopted.Department==request.Applicant.Department && request.Adopted.UnitType==request.Applicant.UnitType)
if (request.Adopted.Department == request.Applicant.Department && request.Adopted.UnitType == request.Applicant.UnitType)
throw new PerformanceException("参数错误,提交科室相同");
var allot = perallotRepository.GetEntity(t => t.ID == request.AllotId);
var allotStatus = new[] { (int)AllotStates.Issue, (int)AllotStates.Archive };
if (allotStatus.Contains(allot.States))
throw new PerformanceException("绩效已下发");
var transfer = new cost_transfer
{
AllotId = request.AllotId,
......@@ -192,7 +250,8 @@ public bool Applicat(CostTransferRequest request)
ApplicantUnitType = request.Applicant.UnitType,
AdoptedDepartment = request.Adopted.Department,
AdoptedUnitType = request.Adopted.UnitType,
Status = allotStatus.Contains(allot.States) ? 2 : 0
Status = 0,
AdminStatus=0
};
var result = costtransferRepository.Add(transfer);
......@@ -209,9 +268,8 @@ public bool Applicat(CostTransferRequest request)
CalculationAmount = t.CalculationAmount,
IsUseRatio = t.IsUseRatio,
Remark = t.Remark,
Status = allotStatus.Contains(allot.States) ? 3 : 0,
AdminStatus = allotStatus.Contains(allot.States) ? 3 : 0
Status = 0,
AdminStatus = 0
}).ToArray();
result = costtransferitemRepository.AddRange(items);
......@@ -282,7 +340,8 @@ public void UpdateApplicat(CostTransferUpdateRequest request)
update.CalculationAmount = item.CalculationAmount;
update.IsUseRatio = item.IsUseRatio;
update.Remark = item.Remark;
update.Status = 0;
update.AdminStatus = 0;
hasPrimaryValueItmes.Remove(item);
}
costtransferitemRepository.UpdateRange(updateItems.ToArray());
......@@ -386,6 +445,7 @@ public bool RejectedApplicat(int allotId, int transferId = 0, bool issue = false
costTransfers.ForEach(t =>
{
t.Status = 2;
t.AdminStatus = 2;
});
costtransferitemRepository.UpdateRange(costItems.ToArray());
......@@ -398,18 +458,10 @@ public bool RejectedApplicat(int allotId, int transferId = 0, bool issue = false
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="allotId"></param>
public void IntoLastTiemData(int hospitalId,int allotId)
public void IntoLastTiemData(int hospitalId, int allotId)
{
var allotList = perallotRepository.GetEntities(w => w.HospitalId == hospitalId)?.OrderBy(s => s.Year).ThenBy(s => s.Month).ToList();
if (allotList == null || !allotList.Any()) throw new PerformanceException("未查询到符合的绩效记录");
var allot = allotList.FirstOrDefault(w => w.ID ==allotId);
if (allot == null) throw new PerformanceException("未查询到符合的绩效记录");
var index = allotList.IndexOf(allot);
if (index == 0) return ;
var prevAllot = allotList[index - 1];
var prevAllot = PrevAllot(hospitalId, allotId);
if (prevAllot == null) return;
var transfers = costtransferRepository.GetEntities(t => t.AllotId == prevAllot.ID);
if (transfers == null || !transfers.Any()) return;
......@@ -424,12 +476,8 @@ public void IntoLastTiemData(int hospitalId,int allotId)
foreach (var item in transferLast)
{
var newTransfers = new cost_transfer();
newTransfers = Mapper.Map<cost_transfer>(item);
newTransfers.AllotId = allotId;
newTransfers.ApplicantDepartment = item.ApplicantDepartment;
newTransfers.ApplicantUnitType = item.ApplicantUnitType;
newTransfers.AdoptedDepartment = item.AdoptedDepartment;
newTransfers.AdoptedUnitType = item.AdoptedUnitType;
newTransfers.Status = 0;
costtransferRepository.Add(newTransfers);
......@@ -453,6 +501,22 @@ public void IntoLastTiemData(int hospitalId,int allotId)
}
private per_allot PrevAllot(int hospitalId, int allotId)
{
var allotList = perallotRepository.GetEntities(w => w.HospitalId == hospitalId)?.OrderBy(s => s.Year).ThenBy(s => s.Month).ToList();
if (allotList == null || !allotList.Any()) throw new PerformanceException("未查询到符合的绩效记录");
var allot = allotList.FirstOrDefault(w => w.ID == allotId);
if (allot == null) throw new PerformanceException("未查询到符合的绩效记录");
var index = allotList.IndexOf(allot);
if (index == 0) return null;
var prevAllot = allotList[index - 1];
return prevAllot;
}
/// <summary>
/// 修改申请记录的状态
/// </summary>
......@@ -469,20 +533,31 @@ public void UpdateCostTransferStatus(int transferId)
{
case var data when data == null || !data.Any():
transfer.Status = 3;
transfer.AdminStatus = 0;
break;
case var data when !data.Any(t => t.Status == 0):
transfer.Status = 2;
transfer.AdminStatus = 0;
break;
case var data when data.Any(t => t.Status == 0) && data.Any(t => t.Status != 0):
case var data when data.Any(t => t.Status == 0) && !data.Any(t => t.Status == 0):
transfer.Status = 1;
transfer.AdminStatus = 0;
break;
case var data when !data.Any(t => t.Status != 0):
case var data when data.Any(t => t.Status == 0):
transfer.Status = 0;
transfer.AdminStatus = 0;
break;
case var data when !data.Any(t => t.Status == 0) && !data.Any(t => t.AdminStatus == 0):
transfer.Status = 2;
transfer.AdminStatus = 2;
break;
case var data when !data.Any(t => t.Status == 0) && data.Any(t => t.AdminStatus == 0) && !data.Any(t => t.AdminStatus == 0):
transfer.Status = 2;
transfer.AdminStatus = 1;
break;
default:
break;
}
......
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