Commit 84b84d99 by ryun

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

parent cb367f2c
......@@ -3,18 +3,18 @@
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\publish\jx</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net5.0</TargetFramework>
<ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net5.0</TargetFramework>
<ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -3,18 +3,18 @@
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\publish\jx.suvalue.com2</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net5.0</TargetFramework>
<ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net5.0</TargetFramework>
<ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
\ No newline at end of file
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 Newtonsoft.Json;
using NPOI.HSSF.UserModel;
......@@ -12,12 +18,6 @@
using Performance.Infrastructure;
using Performance.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
{
......@@ -37,17 +37,14 @@ public class EmployeeService : IAutoInjection
private readonly PerforUserroleRepository userroleRepository;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforUserRepository userRepository;
private readonly PerforRoleRepository _roleRepository;
private readonly PerforPerapramounthideRepository _hideRepository;
private readonly PerforExresultgatherRepository exresultgatherRepository;
private readonly PerforImheaderRepository imheaderRepository;
private readonly PerforPerdeptdicRepository perdeptdicRepository;
private readonly PerforExmoduleRepository exmoduleRepository;
private readonly PerforExitemRepository exitemRepository;
private readonly PerforExspecialRepository exspecialRepository;
private readonly PerforExresultRepository exresultRepository;
private readonly PerforCollectpermissionRepository perforcollectpermissionRepository;
private ILogger<EmployeeService> logger;
private readonly ILogger<EmployeeService> logger;
private readonly RoleService roleService;
private readonly UserService userService;
private readonly DownloadService downloadService;
......@@ -73,10 +70,8 @@ public class EmployeeService : IAutoInjection
PerforUserroleRepository userroleRepository,
PerforPeremployeeRepository peremployeeRepository,
PerforUserRepository userRepository,
PerforRoleRepository roleRepository,
PerforPerapramounthideRepository hideRepository,
PerforExresultgatherRepository exresultgatherRepository,
PerforImheaderRepository imheaderRepository,
PerforPerdeptdicRepository perdeptdicRepository,
PerforExmoduleRepository exmoduleRepository,
PerforExitemRepository exitemRepository,
......@@ -106,15 +101,12 @@ PerAprAmountTypeHideRepository perAprAmountTypeHideRepository
this.userroleRepository = userroleRepository;
this.peremployeeRepository = peremployeeRepository;
this.userRepository = userRepository;
_roleRepository = roleRepository;
_hideRepository = hideRepository;
this.exresultgatherRepository = exresultgatherRepository;
this.imheaderRepository = imheaderRepository;
this.perdeptdicRepository = perdeptdicRepository;
this.exmoduleRepository = exmoduleRepository;
this.exitemRepository = exitemRepository;
this.exspecialRepository = exspecialRepository;
this.exresultRepository = exresultRepository;
this.perforcollectpermissionRepository = perforcollectpermissionRepository;
this.logger = logger;
this.roleService = roleService;
......@@ -555,6 +547,10 @@ public bool InsertApr(per_apr_amount request, int userId)
if (employee == null)
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.Status = 1;
request.CreateUser = userId;
......@@ -583,6 +579,10 @@ public bool UpdateApr(per_apr_amount request)
if (employee == null)
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.PersonnelNumber = request.PersonnelNumber;
data.DoctorName = request.DoctorName;
......@@ -713,7 +713,9 @@ public ApiResponse ImportAprEmployees(int allotid, string path, int userid)
var typeIn = GetTypeInDepartment(userid);
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 (!entities.Any()) throw new PerformanceException("未能找到有效数据,请检查后重试!");
......@@ -737,7 +739,7 @@ public ApiResponse ImportAprEmployees(int allotid, string path, int userid)
/// <param name="allotid"></param>
/// <param name="path"></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>();
try
......@@ -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);
}
if (errors.Count > 0) return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", errors);
}
catch (Exception ex)
......@@ -1196,6 +1210,10 @@ public bool InsertAprHide(per_apr_amount_hide request, int userId)
if (employee == null)
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.Status = 1;
request.CreateUser = userId;
......@@ -1220,6 +1238,10 @@ public bool UpdateAprHide(per_apr_amount_hide request)
if (data == null)
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.PersonnelNumber = request.PersonnelNumber;
data.DoctorName = request.DoctorName;
......@@ -1352,7 +1374,9 @@ public ApiResponse ImportAprHideEmployees(int allotid, string path, int userid)
var typeIn = GetTypeInDepartment(userid);
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 (!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