Commit 10253693 by 钟博

划拨汇总、明细拆分

parent f2dade06
......@@ -68,6 +68,29 @@ public ApiResponse Common(int hospitalId, int allotId, [FromBody] DepartmentDeta
}
/// <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>
/// <param name="itemId"></param>
......
......@@ -7,8 +7,13 @@ namespace Performance.DtoModels
{
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 ApplicantDepartment { get; set; }
......@@ -20,8 +25,6 @@ public class TransferReportResponse
public string AdoptedDepartment { get; set; }
public decimal? PassAmountSum { get; set; }
public List<TransferItem> Items { get; set; }
}
public class TransferItem : cost_transfer_item
......
......@@ -170,19 +170,9 @@ public CommonResponse Common(int allotId, int hospitalId, int roleType, string d
common.account = cofaccountingRepository.GetEntities(t => t.AllotId == allotId)
?.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).ToDistinct().ToList();
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))
{
common.unitType = unittype;
break;
}
}
}
var (prevAllotList, deptDetail) = DeptDetial(allotId, hospitalId, roleType, deparment);
common.unitType = deptDetail.UnitType ?? "";
var sheets = persheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Income);
if (sheets != null && sheets.Any())
......@@ -233,6 +223,25 @@ public CommonResponse Common(int allotId, int hospitalId, int roleType, string d
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>
......@@ -427,7 +436,7 @@ public void DeleteApplicat(int transferId)
public bool CostTransferAudit(AuditRequest request, bool isAdmin)
{
if (request.TransferItemId.Length <= 0)
throw new PerformanceException("没有可以审核的记录");
throw new PerformanceException("科室未审核或已驳回,不能一键通过");
var costItems = costtransferitemRepository.GetEntities(t => request.TransferItemId.Contains(t.Id));
var transferId = costItems?.Select(t => t.TransferId).Distinct();
......@@ -648,56 +657,61 @@ public void UpdateCostTransferStatus(int transferId)
#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);
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 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,
ApplicantUnitType = t.ApplicantUnitType,
AmountSum =transferItems.Where(w => w.TransferId == t.Id)?.Sum(w => w.CalculationAmount.Value),
AdoptedDepartment = t.AdoptedDepartment,
AmountSum = transferItems.Where(w => w.TransferId == t.Id)?.Sum(w => w.CalculationAmount.Value),
AdoptedDepartment = t.AdoptedDepartment,
AdoptedUnitType = t.AdoptedUnitType,
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();
switch (auditType)
result.Items = allItems.Select(c => new TransferItem
{
case 1:
transferContent = transferContent.Where(t => t.AdoptedDepartment == detail.Department && t.AdoptedUnitType == detail?.UnitType).ToList();
break;
case 2:
transferContent = transferContent.Where(t => t.ApplicantDepartment == detail.Department && t.ApplicantUnitType == detail?.UnitType).ToList();
break;
default:
break;
}
ApplicantDepartment = transfers.FirstOrDefault(t => t.Id == c.TransferId)?.ApplicantDepartment,
ApplicantUnitType = transfers.FirstOrDefault(t => t.Id == c.TransferId)?.ApplicantUnitType,
AdoptedDepartment = transfers.FirstOrDefault(t => t.Id == c.TransferId)?.AdoptedDepartment,
AdoptedUnitType = transfers.FirstOrDefault(t => t.Id == c.TransferId)?.AdoptedUnitType,
IsUseRatio = c.IsUseRatio,
Source = c.Source,
Category = c.Category,
Ratio = c.Ratio,
CalculationAmount = c.CalculationAmount
}).OrderBy(c => c.TransferId).ToList();
return transferContent;
return result;
}
#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