Commit b53eca2a by 李承祥

bug -- 部分列头无法获取

parent f118e442
......@@ -3,11 +3,14 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
......@@ -21,17 +24,20 @@ public class TemplateController : Controller
private HospitalService hospitalService;
private IHostingEnvironment evn;
private ClaimService claim;
private Application application;
public TemplateController(TemplateService templateService,
HospitalService hospitalService,
ExtractService extractService,
IHostingEnvironment evn,
ClaimService claim)
ClaimService claim,
IOptions<Application> options)
{
this.templateService = templateService;
this.extractService = extractService;
this.hospitalService = hospitalService;
this.evn = evn;
this.claim = claim;
this.application = options.Value;
}
/// <summary>
......@@ -80,7 +86,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
};
if (templateService.InsertFirst(template))
{
templateService.SendEmail(path, $"{hospital.HosName}首次上传模板", "上传成功");
templateService.SendEmail(application.Receiver.ToList(), path, $"{hospital.HosName}首次上传模板", "上传成功");
}
}
return new ApiResponse(ResponseType.OK);
......@@ -95,7 +101,16 @@ public ApiResponse Import([FromForm] IFormCollection form)
[HttpPost]
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);
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);
}
}
......
......@@ -12,13 +12,11 @@ namespace Performance.Services
{
public class TemplateService : IAutoInjection
{
private Application application;
private IEmailService emailService;
private PerforPerfirstRepository PerforPerfirstRepository;
public TemplateService(IOptions<Application> options, IEmailService emailService,
public TemplateService(IEmailService emailService,
PerforPerfirstRepository PerforPerfirstRepository)
{
this.application = options.Value;
this.emailService = emailService;
this.PerforPerfirstRepository = PerforPerfirstRepository;
}
......@@ -40,11 +38,11 @@ public bool InsertFirst(per_first first)
/// <param name="path"></param>
/// <param name="subject"></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
{
To = application.Receiver.ToList(),
To = receiver,
Attachments = new List<string> { path },
DisplayName = "溯直健康",
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