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)
{
var user = _userService.Login(request);
if (user == null)
return new ApiResponse<JwtToken>(ResponseType.Fail, "用户不存在");
return new ApiResponse<JwtToken>(ResponseType.Fail, "用户或密码错误");
var claims = new List<Claim>
{
......
......@@ -180,6 +180,27 @@ public ApiResponse DeleteAttendanceType(int 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>
/// 加载默认考勤类型
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FluentValidation.AspNetCore;
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.StaticFiles;
using Performance.DtoModels;
using Performance.DtoModels.Request;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Performance.Api.Controllers
{
[Route("api/[controller]")]
public class ComputeController : Controller
{
private ComputeService _computeService;
private readonly ComputeService _computeService;
private readonly DapperService _service;
private AllotService _allotService;
private ClaimService _claim;
private EmployeeService _employeeService;
private readonly AllotService _allotService;
private readonly HospitalService _hospitalService;
private readonly ClaimService _claim;
private readonly DownloadService downloadService;
public ComputeController(
DapperService service,
AllotService allotService,
HospitalService hospitalService,
ComputeService computeService,
EmployeeService employeeService,
DownloadService downloadService,
ClaimService claim)
{
_service = service;
_allotService = allotService;
_hospitalService = hospitalService;
_computeService = computeService;
_employeeService = employeeService;
this.downloadService = downloadService;
_claim = claim;
}
......@@ -711,17 +713,37 @@ public ApiResponse GethosdataView([FromBody] ComputerRequest request)
/// 全院核算绩效发放(视图) 下载
/// </summary>
/// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns>
[Route("gethosdataView/download/{allotId}")]
[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);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
unitType ??= ""; accountingUnit ??= ""; content ??= "";
var hospital = _hospitalService.GetHopital(allot.HospitalId);
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 list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_dept");
var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/print/compute", "全院核算绩效发放");
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();
using (var stream = new FileStream(filepath, FileMode.Open))
......@@ -757,17 +779,38 @@ public ApiResponse AllComputeView([FromBody] ComputerRequest request)
/// 下载全院绩效列表
/// </summary>
/// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns>
[Route("allcomputeView/download/{allotId}")]
[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);
if (null == allot)
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 filepath = downloadService.AllComputerViewReport(allotId, list, "/result/compute", "全院绩效发放");
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/compute", title, "全院绩效发放");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
......@@ -807,17 +850,38 @@ public ApiResponse AllComputeViewByPM([FromBody] ComputerRequest request)
/// 下载全院绩效列表(人事科)
/// </summary>
/// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns>
[Route("allcomputeView/personnel/download/{allotId}")]
[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);
if (null == allot)
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 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();
using (var stream = new FileStream(filepath, FileMode.Open))
......
......@@ -611,6 +611,18 @@
<param name="id"></param>
<returns></returns>
</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)">
<summary>
加载默认考勤类型
......@@ -1227,11 +1239,14 @@
<param name="request"></param>
<returns></returns>
</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>
<param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeView(Performance.DtoModels.ComputerRequest)">
......@@ -1241,11 +1256,14 @@
<param name="request"></param>
<returns></returns>
</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>
<param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewByPM(Performance.DtoModels.ComputerRequest)">
......@@ -1255,11 +1273,14 @@
<param name="request"></param>
<returns></returns>
</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>
<param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetDrugtypeList(Performance.DtoModels.DrugpropRequest)">
......
......@@ -6511,6 +6511,21 @@
是否默认值 0 非默认 1 默认
</summary>
</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">
<summary>
......@@ -10461,6 +10476,21 @@
是否默认值 0 非默认 1 默认
</summary>
</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">
<summary>
His科室
......
......@@ -19,5 +19,18 @@ public class per_attendance_type
/// 是否默认值 0 非默认 1 默认
/// </summary>
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
/// 是否默认值 0 非默认 1 默认
/// </summary>
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 @@
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using Masuit.Tools.Models;
using Microsoft.EntityFrameworkCore;
using Performance.DtoModels;
using Performance.EntityModels;
......@@ -69,28 +70,23 @@ public new List<AccountUnit> GetEmployeeUnit(Expression<Func<per_employee, bool>
/// <returns></returns>
public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(ComparisonPagingRequest request)
{
var queryData = $@"
SELECT
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
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
GROUP BY HospitalId,Year,Month,AllotID,UnitType,AccountingUnit,JobNumber
ORDER BY HospitalId,Year,Month,ABS(SUM(RealGiveFeeExecl) - SUM(RealGiveFeeCompute)) DESC LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize}
";
var queryCount = @"
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
";
var queryData = $@"CALL proc_allot_check_emp(@allotId);";
var checkEmps = DapperQuery<view_check_emp>(queryData, new { allotId = request.AllotId });
request.SearchQuery = request.SearchQuery?.Clean();
if (!string.IsNullOrEmpty(request.SearchQuery))
{
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))
|| (!string.IsNullOrEmpty(w.EmployeeName) && w.EmployeeName.Contains(request.SearchQuery)));
}
checkEmps = checkEmps.OrderByDescending(w => Math.Abs(w.Diff ?? 0));
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>(),
TotalCount = DapperQuery<int>(queryCount, new { allotId = request.AllotId, searchQuery = request.SearchQuery, parm = $"%{request.SearchQuery}%" }, commandTimeout: 10000)?.FirstOrDefault() ?? 0,
Datas = checkEmps.ToPagedList(request.PageIndex, request.PageSize).Data,
TotalCount = checkEmps.Count(),
};
}
......@@ -99,26 +95,23 @@ public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(Compari
/// </summary>
public DtoModels.Comparison<view_check_emp> CheckAccountingUnitRealGiveFeeDiff(ComparisonPagingRequest request)
{
var queryData = $@"
SELECT *,IFNULL(RealGiveFeeExecl,0) - IFNULL(RealGiveFeeCompute,0) AS Diff FROM (
SELECT * FROM view_check_dept_account WHERE AllotId = @allotId UNION ALL
SELECT * FROM view_check_dept_specialunit WHERE AllotId = @allotId
) TAB
WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm
ORDER BY HospitalId,Year,Month,ABS(DIFF) DESC LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize}
";
var queryCount = @"
SELECT count(0) FROM (
SELECT * FROM view_check_dept_account WHERE AllotId = @allotId UNION ALL
SELECT * FROM view_check_dept_specialunit WHERE AllotId = @allotId
) TAB
WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm
";
var queryData = $@"CALL proc_allot_check_dept(@allotId);";
var checkEmps = DapperQuery<view_check_emp>(queryData, new { allotId = request.AllotId });
request.SearchQuery = request.SearchQuery?.Clean();
if (!string.IsNullOrEmpty(request.SearchQuery))
{
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))
|| (!string.IsNullOrEmpty(w.EmployeeName) && w.EmployeeName.Contains(request.SearchQuery)));
}
checkEmps = checkEmps.OrderByDescending(w => Math.Abs(w.Diff ?? 0));
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>(),
TotalCount = DapperQuery<int>(queryCount, new { allotId = request.AllotId, searchQuery = request.SearchQuery, parm = $"%{request.SearchQuery}%" })?.FirstOrDefault() ?? 0,
Datas = checkEmps.ToPagedList(request.PageIndex, request.PageSize).Data,
TotalCount = checkEmps.Count(),
};
}
......@@ -127,17 +120,17 @@ public DtoModels.Comparison<view_check_emp> CheckAccountingUnitRealGiveFeeDiff(C
/// </summary>
public DtoModels.Comparison<DeptComparisonTotal> CheckView_check_deptUnitRealGiveFeeDiffTotal(int allotId)
{
var queryData = @"SELECT UnitType,Count(1) Count,Sum(RealGiveFeeCompute) SumFee FROM
(SELECT *,IFNULL(RealGiveFeeExecl,0) - IFNULL(RealGiveFeeCompute,0) AS Diff FROM (
SELECT * FROM view_check_dept_account UNION ALL
SELECT * FROM view_check_dept_specialunit
) 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>()
var queryData = $@"CALL proc_allot_check_dept(@allotId);";
var checkEmps = DapperQuery<view_check_emp>(queryData, new { allotId });
var list = checkEmps.Where(w => w.Diff != 0).ToList();
var datas = list.GroupBy(w => w.UnitType).Select(w => new 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()
......
......@@ -2,10 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Infrastructure.Extensions;
using Performance.Repository;
namespace Performance.Services.AllotCompute
......@@ -15,6 +17,7 @@ namespace Performance.Services.AllotCompute
/// </summary>
public class ProcessComputService : IAutoInjection
{
private readonly IConfiguration _configuration;
private readonly IMapper _mapper;
private readonly IOptions<Application> _options;
private readonly BudgetService _budgetService;
......@@ -34,6 +37,7 @@ public class ProcessComputService : IAutoInjection
private readonly PerforPerallotRepository perallotRepository;
public ProcessComputService(
IConfiguration configuration,
IMapper mapper,
IOptions<Application> options,
BudgetService budgetService,
......@@ -52,6 +56,7 @@ public class ProcessComputService : IAutoInjection
PerforHospitalRepository hospitalRepository,
PerforPerallotRepository perallotRepository)
{
_configuration = configuration;
_mapper = mapper;
_options = options;
_budgetService = budgetService;
......@@ -103,15 +108,14 @@ private void SaveComputeAccount(PerSheet sheet, int allotId)
perforPerSheetRepository.Add(imsheet);
var dataList = sheet.PerData.Select(t => (PerDataAccountBaisc)t);
List<res_account> addList = new List<res_account>();
foreach (var data in dataList)
List<res_account> addList = _mapper.Map<List<res_account>>(dataList);
foreach (var data in addList)
{
var imdata = _mapper.Map<res_account>(data);
imdata.SheetID = imsheet.ID;
imdata.AllotID = allotId;
addList.Add(imdata);
data.SheetID = imsheet.ID;
data.AllotID = allotId;
}
perforResaccountRepository.AddRange(addList.ToArray());
var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
DapperExtensions.BulkInsert(connectionString, addList, tableName: "res_account", commandTimeout: 60 * 60 * 5);
}
/// <summary>
......@@ -122,6 +126,7 @@ private void SaveComputeAccount(PerSheet sheet, int allotId)
/// <returns></returns>
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 };
perforPerSheetRepository.Add(imsheet);
......@@ -144,18 +149,16 @@ private void SaveCommon(PerSheet sheet, int allotId)
}
}
}
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);
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);
imdata.SheetID = imsheet.ID;
imdata.AllotID = allotId;
addDataList.Add(imdata);
data.SheetID = imsheet.ID;
data.AllotID = allotId;
}
perforImDataRepository.AddRange(addDataList.ToArray());
DapperExtensions.BulkInsert(connectionString, addDataList, tableName: "im_data", commandTimeout: 60 * 60 * 5);
}
/// <summary>
......
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using AutoMapper;
using AutoMapper;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OfficeOpenXml;
......@@ -16,6 +12,11 @@
using Performance.Repository;
using Performance.Services.AllotCompute;
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
namespace Performance.Services
{
......@@ -23,6 +24,7 @@ public class AllotService : IAutoInjection
{
private BaiscNormService baiscNormService;
private ImportDataService importDataService;
private readonly EPImportDataService _epImportDataService;
private ProcessComputService processComputService;
private ResultComputeService resultComputeService;
private PerforLogdbugRepository logdbug;
......@@ -36,6 +38,7 @@ public class AllotService : IAutoInjection
private IEmailService emailService;
private readonly IOptions<Application> options;
private readonly IOptions<AppConnection> _appConnection;
private readonly IConfiguration _configuration;
private readonly ComputeDirector _computeDirector;
private readonly PerforRescomputeRepository _perforRescomputeRepository;
private readonly PerforImemployeeRepository _perforImEmployeeRepository;
......@@ -62,6 +65,7 @@ public class AllotService : IAutoInjection
PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService,
ImportDataService importDataService,
EPImportDataService epImportDataService,
ProcessComputService processComputService,
ResultComputeService resultComputeService,
ConfigService configService,
......@@ -70,6 +74,7 @@ public class AllotService : IAutoInjection
IEmailService emailService,
IOptions<Application> options,
IOptions<AppConnection> appConnection,
IConfiguration configuration,
ComputeDirector computeDirector,
PerforRescomputeRepository perforRescomputeRepository,
PerforImemployeeRepository perforImEmployeeRepository,
......@@ -97,11 +102,13 @@ public class AllotService : IAutoInjection
_evn = evn;
this.baiscNormService = baiscNormService;
this.importDataService = importDataService;
_epImportDataService = epImportDataService;
this.processComputService = processComputService;
this.resultComputeService = resultComputeService;
this.emailService = emailService;
this.options = options;
_appConnection = appConnection;
_configuration = configuration;
_computeDirector = computeDirector;
_perforRescomputeRepository = perforRescomputeRepository;
_perforImEmployeeRepository = perforImEmployeeRepository;
......@@ -338,10 +345,22 @@ public void Generate(per_allot allot)
logManageService.WriteMsg("绩效开始执行", $"数据来源:用户上传的Excel。", 1, allot.ID, "ReceiveMessage", true);
configService.Clear(allot.ID);
var useNewRead = _configuration.GetValue("AllotFileReadOption:UseNewRead", true);
if (useNewRead)
{
_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))
//{
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
......@@ -895,7 +896,7 @@ public PagedList<AssessSchemeResultListResponse> SchemeResultList(QuerySchemeRes
if (!string.IsNullOrEmpty(query.TargetAccountingUnit))
viewAResultQuery = viewAResultQuery.Where(w => w.TargetAccountingUnit == query.TargetAccountingUnit);
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)
throw new PerformanceException("暂无数据");
......
......@@ -2,11 +2,13 @@
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.EntityModels.Entity;
using Performance.EntityModels.Other;
using Performance.Repository;
using Performance.Repository.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Performance.Services
{
......@@ -313,23 +315,24 @@ public void Copy_Empdetail(per_allot allot, int prevAllotId, bool delHistotyData
}
}
/// <summary>
/// 加载上月(考勤类型 --- 考勤上报详情
/// 加载上月(考勤类型 )
/// </summary>
/// <param name="allot">当前绩效</param>
/// <param name="prevAllotId">上月绩效Id</param>
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 prevAttTypes = attendanceTypes.Where(w => w.AllotId == prevAllotId).ToList();
if (!prevAttTypes.Any()) return;
// 删除当月的考勤类型
var delAttTypes = attendanceTypes.Where(w => w.AllotId == allot.ID).ToList();
if (delAttTypes.Any())
// 修改当月的考勤类型,加载上月完成在删除
var updataAttTypes = attendanceTypes.Where(w => w.AllotId == allot.ID).ToList();
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
......@@ -339,6 +342,9 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId)
HospitalId = t.HospitalId,
IsDeduction = t.IsDeduction,
IsDefault = t.IsDefault,
RemarksOne = t.RemarksOne,
RemarksTwo = t.RemarksTwo,
RemarksThree = t.RemarksThree,
}).ToList();
var successfulType = _pperAttendanceTypeRepository.AddRange(newAttTypes.ToArray());
if (successfulType)
......@@ -346,12 +352,32 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId)
var prevPerEmployee = _perforPeremployeeRepository.GetEntities(g => g.AllotId == prevAllotId);
if (!prevPerEmployee.Any()) return;
// 删除当月的考勤上报
var delAttDepts = _perforPerAttendanceDeptRepository.GetEntities(w => w.AllotId == allot.ID).ToList();
if (delAttDepts.Any())
var attendance_Types = _pperAttendanceTypeRepository.GetEntities(g => g.AllotId == 0).ToList();
// 修改当月的考勤上报
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 cofaccounting = _cofaccountingRepository.GetEntities(g => g.AllotId == prevAllotId);
......@@ -384,7 +410,9 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId)
}).ToList();
_perforPerAttendanceDeptRepository.AddRange(newAttDepts.ToArray());
_pperAttendanceTypeRepository.RemoveRange(attendance_Types.ToArray());
}
}
/// <summary>
/// 加载上月绩效考核
......
......@@ -213,7 +213,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
}
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 dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease", $"{hospital.ID}");
......@@ -226,16 +230,16 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
using (ExcelPackage package = new ExcelPackage(fs))
{
var worksheet = package.Workbook.Worksheets.Add(name);
if (dynamics != null && dynamics.Count() > 0)
{
worksheet.SetValue(1, 1, title);
worksheet.Cells[1, 1, 1, headList.Count].Merge = true;
var headers = ((IDictionary<string, object>)dynamics.ElementAt(0)).Keys;
for (int col = 0; col < headList.Count; col++)
{
worksheet.SetValue(2, col + 1, headList[col].Alias);
}
if (data != null && data.Count() > 0)
{
for (int col = 0; col < headList.Count; col++)
{
for (int row = 0; row < data.Count(); row++)
......@@ -246,11 +250,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
worksheet.Cells[row + 3, col + 1].Value = value;
}
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()))
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 样式设置
for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
{
......@@ -277,11 +281,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
worksheet.Column(col).Width = worksheet.Column(col).Width > 20 ? 20 : worksheet.Column(col).Width;
}
#endregion
}
package.Save();
}
return filepath;
}
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");
......
......@@ -47,7 +47,7 @@ public List<RoleResponse> GetUserRole(int userid)
public List<sys_role> GetRole(int userid)
{
if (userid <= 0)
throw new PerformanceException($"userid:{userid} 错误");
throw new PerformanceException($"用户或密码错误");
var joinList = _userroleRepository.GetEntities(t => t.UserID == userid);
if (joinList == null && joinList.Count == 0)
......
using System;
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.EntityModels;
using Performance.Repository;
......@@ -8,11 +13,12 @@ namespace Performance.Services
{
public class TaskService : IAutoInjection
{
private readonly IConfiguration _configuration;
private readonly PerforBgtaskRepository _taskRepository;
public TaskService(
PerforBgtaskRepository taskRepository)
public TaskService(IConfiguration configuration, PerforBgtaskRepository taskRepository)
{
_configuration = configuration;
_taskRepository = taskRepository;
}
......@@ -23,7 +29,13 @@ public class TaskService : IAutoInjection
/// <returns></returns>
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 = "")
......
......@@ -69,18 +69,18 @@ public UserIdentity Login(LoginRequest request)
{
var user = _userRepository.GetEntity(t => t.Login == request.Account && t.IsDelete == 1);
if (user == null)
throw new PerformanceException($"{request.Account}”用户不存在");
throw new PerformanceException($"用户或密码错误");
//MD5小写加密
request.Password = PwdHelper.MD5AndSalt(request.Password);
if (!user.Password.Equals(request.Password, StringComparison.OrdinalIgnoreCase))
throw new PerformanceException($"密码错误");
throw new PerformanceException($"用户或密码错误");
var data = _mapper.Map<UserIdentity>(user);
data.Token = Guid.NewGuid().ToString("N");
return data;
}
throw new PerformanceException($"登录类型LoginType:{request.LoginType}暂不支持");
throw new PerformanceException($"用户或密码错误");
}
public UserIdentity GetUser(int userId)
......@@ -244,7 +244,7 @@ public bool SetHospital(int userId, int[] hosIDArray)
{
var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (null == user)
throw new PerformanceException($"用户不存在 UserId:{userId}");
throw new PerformanceException("用户或密码错误");
var userHospital = _userhospitalRepository.GetUserHospital(userId);
bool rmResult = true, addResult = true;
......@@ -277,7 +277,7 @@ public UserResponse UpdateSelf(UserRequest request)
{
var user = _userRepository.GetEntity(t => t.ID == request.ID && t.IsDelete == 1);
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);
if (null != vlist && vlist.Count() > 0)
......@@ -306,7 +306,7 @@ public UserResponse UpdatePwd(PasswordRequest request, int userId)
{
var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (null == user)
throw new PerformanceException($"用户不存在 UserId:{userId}");
throw new PerformanceException("用户或密码错误");
if (string.IsNullOrEmpty(request.NewPwd))
throw new PerformanceException($"新密码错误");
......@@ -416,7 +416,7 @@ public UserResponse ResetPwd(int userId, int loginUserId, string password)
{
var user = _userRepository.GetEntity(t => t.ID == userId && t.IsDelete == 1);
if (user == null)
throw new PerformanceException($"用户不存在 UserId:{userId}");
throw new PerformanceException("用户或密码错误");
var loginUser = _userRepository.GetEntity(t => t.ID == loginUserId);
if (loginUser == null)
......@@ -628,7 +628,7 @@ public ApiResponse DeleteUser(int userId)
//{
// var user = _userRepository.GetEntity(t => t.ID == iD && t.IsDelete == 1);
// if (null == user)
// throw new PerformanceException($"用户不存在 UserId:{iD}");
// throw new PerformanceException("用户或密码错误");
// user.IsDelete = 2;
// 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