Commit 84b84d99 by ryun

上传/新增/修改类型限制

parent cb367f2c
...@@ -10,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. ...@@ -10,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform> <LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider> <PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\publish\jx</PublishUrl> <PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod> <WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish /> <SiteUrlToLaunchAfterPublish />
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
......
...@@ -10,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. ...@@ -10,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform> <LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider> <PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\publish\jx.suvalue.com2</PublishUrl> <PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod> <WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish /> <SiteUrlToLaunchAfterPublish />
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
......
using AutoMapper; using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using AutoMapper;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
...@@ -12,12 +18,6 @@ ...@@ -12,12 +18,6 @@
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
using Performance.Repository.Repository; using Performance.Repository.Repository;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -37,17 +37,14 @@ public class EmployeeService : IAutoInjection ...@@ -37,17 +37,14 @@ public class EmployeeService : IAutoInjection
private readonly PerforUserroleRepository userroleRepository; private readonly PerforUserroleRepository userroleRepository;
private readonly PerforPeremployeeRepository peremployeeRepository; private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforUserRepository userRepository; private readonly PerforUserRepository userRepository;
private readonly PerforRoleRepository _roleRepository;
private readonly PerforPerapramounthideRepository _hideRepository; private readonly PerforPerapramounthideRepository _hideRepository;
private readonly PerforExresultgatherRepository exresultgatherRepository; private readonly PerforExresultgatherRepository exresultgatherRepository;
private readonly PerforImheaderRepository imheaderRepository;
private readonly PerforPerdeptdicRepository perdeptdicRepository; private readonly PerforPerdeptdicRepository perdeptdicRepository;
private readonly PerforExmoduleRepository exmoduleRepository; private readonly PerforExmoduleRepository exmoduleRepository;
private readonly PerforExitemRepository exitemRepository; private readonly PerforExitemRepository exitemRepository;
private readonly PerforExspecialRepository exspecialRepository; private readonly PerforExspecialRepository exspecialRepository;
private readonly PerforExresultRepository exresultRepository;
private readonly PerforCollectpermissionRepository perforcollectpermissionRepository; private readonly PerforCollectpermissionRepository perforcollectpermissionRepository;
private ILogger<EmployeeService> logger; private readonly ILogger<EmployeeService> logger;
private readonly RoleService roleService; private readonly RoleService roleService;
private readonly UserService userService; private readonly UserService userService;
private readonly DownloadService downloadService; private readonly DownloadService downloadService;
...@@ -73,10 +70,8 @@ public class EmployeeService : IAutoInjection ...@@ -73,10 +70,8 @@ public class EmployeeService : IAutoInjection
PerforUserroleRepository userroleRepository, PerforUserroleRepository userroleRepository,
PerforPeremployeeRepository peremployeeRepository, PerforPeremployeeRepository peremployeeRepository,
PerforUserRepository userRepository, PerforUserRepository userRepository,
PerforRoleRepository roleRepository,
PerforPerapramounthideRepository hideRepository, PerforPerapramounthideRepository hideRepository,
PerforExresultgatherRepository exresultgatherRepository, PerforExresultgatherRepository exresultgatherRepository,
PerforImheaderRepository imheaderRepository,
PerforPerdeptdicRepository perdeptdicRepository, PerforPerdeptdicRepository perdeptdicRepository,
PerforExmoduleRepository exmoduleRepository, PerforExmoduleRepository exmoduleRepository,
PerforExitemRepository exitemRepository, PerforExitemRepository exitemRepository,
...@@ -106,15 +101,12 @@ PerAprAmountTypeHideRepository perAprAmountTypeHideRepository ...@@ -106,15 +101,12 @@ PerAprAmountTypeHideRepository perAprAmountTypeHideRepository
this.userroleRepository = userroleRepository; this.userroleRepository = userroleRepository;
this.peremployeeRepository = peremployeeRepository; this.peremployeeRepository = peremployeeRepository;
this.userRepository = userRepository; this.userRepository = userRepository;
_roleRepository = roleRepository;
_hideRepository = hideRepository; _hideRepository = hideRepository;
this.exresultgatherRepository = exresultgatherRepository; this.exresultgatherRepository = exresultgatherRepository;
this.imheaderRepository = imheaderRepository;
this.perdeptdicRepository = perdeptdicRepository; this.perdeptdicRepository = perdeptdicRepository;
this.exmoduleRepository = exmoduleRepository; this.exmoduleRepository = exmoduleRepository;
this.exitemRepository = exitemRepository; this.exitemRepository = exitemRepository;
this.exspecialRepository = exspecialRepository; this.exspecialRepository = exspecialRepository;
this.exresultRepository = exresultRepository;
this.perforcollectpermissionRepository = perforcollectpermissionRepository; this.perforcollectpermissionRepository = perforcollectpermissionRepository;
this.logger = logger; this.logger = logger;
this.roleService = roleService; this.roleService = roleService;
...@@ -555,6 +547,10 @@ public bool InsertApr(per_apr_amount request, int userId) ...@@ -555,6 +547,10 @@ public bool InsertApr(per_apr_amount request, int userId)
if (employee == null) if (employee == null)
throw new PerformanceException("工号或姓名信息错误"); throw new PerformanceException("工号或姓名信息错误");
var types = perAprAmountTypeRepository.GetEntities(t => t.AllotId == request.AllotId);
if (types?.Any() == true && !types.Any(w => w.PerforType == request.PerforType))
throw new PerformanceException("“绩效类型”错误,请按规定类型填入");
request.TypeInDepartment = GetTypeInDepartment(userId); request.TypeInDepartment = GetTypeInDepartment(userId);
request.Status = 1; request.Status = 1;
request.CreateUser = userId; request.CreateUser = userId;
...@@ -583,6 +579,10 @@ public bool UpdateApr(per_apr_amount request) ...@@ -583,6 +579,10 @@ public bool UpdateApr(per_apr_amount request)
if (employee == null) if (employee == null)
throw new PerformanceException("工号或姓名信息错误"); throw new PerformanceException("工号或姓名信息错误");
var types = perAprAmountTypeRepository.GetEntities(t => t.AllotId == request.AllotId);
if (types?.Any() == true && !types.Any(w => w.PerforType == request.PerforType))
throw new PerformanceException("“绩效类型”错误,请按规定类型填入");
data.Status = 1; data.Status = 1;
data.PersonnelNumber = request.PersonnelNumber; data.PersonnelNumber = request.PersonnelNumber;
data.DoctorName = request.DoctorName; data.DoctorName = request.DoctorName;
...@@ -713,7 +713,9 @@ public ApiResponse ImportAprEmployees(int allotid, string path, int userid) ...@@ -713,7 +713,9 @@ public ApiResponse ImportAprEmployees(int allotid, string path, int userid)
var typeIn = GetTypeInDepartment(userid); var typeIn = GetTypeInDepartment(userid);
var createtime = DateTime.Now; var createtime = DateTime.Now;
var res = OpenAndReadAprAmountExcel(allotid, path, entities); var types = perAprAmountTypeRepository.GetEntities(t => t.AllotId == allotid) ?? new List<per_apr_amount_type>();
var res = OpenAndReadAprAmountExcel(allotid, path, types.Select(w => w.PerforType).ToList(), entities);
if (res.State == ResponseType.OK) if (res.State == ResponseType.OK)
{ {
if (!entities.Any()) throw new PerformanceException("未能找到有效数据,请检查后重试!"); if (!entities.Any()) throw new PerformanceException("未能找到有效数据,请检查后重试!");
...@@ -737,7 +739,7 @@ public ApiResponse ImportAprEmployees(int allotid, string path, int userid) ...@@ -737,7 +739,7 @@ public ApiResponse ImportAprEmployees(int allotid, string path, int userid)
/// <param name="allotid"></param> /// <param name="allotid"></param>
/// <param name="path"></param> /// <param name="path"></param>
/// <param name="userid"></param> /// <param name="userid"></param>
private ApiResponse OpenAndReadAprAmountExcel(int allotid, string path, List<per_apr_amount> entities) private ApiResponse OpenAndReadAprAmountExcel(int allotid, string path, List<string> types, List<per_apr_amount> entities)
{ {
entities ??= new List<per_apr_amount>(); entities ??= new List<per_apr_amount>();
try try
...@@ -845,9 +847,21 @@ private ApiResponse OpenAndReadAprAmountExcel(int allotid, string path, List<per ...@@ -845,9 +847,21 @@ private ApiResponse OpenAndReadAprAmountExcel(int allotid, string path, List<per
{ "错误原因", "“姓名”与人员字典不一致,请修改或删除" }, { "错误原因", "“姓名”与人员字典不一致,请修改或删除" },
}); });
} }
else if (types.Any() && !types.Any(type => type == entity.PerforType))
{
errors.Add(new Dictionary<string, string>
{
{ "行号", $"第{rowindex}行" },
{ "人员工号", entity.PersonnelNumber },
{ "姓名", entity.DoctorName },
{ "来源", "上传文件" },
{ "错误原因", "“绩效类型”错误,请按规定类型填入" },
});
}
entities.Add(entity); entities.Add(entity);
} }
if (errors.Count > 0) return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", errors); if (errors.Count > 0) return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", errors);
} }
catch (Exception ex) catch (Exception ex)
...@@ -1196,6 +1210,10 @@ public bool InsertAprHide(per_apr_amount_hide request, int userId) ...@@ -1196,6 +1210,10 @@ public bool InsertAprHide(per_apr_amount_hide request, int userId)
if (employee == null) if (employee == null)
throw new PerformanceException("工号在字典中不存在"); throw new PerformanceException("工号在字典中不存在");
var types = perAprAmountTypeHIdeRepository.GetEntities(t => t.AllotId == request.AllotId);
if (types?.Any() == true && !types.Any(w => w.PerforType == request.PerforType))
throw new PerformanceException("“绩效类型”错误,请按规定类型填入");
request.TypeInDepartment = GetTypeInDepartment(userId); request.TypeInDepartment = GetTypeInDepartment(userId);
request.Status = 1; request.Status = 1;
request.CreateUser = userId; request.CreateUser = userId;
...@@ -1220,6 +1238,10 @@ public bool UpdateAprHide(per_apr_amount_hide request) ...@@ -1220,6 +1238,10 @@ public bool UpdateAprHide(per_apr_amount_hide request)
if (data == null) if (data == null)
throw new PerformanceException("修改数据无效"); throw new PerformanceException("修改数据无效");
var types = perAprAmountTypeHIdeRepository.GetEntities(t => t.AllotId == request.AllotId);
if (types?.Any() == true && !types.Any(w => w.PerforType == request.PerforType))
throw new PerformanceException("“绩效类型”错误,请按规定类型填入");
data.Status = 1; data.Status = 1;
data.PersonnelNumber = request.PersonnelNumber; data.PersonnelNumber = request.PersonnelNumber;
data.DoctorName = request.DoctorName; data.DoctorName = request.DoctorName;
...@@ -1352,7 +1374,9 @@ public ApiResponse ImportAprHideEmployees(int allotid, string path, int userid) ...@@ -1352,7 +1374,9 @@ public ApiResponse ImportAprHideEmployees(int allotid, string path, int userid)
var typeIn = GetTypeInDepartment(userid); var typeIn = GetTypeInDepartment(userid);
var createtime = DateTime.Now; var createtime = DateTime.Now;
var res = OpenAndReadAprAmountExcel(allotid, path, entities); var types = perAprAmountTypeHIdeRepository.GetEntities(t => t.AllotId == allotid) ?? new List<per_apr_amount_hide_type>();
var res = OpenAndReadAprAmountExcel(allotid, path, types.Select(w => w.PerforType).ToList(), entities);
if (res.State == ResponseType.OK) if (res.State == ResponseType.OK)
{ {
if (!entities.Any()) throw new PerformanceException("未能找到有效数据,请检查后重试!"); if (!entities.Any()) throw new PerformanceException("未能找到有效数据,请检查后重试!");
......
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