Commit 7baa4bde by ruyun.zhang@suvalue.com

Merge remote-tracking branch 'origin/develop' into develop

parents 9996b87d 64d01c52
......@@ -423,12 +423,19 @@ public ApiResponse Issued([FromBody] AllotRequest request)
var allot = _allotService.GetAllot(request.ID);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
// 科室下发
_resultComputeService.GenerateSecondAllot(allot);
//绩效划拨,下发驳回
costTransferService.RejectedApplicat(allot.ID);
return new ApiResponse(ResponseType.OK);
bool isIssued = false;
var result = _resultComputeService.IssuedPrompt(allot, request, ref isIssued);
//绩效状态修改;绩效划拨,下发驳回
if (request.isIssued == 1 && isIssued)
{
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
costTransferService.RejectedApplicat(allot.ID);
}
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
......
......@@ -841,6 +841,7 @@ public ApiResponse CopyDropDown()
{
var result = new List<CopyDrop>
{
new CopyDrop{Label="人员字典",Value="personnels"},
new CopyDrop{Label="工作量配置",Value="workItems"},
new CopyDrop{Label="收入费用类别",Value="drugTypes"},
new CopyDrop{Label="支出费用类别",Value="drugTypeDisburses"},
......@@ -851,5 +852,57 @@ public ApiResponse CopyDropDown()
}; ;
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 自定义表Heads表头
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("customheads")]
public ApiResponse CustomHeads([FromBody] CustomPagingRequest request)
{
if (string.IsNullOrEmpty(request.TableName))
return new ApiResponse(ResponseType.ParameterError, "表名为空");
var result = _configService.QueryHandsCustom(request);
if (result == null)
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
else
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 自定义表显示
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("getcustomlist")]
public ApiResponse GetCustomList([FromBody] CustomPagingRequest request)
{
var allot = _allotService.GetAllot(request.AllotId);
if (allot == null)
return new ApiResponse(ResponseType.ParameterError, "AllotID错误");
return _configService.QueryCustom(request);
}
/// <summary>
/// 保存自定义表数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("savecustom")]
[HttpPost]
public ApiResponse BatchSaveCustom([FromBody] SaveCustomData request)
{
var allot = _allotService.GetAllot(request.AllotId);
if (allot == null)
return new ApiResponse(ResponseType.ParameterError, "AllotID错误");
else if (string.IsNullOrEmpty(request.TableName))
return new ApiResponse(ResponseType.ParameterError, "表名为空");
return _configService.SaveCustomTable(request);
}
}
}
\ No newline at end of file
......@@ -719,5 +719,25 @@ public ApiResponse AprHideOverview(int allotId)
return new ApiResponse(ResponseType.OK, relust);
}
#endregion
/// <summary>
/// 实发绩效比对
/// </summary>
/// <param name="allotId"></param>
/// <param name="request"></param>
/// <returns></returns>
[Route("getComparison")]
[HttpPost]
public ApiResponse GetDeptComparison([FromBody] ComparisonPagingRequest request)
{
var allot = allotService.GetAllot(request.AllotId);
if (allot == null)
return new ApiResponse(ResponseType.ParameterError, "allotId无效");
var relust = employeeService.GetComparison(request);
return new ApiResponse(ResponseType.OK, relust);
}
}
}
......@@ -857,6 +857,27 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.CustomHeads(Performance.DtoModels.CustomPagingRequest)">
<summary>
自定义表Heads表头
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetCustomList(Performance.DtoModels.CustomPagingRequest)">
<summary>
自定义表显示
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.BatchSaveCustom(Performance.DtoModels.SaveCustomData)">
<summary>
保存自定义表数据
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.CostTransferController.SubmitApplications(Performance.DtoModels.CostTransferRequest)">
<summary>
申请划拨
......@@ -1165,6 +1186,14 @@
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.GetDeptComparison(Performance.DtoModels.ComparisonPagingRequest)">
<summary>
实发绩效比对
</summary>
<param name="allotId"></param>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ExConfigController.Extract(Performance.DtoModels.ModModuleRequest)">
<summary>
绩效数据抽取模板
......
......@@ -3492,6 +3492,11 @@
有效收入占比
</summary>
</member>
<member name="P:Performance.DtoModels.IssuedPromptResponse.IssueStatus">
<summary>
1 删除 2 驳回 3 修改 4 新增
</summary>
</member>
<member name="P:Performance.DtoModels.MenuResponse.MenuName">
<summary>
菜单名称
......
......@@ -1170,6 +1170,11 @@
科室实发金额
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.PreRealGiveFee">
<summary>
预发金额
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.Efficiency">
<summary>
效率绩效
......
......@@ -247,6 +247,9 @@ public AutoMapperConfigs()
CreateMap<view_allot_result, OwnerPerformanceDto>()
.ReverseMap();
CreateMap<ag_secondallot, IssuedPromptResponse>()
.ReverseMap();
}
}
}
......@@ -130,5 +130,6 @@ public class PerDataClinicEmployee : IPerData
/// 行号
/// </summary>
public int RowNumber { get; set; }
public Nullable<decimal> RealGiveFee { get; set; }
}
}
......@@ -120,5 +120,6 @@ public class PerDataEmployee : IPerData
/// 行号
/// </summary>
public int RowNumber { get; set; }
public Nullable<decimal> RealGiveFee { get; set; }
}
}
......@@ -75,6 +75,8 @@ public class PerDataLogisticsEmployee : IPerData
/// 行号
/// </summary>
public int RowNumber { get; set; }
public Nullable<decimal> RealGiveFee { get; set; }
}
}
......@@ -33,6 +33,12 @@ public class AllotRequest
/// 路径
/// </summary>
public string Path { get; set; }
public int isIssued { get; set; }
public string SearchQuery { get; set; }
public int? QueryStatus { get; set; }
}
public class AllotRequestValidator : AbstractValidator<AllotRequest>
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class CustomRequest
{
public int AllotId { get; set; }
public string TableName { get; set; }
public string QuerySearch{ get; set; }
}
public class CustomPagingRequest : CustomRequest
{
public int PageIndex { get; set; } = 1;
public int PageSize { get; set; } = 20;
}
public class CustonPagingData
{
public List<dynamic> DataList { get; set; }
public int TotalCount { get; set; }
}
public class CustomResponse
{
public List<Heads> Heads { get; set; }
public CustonPagingData Datas { get; set; }
}
public class Heads
{
public string Cloumn { get; set; }
public string Name { get; set; }
}
}
using Performance.EntityModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class ComparisonResponse
{
public List<Heads> Heads { get; set; }
public Comparison Datas { get; set; }
}
public class Heads
{
public string Cloumon { get; set; }
public string Name { get; set; }
}
public class Comparison
{
public List<view_check_emp> Datas { get; set; }
public int TotalCount { get; set; }
}
public class ComparisonPagingRequest
{
public int AllotId { get; set; }
public string ViewName { get; set; }
public string SearchQuery { get; set; }
public int PageIndex { get; set; } = 1;
public int PageSize { get; set; } = 20;
}
}
using Performance.EntityModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class IssuedPromptResponse : ag_secondallot
{
public string StatusRemake { get; set; }
/// <summary>
/// 1 删除 2 驳回 3 修改 4 新增
/// </summary>
public new int IssueStatus { get; set; }
}
}
......@@ -22,5 +22,11 @@ public class UserCollectData
public new string[][] Data { get; set; }
}
public class SaveCustomData
{
public int AllotId { get; set; }
public string TableName { get; set; }
public string[] ColHeaders { get; set; }
public new string[][] Data { get; set; }
}
}
......@@ -57,6 +57,10 @@ public class ag_secondallot
public Nullable<decimal> RealGiveFee { get; set; }
/// <summary>
/// 预发金额
/// </summary>
public Nullable<decimal> PreRealGiveFee { get; set; }
/// <summary>
/// 效率绩效
/// </summary>
public Nullable<decimal> Efficiency { get; set; }
......
......@@ -230,5 +230,6 @@ public class im_accountbasic
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
public Nullable<decimal> RealGiveFee { get; set; }
}
}
......@@ -175,5 +175,6 @@ public class im_employee
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
public Nullable<decimal> RealGiveFee { get; set; }
}
}
......@@ -175,5 +175,6 @@ public class im_employee_clinic
/// 调节后其他绩效
/// </summary>
public Nullable<decimal> AdjustLaterOtherFee { get; set; }
public Nullable<decimal> RealGiveFee { get; set; }
}
}
......@@ -130,5 +130,6 @@ public class im_employee_logistics
/// 是否需要二次分配
/// </summary>
public string NeedSecondAllot { get; set; }
public Nullable<decimal> RealGiveFee { get; set; }
}
}
using Microsoft.EntityFrameworkCore;
using Performance.EntityModels;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace Performance.EntityModels
{
public class view_check_dept
{
public int HospitalId { get; set; }
public int Year { get; set; }
public int Month { get; set; }
public int AllotID { get; set; }
public string UnitType { get; set; }
public string AccountingUnit { get; set; }
public decimal? RealGiveFeeExecl { get; set; }
public decimal? RealGiveFeeCompute { get; set; }
public decimal? Diff { get; set; }
}
public class view_check_emp : view_check_dept
{
public string JobNumber { get; set; }
public string EmployeeName { get; set; }
}
}
......@@ -3,9 +3,13 @@
// * FileName: per_employee.cs
// </copyright>
//-----------------------------------------------------------------------
using Microsoft.EntityFrameworkCore;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure.Models;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
......@@ -16,11 +20,39 @@ namespace Performance.Repository
/// </summary>
public partial class PerforPeremployeeRepository : PerforRepository<per_employee>
{
public new PageList<per_employee> GetEntitiesForPaging(int pageNumber, int pageSize, Expression<Func<per_employee, bool>> exp)
{
IQueryable<per_employee> queryableAuthors = context.Set<per_employee>().Where(exp).OrderBy(w => w.IsVerify).ThenBy(t => t.Id);
return PageList<per_employee>.Create(queryableAuthors, pageNumber, pageSize);
}
public Comparison GetComparison(ComparisonPagingRequest request)
{
var search = "";
if (string.IsNullOrEmpty(request.SearchQuery))
search = " 1=1 ";
else
{
if (request.ViewName == "view_check_dept")
search = $" ( AccountingUnit like '%{request.SearchQuery}%' )";
else
search = $" ( AccountingUnit like '%{request.SearchQuery}%' or JobNumber like '%{request.SearchQuery}%' or EmployeeName like '%{request.SearchQuery}%') ";
}
var result = new Comparison();
var sql = $@"SELECT COUNT(*) FROM {request.ViewName} WHERE AllotId = @AllotId and {search}";
result.TotalCount = DapperQuery<int>(sql, new { request.AllotId })?.FirstOrDefault() ?? 0;
sql = $@"SELECT * FROM {request.ViewName} WHERE AllotId = @AllotId and {search} ORDER BY HospitalId,Year,Month,ABS(DIFF) DESC LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize}; ";
result.Datas = DapperQuery<view_check_emp>(sql, new { request.AllotId })?.ToList();
return result;
}
}
}
using Performance.DtoModels;
using Microsoft.EntityFrameworkCore;
using Performance.DtoModels;
using Performance.EntityModels;
using System.Collections.Generic;
using System.Linq;
......@@ -395,5 +396,80 @@ public List<dynamic> QueryCompute(int allotId, string viewName)
return DapperQuery<dynamic>(sql, new { allotId })?.ToList();
}
public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead)
{
var result = new CustonPagingData();
string sql, Query;
if (string.IsNullOrEmpty(request.QuerySearch))
Query = " and 1=1 ";
else
Query = $@" and (AccountingUnit like '%{request.QuerySearch}%' or UnitType like '%{request.QuerySearch}%') ";
if (IsHead)
sql = $@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId ";
else
sql = $@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId {Query} order by UnitType,AccountingUnit LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} ";
result.DataList = DapperQuery<dynamic>(sql, new { request.AllotId })?.ToList();
sql = $@"SELECT COUNT(*) FROM {request.TableName} WHERE AllotId = @AllotId {Query} ";
result.TotalCount = DapperQuery<int>(sql, new { request.AllotId })?.FirstOrDefault() ?? 0;
return result;
}
public bool QueryIsAllotId(string tableName)
{
var database = context.Database.GetDbConnection().Database;
var sql = $@"SELECT column_name FROM information_schema.COLUMNS s
WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND (column_name='allotId' or column_name='AccountingUnit' or column_name='UnitType');";
var result = DapperQuery<string>(sql, new { database = database, table_name = tableName });
var isExist=result ?.Count() == 3;
return isExist;
}
public List<dynamic> QueryCustomColumn(string tableName)
{
var database = context.Database.GetDbConnection().Database;
var sql = $@"SELECT column_name,column_comment FROM information_schema.`COLUMNS` WHERE table_schema = @table_schema AND table_name = @table_name AND COLUMN_KEY <> 'PRI' ";
var result = DapperQuery<dynamic>(sql, new { table_schema = database, table_name = tableName })?.ToList();
return result;
}
public bool CreatCustom(int AllotId, string tableName, List<dynamic> datas)
{
var sql = $@"DELETE FROM {tableName} WHERE allotId=@AllotId ";
Execute(sql, new { AllotId });
if (datas == null)
return true;
var database = context.Database.GetDbConnection().Database;
sql = $@"SELECT column_name FROM information_schema.COLUMNS s
WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND COLUMN_KEY <> 'PRI';";
var columns = DapperQuery<string>(sql, new { database = database, table_name = tableName })?.ToList();
sql = $"INSERT INTO {tableName}({string.Join(",", columns.ToArray())}) VALUES({string.Join(",", columns.Select(t => "@" + t))});";
var success = Execute(sql, datas);
if (success > 0)
return true;
else
return false;
}
public List<dynamic> QueryType(string tableName)
{
var database = context.Database.GetDbConnection().Database;
var sql = $@"select column_name,data_type from information_schema.columns where table_name=@table_name and table_schema=@table_schema AND (data_type like '%int%' or data_type like '%decimal%' or data_type like '%date%') AND COLUMN_KEY <> 'PRI' ";
var result = DapperQuery<dynamic>(sql, new { table_schema = database, table_name = tableName })?.ToList();
return result;
}
}
}
......@@ -556,7 +556,7 @@ public void GenerateSecondAllot(per_allot allot)
UnitType = ((UnitType)item.UnitType).ToString(),
Department = item.AccountingUnit,
NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
RealGiveFee = item.RealGiveFee,
PreRealGiveFee = item.RealGiveFee,
});
}
}
......@@ -575,7 +575,7 @@ public void GenerateSecondAllot(per_allot allot)
UnitType = UnitType.特殊核算组.ToString(),
Department = item.AccountingUnit,
NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
RealGiveFee = item.RealGiveFee,
PreRealGiveFee = item.RealGiveFee,
});
}
}
......@@ -595,7 +595,7 @@ public void GenerateSecondAllot(per_allot allot)
Month = allot.Month,
UnitType = item.UnitType,
Department = item.Department,
RealGiveFee = item.RealGiveFee,
PreRealGiveFee = item.PreRealGiveFee,
NightShiftWorkPerforFee = item.NightShiftWorkPerforFee,
Status = 1,
NursingDeptStatus = 1,
......@@ -603,7 +603,8 @@ public void GenerateSecondAllot(per_allot allot)
}
else
{
var backResult = Math.Abs((second.RealGiveFee ?? 0) - (item.RealGiveFee ?? 0)) >= 0.5m
/*
var backResult = Math.Abs((second.PreRealGiveFee ?? 0) - (item.RealGiveFee ?? 0)) >= 0.5m
|| Math.Abs((second.NightShiftWorkPerforFee ?? 0) - (item.NightShiftWorkPerforFee ?? 0)) >= 0.5m;
if (backResult && second.Status > 1)
{
......@@ -612,7 +613,8 @@ public void GenerateSecondAllot(per_allot allot)
second.NursingDeptStatus = 4;
second.NursingDeptRemark = "科室绩效结果发生变更,需要重新提交";
}
second.RealGiveFee = item.RealGiveFee;
*/
second.PreRealGiveFee = item.PreRealGiveFee;
second.NightShiftWorkPerforFee = item.NightShiftWorkPerforFee;
updSecond.Add(second);
}
......@@ -625,6 +627,7 @@ public void GenerateSecondAllot(per_allot allot)
var second = tempSecond?.FirstOrDefault(f => f.UnitType == item.UnitType && f.Department == item.Department);
if (second == null)
{
item.PreRealGiveFee = 0;
delSecond.Add(item);
}
}
......@@ -636,7 +639,7 @@ public void GenerateSecondAllot(per_allot allot)
if (updSecond.Any())
{
perforAgsecondallotRepository.UpdateRange(updSecond.ToArray());
/*
foreach (var item in updSecond.Where(w => w.Status == 4))
{
// 自动驳回,需要清空该科室历史数据
......@@ -644,11 +647,103 @@ public void GenerateSecondAllot(per_allot allot)
if (histories != null && histories.Any())
perforAgcomputeRepository.RemoveRange(histories.ToArray());
}
*/
}
if (delSecond.Any())
perforAgsecondallotRepository.UpdateRange(delSecond.ToArray());
}
public List<IssuedPromptResponse> IssuedPrompt(per_allot allot, AllotRequest request, ref bool isIssued)
{
List<ag_secondallot> tempSecond = new List<ag_secondallot>();
var promptSeconds = new List<IssuedPromptResponse>();
var secondList = perforAgsecondallotRepository.GetEntities(t => t.AllotId == allot.ID && t.Year == allot.Year && t.Month == allot.Month);
if (secondList == null || !secondList.Any())
return new List<IssuedPromptResponse>();
var IsOpen = hospitalRepository.GetEntity(t => t.ID == allot.HospitalId).IsOpenNursingDeptAudit == 1;
var status = new[] { 2, 3 };
foreach (var item in secondList)
{
var second = secondList?.FirstOrDefault(f => f.UnitType == item.UnitType && f.Department == item.Department);
var isDiffer = (item.RealGiveFee ?? 0) > 0 && (item.PreRealGiveFee ?? 0) > 0 && ((item.RealGiveFee ?? 0) != (item.PreRealGiveFee ?? 0));
if ((item.RealGiveFee ?? 0) == 0 && (item.PreRealGiveFee ?? 0) > 0)
{
var promptSecond = Mapper.Map<IssuedPromptResponse>(item);
promptSecond.RealGiveFee = item.PreRealGiveFee;
promptSecond.StatusRemake = "";
promptSecond.IssueStatus = 4;
promptSeconds.Add(promptSecond);
}
else if (isDiffer && !status.Contains(item.Status.Value) && (IsOpen==true? !status.Contains(item.NursingDeptStatus.Value):true))
{
var promptSecond = Mapper.Map<IssuedPromptResponse>(item);
promptSecond.StatusRemake = $@"未提交科室实发绩效变更,原金额:{item.RealGiveFee ?? 0}";
promptSecond.IssueStatus = 3;
promptSecond.RealGiveFee = item.PreRealGiveFee;
promptSeconds.Add(promptSecond);
}
else if (isDiffer && status.Contains(item.Status.Value) && (IsOpen==true? status.Contains(item.NursingDeptStatus.Value):true))
{
var promptSecond = Mapper.Map<IssuedPromptResponse>(item);
promptSecond.StatusRemake = $@"已提交或已审核科室实发绩效变更驳回,原金额:{item.RealGiveFee ?? 0}";
promptSecond.IssueStatus = 2;
promptSecond.RealGiveFee = item.PreRealGiveFee;
promptSecond.Status = 4;
promptSecond.Remark = "科室绩效结果发生变更,需要重新提交";
if (IsOpen)
{
promptSecond.NursingDeptStatus = 4;
promptSecond.NursingDeptRemark = "科室绩效结果发生变更,需要重新提交";
}
promptSeconds.Add(promptSecond);
}
else if ((item.RealGiveFee ?? 0) >= 0 && (item.PreRealGiveFee ?? 0) == 0)
{
var promptSecond = Mapper.Map<IssuedPromptResponse>(item);
promptSecond.StatusRemake = "";
promptSecond.IssueStatus = 1;
promptSeconds.Add(promptSecond);
}
}
if (!string.IsNullOrEmpty(request.SearchQuery))
promptSeconds = promptSeconds?.FindAll(t => t.Department.Contains(request.SearchQuery));
if (!string.IsNullOrEmpty(request.QueryStatus.ToString()))
promptSeconds = promptSeconds?.FindAll(t => t.IssueStatus == request.QueryStatus);
if (request.isIssued == 1)
{
perforAgsecondallotRepository.RemoveRange(delSecond.ToArray());
if (promptSeconds.Any(t => t.IssueStatus != 1))
{
var updSecondQuery = promptSeconds.Where(t => t.IssueStatus != 1);
var updSeconds = secondList.Where(w => updSecondQuery.Select(t => t.Id).Contains(w.Id)) ?? new List<ag_secondallot>();
updSeconds.ToList().ForEach(t => t.RealGiveFee = t.PreRealGiveFee);
perforAgsecondallotRepository.UpdateRange(updSeconds.ToArray());
}
if (promptSeconds.Any(t => t.IssueStatus == 1))
{
//删除
var delSecondQuery = promptSeconds.Where(t => t.IssueStatus == 1);
var delSecond = secondList.Where(w => delSecondQuery.Select(t => t.Id).Contains(w.Id)) ?? new List<ag_secondallot>();
//delSecond.ToList().ForEach(t => t.RealGiveFee = t.PreRealGiveFee);
perforAgsecondallotRepository.RemoveRange(delSecond.ToArray());
}
isIssued = true;
}
return promptSeconds.OrderBy(t => t.IssueStatus).ToList();
}
}
}
......@@ -11,6 +11,7 @@
using System.Text;
using Performance.Repository.Repository;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
namespace Performance.Services
{
......@@ -41,6 +42,7 @@ public class ConfigService : IAutoInjection
private readonly PerforExmoduleRepository perforExmoduleRepository;
private readonly PerforCofdrugtypefactorRepository cofdrugtypefactorRepository;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforReportRepository perforReport;
public ConfigService(PerforCofdirectorRepository cofdirectorRepository,
//PerforCofdrugpropRepository cofdrugpropRepository,
......@@ -65,7 +67,8 @@ public class ConfigService : IAutoInjection
ExConfigService exConfigService,
PerforExmoduleRepository perforExmoduleRepository,
PerforCofdrugtypefactorRepository cofdrugtypefactorRepository,
PerforPerallotRepository perallotRepository)
PerforPerallotRepository perallotRepository,
PerforReportRepository perforReport)
{
this._directorRepository = cofdirectorRepository;
//this._drugpropRepository = cofdrugpropRepository;
......@@ -91,6 +94,7 @@ public class ConfigService : IAutoInjection
this.perforExmoduleRepository = perforExmoduleRepository;
this.cofdrugtypefactorRepository = cofdrugtypefactorRepository;
this.perallotRepository = perallotRepository;
this.perforReport = perforReport;
}
#endregion
......@@ -1081,6 +1085,9 @@ public void NewCopy(CopyRequest request)
{
switch (item)
{
case "personnels":
personService.CreateAllotPersons(allot.HospitalId, allot.ID, allotId);
break;
case "workItems":
logger.LogInformation($"copy workItems");
var workItems = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
......@@ -1096,7 +1103,7 @@ public void NewCopy(CopyRequest request)
break;
case "drugTypes":
logger.LogInformation($"copy drugTypes");
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId==allot.HospitalId);
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (drugTypes == null || !drugTypes.Any())
{
drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allotId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
......@@ -1109,7 +1116,7 @@ public void NewCopy(CopyRequest request)
break;
case "drugTypeDisburses":
logger.LogInformation($"copy drugTypeDisburses");
var drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId==allot.HospitalId);
var drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID && t.HospitalId == allot.HospitalId);
if (drugTypeDisburses == null || !drugTypeDisburses.Any())
{
drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId) ?? drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
......@@ -1432,7 +1439,8 @@ public void SaveSecondaryAlias(SaveCollectData request)
{
// 创建固定数据列
Dictionary<string, string> baseData = CreateBaseData(request, config, r);
baseData.Add(nameof(cof_hrp_department.AllotId), allotId.ToString());
baseData.Add(nameof(cof_hrp_department.HospitalId), hospitalId.ToString());
allData.Add(baseData);
......@@ -1769,5 +1777,227 @@ public void SaveDrugtypeFactor(DrugtypeFactorRequest request)
}
#endregion
#region 自定义表
public HandsonTable QueryHandsCustom(CustomPagingRequest request)
{
var custom = perforReport.QueryCustomColumn(request.TableName);
var isExist = perforReport.QueryIsAllotId(request.TableName);
if (custom == null || isExist == false)
return null;
var dicCustom = new Dictionary<string, string>();
for (int i = 0; i < custom.Count(); i++)
{
var dic = ((IDictionary<string, object>)custom.ElementAt(i)).Values;
if (dic.ElementAt(0).ToString().ToLower() == "allotid")
continue;
dicCustom.Add(dic.ElementAt(0).ToString(), dic.ElementAt(1).ToString());
}
var customGroup = dicCustom.GroupBy(x => x.Value).Where(x => x.Count() > 1);
if (customGroup.Any())
return null;
var result = new HandsonTable((int)SheetType.Unidentifiable, new string[] { }, new List<collect_permission>());
var jsonData = JsonHelper.Serialize(perforReport.QueryCustom(request,true).DataList);
var data = JsonHelper.Deserialize<List<Dictionary<string, string>>>(jsonData);
var headDic = new List<Dictionary<string, object>>();
foreach (var item in data)
{
var head = new Dictionary<string, object>();
foreach (var dic in dicCustom)
{
if (item.ContainsKey(dic.Key.ToLower()))
head.Add(dic.Value, item.FirstOrDefault(t => t.Key == dic.Key.ToLower()).Value);
}
headDic.Add(head);
}
var Columns = dicCustom.Values.Select(t => new HandsonColumn(t, false, DataFormat.普通格式)).ToList();
//表类型
var columnType = perforReport.QueryType(request.TableName);
if (Columns != null && Columns.Any())
{
foreach (var column in Columns)
{
if (dicCustom.FirstOrDefault(t => t.Value.Contains(column.Data)).Key.ToLower() == "unittype")
{
{
column.Type = "autocomplete";
column.Source = EnumHelper.GetItems<UnitType>().Select(w => w.Description.Replace("行政后勤", "行政工勤")).ToArray();
column.Strict = true;
}
}
for (int i = 0; i < columnType.Count(); i++)
{
var type = ((IDictionary<string, object>)columnType.ElementAt(i)).Values;
var itemDic = column.Data.ToUpper() == type.ElementAt(0).ToString().ToUpper();
var dic = dicCustom.FirstOrDefault(t => t.Value == column.Data);
if (dic.Key.ToUpper() == type.ElementAt(0).ToString().ToUpper() && type.ElementAt(1).ToString() == "int")
{
column.Type = "numeric";
column.NumericFormat = new NumericFormat { Pattern = "0,00" };
}
if (dic.Key.ToUpper() == type.ElementAt(0).ToString().ToUpper() && type.ElementAt(1).ToString() == "decimal")
{
column.Type = "numeric";
column.NumericFormat = new NumericFormat { Pattern = "0,00.00" };
}
}
}
}
result.Data = headDic;
result.ColHeaders = dicCustom.Values.ToList();
result.Columns = Columns;
return result;
}
public ApiResponse SaveCustomTable(SaveCustomData request)
{
if (!request.Data.Any())
perforReport.CreatCustom(request.AllotId, request.TableName, null);
var custom = perforReport.QueryCustomColumn(request.TableName);
if(custom.Count>50)
return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据!");
var dicCustom = new Dictionary<string, object>();
for (int i = 0; i < custom.Count(); i++)
{
var dic = ((IDictionary<string, object>)custom.ElementAt(i)).Values;
if (dic.ElementAt(0).ToString().ToLower() == "allotid")
continue;
dicCustom.Add(dic.ElementAt(0).ToString(), dic.ElementAt(1).ToString());
}
//重复表头
var customGroup = dicCustom.GroupBy(x => x.Value).Where(x => x.Count() > 1);
if (customGroup.Any())
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释!");
var dicData = CreateCustomRow(request.AllotId, request, dicCustom);
//字段类型
var typeColumn = perforReport.QueryType(request.TableName);
var datas = new List<dynamic>();
foreach (var item in dicData)
{
for (int i = 0; i < typeColumn.Count(); i++)
{
var type = ((IDictionary<string, object>)typeColumn.ElementAt(i)).Values.ElementAt(0).ToString();
var itemDic = item.FirstOrDefault(t => t.Key.ToUpper() == type.ToUpper());
var value=((IDictionary<string, object>)typeColumn.ElementAt(i)).Values.ElementAt(1).ToString();
if (string.IsNullOrEmpty(itemDic.Value.ToString()) && value.Contains("date"))
item.AddOrUpdate(itemDic.Key,null);
else if(!string.IsNullOrEmpty(itemDic.Value.ToString()) && value.Contains("date"))
{
try
{
var s = DateTime.Parse(itemDic.Value.ToString());
}
catch (FormatException)
{
return new ApiResponse(ResponseType.ParameterError, "请输入正确的日期格式");
}
}
if (string.IsNullOrEmpty(itemDic.Value.ToString()) && !value.Contains("date"))
item.AddOrUpdate(itemDic.Key, 0);
if (!string.IsNullOrEmpty(itemDic.Value.ToString()) && !Regex.IsMatch(itemDic.Value.ToString(), @"^(\-|\+)?\d+(\.\d+)?$") && !value.Contains("date"))
return new ApiResponse(ResponseType.ParameterError, "保存失败,请修改红色输入内容!");
}
datas.Add(item);
}
if (datas.Any())
perforReport.CreatCustom(request.AllotId, request.TableName, datas);
return new ApiResponse(ResponseType.OK);
}
public ApiResponse QueryCustom(CustomPagingRequest request)
{
var result = new CustomResponse();
var heads = perforReport.QueryCustomColumn(request.TableName);
var isExist = perforReport.QueryIsAllotId(request.TableName);
if (isExist == false || heads == null)
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
if(heads.Count>50)
return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据");
var headList = new List<Heads>();
for (int i = 0; i < heads.Count(); i++)
{
var dic = ((IDictionary<string, object>)heads.ElementAt(i)).Values;
if (dic.ElementAt(0).ToString().ToLower() == "allotid")
continue;
var head = new Heads();
head.Cloumn = dic.ElementAt(0).ToString().ToLower();
head.Name = dic.ElementAt(1).ToString();
headList.Add(head);
}
var customGroup = headList.GroupBy(x => x.Name).Where(x => x.Count() > 1);
if (customGroup.Any())
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
result.Heads = headList;
result.Datas = perforReport.QueryCustom(request,false);
return new ApiResponse(ResponseType.OK, result);
}
private List<Dictionary<string, object>> CreateCustomRow(int allotId, SaveCustomData request, Dictionary<string, object> config)
{
List<Dictionary<string, object>> allData = new List<Dictionary<string, object>>();
for (int r = 0; r < request.Data.Length; r++)
{
// 创建固定数据列
Dictionary<string, object> baseData = CreateCustomData(request, config, r);
baseData.Add(nameof(cof_hrp_department.AllotId), allotId);
allData.Add(baseData);
}
return allData;
}
private Dictionary<string, object> CreateCustomData(SaveCustomData request, Dictionary<string, object> config, int rownumber)
{
Dictionary<string, object> result = new Dictionary<string, object>();
for (int c = 0; c < request.ColHeaders.Length; c++)
{
var header = request.ColHeaders[c];
var first = config.FirstOrDefault(w => w.Value.ToString().ToUpper() == header);
if (!default(KeyValuePair<string, object>).Equals(first)
&& !result.ContainsKey(header)
&& request.Data[rownumber].Length > c)
{
result.Add(first.Key, request.Data[rownumber][c]);
}
}
return result;
}
#endregion
}
}
......@@ -14,6 +14,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
namespace Performance.Services
{
......@@ -1097,5 +1098,41 @@ public List<TitleValue> GetPerforTypeDictHide(int allotId)
return others;
}
#endregion
public ComparisonResponse GetComparison(ComparisonPagingRequest request)
{
var result = new ComparisonResponse();
if (request.ViewName == "view_check_dept")
result.Heads = ComparisonConfig.DeptHeads;
else
result.Heads = ComparisonConfig.EmpHeads;
result.Datas = peremployeeRepository.GetComparison(request);
return result;
}
}
public class ComparisonConfig
{
public static List<Heads> DeptHeads { get; } = new List<Heads>
{
new Heads{Cloumon="核算单元组别",Name=nameof(view_check_dept.UnitType)},
new Heads{Cloumon="核算单元",Name=nameof(view_check_dept.AccountingUnit)},
new Heads{Cloumon="测算表实发",Name=nameof(view_check_dept.RealGiveFeeExecl)},
new Heads{Cloumon="软件实发",Name=nameof(view_check_dept.RealGiveFeeCompute)},
new Heads{Cloumon="差额",Name=nameof(view_check_dept.Diff)},
};
public static List<Heads> EmpHeads { get; } = new List<Heads>
{
new Heads{Cloumon="核算单元组别",Name=nameof(view_check_emp.UnitType)},
new Heads{Cloumon="核算单元",Name=nameof(view_check_emp.AccountingUnit)},
new Heads{Cloumon="人员工号",Name=nameof(view_check_emp.JobNumber)},
new Heads{Cloumon="姓名",Name=nameof(view_check_emp.EmployeeName)},
new Heads{Cloumon="测算表实发",Name=nameof(view_check_emp.RealGiveFeeExecl)},
new Heads{Cloumon="软件实发",Name=nameof(view_check_emp.RealGiveFeeCompute)},
new Heads{Cloumon="差额",Name=nameof(view_check_emp.Diff)},
};
}
}
......@@ -27,6 +27,7 @@ public class ExcelReadConfig
new ColumnInfo(nameof(PerDataEmployee.Attendance), "出勤率", true),
new ColumnInfo(nameof(PerDataEmployee.Adjust), "调节系数", true),
new ColumnInfo(nameof(PerDataEmployee.AdjustLaterOtherFee), "调节后其他绩效", true),
new ColumnInfo(nameof(PerDataEmployee.RealGiveFee), "实发绩效", true),
};
......@@ -54,6 +55,7 @@ public class ExcelReadConfig
//new ColumnInfo(nameof(PerDataClinicEmployee.NightWorkPerfor), "夜班费"),
new ColumnInfo(nameof(PerDataClinicEmployee.Adjust), "调节系数", true),
new ColumnInfo(nameof(PerDataClinicEmployee.AdjustLaterOtherFee), "调节后其他绩效", true),
new ColumnInfo(nameof(PerDataClinicEmployee.RealGiveFee), "实发绩效", true),
};
......@@ -72,6 +74,7 @@ public class ExcelReadConfig
new ColumnInfo(nameof(PerDataLogisticsEmployee.OthePerfor), "其他绩效", true),
new ColumnInfo(nameof(PerDataLogisticsEmployee.NeedSecondAllot), "是否需要二次分配"),
//new ColumnInfo(nameof(PerDataLogisticsEmployee.AdjustLaterOtherFee), "调节后其他绩效", true),
new ColumnInfo(nameof(PerDataLogisticsEmployee.RealGiveFee), "实发绩效", true),
};
public static ColumnInfo[] AccountBaisc { get; set; } = new ColumnInfo[]
......@@ -90,6 +93,7 @@ public class ExcelReadConfig
new ColumnInfo(nameof(PerDataAccountBaisc.AssessLaterOtherFee), "考核后其他绩效", true),
new ColumnInfo(nameof(PerDataAccountBaisc.AdjustFactor), "调节系数", true),
new ColumnInfo(nameof(PerDataAccountBaisc.AdjustLaterOtherFee), "调节后其他绩效", true),
new ColumnInfo(nameof(PerDataAccountBaisc.RealGiveFee), "实发绩效", true),
};
}
......
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