Commit a2471c96 by lcx

申请页面下拉选项

parent b186c91a
......@@ -50,7 +50,7 @@ public ApiResponse SubmitApplications([FromBody] CostTransferRequest request)
/// <returns></returns>
[Route("common/{hospitalId}/allot/{allotId}")]
[HttpPost]
public ApiResponse Common(int hospitalId, int allotId)
public ApiResponse Common(int hospitalId, int allotId, [FromBody] DepartmentDetail detail)
{
if (hospitalId <= 0)
return new ApiResponse(ResponseType.ParameterError, "参数HospitalId无效!");
......@@ -61,7 +61,7 @@ public ApiResponse Common(int hospitalId, int allotId)
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, role.Type.Value, user.Department, detail);
result.deparment = user.Department ?? "";
return new ApiResponse(ResponseType.OK, result);
......@@ -75,7 +75,7 @@ public ApiResponse Common(int hospitalId, int allotId)
/// <returns></returns>
[Route("auditlist/{allotId}/menuType/{menuType}")]
[HttpPost]
public ApiResponse AuditList(int allotId,int menuType)
public ApiResponse AuditList(int allotId, int menuType)
{
if (allotId <= 0)
return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
......@@ -83,7 +83,7 @@ public ApiResponse AuditList(int allotId,int menuType)
var userid = claim.GetUserId();
var user = userService.GetUser(userid);
var role = roleService.GetARole(user.UserID);
var result = costTransferService.GetAuditList(allotId,menuType, role.Type.Value, user.Department);
var result = costTransferService.GetAuditList(allotId, menuType, role.Type.Value, user.Department);
return new ApiResponse(ResponseType.OK, result);
......
......@@ -703,7 +703,7 @@
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.CostTransferController.Common(System.Int32,System.Int32)">
<member name="M:Performance.Api.Controllers.CostTransferController.Common(System.Int32,System.Int32,Performance.DtoModels.DepartmentDetail)">
<summary>
</summary>
......
......@@ -154,60 +154,78 @@ public cof_accounting GetAccounting(int allotId, int roleType, string Department
/// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="roleType"></param>
/// <param name="deparment"></param>
/// <param name="detail"></param>
/// <returns></returns>
public CommonResponse Common(int allotId, int hospitalId, int roleType, string deparment)
public CommonResponse Common(int allotId, int hospitalId, int roleType, string deparment, DepartmentDetail detail)
{
var common = new CommonResponse();
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);
common.unitType = GetAccounting(allotId, roleType, deparment)?.UnitType;
if (common.unitType == null)
var prevAllotList = PrevAllotList(hospitalId, allotId);
if (prevAllotList != null && prevAllotList.Any())
{
var prevAllot = PrevAllot(hospitalId, allotId);
if (prevAllot == null) return common;
common.unitType = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
to:
if (common.unitType == null)
foreach (var prevAllot in prevAllotList)
{
string unittype = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
if (!string.IsNullOrEmpty(unittype))
{
var prevAllotId = prevAllot.ID--;
if (prevAllotId <= 0) return common;
common.unitType = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
goto to;
common.unitType = unittype;
break;
}
}
}
if (sheets == null || !sheets.Any())
var sheets = persheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Income);
switch (sheets)
{
var data = new List<Common>()
case var data when data == null || !data.Any():
default:
var sources = new List<Common>()
{
new Common{ Source = "门诊开单收入"},
new Common{ Source = "门诊执行收入"},
new Common{ Source = "住院开单收入"},
new Common{ Source = "住院执行收入"},
};
common.Data = data;
return common;
}
var unitValue = EnumHelper.GetItems<UnitType>().Find(t => t.Name == common.unitType)?.Value;
common.Data = sources;
break;
case var data when data != null && data.Any():
var sheetId = sheets.Select(t => t.ID);
var imData = imdataRepository.GetEntities(t => t.AllotID == allotId && sheetId.Contains(t.SheetID.Value) && t.UnitType == unitValue);
var imData = imdataRepository.GetEntities(t => t.AllotID == allotId && sheetId.Contains(t.SheetID.Value));
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
var commons = new List<Common>();
var unitValue = EnumHelper.GetItems<UnitType>().Find(t => t.Name == detail.UnitType)?.Value;
if (imData != null && imData.Any(t => t.AccountingUnit == detail.Department && t.UnitType == unitValue))
{
var datas = from im in imData.Where(t => t.AccountingUnit == detail.Department && t.UnitType == unitValue)
group im by new { im.SheetID, im.TypeName, im.FactorValue } into i
select new { i.Key, i };
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();
}
else
{
var datas = from im in imData group im by new { im.SheetID, im.TypeName } into i select new { i.Key, i };
commons = datas.Select(t => new Common
{
Source = Regex.Replace(sheets.Find(w => w.ID == t.Key.SheetID).SheetName, @"\d.", ""),
Category = t.Key.TypeName,
Ratio = 1
}).ToList();
}
common.Data = commons;
break;
}
#region
/*
var drugType = cofdrugtypeRepository.GetEntities(t => t.HospitalId == hospitalId && t.AllotID == allotId)
......@@ -228,7 +246,6 @@ public CommonResponse Common(int allotId, int hospitalId, int roleType, string d
*/
#endregion
return common;
}
......@@ -547,6 +564,17 @@ private per_allot PrevAllot(int hospitalId, int allotId)
return prevAllot;
}
private List<per_allot> PrevAllotList(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("未查询到符合的绩效记录");
return allotList.Where(t => t.Year <= allot.Year && t.Month <= allot.Month)?.ToList();
}
/// <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