Commit 82f3d0a1 by 李承祥

科室查询修改

parent b5829785
...@@ -64,9 +64,9 @@ public ApiResponse DelAssess([CustomizeValidator(RuleSet = "Del"), FromBody]Asse ...@@ -64,9 +64,9 @@ public ApiResponse DelAssess([CustomizeValidator(RuleSet = "Del"), FromBody]Asse
//获取所有科室列表 //获取所有科室列表
[HttpPost] [HttpPost]
[Route("departmentlist")] [Route("departmentlist")]
public ApiResponse DepartmentList([CustomizeValidator(RuleSet = "List"), FromBody]AssessRequest request) public ApiResponse DepartmentList([CustomizeValidator(RuleSet = "Use"), FromBody]AssessRequest request)
{ {
var department = assessService.Department(request.AllotID); var department = assessService.Department(request);
return new ApiResponse(ResponseType.OK, "ok", department); return new ApiResponse(ResponseType.OK, "ok", department);
} }
......
...@@ -17,6 +17,10 @@ public class TitleValue<T> ...@@ -17,6 +17,10 @@ public class TitleValue<T>
/// Value /// Value
/// </summary> /// </summary>
public T Value { get; set; } public T Value { get; set; }
/// <summary>
/// 1、已选,2、未选,3、已被选择
/// </summary>
public int State { get; set; }
} }
/// <summary> /// <summary>
/// title value /// title value
......
...@@ -313,22 +313,39 @@ public ApiResponse UseTemplate(int allotID, int assessID) ...@@ -313,22 +313,39 @@ public ApiResponse UseTemplate(int allotID, int assessID)
/// 科室列表 /// 科室列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<TitleValue> Department(int allotId) public List<TitleValue> Department(AssessRequest request)
{ {
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perforPerallotRepository.GetEntity(t => t.ID == request.AllotID);
if (allot != null) if (allot != null)
{ {
var _checked = perforAsdataRepository.GetEntities(t => t.AllotID == allotId)?.Select(t => t.Department).Distinct(); var result = new List<TitleValue>();
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == allot.HospitalId); //取到该家医院下所有科室
var idList = allotList.Select(s => s.ID).ToList(); var idList = perforPerallotRepository.GetEntities(t => t.HospitalId == allot.HospitalId).Select(s => s.ID).ToList();
var department = perforImemployeeRepository.GetEntities(t => t.Department != "" && idList.Contains(t.AllotID.Value)); var department = perforImemployeeRepository.GetEntities(t => t.Department != "" && idList.Contains(t.AllotID.Value))?.Select(t => t.Department).ToList();
if (department != null && department.Count > 0) if (department != null && department.Count > 0)
{ {
var departmentList = department.Select(t => t.Department).Distinct();
if (_checked != null) //自己选的
departmentList = departmentList.Except(_checked).ToList(); var _checked = perforAsdataRepository.GetEntities(t => t.AssessID == request.AssessID)?.Select(t => t.Department).ToList();
return departmentList.Select(t => new TitleValue { Title = t, Value = t }).OrderBy(t => t.Title).ToList(); if (_checked != null && _checked.Count > 0)
result = _checked.Select(t => new TitleValue { Title = t, Value = t, State = 1 }).ToList();
//已经被选择
var assessId = perforAsassessRepository.GetEntities(t => t.AllotID == request.AllotID)?.Select(t => t.ID).ToList();
if (assessId.Count > 0 && assessId != null)
{
assessId.Remove(request.AssessID);
_checked = perforAsdataRepository.GetEntities(t => assessId.Contains(t.AssessID.Value))?.Select(t => t.Department).ToList();
if (_checked != null && _checked.Count > 0)
{
result = result.Union(_checked.Select(t => new TitleValue { Title = t, Value = t, State = 3 })).ToList();
}
}
//未被选择
if (result != null || result.Count > 0)
department = department.Except(result.Select(t => t.Title)).ToList();
result = result.Union(department.Select(t => new TitleValue { Title = t, Value = t, State = 2 })).OrderBy(t => t.State).ThenBy(t => t.Title).ToList();
} }
return result;
} }
return new List<TitleValue>(); return new List<TitleValue>();
} }
......
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