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()
......
...@@ -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("暂无数据");
......
...@@ -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