Blame view

web/WebMvc/Areas/Planned/Controllers/ImportController.cs 1.4 KB
赖素文 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using Hh.Mes.Service;
using Hh.Mes.Service.Planned;
using Hh.Mes.Service.SystemAuth;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;


namespace WebMvc.Areas.Planned.Controllers
{
    /// <summary>
    /// Excel导入 注意 Excel 页签名称和表名要求一致
    /// </summary>
    [Area("Planned")]
    public class ImportController : BaseController
    {
        private readonly ImportService  importService;
18
        private readonly IWebHostEnvironment hostingEnvironment;
赖素文 authored
19
20
        public ImportController(IAuth authUtil,ImportService  import, IWebHostEnvironment hosting) : base(authUtil)
赖素文 authored
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
        {
            this.importService = import;
            hostingEnvironment = hosting;
        }

        [ResponseCache(Duration = 60)]
        public IActionResult Index()
        {
            return View();
        }


        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="excelfile">表单提交的文件信息</param>
        /// <returns></returns>
        [HttpPost]
        public string Import(IFormFileCollection excelfile)
        {
41
            var response = importService.ImportIn(excelfile, hostingEnvironment.ContentRootPath);
赖素文 authored
42
43
44
45
46
47
48
49
50
51
            return Serialize(response);
        }

        [ResponseCache(Duration = 60)]
        public IActionResult IndexQRCode()
        {
            return View();
        }
    }
}