Commit 8f93653f by wyc

人员表添加小组字段,科室工作量详情方法重写

parent 1cb1c2b6
......@@ -241,7 +241,21 @@ public ApiResponse DeptDics(int allotId, int type)
var result = personService.DeptDics(allotId, type);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 科室工作量详情(有小计)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("dept/workdetail/Get")]
public ApiResponse GetDeptWorkloadDetail([CustomizeValidator(RuleSet = "Select"), FromBody] WorkDetailRequest request)
{
var data = personService.GetDeptWorkloadDetail(request, claimService.GetUserId());
return new ApiResponse(ResponseType.OK, data);
}
#region 接口即将弃用
/// <summary>
/// 科室工作量详情
/// </summary>
......@@ -253,6 +267,7 @@ public ApiResponse DeptWorkloadDetail([CustomizeValidator(RuleSet = "Select"), F
var data = personService.DeptWorkloadDetail(request, claimService.GetUserId());
return new ApiResponse(ResponseType.OK, data);
}
#endregion
/// <summary>
/// 门诊开单收入详情
......
......@@ -3907,6 +3907,21 @@
是否附带上次绩效 0 不附带 1 附带
</summary>
</member>
<member name="T:Performance.DtoModels.Response.DeptWorkloadDetail">
<summary>
科室工作量
</summary>
</member>
<member name="P:Performance.DtoModels.Response.DeptWorkloadDetail.SquadName">
<summary>
小组名称
</summary>
</member>
<member name="P:Performance.DtoModels.Response.WorkloadDetail.Category">
<summary>
类别名称
</summary>
</member>
<member name="P:Performance.DtoModels.AttendanceDeptReport.Code">
<summary>
核算单元编码
......
......@@ -7636,6 +7636,11 @@
科室
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.SquadName">
<summary>
小组名称
</summary>
</member>
<member name="P:Performance.EntityModels.per_employee.DoctorName">
<summary>
姓名
......
......@@ -19,8 +19,7 @@ public WorkDetailRequestValidator()
{
RuleSet("Select", () =>
{
RuleFor(x => x.AllotId).NotNull().NotEmpty().GreaterThan(0);
//RuleFor(x => x.SecondId).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.AllotId).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.AccountingUnit).NotNull().NotEmpty();
});
}
......
using System.Collections.Generic;
namespace Performance.DtoModels.Response
{
public class DeptWorkloadDetailResponse
{
public List<WorkloadDetail> WorkloadTotal { get; set; }
public List<DeptWorkloadDetail> WorkloadRows { get; set; }
}
/// <summary>
/// 科室工作量
/// </summary>
public class DeptWorkloadDetail
{
public string Department { get; set; }
public string DoctorName { get; set; }
public string PersonnelNumber { get; set; }
public List<WorkloadDetail> WorkloadDetails { get; set; }
/// <summary>
/// 小组名称
/// </summary>
public string SquadName { get; set; }
}
public class WorkloadDetail
{
/// <summary>
/// 类别名称
/// </summary>
public string Category { get; set; }
public decimal Fee { get; set; }
public string Value { get; set; }
}
}
namespace Performance.DtoModels.Response
{
public class viewSecondReportWorkloadResponse
{
public string Department { get; set; }
public string DoctorName { get; set; }
public string PersonnelNumber { get; set; }
public string Category { get; set; }
public decimal? Fee { get; set; }
public string SquadName { get; set; }
}
}
......@@ -40,6 +40,10 @@ public class per_employee
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 小组名称
/// </summary>
public string SquadName { get; set; }
/// <summary>
/// 姓名
......
......@@ -7,6 +7,7 @@
using Dapper;
using Microsoft.EntityFrameworkCore;
using Performance.DtoModels;
using Performance.DtoModels.Response;
using Performance.EntityModels;
using Performance.EntityModels.Other;
using System;
......@@ -203,6 +204,31 @@ public void ImportWorkloadData(per_allot allot, object parameters)
}
/// <summary>
/// 查询工作量数据(新)
/// </summary>
/// <param name="allotid"></param>
public IEnumerable<viewSecondReportWorkloadResponse> QueryWorkloadDatas(int allotid, string accountingunit, string[] unittypes, int hospitalid)
{
using (var connection = context.Database.GetDbConnection())
{
if (connection.State != ConnectionState.Open) connection.Open();
try
{
string clear = @"
SELECT DISTINCT AccountingUnit as Department,SquadName,if(ifnull(DoctorName,'')='', '未知',DoctorName) DoctorName,PersonnelNumber,Category,ROUND(SUM(Fee),2) Fee
FROM view_second_report_workload
WHERE AllotId = @allotid AND UnitType in @unittypes AND AccountingUnit = @accountingunit
GROUP BY AccountingUnit,DoctorName,PersonnelNumber,Category,SquadName
ORDER BY doctorname,Category;";
return connection.Query<viewSecondReportWorkloadResponse>(clear, new { allotid, accountingunit, unittypes = unittypes.Union(new string[] { "通用工作量" }), hospitalid }, commandTimeout: 60 * 60);
}
catch (Exception)
{
throw;
}
}
}
/// <summary>
/// 查询工作量数据
/// </summary>
/// <param name="allotid"></param>
......@@ -228,6 +254,9 @@ FROM view_second_report_workload
}
}
/// <summary>
/// 查询门诊收入数据
/// </summary>
......
......@@ -90,14 +90,14 @@ public static List<cof_alias> AllComputeViewByDate
new cof_alias{ Alias = "预留绩效", Name = nameof(view_allot_sign_emp.ReservedRatioFee), States = 1, SumStatus = 1, Sort = 12 },
new cof_alias{ Alias = "实发绩效", Name = nameof(view_allot_sign_emp.RealGiveFee), States = 1, SumStatus = 1, Sort = 13 },
new cof_alias{ States = 0, SumStatus = 0, Sort = 15, Alias = "正式/临聘", Name = nameof(per_employee.JobCategory), },
new cof_alias{ States = 0, SumStatus = 0, Sort = 16, Alias = "职务", Name = nameof(per_employee.Duty), },
new cof_alias{ States = 0, SumStatus = 0, Sort = 17, Alias = "职称", Name = nameof(per_employee.JobTitle), },
new cof_alias{ States = 0, SumStatus = 0, Sort = 18, Alias = "出勤天数", Name = nameof(per_employee.AttendanceDay), },
new cof_alias{ States = 0, SumStatus = 0, Sort = 17, Alias = "预留比例", Name = nameof(per_employee.ReservedRatio), },
new cof_alias{ States = 0, SumStatus = 0, Sort = 20, Alias = "银行卡号", Name = nameof(per_employee.BankCard), },
new cof_alias{ States = 0, SumStatus = 0, Sort = 21, Alias = "备用01", Name = nameof(per_employee.Reserve01), },
new cof_alias{ States = 0, SumStatus = 0, Sort = 21, Alias = "备用02", Name = nameof(per_employee.Reserve02), },
new cof_alias{ States = 0, SumStatus = 0, Sort = 21, Alias = "备用03", Name = nameof(per_employee.Reserve03), },
......@@ -173,6 +173,7 @@ public static List<cof_alias> GetAllPersonnelTags(bool ownerQuery)
new cof_alias{ Alias = "员工工号", Name = nameof(per_employee.PersonnelNumber), States = 1, SumStatus = 0, Sort = 0 },
new cof_alias{ Alias = "姓名", Name = nameof(per_employee.DoctorName), States = 1, SumStatus = 0, Sort = 0 },
new cof_alias{ Alias = "核算单元", Name = nameof(per_employee.AccountingUnit), States = 1, SumStatus = 0, Sort = 0 },
new cof_alias{ Alias = "小组名称", Name = nameof(per_employee.SquadName), States = 1, SumStatus = 0, Sort = 5 },
new cof_alias{ Alias = "核算组别", Name = nameof(per_employee.UnitType), States = 0, SumStatus = 0, Sort = 6 },
new cof_alias{ Alias = "HIS工号", Name = nameof(per_employee.JobNumber), States = 1, SumStatus = 0, Sort = 7 },
......
......@@ -7,6 +7,7 @@
using NPOI.XSSF.UserModel;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.DtoModels.Response;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Infrastructure.Models;
......@@ -756,11 +757,119 @@ public List<TitleValue> DeptDics(int allotId, int type)
return result.Select(t => new TitleValue { Title = t, Value = t }).ToList();
}
#region 科室 工作量
/// <summary>
/// 科室工作量数据详情
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DeptWorkloadDetailResponse GetDeptWorkloadDetail(WorkDetailRequest request, int userId)
{
var userInfo = perforUserRepository.GetUser(userId);
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
if (!userInfo.Hospitals.NotNullOrEmpty()) throw new NotImplementedException("当前用户暂未分配医院");
// 查询当前角色下科室的绩效
UnitTypeUtil.Maps.TryGetValue(userInfo?.URole.Type ?? 0, out string[] unitTypes);
if (unitTypes == null || !unitTypes.Any()) return new DeptWorkloadDetailResponse() { };
var accountingUnit = request.AccountingUnit;
var hospitalId = userInfo.HospitalIds.First();
if (userInfo.IsSecondAdmin)
{
var second = agsecondallotRepository.Get(request.AllotId, unitTypes, userInfo.User.Department)?.FirstOrDefault();
if (second != null)
{
accountingUnit = second.Department ?? request.AccountingUnit;
unitTypes = new string[] { second.UnitType };
}
}
var viewData = perallotRepository.QueryWorkloadDatas(request.AllotId, accountingUnit, unitTypes, hospitalId);
if (viewData == null || !viewData.Any()) return new DeptWorkloadDetailResponse() { };
var groupedData = viewData.GroupBy(item => new { item.Department, item.DoctorName, item.PersonnelNumber, item.SquadName });
List<DeptWorkloadDetail> resultList = groupedData
.Select(group => new DeptWorkloadDetail
{
Department = group.Key.Department,
DoctorName = group.Key.DoctorName,
PersonnelNumber = group.Key.PersonnelNumber,
SquadName = group.Key.SquadName,
WorkloadDetails = group.Select(item => new WorkloadDetail
{
Category = item.Category,
Fee = item.Fee ?? 0,
Value = (item.Fee ?? 0).ToString(),
}).ToList()
}).ToList();
//合计
var TotalWorkloadTotal = resultList.SelectMany(w => w.WorkloadDetails)
.GroupBy(w => new { w.Category })
.Select(item => new WorkloadDetail
{
Category = item.Key.Category,
Fee = item.Sum(p => p.Fee),
Value = item.Sum(p => p.Fee) == 0 ? "" : item.Sum(p => p.Fee).ToString(),
}).ToList();
//补全分类
var categorys = viewData.Select(w => w.Category).Distinct().ToList();
foreach (var item in resultList)
{
var itemCategorys = item.WorkloadDetails.Select(w => w.Category).ToHashSet();
var exceptCategorys = categorys.Except(itemCategorys);
item.WorkloadDetails.AddRange(exceptCategorys.Select(exceptCategory => new WorkloadDetail { Category = exceptCategory }));
}
//小计
var subtotals = resultList
.Where(w => !string.IsNullOrEmpty(w.SquadName))
.GroupBy(w => new { w.SquadName })
.Select(group => new DeptWorkloadDetail
{
SquadName = group.Key.SquadName,
WorkloadDetails = group
.SelectMany(w => w.WorkloadDetails)
.GroupBy(w => new { w.Category })
.Select(item => new WorkloadDetail
{
Category = item.Key.Category,
Fee = item.Sum(p => p.Fee),
Value = item.Sum(p => p.Fee) == 0 ? "" : item.Sum(p => p.Fee).ToString(),
}).ToList()
}).ToArray();
resultList.AddRange(subtotals);
//判断小组,有就添加
if (resultList.Any(w => !string.IsNullOrEmpty(w.SquadName)))
{
if (resultList.Any(w => !string.IsNullOrEmpty(w.SquadName)))
{
foreach (var item in resultList)
{
var category = "分类";
var value = item.SquadName;
if (item.PersonnelNumber == null)
{
value += "小计";
}
item.WorkloadDetails.Insert(0, new WorkloadDetail { Category = category, Value = value });
}
}
}
resultList = resultList.OrderByDescending(w => w.SquadName).ToList();
DeptWorkloadDetailResponse deptWorkloadDetailResponses = new DeptWorkloadDetailResponse()
{
WorkloadTotal = TotalWorkloadTotal,
WorkloadRows = resultList
};
return deptWorkloadDetailResponses;
}
public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
{
var userInfo = perforUserRepository.GetUser(userId);
......@@ -787,22 +896,23 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
var data = perallotRepository.QueryWorkloadData(request.AllotId, accountingUnit, unitTypes, hospitalId);
if (data != null && data.Any())
{
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
.Select(t => new DeptIncomeResponse
{
Department = t.Key.Department,
DoctorName = t.Key.DoctorName,
PersonnelNumber = t.Key.PersonnelNumber,
Category = t.Key.Category,
Fee = t.Sum(group => group.Fee ?? 0)
}).OrderBy(t => t.PersonnelNumber).ThenBy(t => t.Category);
data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
.Select(t => new DeptIncomeResponse
{
Department = t.Key.Department,
DoctorName = t.Key.DoctorName,
PersonnelNumber = t.Key.PersonnelNumber,
Category = t.Key.Category,
Fee = t.Sum(group => group.Fee ?? 0)
}).OrderBy(t => t.PersonnelNumber).ThenBy(t => t.Category);
}
return new string[] { };
}
#endregion
/// <summary>
/// 科室工作量数据详情
/// 科室(门诊/住院)工作量数据详情
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
......
......@@ -565,6 +565,7 @@ select new
{
PersonnelNumber = t1.PersonnelNumber,
DoctorName = t1.DoctorName,
SquadName = t1.SquadName,
AccountingUnit = t1.AccountingUnit,
UnitType = t1.UnitType,
JobCategory = t1.JobCategory,
......@@ -798,6 +799,7 @@ public ApiResponse SaveReportPersonTag(int hospitalId, int allotId, int userId,
employee.Reserve08 = pdata.Reserve08;
employee.Reserve09 = pdata.Reserve09;
employee.Reserve10 = pdata.Reserve10;
employee.SquadName = pdata.SquadName;
upEmployees.Add(employee);
#endregion
......@@ -929,7 +931,7 @@ public void SaveReportTag(int hospitalId, SaveCollectData request)
{
var header = request.ColHeaders[c];
var first = alias.FirstOrDefault(w => w.Alias.ToLower() == header.ToLower());
if (first!=null && !default(KeyValuePair<string, string>).Equals(first)
if (first != null && !default(KeyValuePair<string, string>).Equals(first)
&& !result.ContainsKey(header)
&& request.Data[rownumber].Length > c)
{
......
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