Commit a2471c96 by lcx

申请页面下拉选项

parent b186c91a
...@@ -50,7 +50,7 @@ public ApiResponse SubmitApplications([FromBody] CostTransferRequest request) ...@@ -50,7 +50,7 @@ public ApiResponse SubmitApplications([FromBody] CostTransferRequest request)
/// <returns></returns> /// <returns></returns>
[Route("common/{hospitalId}/allot/{allotId}")] [Route("common/{hospitalId}/allot/{allotId}")]
[HttpPost] [HttpPost]
public ApiResponse Common(int hospitalId, int allotId) public ApiResponse Common(int hospitalId, int allotId, [FromBody] DepartmentDetail detail)
{ {
if (hospitalId <= 0) if (hospitalId <= 0)
return new ApiResponse(ResponseType.ParameterError, "参数HospitalId无效!"); return new ApiResponse(ResponseType.ParameterError, "参数HospitalId无效!");
...@@ -61,7 +61,7 @@ public ApiResponse Common(int hospitalId, int allotId) ...@@ -61,7 +61,7 @@ public ApiResponse Common(int hospitalId, int allotId)
var user = userService.GetUser(userid); var user = userService.GetUser(userid);
var role = roleService.GetARole(user.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 ?? ""; result.deparment = user.Department ?? "";
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
...@@ -75,7 +75,7 @@ public ApiResponse Common(int hospitalId, int allotId) ...@@ -75,7 +75,7 @@ public ApiResponse Common(int hospitalId, int allotId)
/// <returns></returns> /// <returns></returns>
[Route("auditlist/{allotId}/menuType/{menuType}")] [Route("auditlist/{allotId}/menuType/{menuType}")]
[HttpPost] [HttpPost]
public ApiResponse AuditList(int allotId,int menuType) public ApiResponse AuditList(int allotId, int menuType)
{ {
if (allotId <= 0) if (allotId <= 0)
return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!"); return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
...@@ -83,7 +83,7 @@ public ApiResponse AuditList(int allotId,int menuType) ...@@ -83,7 +83,7 @@ public ApiResponse AuditList(int allotId,int menuType)
var userid = claim.GetUserId(); var userid = claim.GetUserId();
var user = userService.GetUser(userid); var user = userService.GetUser(userid);
var role = roleService.GetARole(user.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); return new ApiResponse(ResponseType.OK, result);
......
...@@ -703,7 +703,7 @@ ...@@ -703,7 +703,7 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </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>
</summary> </summary>
......
...@@ -154,60 +154,78 @@ public cof_accounting GetAccounting(int allotId, int roleType, string Department ...@@ -154,60 +154,78 @@ public cof_accounting GetAccounting(int allotId, int roleType, string Department
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="hospitalId"></param> /// <param name="hospitalId"></param>
/// <param name="roleType"></param>
/// <param name="deparment"></param>
/// <param name="detail"></param>
/// <returns></returns> /// <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(); var common = new CommonResponse();
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 sheets = persheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Income); var prevAllotList = PrevAllotList(hospitalId, allotId);
common.unitType = GetAccounting(allotId, roleType, deparment)?.UnitType; if (prevAllotList != null && prevAllotList.Any())
if (common.unitType == null)
{ {
var prevAllot = PrevAllot(hospitalId, allotId); foreach (var prevAllot in prevAllotList)
if (prevAllot == null) return common;
common.unitType = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
to:
if (common.unitType == null)
{ {
var prevAllotId = prevAllot.ID--; string unittype = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType;
if (prevAllotId <= 0) return common; if (!string.IsNullOrEmpty(unittype))
common.unitType = GetAccounting(prevAllot.ID, roleType, deparment)?.UnitType; {
goto to; common.unitType = unittype;
break;
}
} }
} }
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 unitValue = EnumHelper.GetItems<UnitType>().Find(t => t.Name == common.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 var sheets = persheetRepository.GetEntities(t => t.AllotID == allotId && t.SheetType == (int)SheetType.Income);
switch (sheets)
{ {
Source = Regex.Replace(sheets.Find(w => w.ID == t.Key.SheetID).SheetName, @"\d.", ""), case var data when data == null || !data.Any():
Category = t.Key.TypeName, default:
Ratio = t.Key.FactorValue.Value var sources = new List<Common>()
}).ToList(); {
new Common{ Source = "门诊开单收入"},
common.Data = commons; new Common{ Source = "门诊执行收入"},
new Common{ Source = "住院开单收入"},
new Common{ Source = "住院执行收入"},
};
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));
if (imData == null || !imData.Any()) return 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 #region
/* /*
var drugType = cofdrugtypeRepository.GetEntities(t => t.HospitalId == hospitalId && t.AllotID == allotId) 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 ...@@ -228,7 +246,6 @@ public CommonResponse Common(int allotId, int hospitalId, int roleType, string d
*/ */
#endregion #endregion
return common; return common;
} }
...@@ -547,6 +564,17 @@ private per_allot PrevAllot(int hospitalId, int allotId) ...@@ -547,6 +564,17 @@ private per_allot PrevAllot(int hospitalId, int allotId)
return prevAllot; 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>
/// 修改申请记录的状态 /// 修改申请记录的状态
/// </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