Commit 10253693 by 钟博

划拨汇总、明细拆分

parent f2dade06
...@@ -68,6 +68,29 @@ public ApiResponse Common(int hospitalId, int allotId, [FromBody] DepartmentDeta ...@@ -68,6 +68,29 @@ public ApiResponse Common(int hospitalId, int allotId, [FromBody] DepartmentDeta
} }
/// <summary> /// <summary>
/// 当前科室、类别
/// </summary>
/// <returns></returns>
[Route("deptdetial/{hospitalId}/allot/{allotId}")]
[HttpPost]
public ApiResponse DeptDetial(int hospitalId, int allotId)
{
if (hospitalId <= 0)
return new ApiResponse(ResponseType.ParameterError, "参数HospitalId无效!");
if (allotId <= 0)
return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
var userid = claim.GetUserId();
var user = userService.GetUser(userid);
var role = roleService.GetARole(user.UserID);
var result = costTransferService.DeptDetial(allotId, hospitalId, role.Type.Value, user.Department);
result.Item2.Department = user.Department ?? "";
return new ApiResponse(ResponseType.OK, result.Item2);
}
/// <summary>
/// 撤回提交 /// 撤回提交
/// </summary> /// </summary>
/// <param name="itemId"></param> /// <param name="itemId"></param>
......
...@@ -7,8 +7,13 @@ namespace Performance.DtoModels ...@@ -7,8 +7,13 @@ namespace Performance.DtoModels
{ {
public class TransferReportResponse public class TransferReportResponse
{ {
public int Id { get; set; } public List<Transfer> Transfers { get; set; }
public List<TransferItem> Items { get; set; }
}
public class Transfer
{
public string ApplicantUnitType { get; set; } public string ApplicantUnitType { get; set; }
public string ApplicantDepartment { get; set; } public string ApplicantDepartment { get; set; }
...@@ -20,8 +25,6 @@ public class TransferReportResponse ...@@ -20,8 +25,6 @@ public class TransferReportResponse
public string AdoptedDepartment { get; set; } public string AdoptedDepartment { get; set; }
public decimal? PassAmountSum { get; set; } public decimal? PassAmountSum { get; set; }
public List<TransferItem> Items { get; set; }
} }
public class TransferItem : cost_transfer_item public class TransferItem : cost_transfer_item
......
...@@ -170,19 +170,9 @@ public CommonResponse Common(int allotId, int hospitalId, int roleType, string d ...@@ -170,19 +170,9 @@ public CommonResponse Common(int allotId, int hospitalId, int roleType, string d
common.account = cofaccountingRepository.GetEntities(t => t.AllotId == allotId) common.account = cofaccountingRepository.GetEntities(t => t.AllotId == allotId)
?.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).ToDistinct().ToList(); ?.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).ToDistinct().ToList();
var prevAllotList = PrevAllotList(hospitalId, allotId); var (prevAllotList, deptDetail) = DeptDetial(allotId, hospitalId, roleType, deparment);
if (prevAllotList != null && prevAllotList.Any())
{ common.unitType = deptDetail.UnitType ?? "";
foreach (var prevAllot in prevAllotList)
{
string unittype = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
if (!string.IsNullOrEmpty(unittype))
{
common.unitType = unittype;
break;
}
}
}
var sheets = persheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Income); var sheets = persheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Income);
if (sheets != null && sheets.Any()) if (sheets != null && sheets.Any())
...@@ -233,6 +223,25 @@ public CommonResponse Common(int allotId, int hospitalId, int roleType, string d ...@@ -233,6 +223,25 @@ public CommonResponse Common(int allotId, int hospitalId, int roleType, string d
return common; return common;
} }
public (List<per_allot>, DepartmentDetail) DeptDetial(int allotId, int hospitalId, int roleType, string deparment)
{
var detail = new DepartmentDetail();
var prevAllotList = PrevAllotList(hospitalId, allotId);
if (prevAllotList != null && prevAllotList.Any())
{
foreach (var prevAllot in prevAllotList)
{
string unittype = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
if (!string.IsNullOrEmpty(unittype))
{
detail.UnitType = unittype;
break;
}
}
}
return (prevAllotList, detail);
}
/// <summary> /// <summary>
/// 申请划拨 /// 申请划拨
/// </summary> /// </summary>
...@@ -427,7 +436,7 @@ public void DeleteApplicat(int transferId) ...@@ -427,7 +436,7 @@ public void DeleteApplicat(int transferId)
public bool CostTransferAudit(AuditRequest request, bool isAdmin) public bool CostTransferAudit(AuditRequest request, bool isAdmin)
{ {
if (request.TransferItemId.Length <= 0) if (request.TransferItemId.Length <= 0)
throw new PerformanceException("没有可以审核的记录"); throw new PerformanceException("科室未审核或已驳回,不能一键通过");
var costItems = costtransferitemRepository.GetEntities(t => request.TransferItemId.Contains(t.Id)); var costItems = costtransferitemRepository.GetEntities(t => request.TransferItemId.Contains(t.Id));
var transferId = costItems?.Select(t => t.TransferId).Distinct(); var transferId = costItems?.Select(t => t.TransferId).Distinct();
...@@ -648,56 +657,61 @@ public void UpdateCostTransferStatus(int transferId) ...@@ -648,56 +657,61 @@ public void UpdateCostTransferStatus(int transferId)
#region 划拨报表 #region 划拨报表
public List<TransferReportResponse> TransferContent(int allotId,int auditType,DepartmentDetail detail) public TransferReportResponse TransferContent(int allotId, int auditType, DepartmentDetail detail)
{ {
var transfers = costtransferRepository.GetEntities(t => t.AllotId == allotId && t.Status != 3 && t.AdminStatus != 3); var transfers = costtransferRepository.GetEntities(t => t.AllotId == allotId && t.Status != 3 && t.AdminStatus != 3);
if (transfers == null || !transfers.Any()) return new List<TransferReportResponse>(); if (transfers == null || !transfers.Any()) return new TransferReportResponse();
var transferItems = costtransferitemRepository.GetEntities(t => transfers.Select(w => w.Id).Contains(t.TransferId)); switch (auditType)
{
case 1:
transfers = transfers.Where(t => t.AdoptedDepartment == detail.Department && t.AdoptedUnitType == detail?.UnitType).ToList();
break;
case 2:
transfers = transfers.Where(t => t.ApplicantDepartment == detail.Department && t.ApplicantUnitType == detail?.UnitType).ToList();
break;
default:
break;
}
if (transferItems == null || !transferItems.Any()) return new List<TransferReportResponse>(); var transferItems = costtransferitemRepository.GetEntities(t => transfers.Select(w => w.Id).Contains(t.TransferId));
if (transferItems == null || !transferItems.Any()) return new TransferReportResponse();
var allItems = transferItems.Where(t => t.Status == 1 && t.AdminStatus == 1); var allItems = transferItems.Where(t => t.Status == 1 && t.AdminStatus == 1);
var finalTransfer = transfers.Where(t => allItems.Select(w => w.TransferId).Distinct().Contains(t.Id)); var finalTransfer = transfers.Where(t => allItems.Select(w => w.TransferId).Distinct().Contains(t.Id));
var transferContent = finalTransfer.Select(t => new TransferReportResponse
{ var result = new TransferReportResponse();
result.Transfers = finalTransfer.Select(t => new Transfer
{
ApplicantDepartment = t.ApplicantDepartment, ApplicantDepartment = t.ApplicantDepartment,
ApplicantUnitType = t.ApplicantUnitType, ApplicantUnitType = t.ApplicantUnitType,
AmountSum =transferItems.Where(w => w.TransferId == t.Id)?.Sum(w => w.CalculationAmount.Value), AmountSum = transferItems.Where(w => w.TransferId == t.Id)?.Sum(w => w.CalculationAmount.Value),
AdoptedDepartment = t.AdoptedDepartment, AdoptedDepartment = t.AdoptedDepartment,
AdoptedUnitType = t.AdoptedUnitType, AdoptedUnitType = t.AdoptedUnitType,
PassAmountSum = allItems.Where(w => w.TransferId == t.Id)?.Sum(w => w.CalculationAmount.Value), PassAmountSum = allItems.Where(w => w.TransferId == t.Id)?.Sum(w => w.CalculationAmount.Value),
Items = allItems.Where(c => c.TransferId == t.Id).Select(c => new TransferItem
{
ApplicantDepartment = t.ApplicantDepartment,
ApplicantUnitType = t.ApplicantUnitType,
AdoptedDepartment = t.AdoptedDepartment,
AdoptedUnitType = t.AdoptedUnitType,
IsUseRatio = c.IsUseRatio,
Source = c.Source,
Category = c.Category,
Ratio = c.Ratio,
CalculationAmount = c.CalculationAmount
}).OrderBy(c => c.TransferId).ToList()
}).ToList(); }).ToList();
switch (auditType) result.Items = allItems.Select(c => new TransferItem
{ {
case 1: ApplicantDepartment = transfers.FirstOrDefault(t => t.Id == c.TransferId)?.ApplicantDepartment,
transferContent = transferContent.Where(t => t.AdoptedDepartment == detail.Department && t.AdoptedUnitType == detail?.UnitType).ToList(); ApplicantUnitType = transfers.FirstOrDefault(t => t.Id == c.TransferId)?.ApplicantUnitType,
break; AdoptedDepartment = transfers.FirstOrDefault(t => t.Id == c.TransferId)?.AdoptedDepartment,
case 2: AdoptedUnitType = transfers.FirstOrDefault(t => t.Id == c.TransferId)?.AdoptedUnitType,
transferContent = transferContent.Where(t => t.ApplicantDepartment == detail.Department && t.ApplicantUnitType == detail?.UnitType).ToList(); IsUseRatio = c.IsUseRatio,
break; Source = c.Source,
default: Category = c.Category,
break; Ratio = c.Ratio,
} CalculationAmount = c.CalculationAmount
}).OrderBy(c => c.TransferId).ToList();
return transferContent;
return result;
} }
#endregion #endregion
} }
......
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