Commit b53eca2a by 李承祥

bug -- 部分列头无法获取

parent f118e442
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
...@@ -21,17 +24,20 @@ public class TemplateController : Controller ...@@ -21,17 +24,20 @@ public class TemplateController : Controller
private HospitalService hospitalService; private HospitalService hospitalService;
private IHostingEnvironment evn; private IHostingEnvironment evn;
private ClaimService claim; private ClaimService claim;
private Application application;
public TemplateController(TemplateService templateService, public TemplateController(TemplateService templateService,
HospitalService hospitalService, HospitalService hospitalService,
ExtractService extractService, ExtractService extractService,
IHostingEnvironment evn, IHostingEnvironment evn,
ClaimService claim) ClaimService claim,
IOptions<Application> options)
{ {
this.templateService = templateService; this.templateService = templateService;
this.extractService = extractService; this.extractService = extractService;
this.hospitalService = hospitalService; this.hospitalService = hospitalService;
this.evn = evn; this.evn = evn;
this.claim = claim; this.claim = claim;
this.application = options.Value;
} }
/// <summary> /// <summary>
...@@ -80,7 +86,7 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -80,7 +86,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
}; };
if (templateService.InsertFirst(template)) if (templateService.InsertFirst(template))
{ {
templateService.SendEmail(path, $"{hospital.HosName}首次上传模板", "上传成功"); templateService.SendEmail(application.Receiver.ToList(), path, $"{hospital.HosName}首次上传模板", "上传成功");
} }
} }
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
...@@ -95,7 +101,16 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -95,7 +101,16 @@ public ApiResponse Import([FromForm] IFormCollection form)
[HttpPost] [HttpPost]
public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Delete"), FromBody]HospitalRequest request) public ApiResponse ExtractData([CustomizeValidator(RuleSet = "Delete"), FromBody]HospitalRequest request)
{ {
var hospital = hospitalService.GetHopital(request.ID);
if (hospital == null)
return new ApiResponse(ResponseType.Fail, "hospitalid不存在");
var filePath = extractService.ExtractData(request.ID); var filePath = extractService.ExtractData(request.ID);
if (!string.IsNullOrEmpty(filePath) && FileHelper.IsExistFile(filePath))
{
var user = claim.At(request.Token);
templateService.SendEmail(new List<string> { user.Mail }, filePath, $"{hospital.HosName}提取数据", $"{hospital.HosName}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}成功提取。");
}
return new ApiResponse(ResponseType.OK, "OK", filePath); return new ApiResponse(ResponseType.OK, "OK", filePath);
} }
} }
......
...@@ -12,17 +12,15 @@ namespace Performance.Services ...@@ -12,17 +12,15 @@ namespace Performance.Services
{ {
public class TemplateService : IAutoInjection public class TemplateService : IAutoInjection
{ {
private Application application;
private IEmailService emailService; private IEmailService emailService;
private PerforPerfirstRepository PerforPerfirstRepository; private PerforPerfirstRepository PerforPerfirstRepository;
public TemplateService(IOptions<Application> options, IEmailService emailService, public TemplateService(IEmailService emailService,
PerforPerfirstRepository PerforPerfirstRepository) PerforPerfirstRepository PerforPerfirstRepository)
{ {
this.application = options.Value;
this.emailService = emailService; this.emailService = emailService;
this.PerforPerfirstRepository = PerforPerfirstRepository; this.PerforPerfirstRepository = PerforPerfirstRepository;
} }
/// <summary> /// <summary>
/// 添加数据 per_first /// 添加数据 per_first
/// </summary> /// </summary>
...@@ -40,11 +38,11 @@ public bool InsertFirst(per_first first) ...@@ -40,11 +38,11 @@ public bool InsertFirst(per_first first)
/// <param name="path"></param> /// <param name="path"></param>
/// <param name="subject"></param> /// <param name="subject"></param>
/// <param name="body"></param> /// <param name="body"></param>
public void SendEmail(string path, string subject, string body) public void SendEmail(List<string> receiver, string path, string subject, string body)
{ {
var message = new EmailMessage var message = new EmailMessage
{ {
To = application.Receiver.ToList(), To = receiver,
Attachments = new List<string> { path }, Attachments = new List<string> { path },
DisplayName = "溯直健康", DisplayName = "溯直健康",
Subject = subject, Subject = subject,
......
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