Commit e98888c7 by 1391696987

完成禅道403、411、415、409、417任务

parent 6aeb04eb
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels.Entity;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository.Repository;
using Performance.Services; using Performance.Services;
using Performance.Services.AllotCompute; using Performance.Services.AllotCompute;
using Performance.Services.ExtractExcelService; using Performance.Services.ExtractExcelService;
...@@ -36,6 +38,8 @@ public class AllotController : Controller ...@@ -36,6 +38,8 @@ public class AllotController : Controller
private LogManageService _logManageService; private LogManageService _logManageService;
private readonly TaskService _taskService; private readonly TaskService _taskService;
private readonly CostTransferService costTransferService; private readonly CostTransferService costTransferService;
private readonly PerforPerAllotActionRepository perforPerAllotActionRepository;
//private IBackgroundTaskQueue _backgroundTaskQueue; //private IBackgroundTaskQueue _backgroundTaskQueue;
private IServiceScopeFactory _serviceScopeFactory; private IServiceScopeFactory _serviceScopeFactory;
...@@ -49,7 +53,8 @@ public class AllotController : Controller ...@@ -49,7 +53,8 @@ public class AllotController : Controller
ClaimService claim, ClaimService claim,
LogManageService logManageService, LogManageService logManageService,
TaskService taskService, TaskService taskService,
CostTransferService costTransferService) CostTransferService costTransferService,
PerforPerAllotActionRepository perforPerAllotActionRepository)
{ {
_allotService = allotService; _allotService = allotService;
_resultComputeService = resultComputeService; _resultComputeService = resultComputeService;
...@@ -59,6 +64,7 @@ public class AllotController : Controller ...@@ -59,6 +64,7 @@ public class AllotController : Controller
_logManageService = logManageService; _logManageService = logManageService;
_taskService = taskService; _taskService = taskService;
this.costTransferService = costTransferService; this.costTransferService = costTransferService;
this.perforPerAllotActionRepository = perforPerAllotActionRepository;
_configService = configService; _configService = configService;
//_backgroundTaskQueue = backgroundTaskQueue; //_backgroundTaskQueue = backgroundTaskQueue;
_serviceScopeFactory = serviceScopeFactory; _serviceScopeFactory = serviceScopeFactory;
...@@ -104,6 +110,9 @@ public ApiResponse Insert([FromBody] AllotRequest request) ...@@ -104,6 +110,9 @@ public ApiResponse Insert([FromBody] AllotRequest request)
_configService.Copy(result); _configService.Copy(result);
//带出上月划拨记录 //带出上月划拨记录
costTransferService.IntoLastTiemData(request.HospitalId.Value, result.ID); costTransferService.IntoLastTiemData(request.HospitalId.Value, result.ID);
LogAllotAction(result.ID, result.Path, "创建");
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
...@@ -179,6 +188,8 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -179,6 +188,8 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (!_allotService.Update(allot)) if (!_allotService.Update(allot))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败"); return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
_configService.Clear(allot.ID); _configService.Clear(allot.ID);
LogAllotAction(allot.ID, allot.Path, "上传");
} }
//var email = _claim.GetUserClaim(JwtClaimTypes.Mail); //var email = _claim.GetUserClaim(JwtClaimTypes.Mail);
...@@ -386,6 +397,9 @@ public ApiResponse Pigeonhole([CustomizeValidator(RuleSet = "Delete"), FromBody] ...@@ -386,6 +397,9 @@ public ApiResponse Pigeonhole([CustomizeValidator(RuleSet = "Delete"), FromBody]
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件"); throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
_allotService.Pigeonhole(allot); _allotService.Pigeonhole(allot);
_taskService.Add(Background.JobType.每日汇报表汇总, allot.ID.ToString()); _taskService.Add(Background.JobType.每日汇报表汇总, allot.ID.ToString());
LogAllotAction(allot.ID, allot.Path, "归档");
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
...@@ -462,6 +476,8 @@ public ApiResponse Issued([FromBody] AllotRequest request) ...@@ -462,6 +476,8 @@ public ApiResponse Issued([FromBody] AllotRequest request)
_taskService.Add(Background.JobType.每日汇报表汇总, allot.ID.ToString()); _taskService.Add(Background.JobType.每日汇报表汇总, allot.ID.ToString());
LogAllotAction(allot.ID, allot.Path, "下发");
return new ApiResponse(ResponseType.OK, "下发成功"); return new ApiResponse(ResponseType.OK, "下发成功");
} }
else else
...@@ -583,5 +599,22 @@ public ApiResponse<List<OwnerMobilePerformanceDto>> GetOwnerMobilePerformance(st ...@@ -583,5 +599,22 @@ public ApiResponse<List<OwnerMobilePerformanceDto>> GetOwnerMobilePerformance(st
var dtos = _allotService.GetOwnerMobilePerformance(userid, beginDate, endDate); var dtos = _allotService.GetOwnerMobilePerformance(userid, beginDate, endDate);
return new ApiResponse<List<OwnerMobilePerformanceDto>>(ResponseType.OK, dtos); return new ApiResponse<List<OwnerMobilePerformanceDto>>(ResponseType.OK, dtos);
} }
/// <summary>
/// 记录创建、下发、归档、上传绩效
/// </summary>
private void LogAllotAction(int allotId, string path, string actionName)
{
per_allot_action per_Allot_Action = new per_allot_action()
{
AllotId = allotId,
CreateDate = DateTime.Now,
CreateUser = _claim.GetUserId(),
FilePath = path,
ActionName = actionName
};
perforPerAllotActionRepository.Add(per_Allot_Action);
}
} }
} }
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.DtoModels.Second; using Performance.DtoModels.Second;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Hosting;
using System.IO;
using Microsoft.AspNetCore.StaticFiles;
namespace Performance.Api.Controllers namespace Performance.Api.Controllers
{ {
...@@ -947,5 +950,49 @@ public ApiResponse RedistributionDetail([FromBody] SecondBaseDto request) ...@@ -947,5 +950,49 @@ public ApiResponse RedistributionDetail([FromBody] SecondBaseDto request)
return new ApiResponse(ResponseType.OK, new { Head = head, Body = rows, Dic = dic }); return new ApiResponse(ResponseType.OK, new { Head = head, Body = rows, Dic = dic });
} }
#endregion #endregion
/// <summary>
/// 二次绩效上传文件
/// </summary>
/// <param name="secondid"></param>
/// <param name="form"></param>
/// <returns></returns>
[Route("api/second/import")]
[HttpPost]
public ApiResponse Import([FromForm] IFormCollection form)
{
return secondAllotService.Import(form);
}
/// <summary>
/// 二次绩效下载文件
/// </summary>
/// <param name="secondid"></param>
/// <returns></returns>
[Route("api/second/download/{secondid}")]
[HttpGet]
[AllowAnonymous]
public IActionResult DownloadCurrentCalculationTable(int secondid)
{
var secondAllot = secondAllotService.GetSecondAllot(secondid);
if (null == secondAllot)
throw new PerformanceException("secondid不存在");
if (string.IsNullOrEmpty(secondAllot.AttachFile))
throw new PerformanceException("尚未上传文件");
if (!FileHelper.IsExistFile(secondAllot.AttachFile))
throw new PerformanceException("文件路径无效");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(secondAllot.AttachFile, FileMode.Open))
{
stream.CopyToAsync(memoryStream).Wait();
}
memoryStream.Seek(0, SeekOrigin.Begin);
var provider = new FileExtensionContentTypeProvider();
FileInfo fileInfo = new FileInfo(secondAllot.AttachFile);
var memi = provider.Mappings[".xlsx"];
return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
}
} }
} }
...@@ -275,6 +275,11 @@ ...@@ -275,6 +275,11 @@
<param name="end">结束月份:2021-04</param> <param name="end">结束月份:2021-04</param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AllotController.LogAllotAction(System.Int32,System.String,System.String)">
<summary>
记录创建、下发、归档、上传绩效
</summary>
</member>
<member name="M:Performance.Api.Controllers.AttendanceController.GetAttendance(System.Int32)"> <member name="M:Performance.Api.Controllers.AttendanceController.GetAttendance(System.Int32)">
<summary> <summary>
查询绩效考勤记录 查询绩效考勤记录
...@@ -2316,6 +2321,21 @@ ...@@ -2316,6 +2321,21 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.SecondAllotController.Import(Microsoft.AspNetCore.Http.IFormCollection)">
<summary>
二次绩效上传文件
</summary>
<param name="secondid"></param>
<param name="form"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SecondAllotController.DownloadCurrentCalculationTable(System.Int32)">
<summary>
二次绩效下载文件
</summary>
<param name="secondid"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.SheetController.SheetList(Performance.DtoModels.SheetRequest)"> <member name="M:Performance.Api.Controllers.SheetController.SheetList(Performance.DtoModels.SheetRequest)">
<summary> <summary>
sheet 列表 sheet 列表
......
...@@ -1180,6 +1180,16 @@ ...@@ -1180,6 +1180,16 @@
审计状态 1 已审计 审计状态 1 已审计
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ag_secondallot.AttachFile">
<summary>
文件路径
</summary>
</member>
<member name="P:Performance.EntityModels.ag_secondallot.AttachDate">
<summary>
文件上传时间
</summary>
</member>
<member name="T:Performance.EntityModels.ag_temp"> <member name="T:Performance.EntityModels.ag_temp">
<summary> <summary>
二次绩效模板 二次绩效模板
...@@ -5985,6 +5995,51 @@ ...@@ -5985,6 +5995,51 @@
归档日期 归档日期
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.Entity.per_allot_action">
<summary>
医院绩效分配
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_allot_action.Id">
<summary>
ID
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_allot_action.AllotId">
<summary>
绩效分配ID
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_allot_action.CreateDate">
<summary>
操作时间
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_allot_action.CreateUser">
<summary>
操作人
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_allot_action.FilePath">
<summary>
文件地址
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_allot_action.ActionName">
<summary>
操作名称
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_allot_action.ActionExplain">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_attendance_type.IsDeduction">
<summary>
是否核减出勤 1 核减 2 不核减
</summary>
</member>
<member name="T:Performance.EntityModels.per_apr_amount"> <member name="T:Performance.EntityModels.per_apr_amount">
<summary> <summary>
...@@ -6155,11 +6210,6 @@ ...@@ -6155,11 +6210,6 @@
审计状态 1 已审计 审计状态 1 已审计
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.Entity.per_attendance_type.IsDeduction">
<summary>
是否核减出勤 1 核减 2 不核减
</summary>
</member>
<member name="T:Performance.EntityModels.per_batch"> <member name="T:Performance.EntityModels.per_batch">
<summary> <summary>
分批发放记录 分批发放记录
......
...@@ -253,5 +253,6 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -253,5 +253,6 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<per_attendance> per_attendance { get; set; } public virtual DbSet<per_attendance> per_attendance { get; set; }
public virtual DbSet<per_attendance_type> per_attendance_type { get; set; } public virtual DbSet<per_attendance_type> per_attendance_type { get; set; }
public virtual DbSet<per_attendance_vacation> per_attendance_vacation { get; set; } public virtual DbSet<per_attendance_vacation> per_attendance_vacation { get; set; }
public virtual DbSet<per_allot_action> per_allot_action { get; set; }
} }
} }
...@@ -148,5 +148,13 @@ public class ag_secondallot ...@@ -148,5 +148,13 @@ public class ag_secondallot
public Nullable<int> MarkStatus { get; set; } public Nullable<int> MarkStatus { get; set; }
public Nullable<int> MarkUser { get; set; } public Nullable<int> MarkUser { get; set; }
public Nullable<DateTime> MarkTime { get; set; } public Nullable<DateTime> MarkTime { get; set; }
/// <summary>
/// 文件路径
/// </summary>
public string AttachFile { get; set; }
/// <summary>
/// 文件上传时间
/// </summary>
public Nullable<DateTime> AttachDate { get; set; }
} }
} }
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.EntityModels.Entity
{
/// <summary>
/// 医院绩效分配
/// </summary>
[Table("per_allot_action")]
public class per_allot_action
{
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 绩效分配ID
/// </summary>
public int AllotId { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public DateTime? CreateDate { get; set; }
/// <summary>
/// 操作人
/// </summary>
public int CreateUser { get; set; }
/// <summary>
/// 文件地址
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// 操作名称
/// </summary>
public string ActionName { get; set; }
/// <summary>
///
/// </summary>
public string ActionExplain { get; set; }
}
}
...@@ -23,9 +23,9 @@ public class view_check_dept ...@@ -23,9 +23,9 @@ public class view_check_dept
public class view_check_emp : view_check_dept public class view_check_emp : view_check_dept
{ {
public int ComputeId { get; set; }
public int UnitTypeId { get; set; } public int UnitTypeId { get; set; }
public int AccountID { get; set; } public int AccountID { get; set; }
public string JobNumber { get; set; } public string JobNumber { get; set; }
public string EmployeeName { get; set; } public string EmployeeName { get; set; }
} }
......
...@@ -64,12 +64,10 @@ public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(Compari ...@@ -64,12 +64,10 @@ public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(Compari
{ {
var queryData = $@" var queryData = $@"
SELECT SELECT
HospitalId,Year,Month,AllotID,UnitType,AccountingUnit,JobNumber,MAX(EmployeeName) AS EmployeeName, 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 SUM(RealGiveFeeExecl) AS RealGiveFeeExecl,SUM(RealGiveFeeCompute) AS RealGiveFeeCompute,SUM(RealGiveFeeExecl) - SUM(RealGiveFeeCompute) AS Diff
FROM ( FROM (
SELECT * FROM view_check_emp_clinic WHERE AllotId = @allotId UNION ALL SELECT * FROM view_check_emp WHERE AllotId = @allotId
SELECT * FROM view_check_emp_employee WHERE AllotId = @allotId UNION ALL
SELECT * FROM view_check_emp_logistics WHERE AllotId = @allotId
) TAB ) TAB
WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm OR if(@searchQuery='','',JobNumber) LIKE @parm OR if(@searchQuery='','',EmployeeName) LIKE @parm 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 GROUP BY HospitalId,Year,Month,AllotID,UnitType,AccountingUnit,JobNumber
...@@ -77,10 +75,8 @@ public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(Compari ...@@ -77,10 +75,8 @@ public DtoModels.Comparison<view_check_emp> CheckEmployeeRealGiveFeeDiff(Compari
"; ";
var queryCount = @" var queryCount = @"
SELECT COUNT(DISTINCT HospitalId,Year,Month,AllotID,UnitType,AccountingUnit,JobNumber) FROM ( SELECT COUNT(DISTINCT HospitalId,Year,Month,AllotID,ComputeId,UnitType,AccountingUnit,JobNumber) FROM (
SELECT * FROM view_check_emp_clinic WHERE AllotId = @allotId UNION ALL SELECT * FROM view_check_emp WHERE AllotId = @allotId
SELECT * FROM view_check_emp_employee WHERE AllotId = @allotId UNION ALL
SELECT * FROM view_check_emp_logistics WHERE AllotId = @allotId
) TAB ) TAB
WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm OR if(@searchQuery='','',JobNumber) LIKE @parm OR if(@searchQuery='','',EmployeeName) LIKE @parm WHERE if(@searchQuery='','',AccountingUnit) LIKE @parm OR if(@searchQuery='','',JobNumber) LIKE @parm OR if(@searchQuery='','',EmployeeName) LIKE @parm
"; ";
......
...@@ -387,7 +387,7 @@ public List<PerReport> NurseAvg(ReportRequest request) ...@@ -387,7 +387,7 @@ public List<PerReport> NurseAvg(ReportRequest request)
/// <returns></returns> /// <returns></returns>
public List<EmployeeReservedDto> GetEmployeeReserved(ReservedRequest request) public List<EmployeeReservedDto> GetEmployeeReserved(ReservedRequest request)
{ {
string view = request.Source == 1 ? "view_allot_result_report_emp" : request.Source == 2 ? "view_allot_result_report_issue": request.Source == 3 ? "view_allot_result_report":""; string view = request.Source == 1 ? "view_allot_result_report_emp" : request.Source == 2 ? "view_allot_result_report_issue_source" : request.Source == 3 ? "view_allot_result_report":"";
string sql = $"SELECT * FROM {view} WHERE HospitalID=@HospitalID AND Year=@Year"; string sql = $"SELECT * FROM {view} WHERE HospitalID=@HospitalID AND Year=@Year";
return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = request.HospitalId, Year = request.Year })?.ToList(); return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = request.HospitalId, Year = request.Year })?.ToList();
......
using Performance.EntityModels;
using Performance.EntityModels.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Repository.Repository
{
/// <summary>
/// per_allot_action Repository
/// </summary>
public partial class PerforPerAllotActionRepository : PerforRepository<per_allot_action>
{
public PerforPerAllotActionRepository(PerformanceDbContext context) : base(context)
{
}
}
}
using AutoMapper; using AutoMapper;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
...@@ -7,9 +9,11 @@ ...@@ -7,9 +9,11 @@
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
...@@ -53,6 +57,7 @@ public partial class SecondAllotService : IAutoInjection ...@@ -53,6 +57,7 @@ public partial class SecondAllotService : IAutoInjection
private readonly PerforCofagainRepository cofagainRepository; private readonly PerforCofagainRepository cofagainRepository;
private readonly ComputeService computeService; private readonly ComputeService computeService;
private readonly IWebHostEnvironment _evn;
private readonly PersonService personService; private readonly PersonService personService;
private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>(); private readonly List<ag_tempitem> tempitems = new List<ag_tempitem>();
...@@ -89,7 +94,8 @@ public partial class SecondAllotService : IAutoInjection ...@@ -89,7 +94,8 @@ public partial class SecondAllotService : IAutoInjection
//PerforAgcomputeRepository agcomputeRepository, //PerforAgcomputeRepository agcomputeRepository,
PerforCofagainRepository cofagainRepository, PerforCofagainRepository cofagainRepository,
PersonService personService, PersonService personService,
ComputeService computeService ComputeService computeService,
IWebHostEnvironment evn
) )
{ {
_mapper = mapper; _mapper = mapper;
...@@ -124,6 +130,7 @@ ComputeService computeService ...@@ -124,6 +130,7 @@ ComputeService computeService
//this.agcomputeRepository = agcomputeRepository; //this.agcomputeRepository = agcomputeRepository;
this.cofagainRepository = cofagainRepository; this.cofagainRepository = cofagainRepository;
this.computeService = computeService; this.computeService = computeService;
_evn = evn;
this.personService = personService; this.personService = personService;
} }
...@@ -1908,6 +1915,7 @@ public ag_secondallot GetSecondAllot(int secondId) ...@@ -1908,6 +1915,7 @@ public ag_secondallot GetSecondAllot(int secondId)
return agsecondallotRepository.GetEntity(t => t.Id == secondId); return agsecondallotRepository.GetEntity(t => t.Id == secondId);
} }
/// <summary> /// <summary>
/// 获取 列 /// 获取 列
/// </summary> /// </summary>
...@@ -2493,5 +2501,46 @@ private List<SecondPerforResponse> GetAllotPerformance(int allotId, List<res_com ...@@ -2493,5 +2501,46 @@ private List<SecondPerforResponse> GetAllotPerformance(int allotId, List<res_com
// return computes; // return computes;
//} //}
public ApiResponse Import(IFormCollection form)
{
var secondid = form.ToDictionary().GetValue("secondid", 0);
var agsecondallot = agsecondallotRepository.GetEntity(t => t.Id == secondid);
if (agsecondallot == null)
return new ApiResponse(ResponseType.Fail, "secondid不存在");
var allot = perallotRepository.GetEntity(t => t.ID == agsecondallot.AllotId);
if (allot == null)
return new ApiResponse(ResponseType.Fail, "allotid不存在");
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(_evn.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}");
using (var stream = file.OpenReadStream())
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
agsecondallot.AttachFile = path;
agsecondallot.AttachDate = DateTime.Now;
agsecondallotRepository.Update(agsecondallot);
return new ApiResponse(ResponseType.OK, $"{file.FileName}上传成功");
}
}
} }
} }
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