Commit af3f7dc9 by ruyun.zhang

Merge branch 'feature/ep读取' into develop

parents 274f5acf 2bc83756
...@@ -67,7 +67,7 @@ public ApiResponse<JwtToken> Login([FromBody] LoginRequest request) ...@@ -67,7 +67,7 @@ public ApiResponse<JwtToken> Login([FromBody] LoginRequest request)
{ {
var user = _userService.Login(request); var user = _userService.Login(request);
if (user == null) if (user == null)
return new ApiResponse<JwtToken>(ResponseType.Fail, "用户不存在"); return new ApiResponse<JwtToken>(ResponseType.Fail, "用户或密码错误");
var claims = new List<Claim> var claims = new List<Claim>
{ {
......
...@@ -180,6 +180,27 @@ public ApiResponse DeleteAttendanceType(int id) ...@@ -180,6 +180,27 @@ public ApiResponse DeleteAttendanceType(int id)
// 删除前需要验证当前类型是否被使用,如果被使用则禁止删除 // 删除前需要验证当前类型是否被使用,如果被使用则禁止删除
return _attendanceService.DeleteAttendanceType(id); return _attendanceService.DeleteAttendanceType(id);
} }
/// <summary>
/// 返回HandsonTable格式考勤类型
/// </summary>
/// <returns></returns>
[HttpGet("AttType")]
[ProducesResponseType(typeof(HandsonTable), StatusCodes.Status200OK)]
public ApiResponse GetAttendanceTypeHandsonTable(int allotId)
{
return new ApiResponse(ResponseType.OK, _attendanceService.GetAttendanceTypeHandsonTable(allotId));
}
/// <summary>
/// 批量添加修改考勤类型(粘贴数据)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("Type/{allotId}/Batch/{hospitalId}")]
public ApiResponse AttendanceTypeBatch(int allotId, int hospitalId, SaveCollectData request)
{
return _attendanceService.AttendanceTypeBatch(allotId, hospitalId, request);
}
/// <summary> /// <summary>
/// 加载默认考勤类型 /// 加载默认考勤类型
......
using System; using FluentValidation.AspNetCore;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.Request; using Performance.DtoModels.Request;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Performance.Api.Controllers namespace Performance.Api.Controllers
{ {
[Route("api/[controller]")] [Route("api/[controller]")]
public class ComputeController : Controller public class ComputeController : Controller
{ {
private ComputeService _computeService; private readonly ComputeService _computeService;
private readonly DapperService _service; private readonly DapperService _service;
private AllotService _allotService; private readonly AllotService _allotService;
private ClaimService _claim; private readonly HospitalService _hospitalService;
private EmployeeService _employeeService; private readonly ClaimService _claim;
private readonly DownloadService downloadService; private readonly DownloadService downloadService;
public ComputeController( public ComputeController(
DapperService service, DapperService service,
AllotService allotService, AllotService allotService,
HospitalService hospitalService,
ComputeService computeService, ComputeService computeService,
EmployeeService employeeService,
DownloadService downloadService, DownloadService downloadService,
ClaimService claim) ClaimService claim)
{ {
_service = service; _service = service;
_allotService = allotService; _allotService = allotService;
_hospitalService = hospitalService;
_computeService = computeService; _computeService = computeService;
_employeeService = employeeService;
this.downloadService = downloadService; this.downloadService = downloadService;
_claim = claim; _claim = claim;
} }
...@@ -711,17 +713,37 @@ public ApiResponse GethosdataView([FromBody] ComputerRequest request) ...@@ -711,17 +713,37 @@ public ApiResponse GethosdataView([FromBody] ComputerRequest request)
/// 全院核算绩效发放(视图) 下载 /// 全院核算绩效发放(视图) 下载
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns> /// <returns></returns>
[Route("gethosdataView/download/{allotId}")] [Route("gethosdataView/download/{allotId}")]
[HttpPost] [HttpPost]
public IActionResult GethosdataView(int allotId) public IActionResult GethosdataView(int allotId, [FromQuery] string? unitType, [FromQuery] string? accountingUnit, [FromQuery] string? content)
{ {
var allot = _allotService.GetAllot(allotId); var allot = _allotService.GetAllot(allotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
unitType ??= ""; accountingUnit ??= ""; content ??= "";
var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_dept"); var hospital = _hospitalService.GetHopital(allot.HospitalId);
var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/print/compute", "全院核算绩效发放"); var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_dept");
var ser = JsonHelper.Serialize(result);
var dict = JsonHelper.Deserialize<List<Dictionary<string, object>>>(ser);
var data = new List<Dictionary<string, object>>();
foreach (var obj in dict)
{
Dictionary<string, object> nobj = new Dictionary<string, object>();
foreach (var item in obj)
{
nobj[item.Key.ToLower()] = item.Value;
}
var values = nobj.Select(item => item.Value == null ? "" : item.Value.ToString());
if (values.Any(w => w.Contains(unitType)) && values.Any(w => w.Contains(accountingUnit)) && values.Any(w => w.Contains(content)))
data.Add(nobj);
}
var title = $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- 全院核算绩效发放";
var filepath = downloadService.AllComputerDown(hospital, data, "/result/print/compute", title, "全院核算绩效发放");
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -757,17 +779,38 @@ public ApiResponse AllComputeView([FromBody] ComputerRequest request) ...@@ -757,17 +779,38 @@ public ApiResponse AllComputeView([FromBody] ComputerRequest request)
/// 下载全院绩效列表 /// 下载全院绩效列表
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns> /// <returns></returns>
[Route("allcomputeView/download/{allotId}")] [Route("allcomputeView/download/{allotId}")]
[HttpPost] [HttpPost]
public IActionResult AllComputeViewDownload(int allotId) public IActionResult AllComputeViewDownload(int allotId, [FromQuery] string? unitType, [FromQuery] string? accountingUnit, [FromQuery] string? content)
{ {
var allot = _allotService.GetAllot(allotId); var allot = _allotService.GetAllot(allotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
unitType ??= ""; accountingUnit ??= ""; content ??= "";
var hospital = _hospitalService.GetHopital(allot.HospitalId);
var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp");
var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp"); var ser = JsonHelper.Serialize(result);
var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/compute", "全院绩效发放"); var dict = JsonHelper.Deserialize<List<Dictionary<string, object>>>(ser);
var data = new List<Dictionary<string, object>>();
foreach (var obj in dict)
{
Dictionary<string, object> nobj = new Dictionary<string, object>();
foreach (var item in obj)
{
nobj[item.Key.ToLower()] = item.Value;
}
var values = nobj.Select(item => item.Value == null ? "" : item.Value.ToString());
if (values.Any(w => w.Contains(unitType)) && values.Any(w => w.Contains(accountingUnit)) && values.Any(w => w.Contains(content)))
data.Add(nobj);
}
var title = $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- 全院绩效发放";
var filepath = downloadService.AllComputerDown(hospital, data, "/result/compute", title, "全院绩效发放");
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -807,17 +850,38 @@ public ApiResponse AllComputeViewByPM([FromBody] ComputerRequest request) ...@@ -807,17 +850,38 @@ public ApiResponse AllComputeViewByPM([FromBody] ComputerRequest request)
/// 下载全院绩效列表(人事科) /// 下载全院绩效列表(人事科)
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns> /// <returns></returns>
[Route("allcomputeView/personnel/download/{allotId}")] [Route("allcomputeView/personnel/download/{allotId}")]
[HttpPost] [HttpPost]
public IActionResult AllComputeByPMViewDownLoad(int allotId) public IActionResult AllComputeByPMViewDownLoad(int allotId, [FromQuery] string? unitType, [FromQuery] string? accountingUnit, [FromQuery] string? content)
{ {
var allot = _allotService.GetAllot(allotId); var allot = _allotService.GetAllot(allotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var hospital = _hospitalService.GetHopital(allot.HospitalId);
unitType ??= ""; accountingUnit ??= ""; content ??= "";
var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp_finance"); var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp_finance");
var filepath = downloadService.AllComputerViewReport(allotId, result, "/result/wholehospital", "财务全院绩效发放"); var ser = JsonHelper.Serialize(result);
var dict = JsonHelper.Deserialize<List<Dictionary<string, object>>>(ser);
var data = new List<Dictionary<string, object>>();
foreach (var obj in dict)
{
Dictionary<string, object> nobj = new Dictionary<string, object>();
foreach (var item in obj)
{
nobj[item.Key.ToLower()] = item.Value;
}
var values = nobj.Select(item => item.Value == null ? "" : item.Value.ToString());
if (values.Any(w => w.Contains(unitType)) && values.Any(w => w.Contains(accountingUnit)) && values.Any(w => w.Contains(content)))
data.Add(nobj);
}
var title = $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- 财务全院绩效发放";
var filepath = downloadService.AllComputerDown(hospital, data, "/result/wholehospital", title, "财务全院绩效发放");
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
......
...@@ -611,6 +611,18 @@ ...@@ -611,6 +611,18 @@
<param name="id"></param> <param name="id"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AttendanceController.GetAttendanceTypeHandsonTable(System.Int32)">
<summary>
返回HandsonTable格式考勤类型
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AttendanceController.AttendanceTypeBatch(System.Int32,System.Int32,Performance.DtoModels.SaveCollectData)">
<summary>
批量添加修改考勤类型(粘贴数据)
</summary>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AttendanceController.AttendanceReplenishment(System.Int32)"> <member name="M:Performance.Api.Controllers.AttendanceController.AttendanceReplenishment(System.Int32)">
<summary> <summary>
加载默认考勤类型 加载默认考勤类型
...@@ -1227,11 +1239,14 @@ ...@@ -1227,11 +1239,14 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.GethosdataView(System.Int32)"> <member name="M:Performance.Api.Controllers.ComputeController.GethosdataView(System.Int32,System.String,System.String,System.String)">
<summary> <summary>
全院核算绩效发放(视图) 下载 全院核算绩效发放(视图) 下载
</summary> </summary>
<param name="allotId"></param> <param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeView(Performance.DtoModels.ComputerRequest)"> <member name="M:Performance.Api.Controllers.ComputeController.AllComputeView(Performance.DtoModels.ComputerRequest)">
...@@ -1241,11 +1256,14 @@ ...@@ -1241,11 +1256,14 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewDownload(System.Int32)"> <member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewDownload(System.Int32,System.String,System.String,System.String)">
<summary> <summary>
下载全院绩效列表 下载全院绩效列表
</summary> </summary>
<param name="allotId"></param> <param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewByPM(Performance.DtoModels.ComputerRequest)"> <member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewByPM(Performance.DtoModels.ComputerRequest)">
...@@ -1255,11 +1273,14 @@ ...@@ -1255,11 +1273,14 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeByPMViewDownLoad(System.Int32)"> <member name="M:Performance.Api.Controllers.ComputeController.AllComputeByPMViewDownLoad(System.Int32,System.String,System.String,System.String)">
<summary> <summary>
下载全院绩效列表(人事科) 下载全院绩效列表(人事科)
</summary> </summary>
<param name="allotId"></param> <param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ConfigController.GetDrugtypeList(Performance.DtoModels.DrugpropRequest)"> <member name="M:Performance.Api.Controllers.ConfigController.GetDrugtypeList(Performance.DtoModels.DrugpropRequest)">
......
...@@ -6511,6 +6511,21 @@ ...@@ -6511,6 +6511,21 @@
是否默认值 0 非默认 1 默认 是否默认值 0 非默认 1 默认
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.Entity.per_attendance_type.RemarksOne">
<summary>
备注01
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_attendance_type.RemarksTwo">
<summary>
备注02
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_attendance_type.RemarksThree">
<summary>
备注03
</summary>
</member>
<member name="T:Performance.EntityModels.per_apr_amount"> <member name="T:Performance.EntityModels.per_apr_amount">
<summary> <summary>
...@@ -10461,6 +10476,21 @@ ...@@ -10461,6 +10476,21 @@
是否默认值 0 非默认 1 默认 是否默认值 0 非默认 1 默认
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.Other.AttendanceType.RemarksOne">
<summary>
备注01
</summary>
</member>
<member name="P:Performance.EntityModels.Other.AttendanceType.RemarksTwo">
<summary>
备注02
</summary>
</member>
<member name="P:Performance.EntityModels.Other.AttendanceType.RemarksThree">
<summary>
备注03
</summary>
</member>
<member name="P:Performance.EntityModels.HisData.HisDepartment"> <member name="P:Performance.EntityModels.HisData.HisDepartment">
<summary> <summary>
His科室 His科室
......
...@@ -19,5 +19,18 @@ public class per_attendance_type ...@@ -19,5 +19,18 @@ public class per_attendance_type
/// 是否默认值 0 非默认 1 默认 /// 是否默认值 0 非默认 1 默认
/// </summary> /// </summary>
public int IsDefault { get; set; } public int IsDefault { get; set; }
/// <summary>
/// 备注01
/// </summary>
public string RemarksOne { get; set; }
/// <summary>
/// 备注02
/// </summary>
public string RemarksTwo { get; set; }
/// <summary>
/// 备注03
/// </summary>
public string RemarksThree { get; set; }
} }
} }
...@@ -85,5 +85,17 @@ public class AttendanceType ...@@ -85,5 +85,17 @@ public class AttendanceType
/// 是否默认值 0 非默认 1 默认 /// 是否默认值 0 非默认 1 默认
/// </summary> /// </summary>
public int IsDefault { get; set; } public int IsDefault { get; set; }
/// <summary>
/// 备注01
/// </summary>
public string RemarksOne { get; set; }
/// <summary>
/// 备注02
/// </summary>
public string RemarksTwo { get; set; }
/// <summary>
/// 备注03
/// </summary>
public string RemarksThree { get; set; }
} }
} }
using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Infrastructure.Extensions
{
public static class DapperExtensions
{
/// <summary>
/// 批量新增
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <param name="connectionString"></param>
/// <param name="entities"></param>
/// <param name="tableName"></param>
/// <param name="transaction"></param>
/// <param name="commandTimeout"></param>
/// <param name="relevantColumns"></param>
/// <param name="ignoreColumns"></param>
/// <param name="batchCount"></param>
/// <returns></returns>
public static int BulkInsert<TEntity>(string connectionString,
List<TEntity> entities,
string? tableName = null,
IDbTransaction? transaction = null,
int? commandTimeout = null,
List<string>? relevantColumns = null,
List<string>? ignoreColumns = null,
int batchCount = 1000)
{
var type = typeof(TEntity);
var properties = type.GetProperties().AsEnumerable();
if (relevantColumns?.Any() == true)
properties = properties.Where(w => relevantColumns.Contains(w.Name));
if (ignoreColumns?.Any() == true)
properties = properties.Where(w => !ignoreColumns.Contains(w.Name));
var columnNames = properties.Select(w => w.Name).ToList();
for (int i = 0; i < Math.Ceiling((double)entities.Count / batchCount); i++)
{
var startIndex = batchCount * i;
var currEntities = entities.Skip(startIndex).Take(batchCount);
var strsql = new StringBuilder();
strsql.Append($"INSERT INTO {tableName}({string.Join(',', columnNames)}) VALUES");
DynamicParameters parameters = new DynamicParameters();
foreach (var item in currEntities.Select((row, index) => (row, index)))
{
var vNames = new List<string>();
foreach (var name in columnNames)
{
var pName = $"@{name}_{item.index}";
if (!vNames.Contains(pName)) vNames.Add(pName);
var value = GetValue<TEntity, object>(item.row, name);
if (value != null && value.GetType().IsClass)
value = value.ToString();
parameters.Add(pName, value);
}
tableName ??= typeof(TEntity).Name;
strsql.Append($"({string.Join(',', vNames)}),");
}
strsql.Remove(strsql.Length - 1, 1);
strsql.Append(';');
var inserSql = strsql.ToString();
using (var conn = new MySqlConnection(connectionString))
{
if (conn.State != ConnectionState.Open) conn.Open();
conn.Execute(inserSql, parameters, transaction, commandTimeout);
conn.Close();
}
}
return entities.Count;
}
/// <summary>
/// 对象取值
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="item"></param>
/// <param name="propertyName"></param>
/// <returns></returns>
public static TValue GetValue<T, TValue>(T item, string propertyName)
{
ParameterExpression parameter = Expression.Parameter(typeof(T), "w");
MemberExpression member = Expression.Property(parameter, propertyName);
UnaryExpression conversion = Expression.Convert(member, typeof(TValue));
var lambda = Expression.Lambda<Func<T, TValue>>(conversion, parameter);
Func<T, TValue> getter = lambda.Compile();
return getter(item);
}
}
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using Masuit.Tools.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -69,28 +70,23 @@ public new List<AccountUnit> GetEmployeeUnit(Expression<Func<per_employee, bool> ...@@ -69,28 +70,23 @@ public new List<AccountUnit> GetEmployeeUnit(Expression<Func<per_employee, bool>
/// <returns></returns> /// <returns></returns>
public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(ComparisonPagingRequest request) public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(ComparisonPagingRequest request)
{ {
var queryData = $@" var queryData = $@"CALL proc_allot_check_emp(@allotId);";
SELECT var checkEmps = DapperQuery<view_check_emp>(queryData, new { allotId = request.AllotId });
HospitalId,Year,Month,AllotID,ComputeId,UnitType,AccountingUnit,JobNumber,MAX(EmployeeName) AS EmployeeName,
SUM(RealGiveFeeExecl) AS RealGiveFeeExecl,SUM(RealGiveFeeCompute) AS RealGiveFeeCompute,SUM(RealGiveFeeExecl) - SUM(RealGiveFeeCompute) AS Diff request.SearchQuery = request.SearchQuery?.Clean();
FROM ( if (!string.IsNullOrEmpty(request.SearchQuery))
SELECT * FROM view_check_emp WHERE AllotId = @allotId {
) TAB checkEmps = checkEmps.Where(w => (!string.IsNullOrEmpty(w.UnitType) && w.UnitType.Contains(request.SearchQuery))
WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm OR if(@searchQuery='','',JobNumber) LIKE @parm OR if(@searchQuery='','',EmployeeName) LIKE @parm || (!string.IsNullOrEmpty(w.AccountingUnit) && w.AccountingUnit.Contains(request.SearchQuery))
GROUP BY HospitalId,Year,Month,AllotID,UnitType,AccountingUnit,JobNumber || (!string.IsNullOrEmpty(w.JobNumber) && w.JobNumber.Contains(request.SearchQuery))
ORDER BY HospitalId,Year,Month,ABS(SUM(RealGiveFeeExecl) - SUM(RealGiveFeeCompute)) DESC LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} || (!string.IsNullOrEmpty(w.EmployeeName) && w.EmployeeName.Contains(request.SearchQuery)));
"; }
var queryCount = @" checkEmps = checkEmps.OrderByDescending(w => Math.Abs(w.Diff ?? 0));
SELECT COUNT(0) FROM (
SELECT * FROM view_check_emp WHERE AllotId = @allotId
) TAB
WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm OR if(@searchQuery='','',JobNumber) LIKE @parm OR if(@searchQuery='','',EmployeeName) LIKE @parm
";
return new DtoModels.Comparison<view_check_emp>() return new DtoModels.Comparison<view_check_emp>()
{ {
Datas = DapperQuery<view_check_emp>(queryData, new { allotId = request.AllotId, searchQuery = request.SearchQuery, parm = $"%{request.SearchQuery}%" }, commandTimeout: 10000)?.ToList() ?? new List<view_check_emp>(), Datas = checkEmps.ToPagedList(request.PageIndex, request.PageSize).Data,
TotalCount = DapperQuery<int>(queryCount, new { allotId = request.AllotId, searchQuery = request.SearchQuery, parm = $"%{request.SearchQuery}%" }, commandTimeout: 10000)?.FirstOrDefault() ?? 0, TotalCount = checkEmps.Count(),
}; };
} }
...@@ -99,26 +95,23 @@ public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(Compari ...@@ -99,26 +95,23 @@ public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(Compari
/// </summary> /// </summary>
public DtoModels.Comparison<view_check_emp> CheckAccountingUnitRealGiveFeeDiff(ComparisonPagingRequest request) public DtoModels.Comparison<view_check_emp> CheckAccountingUnitRealGiveFeeDiff(ComparisonPagingRequest request)
{ {
var queryData = $@" var queryData = $@"CALL proc_allot_check_dept(@allotId);";
SELECT *,IFNULL(RealGiveFeeExecl,0) - IFNULL(RealGiveFeeCompute,0) AS Diff FROM ( var checkEmps = DapperQuery<view_check_emp>(queryData, new { allotId = request.AllotId });
SELECT * FROM view_check_dept_account WHERE AllotId = @allotId UNION ALL
SELECT * FROM view_check_dept_specialunit WHERE AllotId = @allotId request.SearchQuery = request.SearchQuery?.Clean();
) TAB if (!string.IsNullOrEmpty(request.SearchQuery))
WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm {
ORDER BY HospitalId,Year,Month,ABS(DIFF) DESC LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} checkEmps = checkEmps.Where(w => (!string.IsNullOrEmpty(w.UnitType) && w.UnitType.Contains(request.SearchQuery))
"; || (!string.IsNullOrEmpty(w.AccountingUnit) && w.AccountingUnit.Contains(request.SearchQuery))
|| (!string.IsNullOrEmpty(w.JobNumber) && w.JobNumber.Contains(request.SearchQuery))
var queryCount = @" || (!string.IsNullOrEmpty(w.EmployeeName) && w.EmployeeName.Contains(request.SearchQuery)));
SELECT count(0) FROM ( }
SELECT * FROM view_check_dept_account WHERE AllotId = @allotId UNION ALL
SELECT * FROM view_check_dept_specialunit WHERE AllotId = @allotId checkEmps = checkEmps.OrderByDescending(w => Math.Abs(w.Diff ?? 0));
) TAB
WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm
";
return new DtoModels.Comparison<view_check_emp>() return new DtoModels.Comparison<view_check_emp>()
{ {
Datas = DapperQuery<view_check_emp>(queryData, new { allotId = request.AllotId, searchQuery = request.SearchQuery, parm = $"%{request.SearchQuery}%" })?.ToList() ?? new List<view_check_emp>(), Datas = checkEmps.ToPagedList(request.PageIndex, request.PageSize).Data,
TotalCount = DapperQuery<int>(queryCount, new { allotId = request.AllotId, searchQuery = request.SearchQuery, parm = $"%{request.SearchQuery}%" })?.FirstOrDefault() ?? 0, TotalCount = checkEmps.Count(),
}; };
} }
...@@ -127,17 +120,17 @@ public DtoModels.Comparison<view_check_emp> CheckAccountingUnitRealGiveFeeDiff(C ...@@ -127,17 +120,17 @@ public DtoModels.Comparison<view_check_emp> CheckAccountingUnitRealGiveFeeDiff(C
/// </summary> /// </summary>
public DtoModels.Comparison<DeptComparisonTotal> CheckView_check_deptUnitRealGiveFeeDiffTotal(int allotId) public DtoModels.Comparison<DeptComparisonTotal> CheckView_check_deptUnitRealGiveFeeDiffTotal(int allotId)
{ {
var queryData = @"SELECT UnitType,Count(1) Count,Sum(RealGiveFeeCompute) SumFee FROM var queryData = $@"CALL proc_allot_check_dept(@allotId);";
(SELECT *,IFNULL(RealGiveFeeExecl,0) - IFNULL(RealGiveFeeCompute,0) AS Diff FROM ( var checkEmps = DapperQuery<view_check_emp>(queryData, new { allotId });
SELECT * FROM view_check_dept_account UNION ALL var list = checkEmps.Where(w => w.Diff != 0).ToList();
SELECT * FROM view_check_dept_specialunit var datas = list.GroupBy(w => w.UnitType).Select(w => new DeptComparisonTotal
) TAB
ORDER BY HospitalId,Year,Month,ABS(DIFF) DESC )view_check_dept
where AllotID = @allotId and Diff <> 0 GROUP BY UnitType";
return new DtoModels.Comparison<DeptComparisonTotal>()
{ {
Datas = DapperQuery<DeptComparisonTotal>(queryData, new { allotId })?.ToList() ?? new List<DeptComparisonTotal>(), UnitType = w.Key,
}; Count = w.Count(),
SumFee = w.Sum(p => p.RealGiveFeeCompute),
}).ToList();
return new DtoModels.Comparison<DeptComparisonTotal>() { Datas = datas };
} }
public IDbConnection GetDbConnection() public IDbConnection GetDbConnection()
......
using System.Collections.Generic; //using System.Collections.Generic;
using System.IO; //using System.IO;
using System.Linq; //using System.Linq;
using NPOI.HSSF.UserModel; //using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel; //using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel; //using NPOI.XSSF.UserModel;
using Performance.DtoModels; //using Performance.DtoModels;
using Performance.EntityModels; //using Performance.EntityModels;
using Performance.Infrastructure; //using Performance.Infrastructure;
namespace Performance.Services //namespace Performance.Services
{ //{
public class AgainService : IAutoInjection // public class AgainService : IAutoInjection
{ // {
private PerHeaderService perHeaderService; // private PerHeaderService perHeaderService;
private int DataFirstRowNum = 4;//数据起始行 // private int DataFirstRowNum = 4;//数据起始行
private int FactorRow = 3;//系数行 // private int FactorRow = 3;//系数行
public AgainService(PerHeaderService perHeaderService) // public AgainService(PerHeaderService perHeaderService)
{ // {
this.perHeaderService = perHeaderService; // this.perHeaderService = perHeaderService;
} // }
/// <summary> // /// <summary>
/// 导入excel数据 // /// 导入excel数据
/// </summary> // /// </summary>
/// <param name="path"></param> // /// <param name="path"></param>
/// <returns></returns> // /// <returns></returns>
public PerAgainExcel ReadData(per_againallot again) // public PerAgainExcel ReadData(per_againallot again)
{ // {
using (FileStream fs = new FileStream(again.Path, FileMode.Open)) // using (FileStream fs = new FileStream(again.Path, FileMode.Open))
{ // {
var excelVersion = FileHelper.GetExtension(again.Path) == ".xlsx" ? ExcelVersion.xlsx : ExcelVersion.xls; // var excelVersion = FileHelper.GetExtension(again.Path) == ".xlsx" ? ExcelVersion.xlsx : ExcelVersion.xls;
IWorkbook workbook = (excelVersion == ExcelVersion.xlsx) ? new XSSFWorkbook(fs) : new HSSFWorkbook(fs); // IWorkbook workbook = (excelVersion == ExcelVersion.xlsx) ? new XSSFWorkbook(fs) : new HSSFWorkbook(fs);
for (int i = 0; i < workbook.NumberOfSheets; i++) // for (int i = 0; i < workbook.NumberOfSheets; i++)
{ // {
var sheet = workbook.GetSheetAt(i); // var sheet = workbook.GetSheetAt(i);
if (sheet.SheetName == "二次分配表") // if (sheet.SheetName == "二次分配表")
{ // {
var point = new PerSheetPoint { DataFirstRowNum = 2, HeaderFirstCellNum = 0, HeaderFirstRowNum = 1, HeaderLastRowNum = 2 }; // var point = new PerSheetPoint { DataFirstRowNum = 2, HeaderFirstCellNum = 0, HeaderFirstRowNum = 1, HeaderLastRowNum = 2 };
var perHeader = perHeaderService.GetPerHeader(sheet, point); // var perHeader = perHeaderService.GetPerHeader(sheet, point);
var results = ReadData(sheet, perHeader); // var results = ReadData(sheet, perHeader);
return new PerAgainExcel { Header = results.Header, AgainData = results.AgainData, AgainEmployee = results.AgainEmployee }; // return new PerAgainExcel { Header = results.Header, AgainData = results.AgainData, AgainEmployee = results.AgainEmployee };
} // }
} // }
} // }
return null; // return null;
} // }
private (PerHeader Header, List<PerAgainData> AgainData, List<PerAgainEmployee> AgainEmployee) ReadData(ISheet sheet, List<PerHeader> perHeader) // private (PerHeader Header, List<PerAgainData> AgainData, List<PerAgainEmployee> AgainEmployee) ReadData(ISheet sheet, List<PerHeader> perHeader)
{ // {
List<PerAgainData> slideDataList = new List<PerAgainData>(); // List<PerAgainData> slideDataList = new List<PerAgainData>();
List<PerAgainEmployee> fixatDataList = new List<PerAgainEmployee>(); // List<PerAgainEmployee> fixatDataList = new List<PerAgainEmployee>();
var header = perHeader.FirstOrDefault(p => p.CellValue == "工作量绩效工资"); // var header = perHeader.FirstOrDefault(p => p.CellValue == "工作量绩效工资");
if (header != null && header.Children != null) // if (header != null && header.Children != null)
{ // {
for (int r = DataFirstRowNum; r < sheet.LastRowNum + 1; r++) // for (int r = DataFirstRowNum; r < sheet.LastRowNum + 1; r++)
{ // {
var row = sheet.GetRow(r); // var row = sheet.GetRow(r);
if (row == null) continue; // if (row == null) continue;
fixatDataList.Add(FixatRowRead(perHeader, r, row)); // fixatDataList.Add(FixatRowRead(perHeader, r, row));
slideDataList.AddRange(SlideRowRead(sheet, header, r, row)); // slideDataList.AddRange(SlideRowRead(sheet, header, r, row));
} // }
} // }
return (header, slideDataList, fixatDataList); // return (header, slideDataList, fixatDataList);
} // }
/// <summary> // /// <summary>
/// 可扩展列读取 // /// 可扩展列读取
/// </summary> // /// </summary>
/// <param name="sheet"></param> // /// <param name="sheet"></param>
/// <param name="header"></param> // /// <param name="header"></param>
/// <param name="r"></param> // /// <param name="r"></param>
/// <param name="row"></param> // /// <param name="row"></param>
/// <returns></returns> // /// <returns></returns>
private List<PerAgainData> SlideRowRead(ISheet sheet, PerHeader header, int r, IRow row) // private List<PerAgainData> SlideRowRead(ISheet sheet, PerHeader header, int r, IRow row)
{ // {
List<PerAgainData> slideDataList = new List<PerAgainData>(); // List<PerAgainData> slideDataList = new List<PerAgainData>();
for (int c = 0; c < header.Children.Count(); c++) // for (int c = 0; c < header.Children.Count(); c++)
{ // {
var athead = header.Children.ElementAt(c); // var athead = header.Children.ElementAt(c);
//var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell)); // //var cellValue = NopiSevice.GetCellValue(row.GetCell(athead.PointCell));
var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue()); // var cellValue = ConvertHelper.ToDecimalOrNull(row.GetCell(athead.PointCell).GetValue());
if (!cellValue.HasValue || cellValue.Value == 0) // if (!cellValue.HasValue || cellValue.Value == 0)
continue; // continue;
var factorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(FactorRow).GetCell(athead.PointCell)?.ToString()); // var factorValue = ConvertHelper.ToDecimalOrNull(sheet.GetRow(FactorRow).GetCell(athead.PointCell)?.ToString());
PerAgainData data = new PerAgainData // PerAgainData data = new PerAgainData
{ // {
RowNumber = r, // RowNumber = r,
TypeName = athead?.CellValue, // TypeName = athead?.CellValue,
CellValue = cellValue, // CellValue = cellValue,
IsTotal = 2, // IsTotal = 2,
IsFactor = factorValue.HasValue ? 1 : 2, // IsFactor = factorValue.HasValue ? 1 : 2,
FactorValue = factorValue, // FactorValue = factorValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String, // Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
SignID = athead.SignID, // SignID = athead.SignID,
}; // };
slideDataList.Add(data); // slideDataList.Add(data);
} // }
return slideDataList; // return slideDataList;
} // }
/// <summary> // /// <summary>
/// 固定列读取 // /// 固定列读取
/// </summary> // /// </summary>
/// <param name="perHeader"></param> // /// <param name="perHeader"></param>
/// <param name="r"></param> // /// <param name="r"></param>
/// <param name="row"></param> // /// <param name="row"></param>
/// <returns></returns> // /// <returns></returns>
private static PerAgainEmployee FixatRowRead(List<PerHeader> perHeader, int r, IRow row) // private static PerAgainEmployee FixatRowRead(List<PerHeader> perHeader, int r, IRow row)
{ // {
return new PerAgainEmployee // return new PerAgainEmployee
{ // {
RowNumber = r, // RowNumber = r,
Name = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "姓名").PointCell)?.ToString(), // Name = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "姓名").PointCell)?.ToString(),
JobTitle = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "职务").PointCell)?.ToString(), // JobTitle = row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "职务").PointCell)?.ToString(),
JobFactor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "职称系数").PointCell)?.ToString()), // JobFactor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "职称系数").PointCell)?.ToString()),
Attendance = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "出勤").PointCell)?.ToString()), // Attendance = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "出勤").PointCell)?.ToString()),
YearFactor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "年资").PointCell)?.ToString()), // YearFactor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "年资").PointCell)?.ToString()),
Award = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "重点奖励").PointCell)?.ToString()), // Award = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "重点奖励").PointCell)?.ToString()),
Allowance = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "管理津贴").PointCell)?.ToString()), // Allowance = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "管理津贴").PointCell)?.ToString()),
AlonePerfor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "单独核算人员绩效").PointCell)?.ToString()), // AlonePerfor = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "单独核算人员绩效").PointCell)?.ToString()),
NightShift = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "夜班费").PointCell)?.ToString()), // NightShift = ConvertHelper.ToDecimalOrNull(row.GetCell(perHeader.FirstOrDefault(p => p.CellValue == "夜班费").PointCell)?.ToString()),
}; // };
} // }
} // }
} //}
using AutoMapper;
using Dapper;
using Masuit.Tools.Systems;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.Extensions.Configuration;
using MySql.Data.MySqlClient;
using NPOI.Util;
using OfficeOpenXml;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Infrastructure.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Services.AllotCompute
{
public class EPImportDataService : IAutoInjection
{
private readonly IConfiguration _configuration;
private readonly IMapper _mapper;
private readonly PerSheetService _perSheetService;
private readonly LogManageService _logManageService;
public EPImportDataService(IConfiguration configuration, IMapper mapper, PerSheetService perSheetService, LogManageService logManageService)
{
_configuration = configuration;
_mapper = mapper;
_perSheetService = perSheetService;
_logManageService = logManageService;
}
public void DeleteSheetData(per_allot allot)
{
var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
using var conn = new MySqlConnection(connectionString);
if (conn.State != ConnectionState.Open) conn.Open();
conn.Execute("DELETE FROM im_orig_data WHERE AllotId = @AllotId", new { AllotId = allot.ID });
}
public List<ImportData> ReadSheetData(per_allot allot)
{
var maximumColIndex = _configuration.GetValue("AllotFileReadOption:MaximumColIndex", 256);
var maxEmptyRowIndex = _configuration.GetValue("AllotFileReadOption:MaxEmptyRowIndex", 30);
var maxEmptyColIndex = _configuration.GetValue("AllotFileReadOption:MaxEmptyColIndex", 10);
var skipUnidentifiable = _configuration.GetValue("AllotFileReadOption:SkipUnidentifiable", true);
var version = SnowFlake.GetInstance().GetLongId();
List<ImportData> importDatas = new List<ImportData>();
_logManageService.WriteMsg("读取文件", $"文件读取中...当前操作需要一点时间,请耐心等待", 1, allot.ID, "ReceiveMessage", true);
try
{
using ExcelPackage package = new ExcelPackage(new FileInfo(allot.Path));
foreach (var sheet in package.Workbook.Worksheets.Where(sheet => sheet.Dimension != null))
{
if (sheet.AutoFilterAddress != null)
sheet.Cells[sheet.AutoFilterAddress.Address].AutoFilter = false;
var sheetType = (int)_perSheetService.GetSheetType(sheet.Name);
if (skipUnidentifiable && sheetType == (int)SheetType.Unidentifiable) continue;
_logManageService.WriteMsg("准备读取文件", $"正在准备读取“{sheet.Name}”", 1, allot.ID, "ReceiveMessage", true);
for (int rowIndex = sheet.Dimension.Start.Row; rowIndex <= sheet.Dimension.End.Row; rowIndex++)
{
// 判断当前行与最后一条有效数据的行号 连续空行 中断读取
if (rowIndex > maxEmptyRowIndex && rowIndex - importDatas.Max(w => w.RowIndex) > maxEmptyRowIndex)
{
break;
}
var maxColIndex = rowIndex > maxEmptyRowIndex ? importDatas.Max(w => w.ColIndex) + maxEmptyColIndex : maximumColIndex;
var colCount = Math.Min(sheet.Dimension.End.Column, maxColIndex);
for (int colIndex = sheet.Dimension.Start.Column; colIndex <= colCount; colIndex++)
{
var cell = sheet.Cells[rowIndex, colIndex];
var endRowIndex = rowIndex;
var endColIndex = colIndex;
if (cell.Merge)
{
var mergedCellRang = sheet.MergedCells[rowIndex, colIndex];
var endCellName = mergedCellRang.Split(":").Last();
var endCell = sheet.Cells[endCellName];
endRowIndex = endCell.End.Row;
endColIndex = endCell.End.Column;
}
if (!string.IsNullOrEmpty(cell?.Text))
{
var cellData = new ImportData
{
AllotId = allot.ID,
SheetName = sheet.Name,
SheetIndex = sheet.Index,
SheetType = sheetType,
RowIndex = rowIndex,
ColIndex = colIndex,
Address = cell.Address,
Text = cell.Text?.Clean() ?? "",
Value = cell.Value?.ToString()?.Clean() ?? "",
//Comment = cell.Comment?.Text ?? "",
EndRowIndex = endRowIndex,
EndColIndex = endColIndex,
Sign = SnowFlake.GetInstance().GetUniqueShortId(),
ColName = ExcelCellBase.GetAddressCol(colIndex),
Version = version,
//Fulladdress = cell.FullAddress,
//Formula = cell.Formula,
//Format = cell.Style.Numberformat.Format,
//NumFmtId = cell.Style.Numberformat.NumFmtID,
};
importDatas.Add(cellData);
}
}
}
}
}
catch (Exception ex)
{
_logManageService.WriteMsg("读取文件失败", ex.Message.ToString(), 4, allot.ID, "ReceiveMessage", true);
throw;
}
_logManageService.WriteMsg("读取文件", $"EXCEL文件基础数据读取完成!", 1, allot.ID, "ReceiveMessage", true);
_logManageService.WriteMsg("保存基础数据", $"基础数据保存中...当前操作需要一点时间,请耐心等待", 1, allot.ID, "ReceiveMessage", true);
try
{
var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
var tasks = new List<Task>();
foreach (var sheetName in importDatas.Select(w => w.SheetName).Distinct())
{
var task = Task.Factory.StartNew(() =>
{
var items = importDatas.Where(w => w.SheetName == sheetName).ToList();
DapperExtensions.BulkInsert(connectionString, items, tableName: "im_orig_data", commandTimeout: 60 * 60 * 5);
});
tasks.Add(task);
}
Task.WaitAll(tasks.ToArray());
_logManageService.WriteMsg("保存基础数据", $"基础数据保存完成!", 1, allot.ID, "ReceiveMessage", true);
}
catch (Exception ex)
{
_logManageService.WriteMsg("保存数据失败", ex.Message.ToString(), 4, allot.ID, "ReceiveMessage", true);
throw;
}
return importDatas;
}
public PerExcel GetImportExcel(per_allot allot)
{
PerExcel excel = new PerExcel
{
Path = allot.Path,
FileName = Path.GetFileName(allot.Path),
PerSheet = new List<PerSheet>()
};
var (accountbasic, specialunit, data, employee, employee_clinic, employee_logistics, header, sheets) = GetImportData(allot);
foreach (var sheet in sheets)
{
if (sheet.SheetType == (int)SheetType.Employee)
{
var items = header.Where(w => w.SheetID == sheet.ID);
var rows = _mapper.Map<List<PerDataEmployee>>(employee);
PerSheet perSheet = new PerSheet
{
SheetName = sheet.SheetName,
SheetType = (SheetType)sheet.SheetType,
ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType),
PerHeader = _mapper.Map<List<PerHeader>>(items),
PerData = rows.Select(w => (IPerData)w).ToList(),
};
excel.PerSheet.Add(perSheet);
}
else if (sheet.SheetType == (int)SheetType.LogisticsEmployee)
{
var items = header.Where(w => w.SheetID == sheet.ID);
var rows = _mapper.Map<List<PerDataLogisticsEmployee>>(employee_logistics);
PerSheet perSheet = new PerSheet
{
SheetName = sheet.SheetName,
SheetType = (SheetType)sheet.SheetType,
ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType),
PerHeader = _mapper.Map<List<PerHeader>>(items),
PerData = rows.Select(w => (IPerData)w).ToList(),
};
excel.PerSheet.Add(perSheet);
}
else if (sheet.SheetType == (int)SheetType.ClinicEmployee)
{
var items = header.Where(w => w.SheetID == sheet.ID);
var rows = _mapper.Map<List<PerDataClinicEmployee>>(employee_clinic);
PerSheet perSheet = new PerSheet
{
SheetName = sheet.SheetName,
SheetType = (SheetType)sheet.SheetType,
ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType),
PerHeader = _mapper.Map<List<PerHeader>>(items),
PerData = rows.Select(w => (IPerData)w).ToList(),
};
excel.PerSheet.Add(perSheet);
}
else if (sheet.SheetType == (int)SheetType.AccountBasic)
{
var items = header.Where(w => w.SheetID == sheet.ID);
var rows = accountbasic.Select(item =>
new PerDataAccountBaisc
{
UnitType = Enum.IsDefined(typeof(UnitType), item.UnitType) ? ((UnitType)item.UnitType).ToString() : "",
AccountingUnit = item.DoctorAccountingUnit,
Drg = item.Drg,
PermanentStaff = item.PermanentStaff,
Number = item.DoctorNumber ?? 0,
BasicFactor = item.DoctorBasicFactor ?? 0,
Extra = item.DoctorExtra,
AssessBeforeOtherFee = item.AssessBeforeOtherFee,
MedicineExtra = item.MedicineExtra,
MaterialsExtra = item.MaterialsExtra,
ScoringAverage = item.DoctorScoringAverage,
AssessLaterOtherFee = item.AssessLaterOtherFee,
AdjustFactor = item.DoctorAdjustFactor,
AdjustLaterOtherFee = item.AdjustLaterOtherFee,
RealGiveFee = item.RealGiveFee,
});
PerSheet perSheet = new PerSheet
{
SheetName = sheet.SheetName,
SheetType = (SheetType)sheet.SheetType,
ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType),
PerHeader = _mapper.Map<List<PerHeader>>(items),
PerData = rows.Select(w => (IPerData)w).ToList(),
};
excel.PerSheet.Add(perSheet);
}
else if (sheet.SheetType == (int)SheetType.SpecialUnit)
{
var items = header.Where(w => w.SheetID == sheet.ID);
var rows = _mapper.Map<List<PerDataSpecialUnit>>(specialunit);
PerSheet perSheet = new PerSheet
{
SheetName = sheet.SheetName,
SheetType = (SheetType)sheet.SheetType,
ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType),
PerHeader = _mapper.Map<List<PerHeader>>(items),
PerData = rows.Select(w => (IPerData)w).ToList(),
};
excel.PerSheet.Add(perSheet);
}
else if (sheet.SheetType != (int)SheetType.Unidentifiable)
{
var items = header.Where(w => w.SheetID == sheet.ID);
var list = data.Where(w => w.SheetID == sheet.ID);
var rows = _mapper.Map<List<PerData>>(list);
PerSheet perSheet = new PerSheet
{
SheetName = sheet.SheetName,
SheetType = (SheetType)sheet.SheetType,
ModuleName = EnumHelper.GetDescription((SheetType)sheet.SheetType),
PerHeader = _mapper.Map<List<PerHeader>>(items),
PerData = rows.Select(w => (IPerData)w).ToList(),
};
excel.PerSheet.Add(perSheet);
}
}
return excel;
}
private (IEnumerable<im_accountbasic> accountbasic, IEnumerable<im_specialunit> specialunit, IEnumerable<im_data> data, IEnumerable<im_employee> employee, IEnumerable<im_employee_clinic> employee_clinic, IEnumerable<im_employee_logistics> employee_logistics, IEnumerable<im_header> header, IEnumerable<per_sheet> sheet) GetImportData(per_allot allot)
{
var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
using var conn = new MySqlConnection(connectionString);
if (conn.State != ConnectionState.Open) conn.Open();
var sql = @"
SELECT * FROM im_accountbasic WHERE AllotId = @AllotId;
SELECT * FROM im_specialunit WHERE AllotId = @AllotId;
SELECT * FROM im_data WHERE AllotId = @AllotId;
SELECT * FROM im_employee WHERE AllotId = @AllotId;
SELECT * FROM im_employee_clinic WHERE AllotId = @AllotId;
SELECT * FROM im_employee_logistics WHERE AllotId = @AllotId;
SELECT * FROM im_header WHERE AllotId = @AllotId;
SELECT * FROM per_sheet WHERE AllotId = @AllotId;
";
var multipleResults = conn.QueryMultiple(sql, new { AllotId = allot.ID });
var accountbasic = multipleResults.Read<im_accountbasic>();
var specialunit = multipleResults.Read<im_specialunit>();
var data = multipleResults.Read<im_data>();
var employee = multipleResults.Read<im_employee>();
var employee_clinic = multipleResults.Read<im_employee_clinic>();
var employee_logistics = multipleResults.Read<im_employee_logistics>();
var header = multipleResults.Read<im_header>();
var sheet = multipleResults.Read<per_sheet>();
return (accountbasic, specialunit, data, employee, employee_clinic, employee_logistics, header, sheet);
}
public void SheetDataImport(per_allot allot)
{
var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
using var conn = new MySqlConnection(connectionString);
if (conn.State != ConnectionState.Open) conn.Open();
conn.Execute("call proc_allot_import(@AllotId);", new { AllotId = allot.ID }, commandTimeout: 60 * 60 * 5);
}
}
public class ImportData
{
public long Id { get; set; }
/// <summary>
/// 绩效分配月ID
/// </summary>
public long AllotId { get; set; }
/// <summary>
/// 工作表ID
/// </summary>
public long SheetId { get; set; }
/// <summary>
/// 工作表名称
/// </summary>
public string SheetName { get; set; }
/// <summary>
/// 工作表索引
/// </summary>
public int SheetIndex { get; set; }
/// <summary>
/// 行号
/// </summary>
public int RowIndex { get; set; }
/// <summary>
/// 列号
/// </summary>
public int ColIndex { get; set; }
/// <summary>
/// 合并结束行号
/// </summary>
public int EndRowIndex { get; set; }
/// <summary>
/// 合并结束列号
/// </summary>
public int EndColIndex { get; set; }
/// <summary>
/// 文本值
/// </summary>
public string Value { get; set; }
/// <summary>
/// 单元格名称
/// </summary>
public string Address { get; set; }
/// <summary>
/// 文本值
/// </summary>
public string Text { get; set; }
/// <summary>
/// 唯一签名
/// </summary>
public string Sign { get; set; }
/// <summary>
/// 列名
/// </summary>
public string ColName { get; set; }
///// <summary>
///// 单元格备注
///// </summary>
//public string Comment { get; set; }
public int SheetType { get; set; }
public long Version { get; set; }
/// <summary>
/// 数据格式
/// </summary>
//public string Format { get; set; }
///// <summary>
///// 公式
///// </summary>
//public string Formula { get; set; }
///// <summary>
///// 格式ID(第三方)
///// </summary>
//public int? NumFmtId { get; set; }
///// <summary>
///// 单元格地址
///// </summary>
//public string Fulladdress { get; set; }
///// <summary>
///// 创建人
///// </summary>
//public long CreateBy { get; set; }
///// <summary>
///// 创建时间
///// </summary>
//public DateTime CreateTime { get; set; }
///// <summary>
///// 最后修改人
///// </summary>
//public long UpdateBy { get; set; }
///// <summary>
///// 修改时间
///// </summary>
//public DateTime UpdateTime { get; set; }
}
}
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using AutoMapper; using AutoMapper;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure.Extensions;
using Performance.Repository; using Performance.Repository;
namespace Performance.Services.AllotCompute namespace Performance.Services.AllotCompute
...@@ -15,6 +17,7 @@ namespace Performance.Services.AllotCompute ...@@ -15,6 +17,7 @@ namespace Performance.Services.AllotCompute
/// </summary> /// </summary>
public class ProcessComputService : IAutoInjection public class ProcessComputService : IAutoInjection
{ {
private readonly IConfiguration _configuration;
private readonly IMapper _mapper; private readonly IMapper _mapper;
private readonly IOptions<Application> _options; private readonly IOptions<Application> _options;
private readonly BudgetService _budgetService; private readonly BudgetService _budgetService;
...@@ -34,6 +37,7 @@ public class ProcessComputService : IAutoInjection ...@@ -34,6 +37,7 @@ public class ProcessComputService : IAutoInjection
private readonly PerforPerallotRepository perallotRepository; private readonly PerforPerallotRepository perallotRepository;
public ProcessComputService( public ProcessComputService(
IConfiguration configuration,
IMapper mapper, IMapper mapper,
IOptions<Application> options, IOptions<Application> options,
BudgetService budgetService, BudgetService budgetService,
...@@ -52,6 +56,7 @@ public class ProcessComputService : IAutoInjection ...@@ -52,6 +56,7 @@ public class ProcessComputService : IAutoInjection
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforPerallotRepository perallotRepository) PerforPerallotRepository perallotRepository)
{ {
_configuration = configuration;
_mapper = mapper; _mapper = mapper;
_options = options; _options = options;
_budgetService = budgetService; _budgetService = budgetService;
...@@ -103,15 +108,14 @@ private void SaveComputeAccount(PerSheet sheet, int allotId) ...@@ -103,15 +108,14 @@ private void SaveComputeAccount(PerSheet sheet, int allotId)
perforPerSheetRepository.Add(imsheet); perforPerSheetRepository.Add(imsheet);
var dataList = sheet.PerData.Select(t => (PerDataAccountBaisc)t); var dataList = sheet.PerData.Select(t => (PerDataAccountBaisc)t);
List<res_account> addList = new List<res_account>(); List<res_account> addList = _mapper.Map<List<res_account>>(dataList);
foreach (var data in dataList) foreach (var data in addList)
{ {
var imdata = _mapper.Map<res_account>(data); data.SheetID = imsheet.ID;
imdata.SheetID = imsheet.ID; data.AllotID = allotId;
imdata.AllotID = allotId; }
addList.Add(imdata); var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
} DapperExtensions.BulkInsert(connectionString, addList, tableName: "res_account", commandTimeout: 60 * 60 * 5);
perforResaccountRepository.AddRange(addList.ToArray());
} }
/// <summary> /// <summary>
...@@ -122,6 +126,7 @@ private void SaveComputeAccount(PerSheet sheet, int allotId) ...@@ -122,6 +126,7 @@ private void SaveComputeAccount(PerSheet sheet, int allotId)
/// <returns></returns> /// <returns></returns>
private void SaveCommon(PerSheet sheet, int allotId) private void SaveCommon(PerSheet sheet, int allotId)
{ {
var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
var imsheet = new per_sheet { AllotID = allotId, SheetName = sheet.SheetName, Source = 2, SheetType = (int)sheet.SheetType }; var imsheet = new per_sheet { AllotID = allotId, SheetName = sheet.SheetName, Source = 2, SheetType = (int)sheet.SheetType };
perforPerSheetRepository.Add(imsheet); perforPerSheetRepository.Add(imsheet);
...@@ -143,19 +148,17 @@ private void SaveCommon(PerSheet sheet, int allotId) ...@@ -143,19 +148,17 @@ private void SaveCommon(PerSheet sheet, int allotId)
addHeadList.Add(imheaderChild); addHeadList.Add(imheaderChild);
} }
} }
} }
perforImHeaderRepository.AddRange(addHeadList.ToArray()); DapperExtensions.BulkInsert(connectionString, addHeadList, tableName: "im_header", commandTimeout: 60 * 60 * 5);
List<im_data> addDataList = new List<im_data>();
var dataList = sheet.PerData.Select(t => (PerData)t); var dataList = sheet.PerData.Select(t => (PerData)t);
foreach (var data in dataList) List<im_data> addDataList = _mapper.Map<List<im_data>>(dataList);
foreach (var data in addDataList)
{ {
var imdata = _mapper.Map<im_data>(data); data.SheetID = imsheet.ID;
imdata.SheetID = imsheet.ID; data.AllotID = allotId;
imdata.AllotID = allotId;
addDataList.Add(imdata);
} }
perforImDataRepository.AddRange(addDataList.ToArray()); DapperExtensions.BulkInsert(connectionString, addDataList, tableName: "im_data", commandTimeout: 60 * 60 * 5);
} }
/// <summary> /// <summary>
......
using System; using AutoMapper;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using AutoMapper;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OfficeOpenXml; using OfficeOpenXml;
...@@ -16,6 +12,11 @@ ...@@ -16,6 +12,11 @@
using Performance.Repository; using Performance.Repository;
using Performance.Services.AllotCompute; using Performance.Services.AllotCompute;
using Performance.Services.ExtractExcelService; using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -23,6 +24,7 @@ public class AllotService : IAutoInjection ...@@ -23,6 +24,7 @@ public class AllotService : IAutoInjection
{ {
private BaiscNormService baiscNormService; private BaiscNormService baiscNormService;
private ImportDataService importDataService; private ImportDataService importDataService;
private readonly EPImportDataService _epImportDataService;
private ProcessComputService processComputService; private ProcessComputService processComputService;
private ResultComputeService resultComputeService; private ResultComputeService resultComputeService;
private PerforLogdbugRepository logdbug; private PerforLogdbugRepository logdbug;
...@@ -36,6 +38,7 @@ public class AllotService : IAutoInjection ...@@ -36,6 +38,7 @@ public class AllotService : IAutoInjection
private IEmailService emailService; private IEmailService emailService;
private readonly IOptions<Application> options; private readonly IOptions<Application> options;
private readonly IOptions<AppConnection> _appConnection; private readonly IOptions<AppConnection> _appConnection;
private readonly IConfiguration _configuration;
private readonly ComputeDirector _computeDirector; private readonly ComputeDirector _computeDirector;
private readonly PerforRescomputeRepository _perforRescomputeRepository; private readonly PerforRescomputeRepository _perforRescomputeRepository;
private readonly PerforImemployeeRepository _perforImEmployeeRepository; private readonly PerforImemployeeRepository _perforImEmployeeRepository;
...@@ -62,6 +65,7 @@ public class AllotService : IAutoInjection ...@@ -62,6 +65,7 @@ public class AllotService : IAutoInjection
PerforPerallotRepository allotRepository, PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService, BaiscNormService baiscNormService,
ImportDataService importDataService, ImportDataService importDataService,
EPImportDataService epImportDataService,
ProcessComputService processComputService, ProcessComputService processComputService,
ResultComputeService resultComputeService, ResultComputeService resultComputeService,
ConfigService configService, ConfigService configService,
...@@ -70,6 +74,7 @@ public class AllotService : IAutoInjection ...@@ -70,6 +74,7 @@ public class AllotService : IAutoInjection
IEmailService emailService, IEmailService emailService,
IOptions<Application> options, IOptions<Application> options,
IOptions<AppConnection> appConnection, IOptions<AppConnection> appConnection,
IConfiguration configuration,
ComputeDirector computeDirector, ComputeDirector computeDirector,
PerforRescomputeRepository perforRescomputeRepository, PerforRescomputeRepository perforRescomputeRepository,
PerforImemployeeRepository perforImEmployeeRepository, PerforImemployeeRepository perforImEmployeeRepository,
...@@ -97,11 +102,13 @@ public class AllotService : IAutoInjection ...@@ -97,11 +102,13 @@ public class AllotService : IAutoInjection
_evn = evn; _evn = evn;
this.baiscNormService = baiscNormService; this.baiscNormService = baiscNormService;
this.importDataService = importDataService; this.importDataService = importDataService;
_epImportDataService = epImportDataService;
this.processComputService = processComputService; this.processComputService = processComputService;
this.resultComputeService = resultComputeService; this.resultComputeService = resultComputeService;
this.emailService = emailService; this.emailService = emailService;
this.options = options; this.options = options;
_appConnection = appConnection; _appConnection = appConnection;
_configuration = configuration;
_computeDirector = computeDirector; _computeDirector = computeDirector;
_perforRescomputeRepository = perforRescomputeRepository; _perforRescomputeRepository = perforRescomputeRepository;
_perforImEmployeeRepository = perforImEmployeeRepository; _perforImEmployeeRepository = perforImEmployeeRepository;
...@@ -338,10 +345,22 @@ public void Generate(per_allot allot) ...@@ -338,10 +345,22 @@ public void Generate(per_allot allot)
logManageService.WriteMsg("绩效开始执行", $"数据来源:用户上传的Excel。", 1, allot.ID, "ReceiveMessage", true); logManageService.WriteMsg("绩效开始执行", $"数据来源:用户上传的Excel。", 1, allot.ID, "ReceiveMessage", true);
configService.Clear(allot.ID); configService.Clear(allot.ID);
// 关闭筛选功能
ExtractHelper.CloseAutoFilter(allot.Path); var useNewRead = _configuration.GetValue("AllotFileReadOption:UseNewRead", true);
// 导出数据 if (useNewRead)
excel = importDataService.ReadDataAndSave(allot); {
_epImportDataService.DeleteSheetData(allot);
_epImportDataService.ReadSheetData(allot);
_epImportDataService.SheetDataImport(allot);
excel = _epImportDataService.GetImportExcel(allot);
}
else
{
// 关闭筛选功能
ExtractHelper.CloseAutoFilter(allot.Path);
// 导出数据
excel = importDataService.ReadDataAndSave(allot);
}
//if (!checkDataService.Check(excel, allot)) //if (!checkDataService.Check(excel, allot))
//{ //{
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
...@@ -895,7 +896,7 @@ public PagedList<AssessSchemeResultListResponse> SchemeResultList(QuerySchemeRes ...@@ -895,7 +896,7 @@ public PagedList<AssessSchemeResultListResponse> SchemeResultList(QuerySchemeRes
if (!string.IsNullOrEmpty(query.TargetAccountingUnit)) if (!string.IsNullOrEmpty(query.TargetAccountingUnit))
viewAResultQuery = viewAResultQuery.Where(w => w.TargetAccountingUnit == query.TargetAccountingUnit); viewAResultQuery = viewAResultQuery.Where(w => w.TargetAccountingUnit == query.TargetAccountingUnit);
if (!string.IsNullOrEmpty(query.ItemName2)) if (!string.IsNullOrEmpty(query.ItemName2))
viewAResultQuery = viewAResultQuery.Where(w => w.ItemName2 == query.ItemName2); viewAResultQuery = viewAResultQuery.Where(w => w.ItemName2.Contains(query.ItemName2));
if (viewAResultQuery == null || viewAResultQuery.Count() < 0) if (viewAResultQuery == null || viewAResultQuery.Count() < 0)
throw new PerformanceException("暂无数据"); throw new PerformanceException("暂无数据");
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using AutoMapper; using AutoMapper;
using GraphQL;
using K4os.Hash.xxHash; using K4os.Hash.xxHash;
using Masuit.Tools; using Masuit.Tools;
using Masuit.Tools.Reflection; using Masuit.Tools.Reflection;
...@@ -505,6 +506,16 @@ public ApiResponse AttendanceClearAll(int allotId) ...@@ -505,6 +506,16 @@ public ApiResponse AttendanceClearAll(int allotId)
(nameof(RecordAttendcance.BegDate), "开始时间", t => t.BegDate), (nameof(RecordAttendcance.BegDate), "开始时间", t => t.BegDate),
(nameof(RecordAttendcance.EndDate), "结束时间", t => t.EndDate), (nameof(RecordAttendcance.EndDate), "结束时间", t => t.EndDate),
}; };
public static List<(string, string, Func<per_attendance_type, object>)> AttTypes { get; } = new List<(string, string, Func<per_attendance_type, object>)>
{
(nameof(per_attendance_type.AttendanceName), "考勤类型名称", t => t.AttendanceName),
(nameof(per_attendance_type.IsDeduction), "是否核减出勤", t => t.IsDeduction),
(nameof(per_attendance_type.IsDefault), "是否默认值" ,t => t.IsDefault),
(nameof(per_attendance_type.RemarksOne), "备注01", t => t.RemarksOne),
(nameof(per_attendance_type.RemarksTwo), "备注02", t => t.RemarksTwo),
(nameof(per_attendance_type.RemarksThree), "备注03", t => t.RemarksThree),
};
#endregion #endregion
#region 考勤类型 #region 考勤类型
...@@ -540,6 +551,9 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT ...@@ -540,6 +551,9 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT
per_Attendance_Type.AttendanceName = attendanceType.AttendanceName; per_Attendance_Type.AttendanceName = attendanceType.AttendanceName;
per_Attendance_Type.IsDeduction = attendanceType.IsDeduction; per_Attendance_Type.IsDeduction = attendanceType.IsDeduction;
per_Attendance_Type.IsDefault = attendanceType.IsDefault; per_Attendance_Type.IsDefault = attendanceType.IsDefault;
per_Attendance_Type.RemarksOne = attendanceType.RemarksOne;
per_Attendance_Type.RemarksTwo = attendanceType.RemarksTwo;
per_Attendance_Type.RemarksThree = attendanceType.RemarksThree;
if (perfoPperAttendanceTypeRepository.Update(per_Attendance_Type)) if (perfoPperAttendanceTypeRepository.Update(per_Attendance_Type))
return new ApiResponse<AttendanceType>(ResponseType.OK, "修改成功"); return new ApiResponse<AttendanceType>(ResponseType.OK, "修改成功");
...@@ -553,7 +567,10 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT ...@@ -553,7 +567,10 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT
HospitalId = allot.HospitalId, HospitalId = allot.HospitalId,
AttendanceName = attendanceType.AttendanceName, AttendanceName = attendanceType.AttendanceName,
IsDeduction = attendanceType.IsDeduction, IsDeduction = attendanceType.IsDeduction,
IsDefault = attendanceType.IsDefault IsDefault = attendanceType.IsDefault,
RemarksOne = attendanceType.RemarksOne,
RemarksTwo = attendanceType.RemarksTwo,
RemarksThree = attendanceType.RemarksThree,
}; };
if (perfoPperAttendanceTypeRepository.Add(per_Attendance_Type)) if (perfoPperAttendanceTypeRepository.Add(per_Attendance_Type))
return new ApiResponse<AttendanceType>(ResponseType.OK, "添加成功"); return new ApiResponse<AttendanceType>(ResponseType.OK, "添加成功");
...@@ -576,6 +593,142 @@ public ApiResponse DeleteAttendanceType(int id) ...@@ -576,6 +593,142 @@ public ApiResponse DeleteAttendanceType(int id)
: new ApiResponse(ResponseType.Fail, "删除失败"); : new ApiResponse(ResponseType.Fail, "删除失败");
} }
/// <summary> /// <summary>
/// 返回HandsonTable格式考勤类型
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
public HandsonTableBase GetAttendanceTypeHandsonTable(int allotId)
{
HandsonTableBase handson = new HandsonTableBase()
{
Columns = AttTypes.Select(t => new HandsonColumn(t.Item2)).ToList(),
ColHeaders = AttTypes.Select(c => c.Item2).ToList(),
};
if (handson.Columns != null && handson.Columns.Any())
{
foreach (var column in handson.Columns)
{
column.Type = "text";
if (column.Data == "是否核减出勤" || column.Data == "是否默认值")
{
column.Type = "autocomplete";
column.Source = new string[] { "是", "否" };
}
}
}
var convertDate = GetAttendanceType(allotId).Data.Select(t =>
new
{
t.AttendanceName,
t.IsDeduction,
t.IsDefault,
t.RemarksOne,
t.RemarksTwo,
t.RemarksThree,
});
if (!convertDate.Any())
return handson;
List<HandsonRowData> rowDatas = new List<HandsonRowData>();
int i = 1;
var dict = new Dictionary<string, string>();
AttTypes.ForEach(t => dict.Add(t.Item1, t.Item2));
foreach (var item in convertDate)
{
var json = JsonHelper.Serialize(item);
var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json);
var cells = (from conf in dict join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper() select new HandsonCellData(conf.Value, fst.Value)).ToList();
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
handson.SetRowData(rowDatas);
foreach (var item in handson.Data)
{
item.Remove("编号");
if (item.ContainsKey("是否核减出勤") && int.TryParse(item["是否核减出勤"].ToString(), out int IsDeduction))
{
item["是否核减出勤"] = (IsDeduction == 1) ? "是" : "否";
}
if (item.ContainsKey("是否默认值") && int.TryParse(item["是否默认值"].ToString(), out int IsDefault))
{
item["是否默认值"] = (IsDefault == 1) ? "是" : "否";
}
}
return handson;
}
/// <summary>
/// 批量添加修改考勤类型(粘贴数据)
/// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="request"></param>
/// <returns></returns>
public ApiResponse AttendanceTypeBatch(int allotId, int hospitalId, SaveCollectData request)
{
var dict = new Dictionary<string, string>();
AttTypes.ForEach(t => dict.Add(t.Item1, t.Item2));
var dicData = CreateDataRow(request, dict);
if (dicData == null || dicData.Count == 0)
return new ApiResponse(ResponseType.Error, "空数据,无效操作");
foreach (var item in dicData)
{
if (item.ContainsKey("IsDeduction") && item["IsDeduction"] is string IsDeduction)
{
item["IsDeduction"] = (IsDeduction == "是") ? "1" : "0";
}
if (item.ContainsKey("IsDefault") && item["IsDefault"] is string IsDefault)
{
item["IsDefault"] = (IsDefault == "是") ? "1" : "0";
}
}
var jsons = JsonHelper.Serialize(dicData);
var newAttendanceType = JsonHelper.Deserialize<List<per_attendance_type>>(jsons);
var oldAttendanceType = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId && t.HospitalId == hospitalId);
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
for (int i = 0; i < newAttendanceType.Count; i++)
{
if (string.IsNullOrEmpty(newAttendanceType[i].AttendanceName?.Trim()))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{i+1}行" },
{ "考勤类型名称", newAttendanceType[i].AttendanceName??"" },
{ "错误原因", "“考勤类型名称”请补全" },
});
}
}
if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
List<per_attendance_type> addAttendanceType = new List<per_attendance_type>();
foreach (var data in newAttendanceType)
{
data.AllotId = allotId;
data.HospitalId = hospitalId;
addAttendanceType.Add(data);
}
perfoPperAttendanceTypeRepository.RemoveRange(oldAttendanceType.ToArray());
perfoPperAttendanceTypeRepository.AddRange(newAttendanceType.ToArray());
return new ApiResponse(ResponseType.OK, "");
}
/// <summary>
/// 加载默认考勤类型 /// 加载默认考勤类型
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
...@@ -1626,13 +1779,13 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit ...@@ -1626,13 +1779,13 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId); var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId);
var perAttendanceDepts = _attendanceDeptRepository.GetEntities(w => w.AllotId == allotId) ?? new List<per_attendance_dept>(); var perAttendanceDepts = _attendanceDeptRepository.GetEntities(w => w.AllotId == allotId) ?? new List<per_attendance_dept>();
var attendances = perAttendanceDepts?.Where((w) => w.AllotId == allotId && unitTypes.Contains(w.UnitType) && accountingUnit.Equals(w.AccountingUnit)).ToList(); var attendances = perAttendanceDepts?.Where((w) => unitTypes.Contains(w.UnitType) && accountingUnit.Equals(w.AccountingUnit)).ToList();
if (attendances.Count > 0 && attendances.Count == attendances.Count(w => w.State == (int)Attendance.Report.通过)) if (attendances.Count > 0 && attendances.Count == attendances.Count(w => w.State == (int)Attendance.Report.通过))
throw new PerformanceException("当前考勤已审核通过,无法提交!"); throw new PerformanceException("当前考勤已审核通过,无法提交!");
//查询是否在其他科室的考勤记录 //查询是否在其他科室的考勤记录
var data_Numbers = datas.Select(w => w.PersonnelNumber).ToList(); //var data_Numbers = datas.Select(w => w.PersonnelNumber).ToList();
var attendanceDepts = perAttendanceDepts?.Where(w => w.AllotId == allotId && data_Numbers.Contains(w.PersonnelNumber) && unitType != w.UnitType && accountingUnit != w.AccountingUnit).ToList(); //var attendanceDepts = perAttendanceDepts?.Where(w => data_Numbers.Contains(w.PersonnelNumber) && unitType != w.UnitType && accountingUnit != w.AccountingUnit).ToList();
List<per_attendance_dept> newAttendanceDepts = new List<per_attendance_dept>(); List<per_attendance_dept> newAttendanceDepts = new List<per_attendance_dept>();
List<per_attendance_dept> updAttendanceDepts = new List<per_attendance_dept>(); List<per_attendance_dept> updAttendanceDepts = new List<per_attendance_dept>();
...@@ -1747,27 +1900,27 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit ...@@ -1747,27 +1900,27 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
}); });
} }
foreach (var attendanceDept in attendanceDepts.Where(a => row.PersonnelNumber.Equals(a.PersonnelNumber))) //foreach (var attendanceDept in attendanceDepts.Where(a => row.PersonnelNumber.Equals(a.PersonnelNumber)))
{ //{
for (int day = 1; day <= 31; day++) // for (int day = 1; day <= 31; day++)
{ // {
string dayPropertyName = $"Day{day:00}"; // string dayPropertyName = $"Day{day:00}";
var attendanceDeptValue = typeof(per_attendance_dept).GetProperty(dayPropertyName)?.GetValue(attendanceDept); // var attendanceDeptValue = typeof(per_attendance_dept).GetProperty(dayPropertyName)?.GetValue(attendanceDept);
var dataValue = typeof(AttendanceDept).GetProperty(dayPropertyName)?.GetValue(row); // var dataValue = typeof(AttendanceDept).GetProperty(dayPropertyName)?.GetValue(row);
if (!string.IsNullOrEmpty(attendanceDeptValue?.ToString()) && !string.IsNullOrEmpty(dataValue?.ToString())) // if (!string.IsNullOrEmpty(attendanceDeptValue?.ToString()) && !string.IsNullOrEmpty(dataValue?.ToString()))
{ // {
error.Add(new Dictionary<string, string> // error.Add(new Dictionary<string, string>
{ // {
{ "行号", $"第{item.ind + 1}行" }, // { "行号", $"第{item.ind + 1}行" },
{ "工号", attendanceDept.PersonnelNumber ?? "" }, // { "工号", attendanceDept.PersonnelNumber ?? "" },
{ "姓名", attendanceDept.PersonnelName ?? "" }, // { "姓名", attendanceDept.PersonnelName ?? "" },
{ "人员系数", attendanceDept.PermanentStaff?.ToString() ?? "" }, // { "人员系数", attendanceDept.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", "" }, // { "考勤类型", "" },
{ "错误原因", $"{day}号存在考勤记录,所在科室为:{attendanceDept.AccountingUnit},请核实后重新填写"}, // { "错误原因", $"{day}号存在考勤记录,所在科室为:{attendanceDept.AccountingUnit},请核实后重新填写"},
}); // });
} // }
} // }
} //}
var accounting = cofaccounting.Find(p => p.UnitType == unitType && p.AccountingUnit == accountingUnit); var accounting = cofaccounting.Find(p => p.UnitType == unitType && p.AccountingUnit == accountingUnit);
var attendance = attendances.Find(w => w.PersonnelNumber == row.PersonnelNumber && w.UnitType == unitType.ToString() && w.AccountingUnit == accountingUnit); var attendance = attendances.Find(w => w.PersonnelNumber == row.PersonnelNumber && w.UnitType == unitType.ToString() && w.AccountingUnit == accountingUnit);
...@@ -1969,10 +2122,15 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u ...@@ -1969,10 +2122,15 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
string queryAccountingUnit = userInfo.User.Department; string queryAccountingUnit = userInfo.User.Department;
if (!queryUnitTypes.Contains(unitType)) throw new PerformanceException("当前用户角色与“核算组别”不匹配"); if (!queryUnitTypes.Contains(unitType)) throw new PerformanceException("当前用户角色与“核算组别”不匹配");
var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit)) ?? new List<per_attendance_dept>();
var perAttendanceDepts = _attendanceDeptRepository.GetEntities(w => w.AllotId == allotId) ?? new List<per_attendance_dept>();
var attendances = perAttendanceDepts?.Where((w) => queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit)).ToList();
if (!attendances.Any()) return new ApiResponse(ResponseType.OK, "暂无数据,无需提交!"); if (!attendances.Any()) return new ApiResponse(ResponseType.OK, "暂无数据,无需提交!");
int[] states = { (int)Attendance.Report.通过, (int)Attendance.Report.提交 };
//查询是否在其他科室的考勤记录
var data_Numbers = attendances.Select(w => w.PersonnelNumber).ToList();
var attendanceDepts = perAttendanceDepts?.Where(w => data_Numbers.Contains(w.PersonnelNumber) && unitType != w.UnitType && queryAccountingUnit != w.AccountingUnit && w.State.Equals(states)).ToList();
var cofaccounting = cofaccountingRepository.GetEntities(g => g.AllotId == allotId);
var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId); var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId);
var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_attendance_type>(); var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_attendance_type>();
...@@ -1980,7 +2138,7 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u ...@@ -1980,7 +2138,7 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
foreach (var item in attendances.Select((row, ind) => (row, ind))) foreach (var item in attendances.Select((row, ind) => (row, ind)))
{ {
var row = item.row; var row = item.row;
if (string.IsNullOrEmpty(row.PersonnelNumber) || string.IsNullOrEmpty(row.PersonnelNumber)) if (string.IsNullOrEmpty(row.PersonnelNumber))
{ {
error.Add(new Dictionary<string, string> error.Add(new Dictionary<string, string>
{ {
...@@ -2102,13 +2260,33 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u ...@@ -2102,13 +2260,33 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
continue; continue;
} }
foreach (var attendanceDept in attendanceDepts.Where(a => row.PersonnelNumber.Equals(a.PersonnelNumber)))
{
for (int day = 1; day <= 31; day++)
{
string dayPropertyName = $"Day{day:00}";
var attendanceDeptValue = typeof(per_attendance_dept).GetProperty(dayPropertyName)?.GetValue(attendanceDept);
var dataValue = typeof(AttendanceDept).GetProperty(dayPropertyName)?.GetValue(row);
if (!string.IsNullOrEmpty(attendanceDeptValue?.ToString()) && !string.IsNullOrEmpty(dataValue?.ToString()))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{item.ind + 1}行" },
{ "工号", attendanceDept.PersonnelNumber ?? "" },
{ "姓名", attendanceDept.PersonnelName ?? "" },
{ "人员系数", attendanceDept.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"{day}号已提交考勤记录,所在科室为:{attendanceDept.AccountingUnit},请勿重复提交"},
});
}
}
}
} }
if (error.Count > 0) if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error); return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
var stateCount = attendances.GroupBy(w => w.State).Select(w => new { w.Key, StateCount = w.Count() }).ToList(); if (attendances.Count > 0 && attendances.Count == attendances.Count(w => w.State == (int)Attendance.Report.通过))
if (attendances.Count() > 0 && attendances.Count() == attendances.Count(w => w.State == (int)Attendance.Report.通过))
throw new PerformanceException("当前考勤已审核通过,无法提交!"); throw new PerformanceException("当前考勤已审核通过,无法提交!");
var submitTime = DateTime.Now; var submitTime = DateTime.Now;
...@@ -2251,7 +2429,7 @@ public void DeptReportRefresh(per_allot allot, int state, List<per_attendance_de ...@@ -2251,7 +2429,7 @@ public void DeptReportRefresh(per_allot allot, int state, List<per_attendance_de
attendances ??= new List<per_attendance_dept>(); attendances ??= new List<per_attendance_dept>();
var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allot.ID) ?? new List<per_attendance_type>(); var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allot.ID) ?? new List<per_attendance_type>();
Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : ""; Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : "";
List<AttendanceDeptMore> datas = attendances.Select(w => new AttendanceDeptMore List<AttendanceDeptMore> datas = attendances.Where(w => w.State == state).Select(w => new AttendanceDeptMore
{ {
AllotId = allot.ID, AllotId = allot.ID,
Code = w.Code, Code = w.Code,
...@@ -2320,14 +2498,12 @@ public void DeptReportRefresh(per_allot allot, int state, List<per_attendance_de ...@@ -2320,14 +2498,12 @@ public void DeptReportRefresh(per_allot allot, int state, List<per_attendance_de
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
}; };
}); });
var unitTypes = attendances.Select(w => w.UnitType).Distinct().ToList(); var oldEntities = _perforPerAttendanceDeptReportRepository.GetEntities(w => w.AllotId == allot.ID).ToList();
var accountingUnits = attendances.Select(w => w.AccountingUnit).Distinct().ToList(); if (oldEntities.Any())
var oldEntities = _perforPerAttendanceDeptReportRepository.GetEntities(w => w.AllotId == allot.ID && unitTypes.Contains(w.UnitType) && accountingUnits.Contains(w.AccountingUnit));
if (oldEntities?.Any() == true)
{ {
_perforPerAttendanceDeptReportRepository.RemoveRange(oldEntities.ToArray()); _perforPerAttendanceDeptReportRepository.RemoveRange(oldEntities.ToArray());
} }
if (state == (int)Attendance.Report.通过 && newEntities?.Any() == true) if (state == (int)Attendance.Report.通过 && newEntities.Any())
{ {
_perforPerAttendanceDeptReportRepository.AddRange(newEntities.ToArray()); _perforPerAttendanceDeptReportRepository.AddRange(newEntities.ToArray());
} }
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.EntityModels.Entity; using Performance.EntityModels.Entity;
using Performance.EntityModels.Other;
using Performance.Repository; using Performance.Repository;
using Performance.Repository.Repository; using Performance.Repository.Repository;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -313,23 +315,24 @@ public void Copy_Empdetail(per_allot allot, int prevAllotId, bool delHistotyData ...@@ -313,23 +315,24 @@ public void Copy_Empdetail(per_allot allot, int prevAllotId, bool delHistotyData
} }
} }
/// <summary> /// <summary>
/// 加载上月(考勤类型 --- 考勤上报详情 /// 加载上月(考勤类型 )
/// </summary> /// </summary>
/// <param name="allot">当前绩效</param> /// <param name="allot">当前绩效</param>
/// <param name="prevAllotId">上月绩效Id</param> /// <param name="prevAllotId">上月绩效Id</param>
public void Copy_AttendanceType(per_allot allot, int prevAllotId) public void Copy_AttendanceType(per_allot allot, int prevAllotId)
{ {
_logger.LogInformation($"copy attendanceType"); _logger.LogInformation($"加载上月 考勤类型(per_attendance_type)和考勤上报(per_attendance_dept)");
var attendanceTypes = _pperAttendanceTypeRepository.GetEntities(g => g.AllotId == prevAllotId || g.AllotId == allot.ID) ?? new List<per_attendance_type>(); var attendanceTypes = _pperAttendanceTypeRepository.GetEntities(g => g.AllotId == prevAllotId || g.AllotId == allot.ID) ?? new List<per_attendance_type>();
//查询上月有没有类型,没有就跳过 //查询上月有没有类型,没有就跳过
var prevAttTypes = attendanceTypes.Where(w => w.AllotId == prevAllotId).ToList(); var prevAttTypes = attendanceTypes.Where(w => w.AllotId == prevAllotId).ToList();
if (!prevAttTypes.Any()) return; if (!prevAttTypes.Any()) return;
// 删除当月的考勤类型 // 修改当月的考勤类型,加载上月完成在删除
var delAttTypes = attendanceTypes.Where(w => w.AllotId == allot.ID).ToList(); var updataAttTypes = attendanceTypes.Where(w => w.AllotId == allot.ID).ToList();
if (delAttTypes.Any()) if (updataAttTypes.Any())
{ {
_pperAttendanceTypeRepository.RemoveRange(delAttTypes.ToArray()); updataAttTypes.ForEach(w => w.AllotId = 0);
_pperAttendanceTypeRepository.UpdateRange(updataAttTypes.ToArray());
} }
//插入上月的考勤类型 //插入上月的考勤类型
var newAttTypes = prevAttTypes.Select(t => new per_attendance_type var newAttTypes = prevAttTypes.Select(t => new per_attendance_type
...@@ -339,6 +342,9 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId) ...@@ -339,6 +342,9 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId)
HospitalId = t.HospitalId, HospitalId = t.HospitalId,
IsDeduction = t.IsDeduction, IsDeduction = t.IsDeduction,
IsDefault = t.IsDefault, IsDefault = t.IsDefault,
RemarksOne = t.RemarksOne,
RemarksTwo = t.RemarksTwo,
RemarksThree = t.RemarksThree,
}).ToList(); }).ToList();
var successfulType = _pperAttendanceTypeRepository.AddRange(newAttTypes.ToArray()); var successfulType = _pperAttendanceTypeRepository.AddRange(newAttTypes.ToArray());
if (successfulType) if (successfulType)
...@@ -346,12 +352,32 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId) ...@@ -346,12 +352,32 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId)
var prevPerEmployee = _perforPeremployeeRepository.GetEntities(g => g.AllotId == prevAllotId); var prevPerEmployee = _perforPeremployeeRepository.GetEntities(g => g.AllotId == prevAllotId);
if (!prevPerEmployee.Any()) return; if (!prevPerEmployee.Any()) return;
// 删除当月的考勤上报 var attendance_Types = _pperAttendanceTypeRepository.GetEntities(g => g.AllotId == 0).ToList();
var delAttDepts = _perforPerAttendanceDeptRepository.GetEntities(w => w.AllotId == allot.ID).ToList(); // 修改当月的考勤上报
if (delAttDepts.Any()) var updataAttDepts = _perforPerAttendanceDeptRepository.GetEntities(w => w.AllotId == allot.ID).ToList();
if (updataAttDepts.Any())
{ {
_perforPerAttendanceDeptRepository.RemoveRange(delAttDepts.ToArray()); foreach (var att in updataAttDepts)
{
for (int day = 1; day <= 31; day++)
{
string dayPropertyName = $"Day{day:00}";
PropertyInfo dayProperty = typeof(per_attendance_dept).GetProperty(dayPropertyName);
if (dayProperty != null)
{
int? dayValue = (int?)dayProperty.GetValue(att);
var oldDayPropertyName = attendance_Types.FirstOrDefault(w => w.Id == dayValue)?.AttendanceName ?? "考勤类型缺失";
var newDayPropertyName = newAttTypes.FirstOrDefault(w => w.AttendanceName == oldDayPropertyName)?.Id;
if (newDayPropertyName != null)
{
dayProperty.SetValue(att, newDayPropertyName);
}
}
}
}
_perforPerAttendanceDeptRepository.UpdateRange(updataAttDepts.ToArray());
} }
//查询默认考勤类型 //查询默认考勤类型
var typeDefault = newAttTypes.Find(f => f.IsDefault == (int)Attendance.Default.默认); var typeDefault = newAttTypes.Find(f => f.IsDefault == (int)Attendance.Default.默认);
var cofaccounting = _cofaccountingRepository.GetEntities(g => g.AllotId == prevAllotId); var cofaccounting = _cofaccountingRepository.GetEntities(g => g.AllotId == prevAllotId);
...@@ -384,7 +410,9 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId) ...@@ -384,7 +410,9 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId)
}).ToList(); }).ToList();
_perforPerAttendanceDeptRepository.AddRange(newAttDepts.ToArray()); _perforPerAttendanceDeptRepository.AddRange(newAttDepts.ToArray());
_pperAttendanceTypeRepository.RemoveRange(attendance_Types.ToArray());
} }
} }
/// <summary> /// <summary>
/// 加载上月绩效考核 /// 加载上月绩效考核
......
...@@ -213,7 +213,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -213,7 +213,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
} }
data.Add(nobj); data.Add(nobj);
} }
return AllComputerDown(hospital, data, route, title, name, headlist);
}
public string AllComputerDown(sys_hospital hospital, List<Dictionary<string, object>> data, string route, string title, string name, params string[] headlist)
{
var headList = _computeService.CustomColumnHeaders(hospital.ID, route, headlist).Where(w => w.States == 1).ToList(); var headList = _computeService.CustomColumnHeaders(hospital.ID, route, headlist).Where(w => w.States == 1).ToList();
var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease", $"{hospital.ID}"); var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease", $"{hospital.ID}");
...@@ -226,16 +230,16 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -226,16 +230,16 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
using (ExcelPackage package = new ExcelPackage(fs)) using (ExcelPackage package = new ExcelPackage(fs))
{ {
var worksheet = package.Workbook.Worksheets.Add(name); var worksheet = package.Workbook.Worksheets.Add(name);
worksheet.SetValue(1, 1, title);
worksheet.Cells[1, 1, 1, headList.Count].Merge = true;
if (dynamics != null && dynamics.Count() > 0) for (int col = 0; col < headList.Count; col++)
{ {
worksheet.SetValue(1, 1, title); worksheet.SetValue(2, col + 1, headList[col].Alias);
}
var headers = ((IDictionary<string, object>)dynamics.ElementAt(0)).Keys; if (data != null && data.Count() > 0)
for (int col = 0; col < headList.Count; col++) {
{
worksheet.SetValue(2, col + 1, headList[col].Alias);
}
for (int col = 0; col < headList.Count; col++) for (int col = 0; col < headList.Count; col++)
{ {
for (int row = 0; row < data.Count(); row++) for (int row = 0; row < data.Count(); row++)
...@@ -246,42 +250,42 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -246,42 +250,42 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
worksheet.Cells[row + 3, col + 1].Value = value; worksheet.Cells[row + 3, col + 1].Value = value;
} }
if (col == 0) if (col == 0)
worksheet.SetValue(dynamics.Count() + 3, col + 1, "合计"); worksheet.SetValue(data.Count() + 3, col + 1, "合计");
else if (!notSum.Contains(headList[col].Name.ToLower())) else if (!notSum.Contains(headList[col].Name.ToLower()))
worksheet.Cells[dynamics.Count() + 3, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(3, col + 1, dynamics.Count() + 2, col + 1).Address); worksheet.Cells[data.Count() + 3, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(3, col + 1, data.Count() + 2, col + 1).Address);
} }
}
#region 样式设置 #region 样式设置
for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++) for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
{ {
worksheet.Row(row).Height = 20; worksheet.Row(row).Height = 20;
for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
{
if (headList.Count < col && !notSum.Contains(headList[col - 1].Name.ToLower()))
worksheet.Cells[row, col].Style.Numberformat.Format = "#,##0.00";
worksheet.Cells[row, col].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row, col].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
}
}
worksheet.Cells[1, 1, 1, headList.Count].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
worksheet.Cells[1, 1, 1, headList.Count].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Bold = true;
worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Size = 16;
worksheet.Row(1).Height = 24;
worksheet.Cells[2, 1, 2, headList.Count].Style.Font.Bold = true;
worksheet.View.FreezePanes(3, 1);
worksheet.Cells.AutoFitColumns();
for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++) for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
{ {
worksheet.Column(col).Width = worksheet.Column(col).Width > 20 ? 20 : worksheet.Column(col).Width; if (headList.Count < col && !notSum.Contains(headList[col - 1].Name.ToLower()))
worksheet.Cells[row, col].Style.Numberformat.Format = "#,##0.00";
worksheet.Cells[row, col].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row, col].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
} }
#endregion
} }
worksheet.Cells[1, 1, 1, headList.Count].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
worksheet.Cells[1, 1, 1, headList.Count].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Bold = true;
worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Size = 16;
worksheet.Row(1).Height = 24;
worksheet.Cells[2, 1, 2, headList.Count].Style.Font.Bold = true;
worksheet.View.FreezePanes(3, 1);
worksheet.Cells.AutoFitColumns();
for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
{
worksheet.Column(col).Width = worksheet.Column(col).Width > 20 ? 20 : worksheet.Column(col).Width;
}
#endregion
package.Save(); package.Save();
} }
return filepath; return filepath;
} }
public string ExcelDownload(List<Dictionary<string, object>> rows, string name, List<ExcelDownloadHeads> excelDownloadHeads, string[] notSum, string[] ignoreColumns) public string ExcelDownload(List<Dictionary<string, object>> rows, string name, List<ExcelDownloadHeads> excelDownloadHeads, string[] notSum, string[] ignoreColumns)
{ {
var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease"); var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease");
......
...@@ -47,7 +47,7 @@ public List<RoleResponse> GetUserRole(int userid) ...@@ -47,7 +47,7 @@ public List<RoleResponse> GetUserRole(int userid)
public List<sys_role> GetRole(int userid) public List<sys_role> GetRole(int userid)
{ {
if (userid <= 0) if (userid <= 0)
throw new PerformanceException($"userid:{userid} 错误"); throw new PerformanceException($"用户或密码错误");
var joinList = _userroleRepository.GetEntities(t => t.UserID == userid); var joinList = _userroleRepository.GetEntities(t => t.UserID == userid);
if (joinList == null && joinList.Count == 0) if (joinList == null && joinList.Count == 0)
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq;
using Dapper;
using Microsoft.Extensions.Configuration;
using MySql.Data.MySqlClient;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Repository; using Performance.Repository;
...@@ -8,11 +13,12 @@ namespace Performance.Services ...@@ -8,11 +13,12 @@ namespace Performance.Services
{ {
public class TaskService : IAutoInjection public class TaskService : IAutoInjection
{ {
private readonly IConfiguration _configuration;
private readonly PerforBgtaskRepository _taskRepository; private readonly PerforBgtaskRepository _taskRepository;
public TaskService( public TaskService(IConfiguration configuration, PerforBgtaskRepository taskRepository)
PerforBgtaskRepository taskRepository)
{ {
_configuration = configuration;
_taskRepository = taskRepository; _taskRepository = taskRepository;
} }
...@@ -23,7 +29,13 @@ public class TaskService : IAutoInjection ...@@ -23,7 +29,13 @@ public class TaskService : IAutoInjection
/// <returns></returns> /// <returns></returns>
public List<bg_task> GetTasks(int hours = -10) public List<bg_task> GetTasks(int hours = -10)
{ {
return _taskRepository.GetEntities(w => w.CreateTime > DateTime.Now.AddHours(hours)); var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
using var conn = new MySqlConnection(connectionString);
if (conn.State != ConnectionState.Open) conn.Open();
var sql = @"SELECT * FROM bg_task WHERE CreateTime > DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL CAST(@hours AS signed) hour);";
var tasks = conn.Query<bg_task>(sql, new { hours }).ToList();
return tasks;
} }
public bool Add(Background.JobType type, string argument = "") public bool Add(Background.JobType type, string argument = "")
......
...@@ -69,18 +69,18 @@ public UserIdentity Login(LoginRequest request) ...@@ -69,18 +69,18 @@ public UserIdentity Login(LoginRequest request)
{ {
var user = _userRepository.GetEntity(t => t.Login == request.Account && t.IsDelete == 1); var user = _userRepository.GetEntity(t => t.Login == request.Account && t.IsDelete == 1);
if (user == null) if (user == null)
throw new PerformanceException($"{request.Account}”用户不存在"); throw new PerformanceException($"用户或密码错误");
//MD5小写加密 //MD5小写加密
request.Password = PwdHelper.MD5AndSalt(request.Password); request.Password = PwdHelper.MD5AndSalt(request.Password);
if (!user.Password.Equals(request.Password, StringComparison.OrdinalIgnoreCase)) if (!user.Password.Equals(request.Password, StringComparison.OrdinalIgnoreCase))
throw new PerformanceException($"密码错误"); throw new PerformanceException($"用户或密码错误");
var data = _mapper.Map<UserIdentity>(user); var data = _mapper.Map<UserIdentity>(user);
data.Token = Guid.NewGuid().ToString("N"); data.Token = Guid.NewGuid().ToString("N");
return data; return data;
} }
throw new PerformanceException($"登录类型LoginType:{request.LoginType}暂不支持"); throw new PerformanceException($"用户或密码错误");
} }
public UserIdentity GetUser(int userId) public UserIdentity GetUser(int userId)
...@@ -244,7 +244,7 @@ public bool SetHospital(int userId, int[] hosIDArray) ...@@ -244,7 +244,7 @@ public bool SetHospital(int userId, int[] hosIDArray)
{ {
var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1); var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (null == user) if (null == user)
throw new PerformanceException($"用户不存在 UserId:{userId}"); throw new PerformanceException("用户或密码错误");
var userHospital = _userhospitalRepository.GetUserHospital(userId); var userHospital = _userhospitalRepository.GetUserHospital(userId);
bool rmResult = true, addResult = true; bool rmResult = true, addResult = true;
...@@ -277,7 +277,7 @@ public UserResponse UpdateSelf(UserRequest request) ...@@ -277,7 +277,7 @@ public UserResponse UpdateSelf(UserRequest request)
{ {
var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1); var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1);
if (null == user) if (null == user)
throw new PerformanceException($"用户不存在 UserId:{request.ID}"); throw new PerformanceException("用户或密码错误");
var vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Login == request.Login && (t.ParentID == null || t.ParentID == 0) && t.IsDelete == 1); var vlist = _userRepository.GetEntities(t => t.ID != user.ID && t.Login == request.Login && (t.ParentID == null || t.ParentID == 0) && t.IsDelete == 1);
if (null != vlist && vlist.Count() > 0) if (null != vlist && vlist.Count() > 0)
...@@ -306,7 +306,7 @@ public UserResponse UpdatePwd(PasswordRequest request, int userId) ...@@ -306,7 +306,7 @@ public UserResponse UpdatePwd(PasswordRequest request, int userId)
{ {
var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1); var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (null == user) if (null == user)
throw new PerformanceException($"用户不存在 UserId:{userId}"); throw new PerformanceException("用户或密码错误");
if (string.IsNullOrEmpty(request.NewPwd)) if (string.IsNullOrEmpty(request.NewPwd))
throw new PerformanceException($"新密码错误"); throw new PerformanceException($"新密码错误");
...@@ -416,7 +416,7 @@ public UserResponse ResetPwd(int userId, int loginUserId, string password) ...@@ -416,7 +416,7 @@ public UserResponse ResetPwd(int userId, int loginUserId, string password)
{ {
var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1); var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (user == null) if (user == null)
throw new PerformanceException($"用户不存在 UserId:{userId}"); throw new PerformanceException("用户或密码错误");
var loginUser = _userRepository.GetEntity(t => t.ID == loginUserId); var loginUser = _userRepository.GetEntity(t => t.ID == loginUserId);
if (loginUser == null) if (loginUser == null)
...@@ -628,7 +628,7 @@ public ApiResponse DeleteUser(int userId) ...@@ -628,7 +628,7 @@ public ApiResponse DeleteUser(int userId)
//{ //{
// var user = _userRepository.GetEntity(t => t.ID == iD && t.IsDelete == 1); // var user = _userRepository.GetEntity(t => t.ID == iD && t.IsDelete == 1);
// if (null == user) // if (null == user)
// throw new PerformanceException($"用户不存在 UserId:{iD}"); // throw new PerformanceException("用户或密码错误");
// user.IsDelete = 2; // user.IsDelete = 2;
// var result = _userRepository.Remove(user); // var result = _userRepository.Remove(user);
......
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